editory
v0.2.0
Published
Framework-independent ProseMirror block editor
Readme
editory
Pure ProseMirror rich/block editor. ESM; no UI framework dependency.
import {createEditor, moveSelectedBlock} from 'editory';
import 'editory/style.css';
const editor = createEditor({
element: document.querySelector('#editor'),
content: '# Hello\n\nStart writing.',
onUpdate: editor => save(editor.getMarkdown()),
});
const unsubscribe = editor.subscribe(editor => renderToolbar(editor.state));
editor.chain().focus().toggleMark('bold').run();
const transaction = moveSelectedBlock(editor.state, 1);
if (transaction) editor.view.dispatch(transaction);
// On unmount:
unsubscribe();
editor.destroy();The host provides semantic CSS color tokens and labels. createEditor requires
a DOM when instantiated; schema, Markdown and block transaction helpers also run
in Node. Never instantiate a view during server rendering.
setMarkdown(source) and setJSON(doc) update without firing onUpdate by default.
Pass true as the second argument to notify. getJSON() preserves block IDs;
Markdown intentionally contains no internal identifiers. Unsupported Markdown
throws before mutation instead of silently discarding tables, tasks or raw HTML.
Native ProseMirror plugins can be passed in plugins. This version has a fixed
CommonMark + strike + figure schema. Applications adding custom persisted node
types must also provide a matching codec; arbitrary custom schema injection is
not currently exposed.
