הבחירה של המשתמש במצגת הפעילה.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
Methods
| שיטה | סוג הערך שמוחזר | תיאור קצר |
|---|---|---|
get | Page|null | מחזירה את Page או null שפעילים כרגע, אם אין דף פעיל. |
get | Page | הפונקציה מחזירה את אוסף Page של מופעי Page שנבחרו, או null אם לא נבחרו מופעי Page. |
get | Page | הפונקציה מחזירה את Page אוסף של Page מופעים ברצועת התמונות הממוזערות שנבחרו או null אם הבחירה לא מהסוג Selection. |
get | Selection | הפונקציה מחזירה את הערך Selection. |
get | Table | הפונקציה מחזירה את אוסף Table של מופעי Table שנבחרו או null אם לא נבחרו מופעי Table. |
get | Text | הפונקציה מחזירה את הערך Text שנבחר או את הערך null אם הבחירה היא לא מסוג Selection. |
תיעוד מפורט
get Current Page()
מחזירה את Page או null שפעילים כרגע, אם אין דף פעיל.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); if (currentPage != null) { Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
חזרה
Page|null
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Element Range()
הפונקציה מחזירה את אוסף Page של מופעי Page שנבחרו, או null אם לא נבחרו מופעי Page.
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}`); }
חזרה
Page
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Range()
הפונקציה מחזירה את Page אוסף של Page מופעים ברצועת התמונות הממוזערות שנבחרו או null אם הבחירה לא מהסוג 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}`, ); }
חזרה
Page
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Selection Type()
הפונקציה מחזירה את הערך 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()}`); }
חזרה
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Table Cell Range()
הפונקציה מחזירה את אוסף Table של מופעי Table שנבחרו או null אם לא נבחרו מופעי Table.
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}`); }
חזרה
Table
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Text Range()
הפונקציה מחזירה את הערך Text שנבחר או את הערך null אם הבחירה היא לא מסוג Selection.
הערך Text מייצג שני תרחישים:
1. טווח הטקסט שנבחר. לדוגמה, אם לצורה יש טקסט 'Hello' ונבחר הטקסט 'He', הטווח שמוחזר הוא Text = 0 ו-Text = 2.
2. מיקום הסמן. לדוגמה, אם לצורה יש טקסט 'Hello', והסמן נמצא אחרי 'H' ('H|ello'), הטווח שמוחזר הוא Text = 1 ו-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()}`); }
חזרה
Text
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations