Pilihan pengguna dalam presentasi aktif.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
Metode
| Metode | Jenis hasil yang ditampilkan | Deskripsi singkat |
|---|---|---|
get | Page|null | Menampilkan Page yang saat ini aktif atau null jika tidak ada halaman yang aktif. |
get | Page | Menampilkan koleksi Page dari instance Page yang dipilih atau null jika tidak ada instance Page yang dipilih. |
get | Page | Menampilkan Page kumpulan instance Page dalam flimstrip yang dipilih atau null jika pilihan bukan berjenis Selection. |
get | Selection | Menampilkan Selection. |
get | Table | Menampilkan kumpulan Table dari instance Table yang dipilih
atau null jika tidak ada instance Table yang dipilih. |
get | Text | Menampilkan Text yang dipilih atau null jika pilihan bukan berjenis
Selection. |
Dokumentasi mendetail
get Current Page()
Menampilkan Page yang saat ini aktif atau null jika tidak ada halaman yang aktif.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); if (currentPage != null) { Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
Pulang pergi
Page|null
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Element Range()
Menampilkan koleksi Page dari instance Page yang dipilih atau null jika tidak ada instance Page yang dipilih.
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}`); }
Pulang pergi
Page
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Range()
Menampilkan Page kumpulan instance Page dalam flimstrip yang dipilih atau null jika pilihan bukan berjenis 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}`, ); }
Pulang pergi
Page
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Selection Type()
Menampilkan 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()}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Table Cell Range()
Menampilkan kumpulan Table dari instance Table yang dipilih
atau null jika tidak ada instance Table yang dipilih.
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}`); }
Pulang pergi
Table
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Text Range()
Menampilkan Text yang dipilih atau null jika pilihan bukan berjenis
Selection.
Text mewakili dua skenario:
1. Rentang teks yang dipilih. Misalnya, jika bentuk memiliki teks "Hello", dan "He" dipilih,
rentang yang ditampilkan memiliki Text = 0, dan Text =
2.
2. Posisi kursor. Misalnya, jika bentuk memiliki teks "Hello", dan kursor berada setelah "H",
("H|ello"), rentang yang ditampilkan memiliki Text = 1 dan 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()}`); }
Pulang pergi
Text
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations