From 9e24d0d192ebc9126f1018cf2c16e6f80a4538e2 Mon Sep 17 00:00:00 2001 From: Morn Date: Thu, 10 Apr 2025 10:35:48 +0800 Subject: [PATCH] fix: remove text span overlay on mobile --- .../desktop/document/document_link_preview_test.dart | 1 - .../desktop/document/document_test_runner_4.dart | 2 ++ .../link_embed/link_embed_block_component.dart | 2 +- .../editor_plugins/link_preview/custom_link_parser.dart | 6 ++++-- .../toolbar_item/custom_hightlight_color_toolbar_item.dart | 3 +++ .../lib/plugins/document/presentation/editor_style.dart | 5 ++--- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_link_preview_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_link_preview_test.dart index 5da5a9e2a7..f74011ee2b 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/document/document_link_preview_test.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_link_preview_test.dart @@ -373,7 +373,6 @@ void main() { isMetaPressed: Platform.isMacOS, ); await tester.simulateKeyEvent(LogicalKeyboardKey.delete); - await tester.ime.insertText(unavailableLink); await tester.enterText(find.byType(TextFormField), unavailableLink); await tester.tapButton(find.text(LocaleKeys.button_replace.tr())); final node = tester.editor.getNodeAtPath([0]); diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart index a05545753e..bc0671834b 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart @@ -13,6 +13,7 @@ import 'document_with_multi_image_block_test.dart' as document_with_multi_image_block_test; import 'document_with_simple_table_test.dart' as document_with_simple_table_test; +import 'document_link_preview_test.dart' as document_link_preview_test; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -28,4 +29,5 @@ void main() { document_find_menu_test.main(); document_toolbar_test.main(); document_with_simple_table_test.main(); + document_link_preview_test.main(); } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart index cef8044fc4..6dc6501c03 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart @@ -181,7 +181,7 @@ class LinkEmbedBlockComponentState extends State borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), child: FlowyNetworkImage( url: linkInfo.imageUrl ?? '', - width: double.infinity, + width: MediaQuery.of(context).size.width, ), ), ), diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart index 27a16965ec..0032d9cd33 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart @@ -116,9 +116,11 @@ class LinkInfo { } class LinkInfoCache { + final _linkInfoPrefix = 'link_info'; + Future get(String url) async { final option = await getIt().getWithFormat( - url, + _linkInfoPrefix + url, (value) => LinkInfo.fromJson(jsonDecode(value)), ); return option; @@ -126,7 +128,7 @@ class LinkInfoCache { Future set(String url, LinkInfo data) async { await getIt().set( - url, + _linkInfoPrefix + url, jsonEncode(data.toJson()), ); } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_hightlight_color_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_hightlight_color_toolbar_item.dart index 8b32ebdde9..cd332e14ef 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_hightlight_color_toolbar_item.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_hightlight_color_toolbar_item.dart @@ -58,6 +58,9 @@ class _HighlightColorPickerWidgetState @override Widget build(BuildContext context) { + if (editorState.selection == null) { + return const SizedBox.shrink(); + } final selectionRectList = editorState.selectionRects(); final top = selectionRectList.isEmpty ? 0.0 : selectionRectList.first.height; diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart index bd205ffea9..3664c9aee7 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart @@ -591,10 +591,9 @@ class EditorStyleCustomizer { Node node, SelectableMixin delegate, ) { + if (UniversalPlatform.isMobile) return []; final delta = node.delta; - if (delta == null) { - return []; - } + if (delta == null) return []; final widgets = []; final textInserts = delta.whereType(); int index = 0;