اختيار المستخدم في العرض التقديمي النشط
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. |
مستندات تفصيلية
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