Skip to content

Commit 8a892cc

Browse files
committed
fix: copy link to block not supported well
1 parent e710fc1 commit 8a892cc

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,6 @@ void main() {
483483
});
484484
});
485485

486-
testWidgets('paste image url without extension', (tester) async {
487-
const plainText =
488-
'https://images.unsplash.com/photo-1469474968028-56623f02e42e?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=david-marcu-78A265wPiO4-unsplash.jpg&w=640';
489-
await tester.pasteContent(plainText: plainText, (editorState) {
490-
final node = editorState.getNodeAtPath([0])!;
491-
expect(node.type, ImageBlockKeys.type);
492-
expect(node.attributes[ImageBlockKeys.url], isNotEmpty);
493-
});
494-
});
495-
496486
const testMarkdownText = '''
497487
# I'm h1
498488
## I'm h2

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/delta/text_delta_extension.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart';
12
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
23
import 'package:appflowy_editor/appflowy_editor.dart';
34

@@ -27,9 +28,15 @@ extension TextDeltaExtension on Delta {
2728
if (op.text == MentionBlockKeys.mentionChar) {
2829
final mention = attributes?[MentionBlockKeys.mention];
2930
final mentionPageId = mention?[MentionBlockKeys.pageId];
31+
final mentionType = mention?[MentionBlockKeys.type];
3032
if (mentionPageId != null) {
3133
text += await getMentionPageName(mentionPageId);
3234
continue;
35+
} else if (mentionType == MentionType.externalLink.name) {
36+
final url = mention?[MentionBlockKeys.url] ?? '';
37+
final info = await LinkInfoCache().get(url);
38+
text += info?.siteName ?? url;
39+
continue;
3340
}
3441
}
3542

0 commit comments

Comments
 (0)