insert method

Delta insert (
  1. int index,
  2. String text

Inserts text in this document at specified index.

This method applies heuristic rules before modifying this document and produces a NotusChange with source set to ChangeSource.local.

Returns an instance of Delta actually composed into this document.


Delta insert(int index, String text) {
  assert(index >= 0);
  text = _sanitizeString(text);
  if (text.isEmpty) return Delta();
  final change = _heuristics.applyInsertRules(this, index, text);
  compose(change, ChangeSource.local);
  return change;