Scribo markdown editor

Markdown editor built on Lexical framework. Intended to be used as part of eventuras, but also packed as a standalone component. Scribo is a WYSIWYG editor with markdown export.

The editor should provide simple and intuitive editing of markdown text, with a focus on the most common use cases.

Test the scribo editor online demo.

Lexical version: we are keeping the lexical version in sync with the lexical version used in Payload CMS, to prevent multiple versions making trouble.

Installation

bash
pnpm add @eventuras/scribo-markdown

Renamed in 0.11.0: this package was called @eventuras/scribo. That name is deprecated and now only re-exports @eventuras/scribo-markdown, so existing imports keep working. To move, replace @eventuras/scribo with @eventuras/scribo-markdown in your dependencies and imports, style.css and the plugin subpaths included.

Usage

Important: You must import the CSS file for Scribo to display correctly:

MarkdownEditor (WYSIWYG Editor)

tsx
import "@eventuras/scribo-markdown/style.css";
import { MarkdownEditor } from "@eventuras/scribo-markdown";
function MyComponent() {
return <MarkdownEditor initialMarkdown="# Hello World" />;
}

MarkdownInput (Form-ready Input)

For use with native HTML forms (FormData API):

tsx
import "@eventuras/scribo-markdown/style.css";
import { MarkdownInput } from "@eventuras/scribo-markdown";
function MyForm() {
return (
<form>
<MarkdownInput
name="description"
label="Description"
placeholder="Enter markdown..."
defaultValue="# Hello"
maxLength={500}
className="mb-4"
labelClassName="font-bold"
editorClassName="border rounded"
errorClassName="text-red-500"
/>
<button type="submit">Submit</button>
</form>
);
}

The MarkdownInput component is framework-agnostic and provides:

  • Hidden input for FormData submission
  • Optional label and validation
  • Flexible styling via className props
  • Character limit validation

Dependencies

React is the only peer dependency:

bash
pnpm add react react-dom

The Lexical packages and the two Scribo packages below are regular dependencies of Scribo and are installed with it.

Code blocks and syntax highlighting

Code blocks are plain: Scribo does not syntax highlight code, and never has. The toolbar's language picker only sets the language of the code fence, which is kept in the Markdown for whatever renders it later.

There is nothing to import or install for this. Earlier versions of this README told apps to import Prism grammars; that had no effect, and with pnpm's isolated installs an app cannot resolve prismjs through Scribo in any case.

The language list comes from @eventuras/scribo-code-prism. Highlighting is an option of that package for editors built on the core (see below); MarkdownEditor does not switch it on.

Packages

Scribo is a small monorepo. @eventuras/scribo-markdown is the Markdown editor above, and a preset over a core that can also be used on its own:

  • @eventuras/scribo-markdown: MarkdownEditor and MarkdownInput, with the callout and schedule plugins at ./plugins/callout and ./plugins/schedule. The only package that knows eventuras' defaults.
  • @eventuras/scribo-core: the clean core. Extensions for rich text, a toolbar built from data, Markdown and code blocks, on Lexical's extension API. No highlighter and no app-specific nodes.
  • @eventuras/scribo-react: React bindings for the core: a toolbar built from its items, a language picker for code blocks and a placeholder.
  • @eventuras/scribo-code-prism: Prism as a syntax highlighter for the core's code blocks. It gives the language list, and highlighting as an option.
  • @eventuras/scribo-chords: songs with chords, as an extension for the core: chord and song nodes, transposing, capo, ChordPro, a reader and a play mode. Its song model at ./song needs neither Lexical nor React.
  • @eventuras/scribo: deprecated, the old name of @eventuras/scribo-markdown. It re-exports it and nothing else.

Every package pins lexical and @lexical/* to the same exact version.

Plugins

MarkdownEditor and MarkdownInput take plugins:

tsx
import { MarkdownEditor } from "@eventuras/scribo-markdown";
import { calloutPlugin } from "@eventuras/scribo-markdown/plugins/callout";
import { schedulePlugin } from "@eventuras/scribo-markdown/plugins/schedule";
<MarkdownEditor plugins={[schedulePlugin, calloutPlugin]} />;

A plugin is a ScriboPlugin object (nodes, transformers, toolbarButtons, editorPlugins), or wraps a Lexical extension in its extension field, which is how the two plugins above are made. The editor is set up once, from the plugins of the first render; later changes to the plugins prop do not reach it.

Building your own editor on the core

tsx
import { BaseExtension, ToolbarExtension, defineExtension } from "@eventuras/scribo-core";
import { codeBlocks } from "@eventuras/scribo-core/extensions/code";
import { HeadingExtension } from "@eventuras/scribo-core/extensions/heading";
import { MarkdownExtension } from "@eventuras/scribo-core/markdown";
import { Toolbar } from "@eventuras/scribo-react";
import { prismHighlighter } from "@eventuras/scribo-code-prism";
import { LexicalExtensionComposer } from "@lexical/react/LexicalExtensionComposer";
const editor = defineExtension({
name: "my-editor",
dependencies: [
BaseExtension,
HeadingExtension,
...codeBlocks({ highlighter: prismHighlighter, highlight: true }),
ToolbarExtension,
MarkdownExtension,
],
});
<LexicalExtensionComposer extension={editor}>
<Toolbar />
</LexicalExtensionComposer>;

See packages/scribo-core, packages/scribo-react, packages/scribo-code-prism and packages/scribo-chords.

Develop

bash
pnpm install
pnpm dev # the demo, with the workspace packages loaded from source
pnpm lint
pnpm test
pnpm build # builds the packages in dependency order

Release

Quick release process:

bash
# 1. Create changeset (choose one)
pnpm changeset # Manual (recommended)
pnpm changeset:suggest # Auto-generate from commits
# 2. Version package
pnpm changeset:version
# 3. Commit and push (create PR to main)
git checkout -b release/scribo-v0.x.x
git add .
git commit -m "chore(scribo): release v0.x.x"
git push origin release/scribo-v0.x.x
# 4. Merge PR to main, then automated workflow will publish to npm and create GitHub release

For detailed release instructions, including setup and troubleshooting, see RELEASE.md.

Credits

Scribo is built on the Lexical framework, and most of the code in the repo is done by Meta under MIT license.

Learn More