Contains the text of the document. Documents are controlled by a single EditSession. At its core, Documents are just an array of strings, with each row in the document matching up to the array index.
Document[edit]
Constructors
Methods
-
- Document.applyDeltas(deltas)
-
- Void
Applies all the changes previously accumulated. These can be either 'includeText', 'insertLines', 'removeText'...
-
- Document.getAllLines()
-
- [ String ]
Returns all lines in the document as string array. Warning: The caller should not modify this array! ...
-
- Document.getLength()
Returns the number of rows in the document. ...
-
- Document.getNewLineMode()
Returns the type of newlines being used; either windows, unix, or auto
-
- Document.getValue()
Returns all the lines in the document as a single string, split by the new line character. ...
Inserts text into the position at the current row. This method also triggers the 'change' event. ...
Inserts the elements in lines into the document, starting at the row index given by row. This method also trigge...
Arguments
| row | Number | Required. The index of the row to insert at |
| lines | Array | Required. An array of strings |
Returns
| Object | Returns an object containing the final row and column, like this:{row: endRow, column: 0}If lines is empty, this function returns an object containing the current row, and column, like this:{row: row, column: 0} |
Removes the specified columns from the row. This method also triggers the 'change' event. ...
Arguments
| row | Number | Required. The row to remove from |
| startColumn | Number | Required. The column to start removing at |
| endColumn | Number | Required. The column to stop removing at |
Returns
| Object | Returns an object containing startRow and startColumn, indicating the new row and column values.If startColumn is equal to endColumn, this function returns nothing. |
Replaces a range in the document with the new text. ...
Arguments
| range | Range | Required. A specified Range to replace |
| text | String | Required. The new text to use as a replacement |
Returns
| Object | Returns an object containing the final row and column, like this: {row: endRow, column: 0} If the text and range are empty, this function returns an object containing the current range.start value. If the text is the exact same as what currently exists, this function returns an object containing the current range.end value. |
-
- Document.revertDeltas(deltas)
-
- Void
Reverts any changes previously applied. These can be either 'includeText', 'insertLines', 'removeText', and `'...