Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: notify transaction instead of operations
Lucas.Xu71b1769eee60
diff --git a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dartindex 89f4977b21..8d66b25b46 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart+++ b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart@@ -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,diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dartindex 6c0acb16b9..b01f88fed3 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart@@ -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);}}diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/undo_manager.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/history/undo_manager.dartsimilarity index 100%rename from frontend/app_flowy/packages/appflowy_editor/lib/src/undo_manager.dartrename to frontend/app_flowy/packages/appflowy_editor/lib/src/history/undo_manager.dartdiff --git a/frontend/app_flowy/packages/appflowy_editor/test/legacy/undo_manager_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/legacy/undo_manager_test.dartindex bd173ce15f..7fbf4ec162 100644--- a/frontend/app_flowy/packages/appflowy_editor/test/legacy/undo_manager_test.dart+++ b/frontend/app_flowy/packages/appflowy_editor/test/legacy/undo_manager_test.dart@@ -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 {