ModaEditor — Rich Text Editor

Headless editor core — React/Vue/Svelte/vanilla.

A framework-agnostic headless rich-text editor built on immutable JSON AST documents and transaction updates.

All editor logic — document model, transactions, selection, input binding — lives in a pure TypeScript core; each framework adapter is a thin reactive binding. Five renderers emit the same DOM contract, so behavior is identical everywhere.

One starter bundle covers marks, headings, quotes, lists, tasks, tables, code blocks, links, images, alignment, history — and extensions/plugins/input rules allow infinite growth.

Free (MIT)React · Vue 3 · Vue 2.7 · Svelte 5 · VanillaImmutable EditorState · transactionsTypeScript

Live demo

Runs on the real core loaded from CDN. Each toolbar button maps 1:1 to an editor.commands.* call (API name in tooltip); every edit streams the HTML serialization and document JSON to the panel below, and events subscribed via editor.on() flow at the bottom.

Packages by environment

EnvironmentPackageNotes
React@moda-editor/reactuseEditor + EditorView; custom node views are React components
Vue 3@moda-editor/vueuseEditor + EditorView SFC, useEditorState subscribes outside
Vue 2.7@moda-editor/vue2Same Composition API usage as Vue 3
Svelte 5@moda-editor/sveltecreateEditorStore + EditorView, readable store binding
Vanilla JS / CDNmoda-editor.jsOne <script> line, no build tools — window.ModaEditor
No framework@moda-editor/coreUse headless createEditor + mountEditor directly

Install via npm

npm i @moda-editor/react # React
npm i @moda-editor/vue # Vue 3
npm i @moda-editor/vue2 # Vue 2.7
npm i @moda-editor/svelte # Svelte 5
npm i @moda-editor/core # Headless core only
npmjs.com/package/@moda-editor/react →

Use via CDN

https://editor.modaolive.com/moda-editor.js
https://editor.modaolive.com/style.css

Get started in 3 steps

  1. 1

    Install package

    Install an adapter like npm i @moda-editor/react, or load the core with a single CDN <script>.

  2. 2

    Pass extensions

    starterExtensions() alone bundles schema·commands·keymaps·input rules·history. Pass the initial doc JSON via doc.

  3. 3

    Render & control

    Adapters only need one <EditorView>. Wire the toolbar to editor.commands.*; vanilla uses mountEditor(el, options).

// npm i @moda-editor/react
import { EditorView, starterExtensions, useEditor } from "@moda-editor/react";
import "@moda-editor/react/styles.css";

function App() {
  const { editor, state } = useEditor({
    doc: myDoc,                       // DocNode JSON (empty doc if omitted)
    extensions: starterExtensions(),  // starter schema·commands·keymaps·history
  });

  return (
    <>
      <button onClick={() => editor.commands.toggleBold()}>B</button>
      <button onClick={() => editor.commands.setHeading(2)}>H2</button>
      <EditorView editor={editor} />
    </>
  );
}
// state is an immutable EditorState — === comparison decides whether to re-render

EditorState is immutable — it returns the same reference until a change, so the React useSyncExternalStore snapshot contract holds structurally.

Usage by feature — what to use

Every feature runs on core commands/options — adapters just forward them. Hover a toolbar button in the live demo to see the matching API.

Formatting (inline marks)

FeatureHow to enable (option/prop/input)Core API
Bold·italic·underlineToolbar / Mod-B·I·Ucommands.toggleBold() / toggleItalic() / toggleUnderline()
StrikethroughToolbar buttoncommands.toggleStrike()
Super/subscript—commands.toggleSuperscript() / toggleSubscript()
Inline codeToolbar buttoncommands.toggleCode()
Change mark attrs—commands.setMarkAttr("link", { href })
Clear formatting—clearFormat (starter helper)

Blocks

FeatureHow to enable (option/prop/input)Core API
HeadingsToolbar buttoncommands.setHeading(1~6)
BlockquoteToolbar buttoncommands.toggleQuote()
Code blocktoggleCodeBlock — incl. language pickercommands.setCodeLanguage(lang) / highlightCode
Divider · hard break—commands.insertHorizontalRule() / insertHardBreak()
AlignmentWhen align feature is registeredcommands.setAlign("left"|"center"|"right")
Split / exit blockEnter / Mod-EntersplitBlock / exitBlock commands

Lists & tables

FeatureHow to enable (option/prop/input)Core API
Bulleted · numbered listsToolbar buttoncommands.toggleBulletList() / toggleOrderedList()
Task listToolbar buttoncommands.toggleTaskList() / toggleTaskItem()
Indent / outdentTab / Shift-Tabcommands.sinkListItem() / liftListItem()
Insert table · rows · columns—commands.insertTable(r,c) / addTableRow / addTableColumn / deleteTable
Cell navigationTab inside a tablenextCell / prevCell

Links, images & paste

