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 را برمی‌گرداند.

مستندات دقیق

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 Element Range (Page Element Range) از نمونه‌های Page Element (Page Element) که انتخاب شده‌اند را برمی‌گرداند و در صورت عدم انتخاب هیچ نمونه‌ی Page Element 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}`);
}

بازگشت

Page Element Range |null

مجوز

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

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

get Page Range()

Page Range مجموعه‌ای از نمونه‌های Page instances) در نوار لغزنده (flimstrip) را برمی‌گرداند که انتخاب شده‌اند یا اگر انتخاب از نوع Selection Type.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}`,
  );
}

بازگشت

Page Range |null

مجوز

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

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

get Selection Type()

Selection Type برمی‌گرداند.

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

بازگشت

Selection Type

مجوز

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

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

get Table Cell Range()

مجموعه‌ی Table Cell Range Cell Range) از نمونه‌های Table Cell که انتخاب شده‌اند را برمی‌گرداند یا در صورت عدم انتخاب هیچ نمونه Table Cell 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}`);
}

بازگشت

Table Cell Range |null

مجوز

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

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

get Text Range()

Text Range انتخاب شده را برمی‌گرداند یا اگر انتخاب از نوع Selection Type.TEXT نباشد، null را برمی‌گرداند.

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

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

۲. موقعیت مکان‌نما. برای مثال، اگر یک شکل دارای متن "Hello" باشد و مکان‌نما بعد از "H" ("H|ello") باشد، محدوده‌ی بازگشتی دارای Text Range.getStartIndex() = ۱ و Text Range.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()}`);
}

بازگشت

Text Range |null

مجوز

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

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