applyInsertRules method

Delta applyInsertRules(
  1. NotusDocument document,
  2. int index,
  3. Object data
)

Applies heuristic rules to specified insert operation based on current state of Notus document.

Implementation

Delta applyInsertRules(NotusDocument document, int index, Object data) {
  final delta = document.toDelta();
  for (var rule in insertRules) {
    final result = rule.apply(delta, index, data);
    if (result != null) return result..trim();
  }
  throw StateError('Failed to apply insert heuristic rules: none applied.');
}