Getting started

Introduction

Matra is a headless rich text editor framework. It gives you a document model, an extension API and a command system · and stays out of the way of your interface.

Why another editor

Every editor framework leaks its engine into your code. You import the engine's types, write against its internals, and upgrading it becomes your problem. Matra wraps the engine completely: your document is plain JSON and no engine type appears in a public signature.

It also has no runtime dependencies. The document model, transforms, position mapping, editor state and the editable view are written from scratch, which is why an app bundles 31.1 kB gzipped instead of 117.

The three ideas

Everything else follows from these, and there is not a fourth.

Install

npm i @matrajs/core
import { createEditor, starterKit } from '@matrajs/core'

const editor = createEditor({ extensions: starterKit, content: '<p>Hello.</p>' })
editor.mount(document.querySelector('#editor'))

That is a working editor. It will look like unstyled text until you write some CSS, which is what headless means — Styling covers it in a page.

What is in the box

PackageLicenceWhat it is
@matrajs/coreMIT The engine and 79 extensions
@matrajs/react, /vue, /svelte, /solid MITFramework bindings · thin, and optional
@matrajs/aiPaid Streaming edits that survive concurrent typing
@matrajs/collabPaid An authority, step rebasing, remote cursors
@matrajs/versionsPaid Snapshots, a real diff, restore

Table of contents, unique block ids, drag handle and comments are in the core and stay there. They are paid features elsewhere.

Where to go next

Depending on what you came here to do:

Matra is 1.0. The public API is stable and follows semver from here. What has not yet met real IME users on iOS and Android at scale is the view · if your users type Bangla, Chinese or Japanese, test before you commit.

Edit this page on GitHub