Interface PrismEditor

Hierarchy

Properties

activeLine: HTMLDivElement

The line the cursor is currently on.

activeLineNumber: number

The line number of the active line.

extensions: {
    codeFold?: ReadOnlyCodeFolding;
    cursor?: Cursor;
    history?: EditHistory;
    indentGuides?: IndentGuides;
    matchBrackets?: BracketMatcher;
    matchTags?: TagMatcher;
    searchWidget?: SearchWidget;
}

Object storing some of the extensions added to the editor.

Type declaration

focused: boolean

Whether the textarea is focused.

inputCommandMap: Record<string, undefined | null | InputCommandCallback>

Record mapping an input to a function called when that input is typed.

keyCommandMap: Record<string, undefined | null | KeyCommandCallback>

Record mapping KeyboardEvent.key to a function called when that key is pressed.

options: EditorOptions

Current options for the editor. The event handlers can be changed by mutating this object. Use setOptions to change the other options.

overlays: HTMLDivElement

Element containing overlays that are absolutely positioned ontop or behind the code. It is completely safe to append your own overlays to this element, but they will get some default styles.

removed: boolean

True if the remove method has been called.

scrollContainer: HTMLDivElement

This is the outermost element of the editor.

textarea: HTMLTextAreaElement

Underlying <textarea> in the editor.

tokens: TokenStream

Tokens currently displayed in the editor.

value: string

Current code in the editor. Same as textarea.value.

wrapper: HTMLDivElement

Element wrapping the lines and overlays.

Methods

  • Adds extensions to the editor and calls their update methods.

    Parameters

    Returns void

  • Removes the editor from the DOM and marks the editor as removed.

    Parameters

    • this: void

    Returns void

  • Set new options for the editor. Ommitted properties will use their old value.

    Parameters

    • this: void
    • options: Partial<EditorOptions>

      New options for the editor

    Returns void

  • Sets the selection for the textarea and synchronously runs the selectionChange listeners. If you don't want to synchronously run the listeners, use textarea.setSelectionRange instead.

    Parameters

    • this: void
    • start: number

      New selectionStart.

    • Optional end: number

      New selectionEnd. Defaults to start.

    • Optional direction: "forward" | "backward" | "none"

      New direction.

    Returns void

  • Forces the editor to update. Can be useful after adding a tokenize listener or modifying a grammar.

    Parameters

    • this: void

    Returns void

Generated using TypeDoc