prosekit/core/test
Interfaces
Section titled “Interfaces”TestEditor
Section titled “TestEditor”An editor for testing purposes.
Accessors
Section titled “Accessors”-
get mounted():boolean -
Whether the editor is mounted.
-
get view():EditorView -
The editor view.
-
get state():EditorState -
The editor's current state.
-
get focused():boolean -
Whether the editor is focused.
-
get commands():ExtractCommandActions<E> -
All CommandActions defined by the editor.
-
get nodes():ExtractNodeActions<E> -
All NodeActions defined by the editor.
-
get marks():ExtractMarkActions<E> -
All MarkActions defined by the editor.
Methods
Section titled “Methods”-
mount(place:HTMLElement|null|undefined):void -
Mount the editor to the given HTML element. Pass
nullorundefinedto unmount the editor.
-
unmount():void -
Unmount the editor. This is equivalent to
mount(null).
-
focus():void -
Focus the editor.
-
blur():void -
Blur the editor.
-
Register an extension to the editor. Return a function to unregister the extension.
-
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.
-
setContent(content:string|ProseMirrorNode|NodeJSON|HTMLElement,selection?:Selection|"start"|SelectionJSON|"end"):void -
Update the editor's document and selection.
-
Return a JSON object representing the editor's current document.
-
getDocHTML(options?:getDocHTMLOptions):string -
Return a HTML string representing the editor's current document.
-
Execute the given command. Return
trueif the command was successfully executed, otherwisefalse.
-
Check if the given command can be executed. Return
trueif the command can be executed, otherwisefalse.
-
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.
-
dispatchEvent(event:Event):void
Functions
Section titled “Functions”createTestEditor()
Section titled “createTestEditor()”-
function createTestEditor<E>(options:EditorOptions<E>):TestEditor<E>