Block

block:before:remove#

Hook emitted before a block is removed.

Type: hook (handler may return a value).

Payload:

  • type — string — type of the block being removed
  • block — block instance

Example:

app.on('block:before:remove', ({ type, block }) => {
  if (block.isProtected?.()) return { type, block };
  return { type, block };
});

block:control#

Emitted when the control bar is shown for a focused block.

Type: signal.

Payload:

  • block — block instance

Example:

app.on('block:control', ({ block }) => {
  app.statusbar.update('block', block.getMeta().label || block.getType());
});

block:control:clear#

Emitted when the control bar is cleared.

Type: signal.

Payload: none.

Example:

app.on('block:control:clear', () => {
  // react to the signal
});

block:focus#

Emitted when a block receives focus.

Type: signal.

Payload:

  • block — block instance

Example:

app.on('block:focus', ({ block }) => {
  highlightOutline(block.getEl());
});

block:focus:clear#

Emitted when block focus is cleared.

Type: signal.

Payload: none.

Example:

app.on('block:focus:clear', () => {
  // react to the signal
});

block:remove#

Emitted after a block is removed.

Type: signal.

Payload:

  • type — string — type of the removed block
  • block — block instance

Example:

app.on('block:remove', ({ type, block }) => {
  analytics.track('block-removed', { type });
});