mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: notify transaction instead of operations
This commit is contained in:
parent
8895430d9e
commit
71b1769eee
@ -109,8 +109,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
..handler = (message) {
|
||||
debugPrint(message);
|
||||
};
|
||||
_editorState!.operationStream.listen((event) {
|
||||
debugPrint('Operation: ${event.toJson()}');
|
||||
_editorState!.transactionStream.listen((event) {
|
||||
debugPrint('Transaction: ${event.toJson()}');
|
||||
});
|
||||
return Container(
|
||||
color: darkMode ? Colors.black : Colors.white,
|
||||
|
@ -9,7 +9,7 @@ import 'package:appflowy_editor/src/core/location/selection.dart';
|
||||
import 'package:appflowy_editor/src/core/document/document.dart';
|
||||
import 'package:appflowy_editor/src/core/transform/operation.dart';
|
||||
import 'package:appflowy_editor/src/core/transform/transaction.dart';
|
||||
import 'package:appflowy_editor/src/undo_manager.dart';
|
||||
import 'package:appflowy_editor/src/history/undo_manager.dart';
|
||||
|
||||
class ApplyOptions {
|
||||
/// This flag indicates that
|
||||
@ -63,8 +63,8 @@ class EditorState {
|
||||
EditorStyle editorStyle = EditorStyle.defaultStyle();
|
||||
|
||||
/// Operation stream.
|
||||
Stream<Operation> get operationStream => _observer.stream;
|
||||
final StreamController<Operation> _observer = StreamController.broadcast();
|
||||
Stream<Transaction> get transactionStream => _observer.stream;
|
||||
final StreamController<Transaction> _observer = StreamController.broadcast();
|
||||
|
||||
final UndoManager undoManager = UndoManager();
|
||||
Selection? _cursorSelection;
|
||||
@ -140,6 +140,8 @@ class EditorState {
|
||||
_applyOperation(op);
|
||||
}
|
||||
|
||||
_observer.add(transaction);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
updateCursorSelection(transaction.afterSelection);
|
||||
});
|
||||
@ -187,6 +189,5 @@ class EditorState {
|
||||
} else if (op is UpdateTextOperation) {
|
||||
document.updateText(op.path, op.delta);
|
||||
}
|
||||
_observer.add(op);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'dart:collection';
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor/src/undo_manager.dart';
|
||||
import 'package:appflowy_editor/src/history/undo_manager.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() async {
|
||||
|
Loading…
Reference in New Issue
Block a user