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.

Merge pull request #787 from AppFlowy-IO/feat/add-default-impl-for-image

Nathan.fooo0bf4a79ec914
diff --cc frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart
index f824b87234,f4894a08c0..0aae0b38c8
--- 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
@@@ -71,23 -71,20 +71,26 @@@ FlowyKeyEventHandler slashShortcutHandl
}
final rect = selectable.getCursorRectInPosition(selection.start);
+ if (rect == null) {
+ return KeyEventResult.ignored;
+ }
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(