Low-level block focus helpers.
Access:
app.getService('blockFocus')
App code:
const blockFocus = app.getService('blockFocus');
Plugin:
const blockFocus = this.app.getService('blockFocus');
focus#
Focuses a block or element, optionally placing the caret at start/end, setting data-selected on focusable blocks, and emitting block:focus events.
Parameters:
- blockOrEl (
Block | HTMLElement) — block instance or its root element - options (
object) — object with the keys below- alwaysSelect (
boolean) — force reselecting the block even when it is already focused - caret (
any) — place the caret at'start'or'end'of the block after focusing - nestedCaret (
boolean) — allow the caret to land inside nested child blocks (list/table/layout containers)
- alwaysSelect (
Returns: void
blockFocus.focus(block, { caret: 'end' });
clear#
Removes data-selected from all blocks, resets focusedBlock, and emits block:focus:clear and context:clear events.
Returns: void
blockFocus.clear();
getFocused#
Returns the currently focused block instance, or null when no block is focused.
Returns: Block|null
blockFocus.getFocused();