Skip to content

PrismEditor

Defined in: types.ts:115

T extends object = { }

readonly activeLine: number

Defined in: types.ts:131

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:117

This is the outermost element of the editor.


readonly extensions: object

Defined in: types.ts:148

Object storing some of the extensions added to the editor.

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:133

Whether the textarea is focused.


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

Defined in: types.ts:142

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


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

Defined in: types.ts:144

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


readonly lines: HTMLCollectionOf<HTMLDivElement>

Defined in: types.ts:124

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 & Omit<T, keyof EditorOptions>

Defined in: types.ts:140

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:126

Underlying <textarea> in the editor.


readonly tokens: TokenStream

Defined in: types.ts:146

Tokens currently displayed in the editor.


readonly value: string

Defined in: types.ts:135

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


readonly wrapper: HTMLDivElement

Defined in: types.ts:119

Element wrapping the lines and overlays.

addExtensions(this, …extensions): void

Defined in: types.ts:168

Adds extensions to the editor and calls their update methods.

void

EditorExtension<T>[]

void


getSelection(this): InputSelection

Defined in: types.ts:164

Gets selectionStart, selectionEnd and selectionDirection for the textarea.

void

InputSelection


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

Defined in: types.ts:166

Adds a listener for events with the specified name.

U extends keyof EditorEventMap<{ }>

void

U

EditorEventMap<T>[U]

(): void

void


remove(this): void

Defined in: types.ts:170

Removes the editor from the DOM.

void

void


setOptions(this, options): void

Defined in: types.ts:160

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

void

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

New options for the editor

void


update(this): void

Defined in: types.ts:162

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

void

void