Skip to content

PrismEditor

Defined in: types.ts:116

T extends object = { }

readonly activeLine: number

Defined in: types.ts:132

The line number of the line the cursor is currently on. You can use editor.lines[editor.activeLine] to get the element for the active line.


readonly container: HTMLDivElement

Defined in: types.ts:118

This is the outermost element of the editor.


readonly extensions: object

Defined in: types.ts:149

Object storing some of the extensions added to the editor.

optional autoComplete: AutoComplete

optional codeFold: ReadOnlyCodeFolding

optional cursor: Cursor

optional history: EditHistory

optional matchBrackets: BracketMatcher

optional matchTags: TagMatcher

optional searchWidget: SearchWidget


readonly focused: boolean

Defined in: types.ts:134

Whether the textarea is focused.


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

Defined in: types.ts:143

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


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

Defined in: types.ts:145

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


readonly lines: HTMLCollectionOf<HTMLDivElement>

Defined in: types.ts:125

Collection containing the overlays as the first element. The rest of the elements are the code lines. This means the index of a line is the same as its line number.


readonly options: EditorOptions<T> & Omit<T, keyof EditorOptions<{ }>>

Defined in: types.ts:141

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


readonly textarea: HTMLTextAreaElement

Defined in: types.ts:127

Underlying <textarea> in the editor.


readonly tokens: TokenStream

Defined in: types.ts:147

Tokens currently displayed in the editor.


readonly value: string

Defined in: types.ts:136

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


readonly wrapper: HTMLDivElement

Defined in: types.ts:120

Element wrapping the lines and overlays.

addExtensions(this, …extensions): void

Defined in: types.ts:177

Adds extensions to the editor and calls their update methods.

void

EditorExtension<T>[]

void


getSelection(this): InputSelection

Defined in: types.ts:166

Gets selectionStart, selectionEnd and selectionDirection for the textarea.

void

InputSelection


on<U>(this, name, listener): () => void

Defined in: types.ts:171

Adds a listener for editor events with the specified name.

U extends keyof EditorEventMap<{ }>

void

U

EditorEventMap<T>[U]

A cleanup function that removes the listener.

(): void

void


remove(this): void

Defined in: types.ts:179

Removes the editor from the DOM.

void

void


setOptions(this, options): void

Defined in: types.ts:162

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

void

Partial<EditorOptions<T> & Omit<T, keyof EditorOptions>>

New options for the editor

void


update(this): void

Defined in: types.ts:164

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

void

void