FeatureHow to enable (option/prop/input)Core API
LinkToolbar / [text](url) input rulecommands.setLink(href) / unsetLink()
ImageInsert URL / paste · dropcommands.insertImage(src, alt) / updateImage / deleteImage
Image upload hookonImageUpload option — async File → URLIf omitted, inserts instantly as a FileReader data URL
HTML paste sanitizingAutomatic — strips script·on*·javascript:parseHTML + sanitizeHTML built-in pipeline
Paste from Word · Google DocsAutomatic — prevents stray bolds & wrapper flatteningOn external paste: structure cleanup + history skip
paste event—editor.on("paste", ({html, text}) => …)

State, events & history

FeatureHow to enable (option/prop/input)Core API
Immutable state—editor.state — same reference until a change
Render subscriptionAdapters wire it automaticallyeditor.subscribe(fn) / getSnapshot()
Semantic events—editor.on("update"|"selectionUpdate"|"transaction"|"focus"|"blur"|"destroy")
Undo / redostarterExtensions includes history, Mod-Z / Mod-Shift-Zcommands.undo() / redo(), canUndo / canRedo
Read-onlyEditorOptions.editable: falseSignals the view to disable contenteditable
Collaboration (CRDT)bindCollab — @moda-editor/collab-yjsLifecycle binding via subscribe·apply, Point-based position mapping
Manual dispatch—editor.dispatch(tr) — single entry point for all changes

Doc & extensions

FeatureHow to enable (option/prop/input)Core API
JSON doc modeldoc: DocNode optioncreateDoc(content) / createText(text, marks)
HTML serialization—serializeToHTML(doc, schema)
HTML → doc—parseHTML(html, schema) → createDoc(nodes)
Custom node viewEditorView's nodeViews prop{ codeBlock: MyComponent } — NodeViewProps
Extension systemextensions arrayExtension = nodes + marks + commands + keymap + inputRules + plugins
Starter bundleextensions: starterExtensions()Schema·commands·keymaps·input rules·history bundle
Theme--me-* CSS variables in styles.css.me-* DOM class contract for custom

Common recipes

Copy-paste-ready code snippets.

Wire toolbar buttons

editor.commands is the command registry from extensions — bind to onClick

<button onClick={() => editor.commands.toggleBold()}>B</button>
<button onClick={() => editor.commands.setHeading(2)}>H2</button>
<button onClick={() => editor.commands.toggleTaskList()}>{t.todoL}</button>
<button onClick={() => editor.commands.undo()}>↶</button>

// returning false = not applicable at the current selection → use as a button-disabled signal

Autosave (update event)

Fired on every doc/selection change — debounce & send to server

editor.on("update", ({ state, prevState }) => {
  if (state.doc === prevState.doc) return;  // skip when only the selection changed
  scheduleSave(serializeToHTML(state.doc, editor.schema));
});

// or store the document JSON as-is
const payload = JSON.stringify(state.doc);

Load HTML → doc

Parses existing HTML to initial doc — built-in sanitizer removes dangerous tags

import { createEditor, createDoc, parseHTML, starterExtensions }
  from "@moda-editor/core";

const extensions = starterExtensions();
const boot = createEditor({ extensions });
const doc = createDoc(parseHTML(savedHtml, boot.schema));

const editor = createEditor({ extensions, doc });

Image upload

Files from paste/drop/picker get replaced with server upload URLs

useEditor({
  extensions: starterExtensions(),
  onImageUpload: async (file) => {
    const form = new FormData();
    form.append("file", file);
    const res = await fetch("/api/upload", { method: "POST", body: form });
    return (await res.json()).url;   // the editor inserts it as src
  },
});

Custom node view (React)

Replace a node type's rendering with your component — content gets an editor outlet

function CodeBlockView({ node, editor, path, content }: NodeViewProps) {
  return (
    <div className="my-codeblock">
      <select onChange={(e) =>
        editor.commands.setCodeLanguageAt(path, e.target.value)} />
      {content}   {/* editing area — must be rendered */}
    </div>
  );
}

<EditorView editor={editor} nodeViews={{ codeBlock: CodeBlockView }} />

Event log & external sync

transaction emits every tr pre-filter — the lowest-level hook for debug/sync

editor.on("transaction", ({ tr, state }) => console.log(tr.steps));
editor.on("paste", ({ html, text }) => console.log(t.pasteL, text));
editor.on("blur",  () => saveDraft());
editor.on("destroy", () => cleanup());

// share an externally created editor with the view
const editor = createEditor({ extensions: starterExtensions() });
<EditorView editor={editor} />   // the view handles subscription

Same behavior across frameworks

React, Vue, Svelte, and Vanilla renderers all emit the same DOM contract (.me-* classes) and are verified by the shared conformance spec (runWidgetConformance). The API and CSS variables (--me-*) you learn on one platform carry over to the rest.

Source & docs

github.com/park-taejoon/moda-editor-releases
  • Platform guides — React / Vue 3 / Vue 2.7 / Svelte 5 / Vanilla
  • Feature guides — custom nodeViews, searchable list example
  • Theming — --me-* CSS variables, migration mapping doc

How to use

Headless editor core — React/Vue/Svelte/vanilla.

rich text editor

Related tools