اختيار المستخدم في العرض التقديمي النشط
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
الطُرق
| الطريقة | نوع القيمة التي تم إرجاعها | وصف قصير |
|---|---|---|
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. |
مستندات تفصيلية
getCurrentPage()
تعرض هذه السمة 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
getPageElementRange()
تعرِض هذه الدالة مجموعة PageElementRange من مثيلات PageElement التي تم اختيارها أو null إذا لم يتم اختيار أي مثيل PageElement.
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}`); }
الإرجاع
PageElementRange|null
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getPageRange()
تعرض هذه السمة PageRange، وهي مجموعة من مثيلات Page في شريط الصور الذي تم اختياره، أو null إذا لم يكن الاختيار من النوع SelectionType.PAGE.
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}`, ); }
الإرجاع
PageRange|null
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getSelectionType()
تعرض SelectionType.
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
getTableCellRange()
تعرِض هذه الدالة مجموعة TableCellRange من مثيلات TableCell التي تم اختيارها أو null إذا لم يتم اختيار أي مثيلات TableCell.
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}`); }
الإرجاع
TableCellRange|null
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getTextRange()
تعرض هذه الدالة TextRange الذي تم اختياره أو null إذا لم يكن الاختيار من النوع SelectionType.TEXT.
يمثّل الرمز TextRange سيناريوهَين:
1. نطاق النص المحدّد على سبيل المثال، إذا كان الشكل يتضمّن النص "Hello" وتم اختيار "He"،
سيكون النطاق المعروض TextRange.getStartIndex() = 0 وTextRange.getEndIndex() =
2.
2. موضع المؤشر على سبيل المثال، إذا كان الشكل يتضمّن النص "Hello" وكان المؤشر بعد "H"،
("H|ello")، سيتضمّن النطاق المعروض TextRange.getStartIndex() = 1 وTextRange.getEndIndex() = 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()}`); }
الإرجاع
TextRange|null
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations