Contains the text of the document. Document can be attached to several EditSession
s. At its core, Document
s are just an array of strings, with each row in the document matching up to the array index.
Contains the text of the document. Document can be attached to several EditSession
s. At its core, Document
s are just an array of strings, with each row in the document matching up to the array index.
Fires whenever the document changes.
Fires whenever the document changes.
Several methods trigger different "change"
events. Below is a list of each action type, followed by each property that's also available:
"insertLines"
(emitted by Document.insertLines()
)range
: the Range
of the change within the documentlines
: the lines in the document that are changing"insertText"
(emitted by Document.insertNewLine()
)range
: the Range
of the change within the documenttext
: the text that's being added"removeLines"
(emitted by Document.insertLines()
)range
: the Range
of the change within the documentlines
: the lines in the document that were removednl
: the new line character (as defined by Document.getNewLineCharacter()
)"removeText"
(emitted by Document.removeInLine()
and Document.removeNewLine()
)range
: the Range
of the change within the documenttext
: the text that's being removede | Object | Required. Contains at least one property called |
Splits a string of text on any newline (\n
) or carriage-return ('\r') characters.
Applies all the changes previously accumulated. These can be either 'includeText'
, 'insertLines'
, 'removeText'
, and 'removeLines'
.
Applies all the changes previously accumulated. These can be either 'includeText'
, 'insertLines'
, 'removeText'
, and 'removeLines'
.
Returns all lines in the document as string array. Warning: The caller should not modify this array!
Returns all lines in the document as string array. Warning: The caller should not modify this array!
Returns the number of rows in the document.
Returns the number of rows in the document.
Returns an array of strings of the rows between firstRow
and lastRow
. This function is inclusive of lastRow
.
Returns the newline character that's being used, depending on the value of newLineMode
.
Returns the newline character that's being used, depending on the value of newLineMode
.
String | If
|
Returns the type of newlines being used; either windows
, unix
, or auto
Returns the type of newlines being used; either windows
, unix
, or auto
Given a range within the document, this function returns all the text within that range as a single string.
Given a range within the document, this function returns all the text within that range as a single string.
range | Range | Required. The range to work with |
Returns all the lines in the document as a single string, split by the new line character.
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 text
into the position
at the current row. This method also triggers the 'change'
event.
position | Number | Required. The position to insert at |
text | String | Required. A chunk of text |
Object | Returns an object containing the final row and column, like this:
|
Number | If |
Inserts the elements in lines
into the document, starting at the row index given by 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 triggers the 'change'
event.
row | Number | Required. The index of the row to insert at |
lines | Array | Required. An array of strings |
Object | Returns an object containing the final row and column, like this:
|
Inserts a new line into the document at the current row's position
. This method also triggers the 'change'
event.
Removes the range
from the document.
Removes the specified columns from the row
. This method also triggers the 'change'
event.
Removes the specified columns from the row
. This method also triggers the 'change'
event.
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 |
Object | Returns an object containing |
Removes a range of full lines. This method also triggers the 'change'
event.
Removes the new line between row
and the row immediately following it. This method also triggers the 'change'
event.
Removes the new line between row
and the row immediately following it. This method also triggers the 'change'
event.
row | Number | Required. The row to check |
Replaces a range in the document with the new text
.
Replaces a range in the document with the new text
.
range | Range | Required. A specified Range to replace |
text | String | Required. The new text to use as a replacement |
Object | Returns an object containing the final row and column, like this:
|
Reverts any changes previously applied. These can be either 'includeText'
, 'insertLines'
, 'removeText'
, and 'removeLines'
.
Reverts any changes previously applied. These can be either 'includeText'
, 'insertLines'
, 'removeText'
, and 'removeLines'
.