Blocks

blocks:change#

Emitted whenever the block structure or block-affecting operation completes. This is the main “document changed” signal.

Type: signal.

Payload: none.

Example:

let timer;
app.on('blocks:change', () => {
  clearTimeout(timer);
  timer = setTimeout(() => saveDraft(), 300);
});

blocks:decorations:change#

Emitted when block decoration classes/styles change.

Type: signal.

Payload:

  • blocks — blocks whose decorations changed (same as changedBlocks)
  • changedBlocks — blocks updated by the decorator
  • selected — selection snapshot used for the operation
  • options — { attrs?, classes?, styles? } applied decorations
  • report — internal formatter report object

Example:

app.on('blocks:decorations:change', ({ changedBlocks, options }) => {
  changedBlocks.forEach((b) => markDirty(b.getEl()));
});

blocks:format#

Emitted after block-level formatting is applied.

Type: signal.

Payload:

  • targetType — format target type (e.g. text, h1, quote)
  • options — options passed to the formatter
  • blocks — blocks that were formatted
  • context — formatter context object

Example:

app.on('blocks:format', ({ targetType, blocks }) => {
  if (targetType === 'quote') highlightQuotes(blocks);
});

blocks:mutated#

Emitted when the mutation observer detects DOM changes on mounted blocks.

Type: signal.

Payload:

  • blocks — affected block instances
  • mutations — MutationRecord batch from the observer

Example:

app.on('blocks:mutated', ({ blocks, mutations }) => {
  if (mutations.some((m) => m.type === 'attributes')) syncAttributes(blocks);
});