PrismEditor
Defined in: types.ts:116
Type Parameters
Section titled “Type Parameters”T extends object = { }
Properties
Section titled “Properties”activeLine
Section titled “activeLine”
readonlyactiveLine: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.
container
Section titled “container”
readonlycontainer:HTMLDivElement
Defined in: types.ts:118
This is the outermost element of the editor.
extensions
Section titled “extensions”
readonlyextensions:object
Defined in: types.ts:149
Object storing some of the extensions added to the editor.
autoComplete?
Section titled “autoComplete?”
optionalautoComplete:AutoComplete
codeFold?
Section titled “codeFold?”
optionalcodeFold:ReadOnlyCodeFolding
cursor?
Section titled “cursor?”
optionalcursor:Cursor
history?
Section titled “history?”
optionalhistory:EditHistory
matchBrackets?
Section titled “matchBrackets?”
optionalmatchBrackets:BracketMatcher
matchTags?
Section titled “matchTags?”
optionalmatchTags:TagMatcher
searchWidget?
Section titled “searchWidget?”
optionalsearchWidget:SearchWidget
focused
Section titled “focused”
readonlyfocused:boolean
Defined in: types.ts:134
Whether the textarea is focused.
inputCommandMap
Section titled “inputCommandMap”
readonlyinputCommandMap:Record<string,InputCommandCallback|null|undefined>
Defined in: types.ts:143
Record mapping an input to a function called when that input is typed.
keyCommandMap
Section titled “keyCommandMap”
readonlykeyCommandMap:Record<string,KeyCommandCallback|null|undefined>
Defined in: types.ts:145
Record mapping KeyboardEvent.key to a function called when that key is pressed.
readonlylines: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.
options
Section titled “options”
readonlyoptions:EditorOptions<T> &Omit<T, keyofEditorOptions<{ }>>
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.
textarea
Section titled “textarea”
readonlytextarea:HTMLTextAreaElement
Defined in: types.ts:127
Underlying <textarea> in the editor.
tokens
Section titled “tokens”
readonlytokens:TokenStream
Defined in: types.ts:147
Tokens currently displayed in the editor.
readonlyvalue:string
Defined in: types.ts:136
Current code in the editor. Same as textarea.value.
wrapper
Section titled “wrapper”
readonlywrapper:HTMLDivElement
Defined in: types.ts:120
Element wrapping the lines and overlays.
Methods
Section titled “Methods”addExtensions()
Section titled “addExtensions()”addExtensions(
this, …extensions):void
Defined in: types.ts:177
Adds extensions to the editor and calls their update methods.
Parameters
Section titled “Parameters”void
extensions
Section titled “extensions”…EditorExtension<T>[]
Returns
Section titled “Returns”void
getSelection()
Section titled “getSelection()”getSelection(
this):InputSelection
Defined in: types.ts:166
Gets selectionStart, selectionEnd and selectionDirection for the textarea.
Parameters
Section titled “Parameters”void
Returns
Section titled “Returns”on<
U>(this,name,listener): () =>void
Defined in: types.ts:171
Adds a listener for editor events with the specified name.
Type Parameters
Section titled “Type Parameters”U extends keyof EditorEventMap<{ }>
Parameters
Section titled “Parameters”void
U
listener
Section titled “listener”EditorEventMap<T>[U]
Returns
Section titled “Returns”A cleanup function that removes the listener.
():
void
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove(
this):void
Defined in: types.ts:179
Removes the editor from the DOM.
Parameters
Section titled “Parameters”void
Returns
Section titled “Returns”void
setOptions()
Section titled “setOptions()”setOptions(
this,options):void
Defined in: types.ts:162
Set new options for the editor. Omitted properties will use their old value.
Parameters
Section titled “Parameters”void
options
Section titled “options”Partial<EditorOptions<T> & Omit<T, keyof EditorOptions>>
New options for the editor
Returns
Section titled “Returns”void
update()
Section titled “update()”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.
Parameters
Section titled “Parameters”void
Returns
Section titled “Returns”void