deleteSelection static method

TransactionSpec? deleteSelection(
  1. EditorState state
)

Delete the currently selected range. Returns null if the selection is empty (nothing to delete).

Implementation

static TransactionSpec? deleteSelection(EditorState state) {
  final main = state.selection.main;
  if (main.isEmpty) return null;
  final changes = ChangeSet.of(state.doc.length, [
    ChangeSpec(from: main.from, to: main.to),
  ]);
  return TransactionSpec(
    changes: changes,
    selection: EditorSelection.cursor(main.from),
  );
}