Class Bookmark

書籤

代表書籤的物件。

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();

// Insert a bookmark at the cursor position (in the active tab) and log its ID.
const cursor = doc.getCursor();
const bookmark = documentTab.addBookmark(cursor);
Logger.log(bookmark.getId());

方法

方法傳回類型簡短說明
getId()String取得 Bookmark 的 ID。
getPosition()Position取得 DocumentTabBookmarkBookmarkPosition
remove()void刪除 Bookmark

內容詳盡的說明文件

getId()

取得 Bookmark 的 ID。ID 在 DocumentTab 中不得重複。

回攻員

StringBookmark 的 ID,在 DocumentTab 內不得重複。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

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

getPosition()

取得 DocumentTabBookmarkBookmarkPosition只要 Bookmark 未刪除,即使指令碼變更文件結構,Position 仍會保持準確。

回攻員

Position - Bookmark 的位置。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

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

remove()

刪除 Bookmark。如果 Bookmark 已遭刪除,呼叫這個方法不會產生任何效果。

授權

使用這個方法的指令碼需要下列一或多個範圍的授權:

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