활성 프레젠테이션에서 사용자의 선택사항입니다.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
메서드
| 메서드 | 반환 유형 | 간략한 설명 |
|---|---|---|
get | Page | 활성 페이지가 없는 경우 현재 활성 Page 또는 null을 반환합니다. |
get | Page | 선택된 Page 인스턴스의 Page 컬렉션을 반환하거나 선택된 Page 인스턴스가 없는 경우 null을 반환합니다. |
get | Page | 선택된 필름 스트립의 Page 인스턴스 컬렉션인 Page을 반환하거나 선택이 Selection 유형이 아닌 경우 null을 반환합니다. |
get | Selection | Selection를 반환합니다. |
get | Table | 선택된 Table 인스턴스의 Table 컬렉션을 반환하거나 선택된 Table 인스턴스가 없는 경우 null을 반환합니다. |
get | Text | 선택된 Text를 반환하거나 선택이 Selection 유형이 아닌 경우 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()}`); }
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Element Range()
선택된 Page 인스턴스의 Page 컬렉션을 반환하거나 선택된 Page 인스턴스가 없는 경우 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}`); }
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Range()
선택된 필름 스트립의 Page 인스턴스 컬렉션인 Page을 반환하거나 선택이 Selection 유형이 아닌 경우 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}`, ); }
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 컬렉션을 반환하거나 선택된 Table 인스턴스가 없는 경우 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}`); }
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Text Range()
선택된 Text를 반환하거나 선택이 Selection 유형이 아닌 경우 null을 반환합니다.
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()}`); }
리턴
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations