Lựa chọn của người dùng trong bản trình bày đang hoạt động.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
Phương thức
| Phương thức | Kiểu dữ liệu trả về | Mô tả ngắn |
|---|---|---|
get | Page|null | Trả về Page hoặc null hiện đang hoạt động nếu không có trang nào đang hoạt động. |
get | Page | Trả về tập hợp Page của các phiên bản Page được chọn hoặc null nếu không có phiên bản Page nào được chọn. |
get | Page | Trả về Page một tập hợp các thực thể Page trong dải băng được chọn hoặc null nếu lựa chọn không thuộc loại Selection. |
get | Selection | Trả về Selection. |
get | Table | Trả về tập hợp Table gồm các thực thể Table được chọn hoặc null nếu không có thực thể Table nào được chọn. |
get | Text | Trả về Text đã chọn hoặc null nếu lựa chọn không thuộc loại Selection. |
Tài liệu chi tiết
get Current Page()
Trả về Page hoặc null hiện đang hoạt động nếu không có trang nào đang hoạt động.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); if (currentPage != null) { Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
Cầu thủ trả bóng
Page|null
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Element Range()
Trả về tập hợp Page của các phiên bản Page được chọn hoặc null nếu không có phiên bản Page nào được chọn.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.PAGE_ELEMENT) { const currentPage = selection.getCurrentPage(); const pageElements = selection.getPageElementRange().getPageElements(); Logger.log(`Number of page elements selected: ${pageElements.length}`); }
Cầu thủ trả bóng
Page
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Range()
Trả về Page một tập hợp các thực thể Page trong dải băng được chọn hoặc null nếu lựa chọn không thuộc loại Selection.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.PAGE) { const pageRange = selection.getPageRange(); Logger.log( `Number of pages in the flimstrip selected: ${ pageRange.getPages().length}`, ); }
Cầu thủ trả bóng
Page
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Selection Type()
Trả về Selection.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.CURRENT_PAGE) { const currentPage = selection.getCurrentPage(); Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
Cầu thủ trả bóng
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Table Cell Range()
Trả về tập hợp Table gồm các thực thể Table được chọn hoặc null nếu không có thực thể Table nào được chọn.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.TABLE_CELL) { const currentPage = selection.getCurrentPage(); const tableCells = selection.getTableCellRange().getTableCells(); const table = tableCells[0].getParentTable(); Logger.log(`Number of table cells selected: ${tableCells.length}`); }
Cầu thủ trả bóng
Table
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Text Range()
Trả về Text đã chọn hoặc null nếu lựa chọn không thuộc loại Selection.
Text đại diện cho hai trường hợp:
1. Phạm vi văn bản được chọn. Ví dụ: nếu một hình dạng có văn bản "Xin chào" và bạn chọn "Xin", thì dải ô được trả về sẽ có Text = 0 và Text = 2.
2. Vị trí con trỏ. Ví dụ: nếu một hình dạng có văn bản "Hello" và con trỏ nằm sau "H" ("H|ello"), thì dải ô được trả về sẽ có Text = 1 và Text = 1.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.TEXT) { const currentPage = selection.getCurrentPage(); const pageElement = selection.getPageElementRange().getPageElements()[0]; const textRange = selection.getTextRange(); Logger.log(`Text selected: ${textRange.asString()}`); }
Cầu thủ trả bóng
Text
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations