fix: remove text span overlay on mobile

This commit is contained in:
Morn 2025-04-10 10:35:48 +08:00
parent 05b0160b80
commit 9e24d0d192
6 changed files with 12 additions and 7 deletions

View file

@ -373,7 +373,6 @@ void main() {
isMetaPressed: Platform.isMacOS, isMetaPressed: Platform.isMacOS,
); );
await tester.simulateKeyEvent(LogicalKeyboardKey.delete); await tester.simulateKeyEvent(LogicalKeyboardKey.delete);
await tester.ime.insertText(unavailableLink);
await tester.enterText(find.byType(TextFormField), unavailableLink); await tester.enterText(find.byType(TextFormField), unavailableLink);
await tester.tapButton(find.text(LocaleKeys.button_replace.tr())); await tester.tapButton(find.text(LocaleKeys.button_replace.tr()));
final node = tester.editor.getNodeAtPath([0]); final node = tester.editor.getNodeAtPath([0]);

View file

@ -13,6 +13,7 @@ import 'document_with_multi_image_block_test.dart'
as document_with_multi_image_block_test; as document_with_multi_image_block_test;
import 'document_with_simple_table_test.dart' import 'document_with_simple_table_test.dart'
as document_with_simple_table_test; as document_with_simple_table_test;
import 'document_link_preview_test.dart' as document_link_preview_test;
void main() { void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -28,4 +29,5 @@ void main() {
document_find_menu_test.main(); document_find_menu_test.main();
document_toolbar_test.main(); document_toolbar_test.main();
document_with_simple_table_test.main(); document_with_simple_table_test.main();
document_link_preview_test.main();
} }

View file

@ -181,7 +181,7 @@ class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
child: FlowyNetworkImage( child: FlowyNetworkImage(
url: linkInfo.imageUrl ?? '', url: linkInfo.imageUrl ?? '',
width: double.infinity, width: MediaQuery.of(context).size.width,
), ),
), ),
), ),

View file

@ -116,9 +116,11 @@ class LinkInfo {
} }
class LinkInfoCache { class LinkInfoCache {
final _linkInfoPrefix = 'link_info';
Future<LinkInfo?> get(String url) async { Future<LinkInfo?> get(String url) async {
final option = await getIt<KeyValueStorage>().getWithFormat<LinkInfo?>( final option = await getIt<KeyValueStorage>().getWithFormat<LinkInfo?>(
url, _linkInfoPrefix + url,
(value) => LinkInfo.fromJson(jsonDecode(value)), (value) => LinkInfo.fromJson(jsonDecode(value)),
); );
return option; return option;
@ -126,7 +128,7 @@ class LinkInfoCache {
Future<void> set(String url, LinkInfo data) async { Future<void> set(String url, LinkInfo data) async {
await getIt<KeyValueStorage>().set( await getIt<KeyValueStorage>().set(
url, _linkInfoPrefix + url,
jsonEncode(data.toJson()), jsonEncode(data.toJson()),
); );
} }

View file

@ -58,6 +58,9 @@ class _HighlightColorPickerWidgetState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (editorState.selection == null) {
return const SizedBox.shrink();
}
final selectionRectList = editorState.selectionRects(); final selectionRectList = editorState.selectionRects();
final top = final top =
selectionRectList.isEmpty ? 0.0 : selectionRectList.first.height; selectionRectList.isEmpty ? 0.0 : selectionRectList.first.height;

View file

@ -591,10 +591,9 @@ class EditorStyleCustomizer {
Node node, Node node,
SelectableMixin delegate, SelectableMixin delegate,
) { ) {
if (UniversalPlatform.isMobile) return [];
final delta = node.delta; final delta = node.delta;
if (delta == null) { if (delta == null) return [];
return [];
}
final widgets = <Widget>[]; final widgets = <Widget>[];
final textInserts = delta.whereType<TextInsert>(); final textInserts = delta.whereType<TextInsert>();
int index = 0; int index = 0;