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.

Constructors

Properties

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 onFocus onPaste onScrollLeftChange onScrollTopChange onSelectionChange 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 toLowerCase toUpperCase toggleBlockComment toggleCommentLines toggleOverwrite toggleWord transposeLetters undo unsetStyle

Constructors

  • Creates a new Editor object.

    Parameters

    • renderer: VirtualRenderer

      Associated VirtualRenderer that draws everything

    • Optional session: EditSession

      The EditSession to refer to

    • Optional options: Partial<EditorOptions>

      The default options

    Returns Editor

Properties

$highlightPending: boolean
$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
$onScrollLeftChange: any
$onScrollTopChange: any
$onSelectionChange: any
$onTokenizerUpdate: any
$opResetTimer: {
    schedule: { (timeout: any): void; delay(timeout: any): void; schedule: ...; call(): void; cancel(): void; isPending(): any; };
    call(): void;
    cancel(): void;
    delay(timeout): void;
    isPending(): any;
    (timeout): void;
}

Type declaration

    • (timeout): void
    • Parameters

      • timeout: any

      Returns void

  • schedule: { (timeout: any): void; delay(timeout: any): void; schedule: ...; call(): void; cancel(): void; isPending(): any; }
  • call:function
  • cancel:function
  • delay:function
  • isPending:function
$scrollAnchor: HTMLDivElement
$search: Search
$toDestroy: any[]
$toggleWordPairs: string[][]
_$emitInputEvent: {
    schedule: { (timeout: any): void; delay(timeout: any): void; schedule: ...; call(): void; cancel(): void; isPending(): any; };
    call(): void;
    cancel(): void;
    delay(timeout): void;
    isPending(): any;
    (timeout): void;
}

Type declaration

    • (timeout): void
    • Parameters

      • timeout: any

      Returns void

  • schedule: { (timeout: any): void; delay(timeout: any): void; schedule: ...; call(): void; cancel(): void; isPending(): any; }
  • call:function
  • cancel:function
  • delay:function
  • isPending:function
commands: CommandManager
container: HTMLElement & {
    env?: any;
    value?: any;
}

Type declaration

  • Optional env?: any
  • Optional value?: any
curOp: {
    [key: string]: any;
}

Type declaration

  • [key: string]: any
id: string
inVirtualSelectionMode: boolean
keyBinding: KeyBinding
mergeNextCommand: boolean
prevOp: {}

