Core concepts
The block model
The heart of EditorData is the blocks array: Block objects that preserve order. Each Block carries its type, type-specific data, and optional tunes metadata.
| Field | Type | Description |
|---|---|---|
| id | string | undefined | Optional unique identifier, assigned by the editor at creation. |
| type | BlockToolType | Literal key that binds the block to its schema, input component, and renderer. |
| data | object | Type-specific data object: shape differs per block type. |
| tunes | BlockTunes | undefined | Optional cross-type tune metadata dictionary. Key is the tune name, value is free-form data. |
{
"time": 1745000000000,
"version": "1.0.0",
"blocks": [
{
"id": "abc123",
"type": "header",
"data": { "html": "Hello world", "level": "h1" }
},
{
"id": "def456",
"type": "paragraph",
"data": { "html": "This is a <b>rich</b> paragraph." }
}
]
}Block tools vs inline tools
Block tools create top-level slots directly inside EditorData. Inline tools decorate text inside the html payload a block contains. The two layers are entirely separate: they cannot be substituted for each other.
JSON-first output
The editor never persists HTML. When you call editor.data.extract(), you get pure EditorData JSON: complete including media URLs. This JSON can be stored in a database, personalised, or converted to other formats.
import { Editor } from '@clepit/core';
const editor = Editor.create({ containerId: 'editor' });
const data = editor.data.extract();
// data: EditorData
// {
// time: 1745000000000,
// version: '1.0.0',
// blocks: [ ... ]
// }Editor vs Renderer
Block tunes
Tunes are a type-agnostic metadata slot for any block type. The key is the tune name set by the system or a plugin, and the value is typed to BlockTuneData: any combination of string, number, boolean, or null. Tunes can add semantics without breaking the core data shape.
{
"id": "abc123",
"type": "paragraph",
"data": { "html": "Some text." },
"tunes": {
"textAlign": { "alignment": "center" },
"visibility": { "hidden": false }
}
}