<divclass="memberContent"><p>Contains the text of the document. Document can be attached to several <ahref="edit_session.html"class="link-short"title="EditSession (class)"data-id="EditSession"><code>EditSession</code></a>s. </p>
<p>At its core, <code>Document</code>s are just an array of strings, with each row in the document matching up to the array index.</p>
<divid="ellipsis_Document.new"class="ellipsis_description"><p>Creates a new <code>Document</code>. If <code>text</code> is included, the <code>Document</code> contains those strings; otherwise, it's empty.</p>
</div>
<divclass="description"><p>Creates a new <code>Document</code>. If <code>text</code> is included, the <code>Document</code> contains those strings; otherwise, it's empty.</p>
<divid="ellipsis_Document.event.change"class="ellipsis_description"><p>Fires whenever the document changes.</p>
</div>
<divclass="description"><p>Fires whenever the document changes.</p>
<p>Several methods trigger different <code>"change"</code> events. Below is a list of each action type, followed by each property that's also available:</p>
<ul>
<li><code>"insertLines"</code> (emitted by <ahref="#Document.insertLines"class="link-short"title="Document.insertLines (class method)"data-id="Document.insertLines"><code>Document.insertLines()</code></a>)</li>
<li><code>range</code>: the <ahref="range.html"class="link-short"title="Range (class)"data-id="Range"><code>Range</code></a> of the change within the document</li>
<li><code>lines</code>: the lines in the document that are changing</li>
<li><code>"insertText"</code> (emitted by <ahref="#Document.insertNewLine"class="link-short"title="Document.insertNewLine (class method)"data-id="Document.insertNewLine"><code>Document.insertNewLine()</code></a>)</li>
<li><code>range</code>: the <ahref="range.html"class="link-short"title="Range (class)"data-id="Range"><code>Range</code></a> of the change within the document</li>
<li><code>text</code>: the text that's being added</li>
<li><code>"removeLines"</code> (emitted by <ahref="#Document.insertLines"class="link-short"title="Document.insertLines (class method)"data-id="Document.insertLines"><code>Document.insertLines()</code></a>)</li>
<li><code>range</code>: the <ahref="range.html"class="link-short"title="Range (class)"data-id="Range"><code>Range</code></a> of the change within the document</li>
<li><code>lines</code>: the lines in the document that were removed</li>
<li><code>nl</code>: the new line character (as defined by <ahref="#Document.getNewLineCharacter"class="link-short"title="Document.getNewLineCharacter (class method)"data-id="Document.getNewLineCharacter"><code>Document.getNewLineCharacter()</code></a>)</li>
<li><code>"removeText"</code> (emitted by <ahref="#Document.removeInLine"class="link-short"title="Document.removeInLine (class method)"data-id="Document.removeInLine"><code>Document.removeInLine()</code></a> and <ahref="#Document.removeNewLine"class="link-short"title="Document.removeNewLine (class method)"data-id="Document.removeNewLine"><code>Document.removeNewLine()</code></a>)</li>
<li><code>range</code>: the <ahref="range.html"class="link-short"title="Range (class)"data-id="Range"><code>Range</code></a> of the change within the document</li>
<li><code>text</code>: the text that's being removed</li>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">e</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"class=""title="Object"data-id="Object">Object</a></td><tdclass="argDescription "><p>Required. Contains at least one property called <code>"action"</code>. <code>"action"</code> indicates the action that triggered the change. Each action also has a set of additional properties.</p>
<divid="ellipsis_Document.applyDeltas"class="ellipsis_description"><p>Applies all the changes previously accumulated. These can be either <code>'includeText'</code>, <code>'insertLines'</code>, <code>'removeText'</code>, and <code>'removeLines'</code>.</p>
</div>
<divclass="description"><p>Applies all the changes previously accumulated. These can be either <code>'includeText'</code>, <code>'insertLines'</code>, <code>'removeText'</code>, and <code>'removeLines'</code>.</p>
<divid="ellipsis_Document.createAnchor"class="ellipsis_description"><p>Creates a new <code>Anchor</code> to define a floating point in the document.</p>
</div>
<divclass="description"><p>Creates a new <code>Anchor</code> to define a floating point in the document.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">row</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The row number to use</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">column</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The column number to use</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">row</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The row index to retrieve</p>
<divid="ellipsis_Document.getLines"class="ellipsis_description"><p>Returns an array of strings of the rows between <code>firstRow</code> and <code>lastRow</code>. This function is inclusive of <code>lastRow</code>.</p>
</div>
<divclass="description"><p>Returns an array of strings of the rows between <code>firstRow</code> and <code>lastRow</code>. This function is inclusive of <code>lastRow</code>.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">firstRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The first row index to retrieve</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">lastRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The final row index to retrieve</p>
<divid="ellipsis_Document.getNewLineCharacter"class="ellipsis_description"><p>Returns the newline character that's being used, depending on the value of <code>newLineMode</code>.</p>
</div>
<divclass="description"><p>Returns the newline character that's being used, depending on the value of <code>newLineMode</code>.</p>
<divid="ellipsis_Document.getNewLineMode"class="ellipsis_description"><p>Returns the type of newlines being used; either <code>windows</code>, <code>unix</code>, or <code>auto</code></p>
</div>
<divclass="description"><p>Returns the type of newlines being used; either <code>windows</code>, <code>unix</code>, or <code>auto</code></p>
<divid="ellipsis_Document.getTextRange"class="ellipsis_description"><p>Given a range within the document, this function returns all the text within that range as a single string.</p>
</div>
<divclass="description"><p>Given a range within the document, this function returns all the text within that range as a single string.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">range</td><tdclass="argType""><ahref="range.html"class=""title="Range (class)"data-id="Range">Range</a></td><tdclass="argDescription "><p>Required. The range to work with</p>
<divid="ellipsis_Document.getValue"class="ellipsis_description"><p>Returns all the lines in the document as a single string, split by the new line character.</p>
</div>
<divclass="description"><p>Returns all the lines in the document as a single string, split by the new line character.</p>
<divid="ellipsis_Document.indexToPosition"class="ellipsis_description"><p>Converts an index position in a document to a <code>{row, column}</code> object.</p>
</div>
<divclass="description"><p>Converts an index position in a document to a <code>{row, column}</code> object.</p>
<p>Index refers to the "absolute position" of a character in the document. For example:</p>
<pre><codeclass="language-javascript"><spanclass="keyword">var</span> x = <spanclass="number">0</span>; <spanclass="comment">// 10 characters, plus one for newline</span>
<spanclass="keyword">var</span> y = -<spanclass="number">1</span>;</code></pre>
<p>Here, <code>y</code> is an index 15: 11 characters for the first row, and 5 characters until <code>y</code> in the second.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">index</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. An index to convert</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">startRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. =0 The row from which to start the conversion</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">position</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"class=""title="Object"data-id="Object">Object</a></td><tdclass="argDescription "><p>Required. The position to start inserting at</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">text</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. A chunk of text to insert</p>
<divid="ellipsis_Document.insertInLine"class="ellipsis_description"><p>Inserts <code>text</code> into the <code>position</code> at the current row. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Inserts <code>text</code> into the <code>position</code> at the current row. This method also triggers the <code>'change'</code> event.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">position</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"class=""title="Object"data-id="Object">Object</a></td><tdclass="argDescription "><p>Required. The position to insert at</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">text</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. A chunk of text</p>
<divid="ellipsis_Document.insertLines"class="ellipsis_description"><p>Inserts the elements in <code>lines</code> into the document, starting at the row index given by <code>row</code>. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Inserts the elements in <code>lines</code> into the document, starting at the row index given by <code>row</code>. This method also triggers the <code>'change'</code> event.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">row</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The index of the row to insert at</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">lines</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array"class=""title="Array"data-id="Array">Array</a></td><tdclass="argDescription "><p>Required. An array of strings</p>
<divid="ellipsis_Document.insertNewLine"class="ellipsis_description"><p>Inserts a new line into the document at the current row's <code>position</code>. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Inserts a new line into the document at the current row's <code>position</code>. This method also triggers the <code>'change'</code> event.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">position</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"class=""title="Object"data-id="Object">Object</a></td><tdclass="argDescription "><p>Required. The position to insert at</p>
<divid="ellipsis_Document.isNewLine"class="ellipsis_description"><p>Returns <code>true</code> if <code>text</code> is a newline character (either <code>\r\n</code>, <code>\r</code>, or <code>\n</code>).</p>
</div>
<divclass="description"><p>Returns <code>true</code> if <code>text</code> is a newline character (either <code>\r\n</code>, <code>\r</code>, or <code>\n</code>).</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">text</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. The text to check</p>
<divid="ellipsis_Document.positionToIndex"class="ellipsis_description"><p>Converts the <code>{row, column}</code> position in a document to the character's index.</p>
</div>
<divclass="description"><p>Converts the <code>{row, column}</code> position in a document to the character's index.</p>
<p>Index refers to the "absolute position" of a character in the document. For example:</p>
<pre><codeclass="language-javascript"><spanclass="keyword">var</span> x = <spanclass="number">0</span>; <spanclass="comment">// 10 characters, plus one for newline</span>
<spanclass="keyword">var</span> y = -<spanclass="number">1</span>;</code></pre>
<p>Here, <code>y</code> is an index 15: 11 characters for the first row, and 5 characters until <code>y</code> in the second.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">pos</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object"class=""title="Object"data-id="Object">Object</a></td><tdclass="argDescription "><p>Required. The <code>{row, column}</code> to convert</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">startRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. =0 The row from which to start the conversion</p>
<divid="ellipsis_Document.remove"class="ellipsis_description"><p>Removes the <code>range</code> from the document.</p>
</div>
<divclass="description"><p>Removes the <code>range</code> from the document.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">range</td><tdclass="argType""><ahref="range.html"class=""title="Range (class)"data-id="Range">Range</a></td><tdclass="argDescription "><p>Required. A specified Range to remove</p>
<divid="ellipsis_Document.removeInLine"class="ellipsis_description"><p>Removes the specified columns from the <code>row</code>. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Removes the specified columns from the <code>row</code>. This method also triggers the <code>'change'</code> event.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">row</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The row to remove from</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">startColumn</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The column to start removing at</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">endColumn</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The column to stop removing at</p>
<divid="ellipsis_Document.removeLines"class="ellipsis_description"><p>Removes a range of full lines. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Removes a range of full lines. This method also triggers the <code>'change'</code> event.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">firstRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The first row to be removed</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">lastRow</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number"class=""title="Number"data-id="Number">Number</a></td><tdclass="argDescription "><p>Required. The last row to be removed</p>
<divid="ellipsis_Document.removeNewLine"class="ellipsis_description"><p>Removes the new line between <code>row</code> and the row immediately following it. This method also triggers the <code>'change'</code> event.</p>
</div>
<divclass="description"><p>Removes the new line between <code>row</code> and the row immediately following it. This method also triggers the <code>'change'</code> event.</p>
<divid="ellipsis_Document.replace"class="ellipsis_description"><p>Replaces a range in the document with the new <code>text</code>.</p>
</div>
<divclass="description"><p>Replaces a range in the document with the new <code>text</code>.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">range</td><tdclass="argType""><ahref="range.html"class=""title="Range (class)"data-id="Range">Range</a></td><tdclass="argDescription "><p>Required. A specified Range to replace</p>
</td></tr><trclass="argumentRow "><tdclass="argName ">text</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. The new text to use as a replacement</p>
<divid="ellipsis_Document.revertDeltas"class="ellipsis_description"><p>Reverts any changes previously applied. These can be either <code>'includeText'</code>, <code>'insertLines'</code>, <code>'removeText'</code>, and <code>'removeLines'</code>.</p>
</div>
<divclass="description"><p>Reverts any changes previously applied. These can be either <code>'includeText'</code>, <code>'insertLines'</code>, <code>'removeText'</code>, and <code>'removeLines'</code>.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">newLineMode</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. The newline mode to use; can be either <code>windows</code>, <code>unix</code>, or <code>auto</code></p>
<divid="ellipsis_Document.setValue"class="ellipsis_description"><p>Replaces all the lines in the current <code>Document</code> with the value of <code>text</code>.</p>
</div>
<divclass="description"><p>Replaces all the lines in the current <code>Document</code> with the value of <code>text</code>.</p>
<h4>Arguments</h4><tableclass="argumentTable argument-list table table-striped table-bordered"><trclass="argumentRow "><tdclass="argName ">text</td><tdclass="argType""><ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String"class=""title="String"data-id="String">String</a></td><tdclass="argDescription "><p>Required. The text to use</p>