Content
Markdown Support
Import and export Markdown via the serialization pipeline — limitations and storage patterns.
Lextrix is a rich-text engine with a ChangeSet document model — not a Markdown-first editor. In 2.x, Markdown enters and leaves through the serialization pipeline via importContent and exportContent.
Import Markdown
editor.importContent('# Title\n\n**bold** paragraph.', 'markdown');
editor.importContent('- item one\n- item two', 'markdown');The Markdown serializer converts to ChangeSet ops, then the editor renders rich text with undo/history intact.
Export Markdown
const md = editor.exportContent('markdown');List available formats:
editor.listExportFormats(); // ['json', 'html', 'markdown', 'mdx', ...]What round-trips
The built-in serializer covers a subset of Markdown — not full CommonMark/GFM:
- Headers (
#–###) - Bold, italic, inline code
- Ordered and bullet lists (export always uses
1.for ordered) - Links and images
- Simple GFM tables on import (no colspan/rowspan)
- Code blocks
What does not export to Markdown
| Feature | Export path |
|---|---|
| Native editor tables | exportContent('html') only — throws SerializationError for Markdown |
| Align, color, font | HTML or JSON |
| Combined bold+italic | May export as bold only |
| Video embeds | [video](url) in Markdown/MDX |
Storage recommendations
| Use case | Format |
|---|---|
| Full fidelity + undo | ChangeSet JSON via getContents() |
| CMS with Markdown storage | exportContent('markdown') on save, importContent(md, 'markdown') on load |
| Read-only render | exportContent('html') |
| Search / LLM context | getText() |
ChangeSet remains the internal model. Markdown is a boundary format — import on open, export on save.
Clipboard paste
The clipboard module also normalizes pasted plain text that looks like Markdown into Lextrix formats. For programmatic loads, prefer importContent over paste simulation.
Next steps
- Serialization — full API, headless host, custom serializers
- MDX Support — when Markdown is not enough
- ChangeSet guide on GitHub