gas-types-detailed
Version:
Enhanced Google Apps Script Type Definitions with detailed documentation. Includes type definitions plus code snippets, return values, required authorization scopes, and other details not found in @types/google-apps-script.
1,247 lines (1,182 loc) • 837 kB
TypeScript
// Type definitions for Google Apps Script 2025-11-10
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.base.d.ts" />
declare namespace GoogleAppsScript {
namespace Document {
/**
* An enumeration of the element attributes.
*
* To call an enum, you call its parent class, name, and property. For example,
* DocumentApp.Attribute.BACKGROUND_COLOR.
*
* Use attributes to compose custom styles. For example:
*
* // Define a style with yellow background.
* const highlightStyle = {};
* highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
* highlightStyle[DocumentApp.Attribute.BOLD] = true;
*
* // Insert "Hello", highlighted.
* DocumentApp.getActiveDocument()
* .getActiveTab()
* .asDocumentTab()
* .editAsText()
* .insertText(0, 'Hello\n')
* .setAttributes(0, 4, highlightStyle);
*/
enum Attribute { BACKGROUND_COLOR, BOLD, BORDER_COLOR, BORDER_WIDTH, CODE, FONT_FAMILY, FONT_SIZE, FOREGROUND_COLOR, HEADING, HEIGHT, HORIZONTAL_ALIGNMENT, INDENT_END, INDENT_FIRST_LINE, INDENT_START, ITALIC, GLYPH_TYPE, LEFT_TO_RIGHT, LINE_SPACING, LINK_URL, LIST_ID, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, NESTING_LEVEL, MINIMUM_HEIGHT, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, PAGE_HEIGHT, PAGE_WIDTH, SPACING_AFTER, SPACING_BEFORE, STRIKETHROUGH, UNDERLINE, VERTICAL_ALIGNMENT, WIDTH }
/**
* The content of a tab in a Google Docs document. The Body may contain ListItem,
* Paragraph, Table, and TableOfContents elements. For more information on
* document structure, see the guide to
* extending Google Docs.
*
* The Body typically contains the full tab's contents except for the HeaderSection, FooterSection, and any FootnoteSection elements.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Append a paragraph and a page break to the tab's body section directly.
* body.appendParagraph('A paragraph.');
* body.appendPageBreak();
*/
interface Body extends Element {
/**
* Creates and appends a new HorizontalRule.
* The HorizontalRule will be contained in a new Paragraph.
*
* Return:
* - HorizontalRule — The new horizontal rule.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendHorizontalRule()
*/
appendHorizontalRule(): HorizontalRule;
/**
* Creates and appends a new InlineImage from the specified image blob.
* The image will be contained in a new Paragraph.
*
* Return:
* - InlineImage — The appended image.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendImage(BlobSource)
* @param image The image data.
*/
appendImage(image: Base.BlobSource): InlineImage;
/**
* Appends the given InlineImage.
* The InlineImage will be contained in a new Paragraph.
* Use this version of appendImage when appending a copy of an existing InlineImage.
*
* Return:
* - InlineImage — The appended image.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendImage(InlineImage)
* @param image The image data.
*/
appendImage(image: InlineImage): InlineImage;
/**
* Appends the given ListItem.
* Use this version of appendListItem when appending a copy of an existing ListItem.
*
* Return:
* - ListItem — The appended list item.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendListItem(ListItem)
* @param listItem The list item to append.
*/
appendListItem(listItem: ListItem): ListItem;
/**
* Creates and appends a new ListItem containing the specified text contents.
* Consecutive list items are added as part of the same list.
*
* Return:
* - ListItem — The new list item.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendListItem(String)
* @param text The list item's text contents.
*/
appendListItem(text: string): ListItem;
/**
* Creates and appends a new PageBreak.
* The PageBreak will be contained in a new Paragraph.
*
* Return:
* - PageBreak — The new page break.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendPageBreak()
*/
appendPageBreak(): PageBreak;
/**
* Appends the given PageBreak.
* The PageBreak will be contained in a new Paragraph.
* Use this version of appendPageBreak when appending a copy of an existing PageBreak.
*
* Return:
* - PageBreak — The appended page break.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendPageBreak(PageBreak)
* @param pageBreak The page break to append.
*/
appendPageBreak(pageBreak: PageBreak): PageBreak;
/**
* Appends the given Paragraph.
* Use this version of appendParagraph when appending a copy of an existing Paragraph.
*
* Return:
* - Paragraph — The appended paragraph.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendParagraph(Paragraph)
* @param paragraph The paragraph to append.
*/
appendParagraph(paragraph: Paragraph): Paragraph;
/**
* Creates and appends a new Paragraph containing the specified text contents.
*
* Return:
* - Paragraph — The new paragraph.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendParagraph(String)
* @param text The paragraph's text contents.
*/
appendParagraph(text: string): Paragraph;
/**
* Creates and appends a new Table.
* This method will also append an empty paragraph after the table, since Google Docs documents cannot end with a table.
*
* Return:
* - Table — The new table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendTable()
*/
appendTable(): Table;
/**
* Appends a new Table containing a TableCell for each specified string value.
* This method will also append an empty paragraph after the table, since Google Docs documents cannot end with a table.
*
* Return:
* - Table — The appended table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendTable(String)
* @param cells The text contents of the table cells to add to the new table.
*/
appendTable(cells: string[][]): Table;
/**
* Appends the given Table.
* Use this version of appendTable when appending a copy of an existing Table. This method will also append an empty paragraph after the table, since Google Docs documents cannot end with a table.
*
* Return:
* - Table — The appended table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#appendTable(Table)
* @param table The table to append.
*/
appendTable(table: Table): Table;
/**
* Clears the contents of the element.
*
* Return:
* - Body — The current element.
*
* https://developers.google.com/apps-script/reference/document/body#clear()
*/
clear(): Body;
/**
* Returns a detached, deep copy of the current element.
* Any child elements present in the element are also copied. The new element doesn't have a parent.
*
* Return:
* - Body — The new copy.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#copy()
*/
copy(): Body;
/**
* Obtains a Text version of the current element, for editing.
* Use editAsText for manipulating the elements contents as rich text. The editAsText mode ignores non-text elements (such as InlineImage and HorizontalRule).
* Child elements fully contained within a deleted text range are removed from the element.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Insert two paragraphs separated by a paragraph containing an
* // horizontal rule.
* body.insertParagraph(0, 'An editAsText sample.');
* body.insertHorizontalRule(0);
* body.insertParagraph(0, 'An example.');
*
* // Delete " sample.\n\n An" removing the horizontal rule in the process.
* body.editAsText().deleteText(14, 25);
*
* Return:
* - Text — a text version of the current element
*
* https://developers.google.com/apps-script/reference/document/body#editAsText()
*/
editAsText(): Text;
/**
* Searches the contents of the element for a descendant of the specified type.
*
* Return:
* - RangeElement — A search result indicating the position of the search element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#findElement(ElementType)
* @param elementType The type of element to search for.
*/
findElement(elementType: ElementType): RangeElement;
/**
* Searches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Define the search parameters.
*
* let searchResult = null;
*
* // Search until the paragraph is found.
* while (
* (searchResult = body.findElement(
* DocumentApp.ElementType.PARAGRAPH,
* searchResult,
* ))) {
* const par = searchResult.getElement().asParagraph();
* if (par.getHeading() === DocumentApp.ParagraphHeading.HEADING1) {
* // Found one, update and stop.
* par.setText('This is the first header.');
* break;
* }
* }
*
* Return:
* - RangeElement — A search result indicating the next position of the search element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#findElement(ElementType,RangeElement)
* @param elementType The type of element to search for.
* @param from The search result to search from.
*/
findElement(elementType: ElementType, from: RangeElement): RangeElement;
/**
* Searches the contents of the element for the specified text pattern using regular expressions.
* A subset of the JavaScript regular expression features are not fully supported, such as capture groups and mode modifiers.
* The provided regular expression pattern is independently matched against each text block contained in the current element.
*
* Return:
* - RangeElement — a search result indicating the position of the search text, or null if there is no match
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#findText(String)
* @param searchPattern the pattern to search for
*/
findText(searchPattern: string): RangeElement;
/**
* Searches the contents of the element for the specified text pattern, starting from a given search result.
* A subset of the JavaScript regular expression features are not fully supported, such as capture groups and mode modifiers.
* The provided regular expression pattern is independently matched against each text block contained in the current element.
*
* Return:
* - RangeElement — a search result indicating the next position of the search text, or null if there is no match
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#findText(String,RangeElement)
* @param searchPattern the pattern to search for
* @param from the search result to search from
*/
findText(searchPattern: string, from: RangeElement): RangeElement;
/**
* Retrieves the element's attributes.
* The result is an object containing a property for each valid element attribute where each property name corresponds to an item in the DocumentApp.Attribute enumeration.
*
* 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]}`);
* }
*
* Return:
* - Object — The element's attributes.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getAttributes()
*/
getAttributes(): any;
/**
* Retrieves the child element at the specified child index.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Obtain the first element in the tab.
* const firstChild = body.getChild(0);
*
* // If it's a paragraph, set its contents.
* if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) {
* firstChild.asParagraph().setText('This is the first paragraph.');
* }
*
* Return:
* - Element — The child element at the specified index.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getChild(Integer)
* @param childIndex The index of the child element to retrieve.
*/
getChild(childIndex: Integer): Element;
/**
* Retrieves the child index for the specified child element.
*
* Return:
* - Integer — The child index.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getChildIndex(Element)
* @param child The child element for which to retrieve the index.
*/
getChildIndex(child: Element): Integer;
/**
* Retrieves the set of attributes for the provided ParagraphHeading.
*
* Return:
* - Object — A map of the attributes and their current values.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getHeadingAttributes(ParagraphHeading)
* @param paragraphHeading The heading whose attributes should be retrieved.
*/
getHeadingAttributes(paragraphHeading: ParagraphHeading): any;
/**
* Retrieves all the InlineImages contained in the section.
*
* Return:
* - InlineImage[] — The section images.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getImages()
*/
getImages(): InlineImage[];
/**
* Retrieves all the ListItems contained in the section.
*
* Return:
* - ListItem[] — The section list items.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getListItems()
*/
getListItems(): ListItem[];
/**
* Retrieves the bottom margin, in points.
*
* Return:
* - Number — The bottom margin, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getMarginBottom()
*/
getMarginBottom(): number;
/**
* Retrieves the left margin, in points.
*
* Return:
* - Number — The left margin, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getMarginLeft()
*/
getMarginLeft(): number;
/**
* Retrieves the right margin.
*
* Return:
* - Number — The right margin, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getMarginRight()
*/
getMarginRight(): number;
/**
* Retrieves the top margin.
*
* Return:
* - Number — The top margin, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getMarginTop()
*/
getMarginTop(): number;
/**
* Retrieves the number of children.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Log the number of elements in the tab.
* Logger.log(`There are ${body.getNumChildren()} elements in the tab's body.`);
*
* Return:
* - Integer — The number of children.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getNumChildren()
*/
getNumChildren(): Integer;
/**
* Retrieves the page height, in points.
*
* Return:
* - Number — The page height, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getPageHeight()
*/
getPageHeight(): number;
/**
* Retrieves the page width, in points.
*
* Return:
* - Number — The page width, in points.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getPageWidth()
*/
getPageWidth(): number;
/**
* Retrieves all the Paragraphs contained in the section (including ListItems).
*
* Return:
* - Paragraph[] — The section paragraphs.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getParagraphs()
*/
getParagraphs(): Paragraph[];
/**
* Retrieves the element's parent element.
* The parent element contains the current element.
*
* Return:
* - ContainerElement — The parent element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getParent()
*/
getParent(): ContainerElement;
/**
* Retrieves all the Tables contained in the section.
*
* Return:
* - Table[] — The section tables.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getTables()
*/
getTables(): Table[];
/**
* Retrieves the contents of the element as a text string.
*
* Return:
* - String — the contents of the element as text string
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getText()
*/
getText(): string;
/**
* Gets the text alignment. The available types of alignment are DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, and DocumentApp.TextAlignment.SUPERSCRIPT.
*
* Return:
* - TextAlignment — the type of text alignment, or null if the text contains multiple types of text alignments or if the text alignment has never been set
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getTextAlignment()
*/
getTextAlignment(): TextAlignment;
/**
* Retrieves the element's ElementType.
* Use getType() to determine the exact type of a given element.
*
* 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.');
* }
*
* Return:
* - ElementType — The element type.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#getType()
*/
getType(): ElementType;
/**
* Creates and inserts a new HorizontalRule at the specified index.
* The HorizontalRule will be contained in a new Paragraph.
*
* Return:
* - HorizontalRule — The new horizontal rule.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertHorizontalRule(Integer)
* @param childIndex The index at which to insert the element.
*/
insertHorizontalRule(childIndex: Integer): HorizontalRule;
/**
* Creates and inserts an InlineImage from the specified image blob, at the specified index.
*
* Return:
* - InlineImage — The inserted inline image.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertImage(Integer,BlobSource)
* @param childIndex The index at which to insert the element.
* @param image The image data.
*/
insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
/**
* Inserts the given InlineImage at the specified index.
* The image will be contained in a new Paragraph.
*
* Return:
* - InlineImage — The inserted inline image.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertImage(Integer,InlineImage)
* @param childIndex The index at which to insert the element.
* @param image The image to insert.
*/
insertImage(childIndex: Integer, image: InlineImage): InlineImage;
/**
* Inserts the given ListItem at the specified index.
*
* Return:
* - ListItem — The inserted list item.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertListItem(Integer,ListItem)
* @param childIndex The index at which to insert.
* @param listItem The list item to insert.
*/
insertListItem(childIndex: Integer, listItem: ListItem): ListItem;
/**
* Creates and inserts a new ListItem at the specified index, containing the specified text contents.
*
* Return:
* - ListItem — The new list item.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertListItem(Integer,String)
* @param childIndex The index at which to insert.
* @param text The list item's text contents.
*/
insertListItem(childIndex: Integer, text: string): ListItem;
/**
* Creates and inserts a new PageBreak at the specified index.
* The PageBreak will be contained in a new Paragraph.
*
* Return:
* - PageBreak — The new page break.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertPageBreak(Integer)
* @param childIndex The index at which to insert the element.
*/
insertPageBreak(childIndex: Integer): PageBreak;
/**
* Inserts the given PageBreak at the specified index.
* The PageBreak will be contained in a new Paragraph.
*
* Return:
* - PageBreak — The inserted page break.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertPageBreak(Integer,PageBreak)
* @param childIndex The index at which to insert the element.
* @param pageBreak The page break to insert.
*/
insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak;
/**
* Inserts the given Paragraph at the specified index.
*
* Return:
* - Paragraph — The inserted paragraph.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertParagraph(Integer,Paragraph)
* @param childIndex The index at which to insert.
* @param paragraph The paragraph to insert.
*/
insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph;
/**
* Creates and inserts a new Paragraph at the specified index, containing the specified text contents.
*
* Return:
* - Paragraph — The new paragraph.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertParagraph(Integer,String)
* @param childIndex The index at which to insert.
* @param text The paragraph's text contents.
*/
insertParagraph(childIndex: Integer, text: string): Paragraph;
/**
* Creates and inserts a new Table at the specified index.
*
* Return:
* - Table — The new table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertTable(Integer)
* @param childIndex The index at which to insert.
*/
insertTable(childIndex: Integer): Table;
/**
* Creates and inserts a new Table containing the specified cells, at the specified index.
*
* Return:
* - Table — The new table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertTable(Integer,String)
* @param childIndex The index at which to insert.
* @param cells The text contents of the table cells to add to the new table.
*/
insertTable(childIndex: Integer, cells: string[][]): Table;
/**
* Inserts the given Table at the specified index.
*
* Return:
* - Table — The inserted table.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#insertTable(Integer,Table)
* @param childIndex The index at which to insert.
* @param table The table to insert.
*/
insertTable(childIndex: Integer, table: Table): Table;
/**
* Removes the specified child element.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#removeChild(Element)
* @param child The child element to remove.
*/
removeChild(child: Element): Body;
/**
* Replaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
* The search pattern is passed as a string, not a JavaScript regular expression object. Because of this you'll need to escape any backslashes in the pattern.
* This methods uses Google's RE2 regular expression library, which limits the supported syntax.
* The provided regular expression pattern is independently matched against each text block contained in the current element.
*
* const body =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
*
* // Clear the text surrounding "Apps Script", with or without text.
* body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
*
* Return:
* - Element — the current element
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#replaceText(String,String)
* @param searchPattern the regex pattern to search for
* @param replacement the text to use as replacement
*/
replaceText(searchPattern: string, replacement: string): Element;
/**
* Sets the element's attributes.
* The specified attributes parameter must be an object where each property name is an item in the DocumentApp.Attribute enumeration and each property value is the new value to be applied.
*
* 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);
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setAttributes(Object)
* @param attributes The element's attributes.
*/
setAttributes(attributes: any): Body;
/**
* Sets the attributes for the provided ParagraphHeading.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setHeadingAttributes(ParagraphHeading,Object)
* @param paragraphHeading The heading whose attributes should be set.
* @param attributes A map of attributes and the values to set them to.
*/
setHeadingAttributes(paragraphHeading: ParagraphHeading, attributes: any): Body;
/**
* Sets the bottom margin, in points.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setMarginBottom(Number)
* @param marginBottom The bottom margin, in points.
*/
setMarginBottom(marginBottom: number): Body;
/**
* Sets the left margin, in points.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setMarginLeft(Number)
* @param marginLeft The left margin, in points.
*/
setMarginLeft(marginLeft: number): Body;
/**
* Sets the right margin, in points.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setMarginRight(Number)
* @param marginRight The right margin.
*/
setMarginRight(marginRight: number): Body;
/**
* Sets the top margin.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setMarginTop(Number)
* @param marginTop The top margin, in points.
*/
setMarginTop(marginTop: number): Body;
/**
* Sets the page height, in points.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setPageHeight(Number)
* @param pageHeight The page height, in points.
*/
setPageHeight(pageHeight: number): Body;
/**
* Sets the page width, in points.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setPageWidth(Number)
* @param pageWidth The page width, in points.
*/
setPageWidth(pageWidth: number): Body;
/**
* Sets the contents as plain text.
* Note: existing contents are cleared.
*
* Return:
* - Body — The current element.
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setText(String)
* @param text The new text contents.
*/
setText(text: string): Body;
/**
* Sets the text alignment. The available types of alignment are DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, and DocumentApp.TextAlignment.SUPERSCRIPT.
*
* // Make the entire first paragraph in the active tab be superscript.
* const documentTab =
* DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
* const text = documentTab.getBody().getParagraphs()[0].editAsText();
* text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
*
* Return:
* - Body — the current element
*
* Authorization:
*
* Scripts that use this method require authorization with one or more of the following scopes:
* - https://www.googleapis.com/auth/documents.currentonly
* - https://www.googleapis.com/auth/documents
*
* https://developers.google.com/apps-script/reference/document/body#setTextAlignment(TextAlignment)
* @param textAlignment the type of text alignment to apply
*/
setTextAlignment(textAlignment: TextAlignment): Body;
/** @deprecated DO NOT USE */ getFootnotes(): Footnote[];
/** @deprecated DO NOT USE */ getLinkUrl(): string;
/** @deprecated DO NOT USE */ getNextSibling(): Element;
/** @deprecated DO NOT USE */ getPreviousSibling(): Element;
/** @deprecated DO NOT USE */ isAtDocumentEnd(): boolean;
/** @deprecated DO NOT USE */ setLinkUrl(url: string): Body;
}
/**
* An object representing a 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());
*/
interface Bookmark {
/**
* Gets the ID of the Bookmark. The ID is unique within t