UNPKG

gas-types-detailed

Version:

Detailed Google Apps Script Type Definitions. Forked from Definitely Typed @types/google-apps-script. Adds full documentation and urls.

1,250 lines (1,145 loc) 493 kB
// Type definitions for Google Apps Script 2023-10-28 // 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. * var highlightStyle = {}; * highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00'; * highlightStyle[DocumentApp.Attribute.BOLD] = true; * * // Insert "Hello", highlighted. * DocumentApp.getActiveDocument().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 } /** * An element representing a document body. 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 document contents except for the HeaderSection, FooterSection, and any FootnoteSection elements. * * var doc = DocumentApp.getActiveDocument(); * var body = doc.getBody(); * * // Append a paragraph and a page break to the document 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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. * * * var body = DocumentApp.getActiveDocument().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); * 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. * 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. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Define the search parameters. * var searchType = DocumentApp.ElementType.PARAGRAPH; * var searchHeading = DocumentApp.ParagraphHeading.HEADING1; * var searchResult = null; * * // Search until the paragraph is found. * while (searchResult = body.findElement(searchType, searchResult)) { * var par = searchResult.getElement().asParagraph(); * if (par.getHeading() == searchHeading) { * // Found one, update and stop. * par.setText('This is the first header.'); * return; * } * } * 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. * 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. * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Append a styled paragraph. * var par = body.appendParagraph('A bold, italicized paragraph.'); * par.setBold(true); * par.setItalic(true); * * // Retrieve the paragraph's attributes. * var atts = par.getAttributes(); * * // Log the paragraph attributes. * for (var att in atts) { * Logger.log(att + ":" + atts[att]); * } * https://developers.google.com/apps-script/reference/document/body#getAttributes() */ getAttributes(): any; /** * Retrieves the child element at the specified child index. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Obtain the first element in the document. * var 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."); * } * 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. * 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. * https://developers.google.com/apps-script/reference/document/body#getHeadingAttributes(ParagraphHeading) * @param paragraphHeading the heading whose attributes will be retrieved */ getHeadingAttributes(paragraphHeading: ParagraphHeading): any; /** * Retrieves all the InlineImages contained in the section. * https://developers.google.com/apps-script/reference/document/body#getImages() */ getImages(): InlineImage[]; /** * Retrieves all the ListItems contained in the section. * https://developers.google.com/apps-script/reference/document/body#getListItems() */ getListItems(): ListItem[]; /** * Retrieves the bottom margin, in points. * https://developers.google.com/apps-script/reference/document/body#getMarginBottom() */ getMarginBottom(): number; /** * Retrieves the left margin, in points. * https://developers.google.com/apps-script/reference/document/body#getMarginLeft() */ getMarginLeft(): number; /** * Retrieves the right margin. * https://developers.google.com/apps-script/reference/document/body#getMarginRight() */ getMarginRight(): number; /** * Retrieves the top margin. * https://developers.google.com/apps-script/reference/document/body#getMarginTop() */ getMarginTop(): number; /** * Retrieves the number of children. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Log the number of elements in the document. * Logger.log("There are " + body.getNumChildren() + * " elements in the document body."); * https://developers.google.com/apps-script/reference/document/body#getNumChildren() */ getNumChildren(): Integer; /** * Retrieves the page height, in points. * https://developers.google.com/apps-script/reference/document/body#getPageHeight() */ getPageHeight(): number; /** * Retrieves the page width, in points. * https://developers.google.com/apps-script/reference/document/body#getPageWidth() */ getPageWidth(): number; /** * Retrieves all the Paragraphs contained in the section (including ListItems). * 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. * https://developers.google.com/apps-script/reference/document/body#getParent() */ getParent(): ContainerElement; /** * Retrieves all the Tables contained in the section. * https://developers.google.com/apps-script/reference/document/body#getTables() */ getTables(): Table[]; /** * Retrieves the contents of the element as a text string. * 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. * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Obtain the first element in the document body. * * var 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.'); * } * 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. * 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. * 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. * 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. * 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. * 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. * 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. * 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 p[age break to insert */ insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak; /** * Inserts the given Paragraph at the specified index. * 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. * 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. * 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. * 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. * 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. * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Clear the text surrounding "Apps Script", with or without text. * body.replaceText("^.*Apps ?Script.*$", "Apps Script"); * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Define a custom paragraph style. * var 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. * var par = body.appendParagraph('A paragraph with custom style.'); * * // Apply the custom style. * par.setAttributes(style); * 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. * https://developers.google.com/apps-script/reference/document/body#setHeadingAttributes(ParagraphHeading,Object) * @param paragraphHeading the heading whose attributes will 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. * 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. * 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. * https://developers.google.com/apps-script/reference/document/body#setMarginRight(Number) * @param marginRight the right margin */ setMarginRight(marginRight: number): Body; /** * Sets the top margin. * 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. * 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. * 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. * 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 be superscript. * var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); * text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT); * 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. * * // Insert a bookmark at the cursor position and log its ID. * var doc = DocumentApp.getActiveDocument(); * var cursor = doc.getCursor(); * var bookmark = doc.addBookmark(cursor); * Logger.log(bookmark.getId()); */ interface Bookmark { /** * Gets the ID of the Bookmark. The ID is unique within the document. * https://developers.google.com/apps-script/reference/document/bookmark#getId() */ getId(): string; /** * Gets the Position of the Bookmark within the Document. The Position remains accurate so long as the Bookmark is not deleted, even if the script * changes the document structure. * https://developers.google.com/apps-script/reference/document/bookmark#getPosition() */ getPosition(): Position; /** * Deletes the Bookmark. Calling this method on a Bookmark that has already been * deleted has no effect. * https://developers.google.com/apps-script/reference/document/bookmark#remove() */ remove(): void; } /** * A generic element that may contain other elements. All elements that may contain child elements, * such as Paragraph, inherit from ContainerElement. */ interface ContainerElement extends Element { /** * Returns the current element as a Body. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asBody() */ asBody(): Body; /** * Returns the current element as an Equation. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asEquation() */ asEquation(): Equation; /** * Returns the current element as a FooterSection. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asFooterSection() */ asFooterSection(): FooterSection; /** * Returns the current element as a FootnoteSection. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asFootnoteSection() */ asFootnoteSection(): FootnoteSection; /** * Returns the current element as a HeaderSection. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asHeaderSection() */ asHeaderSection(): HeaderSection; /** * Returns the current element as a ListItem. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asListItem() */ asListItem(): ListItem; /** * Returns the current element as a Paragraph. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asParagraph() */ asParagraph(): Paragraph; /** * Returns the current element as a Table. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asTable() */ asTable(): Table; /** * Returns the current element as a TableCell. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asTableCell() */ asTableCell(): TableCell; /** * Returns the current element as a TableOfContents. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asTableOfContents() */ asTableOfContents(): TableOfContents; /** * Returns the current element as a TableRow. * * * Use this method to aid auto-complete whenever a given element is known to be of a specific * type. * https://developers.google.com/apps-script/reference/document/container-element#asTableRow() */ asTableRow(): TableRow; /** * Clears the contents of the element. * https://developers.google.com/apps-script/reference/document/container-element#clear() */ clear(): ContainerElement; /** * 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. * https://developers.google.com/apps-script/reference/document/container-element#copy() */ copy(): ContainerElement; /** * 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. * * * var body = DocumentApp.getActiveDocument().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); * https://developers.google.com/apps-script/reference/document/container-element#editAsText() */ editAsText(): Text; /** * Searches the contents of the element for a descendant of the specified type. * https://developers.google.com/apps-script/reference/document/container-element#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. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Define the search parameters. * var searchType = DocumentApp.ElementType.PARAGRAPH; * var searchHeading = DocumentApp.ParagraphHeading.HEADING1; * var searchResult = null; * * // Search until the paragraph is found. * while (searchResult = body.findElement(searchType, searchResult)) { * var par = searchResult.getElement().asParagraph(); * if (par.getHeading() == searchHeading) { * // Found one, update and stop. * par.setText('This is the first header.'); * return; * } * } * https://developers.google.com/apps-script/reference/document/container-element#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. * https://developers.google.com/apps-script/reference/document/container-element#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. * https://developers.google.com/apps-script/reference/document/container-element#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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Append a styled paragraph. * var par = body.appendParagraph('A bold, italicized paragraph.'); * par.setBold(true); * par.setItalic(true); * * // Retrieve the paragraph's attributes. * var atts = par.getAttributes(); * * // Log the paragraph attributes. * for (var att in atts) { * Logger.log(att + ":" + atts[att]); * } * https://developers.google.com/apps-script/reference/document/container-element#getAttributes() */ getAttributes(): any; /** * Retrieves the child element at the specified child index. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Obtain the first element in the document. * var 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."); * } * https://developers.google.com/apps-script/reference/document/container-element#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. * https://developers.google.com/apps-script/reference/document/container-element#getChildIndex(Element) * @param child the child element for which to retrieve the index */ getChildIndex(child: Element): Integer; /** * Retrieves the link url. * https://developers.google.com/apps-script/reference/document/container-element#getLinkUrl() */ getLinkUrl(): string; /** * Retrieves the element's next sibling element. * * * The next sibling has the same parent and follows the current element. * https://developers.google.com/apps-script/reference/document/container-element#getNextSibling() */ getNextSibling(): Element; /** * Retrieves the number of children. * * * // Get the body section of the active document. * var body = DocumentApp.getActiveDocument().getBody(); * * // Log the number of elements in the document. * Logger.log("There are " + body.getNumChildren() + * " elements in the document body."); * https://developers.google.com/apps-script/reference/document/container-element#getNumChildren() */ getNumChildren(): Integer; /** * Retrieves the element's parent element. * * * The parent element contains the current element. * https://developers.google.com/apps-script/reference/document/container-element#getParent() */ getParent(): ContainerElement; /** * Retrieves the element's previous sibling element. * * * The previous sibling has the same parent and precedes the current element. * https://developers.google.com/apps-script/reference/document/container-element#getPreviousSibling() */ getPreviousSibling(): Element; /** * Retrieves the contents of the element as a text string. * https://developers.google.com/apps-script/reference/document/container-element#getText() */ getText(): string; /** * Gets the text alignment. The available types of alignment are DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, and DocumentApp.TextAlignment.SUPERSCRIPT. * https://developers.google.com/apps-script/reference/document/container-element#getTextAlignment() */ getTextAlignment(): TextAlignment; /** * Retrieves the element's ElementType. * * * Use getType() to determine the exact type of a given element. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Obtain the first element in the document body. * * var 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.'); * } * https://developers.google.com/apps-script/reference/document/container-element#getType() */ getType(): ElementType; /** * Determines whether the element is at the end of the Document. * https://developers.google.com/apps-script/reference/document/container-element#isAtDocumentEnd() */ isAtDocumentEnd(): boolean; /** * Merges the element with the preceding sibling of the same type. * * * Only elements of the same ElementType can be merged. Any child elements contained in * the current element are moved to the preceding sibling element. * * * The current element is removed from the document. * * * var body = DocumentApp.getActiveDocument().getBody(); * // Example 1: Merge paragraphs * // Append two paragraphs to the document. * var par1 = body.appendParagraph('Paragraph 1.'); * var par2 = body.appendParagraph('Paragraph 2.'); * // Merge the newly added paragraphs into a single paragraph. * par2.merge(); * * // Example 2: Merge table cells * // Create a two-dimensional array containing the table's cell contents. * var cells = [ * ['Row 1, Cell 1', 'Row 1, Cell 2'], * ['Row 2, Cell 1', 'Row 2, Cell 2'] * ]; * // Build a table from the array. * var table = body.appendTable(cells); * // Get the first row in the table. * var row = table.getRow(0); * // Get the two cells in this row. * var cell1 = row.getCell(0); * var cell2 = row.getCell(1); * // Merge the current cell into its preceding sibling element. * var merged = cell2.merge(); * https://developers.google.com/apps-script/reference/document/container-element#merge() */ merge(): ContainerElement; /** * Removes the element from its parent. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Remove all images in the document body. * var imgs = body.getImages(); * for (var i = 0; i < imgs.length; i++) { * imgs[i].removeFromParent(); * } * https://developers.google.com/apps-script/reference/document/container-element#removeFromParent() */ removeFromParent(): ContainerElement; /** * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Clear the text surrounding "Apps Script", with or without text. * body.replaceText("^.*Apps ?Script.*$", "Apps Script"); * https://developers.google.com/apps-script/reference/document/container-element#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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Define a custom paragraph style. * var 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. * var par = body.appendParagraph('A paragraph with custom style.'); * * // Apply the custom style. * par.setAttributes(style); * https://developers.google.com/apps-script/reference/document/container-element#setAttributes(Object) * @param attributes The element's attributes. */ setAttributes(attributes: any): ContainerElement; /** * Sets the link url. * https://developers.google.com/apps-script/reference/document/container-element#setLinkUrl(String) * @param url the link url */ setLinkUrl(url: string): ContainerElement; /** * 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 be superscript. * var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); * text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT); * https://developers.google.com/apps-script/reference/document/container-element#setTextAlignment(TextAlignment) * @param textAlignment the type of text alignment to apply */ setTextAlignment(textAlignment: TextAlignment): ContainerElement; } /** * An element representing a formatted date */ interface Date { /** * 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. * https://developers.google.com/apps-script/reference/document/date#copy() */ copy(): Date; /** * 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. * * * var body = DocumentApp.getActiveDocument().getBody(); * * // Append a styled parag