Getting started
There are two ways in. Take the Markdown editor if you want a finished component. Build on the core if you want to choose what the editor can do, or add to it.
The Markdown editor
pnpm add @eventuras/scribo-markdown react react-dom
React is the only peer dependency. Lexical and the Scribo packages the editor is built from come with it.
Import the stylesheet once, and render the editor:
import "@eventuras/scribo-markdown/style.css";import { MarkdownEditor } from "@eventuras/scribo-markdown";function Notes() {return (<MarkdownEditorinitialMarkdown="# Hello"placeholder="Write something…"onChange={(markdown) => console.log(markdown)}/>);}
onChange is called with the document as Markdown. initialMarkdown is read on the first render only: the editor is made once, and later changes to the prop do not reach it.
In a native HTML form, use MarkdownInput. It keeps the Markdown in a hidden input, so it is submitted with the form under its name:
import { MarkdownInput } from "@eventuras/scribo-markdown";<form><MarkdownInput name="description" label="Description" defaultValue="# Hello" maxLength={500} /><button type="submit">Save</button></form>;
Callouts and schedules are plugins, passed in the plugins prop. The package page has them, and the rest of the props.
An editor on the core
The core is a set of Lexical extensions. You name the ones you want as the dependencies of an extension of your own, and mount that with Lexical's LexicalExtensionComposer.
pnpm add @eventuras/scribo-core @eventuras/scribo-react @lexical/react@0.50.0 @lexical/markdown@0.50.0 react react-dom
@lexical/markdown is needed only by the core's ./markdown entry. Install the @lexical/* packages at exactly 0.50.0: that is the version every Scribo package pins, the same one Payload CMS uses.
import { BaseExtension, ToolbarExtension, defineExtension } from "@eventuras/scribo-core";import { HeadingExtension } from "@eventuras/scribo-core/extensions/heading";import { ListsExtension } from "@eventuras/scribo-core/extensions/list";import { MarkdownExtension } from "@eventuras/scribo-core/markdown";import { Placeholder, Toolbar } from "@eventuras/scribo-react";import { LexicalExtensionComposer } from "@lexical/react/LexicalExtensionComposer";const editor = defineExtension({name: "my-editor",dependencies: [BaseExtension, HeadingExtension, ListsExtension, ToolbarExtension, MarkdownExtension],});export function Editor() {return (<LexicalExtensionComposer extension={editor}><Toolbar /><Placeholder>Write something…</Placeholder></LexicalExtensionComposer>);}
BaseExtensiongives paragraphs, bold, italic, strikethrough, inline code and undo.- The entries under
@eventuras/scribo-core/extensions/*are opt-in:heading,quote,list,linkandcode. Each adds its command and its toolbar items. ToolbarExtensioncollects the toolbar items, andToolbarfrom@eventuras/scribo-reactrenders them as plain buttons withscribo-class names. It ships no CSS, so the styling is yours.MarkdownExtensionreads and writes Markdown for the extensions the editor has loaded, and turns Markdown typed in the editor into formatting.
To get the document out, use exportMarkdown(editor) and importMarkdown(editor, markdown) from @eventuras/scribo-core/markdown, or exportJSON(editor) and importJSON(editor, json) from @eventuras/scribo-core. The core's page describes the toolbar and Markdown in full, and the React bindings' page lists the hooks for a toolbar with your own markup.
Adding an extension: chords
An extension from another package goes in the same list. @eventuras/scribo-chords adds songs with chords:
pnpm add @eventuras/scribo-chords
import "@eventuras/scribo-chords/style.css";import { ChordsExtension } from "@eventuras/scribo-chords";import { ChordsReactExtension } from "@eventuras/scribo-chords/react";const editor = defineExtension({name: "my-editor",dependencies: [BaseExtension,HeadingExtension,ChordsExtension,ChordsReactExtension,ToolbarExtension,MarkdownExtension,],});
Nothing else changes. ChordsExtension contributes its toolbar items and its Markdown transformer by itself: the toolbar gets an item that inserts a song, typing [Am] in a song line makes a chord, and in Markdown a song is a fenced chordpro block. ChordsReactExtension draws the chords as chips.
For an editor where the whole document is one song, use SongDocumentExtension in place of ChordsExtension. That is what the song editor below is built from:

The chords page covers the song model, the reader, play mode and transposing. To make an extension of your own, see Writing an extension.
Without React, or without a DOM
The core imports only Lexical. buildEditorFromExtensions(extension) from @eventuras/scribo-core gives an editor with no DOM, for a server, a migration or a test:
import { BaseExtension, buildEditorFromExtensions, defineExtension } from "@eventuras/scribo-core";import { MarkdownExtension, exportMarkdown, importMarkdown } from "@eventuras/scribo-core/markdown";const editor = buildEditorFromExtensions(defineExtension({ name: "convert", dependencies: [BaseExtension, MarkdownExtension] }),);importMarkdown(editor, "Some **bold** text");exportMarkdown(editor);