表示脚注的元素。每个 Footnote 都包含在 List 或 Paragraph 中,并且具有相应的 Footnote 元素来表示脚注的内容。Footnote 本身不能包含任何其他元素。如需详细了解文档结构,请参阅扩展 Google 文档的指南。
方法
| 方法 | 返回类型 | 简介 | 
|---|---|---|
| copy() | Footnote | 返回当前元素的脱离式深层副本。 | 
| get | Object | 检索元素的属性。 | 
| get | Footnote | 检索脚注元素的内容。 | 
| get | Element | 检索元素的下一个同级元素。 | 
| get | Container | 检索元素的父元素。 | 
| get | Element | 检索元素的上一个同级元素。 | 
| get | Element | 检索元素的 Element。 | 
| is | Boolean | 确定元素是否位于 Document的末尾。 | 
| remove | Footnote | 从其父元素中移除元素。 | 
| set | Footnote | 设置元素的属性。 | 
详细文档
copy()
get
检索元素的属性。
结果是一个对象,其中包含每个有效元素属性的属性,每个属性名称对应于 Document 枚举中的项。
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
返回
Object - 元素的属性。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents
get
检索脚注元素的内容。
返回
Footnote - 脚注部分
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents
get
get
检索元素的父元素。
父元素包含当前元素。
返回
Container - 父元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents
get
get
检索元素的 Element。
使用 get 确定给定元素的确切类型。
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Obtain the first element in the active tab's body. const firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
返回
Element - 元素类型。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents
is
remove
从其父元素中移除元素。
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Remove all images in the active tab's body. const imgs = body.getImages(); for (let i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
返回
Footnote - 移除的元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents
set
设置元素的属性。
指定的 attributes 参数必须是对象,其中每个属性名称都是 Document 枚举中的项,每个属性值都是要应用的新值。
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Define a custom paragraph style. const style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. const par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| attributes | Object | 元素的属性。 | 
返回
Footnote - 当前元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/documents.currentonly
- 
https://www.googleapis.com/auth/documents