Contains the text of the document. Document can be attached to several EditSessions. At its core, Documents are just an array of strings, with each row in the document matching up to the array index.

Constructors

Creates a new Document. If text is included, the Document contains those strings; otherwise, it's empty.

   

Creates a new Document. If text is included, the Document contains those strings; otherwise, it's empty.

Arguments

textString | ArrayRequired. The starting text

Methods

    • Document.$clipPosition(position)
    • Internal

   

    • Document.$detectNewLine(text)
      • Void
    • Internal

   

Splits a string of text on any newline (\n) or carriage-return ('\r') characters.

   

Splits a string of text on any newline (\n) or carriage-return ('\r') characters.

Arguments

textStringRequired. The text to work with
    • Document.applyDeltas(deltas)
      • Void

    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'.

    Creates a new Anchor to define a floating point in the document.

       

    Creates a new Anchor to define a floating point in the document.

    Arguments

    rowNumberRequired. The row number to use
    columnNumberRequired. The column number to use
      • Document.getAllLines()

      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 a verbatim copy of the given line as it is in the document

         

      Returns a verbatim copy of the given line as it is in the document

      Arguments

      rowNumberRequired. The row index to retrieve

      Returns an array of strings of the rows between firstRow and lastRow. This function is inclusive of lastRow.

         

      Returns an array of strings of the rows between firstRow and lastRow. This function is inclusive of lastRow.

      Arguments

      firstRowNumberRequired. The first row index to retrieve
      lastRowNumberRequired. The final row index to retrieve
        • Document.getNewLineCharacter()

        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.

          • Document.getNewLineMode()

          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.

          Arguments

          rangeRangeRequired. 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.

             

          Arguments

          positionNumberRequired. The position to start inserting at
          textStringRequired. A chunk of text to insert

          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.

          Arguments

          positionNumberRequired. The position to insert at
          textStringRequired. A chunk of text

          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.

          Arguments

          rowNumberRequired. The index of the row to insert at
          linesArrayRequired. An array of strings

          Inserts a new line into the document at the current row's position. This method also triggers the 'change' event.

             

          Inserts a new line into the document at the current row's position. This method also triggers the 'change' event.

          Arguments

          positionStringRequired. The position to insert at

          Returns true if text is a newline character (either \r\n, \r, or \n).

             

          Returns true if text is a newline character (either \r\n, \r, or \n).

          Arguments

          textStringRequired. The text to check

          Removes the range from the document.

             

          Removes the range from the document.

          Arguments

          rangeRangeRequired. A specified Range to remove

          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.

          Arguments

          rowNumberRequired. The row to remove from
          startColumnNumberRequired. The column to start removing at
          endColumnNumberRequired. The column to stop removing at

          Removes a range of full lines. This method also triggers the 'change' event.

             

          Removes a range of full lines. This method also triggers the 'change' event.

          Arguments

          firstRowNumberRequired. The first row to be removed
          lastRowNumberRequired. The last row to be removed
            • Document.removeNewLine(Number row)
              • Void

            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.

            Arguments

            rowNumberRequired. The row to check

            Replaces a range in the document with the new text.

               

            Replaces a range in the document with the new text.

            Arguments

            rangeRangeRequired. A specified Range to replace
            textStringRequired. The new text to use as a replacement
              • Document.revertDeltas(deltas)
                • Void

              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'.

                • Document.setNewLineMode(String newLineMode)
                  • Void

                Sets the new line mode.

                   

                Sets the new line mode.

                Arguments

                newLineModeStringRequired. The newline mode to use; can be either windows, unix, or auto
                  • Document.setValue(String text)
                    • Void

                  Replaces all the lines in the current Document with the value of text.

                     

                  Replaces all the lines in the current Document with the value of text.

                  Arguments

                  textStringRequired. The text to use