PrismEditor
Defined in: types.ts:115
Type Parameters
Section titled “Type Parameters”T
extends object
= { }
Properties
Section titled “Properties”activeLine
Section titled “activeLine”
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.
container
Section titled “container”
readonly
container:HTMLDivElement
Defined in: types.ts:117
This is the outermost element of the editor.
extensions
Section titled “extensions”
readonly
extensions:object
Defined in: types.ts:148
Object storing some of the extensions added to the editor.
codeFold?
Section titled “codeFold?”
optional
codeFold:ReadOnlyCodeFolding
cursor?
Section titled “cursor?”
optional
cursor:Cursor
history?
Section titled “history?”
optional
history:EditHistory
matchBrackets?
Section titled “matchBrackets?”
optional
matchBrackets:BracketMatcher
matchTags?
Section titled “matchTags?”
optional
matchTags:TagMatcher
searchWidget?
Section titled “searchWidget?”
optional
searchWidget:SearchWidget
focused
Section titled “focused”
readonly
focused:boolean
Defined in: types.ts:133
Whether the textarea
is focused.
inputCommandMap
Section titled “inputCommandMap”
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.
keyCommandMap
Section titled “keyCommandMap”
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.
options
Section titled “options”
readonly
options:EditorOptions
&Omit
<T
, keyofEditorOptions
>
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.
textarea
Section titled “textarea”
readonly
textarea:HTMLTextAreaElement
Defined in: types.ts:126
Underlying <textarea>
in the editor.
tokens
Section titled “tokens”
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
.
wrapper
Section titled “wrapper”
readonly
wrapper:HTMLDivElement
Defined in: types.ts:119
Element wrapping the lines and overlays.
Methods
Section titled “Methods”addExtensions()
Section titled “addExtensions()”addExtensions(
this
, …extensions
):void
Defined in: types.ts:168
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:164
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:166
Adds a listener for 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”():
void
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove(
this
):void
Defined in: types.ts:170
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:160
Set new options for the editor. Omitted properties will use their old value.
Parameters
Section titled “Parameters”void
options
Section titled “options”Partial
<EditorOptions
& 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:162
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