Skip to content

EditorStateOptions

What a new editor state starts with (createEditorState). Every field is optional.

optional checkSpelling?: boolean

Draw spelling squiggles when the environment's spell service is on. Turn it off for an editor where a squiggle could not be fixed. Default true.


optional diagrams?: boolean

Render ```mermaid fences as diagrams. With false, they show as ordinary code blocks and Mermaid is never loaded — for a page that must not download it, or whose Content Security Policy cannot allow Mermaid's inline styles (see the self-hosting guide). Default true. Ignored by the @openmarkdown-dev/editor/no-diagrams entry, which never renders diagrams and does not contain Mermaid at all.


optional doc?: string

The Markdown source to edit. Default: the empty document.


optional docPath?: string | null

The document's absolute path, or null for an unsaved one. Relative links and images resolve against it, and pasted images are stored beside it. Default: null.


optional extensions?: Extension

Your own CodeMirror extensions, installed in this state beside the editor's. They stay installed in every mode and travel with the state.


optional host?: EditorHost

The per-document callbacks (change, links, images, attachments, completion, outline). Default: none.


optional mode?: EditorMode

Live preview (default), plain source, or read-only reading mode.


optional selection?: object

Where the caret starts (UTF-16 offsets into doc). Default: the start of the document.

anchor: number

optional head?: number