Class Selection

Seçim

Kullanıcının etkin sunudaki seçimi.

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

Yöntemler

YöntemDönüş türüKısa açıklama
getCurrentPage()Page|nullEtkin bir sayfa yoksa şu anda etkin olan Page veya null değerini döndürür.
getPageElementRange()PageElementRange|nullSeçilen PageElementRange örneklerinin PageElement koleksiyonunu veya PageElement örnek seçilmemişse null değerini döndürür.
getPageRange()PageRange|nullSeçilen film şeridindeki PageRange bir Page örnekleri koleksiyonunu veya seçim SelectionType.PAGE türünde değilse null değerini döndürür.
getSelectionType()SelectionTypeSelectionType değerini döndürür.
getTableCellRange()TableCellRange|nullSeçilen TableCellRange örneklerin TableCell koleksiyonunu veya null seçilen TableCell örnek yoksa döndürür.
getTextRange()TextRange|nullSeçilen TextRange değerini veya seçim SelectionType.TEXT türünde değilse null değerini döndürür.

Ayrıntılı belgeler

getCurrentPage()

Etkin bir sayfa yoksa şu anda etkin olan Page veya null değerini döndürür.

const selection = SlidesApp.getActivePresentation().getSelection();
const currentPage = selection.getCurrentPage();
if (currentPage != null) {
  Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`);
}

Return

Page|null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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

getPageElementRange()

Seçilen PageElementRange örneklerinin PageElement koleksiyonunu veya PageElement örnek seçilmemişse null değerini döndürür.

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

Return

PageElementRange|null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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

getPageRange()

Seçilen film şeridindeki PageRange bir Page örnekleri koleksiyonunu veya seçim SelectionType.PAGE türünde değilse null değerini döndürür.

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

Return

PageRange|null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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

getSelectionType()

SelectionType değerini döndürür.

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

Return

SelectionType

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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

getTableCellRange()

Seçilen TableCellRange örneklerin TableCell koleksiyonunu veya null seçilen TableCell örnek yoksa döndürür.

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

Return

TableCellRange|null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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

getTextRange()

Seçilen TextRange değerini veya seçim SelectionType.TEXT türünde değilse null değerini döndürür.

TextRange, iki senaryoyu temsil eder:

1. Seçilen metin aralığı. Örneğin, bir şekilde "Merhaba" metni varsa ve "He" seçiliyse döndürülen aralıkta TextRange.getStartIndex() = 0 ve TextRange.getEndIndex() = 2 olur.

2. İmleç konumu Örneğin, bir şekilde "Merhaba" metni varsa ve imleç "M"den sonra ise ("M|erhaba"), döndürülen aralıkta TextRange.getStartIndex() = 1 ve TextRange.getEndIndex() = 1 olur.

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

Return

TextRange|null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:

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