applyFormatRules method

Delta applyFormatRules(
  1. NotusDocument document,
  2. int index,
  3. int length,
  4. NotusAttribute value,
)

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

Implementation

Delta applyFormatRules(
    NotusDocument document, int index, int length, NotusAttribute value) {
  final delta = document.toDelta();
  for (var rule in formatRules) {
    final result = rule.apply(delta, index, length, value);
    if (result != null) return result..trim();
  }
  throw StateError('Failed to apply format heuristic rules: none applied.');
}