Class Selection

चुना गया

उपयोगकर्ता ने ऐक्टिव प्रज़ेंटेशन में क्या चुना है.

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

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
getCurrentPage()Page|nullअगर कोई पेज चालू नहीं है, तो फ़िलहाल चालू Page या null दिखाता है.
getPageElementRange()PageElementRange|nullयह फ़ंक्शन, चुने गए PageElementRange इंस्टेंस का PageElementRange कलेक्शन या null दिखाता है. ऐसा तब होता है, जब कोई PageElement इंस्टेंस नहीं चुना जाता.PageElement
getPageRange()PageRange|nullयह फ़्लिमस्ट्रिप में मौजूद Page इंस्टेंस का PageRange कलेक्शन दिखाता है. ये इंस्टेंस चुने गए हैं या null अगर चुना गया इंस्टेंस SelectionType.PAGE टाइप का नहीं है.
getSelectionType()SelectionTypeSelectionType दिखाता है.
getTableCellRange()TableCellRange|nullयह फ़ंक्शन, चुने गए TableCellRange इंस्टेंस का TableCellRange कलेक्शन दिखाता है. अगर कोई TableCell इंस्टेंस नहीं चुना गया है, तो यह null दिखाता है.TableCell
getTextRange()TextRange|nullयह फ़ंक्शन, चुनी गई TextRange या null दिखाता है. हालांकि, ऐसा तब होता है, जब चुना गया विकल्प SelectionType.TEXT टाइप का न हो.

ज़्यादा जानकारी वाला दस्तावेज़

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 इंस्टेंस का PageElementRange कलेक्शन या null दिखाता है. ऐसा तब होता है, जब कोई PageElement इंस्टेंस नहीं चुना जाता.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()

यह फ़्लिमस्ट्रिप में मौजूद Page इंस्टेंस का PageRange कलेक्शन दिखाता है. ये इंस्टेंस चुने गए हैं या 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()}`);
}

वापसी का टिकट

SelectionType

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:

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

getTableCellRange()

यह फ़ंक्शन, चुने गए TableCellRange इंस्टेंस का 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