Private
$clipConverts an index position in a document to a {row, column}
object.
Index refers to the "absolute position" of a character in the document. For example:
var x = 0; // 10 characters, plus one for newline
var y = -1;
Here, y
is an index 15: 11 characters for the first row, and 5 characters until y
in the second.
An index to convert
Optional
startRow: numberThe row from which to start the conversion
A {row, column}
object of the index
position
Inserts a block of text
at the indicated position
.
The position to start inserting at; it's an object that looks like { row: row, column: column}
A chunk of text to insert
The position ({row, column}) of the last line of text
. If the length of text
is 0, this function simply returns position
.
Inserts the elements in lines
into the document as full lines (does not merge with existing line), starting at the row index given by row
. This method also triggers the "change"
event.
The index of the row to insert at
An array of strings
Inserts text
into the position
at the current row. This method also triggers the "change"
event.
This differs from the insert
method in two ways:
insert
method for single-line text insertions.The position to insert at; it's an object that looks like { row: row, column: column}
A chunk of text without new lines
Returns the position of the end of the inserted text
Inserts the elements in lines
into the document, starting at the position index given by row
. This method also triggers the "change"
event.
An array of strings
Contains 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}
Converts the {row, column}
position in a document to the character's index.
Index refers to the "absolute position" of a character in the document. For example:
var x = 0; // 10 characters, plus one for newline
var y = -1;
Here, y
is an index 15: 11 characters for the first row, and 5 characters until y
in the second.
The {row, column}
to convert
Optional
startRow: numberThe row from which to start the conversion
The index position in the document
Removes the specified columns from the row
. This method also triggers a "change"
event.
The row to remove from
The column to start removing at
The column to stop removing at
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
.
A specified Range to replace
The new text to use as a replacement
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.
Generated using TypeDoc
Contains the text of the document. Document can be attached to several [[EditSession
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.