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: disable apply operation when setting editable = false
Lucas.Xuab0131c19ccf
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 4f2ca39a84..4aeb7ab599 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@@ -72,6 +72,8 @@ class EditorState {// TODO: only for testing.bool disableSealTimer = false;+ bool editable = true;+Selection? get cursorSelection {return _cursorSelection;}@@ -112,6 +114,9 @@ class EditorState {/// should record the transaction in undo/redo stack.apply(Transaction transaction,[ApplyOptions options = const ApplyOptions()]) {+ if (!editable) {+ return;+ }// TODO: validate the transation.for (final op in transaction.operations) {_applyOperation(op);diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/editor_service.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/editor_service.dartindex 7174290b9c..3d9599383d 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/editor_service.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/editor_service.dart@@ -72,6 +72,7 @@ class _AppFlowyEditorState extends State<AppFlowyEditor> {editorState.selectionMenuItems = widget.selectionMenuItems;editorState.editorStyle = widget.editorStyle;editorState.service.renderPluginService = _createRenderPlugin();+ editorState.editable = widget.editable;}@override@@ -84,6 +85,7 @@ class _AppFlowyEditorState extends State<AppFlowyEditor> {}editorState.editorStyle = widget.editorStyle;+ editorState.editable = widget.editable;services = null;}