Content Formats

Persist Editor content as BlockNote JSON or Markdown.

Overview

Editor.Root has one content API for every supported format:

<Editor.Root
  content={content}
  contentFormat="blocknote"
  onContentChange={({ content }) => saveContent(content)}
>
  <Editor.View />
</Editor.Root>

Set contentFormat to choose the canonical type Cubitt receives and emits. Consumers do not need separate props for Markdown and BlockNote JSON.

BlockNote JSON

Use contentFormat="blocknote" when the consuming app can persist BlockNote blocks directly. This is the richest mode and supports the full free BlockNote editing surface, including toggle blocks, file/media blocks, tables, slash commands, drag handles, side menu, and table handles.

<Editor.Root
  content={blocks}
  contentFormat="blocknote"
  onContentChange={({ content }) => saveBlocks(content)}
  uploadFile={uploadFile}
>
  <Editor.View />
</Editor.Root>

In this mode, content is EditorPartialBlock[], and onContentChange emits EditorPartialBlock[].

Markdown

Use contentFormat="markdown" when the consuming app stores Markdown as the source of truth.

<Editor.Root
  content={markdown}
  contentFormat="markdown"
  onContentChange={({ content }) => saveMarkdown(content)}
>
  <Editor.View />
</Editor.Root>

In this mode, content is a string, and onContentChange emits a Markdown string.

Markdown mode intentionally narrows the editor UI to blocks and inline content that can round-trip through Markdown. It does not expose uploadFile or resolveFileUrl because dedicated BlockNote file and media blocks are not native Markdown content.

Round trip

Markdown mode keeps the Markdown it is given. Each block remembers the source it was parsed from, and onContentChange writes blocks you have not edited back exactly as they were, including their list markers, numbering, table alignment, escapes and spacing. Undoing an edit returns the original string, so apps can compare it with saved content to detect unsaved changes.

Edited blocks are written as Markdown that reads back as the same content:

  • Bullets keep the document's marker, and numbered items keep their number style.
  • Characters that would otherwise become formatting, such as a literal *, _ or a line that starts with #, are escaped.
  • Tables are written without padding.
  • Where Markdown delimiters would be ambiguous, such as italic text directly followed by bold text, styles are written as <em> and <strong> tags.

When reading Markdown, wrapped lines in a list item stay in that item, and indented code blocks and underlined (setext) headings are read as code blocks and headings.

Raw HTML

Raw HTML that BlockNote cannot write back is kept as literal text, so editing never deletes it. This covers XML-style tags used in prompts and instructions, such as <example> or <placeholder>, HTML comments, and unsupported elements such as <div> or <details>. They appear in the editor as typed and return unchanged in onContentChange. HTML with a Markdown equivalent, such as <strong>, <em>, <br>, lists, tables and images, still renders as rich content; write \<strong> to keep such a tag as literal text. Code spans and fenced code blocks are never changed.

Line breaks

Markdown mode reads each newline inside a paragraph as a line break. By default it writes line breaks in edited blocks as Markdown hard breaks, with a backslash at the end of the line. Set markdownLineBreaks="newline" to write plain newlines instead, so Markdown such as agent instructions keeps its lines exactly as written.

<Editor.Root
  content={markdown}
  contentFormat="markdown"
  markdownLineBreaks="newline"
  onContentChange={({ content }) => saveMarkdown(content)}
>
  <Editor.View />
</Editor.Root>

Renderers that follow CommonMark strictly show a plain newline as a space. Markdown mode, and renderers with line-break support such as remark-breaks, show it as a line break.

Supported Blocks

BlockNote mode supports the default free BlockNote block set:

BlockBlockNote JSONMarkdown
ParagraphYesYes
Heading 1-6YesYes
QuoteYesYes
Bullet listYesYes
Numbered listYesYes
ChecklistYesYes
Code blockYesYes
TableYesYes
DividerYesYes
ImageYesMarkdown image syntax
FileYesMarkdown link only
VideoYesMarkdown link only
AudioYesMarkdown link only
Toggle headingYesNo
Toggle list itemYesNo

Markdown can preserve file, video, and audio references as links, but those links are not the same as BlockNote's dedicated file/media blocks. If an app needs first-class uploads, previews, captions, and file panels, persist BlockNote JSON.

Controlled Content

Use content for controlled content. This is the right path for reactive data sources such as TanStack DB query results.

<Editor.Root
  content={markdown}
  contentFormat="markdown"
  onContentChange={({ content }) => setMarkdown(content)}
>
  <Editor.View />
</Editor.Root>

contentFormat determines the type for all content props and change events.

On this page