All methods are
async and must return a Promise. You can use async/await
or return a Promise directly — both are fully supported.loadState()
Fetches the raw initial content for the entity being edited. blökkli calls this method once, immediately after the editor overlay activates. The return value is passed directly to mapState() as its state argument.
You have full control over the return shape — mapState() is responsible for the transformation.
Signature
mapState(state)
Transforms the raw value returned by loadState() into blökkli’s expected internal format. blökkli calls this immediately after loadState() and whenever it needs to reconcile state (for example, after an undo/redo operation).
Your return value must include at minimum a blocks array.
Signature
MappedState is exported from @blokkli/editor. Each block object in the
blocks array must include uuid (string), bundle (string), and
hostField (string) at minimum. Additional properties are passed as props to
your block components.getAllBundles()
Returns the list of block types the current user can add. blökkli calls this once on editor activation and uses the result to populate the “Add block” panel. Each bundle object requires at least an id and a label.
Signature
getFieldConfig()
Returns configuration for each block field (region) in the current entity, including which block types are allowed in each region. blökkli uses this to validate drag-and-drop targets and to enforce allowed block types.
Signature
The
name value in each FieldConfig entry must match the name prop on the
corresponding <BlokkliField> component in your template. Mismatches cause
the field to behave as if it has no allowed bundles.addNewBlock(options)
Persists a newly added block to your backend. blökkli calls this when the user drags a block type from the add-block panel, or clicks a block type to insert it at the current cursor position.
Signature
The block type identifier to create (matches an
id from getAllBundles()).The field name of the target region (matches a
name from getFieldConfig()).UUID of the block that the new block should be placed after.
null means
insert at the beginning of the field.Initial option values for the new block, if any defaults were configured.
moveBlock(options)
Persists the new position of a single block after the user drags it to a different location. blökkli updates its internal state optimistically and calls this method to sync the change to your backend.
Signature
UUID of the block being moved.
The target field name. May differ from the block’s current field if the user
moves it across regions.
UUID of the block that should precede the moved block in its new position.
null places it at the start of the field.moveMultipleBlocks(options)
Persists the new positions of multiple blocks simultaneously. blökkli calls this when the user has selected more than one block and drags the selection to a new position.
Signature
Ordered array of UUIDs for the blocks being moved. The order reflects the
blocks’ relative sequence after the move.
The target field name for all moved blocks.
UUID of the block that the moved group should be placed after.
null places
the group at the start of the field.
