yTextToDelta method

List<YTextDelta> yTextToDelta({
  1. required YText ref,
  2. YSnapshot? snapshot,
  3. YSnapshot? prevSnapshot,
  4. YTransaction? txn,
})

https://quilljs.com/docs/delta/ TODO: implement compute_ychange: Option

Implementation

List<YTextDelta> yTextToDelta({
  required YText ref,
  YSnapshot? snapshot,
  YSnapshot? prevSnapshot,
  YTransaction? txn,
}) {
  final results = _yTextToDelta([
    ref.toWasm(),
    (snapshot == null
        ? const None().toWasm()
        : Option.fromValue(snapshot).toWasm((some) => some.toWasm())),
    (prevSnapshot == null
        ? const None().toWasm()
        : Option.fromValue(prevSnapshot).toWasm((some) => some.toWasm())),
    (txn == null
        ? const None().toWasm()
        : Option.fromValue(txn).toWasm(YTransaction.toWasm))
  ]);
  final result = results[0];
  return (result! as Iterable).map(YTextDelta.fromJson).toList();
}