prosekit/core/test
Interfaces
Section titled “Interfaces”TestEditor<E>
Section titled “TestEditor<E>”Extends
Section titled “Extends”Editor
<E
>
Type Parameters
Section titled “Type Parameters”Type Parameter | Default type |
---|---|
|
Accessors
Section titled “Accessors”commands
Section titled “commands”Get Signature
Section titled “Get Signature”get commands():
ExtractCommandActions
<E
>
All CommandActions defined by the editor.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”focused
Section titled “focused”Get Signature
Section titled “Get Signature”get focused():
boolean
Whether the editor is focused.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get marks():
ExtractMarkActions
<E
>
All MarkActions defined by the editor.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”mounted
Section titled “mounted”Get Signature
Section titled “Get Signature”get mounted():
boolean
Whether the editor is mounted.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get nodes():
ExtractNodeActions
<E
>
All NodeActions defined by the editor.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”schema
Section titled “schema”Get Signature
Section titled “Get Signature”get schema():
Schema
<ExtractNodeNames
<E
>, ExtractMarkNames
<E
>>
The editor schema.
Returns
Section titled “Returns”Schema
<ExtractNodeNames
<E
>, ExtractMarkNames
<E
>>
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get state():
EditorState
The editor’s current state.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get view():
EditorView
The editor view.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”blur()
Section titled “blur()”-
blur():
void
-
Blur the editor.
Inherited from
Section titled “Inherited from”
canExec()
Section titled “canExec()”-
Check if the given command can be executed. Return
true
if the command can be executed, otherwisefalse
.Inherited from
Section titled “Inherited from”
dispatchEvent()
Section titled “dispatchEvent()”-
dispatchEvent(
event
:Event
):void
exec()
Section titled “exec()”-
Execute the given command. Return
true
if the command was successfully executed, otherwisefalse
.Inherited from
Section titled “Inherited from”
focus()
Section titled “focus()”-
focus():
void
-
Focus the editor.
Inherited from
Section titled “Inherited from”
getDocHTML()
Section titled “getDocHTML()”-
getDocHTML(
options?
:getDocHTMLOptions
):string
-
Return a HTML string representing the editor’s current document.
Inherited from
Section titled “Inherited from”
getDocJSON()
Section titled “getDocJSON()”-
Return a JSON object representing the editor’s current document.
Inherited from
Section titled “Inherited from”
mount()
Section titled “mount()”-
mount(
place
:undefined
|null
|HTMLElement
):void
-
Mount the editor to the given HTML element. Pass
null
orundefined
to unmount the editor.Inherited from
Section titled “Inherited from”
-
set(
doc
:ProseMirrorNode
):void
-
Set the editor state to the given document. You can use special tokens
<a>
and<b>
to set the anchor and head positions of the selection.Example
Section titled “Example”const editor = createTestEditor({ extension }) const n = editor.nodes const doc = n.doc(n.paragraph('<a>Hello<b> world!')) editor.set(doc) // "Hello" is selected.
setContent()
Section titled “setContent()”-
setContent(
content
:string
|ProseMirrorNode
|NodeJSON
|HTMLElement
,selection?
:Selection
|"start"
|SelectionJSON
|"end"
):void
-
Update the editor’s document and selection.
Inherited from
Section titled “Inherited from”
unmount()
Section titled “unmount()”-
unmount():
void
-
Unmount the editor. This is equivalent to
mount(null)
.Inherited from
Section titled “Inherited from”
updateState()
Section titled “updateState()”-
updateState(
state
:EditorState
):void
-
Update the editor’s state.
Remarks
Section titled “Remarks”This is an advanced method. Use it only if you have a specific reason to directly manipulate the editor’s state.
Inherited from
Section titled “Inherited from”
-
Register an extension to the editor. Return a function to unregister the extension.
Inherited from
Section titled “Inherited from”
Functions
Section titled “Functions”createTestEditor()
Section titled “createTestEditor()”-
function createTestEditor<E>(
options
:EditorOptions
<E
>):TestEditor
<E
>