execute method

  1. @override
void execute(
  1. Document document,
  2. DocumentEditorTransaction transaction
)
override

Executes this command against the given document, with changes applied to the given transaction.

The document is provided in case this command needs to query the current content of the document to make appropriate changes.

Implementation

@override
void execute(Document document, DocumentEditorTransaction transaction) {
  _log.log('DeleteNodeCommand', 'DocumentEditor: deleting node: $nodeId');

  final node = document.getNodeById(nodeId);
  if (node == null) {
    _log.log('DeleteNodeCommand', 'No such node. Returning.');
    return;
  }

  _log.log('DeleteNodeCommand', ' - deleting node');
  transaction.deleteNode(node);

  _log.log('DeleteNodeCommand', ' - done with node deletion');
}