Class Selection

انتخاب

انتخاب کاربر در ارائه فعال.

const selection = SlidesApp.getActivePresentation().getSelection();
const currentPage = selection.getCurrentPage();
const selectionType = selection.getSelectionType();

روش‌ها

روش نوع بازگشتی شرح مختصر
get Current Page() Page |null Page فعال فعلی را برمی‌گرداند و در صورت عدم وجود صفحه فعال، null برمی‌گرداند.
get Page Element Range() Page Element Range |null مجموعه‌ی Page Element Range (Page Element Range) از نمونه‌های Page Element (Page Element) که انتخاب شده‌اند را برمی‌گرداند و در صورت عدم انتخاب هیچ نمونه Page Element null برمی‌گرداند.
get Page Range() Page Range |null Page Range مجموعه‌ای از نمونه‌های Page instances) در نوار لغزنده (flimstrip) را برمی‌گرداند که انتخاب شده‌اند یا اگر انتخاب از نوع Selection Type.PAGE نباشد، null می‌شوند.
get Selection Type() Selection Type Selection Type برمی‌گرداند.
get Table Cell Range() Table Cell Range |null مجموعه‌ی Table Cell Range Cell Range) از نمونه‌های Table Cell که انتخاب شده‌اند را برمی‌گرداند یا در صورت عدم انتخاب هیچ نمونه Table Cell null را برمی‌گرداند.
get Text Range() Text Range |null Text Range انتخاب شده را برمی‌گرداند یا اگر انتخاب از نوع Selection Type.TEXT نباشد، null را برمی‌گرداند.

مستندات دقیق

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 که انتخاب شده‌اند را برمی‌گرداند یا در صورت عدم انتخاب هیچ نمونه PageElement null را برمی‌گرداند.

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 در flimstrip را برمی‌گرداند که انتخاب شده‌اند یا اگر انتخاب از نوع SelectionType.PAGE نباشد null .

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()}`);
}

بازگشت

SelectionType

مجوز

اسکریپت‌هایی که از این روش استفاده می‌کنند، نیاز به مجوز با یک یا چند مورد از حوزه‌های زیر دارند:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTableCellRange()

مجموعه TableCellRange از نمونه‌های TableCell که انتخاب شده‌اند را برمی‌گرداند یا در صورت عدم انتخاب هیچ نمونه TableCell null را برمی‌گرداند.

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 انتخاب شده را برمی‌گرداند یا اگر انتخاب از نوع SelectionType.TEXT نباشد null را برمی‌گرداند.

TextRange دو سناریو را نشان می‌دهد:

۱. محدوده متن انتخاب شده. برای مثال، اگر یک شکل متن "Hello" داشته باشد و "He" انتخاب شده باشد، محدوده برگردانده شده دارای TextRange.getStartIndex() = 0 و TextRange.getEndIndex() = 2 خواهد بود.

۲. موقعیت مکان‌نما. برای مثال، اگر یک شکل دارای متن "Hello" باشد و مکان‌نما بعد از "H" ("H|ello") باشد، محدوده‌ی بازگشتی دارای TextRange.getStartIndex() = ۱ و TextRange.getEndIndex() = ۱ خواهد بود.

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