Stores all the data about [[Editor Editor]] state providing easy way to change editors state.

EditSession can be attached to only one [[Document Document]]. Same Document can be attached to several EditSessions.

Hierarchy

  • EventEmitter<Ace.EditSessionEvents>
  • OptionsProvider<Ace.EditSessionOptions>
  • Folding
  • BracketMatch
    • EditSession

Constructors

Properties

Accessors

Methods

addDynamicMarker addEventListener addFold addFolds addGutterDecoration addMarker adjustWrapLimit clearAnnotations clearBreakpoint clearBreakpoints destroy documentToScreenColumn documentToScreenPosition documentToScreenRow duplicateLines endOperation expandFold expandFolds foldAll foldAllComments foldToLevel getAWordRange getAllFolds getAnnotations getBreakpoints getCommentFoldRange getDisplayLine getDocument getDocumentLastRowColumn getDocumentLastRowColumnPosition getFoldAt getFoldDisplayLine getFoldLine getFoldStringAt getFoldedRowCount getFoldsInRange getFoldsInRangeList getLength getLine getLineWidgetMaxWidth getLines getMarkers getMode getNavigateWithinSoftTabs getNewLineMode getNextFoldLine getOption getOptions getOverwrite getParentFoldRangeData getPrecedingCharacter getRowFoldEnd getRowFoldStart getRowLength getRowLineCount getRowSplitData getRowWrapIndent getScreenLastRowColumn getScreenLength getScreenTabSize getScreenWidth getScrollLeft getScrollTop getSelection getSelectionMarkers getState getTabSize getTabString getTextRange getTokenAt getTokens getUndoManager getUseSoftTabs getUseWorker getUseWrapMode getWordRange getWrapLimit getWrapLimitRange highlight highlightLines indentRows insert isRowFolded isTabStop markUndoGroup moveLinesDown moveLinesUp moveText off on onFoldWidgetClick onSelectionChange once outdentRows redoChanges remove removeAllListeners removeDefaultHandler removeEventListener removeFold removeFolds removeFullLines removeGutterDecoration removeListener removeMarker replace resetCaches screenToDocumentColumn screenToDocumentPosition screenToDocumentRow setAnnotations setBreakpoint setBreakpoints setDefaultHandler setDocument setFoldStyle setMode setNavigateWithinSoftTabs setNewLineMode setOption setOptions setOverwrite setScrollLeft setScrollTop setTabSize setUndoManager setUndoSelect setUseSoftTabs setUseWorker setUseWrapMode setValue setWrapLimit setWrapLimitRange startOperation toJSON toggleFold toggleFoldWidget toggleOverwrite tokenizerUpdateFoldWidgets undoChanges unfold updateFoldWidgets fromJSON

Constructors

Properties

bgTokenizer: BackgroundTokenizer
curOp: Operation
destroyed: boolean
doc: Document
findMatchingBracket: ((position, chr?) => Ace.Point)

Type declaration

foldWidgets: any[]
getBracketRange: ((pos) => Range)

Type declaration

getFoldWidget: any
getFoldWidgetRange: any
getMatchingBracketRanges: ((pos, isBackwards?) => Range[])

Returns:

  • null if there is no any bracket at pos;
  • two Ranges if there is opening and closing brackets;
  • one Range if there is only one bracket

Type declaration

    • (pos, isBackwards?): Range[]
    • Returns:

      • null if there is no any bracket at pos;
      • two Ranges if there is opening and closing brackets;
      • one Range if there is only one bracket

      Parameters

      • pos: Ace.Point
      • Optional isBackwards: boolean

      Returns Range[]

getMatchingTags: ((pos) => {
    closeTag: Range;
    closeTagName: Range;
    openTag: Range;
    openTagName: Range;
})

Returns [[Range]]'s for matching tags and tag names, if there are any

Type declaration

    • (pos): {
          closeTag: Range;
          closeTagName: Range;
          openTag: Range;
          openTagName: Range;
      }
    • Returns [[Range]]'s for matching tags and tag names, if there are any

      Parameters

      Returns {
          closeTag: Range;
          closeTagName: Range;
          openTag: Range;
          openTagName: Range;
      }

getValue: (() => string)

Returns the current [[Document Document]] as a string.

