genesis-editor

Usage

Seed or control the document, save it automatically, and drive the editor from code.

Documents are arrays of blocks#

The editor reads and writes BlockNote's block JSON. Store it as is in your database. You can pass shorthand when creating content, such as content: "Text" instead of a full text array, and onChange always gives you complete blocks.

[
  {
    "id": "c1f…",
    "type": "heading",
    "props": { "level": 2, "textColor": "default", "textAlignment": "left" },
    "content": [{ "type": "text", "text": "Meeting notes", "styles": {} }],
    "children": []
  }
]

Uncontrolled#

Pass initialContent for the first render and read changes from onChange. This is the simplest way to save to your own backend.

Controlled#

Pass value and update it from onChange. When value changes to something other than the current document, the editor replaces its content. Changes made through value don't call onChange again.

Autosave with persist#

persist saves the document to localStorage shortly after each edit, flushes when the tab is hidden or closed, and restores it on the next visit. Give each document its own key. onPersistStatusChange drives a "Saving…/Saved" indicator.

A saved document wins over initialContent. Use the ref's clearPersisted() to forget it.

Read-only#

editable={false} renders the document without the side menu, toolbars, or mobile toolbar.

Ref methods#

A ref gives you getMarkdown(), setMarkdown(), getBlocks(), setBlocks(), setHTML(), importFile(), focus(), and the underlying BlockNote editor. See the API reference.