Skip to content
QuireKit
Core docs
Alpha · evolving API
API and referenceView Markdown ↗

Editor: state, commands and lifetime

Task-oriented arguments, results, state shape and lifecycle effects.

Use the complete product to see these methods together. This page explains invocation semantics; Core API retains full source signatures.

Creation and state

new Editor(options) establishes schema, commands and create-time extensions. Common options are extensions, content, editable, element and mode. Do not pass browser DOM during SSR. Install an adapter before explicit mounting. Incompatible schema changes need a new session and migration rather than assuming setOptions({ extensions }) hot-recompiles the model.

ts

External editor.state is a QuireKit wrapper with native PM state at .pm. A raw command's contextual state is the shared-transaction PM facade, where state.selection is direct. Keep those contexts distinct.

See options and events for all creation, replacement and event fields, and selections for caret, range and node targets.

@quirekit/coreMIT

Serializable editor state owned by the core package.

QuireEditorStatets

Reading and writing

MethodInput → resultEffects and use
getJSON()none → canonical JSONSerialize explicitly for persistence/download/conversion, not each input projection
getHTML()none → HTMLUses installed serializers, not paginated Canvas pixels
getText(options?)text serialization options → stringPlain text with optional block separators and node serializers
getMarkdown()none → stringUses installed Markdown conversion rules
commands.setContent(content, options)compatible content/options → booleanOrdinary content replacement; does not replace all top-node attributes
commands.replaceDocument(content, options)complete document → booleanRestore files including root attributes, reset selection to start, commit with import origin/non-history
commands.insertContent(content)text/HTML/JSON → booleanInsert at current selection through command/history semantics
isActive(name, attrs?)Node/Mark name and conditions → booleanRead formatting, not executability or persistence
setEditable(value, emitUpdate?)boolean → voidUpdate edit policy; may emit update by default; host permissions still need projection
setOptions(options)partial options → voidUpdate options, without assuming schema recompilation or content migration

Choose invalid-content policy explicitly and validate independently before restoring. getHTML() requires a DOM document and cannot simply be assumed available on a server. Command handling, actual document change and persistence acknowledgement are separate results.

Three command modes

ts

Custom raw commands use the supplied tr and dispatch guard. Dry runs must not perform networking, dialogs or real-state writes. A false result must not be displayed as success.

can() is not a permission check, and setEditable(false) does not block every programmatic command. A false run() does not automatically revert other steps in the chain; see commands and transactions.

@quirekit/coreMIT

Tiptap-compatible props supplied to one raw command callback.

CommandPropsts

Mounting and exit

MethodResultLifetime
mount({ element, mode, id?, editable? })mounted viewFirst is primary; later calls add views, read-only by default
mount(element)mounted viewCompatibility shorthand selects html, not native dom; tutorials use explicit options
changeMode(mode, options?)replacement primary viewPreserve Core content/history; register the mode first
unmount()voidRelease every view while retaining Core state
destroy()voidFinal destruction; no later commands or mounting
@quirekit/coreMIT

Options used to mount an editor view surface.

QuireEditorMountOptionsts
@quirekit/coreMIT

Options used to switch the currently mounted primary view mode.

QuireEditorChangeModeOptionsts

Events

on('transaction', listener) observes accepted state. Use update for content, selectionUpdate for selection, and focus events only when consumed. Release host subscriptions using the same function reference with off. The reference makes one bounded control projection from transaction events and publishes saving state separately.

@quirekit/coreMIT

Payload emitted after a transaction is applied.

QuireEditorTransactionEventts

See the complete session for dirty state and concurrent saving.

QuireKitQuireKit · Core, plugins and Classic docs