From dfe812e837282f136568f2c03643a904b18a8c1d Mon Sep 17 00:00:00 2001 From: singerdmx Date: Sat, 26 Dec 2020 10:25:04 -0800 Subject: [PATCH] expose Stream get changes --- lib/models/documents/document.dart | 2 +- lib/widgets/controller.dart | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/models/documents/document.dart b/lib/models/documents/document.dart index bd3a4372..79efcd9f 100644 --- a/lib/models/documents/document.dart +++ b/lib/models/documents/document.dart @@ -33,7 +33,7 @@ class Document { final History _history = History(); - Stream get changes => _observer.stream; + Stream> get changes => _observer.stream; Document() : _delta = Delta() ..insert('\n') { diff --git a/lib/widgets/controller.dart b/lib/widgets/controller.dart index e8fdfad5..b7b40f6b 100644 --- a/lib/widgets/controller.dart +++ b/lib/widgets/controller.dart @@ -7,6 +7,7 @@ import 'package:flutter_quill/models/documents/nodes/embed.dart'; import 'package:flutter_quill/models/documents/style.dart'; import 'package:flutter_quill/utils/diff_delta.dart'; import 'package:quill_delta/quill_delta.dart'; +import 'package:tuple/tuple.dart'; class QuillController extends ChangeNotifier { final Document document; @@ -22,6 +23,13 @@ class QuillController extends ChangeNotifier { document: Document(), selection: TextSelection.collapsed(offset: 0)); } + // item1: Document state before [change]. + // + // item2: Change delta applied to the document. + // + // item3: The source of this change. + Stream> get changes => document.changes; + TextEditingValue get plainTextEditingValue => TextEditingValue( text: document.toPlainText(), selection: selection,