Skip to content
Core

Events and permissions ​

Loading interactive example…Open in new tab ↗
Opening the live canvas…

The first card is protected by a host admission hook. Try deleting it with the button, or moving and editing it on the canvas. The second card and connection remain editable. A rejected verb displays its reason and adds no undo entry. Change the connection, undo it, and redo it to compare an admitted operation.

DiagramRules(beforeChange: ...) in the diagram's configuration checks the candidate before publication. UI gestures, verbs and document imports share this boundary. The example protects one identity; a real host supplies its own authorization context. This local hook does not replace authorization on a remote server.

The change set is derived lazily and scans the documents when read. Avoid using this example as a performance policy for very large documents without profiling.

See Rules and changes and LLM documentation.

Source ​

dart
EditResult protectFirstCard(DiagramChangeProposal proposal) {
  // This is host policy, not a second mutation path. The shared store applies
  // it to UI previews, commands, imports, undo and redo before publication.
  final changes = proposal.elements;
  if (changes.updatedIds.contains('card-0') ||
      changes.removedIds.contains('card-0')) {
    return const EditResult.denied(reason: 'The first card is protected.');
  }
  return const EditResult.allow();
}