Type declaration

    previousCommand: any
    renderer: VirtualRenderer
    selection: Selection
    sequenceStartTime: number
    session: EditSession

    @type{EditSession}

    textInput: any
    $uid: number

    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

      • dir: any
      • select: any

      Returns void

    • Parameters

      • range: IRange
      • Optional replacement: string

      Returns IRange

    • Parameters

      • Optional text: string
      • Optional composition: any

      Returns void

    • Indents the current line.

      Returns void

      Related

      EditSession.indentRows

    • Outdents the current line.

      Returns void

      Related

      EditSession.outdentRows

    • Attempts to center the current selection on the screen.

      Returns void

    • {:Selection.clearSelection}

      Returns void

      Related

      Selection.clearSelection

    • Copies all the selected lines down one row.

      Returns void

      Related

      EditSession.duplicateLines

    • Copies all the selected lines up one row.

      Returns void

    • Parameters

      • command: string | string[]
      • Optional args: any

      Returns boolean

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

      Parameters

      • needle: any

        The text to search for (optional)

      • Optional options: Partial<SearchOptions>

        An object defining various search properties

      • Optional animate: boolean

        If true animate scrolling

      Returns false | Range

      Related

      Search.find

    • 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

      • Optional options: Partial<SearchOptions>

        search options

      • Optional animate: boolean

        If true animate scrolling

      Returns void

      Related

      Editor.find

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

      Parameters

      • Optional options: Partial<SearchOptions>

        search options

      • Optional animate: boolean

        If true animate scrolling

      Returns void

      Related

      Editor.find

    • 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 Point

      An object that looks something like this:

      { row: currRow, column: currCol }
      

      Related

      Selection.getCursor

    • Returns the screen position of the cursor.

      Returns Point

      Related

      EditSession.documentToScreenPosition

    • Returns the current mouse drag delay.

      Returns number

    • {:VirtualRenderer.getFirstVisibleRow}

      Returns number

      Related

      VirtualRenderer.getFirstVisibleRow

    • Gets the current font size of the editor text.

      Returns string

    • 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

    • {:Search.getOptions} For more information on options, see [[Search Search]].

      Returns Partial<SearchOptions>

      Related

      Search.getOptions

    • {:VirtualRenderer.getLastVisibleRow}

      Returns number

      Related

      VirtualRenderer.getLastVisibleRow

    • 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

      Related

      EditSession.getOverwrite

    • 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

      Related

      Selection.getRange

    • 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

      Related

      VirtualRenderer.getTheme

    • Returns the current session's content.

      Returns string

      Related

      EditSession.getValue

    • 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

      • Optional column: number

        A column number to go to

      • Optional animate: 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

      Related

      EditSession.indentRows

    • Inserts text into wherever the cursor is pointing.

      Parameters

      • text: string

        The new text to add

      • Optional pasted: 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

      • Optional select: boolean
      • Optional expand: 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

      Related

      Selection.moveCursorTo

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

      Parameters

      • pos: Point

        An object with two properties, row and column

      Returns void

      Related

      Selection.moveCursorToPosition

    • Shifts all the selected lines down one row.

      Returns void

      Related

      EditSession.moveLinesUp

    • Shifts all the selected lines up one row.

      Returns void

      Related

      EditSession.moveLinesDown

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

      Related

      EditSession.moveText

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

      Parameters

      • Optional times: 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

      • Optional times: 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

      • Optional times: 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

      Related

      Editor.moveCursorTo

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

      Parameters

      • Optional times: 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

    • Emitted once the editor has been blurred.

      Parameters

      • e: any

      Returns void

    • Parameters

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

      Returns boolean

    • Parameters

      • compositionState: any

      Returns void

    • Parameters

      • text: any

      Returns void

    • Called whenever a text "copy" happens.

      Returns void

    • Emitted when the selection changes.

      Returns void

    • Called whenever a text "cut" happens.

      Returns void

    • Emitted whenever the document is changed.

      Parameters

      • delta: Delta

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

      Returns void

    • Emitted once the editor comes into focus.

      Parameters

      • e: any

      Returns void

    • Called whenever a text "paste" happens.

      Parameters

      • text: string

        The pasted text

      • event: any

      Returns void

    • Parameters

      • text: any
      • composition: any

      Returns any

    • 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

      Related

      UndoManager.redo

    • Removes the current selection or one character.

      Parameters

      • Optional dir: "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

      Related

      EditSession.remove

    • 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

      • Optional replacement: string

        The text to replace with

      • Optional options: Partial<SearchOptions>

        The [[Search Search]] options to use

      Returns number

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

      Parameters

      • Optional replacement: string

        The text to replace with

      • Optional options: Partial<SearchOptions>

        The [[Search Search]] options to use

      Returns number

    • {:VirtualRenderer.onResize}

      Parameters

      • Optional force: boolean

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

      Returns void

      Related

      VirtualRenderer.onResize

    • Parameters

      • range: Range
      • Optional animate: 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

      • Optional callback: (() => void)

        Function to be called when the animation has finished

          • (): void
          • Returns void

      Returns void

      Related

      VirtualRenderer.scrollToLine

    • Moves the editor to the specified row.

      Parameters

      • row: number

      Returns void

      Related

      VirtualRenderer.scrollToRow

    • Selects all the text in editor.

      Returns void

      Related

      Selection.selectAll

    • 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

        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

      • Optional position: 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

      • keyboardHandler: string | KeyboardHandler

        The new key handler

      • Optional cb: (() => void)
          • (): void
          • Returns void

      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

      Related

      EditSession.setOverwrite

    • 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

      • Optional session: 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

      Returns void

      Related

      VirtualRenderer.setStyle

    • {:VirtualRenderer.setTheme}

      Parameters

      • theme: string | Theme

        The path to a theme

      • Optional cb: (() => void)

        optional callback called when theme is loaded

          • (): void
          • Returns void

      Returns void

    • Sets the current document to val.

      Parameters

      • val: string

        The new value to set for the document

      • Optional cursorPos: 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

      Related

      Document.setValue

    • 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

    • Converts the current selection entirely into lowercase.

      Returns void

    • Converts the current selection entirely into uppercase.

      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

      Related

      EditSession.toggleOverwrite

    • Transposes current line.

      Returns void

    • {:UndoManager.undo}

      Returns void

      Related

      UndoManager.undo

    • {:VirtualRenderer.unsetStyle}

      Parameters

      • style: string

      Returns void

      Related

      VirtualRenderer.unsetStyle

    Generated using TypeDoc