expose Stream<Tuple3> get changes

pull/13/head
singerdmx 4 years ago
parent c6b827a178
commit dfe812e837
  1. 2
      lib/models/documents/document.dart
  2. 8
      lib/widgets/controller.dart

@ -33,7 +33,7 @@ class Document {
final History _history = History(); final History _history = History();
Stream<Tuple3> get changes => _observer.stream; Stream<Tuple3<Delta, Delta, ChangeSource>> get changes => _observer.stream;
Document() : _delta = Delta() Document() : _delta = Delta()
..insert('\n') { ..insert('\n') {

@ -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/models/documents/style.dart';
import 'package:flutter_quill/utils/diff_delta.dart'; import 'package:flutter_quill/utils/diff_delta.dart';
import 'package:quill_delta/quill_delta.dart'; import 'package:quill_delta/quill_delta.dart';
import 'package:tuple/tuple.dart';
class QuillController extends ChangeNotifier { class QuillController extends ChangeNotifier {
final Document document; final Document document;
@ -22,6 +23,13 @@ class QuillController extends ChangeNotifier {
document: Document(), selection: TextSelection.collapsed(offset: 0)); 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<Tuple3<Delta, Delta, ChangeSource>> get changes => document.changes;
TextEditingValue get plainTextEditingValue => TextEditingValue( TextEditingValue get plainTextEditingValue => TextEditingValue(
text: document.toPlainText(), text: document.toPlainText(),
selection: selection, selection: selection,

Loading…
Cancel
Save