Skip to content

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.

feat: hide overlay when tap on the editor

Lucas.Xue3e1d254946a
diff --git a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/document_node_widget.dart b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/document_node_widget.dart
index 80ca4f5f00..a9d891cf3d 100644
--- a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/document_node_widget.dart
+++ b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/document_node_widget.dart
@@ -46,6 +46,13 @@ class _EditorNodeWidget extends StatelessWidget {
..onEnd = _onPanEnd;
},
),
+ TapGestureRecognizer:
+ GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
+ () => TapGestureRecognizer(),
+ (recongizer) {
+ recongizer..onTap = _onTap;
+ },
+ )
},
child: SingleChildScrollView(
child: Column(
@@ -66,8 +73,15 @@ class _EditorNodeWidget extends StatelessWidget {
);
}
+ void _onTap() {
+ editorState.panStartOffset = null;
+ editorState.panEndOffset = null;
+ editorState.updateSelection();
+ }
+
void _onPanStart(DragStartDetails details) {
editorState.panStartOffset = details.globalPosition;
+ editorState.updateSelection();
}
void _onPanUpdate(DragUpdateDetails details) {
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart b/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
index bc111ab4b8..fce1ac8ffd 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
@@ -56,6 +56,10 @@ class EditorState {
List<OverlayEntry> selectionOverlays = [];
void updateSelection() {
+ selectionOverlays
+ ..forEach((element) => element.remove())
+ ..clear();
+
final selectedNodes = _selectedNodes;
if (selectedNodes.isEmpty) {
return;
@@ -63,9 +67,6 @@ class EditorState {
assert(panStartOffset != null && panEndOffset != null);
- selectionOverlays
- ..forEach((element) => element.remove())
- ..clear();
for (final node in selectedNodes) {
final key = node.key;
if (key != null && key.currentState is Selectable) {