@open-commune/editor
v0.1.5
Published
The rich-text editor: document schema, extensions and their sanitisation.
Downloads
295
Readme
@open-commune/editor
The rich-text editor of Open Commune: document schema, TipTap extensions, and the sanitisation that guards them.
Split out from the application so that the same document schema is shared by the editor writing the content and the server storing it — a document accepted by one is valid for the other.
Install
npm install @open-commune/editorUse
import { Callout, Details, Embed, FileNode, ImageNode, Uid, sanitizeDoc } from '@open-commune/editor';
// client — add the shared nodes to a TipTap editor
const editor = new Editor({
extensions: [StarterKit, Uid, Callout, ImageNode, FileNode, Embed, Details],
content: doc,
});
// server — never trust a document that came over the wire
const safe = sanitizeDoc(incoming);sanitizeDoc returns a document conforming to the schema, dropping anything the schema does not allow. It is what stands between stored content and injected markup, so run it on every write path.
Licence
AGPL-3.0-or-later.
