Ace API Reference
    Preparing search index...

    Class Editor

    The main entry point into the Ace functionality.

    The Editor manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.

    Event sessions dealing with the mouse and keyboard are bubbled up from Document to the Editor, which decides what to do with them.

    Index

    Constructors

    Properties

    Accessors

    Methods

    $cursorChange $getSelectedRows $getSelectionHighLightRegexp $getVisibleRowCount $handlePaste $highlightBrackets $historyTracker $initOperationListeners $moveByPage $resetCursorStyle $tryReplace $updateHighlightActiveLine applyComposition autoIndent blockIndent blockOutdent blur centerSelection clearSelection copyLinesDown copyLinesUp destroy duplicateSelection endOperation execCommand find findLinkAt findNext findPrevious focus getAnimatedScroll getBehavioursEnabled getCopyText getCursorPosition getCursorPositionScreen getDisplayIndentGuides getDragDelay getFadeFoldWidgets getFirstVisibleRow getFontSize getHighlightActiveLine getHighlightGutterLine getHighlightIndentGuides getHighlightSelectedWord getKeyboardHandler getLastSearchOptions getLastVisibleRow getNumberAt getOverwrite getPrintMarginColumn getReadOnly getScrollSpeed getSelectedText getSelection getSelectionRange getSelectionStyle getSession getShowFoldWidgets getShowInvisibles getShowPrintMargin getTheme getValue getWrapBehavioursEnabled gotoLine gotoPageDown gotoPageUp indent insert isFocused isRowFullyVisible isRowVisible jumpToMatching modifyNumber moveCursorTo moveCursorToPosition moveLinesDown moveLinesUp moveText navigateDown navigateFileEnd navigateFileStart navigateLeft navigateLineEnd navigateLineStart navigateRight navigateTo navigateUp navigateWordLeft navigateWordRight onBlur onChangeAnnotation onChangeBackMarker onChangeBreakpoint onChangeFold onChangeFrontMarker onChangeMode onChangeWrapLimit onChangeWrapMode onCommandKey onCompositionEnd onCompositionStart onCompositionUpdate onCopy onCursorChange onCut onDocumentChange onEndOperation onFocus onPaste onScrollLeftChange onScrollTopChange onSelectionChange onStartOperation onTextInput onTokenizerUpdate openLink prompt redo remove removeGhostText removeLines removeToLineEnd removeToLineStart removeWordLeft removeWordRight replace replaceAll resize revealRange scrollPageDown scrollPageUp scrollToLine scrollToRow selectAll selectPageDown selectPageUp setAnimatedScroll setAutoScrollEditorIntoView setBehavioursEnabled setDisplayIndentGuides setDragDelay setFadeFoldWidgets setFontSize setGhostText setHighlightActiveLine setHighlightGutterLine setHighlightIndentGuides setHighlightSelectedWord setKeyboardHandler setOverwrite setPrintMarginColumn setReadOnly setScrollSpeed setSelectionStyle setSession setShowFoldWidgets setShowInvisibles setShowPrintMargin setStyle setTheme setValue setWrapBehavioursEnabled sortLines splitLine startOperation toggleBlockComment toggleCommentLines toggleOverwrite toggleWord toLowerCase toUpperCase transposeLetters undo unsetStyle

    Constructors

    • Creates a new Editor object.

      Parameters

      • renderer: VirtualRenderer

        Associated VirtualRenderer that draws everything

      • Optionalsession: EditSession

        The EditSession to refer to

      • Optionaloptions: Partial<EditorOptions>

        The default options

      Returns Editor

    Properties

    _$emitInputEvent: {
        schedule: { (timeout?: number): void; delay(timeout?: number): void; schedule: ...; call(): void; cancel(): void; isPending(): any; };
        call(): void;
        cancel(): void;
        delay(timeout?: number): void;
        isPending(): any;
        (timeout?: number): void;
    }
    $highlightPending: boolean
    $hoverTooltip: any
    $isFocused: boolean
    $keybindingId: string
    $lastSel: Range | Range[]
    $mergeableCommands: string[]
    $mouseHandler: MouseHandler
    $onChangeAnnotation: any
    $onChangeBackMarker: any
    $onChangeBreakpoint: any
    $onChangeFold: any
    $onChangeFrontMarker: any
    $onChangeMode: any
    $onChangeTabSize: any
    $onChangeWrapLimit: any
    $onChangeWrapMode: any
    $onCursorChange: any
    $onDocumentChange: any
    $onEndOperation: any
    $onScrollLeftChange: any
    $onScrollTopChange: any
    $onSelectionChange: any
    $onStartOperation: any
    $onTokenizerUpdate: any
    $scrollAnchor: HTMLDivElement
    $search: Search
    $toDestroy: any[]
    $toggleWordPairs: string[][]
    commands: CommandManager
    container: HTMLElement & { env?: any; value?: any }
    curOp: {}
    destroyed: boolean

    true if editor is destroyed

    id: string
    inVirtualSelectionMode: boolean
    keyBinding: KeyBinding
    mergeNextCommand: boolean
    previousCommand: any
    prevOp: {}
    renderer: VirtualRenderer
    selection: Selection
    sequenceStartTime: number
    session: EditSession

    @type{EditSession}

    textInput: TextInput
    $uid: number

    Accessors

    Methods

    • Returns an object indicating the currently selected rows. The object looks like this:

      { first: range.start.row, last: range.end.row }
      

      Parameters

      • range: any

      Returns any

    • Returns the number of currently visible rows.

      Returns number

    • Parameters

      • e: string | { event?: ClipboardEvent; text: string }

      Returns boolean

    • Parameters

      • e: any

      Returns void

    • Parameters

      • dir: any
      • select: any

      Returns void

    • Parameters

      • Optionaltext: string
      • Optionalcomposition: any

      Returns void

    • Indents the current line.

      Returns void

    • Outdents the current line.

      Returns void

    • Attempts to center the current selection on the screen.

      Returns void

    • {:Selection.clearSelection}

      Returns void

    • Copies all the selected lines down one row.

      Returns void

    • Copies all the selected lines up one row.

      Returns void

    • Parameters

      • e: any

      Returns void

      e

    • Attempts to find needle within the document. For more information on options, see [[Search Search]].

      Parameters

      • needle: any

        The text to search for (optional)

      • Optionaloptions: Partial<Ace.SearchOptions>

        An object defining various search properties

      • Optionalanimate: boolean

        If true animate scrolling

      Returns false | Range

    • Finds link at defined {row} and {column}

      Parameters

      • row: any
      • column: any

      Returns string

    • Performs another search for needle in the document. For more information on options, see [[Search Search]].

      Parameters

      • Optionaloptions: Partial<Ace.SearchOptions>

        search options

      • Optionalanimate: boolean

        If true animate scrolling

      Returns void

    • Performs a search for needle backwards. For more information on options, see [[Search Search]].

      Parameters

      • Optionaloptions: Partial<Ace.SearchOptions>

        search options

      • Optionalanimate: boolean

        If true animate scrolling

      Returns void

    • Brings the current textInput into focus.

      Returns void

    • Returns true if the behaviors are currently enabled. {:BehaviorsDef}

      Returns boolean

    • Returns the string of text currently highlighted.

      Returns string

    • Gets the current position of the cursor.

      Returns Ace.Point

      An object that looks something like this:

      { row: currRow, column: currCol }
      
    • Returns the current mouse drag delay.

      Returns number

    • {:VirtualRenderer.getFirstVisibleRow}

      Returns number

    • Gets the current font size of the editor text.

      Returns string | number

    • Returns true if current lines are always highlighted.

      Returns boolean

    • Returns true if currently highlighted words are to be highlighted.

      Returns boolean

    • Returns the keyboard handler, such as "vim" or "windows".

      Returns any

    • {:VirtualRenderer.getLastVisibleRow}

      Returns number

    • Works like [[EditSession.getTokenAt]], except it returns a number.

      Parameters

      • row: any
      • column: any

      Returns any

    • Returns true if overwrites are enabled; false otherwise.

      Returns boolean

    • Returns the column number of where the print margin is.

      Returns number

    • Returns true if the editor is set to read-only mode.

      Returns boolean

    • Returns the value indicating how fast the mouse scroll speed is (in milliseconds).

      Returns number

    • Returns the string of text currently highlighted.

      Returns string

    • Returns the currently highlighted selection.

      Returns Selection

      The selection object

    • {:Selection.getRange}

      Returns Range

    • Returns the current selection style.

      Returns "line" | "text" | "fullLine" | "screenLine"

    • Returns the current session being used.

      Returns EditSession

    • Returns true if the fold widgets are shown.

      Returns boolean

    • Returns true if invisible characters are being shown.

      Returns boolean

    • Returns true if the print margin is being shown.

      Returns boolean

    • {:VirtualRenderer.getTheme}

      Returns string

      The set theme

    • Returns the current session's content.

      Returns string

    • Returns true if the wrapping behaviors are currently enabled.

      Returns boolean

    • Moves the cursor to the specified line number, and also into the indicated column.

      Parameters

      • lineNumber: number

        The line number to go to

      • Optionalcolumn: number

        A column number to go to

      • Optionalanimate: boolean

        If true animates scolling

      Returns void

    • Shifts the document to wherever "page down" is, as well as moving the cursor position.

      Returns void

    • Shifts the document to wherever "page up" is, as well as moving the cursor position.

      Returns void

    • Inserts an indentation into the current cursor position or indents the selected lines.

      Returns void

    • Inserts text into wherever the cursor is pointing.

      Parameters

      • text: string

        The new text to add

      • Optionalpasted: boolean

      Returns void

    • Returns true if the current textInput is in focus.

      Returns boolean

    • Indicates if the entire row is currently visible on the screen.

      Parameters

      • row: number

        The row to check

      Returns boolean

    • Indicates if the row is currently visible on the screen.

      Parameters

      • row: number

        The row to check

      Returns boolean

    • Moves the cursor's row and column to the next matching bracket or HTML tag.

      Parameters

      • Optionalselect: boolean
      • Optionalexpand: boolean

      Returns void

    • If the character before the cursor is a number, this functions changes its value by amount.

      Parameters

      • amount: number

        The value to change the numeral by (can be negative to decrease value)

      Returns void

    • Moves the cursor to the specified row and column. Note that this does not de-select the current selection.

      Parameters

      • row: number

        The new row number

      • column: number

        The new column number

      Returns void

    • Moves the cursor to the position indicated by pos.row and pos.column.

      Parameters

      • pos: Ace.Point

        An object with two properties, row and column

      Returns void

    • Shifts all the selected lines down one row.

      Returns void

    • Shifts all the selected lines up one row.

      Returns void

    • 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

      • range: 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

      • Optionalcopy: boolean

      Returns Range

      The new range where the text was moved to.

    • Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the end of the current file. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the start of the current file. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the end of the current line. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the start of the current line. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the specified row and column. Note that this does de-select the current selection.

      Parameters

      • row: number

        The new row number

      • column: number

        The new column number

      Returns void

    • Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.

      Returns void

    • Internal

      Emitted once the editor has been blurred.

      Parameters

      • e: any

      Returns void

    • Internal

      Parameters

      • e: any

      Returns void

    • Internal

      Parameters

      • e: any
      • hashId: any
      • keyCode: any

      Returns boolean

    • Internal

      Parameters

      • compositionState: any

      Returns void

    • Internal

      Parameters

      • text: any

      Returns void

    • Internal

      Called whenever a text "copy" happens.

      Returns void

    • Internal

      Emitted when the selection changes.

      Returns void

    • Internal

      Called whenever a text "cut" happens.

      Returns void

    • Internal

      Emitted whenever the document is changed.

      Parameters

      • delta: Ace.Delta

        Contains a single property, data, which has the delta of changes

      Returns void

    • Parameters

      • e: any

      Returns void

      e

    • Internal

      Emitted once the editor comes into focus.

      Parameters

      • e: any

      Returns void

    • Internal

      Called whenever a text "paste" happens.

      Parameters

      • text: string

        The pasted text

      • Optionalevent: ClipboardEvent

      Returns void

    • Internal

      Parameters

      • e: any

      Returns void

    • Parameters

      • commandEvent: any

      Returns void

    • Internal

      Parameters

      • text: any
      • composition: any

      Returns any

    • Internal

      Parameters

      • e: any

      Returns void

    • Open valid url under cursor in another tab

      Returns boolean

    • opens a prompt displaying message

      Parameters

      • message: any
      • options: any
      • callback: any

      Returns void

    • {:UndoManager.redo}

      Returns void

    • Removes the current selection or one character.

      Parameters

      • Optionaldir: "left" | "right"

        The direction of the deletion to occur, either "left" or "right"

      Returns void

    • Removes "ghost" text currently displayed in the editor.

      Returns void

    • Removes all the lines in the current selection

      Returns void

    • Removes all the words to the right of the current selection, until the end of the line.

      Returns void

    • Removes all the words to the left of the current selection, until the start of the line.

      Returns void

    • Removes the word directly to the left of the current selection.

      Returns void

    • Removes the word directly to the right of the current selection.

      Returns void

    • Replaces the first occurrence of options.needle with the value in replacement.

      Parameters

      • Optionalreplacement: string

        The text to replace with

      • Optionaloptions: Partial<Ace.SearchOptions>

        The [[Search Search]] options to use

      Returns number

    • Replaces all occurrences of options.needle with the value in replacement.

      Parameters

      • Optionalreplacement: string

        The text to replace with

      • Optionaloptions: Partial<Ace.SearchOptions>

        The [[Search Search]] options to use

      Returns number

    • {:VirtualRenderer.onResize}

      Parameters

      • Optionalforce: boolean

        If true, recomputes the size, even if the height and width haven't changed

      Returns void

    • Parameters

      • range: Range
      • Optionalanimate: boolean

      Returns void

    • Scrolls the document to wherever "page down" is, without changing the cursor position.

      Returns void

    • Scrolls the document to wherever "page up" is, without changing the cursor position.

      Returns void

    • Scrolls to a line. If center is true, it puts the line in middle of screen (or attempts to).

      Parameters

      • line: number

        The line to scroll to

      • center: boolean

        If true

      • animate: boolean

        If true animates scrolling

      • Optionalcallback: () => void

        Function to be called when the animation has finished

      Returns void

    • Moves the editor to the specified row.

      Parameters

      • row: number

      Returns void

    • Selects all the text in editor.

      Returns void

    • Selects the text from the current position of the document until where a "page down" finishes.

      Returns void

    • Selects the text from the current position of the document until where a "page up" finishes.

      Returns void

    • Parameters

      • shouldAnimate: boolean

      Returns void

    • Enables automatic scrolling of the cursor into view when editor itself is inside scrollable element

      Parameters

      • enable: boolean

        default true

      Returns void

    • Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef}

      Parameters

      • enabled: boolean

        Enables or disables behaviors

      Returns void

    • Parameters

      • display: boolean

      Returns void

    • Sets the delay (in milliseconds) of the mouse drag.

      Parameters

      • dragDelay: number

        A value indicating the new delay

      Returns void

    • Parameters

      • fade: boolean

      Returns void

    • Set a new font size (in pixels) for the editor text.

      Parameters

      • size: string | number

        A font size ( e.g. "12px")

      Returns void

    • Set the "ghost" text in provided position. "Ghost" text is a kind of preview text inside the editor which can be used to preview some code inline in the editor such as, for example, code completions.

      Parameters

      • text: string

        Text to be inserted as "ghost" text

      • Optionalposition: Ace.Point

        Position to insert text to

      Returns void

    • Determines whether or not the current line should be highlighted.

      Parameters

      • shouldHighlight: boolean

        Set to true to highlight the current line

      Returns void

    • Parameters

      • shouldHighlight: boolean

      Returns void

    • Parameters

      • highlight: boolean

      Returns void

    • Determines if the currently selected word should be highlighted.

      Parameters

      • shouldHighlight: boolean

        Set to true to highlight the currently selected word

      Returns void

    • Sets a new key handler, such as "vim" or "windows".

      Parameters

      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 column defining where the print margin should be.

      Parameters

      • showPrintMargin: number

        Specifies the new print margin

      Returns void

    • If readOnly is true, then the editor is set to read-only mode, and none of the content can change.

      Parameters

      • readOnly: boolean

        Specifies whether the editor can be modified or not

      Returns void

    • Sets how fast the mouse scrolling should do.

      Parameters

      • speed: number

        A value indicating the new speed (in milliseconds)

      Returns void

    • Draw selection markers spanning whole line, or only over selected text. Default value is "line"

      Parameters

      • val: "line" | "text" | "fullLine" | "screenLine"

        The new selection style "line"|"text"

      Returns void

    • Sets a new editsession to use. This method also emits the 'changeSession' event.

      Parameters

      • Optionalsession: EditSession

        The new session to use

      Returns void

    • Indicates whether the fold widgets should be shown or not.

      Parameters

      • show: boolean

        Specifies whether the fold widgets are shown

      Returns void

    • If showInvisibles is set to true, invisible characters—like spaces or new lines—are show in the editor.

      Parameters

      • showInvisibles: boolean

        Specifies whether or not to show invisible characters

      Returns void

    • If showPrintMargin is set to true, the print margin is shown in the editor.

      Parameters

      • showPrintMargin: boolean

        Specifies whether or not to show the print margin

      Returns void

    • {:VirtualRenderer.setStyle}

      Parameters

      • style: string

        A class name

      • Optionalincluude: boolean

        pass false to remove the class name

      Returns void

    • {:VirtualRenderer.setTheme}

      Parameters

      • theme: string | Ace.Theme

        The path to a theme

      • Optionalcb: () => void

        optional callback called when theme is loaded

      Returns void

    • Sets the current document to val.

      Parameters

      • val: string

        The new value to set for the document

      • OptionalcursorPos: number

        Where to set the new value. undefined or 0 is selectAll, -1 is at the document start, and 1 is at the end

      Returns string

      The current document value

    • Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets when such a character is typed in.

      Parameters

      • enabled: boolean

        Enables or disables wrapping behaviors

      Returns void

    • Splits the line at the current selection (by inserting an '\n').

      Returns void

    • Parameters

      • commandEvent: any

      Returns void

    • Given the currently selected range, this function either comments all the lines, or uncomments all of them.

      Returns void

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

      Returns void

    • Converts the current selection entirely into lowercase.

      Returns void

    • Converts the current selection entirely into uppercase.

      Returns void

    • Transposes current line.

      Returns void

    • {:UndoManager.undo}

      Returns void

    • {:VirtualRenderer.unsetStyle}

      Parameters

      • style: string

      Returns void