Type declaration

    • (): string
    • Returns the current [[Document Document]] as a string.

      Returns string

      Method

      getValue

      Alias

      EditSession.toString

Method

getValue

Alias

EditSession.toString

gutterRenderer?: any
id: string
isFullWidth: ((c) => boolean)

Type declaration

    • (c): boolean
    • Parameters

      • c: any

      Returns boolean

lineWidgetWidth: number
lineWidgets: Ace.LineWidget[]
lineWidgetsWidth?: number
mergeUndoDeltas: boolean
multiSelect?: any
nonTokenRe: RegExp
prevOp: {}

Type declaration

    screenWidth: any
    selection: Selection
    selectionMarkerCount?: number
    tokenRe: RegExp

    Accessors

    Methods

    • Adds a new fold. The new created Fold object or an existing fold object in case the passed in range fits an existing fold exactly.

      Parameters

      • placeholder: string | Fold
      • Optional range: Range

      Returns Fold

    • Parameters

      • folds: Fold[]

      Returns void

    • Adds className to the row, to be used for CSS stylings and whatnot.

      Parameters

      • row: number

        The row number

      • className: string

        The class to add

      Returns void

    • Adds a new marker to the given Range. If inFront is true, a front marker is defined, and the 'changeFrontMarker' event fires; otherwise, the 'changeBackMarker' event fires.

      Parameters

      • range: Range

        Define the range of the marker

      • clazz: string

        Set the CSS class for the marker

      • Optional type: "line" | "text" | "fullLine" | "screenLine" | MarkerRenderer

        Identify the renderer type of the marker. If string provided, corresponding built-in renderer is used. Supported string types are "fullLine", "screenLine", "text" or "line". If a Function is provided, that Function is used as renderer.

      • Optional inFront: boolean

        Set to true to establish a front marker

      Returns number

      The new marker id

    • This should generally only be called by the renderer when a resize is detected.

      Parameters

      • desiredLimit: number

        The new wrap limit

      • Optional $printMargin: any

      Returns boolean

    • Clears all the annotations for this session. This function also triggers the 'changeAnnotation' event.

      Returns void

    • Removes a breakpoint on the row number given by row. This function also emits the 'changeBreakpoint' event.

      Parameters

      • row: number

        A row index

      Returns void

    • Removes all breakpoints on the rows. This function also emits the 'changeBreakpoint' event.

      Returns void

    • For the given document row and column, returns the screen column.

      Parameters

      • row: number | Ace.Point
      • Optional docColumn: number

      Returns number

    • Converts document coordinates to screen coordinates. {:conversionConsiderations}

      Parameters

      • docRow: number | Ace.Point

        The document row to check

      • Optional docColumn: number

        The document column to check

      Returns Ace.Point

      The object returned by this method has two properties: row and column.

      Related

      EditSession.screenToDocumentPosition

    • For the given document row and column, returns the screen row.

      Parameters

      • docRow: number | Ace.Point
      • Optional docColumn: number

      Returns number

    • Duplicates all the text between firstRow and lastRow.

      Parameters

      • firstRow: number

        The starting row to duplicate

      • lastRow: number

        The final row to duplicate

      Returns number

      Returns the number of new rows added; in other words, lastRow - firstRow + 1.

    • End current Ace operation. Emits "beforeEndOperation" event just before clearing everything, where the current operation can be accessed through curOp property.

      Parameters

      • Optional e: any

      Returns void

    • Parameters

      • fold: Fold

      Returns void

    • Parameters

      • folds: Fold[]

      Returns void

    • Parameters

      • Optional startRow: number
      • Optional endRow: number
      • Optional depth: number
      • Optional test: Function

      Returns void

    • Parameters

      • level: number

      Returns void

    • Gets the range of a word, including its right whitespace.

      Parameters

      • row: number

        The row number to start from

      • column: number

        The column number to start from

      Returns Range

    • Returns all folds in the document

      Returns Fold[]

    • Returns an array of strings, indicating the breakpoint class (if any) applied to each row.

      Returns string[]

    • Parameters

      • row: number
      • column: number
      • Optional dir: number

      Returns Range

    • Parameters

      • row: number
      • endColumn: number
      • startRow: number
      • startColumn: number

      Returns string

    • For the given document row and column, this returns the column position of the last screen row.

      Parameters

      • docRow: number
      • docColumn: number

      Returns number

    • For the given document row and column, this returns the document position of the last row.

      Parameters

      • docRow: number
      • docColumn: number

      Returns Ace.Point

    • Looks up a fold at a given row/column. Possible values for side: -1: ignore a fold if fold.start = row/column +1: ignore a fold if fold.end = row/column

      Parameters

      • row: number
      • column: number
      • Optional side: number

      Returns Fold

    • Parameters

      • foldLine: FoldLine
      • Optional endRow: number
      • Optional endColumn: number
      • Optional startRow: number
      • Optional startColumn: number

      Returns string

    • Parameters

      • docRow: number
      • Optional startFoldLine: FoldLine

      Returns FoldLine

    • Returns the string between folds at the given position. E.g. foob|arwolrd -> "bar" foobarwol|rd -> "world" foobar<fo|ld>wolrd ->

      where | means the position of row/column

      The trim option determs if the return string should be trimed according to the "side" passed with the trim value:

      E.g. foob|arwolrd -trim=-1> "b" foobarwol|rd -trim=+1> "rld" fo|obarwolrd -trim=00> "foo"

      Parameters

      • row: number
      • column: number
      • Optional trim: number
      • Optional foldLine: FoldLine

      Returns string

    • Parameters

      • first: number
      • last: number

      Returns number

    • Returns all folds in the given range. Note, that this will return folds

      Parameters

      Returns Fold[]

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

      Parameters

      • row: number

        The row to retrieve from

      Returns string

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

      Parameters

      • firstRow: number

        The first row index to retrieve

      • lastRow: number

        The final row index to retrieve

      Returns string[]

    • Returns an object containing all of the markers, either front or back.

      Parameters

      • Optional inFront: boolean

        If true, indicates you only want front markers; false indicates only back markers

      Returns {
          [id: number]: ace;
      }

      • [id: number]: ace
    • Returns true if keyboard navigation moves the cursor within soft tabs, false if it moves the cursor over soft tabs.

      Returns boolean

    • Returns the fold which starts after or contains docRow

      Parameters

      • docRow: number
      • Optional startFoldLine: FoldLine

      Returns FoldLine

    • Parameters

      • row: number
      • Optional ignoreCurrent: boolean

      Returns {
          firstRange?: Range;
          range?: Range;
      }

    • Returns string

      the last character preceding the cursor in the editor

    • Parameters

      • docRow: number
      • Optional startFoldRow: FoldLine

      Returns number

    • Parameters

      • docRow: number
      • Optional startFoldRow: FoldLine

      Returns number

    • Returns number of screenrows in a wrapped line.

      Parameters

      • row: number

        The row number to check

      Returns number

    • For the given row, this returns the split data.

      Parameters

      • row: number

      Returns string

    • Returns the position (on screen) for the last character in the provided screen row.

      Parameters

      • screenRow: number

        The screen row to check

      Returns number

      Related

      EditSession.documentToScreenColumn

    • The distance to the next tab stop at the specified screen column.

      Parameters

      • screenColumn: number

        The screen column to check

      Returns number

    • [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}

      Returns number

    • [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}

      Returns number

    • {:BackgroundTokenizer.getState}

      Parameters

      • row: number

        The row to start at

      Returns string | string[]

      Related

      BackgroundTokenizer.getState

    • Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize getTabSize()]]); otherwise it's simply '\t'.

      Returns string

    • Returns an object indicating the token at the current row. The object has two properties: index and start.

      Parameters

      • row: number

        The row number to retrieve from

      • column: number

        The column number to retrieve from

      Returns Token

    • Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.

      Parameters

      • row: number

        The row to start at

      Returns Token[]

    • Returns true if soft tabs are being used, false otherwise.

      Returns boolean

    • Returns true if wrap mode is being used; false otherwise.

      Returns boolean

    • Given a starting row and column, this method returns the Range of the first word boundary it finds.

      Parameters

      • row: number

        The row to start at

      • column: number

        The column to start at

      Returns Range

    • Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this:

      { min: wrapLimitRange_min, max: wrapLimitRange_max }
      

      Returns {
          max: number;
          min: number;
      }

      • max: number
      • min: number
    • experimental

      Parameters

      • startRow: number
      • endRow: number
      • clazz: string
      • Optional inFront: boolean

      Returns Range

    • Indents all the rows, from startRow to endRow (inclusive), by prefixing each row with the token in indentString.

      If indentString contains the '\t' character, it's replaced by whatever is defined by [[EditSession.getTabString getTabString()]].

      Parameters

      • startRow: number

        Starting row

      • endRow: number

        Ending row

      • indentString: string

        The indent token

      Returns void

    • Inserts a block of text and the indicated position.

      Parameters

      • position: Ace.Point

        The position {row, column} to start inserting at

      • text: string

        A chunk of text to insert

      Returns Ace.Point

      The position of the last line of text. If the length of text is 0, this function simply returns position.

    • Checks if a given documentRow is folded. This is true if there are some folded parts such that some parts of the line is still visible.

      Parameters

      • docRow: number
      • Optional startFoldRow: FoldLine

      Returns boolean

    • Returns true if the character at the position is a soft tab.

      Parameters

      • position: Ace.Point

        The position to check

      Returns boolean

    • Shifts all the lines in the document down one, starting from firstRow and ending at lastRow.

      Parameters

      • firstRow: number

        The starting row to move down

      • lastRow: number

        The final row to move down

      Returns number

      If firstRow is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.

    • Shifts all the lines in the document up one, starting from firstRow and ending at lastRow.

      Parameters

      • firstRow: number

        The starting row to move up

      • lastRow: number

        The final row to move up

      Returns number

      If firstRow is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.

    • Moves a range of text from the given range to the given position. toPosition is an object that looks like this:

        { row: newRowLocation, column: newColumnLocation }
      

      Parameters

      • fromRange: Range

        The range of text you want moved within the document

      • toPosition: Ace.Point

        The location (row and column) where you want to move the text to

      • Optional copy: boolean

      Returns Range

      The new range where the text was moved to.

    • Parameters

      • row: number
      • e: any

      Returns void

    • Outdents all the rows defined by the start and end properties of range.

      Parameters

      • range: Range

        A range of rows

      Returns void

    • Re-implements a previously undone change to your document.

      Parameters

      • deltas: Ace.Delta[]

        An array of previous changes

      • Optional dontSelect: boolean

      Returns void

    • Removes the range from the document.

      Parameters

      • range: Ace.IRange

        A specified Range to remove

      Returns Ace.Point

      The new start property of the range, which contains startRow and startColumn. If range is empty, this function returns the unmodified value of range.start.

    • Parameters

      • Optional name: string

      Returns void

    • Parameters

      • name: string
      • callback: Function

      Returns void

    • Parameters

      • fold: Fold

      Returns void

    • Parameters

      • folds: Fold[]

      Returns void

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

      Parameters

      • firstRow: number

        The first row to be removed

      • lastRow: number

        The last row to be removed

      Returns string[]

      Returns all the removed lines.

      Related

      Document.removeFullLines

    • Removes className from the row.

      Parameters

      • row: number

        The row number

      • className: string

        The class to add

      Returns void

    • Removes the marker with the specified ID. If this marker was in front, the 'changeFrontMarker' event is emitted. If the marker was in the back, the 'changeBackMarker' event is emitted.

      Parameters

      • markerId: number

        A number representing a marker

      Returns void

    • Replaces a range in the document with the new text.

      Parameters

      • range: Ace.IRange

        A specified Range to replace

      • text: string

        The new text to use as a replacement

      Returns Ace.Point

      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.

      Related

      Document.replace

    • Parameters

      • screenRow: number
      • screenColumn: number

      Returns number

    • Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}

      Parameters

      • screenRow: number

        The screen row to check

      • screenColumn: number

        The screen column to check

      • Optional offsetX: number

        screen character x-offset [optional]

      Returns Ace.Point

      The object returned has two properties: row and column.

      Related

      EditSession.documentToScreenPosition

    • Parameters

      • screenRow: number
      • screenColumn: number

      Returns number

    • Sets annotations for the EditSession. This functions emits the 'changeAnnotation' event.

      Parameters

      Returns void

    • Sets a breakpoint on the row number given by row. This function also emits the 'changeBreakpoint' event.

      Parameters

      • row: number

        A row index

      • className: string

        Class of the breakpoint

      Returns void

    • Sets a breakpoint on every row number given by rows. This function also emites the 'changeBreakpoint' event.

      Parameters

      • rows: number[]

        An array of row indices

      Returns void

    • Parameters

      • name: string
      • callback: Function

      Returns void

    • Sets the EditSession to point to a new Document. If a BackgroundTokenizer exists, it also points to doc.

      Parameters

      • doc: Document

        The new Document to use

      Returns void

    • Parameters

      • style: string

      Returns void

    • Sets a new text mode for the EditSession. This method also emits the 'changeMode' event. If a [[BackgroundTokenizer BackgroundTokenizer]] is set, the 'tokenizerUpdate' event is also emitted.

      Parameters

      • mode: string | Ace.SyntaxMode

        Set a new text mode

      • Optional cb: (() => void)

        optional callback

          • (): void
          • Returns void

      Returns void

    • Set whether keyboard navigation of soft tabs moves the cursor within the soft tab, rather than over

      Parameters

      • navigateWithinSoftTabs: boolean

        Value indicating whether or not to navigate within soft tabs

      Returns void

    • Pass in true to enable overwrites in your session, or false to disable.

      If overwrites is enabled, any text you enter will type over any text after it. If the value of overwrite changes, this function also emits the changeOverwrite event.

      Parameters

      • overwrite: boolean

        Defines whether or not to set overwrites

      Returns void

    • [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}

      Parameters

      • scrollLeft: number

      Returns void

    • This function sets the scroll top value. It also emits the 'changeScrollTop' event.

      Parameters

      • scrollTop: number

        The new scroll top value

      Returns void

    • Set the number of spaces that define a soft tab; for example, passing in 4 transforms the soft tabs to be equivalent to four spaces. This function also emits the changeTabSize event.

      Parameters

      • tabSize: number

        The new tab size

      Returns void

    • Enables or disables highlighting of the range where an undo occurred.

      Parameters

      • enable: boolean

        If true, selects the range of the reinserted change

      Returns void

    • Pass true to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character ('\t').

      Parameters

      • val: boolean

        Value indicating whether or not to use soft tabs

      Returns void

    • Identifies if you want to use a worker for the EditSession.

      Parameters

      • useWorker: boolean

        Set to true to use a worker

      Returns void

    • Sets whether or not line wrapping is enabled. If useWrapMode is different than the current value, the 'changeWrapMode' event is emitted.

      Parameters

      • useWrapMode: boolean

        Enable (or disable) wrap mode

      Returns void

    • Sets the session text.

      Parameters

      • text: string

        The new text to place

      Returns void

    • Sets the line length for soft wrap in the editor. Lines will break at a minimum of the given length minus 20 chars and at a maximum of the given number of chars.

      Parameters

      • limit: number

        The maximum line length in chars, for soft wrapping lines.

      Returns void

    • Sets the boundaries of wrap. Either value can be null to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for min or max are different, this method also emits the 'changeWrapMode' event.

      Parameters

      • min: number

        The minimum wrap value (the left side wrap)

      • max: number

        The maximum wrap value (the right side wrap)

      Returns void

    • Start an Ace operation, which will then batch all the subsequent changes (to either content or selection) under a single atomic operation.

      Parameters

      • Optional commandEvent: {
            args?: any;
            command?: {
                name?: string;
            };
        }

        Optional name for the operation

        • Optional args?: any
        • Optional command?: {
              name?: string;
          }
          • Optional name?: string

      Returns void

    • Parameters

      • Optional tryToUnfold: boolean

      Returns void

    • Parameters

      • Optional toggleParent: boolean

      Returns void

    • Sets the value of overwrite to the opposite of whatever it currently is.

      Returns void

    • Parameters

      • e: any

      Returns void

    • Reverts previous changes to your document.

      Parameters

      • deltas: Ace.Delta[]

        An array of previous changes

      • Optional dontSelect: boolean

        If true, doesn't select the range of where the change occured

      Returns void

    • Parameters

      Returns Fold[]

    Generated using TypeDoc