apply method

Delta apply(
  1. RuleType ruleType,
  2. Document document,
  3. int index, {
  4. int? len,
  5. Object? data,
  6. Attribute? attribute,
})

Implementation

Delta apply(RuleType ruleType, Document document, int index,
    {int? len, Object? data, Attribute? attribute}) {
  final delta = document.toDelta();
  for (final rule in _customRules + _rules) {
    if (rule.type != ruleType) {
      continue;
    }
    try {
      final result = rule.apply(delta, index,
          len: len, data: data, attribute: attribute);
      if (result != null) {
        return result..trim();
      }
    } catch (e) {
      rethrow;
    }
  }
  throw 'Apply rules failed';
}