Every extension
uniqueId
Declare the attribute so the schema keeps it.
Without this the id is dropped on the way in: undeclared attributes do not survive, which is a security property rather than an oversight. The id is written to the element as `data-<attribute>` and read back from there, so it survives HTML as well as JSON.
Adding it
import { createEditor, document, paragraph, text, uniqueId } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, uniqueId({ … })],
element: document.querySelector('#editor'),
})
There is no separate package · uniqueId is already in @matrajs/core, and an extension you do not import is not in your bundle. document, paragraph and text are the floor every document needs.
Options
| Field | Type | |
|---|---|---|
types | string[] | Which node types get an id. Defaults to the blocks in the box. |
attribute | string | The attribute the id is written to. |
generate | () => string | Supply your own, when the ids have to match something outside the editor. |