Add data attributes to your rendered HTML to enable progressively richer visual editing:
Example of a fully annotated slide block:
If you can't modify the markup (e.g., using a 3rd party component library), use comment syntax to specify block attributes:
Supported attributes: block-uid, block-readonly, edit-text, edit-link, edit-media, block-add
Add data-linkable-allow to elements that should navigate during edit mode (paging links, facet controls, etc.):
The data-edit-text|edit-media|edit-link attributes support Unix-style paths to edit fields outside the current block:
This allows fixed parts of the page (like headers) to be editable without being inside a block.
Add data-block-readonly (or <!-- hydra block-readonly --> comment) to disable inline editing for all fields inside an element:
Or using comment syntax:
When rendering Slate nodes to DOM, your renderer must follow these rules for data-node-id:
hydra.js uses node-ids to map between Slate's data model and your DOM. When restoring cursor position after formatting changes, it walks your DOM counting Slate children.
Slate data structure (value is an array but always contains a single root node):
Renderer:
Usage: