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

Commands and transactions

Use commands first, then understand how changes share document history.

Commands expose actions such as Bold, insertion and undo. Toolbars, shortcuts and application code use them to modify the same document.

Run one command

With Bold or StarterKit installed:

Toggle Bold immediatelyts

The action targets the current selection. Its boolean result reports handling, not persistence.

Combine actions

After clicking a toolbar, return focus before formatting:

Chain commandsts

Actions share a transaction context, submitted by run(). A transaction describes content and selection changes that history uses for undo and redo.

run() reports whether every action returned true. It does not automatically roll back: one false result does not remove steps already added by other actions. Check with the equivalent can().chain() when needed, and make custom commands reject before modifying tr.

Check whether an action can run

Check without changing contentts

can() checks the current state without committing changes. It does not check application write permissions and may return true while read-only. Controls typically combine editor.isEditable && editor.can().toggleBold(); use isActive('bold') to query active formatting separately.

setEditable(false) controls View input; business commands and collaboration transactions can still write. Buttons, AI, asynchronous services and automation must validate their own permissions, targets and current editability immediately before invoking commands. Hiding controls is insufficient.

Write commands

Register actions in addCommands() and use its supplied commands, tr and dispatch. Direct calls, chains and can() then share the implementation. Checks must not start requests, open dialogs or mutate external state.

See toolbar integration and the content-extension tutorial.

QuireKitQuireKit · Core, plugins and Classic docs