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
fix: popuplist will not show when the selection is not collapsed
Lucas.Xu849e19e1ef8b
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dartindex 68bcdca7a6..f824b87234 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart@@ -72,16 +72,22 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) {final rect = selectable.getCursorRectInPosition(selection.start);final offset = selectable.localToGlobal(rect.topLeft);- if (!selection.isCollapsed) {- TransactionBuilder(editorState)- ..deleteText(- textNode,- selection.start.offset,- selection.end.offset - selection.start.offset,- )- ..commit();- }+ TransactionBuilder(editorState)+ ..replaceText(textNode, selection.start.offset,+ selection.end.offset - selection.start.offset, '/')+ ..commit();++ _editorState = editorState;+ WidgetsBinding.instance.addPostFrameCallback((_) {+ showPopupList(context, editorState, offset);+ });++ return KeyEventResult.handled;+};++void showPopupList(+ BuildContext context, EditorState editorState, Offset offset) {_popupListOverlay?.remove();_popupListOverlay = OverlayEntry(builder: (context) => Positioned(@@ -97,16 +103,12 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) {Overlay.of(context)?.insert(_popupListOverlay!);editorState.service.selectionService.currentSelection- .removeListener(clearPopupListOverlay);+ .removeListener(clearPopupList);editorState.service.selectionService.currentSelection- .addListener(clearPopupListOverlay);- // editorState.service.keyboardService?.disable();- _editorState = editorState;-- return KeyEventResult.handled;-};+ .addListener(clearPopupList);+}-void clearPopupListOverlay() {+void clearPopupList() {_popupListOverlay?.remove();_popupListOverlay = null;@@ -215,7 +217,7 @@ class _PopupListWidgetState extends State<PopupListWidget> {}if (event.logicalKey == LogicalKeyboardKey.escape) {- clearPopupListOverlay();+ clearPopupList();return KeyEventResult.handled;}