applyInsertRules method

Delta applyInsertRules(
  1. NotusDocument document,
  2. int index,
  3. String insert
)

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

Implementation

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