A document is StoredBlock[]: plain JSON, written back by the editor on every change.
Store it as it is. Built-in types start with md:; any other type is a plugin's, so
never rename a plugin's type — stored documents refer to it.
interface StoredBlock {
type: string; // 'md:p', 'md:h2', 'md:ul'… or a plugin's type
indent: number; // 0…6
text?: string; // inline markdown (raw text for md:code)
props?: Record<string, unknown>; // a plugin's settings; md:todo { checked }, md:code { lang }
blocks?: StoredBlock[]; // a container's nested document (one level)
}Edit the document and watch its stored form. Lists are blocks with an indent, not nested arrays.
[
{
"type": "md:h3",
"indent": 0,
"text": "Opening hours"
},
{
"type": "md:ul",
"indent": 0,
"text": "Monday to Friday: **9–17**"
},
{
"type": "md:ul",
"indent": 1,
"text": "lunch break 12–13"
},
{
"type": "gap",
"indent": 0,
"props": {
"lines": "1"
}
}
]blocksSchemaFor(plugins) from @atom-forge/brickee/schema is a zod schema for saved documents. Break the JSON to see the errors.
Valid: 2 block(s)