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
feat: revamp link preivew (#7692)
Morn4997ac99cf4c
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dartindex c18b42939c..ee82f01d3f 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart@@ -1,10 +1,12 @@+import 'dart:async';import 'dart:io';import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/plugins/document/presentation/editor_plugins/block_menu/block_menu_button.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';@@ -320,8 +322,14 @@ void main() {(tester) async {const url = 'https://appflowy.io';await tester.pasteContent(plainText: url, (editorState) async {+ final pasteAsMenu = find.byType(PasteAsMenu);+ expect(pasteAsMenu, findsOneWidget);+ final bookmarkButton = find.text(+ LocaleKeys.document_plugins_linkPreview_typeSelection_bookmark.tr(),+ );+ await tester.tapButton(bookmarkButton);// the second one is the paragraph node- expect(editorState.document.root.children.length, 2);+ expect(editorState.document.root.children.length, 1);final node = editorState.getNodeAtPath([0])!;expect(node.type, LinkPreviewBlockKeys.type);expect(node.attributes[LinkPreviewBlockKeys.url], url);@@ -333,19 +341,19 @@ void main() {await tester.hoverOnWidget(find.byType(CustomLinkPreviewWidget),onHover: () async {- final convertToLinkButton = find.byWidgetPredicate((widget) {- return widget is MenuBlockButton &&- widget.tooltip ==- LocaleKeys.document_plugins_urlPreview_convertToLink.tr();- });+ /// show menu+ final menu = find.byType(CustomLinkPreviewMenu);+ expect(menu, findsOneWidget);+ await tester.tapButton(menu);++ final convertToLinkButton = find.text(+ LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toUrl.tr(),+ );expect(convertToLinkButton, findsOneWidget);- await tester.tap(convertToLinkButton);- await tester.pumpAndSettle();+ await tester.tapButton(convertToLinkButton);},);- await tester.pumpAndSettle();-final editorState = tester.editor.getCurrentEditorState();final textNode = editorState.getNodeAtPath([0])!;expect(textNode.type, ParagraphBlockKeys.type);@@ -363,14 +371,20 @@ void main() {(tester) async {const url = 'https://appflowy.io';await tester.pasteContent(plainText: url, (editorState) async {+ final pasteAsMenu = find.byType(PasteAsMenu);+ expect(pasteAsMenu, findsOneWidget);+ final bookmarkButton = find.text(+ LocaleKeys.document_plugins_linkPreview_typeSelection_bookmark.tr(),+ );+ await tester.tapButton(bookmarkButton);// the second one is the paragraph node- expect(editorState.document.root.children.length, 2);+ expect(editorState.document.root.children.length, 1);final node = editorState.getNodeAtPath([0])!;expect(node.type, LinkPreviewBlockKeys.type);expect(node.attributes[LinkPreviewBlockKeys.url], url);});- await tester.editor.tapLineOfEditorAt(0);+await tester.simulateKeyEvent(LogicalKeyboardKey.keyZ,isControlPressed:@@ -521,7 +535,7 @@ void main() {extension on WidgetTester {Future<void> pasteContent(- void Function(EditorState editorState) test, {+ FutureOr<void> Function(EditorState editorState) test, {Future<void> Function(EditorState editorState)? beforeTest,String? plainText,String? html,@@ -558,6 +572,6 @@ extension on WidgetTester {);await pumpAndSettle(const Duration(milliseconds: 1000));- test(editor.getCurrentEditorState());+ await test(editor.getCurrentEditorState());}}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.dartnew file mode 100644index 0000000000..f74011ee2b--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_link_preview_test.dart@@ -0,0 +1,452 @@+import 'dart:io';++import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_link_block.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_link_error_preview.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_link_preview.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';++import '../../shared/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ const avaliableLink = 'https://appflowy.io/',+ unavailableLink = 'www.thereIsNoting.com';++ Future<void> preparePage(WidgetTester tester, {String? pageName}) async {+ await tester.initializeAppFlowy();+ await tester.tapAnonymousSignInButton();+ await tester.createNewPageWithNameUnderParent(name: pageName);+ await tester.editor.tapLineOfEditorAt(0);+ }++ Future<void> pasteLink(WidgetTester tester, String link) async {+ await getIt<ClipboardService>()+ .setData(ClipboardServiceData(plainText: link));++ /// paste the link+ await tester.simulateKeyEvent(+ LogicalKeyboardKey.keyV,+ isControlPressed: Platform.isLinux || Platform.isWindows,+ isMetaPressed: Platform.isMacOS,+ );+ await tester.pumpAndSettle(Duration(seconds: 1));+ }++ Future<void> pasteAs(+ WidgetTester tester,+ String link,+ PasteMenuType type, {+ Duration waitTime = const Duration(milliseconds: 500),+ }) async {+ await pasteLink(tester, link);+ final convertToMentionButton = find.text(type.title);+ await tester.tapButton(convertToMentionButton);+ await tester.pumpAndSettle(waitTime);+ }++ void checkUrl(Node node, String link) {+ expect(node.type, ParagraphBlockKeys.type);+ expect(node.delta!.toJson(), [+ {+ 'insert': link,+ 'attributes': {'href': link},+ }+ ]);+ }++ void checkMention(Node node, String link) {+ final delta = node.delta!;+ final insert = (delta.first as TextInsert).text;+ final attributes = delta.first.attributes;+ expect(insert, MentionBlockKeys.mentionChar);+ final mention =+ attributes?[MentionBlockKeys.mention] as Map<String, dynamic>;+ expect(mention[MentionBlockKeys.type], MentionType.externalLink.name);+ expect(mention[MentionBlockKeys.url], avaliableLink);+ }++ void checkBookmark(Node node, String link) {+ expect(node.type, LinkPreviewBlockKeys.type);+ expect(node.attributes[LinkPreviewBlockKeys.url], link);+ }++ void checkEmbed(Node node, String link) {+ expect(node.type, LinkPreviewBlockKeys.type);+ expect(node.attributes[LinkEmbedKeys.previewType], LinkEmbedKeys.embed);+ expect(node.attributes[LinkPreviewBlockKeys.url], link);+ }++ group('Paste as URL', () {+ Future<void> pasteAndTurnInto(+ WidgetTester tester,+ String link,+ String title,+ ) async {+ await pasteLink(tester, link);+ final convertToLinkButton = find+ .text(LocaleKeys.document_plugins_linkPreview_typeSelection_URL.tr());+ await tester.tapButton(convertToLinkButton);++ /// hover link and turn into mention+ await tester.hoverOnWidget(+ find.byType(LinkHoverTrigger),+ onHover: () async {+ final turnintoButton = find.byFlowySvg(FlowySvgs.turninto_m);+ await tester.tapButton(turnintoButton);+ final convertToButton = find.text(title);+ await tester.tapButton(convertToButton);+ await tester.pumpAndSettle(Duration(seconds: 1));+ },+ );+ }++ testWidgets('paste a link', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteLink(tester, link);+ final convertToLinkButton = find+ .text(LocaleKeys.document_plugins_linkPreview_typeSelection_URL.tr());+ await tester.tapButton(convertToLinkButton);+ final node = tester.editor.getNodeAtPath([0]);+ checkUrl(node, link);+ });++ testWidgets('paste a link and turn into mention', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAndTurnInto(+ tester,+ link,+ LinkConvertMenuCommand.toMention.title,+ );++ /// check metion values+ final node = tester.editor.getNodeAtPath([0]);+ checkMention(node, link);+ });++ testWidgets('paste a link and turn into bookmark', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAndTurnInto(+ tester,+ link,+ LinkConvertMenuCommand.toBookmark.title,+ );++ /// check metion values+ final node = tester.editor.getNodeAtPath([0]);+ checkBookmark(node, link);+ });++ testWidgets('paste a link and turn into embed', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAndTurnInto(+ tester,+ link,+ LinkConvertMenuCommand.toEmbed.title,+ );++ /// check metion values+ final node = tester.editor.getNodeAtPath([0]);+ checkEmbed(node, link);+ });+ });++ group('Paste as Mention', () {+ Future<void> pasteAsMention(WidgetTester tester, String link) =>+ pasteAs(tester, link, PasteMenuType.mention);++ String getMentionLink(Node node) {+ final insert = node.delta?.first as TextInsert?;+ final mention = insert?.attributes?[MentionBlockKeys.mention]+ as Map<String, dynamic>?;+ return mention?[MentionBlockKeys.url] ?? '';+ }++ Future<void> hoverMentionAndClick(+ WidgetTester tester,+ String command,+ ) async {+ final mentionLink = find.byType(MentionLinkBlock);+ expect(mentionLink, findsOneWidget);+ await tester.hoverOnWidget(+ mentionLink,+ onHover: () async {+ final errorPreview = find.byType(MentionLinkErrorPreview);+ expect(errorPreview, findsOneWidget);+ final convertButton = find.byFlowySvg(FlowySvgs.turninto_m);+ await tester.tapButton(convertButton);+ final menuButton = find.text(command);+ await tester.tapButton(menuButton);+ },+ );+ }++ testWidgets('paste a link as mention', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ final node = tester.editor.getNodeAtPath([0]);+ checkMention(node, link);+ });++ testWidgets('paste as mention and copy link', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ final mentionLink = find.byType(MentionLinkBlock);+ expect(mentionLink, findsOneWidget);+ await tester.hoverOnWidget(+ mentionLink,+ onHover: () async {+ final preview = find.byType(MentionLinkPreview);+ if (!preview.hasFound) {+ final copyButton = find.byFlowySvg(FlowySvgs.toolbar_link_m);+ await tester.tapButton(copyButton);+ } else {+ final moreOptionButton = find.byFlowySvg(FlowySvgs.toolbar_more_m);+ await tester.tapButton(moreOptionButton);+ final copyButton =+ find.text(MentionLinktMenuCommand.copyLink.title);+ await tester.tapButton(copyButton);+ }+ },+ );+ final clipboardContent = await getIt<ClipboardService>().getData();+ expect(clipboardContent.plainText, link);+ });++ testWidgets('paste as error mention and turninto url', (tester) async {+ String link = unavailableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ Node node = tester.editor.getNodeAtPath([0]);+ link = getMentionLink(node);+ await hoverMentionAndClick(+ tester,+ MentionLinktErrorMenuCommand.toURL.title,+ );+ node = tester.editor.getNodeAtPath([0]);+ checkUrl(node, link);+ });++ testWidgets('paste as error mention and turninto embed', (tester) async {+ String link = unavailableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ Node node = tester.editor.getNodeAtPath([0]);+ link = getMentionLink(node);+ await hoverMentionAndClick(+ tester,+ MentionLinktErrorMenuCommand.toEmbed.title,+ );+ node = tester.editor.getNodeAtPath([0]);+ checkEmbed(node, link);+ });++ testWidgets('paste as error mention and turninto bookmark', (tester) async {+ String link = unavailableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ Node node = tester.editor.getNodeAtPath([0]);+ link = getMentionLink(node);+ await hoverMentionAndClick(+ tester,+ MentionLinktErrorMenuCommand.toBookmark.title,+ );+ node = tester.editor.getNodeAtPath([0]);+ checkBookmark(node, link);+ });++ testWidgets('paste as error mention and remove link', (tester) async {+ String link = unavailableLink;+ await preparePage(tester);+ await pasteAsMention(tester, link);+ Node node = tester.editor.getNodeAtPath([0]);+ link = getMentionLink(node);+ await hoverMentionAndClick(+ tester,+ MentionLinktErrorMenuCommand.removeLink.title,+ );+ node = tester.editor.getNodeAtPath([0]);+ expect(node.type, ParagraphBlockKeys.type);+ expect(node.delta!.toJson(), [+ {'insert': link},+ ]);+ });+ });++ group('Paste as Bookmark', () {+ Future<void> pasteAsBookmark(WidgetTester tester, String link) =>+ pasteAs(tester, link, PasteMenuType.bookmark);++ Future<void> hoverAndClick(+ WidgetTester tester,+ LinkPreviewMenuCommand command,+ ) async {+ final bookmark = find.byType(CustomLinkPreviewBlockComponent);+ expect(bookmark, findsOneWidget);+ await tester.hoverOnWidget(+ bookmark,+ onHover: () async {+ final menuButton = find.byFlowySvg(FlowySvgs.toolbar_more_m);+ await tester.tapButton(menuButton);+ final commandButton = find.text(command.title);+ await tester.tapButton(commandButton);+ },+ );+ }++ testWidgets('paste a link as bookmark', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ final node = tester.editor.getNodeAtPath([0]);+ checkBookmark(node, link);+ });++ testWidgets('paste a link as bookmark and convert to mention',+ (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.convertToMention);+ final node = tester.editor.getNodeAtPath([0]);+ checkMention(node, link);+ });++ testWidgets('paste a link as bookmark and convert to url', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.convertToUrl);+ final node = tester.editor.getNodeAtPath([0]);+ checkUrl(node, link);+ });++ testWidgets('paste a link as bookmark and convert to embed',+ (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.convertToEmbed);+ final node = tester.editor.getNodeAtPath([0]);+ checkEmbed(node, link);+ });++ testWidgets('paste a link as bookmark and copy link', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.copyLink);+ final clipboardContent = await getIt<ClipboardService>().getData();+ expect(clipboardContent.plainText, link);+ });++ testWidgets('paste a link as bookmark and replace link', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.replace);+ await tester.simulateKeyEvent(+ LogicalKeyboardKey.keyA,+ isControlPressed: Platform.isLinux || Platform.isWindows,+ isMetaPressed: Platform.isMacOS,+ );+ await tester.simulateKeyEvent(LogicalKeyboardKey.delete);+ await tester.enterText(find.byType(TextFormField), unavailableLink);+ await tester.tapButton(find.text(LocaleKeys.button_replace.tr()));+ final node = tester.editor.getNodeAtPath([0]);+ checkBookmark(node, unavailableLink);+ });++ testWidgets('paste a link as bookmark and remove link', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsBookmark(tester, link);+ await hoverAndClick(tester, LinkPreviewMenuCommand.removeLink);+ final node = tester.editor.getNodeAtPath([0]);+ expect(node.type, ParagraphBlockKeys.type);+ expect(node.delta!.toJson(), [+ {'insert': link},+ ]);+ });+ });+ group('Paste as Embed', () {+ Future<void> pasteAsEmbed(WidgetTester tester, String link) =>+ pasteAs(tester, link, PasteMenuType.embed);++ Future<void> hoverAndConvert(+ WidgetTester tester,+ PasteMenuType command,+ ) async {+ final embed = find.byType(LinkEmbedBlockComponent);+ expect(embed, findsOneWidget);+ await tester.hoverOnWidget(+ embed,+ onHover: () async {+ final menuButton = find.byFlowySvg(FlowySvgs.turninto_m);+ await tester.tapButton(menuButton);+ final commandButton = find.text(command.title);+ await tester.tapButton(commandButton);+ },+ );+ }++ testWidgets('paste a link as embed', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsEmbed(tester, link);+ final node = tester.editor.getNodeAtPath([0]);+ checkEmbed(node, link);+ });++ testWidgets('paste a link as bookmark and convert to mention',+ (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsEmbed(tester, link);+ await hoverAndConvert(tester, PasteMenuType.mention);+ final node = tester.editor.getNodeAtPath([0]);+ checkMention(node, link);+ });++ testWidgets('paste a link as bookmark and convert to url', (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsEmbed(tester, link);+ await hoverAndConvert(tester, PasteMenuType.url);+ final node = tester.editor.getNodeAtPath([0]);+ checkUrl(node, link);+ });++ testWidgets('paste a link as bookmark and convert to bookmark',+ (tester) async {+ final link = avaliableLink;+ await preparePage(tester);+ await pasteAsEmbed(tester, link);+ await hoverAndConvert(tester, PasteMenuType.bookmark);+ final node = tester.editor.getNodeAtPath([0]);+ checkBookmark(node, link);+ });+ });+}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.dartindex 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/integration_test/desktop/uncategorized/emoji_shortcut_test.dart b/frontend/appflowy_flutter/integration_test/desktop/uncategorized/emoji_shortcut_test.dartindex aba3a7be06..1a4e57078f 100644--- a/frontend/appflowy_flutter/integration_test/desktop/uncategorized/emoji_shortcut_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/uncategorized/emoji_shortcut_test.dart@@ -43,7 +43,10 @@ void main() {});group('insert emoji by colon', () {- Future<void> createNewDocumentAndShowEmojiList(WidgetTester tester, {String? search}) async {+ Future<void> createNewDocumentAndShowEmojiList(+ WidgetTester tester, {+ String? search,+ }) async {await tester.initializeAppFlowy();await tester.tapAnonymousSignInButton();await tester.createNewPageWithNameUnderParent();diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dartindex 67ab383eba..b3d99ab84b 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart@@ -16,6 +16,7 @@ import 'package:flutter/services.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:universal_platform/universal_platform.dart';+import 'editor_plugins/link_preview/custom_link_preview_block_component.dart';import 'editor_plugins/page_block/custom_page_block_component.dart';/// A global configuration for the editor.@@ -969,11 +970,11 @@ OutlineBlockComponentBuilder _buildOutlineBlockComponentBuilder();}-LinkPreviewBlockComponentBuilder _buildLinkPreviewBlockComponentBuilder(+CustomLinkPreviewBlockComponentBuilder _buildLinkPreviewBlockComponentBuilder(BuildContext context,BlockComponentConfiguration configuration,) {- return LinkPreviewBlockComponentBuilder(+ return CustomLinkPreviewBlockComponentBuilder(configuration: configuration.copyWith(padding: (node) {if (UniversalPlatform.isMobile) {@@ -983,20 +984,6 @@ LinkPreviewBlockComponentBuilder _buildLinkPreviewBlockComponentBuilder(},),cache: LinkPreviewDataCache(),- showMenu: true,- menuBuilder: (context, node, state) => Positioned(- top: 10,- right: 0,- child: LinkPreviewMenu(node: node, state: state),- ),- builder: (_, node, url, title, description, imageUrl) =>- CustomLinkPreviewWidget(- node: node,- url: url,- title: title,- description: description,- imageUrl: imageUrl,- ),);}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_paste_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_paste_command.dartindex 5c25d470d5..dd3f7362a9 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_paste_command.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_paste_command.dart@@ -16,6 +16,7 @@ import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:http/http.dart' as http;import 'package:string_validator/string_validator.dart';+import 'package:universal_platform/universal_platform.dart';/// - support/// - desktop@@ -162,6 +163,7 @@ Future<bool> _pasteAsLinkPreview(EditorState editorState,String? text,) async {+ final isMobile = UniversalPlatform.isMobile;// the url should contain a protocolif (text == null || !isURL(text, {'require_protocol': true})) {return false;@@ -193,6 +195,8 @@ Future<bool> _pasteAsLinkPreview(return false;}+ if (!isMobile && !isImageUrl) return false;+// insert the text with link formatfinal textTransaction = editorState.transaction..insertText(@@ -250,6 +254,7 @@ Future<void> doPlainPaste(EditorState editorState) async {}Future<bool> _isImageUrl(String text) async {+ if (isNotImageUrl(text)) return false;final response = await http.head(Uri.parse(text));if (response.statusCode == 200) {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dartindex 6eff666991..3f11759545 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart@@ -1,3 +1,4 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_plain_text.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy/shared/markdown_to_document.dart';import 'package:appflowy/shared/patterns/common_patterns.dart';@@ -13,6 +14,7 @@ extension PasteFromHtml on EditorState {}if (nodes.length == 1) {await pasteSingleLineNode(nodes.first);+ checkToShowPasteAsMenu(nodes.first);} else {await pasteMultiLineNodes(nodes.toList());}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_plain_text.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_plain_text.dartindex 4728eb7cf6..fcb12cefa5 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_plain_text.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_plain_text.dart@@ -1,6 +1,8 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';import 'package:appflowy/shared/markdown_to_document.dart';import 'package:appflowy/shared/patterns/common_patterns.dart';import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:universal_platform/universal_platform.dart';extension PasteFromPlainText on EditorState {Future<void> pastePlainText(String plainText) async {@@ -41,6 +43,7 @@ extension PasteFromPlainText on EditorState {}if (nodes.length == 1) {await pasteSingleLineNode(nodes.first);+ checkToShowPasteAsMenu(nodes.first);} else {await pasteMultiLineNodes(nodes.toList());}@@ -65,6 +68,29 @@ extension PasteFromPlainText on EditorState {AppFlowyRichTextKeys.href: plainText,});await apply(transaction);+ checkToShowPasteAsMenu(node);return true;}++ void checkToShowPasteAsMenu(Node node) {+ if (selection == null || !selection!.isCollapsed) return;+ if (UniversalPlatform.isMobile) return;+ final href = _getLinkFromNode(node);+ if (href != null) {+ final context = document.root.context;+ if (context != null && context.mounted) {+ PasteAsMenuService(context: context, editorState: this).show(href);+ }+ }+ }++ String? _getLinkFromNode(Node node) {+ final delta = node.delta;+ if (delta == null) return null;+ final inserts = delta.whereType<TextInsert>();+ if (inserts.isEmpty || inserts.length > 1) return null;+ final link = inserts.first.attributes?.href;+ if (link != null) return inserts.first.text;+ return null;+ }}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dartindex bc14073193..a6e1a78299 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dart@@ -304,11 +304,14 @@ void showLinkCreateMenu(return (left, top, right, bottom, alignment);}-ShapeDecoration buildToolbarLinkDecoration(BuildContext context) =>+ShapeDecoration buildToolbarLinkDecoration(+ BuildContext context, {+ double radius = 12.0,+}) =>ShapeDecoration(color: Theme.of(context).cardColor,shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(12),+ borderRadius: BorderRadius.circular(radius),),shadows: [const BoxShadow(diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dartindex 1abf70028f..c992e40c61 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart@@ -6,6 +6,9 @@ import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/document/application/document_bloc.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/shared.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/toolbar_item/custom_link_toolbar_item.dart';import 'package:appflowy/startup/startup.dart';@@ -14,6 +17,7 @@ import 'package:appflowy/workspace/application/view/view_service.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -139,6 +143,7 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {isHoverMenuHovering = false;tryToDismissLinkHoverMenu();},+ onConvertTo: (type) => convertLinkTo(editorState, selection, type),onOpenLink: openLink,onCopyLink: () => copyLink(context),onEditLink: showLinkEditMenu,@@ -236,14 +241,7 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {Future<void> copyLink(BuildContext context) async {final href = widget.attribute.href ?? '';- if (href.isEmpty) return;- await getIt<ClipboardService>()- .setData(ClipboardServiceData(plainText: href));- if (context.mounted) {- showToastNotification(- message: LocaleKeys.shareAction_copyLinkSuccess.tr(),- );- }+ await context.copyLink(href);hoverMenuController.close();}@@ -270,6 +268,26 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {editorState.apply(transaction);}+ Future<void> convertLinkTo(+ EditorState editorState,+ Selection selection,+ LinkConvertMenuCommand type,+ ) async {+ final url = widget.attribute.href ?? '';+ if (type == LinkConvertMenuCommand.toBookmark) {+ await convertUrlToLinkPreview(editorState, selection, url);+ } else if (type == LinkConvertMenuCommand.toMention) {+ await convertUrlToMention(editorState, selection);+ } else if (type == LinkConvertMenuCommand.toEmbed) {+ await convertUrlToLinkPreview(+ editorState,+ selection,+ url,+ previewType: LinkEmbedKeys.embed,+ );+ }+ }+void onRemoveAndReplaceLink(EditorState editorState,Selection selection,@@ -307,6 +325,7 @@ class LinkHoverMenu extends StatefulWidget {required this.onOpenLink,required this.onEditLink,required this.onRemoveLink,+ required this.onConvertTo,});final Attributes attribute;@@ -317,6 +336,7 @@ class LinkHoverMenu extends StatefulWidget {final VoidCallback onOpenLink;final VoidCallback onEditLink;final VoidCallback onRemoveLink;+ final ValueChanged<LinkConvertMenuCommand> onConvertTo;@overrideState<LinkHoverMenu> createState() => _LinkHoverMenuState();@@ -326,6 +346,8 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {ViewPB? currentView;late bool isPage = widget.attribute.isPage;late String href = widget.attribute.href ?? '';+ final popoverController = PopoverController();+ bool isConvertButtonSelected = false;@overridevoid initState() {@@ -333,6 +355,12 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {if (isPage) getPageView();}+ @override+ void dispose() {+ super.dispose();+ popoverController.close();+ }+@overrideWidget build(BuildContext context) {return Column(@@ -364,6 +392,7 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {FlowyIconButton(icon: FlowySvg(FlowySvgs.toolbar_link_m),tooltipText: LocaleKeys.editor_copyLink.tr(),+ preferBelow: false,width: 36,height: 32,onPressed: widget.onCopyLink,@@ -371,13 +400,16 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {FlowyIconButton(icon: FlowySvg(FlowySvgs.toolbar_link_edit_m),tooltipText: LocaleKeys.editor_editLink.tr(),+ preferBelow: false,width: 36,height: 32,onPressed: widget.onEditLink,),+ buildConvertButton(),FlowyIconButton(icon: FlowySvg(FlowySvgs.toolbar_link_unlink_m),tooltipText: LocaleKeys.editor_removeLink.tr(),+ preferBelow: false,width: 36,height: 32,onPressed: widget.onRemoveLink,@@ -444,6 +476,73 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {),);}++ Widget buildConvertButton() {+ return AppFlowyPopover(+ offset: Offset(44, 10.0),+ direction: PopoverDirection.bottomWithRightAligned,+ margin: EdgeInsets.zero,+ controller: popoverController,+ onOpen: () => keepEditorFocusNotifier.increase(),+ onClose: () => keepEditorFocusNotifier.decrease(),+ popupBuilder: (context) => buildConvertMenu(),+ child: FlowyIconButton(+ icon: FlowySvg(FlowySvgs.turninto_m),+ isSelected: isConvertButtonSelected,+ tooltipText: LocaleKeys.editor_convertTo.tr(),+ preferBelow: false,+ width: 36,+ height: 32,+ onPressed: () {+ setState(() {+ isConvertButtonSelected = true;+ });+ showConvertMenu();+ },+ ),+ );+ }++ Widget buildConvertMenu() {+ return MouseRegion(+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children:+ List.generate(LinkConvertMenuCommand.values.length, (index) {+ final command = LinkConvertMenuCommand.values[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () {+ widget.onConvertTo(command);+ closeConvertMenu();+ },+ ),+ );+ }),+ ),+ ),+ );+ }++ void showConvertMenu() {+ keepEditorFocusNotifier.increase();+ popoverController.show();+ }++ void closeConvertMenu() {+ popoverController.close();+ }}class HoverTriggerKey {@@ -489,3 +588,48 @@ class LinkHoverTriggers {callbacks.first.call();}}++enum LinkConvertMenuCommand {+ toMention,+ toBookmark,+ toEmbed;++ String get title {+ switch (this) {+ case toMention:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toMetion+ .tr();+ case toBookmark:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_toBookmark+ .tr();+ case toEmbed:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toEmbed+ .tr();+ }+ }++ String get type {+ switch (this) {+ case toMention:+ return MentionBlockKeys.type;+ case toBookmark:+ return LinkPreviewBlockKeys.type;+ case toEmbed:+ return LinkPreviewBlockKeys.type;+ }+ }+}++extension LinkExtension on BuildContext {+ Future<void> copyLink(String link) async {+ if (link.isEmpty) return;+ await getIt<ClipboardService>()+ .setData(ClipboardServiceData(plainText: link));+ if (mounted) {+ showToastNotification(+ message: LocaleKeys.shareAction_copyLinkSuccess.tr(),+ );+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_replace_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_replace_menu.dartnew file mode 100644index 0000000000..d08442d779--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_replace_menu.dart@@ -0,0 +1,184 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/menu/menu_extension.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';+// ignore: implementation_imports+import 'package:appflowy_editor/src/editor/util/link_util.dart';+import 'package:flutter/services.dart';++import 'link_create_menu.dart';+import 'link_styles.dart';++void showReplaceMenu({+ required BuildContext context,+ required EditorState editorState,+ required Node node,+ String? url,+ required LTRB ltrb,+ required ValueChanged<String> onReplace,+}) {+ OverlayEntry? overlay;++ void dismissOverlay() {+ keepEditorFocusNotifier.decrease();+ overlay?.remove();+ overlay = null;+ }++ keepEditorFocusNotifier.increase();+ overlay = FullScreenOverlayEntry(+ top: ltrb.top,+ bottom: ltrb.bottom,+ left: ltrb.left,+ right: ltrb.right,+ dismissCallback: () => keepEditorFocusNotifier.decrease(),+ builder: (context) {+ return LinkReplaceMenu(+ link: url ?? '',+ onSubmitted: (link) async {+ onReplace.call(link);+ dismissOverlay();+ },+ onDismiss: dismissOverlay,+ );+ },+ ).build();++ Overlay.of(context, rootOverlay: true).insert(overlay!);+}++class LinkReplaceMenu extends StatefulWidget {+ const LinkReplaceMenu({+ super.key,+ required this.onSubmitted,+ required this.link,+ required this.onDismiss,+ });++ final ValueChanged<String> onSubmitted;+ final VoidCallback onDismiss;+ final String link;++ @override+ State<LinkReplaceMenu> createState() => _LinkReplaceMenuState();+}++class _LinkReplaceMenuState extends State<LinkReplaceMenu> {+ bool showErrorText = false;+ late FocusNode focusNode = FocusNode(onKeyEvent: onKeyEvent);+ late TextEditingController textEditingController =+ TextEditingController(text: widget.link);++ @override+ void initState() {+ super.initState();+ WidgetsBinding.instance.addPostFrameCallback((_) {+ focusNode.requestFocus();+ });+ }++ @override+ void dispose() {+ focusNode.dispose();+ textEditingController.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ return Container(+ width: 330,+ padding: EdgeInsets.all(8),+ decoration: buildToolbarLinkDecoration(context),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Expanded(child: buildLinkField()),+ HSpace(8),+ buildReplaceButton(),+ ],+ ),+ );+ }++ Widget buildLinkField() {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ height: 32,+ child: TextFormField(+ autovalidateMode: AutovalidateMode.onUserInteraction,+ autofocus: true,+ focusNode: focusNode,+ textAlign: TextAlign.left,+ controller: textEditingController,+ style: TextStyle(+ fontSize: 14,+ height: 20 / 14,+ fontWeight: FontWeight.w400,+ ),+ decoration: LinkStyle.buildLinkTextFieldInputDecoration(+ LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_pasteHint+ .tr(),+ context,+ showErrorBorder: showErrorText,+ ),+ ),+ ),+ if (showErrorText)+ Padding(+ padding: const EdgeInsets.only(top: 4),+ child: FlowyText.regular(+ LocaleKeys.document_plugins_file_networkUrlInvalid.tr(),+ color: LinkStyle.textStatusError,+ fontSize: 12,+ figmaLineHeight: 16,+ ),+ ),+ ],+ );+ }++ Widget buildReplaceButton() {+ return FlowyTextButton(+ LocaleKeys.button_replace.tr(),+ padding: EdgeInsets.zero,+ mainAxisAlignment: MainAxisAlignment.center,+ constraints: BoxConstraints(maxWidth: 78, minHeight: 32),+ fontSize: 14,+ lineHeight: 20 / 14,+ hoverColor: LinkStyle.fillThemeThick.withAlpha(200),+ fontColor: Colors.white,+ fillColor: LinkStyle.fillThemeThick,+ fontWeight: FontWeight.w400,+ onPressed: onSubmit,+ );+ }++ void onSubmit() {+ final link = textEditingController.text.trim();+ if (link.isEmpty || !isUri(link)) {+ setState(() {+ showErrorText = true;+ });+ return;+ }+ widget.onSubmitted.call(link);+ }++ KeyEventResult onKeyEvent(FocusNode node, KeyEvent key) {+ if (key is! KeyDownEvent) return KeyEventResult.ignored;+ if (key.logicalKey == LogicalKeyboardKey.escape) {+ widget.onDismiss.call();+ return KeyEventResult.handled;+ } else if (key.logicalKey == LogicalKeyboardKey.enter) {+ onSubmit();+ return KeyEventResult.handled;+ }+ return KeyEventResult.ignored;+ }+}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.dartnew file mode 100644index 0000000000..6dc6501c03--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart@@ -0,0 +1,286 @@+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart';+import 'package:appflowy/shared/appflowy_network_image.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';+import 'package:flutter_bloc/flutter_bloc.dart';++import 'link_embed_menu.dart';++class LinkEmbedKeys {+ const LinkEmbedKeys._();+ static const String previewType = 'preview_type';+ static const String embed = 'embed';+ static const String align = 'align';+}++Node linkEmbedNode({required String url}) => Node(+ type: LinkPreviewBlockKeys.type,+ attributes: {+ LinkPreviewBlockKeys.url: url,+ LinkEmbedKeys.previewType: LinkEmbedKeys.embed,+ },+ );++class LinkEmbedBlockComponent extends BlockComponentStatefulWidget {+ const LinkEmbedBlockComponent({+ super.key,+ super.showActions,+ super.actionBuilder,+ super.configuration = const BlockComponentConfiguration(),+ required super.node,+ });++ @override+ State<LinkEmbedBlockComponent> createState() =>+ LinkEmbedBlockComponentState();+}++class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>+ with BlockComponentConfigurable {+ @override+ BlockComponentConfiguration get configuration => widget.configuration;++ @override+ Node get node => widget.node;++ String get url => widget.node.attributes[LinkPreviewBlockKeys.url]!;++ EmbedLoadingStatus status = EmbedLoadingStatus.loading;+ final parser = LinkParser();+ LinkInfo linkInfo = LinkInfo();++ final showActionsNotifier = ValueNotifier<bool>(false);+ bool isMenuShowing = false, isHovering = false;++ @override+ void initState() {+ super.initState();+ parser.addLinkInfoListener((v) {+ if (mounted) {+ setState(() {+ if (v.isEmpty() && linkInfo.isEmpty()) {+ status = EmbedLoadingStatus.error;+ } else {+ linkInfo = v;+ status = EmbedLoadingStatus.idle;+ }+ });+ }+ });+ parser.start(url);+ }++ @override+ void dispose() {+ parser.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ Widget result = MouseRegion(+ onEnter: (_) {+ isHovering = true;+ showActionsNotifier.value = true;+ },+ onExit: (_) {+ isHovering = false;+ Future.delayed(const Duration(milliseconds: 200), () {+ if (isMenuShowing || isHovering) return;+ if (mounted) showActionsNotifier.value = false;+ });+ },+ child: buildChild(context),+ );+ result = Padding(padding: padding, child: result);++ if (widget.showActions && widget.actionBuilder != null) {+ result = BlockComponentActionWrapper(+ node: node,+ actionBuilder: widget.actionBuilder!,+ child: result,+ );+ }+ return result;+ }++ Widget buildChild(BuildContext context) {+ final theme = AppFlowyTheme.of(context),+ fillSceme = theme.fillColorScheme,+ borderScheme = theme.borderColorScheme;+ Widget child;+ final isIdle = status == EmbedLoadingStatus.idle;+ if (isIdle) {+ child = buildContent(context);+ } else {+ child = buildErrorLoadingWidget(context);+ }+ return Container(+ height: 450,+ decoration: BoxDecoration(+ color: isIdle ? Theme.of(context).cardColor : fillSceme.tertiaryHover,+ borderRadius: BorderRadius.all(Radius.circular(16)),+ border: Border.all(color: borderScheme.greyTertiary),+ ),+ child: Stack(+ children: [+ child,+ buildMenu(context),+ ],+ ),+ );+ }++ Widget buildMenu(BuildContext context) {+ return Positioned(+ top: 12,+ right: 12,+ child: ValueListenableBuilder<bool>(+ valueListenable: showActionsNotifier,+ builder: (context, showActions, child) {+ if (!showActions) return SizedBox.shrink();+ return LinkEmbedMenu(+ editorState: context.read<EditorState>(),+ node: node,+ onReload: () {+ setState(() {+ status = EmbedLoadingStatus.loading;+ });+ Future.delayed(const Duration(milliseconds: 200), () {+ if (mounted) parser.start(url);+ });+ },+ onMenuShowed: () {+ isMenuShowing = true;+ },+ onMenuHided: () {+ isMenuShowing = false;+ if (!isHovering && mounted) {+ showActionsNotifier.value = false;+ }+ },+ );+ },+ ),+ );+ }++ Widget buildContent(BuildContext context) {+ final theme = AppFlowyTheme.of(context), textScheme = theme.textColorScheme;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Expanded(+ child: ClipRRect(+ borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),+ child: FlowyNetworkImage(+ url: linkInfo.imageUrl ?? '',+ width: MediaQuery.of(context).size.width,+ ),+ ),+ ),+ Container(+ height: 64,+ padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20),+ child: Row(+ children: [+ SizedBox.square(+ dimension: 40,+ child: Center(+ child: linkInfo.buildIconWidget(size: Size.square(32)),+ ),+ ),+ HSpace(12),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ FlowyText(+ linkInfo.siteName ?? '',+ color: textScheme.primary,+ fontSize: 14,+ figmaLineHeight: 20,+ fontWeight: FontWeight.w600,+ overflow: TextOverflow.ellipsis,+ ),+ VSpace(4),+ FlowyText.regular(+ url,+ color: textScheme.secondary,+ fontSize: 12,+ figmaLineHeight: 16,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ ),+ ],+ ),+ ),+ ],+ );+ }++ Widget buildErrorLoadingWidget(BuildContext context) {+ final theme = AppFlowyTheme.of(context), textSceme = theme.textColorScheme;+ final isLoading = status == EmbedLoadingStatus.loading;+ return isLoading+ ? Center(+ child: SizedBox.square(+ dimension: 64,+ child: CircularProgressIndicator.adaptive(),+ ),+ )+ : Center(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ SvgPicture.asset(+ FlowySvgs.embed_error_xl.path,+ ),+ VSpace(4),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 24),+ child: RichText(+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ text: TextSpan(+ children: [+ TextSpan(+ text: '$url ',+ style: TextStyle(+ color: textSceme.primary,+ fontSize: 14,+ height: 20 / 14,+ fontWeight: FontWeight.w700,+ ),+ ),+ TextSpan(+ text: LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_refuseConnect+ .tr(),+ style: TextStyle(+ color: textSceme.primary,+ fontSize: 14,+ height: 20 / 14,+ fontWeight: FontWeight.w400,+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ );+ }+}++enum EmbedLoadingStatus { loading, idle, error }diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_menu.dartnew file mode 100644index 0000000000..8b9ac122a8--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_embed/link_embed_menu.dart@@ -0,0 +1,332 @@+import 'package:appflowy/core/helpers/url_launcher.dart';+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_replace_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/shared.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/menu/menu_extension.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/widgets.dart';++import 'link_embed_block_component.dart';++class LinkEmbedMenu extends StatefulWidget {+ const LinkEmbedMenu({+ super.key,+ required this.node,+ required this.editorState,+ required this.onMenuShowed,+ required this.onMenuHided,+ required this.onReload,+ });++ final Node node;+ final EditorState editorState;+ final VoidCallback onMenuShowed;+ final VoidCallback onMenuHided;+ final VoidCallback onReload;++ @override+ State<LinkEmbedMenu> createState() => _LinkEmbedMenuState();+}++class _LinkEmbedMenuState extends State<LinkEmbedMenu> {+ final turnintoController = PopoverController();+ final moreOptionController = PopoverController();+ int turnintoMenuNum = 0, moreOptionNum = 0, alignMenuNum = 0;+ final moreOptionButtonKey = GlobalKey();+ bool get isTurnIntoShowing => turnintoMenuNum > 0;+ bool get isMoreOptionShowing => moreOptionNum > 0;+ bool get isAlignMenuShowing => alignMenuNum > 0;++ Node get node => widget.node;+ EditorState get editorState => widget.editorState;++ String get url => node.attributes[LinkPreviewBlockKeys.url] ?? '';++ @override+ void dispose() {+ super.dispose();+ turnintoController.close();+ moreOptionController.close();+ widget.onMenuHided.call();+ }++ @override+ Widget build(BuildContext context) {+ return buildChild();+ }++ Widget buildChild() {+ final theme = AppFlowyTheme.of(context),+ iconScheme = theme.iconColorTheme,+ fillScheme = theme.fillColorScheme;++ return Container(+ padding: EdgeInsets.all(4),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(16),+ color: fillScheme.primaryAlpha80,+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ // FlowyIconButton(+ // icon: FlowySvg(+ // FlowySvgs.embed_fullscreen_m,+ // color: iconScheme.tertiary,+ // ),+ // tooltipText: LocaleKeys.document_imageBlock_openFullScreen.tr(),+ // preferBelow: false,+ // onPressed: () {},+ // ),+ FlowyIconButton(+ icon: FlowySvg(+ FlowySvgs.toolbar_link_m,+ color: iconScheme.tertiary,+ ),+ tooltipText: LocaleKeys.editor_copyLink.tr(),+ preferBelow: false,+ onPressed: () => copyLink(context),+ ),+ buildTurnIntoBotton(),+ buildMoreOptionBotton(),+ ],+ ),+ );+ }++ Widget buildTurnIntoBotton() {+ final theme = AppFlowyTheme.of(context), iconScheme = theme.iconColorTheme;+ return AppFlowyPopover(+ offset: Offset(0, 6),+ direction: PopoverDirection.bottomWithRightAligned,+ margin: EdgeInsets.zero,+ controller: turnintoController,+ onOpen: () {+ keepEditorFocusNotifier.increase();+ turnintoMenuNum++;+ },+ onClose: () {+ keepEditorFocusNotifier.decrease();+ turnintoMenuNum--;+ checkToHideMenu();+ },+ popupBuilder: (context) => buildTurnIntoMenu(),+ child: FlowyIconButton(+ icon: FlowySvg(+ FlowySvgs.turninto_m,+ color: iconScheme.tertiary,+ ),+ tooltipText: LocaleKeys.document_toolbar_turnInto.tr(),+ preferBelow: false,+ onPressed: showTurnIntoMenu,+ ),+ );+ }++ Widget buildTurnIntoMenu() {+ final types =+ PasteMenuType.values.where((e) => e != PasteMenuType.embed).toList();+ return Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children: List.generate(types.length, (index) {+ final command = types[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () {+ if (command == PasteMenuType.bookmark) {+ final transaction = editorState.transaction;+ transaction.updateNode(node, {+ LinkPreviewBlockKeys.url: url,+ LinkEmbedKeys.previewType: '',+ });+ editorState.apply(transaction);+ } else if (command == PasteMenuType.mention) {+ convertUrlPreviewNodeToMention(editorState, node);+ } else if (command == PasteMenuType.url) {+ convertUrlPreviewNodeToLink(editorState, node);+ }+ },+ ),+ );+ }),+ ),+ );+ }++ Widget buildMoreOptionBotton() {+ final theme = AppFlowyTheme.of(context), iconScheme = theme.iconColorTheme;+ return AppFlowyPopover(+ offset: Offset(0, 6),+ direction: PopoverDirection.bottomWithRightAligned,+ margin: EdgeInsets.zero,+ controller: moreOptionController,+ onOpen: () {+ keepEditorFocusNotifier.increase();+ moreOptionNum++;+ },+ onClose: () {+ keepEditorFocusNotifier.decrease();+ moreOptionNum--;+ checkToHideMenu();+ },+ popupBuilder: (context) => buildMoreOptionMenu(),+ child: FlowyIconButton(+ key: moreOptionButtonKey,+ icon: FlowySvg(+ FlowySvgs.toolbar_more_m,+ color: iconScheme.tertiary,+ ),+ tooltipText: LocaleKeys.document_toolbar_moreOptions.tr(),+ preferBelow: false,+ onPressed: showMoreOptionMenu,+ ),+ );+ }++ Widget buildMoreOptionMenu() {+ final types = LinkEmbedMenuCommand.values;+ return Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children: List.generate(types.length, (index) {+ final command = types[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () => onEmbedMenuCommand(command),+ ),+ );+ }),+ ),+ );+ }++ void showTurnIntoMenu() {+ keepEditorFocusNotifier.increase();+ turnintoController.show();+ checkToShowMenu();+ turnintoMenuNum++;+ if (isMoreOptionShowing) closeMoreOptionMenu();+ }++ void closeTurnIntoMenu() {+ turnintoController.close();+ checkToHideMenu();+ }++ void showMoreOptionMenu() {+ keepEditorFocusNotifier.increase();+ moreOptionController.show();+ checkToShowMenu();+ moreOptionNum++;+ if (isTurnIntoShowing) closeTurnIntoMenu();+ }++ void closeMoreOptionMenu() {+ moreOptionController.close();+ checkToHideMenu();+ }++ void checkToHideMenu() {+ Future.delayed(Duration(milliseconds: 200), () {+ if (!mounted) return;+ if (!isAlignMenuShowing && !isMoreOptionShowing && !isTurnIntoShowing) {+ widget.onMenuHided.call();+ }+ });+ }++ void checkToShowMenu() {+ if (!isAlignMenuShowing && !isMoreOptionShowing && !isTurnIntoShowing) {+ widget.onMenuShowed.call();+ }+ }++ Future<void> copyLink(BuildContext context) async {+ await context.copyLink(url);+ widget.onMenuHided.call();+ }++ void onEmbedMenuCommand(LinkEmbedMenuCommand command) {+ switch (command) {+ case LinkEmbedMenuCommand.openLink:+ afLaunchUrlString(url, addingHttpSchemeWhenFailed: true);+ break;+ case LinkEmbedMenuCommand.replace:+ final box = moreOptionButtonKey.currentContext?.findRenderObject()+ as RenderBox?;+ if (box == null) return;+ final p = box.localToGlobal(Offset.zero);+ showReplaceMenu(+ context: context,+ editorState: editorState,+ node: node,+ url: url,+ ltrb: LTRB(left: p.dx - 330, top: p.dy),+ onReplace: (url) async {+ await convertLinkBlockToOtherLinkBlock(+ editorState,+ node,+ node.type,+ url: url,+ );+ },+ );+ break;+ case LinkEmbedMenuCommand.reload:+ widget.onReload.call();+ break;+ case LinkEmbedMenuCommand.removeLink:+ removeUrlPreviewLink(editorState, node);+ break;+ }+ closeMoreOptionMenu();+ }+}++enum LinkEmbedMenuCommand {+ openLink,+ replace,+ reload,+ removeLink;++ String get title {+ switch (this) {+ case openLink:+ return LocaleKeys.editor_openLink.tr();+ case replace:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_replace+ .tr();+ case reload:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_reload+ .tr();+ case removeLink:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_removeLink+ .tr();+ }+ }+}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.dartnew file mode 100644index 0000000000..0032d9cd33--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart@@ -0,0 +1,135 @@+import 'dart:convert';+import 'package:appflowy/core/config/kv.dart';+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/shared/appflowy_network_image.dart';+import 'package:appflowy/shared/appflowy_network_svg.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy_backend/log.dart';+import 'package:favicon/favicon.dart';+import 'package:flutter/material.dart';+// ignore: depend_on_referenced_packages+import 'package:flutter_link_previewer/flutter_link_previewer.dart' hide Size;++class LinkParser {+ static final LinkInfoCache _cache = LinkInfoCache();+ final Set<ValueChanged<LinkInfo>> _listeners = <ValueChanged<LinkInfo>>{};++ Future<void> start(String url) async {+ final data = await _cache.get(url);+ if (data != null) {+ refreshLinkInfo(data);+ }+ await _getLinkInfo(url);+ }++ Future<LinkInfo?> _getLinkInfo(String url) async {+ try {+ final previewData = await getPreviewData(url);+ final favicon = await FaviconFinder.getBest(url);+ final linkInfo = LinkInfo(+ siteName: previewData.title,+ description: previewData.description,+ imageUrl: previewData.image?.url,+ faviconUrl: favicon?.url,+ );+ if (!linkInfo.isEmpty()) await _cache.set(url, linkInfo);+ refreshLinkInfo(linkInfo);+ return linkInfo;+ } catch (e, s) {+ Log.error('get link info error: ', e, s);+ refreshLinkInfo(LinkInfo());+ return null;+ }+ }++ void refreshLinkInfo(LinkInfo info) {+ for (final listener in _listeners) {+ listener(info);+ }+ }++ void addLinkInfoListener(ValueChanged<LinkInfo> listener) {+ _listeners.add(listener);+ }++ void dispose() {+ _listeners.clear();+ }+}++class LinkInfo {+ factory LinkInfo.fromJson(Map<String, dynamic> json) => LinkInfo(+ siteName: json['siteName'],+ description: json['description'],+ imageUrl: json['imageUrl'],+ faviconUrl: json['faviconUrl'],+ );++ LinkInfo({+ this.siteName,+ this.description,+ this.imageUrl,+ this.faviconUrl,+ });++ final String? siteName;+ final String? description;+ final String? imageUrl;+ final String? faviconUrl;++ Map<String, dynamic> toJson() => {+ 'siteName': siteName,+ 'description': description,+ 'imageUrl': imageUrl,+ 'faviconUrl': faviconUrl,+ };++ bool isEmpty() {+ return siteName == null ||+ description == null ||+ imageUrl == null ||+ faviconUrl == null;+ }++ Widget buildIconWidget({Size size = const Size.square(20.0)}) {+ final iconUrl = faviconUrl;+ if (iconUrl == null) {+ return FlowySvg(FlowySvgs.toolbar_link_earth_m, size: size);+ }+ if (iconUrl.endsWith('.svg')) {+ return FlowyNetworkSvg(+ iconUrl,+ height: size.height,+ width: size.width,+ errorWidget: const FlowySvg(FlowySvgs.toolbar_link_earth_m),+ );+ }+ return FlowyNetworkImage(+ url: iconUrl,+ fit: BoxFit.contain,+ height: size.height,+ width: size.width,+ errorWidgetBuilder: (context, error, stackTrace) =>+ const FlowySvg(FlowySvgs.toolbar_link_earth_m),+ );+ }+}++class LinkInfoCache {+ final _linkInfoPrefix = 'link_info';++ Future<LinkInfo?> get(String url) async {+ final option = await getIt<KeyValueStorage>().getWithFormat<LinkInfo?>(+ _linkInfoPrefix + url,+ (value) => LinkInfo.fromJson(jsonDecode(value)),+ );+ return option;+ }++ Future<void> set(String url, LinkInfo data) async {+ await getIt<KeyValueStorage>().set(+ _linkInfoPrefix + url,+ jsonEncode(data.toJson()),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dartindex 879a71f008..0b6ad9fd7b 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dart@@ -12,6 +12,7 @@ import 'package:flutter/material.dart';import 'package:go_router/go_router.dart';import 'package:provider/provider.dart';import 'package:universal_platform/universal_platform.dart';+import 'package:appflowy_ui/appflowy_ui.dart';class CustomLinkPreviewWidget extends StatelessWidget {const CustomLinkPreviewWidget({@@ -21,6 +22,8 @@ class CustomLinkPreviewWidget extends StatelessWidget {this.title,this.description,this.imageUrl,+ this.isHovering = false,+ this.status = LinkPreviewStatus.loading,});final Node node;@@ -28,9 +31,14 @@ class CustomLinkPreviewWidget extends StatelessWidget {final String? description;final String? imageUrl;final String url;+ final bool isHovering;+ final LinkPreviewStatus status;@overrideWidget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context),+ borderScheme = theme.borderColorScheme,+ textScheme = theme.textColorScheme;final documentFontSize = context.read<EditorState>().editorStyle@@ -39,69 +47,60 @@ class CustomLinkPreviewWidget extends StatelessWidget {.fontSize ??16.0;final (fontSize, width) = UniversalPlatform.isDesktopOrWeb- ? (documentFontSize, 180.0)+ ? (documentFontSize, 160.0): (documentFontSize - 2, 120.0);final Widget child = Container(clipBehavior: Clip.hardEdge,decoration: BoxDecoration(border: Border.all(- color: Theme.of(context).colorScheme.onSurface,- ),- borderRadius: BorderRadius.circular(- 6.0,+ color: isHovering+ ? borderScheme.greyTertiaryHover+ : borderScheme.greyTertiary,),+ borderRadius: BorderRadius.circular(16.0),),- child: IntrinsicHeight(+ child: SizedBox(+ height: 96,child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,children: [- if (imageUrl != null)- ClipRRect(- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(6.0),- bottomLeft: Radius.circular(6.0),- ),- child: FlowyNetworkImage(- url: imageUrl!,- width: width,- ),- ),+ buildImage(context),Expanded(child: Padding(- padding: const EdgeInsets.all(8.0),+ padding: const EdgeInsets.fromLTRB(20, 12, 60, 12),child: Column(crossAxisAlignment: CrossAxisAlignment.start,mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [+ buildLoadingOrErrorWidget(),if (title != null)Padding(- padding: const EdgeInsets.only(- bottom: 4.0,- right: 10.0,- ),+ padding: const EdgeInsets.only(bottom: 4.0),child: FlowyText.medium(title!,- maxLines: 2,overflow: TextOverflow.ellipsis,fontSize: fontSize,+ color: textScheme.primary,+ figmaLineHeight: 20,),),if (description != null)Padding(- padding: const EdgeInsets.only(bottom: 4.0),+ padding: const EdgeInsets.only(bottom: 16.0),child: FlowyText(description!,- maxLines: 2,overflow: TextOverflow.ellipsis,fontSize: fontSize - 4,+ figmaLineHeight: 16,+ color: textScheme.primary,),),FlowyText(url.toString(),overflow: TextOverflow.ellipsis,- maxLines: 2,- color: Theme.of(context).hintColor,+ color: textScheme.secondary,fontSize: fontSize - 4,+ figmaLineHeight: 16,),],),@@ -150,4 +149,67 @@ class CustomLinkPreviewWidget extends StatelessWidget {),];}++ Widget buildImage(BuildContext context) {+ final theme = AppFlowyTheme.of(context),+ fillScheme = theme.fillColorScheme,+ iconScheme = theme.iconColorTheme;+ final width = UniversalPlatform.isDesktopOrWeb ? 160.0 : 120.0;+ Widget child;+ if (imageUrl != null) {+ child = FlowyNetworkImage(+ url: imageUrl!,+ width: width,+ );+ } else {+ child = Center(+ child: FlowySvg(+ FlowySvgs.toolbar_link_earth_m,+ color: iconScheme.secondary,+ size: Size.square(30),+ ),+ );+ }+ return ClipRRect(+ borderRadius: const BorderRadius.only(+ topLeft: Radius.circular(16.0),+ bottomLeft: Radius.circular(16.0),+ ),+ child: Container(+ width: width,+ color: fillScheme.quaternary,+ child: child,+ ),+ );+ }++ Widget buildLoadingOrErrorWidget() {+ if (status == LinkPreviewStatus.loading) {+ return Expanded(+ child: const Center(+ child: SizedBox(+ height: 16,+ width: 16,+ child: CircularProgressIndicator.adaptive(),+ ),+ ),+ );+ } else if (status == LinkPreviewStatus.error) {+ return Expanded(+ child: const Center(+ child: SizedBox(+ height: 16,+ width: 16,+ child: Icon(+ Icons.error_outline,+ color: Colors.red,+ ),+ ),+ ),+ );+ }+ return SizedBox.shrink();+ }}++enum LinkPreviewStatus { loading, error, idle }diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview_block_component.dartnew file mode 100644index 0000000000..3772169331--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview_block_component.dart@@ -0,0 +1,204 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';+import 'package:flutter/material.dart';++import 'custom_link_preview.dart';+import 'link_preview_menu.dart';++class CustomLinkPreviewBlockComponentBuilder extends BlockComponentBuilder {+ CustomLinkPreviewBlockComponentBuilder({+ super.configuration,+ this.cache,+ });++ final LinkPreviewDataCacheInterface? cache;++ @override+ BlockComponentWidget build(BlockComponentContext blockComponentContext) {+ final node = blockComponentContext.node;+ final isEmbed =+ node.attributes[LinkEmbedKeys.previewType] == LinkEmbedKeys.embed;+ if (isEmbed) {+ return LinkEmbedBlockComponent(+ key: node.key,+ node: node,+ configuration: configuration,+ showActions: showActions(node),+ actionBuilder: (_, state) =>+ actionBuilder(blockComponentContext, state),+ );+ }+ return CustomLinkPreviewBlockComponent(+ key: node.key,+ node: node,+ configuration: configuration,+ showActions: showActions(node),+ actionBuilder: (_, state) => actionBuilder(blockComponentContext, state),+ cache: cache,+ );+ }++ @override+ BlockComponentValidate get validate =>+ (node) => node.attributes[LinkPreviewBlockKeys.url]!.isNotEmpty;+}++class CustomLinkPreviewBlockComponent extends BlockComponentStatefulWidget {+ const CustomLinkPreviewBlockComponent({+ super.key,+ required super.node,+ super.showActions,+ super.actionBuilder,+ super.configuration = const BlockComponentConfiguration(),+ this.cache,+ });++ final LinkPreviewDataCacheInterface? cache;++ @override+ State<CustomLinkPreviewBlockComponent> createState() =>+ CustomLinkPreviewBlockComponentState();+}++class CustomLinkPreviewBlockComponentState+ extends State<CustomLinkPreviewBlockComponent>+ with BlockComponentConfigurable {+ @override+ BlockComponentConfiguration get configuration => widget.configuration;++ @override+ Node get node => widget.node;++ String get url => widget.node.attributes[LinkPreviewBlockKeys.url]!;++ late final LinkPreviewParser parser;+ late Future<void> future;++ final showActionsNotifier = ValueNotifier<bool>(false);+ bool isMenuShowing = false, isHovering = false;++ @override+ void initState() {+ super.initState();+ parser = LinkPreviewParser(url: url, cache: widget.cache);+ future = parser.start();+ }++ @override+ void didUpdateWidget(CustomLinkPreviewBlockComponent oldWidget) {+ super.didUpdateWidget(oldWidget);+ final url = widget.node.attributes[LinkPreviewBlockKeys.url]!;+ final oldUrl = oldWidget.node.attributes[LinkPreviewBlockKeys.url]!;+ if (url != oldUrl) {+ parser = LinkPreviewParser(url: url, cache: widget.cache);+ setState(() {+ future = parser.start();+ });+ }+ }++ @override+ Widget build(BuildContext context) {+ return MouseRegion(+ onEnter: (_) {+ isHovering = true;+ showActionsNotifier.value = true;+ },+ onExit: (_) {+ isHovering = false;+ Future.delayed(const Duration(milliseconds: 200), () {+ if (isMenuShowing || isHovering) return;+ if (mounted) showActionsNotifier.value = false;+ });+ },+ hitTestBehavior: HitTestBehavior.opaque,+ opaque: false,+ child: ValueListenableBuilder<bool>(+ valueListenable: showActionsNotifier,+ builder: (context, showActions, child) {+ return FutureBuilder(+ future: future,+ builder: (context, snapshot) {+ Widget child;++ if (snapshot.connectionState != ConnectionState.done) {+ child = CustomLinkPreviewWidget(+ node: node,+ url: url,+ isHovering: showActions,+ );+ } else {+ final title = parser.getContent(LinkPreviewRegex.title);+ final description =+ parser.getContent(LinkPreviewRegex.description);+ final image = parser.getContent(LinkPreviewRegex.image);++ if (title == null && description == null && image == null) {+ child = CustomLinkPreviewWidget(+ node: node,+ url: url,+ isHovering: showActions,+ status: LinkPreviewStatus.error,+ );+ } else {+ child = CustomLinkPreviewWidget(+ node: node,+ url: url,+ title: title,+ description: description,+ imageUrl: image,+ isHovering: showActions,+ status: LinkPreviewStatus.idle,+ );+ }+ }++ child = Padding(padding: padding, child: child);++ if (widget.showActions && widget.actionBuilder != null) {+ child = BlockComponentActionWrapper(+ node: node,+ actionBuilder: widget.actionBuilder!,+ child: child,+ );+ }++ child = Stack(+ children: [+ child,+ if (showActions)+ Positioned(+ top: 16,+ right: 16,+ child: CustomLinkPreviewMenu(+ onMenuShowed: () {+ isMenuShowing = true;+ },+ onMenuHided: () {+ isMenuShowing = false;+ if (!isHovering && mounted) {+ showActionsNotifier.value = false;+ }+ },+ onReload: () {+ if (mounted) {+ setState(() {+ future = parser.start();+ });+ }+ },+ node: node,+ ),+ ),+ ],+ );++ return child;+ },+ );+ },+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dartindex 2ba67a87da..2fb493dda3 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/link_preview_menu.dart@@ -1,109 +1,207 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/plugins/document/presentation/editor_plugins/block_menu/block_menu_button.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_replace_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/shared.dart';-import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/menu/menu_extension.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';-import 'package:flutter/services.dart';import 'package:provider/provider.dart';-import '../image/custom_image_block_component/custom_image_block_component.dart';--class LinkPreviewMenu extends StatefulWidget {- const LinkPreviewMenu({+class CustomLinkPreviewMenu extends StatefulWidget {+ const CustomLinkPreviewMenu({super.key,+ required this.onMenuShowed,+ required this.onMenuHided,+ required this.onReload,required this.node,- required this.state,});-+ final VoidCallback onMenuShowed;+ final VoidCallback onMenuHided;+ final VoidCallback onReload;final Node node;- final LinkPreviewBlockComponentState state;@override- State<LinkPreviewMenu> createState() => _LinkPreviewMenuState();+ State<CustomLinkPreviewMenu> createState() => _CustomLinkPreviewMenuState();}-class _LinkPreviewMenuState extends State<LinkPreviewMenu> {+class _CustomLinkPreviewMenuState extends State<CustomLinkPreviewMenu> {+ final popoverController = PopoverController();+ final buttonKey = GlobalKey();+ bool closed = false;+ bool selected = false;++ @override+ void dispose() {+ super.dispose();+ popoverController.close();+ widget.onMenuHided.call();+ }+@overrideWidget build(BuildContext context) {- final theme = Theme.of(context);- return Container(- height: 32,- decoration: BoxDecoration(- color: theme.cardColor,- boxShadow: [- BoxShadow(- blurRadius: 5,- spreadRadius: 1,- color: Colors.black.withValues(alpha: 0.1),- ),- ],- borderRadius: BorderRadius.circular(4.0),+ return AppFlowyPopover(+ offset: Offset(0, 0.0),+ direction: PopoverDirection.bottomWithRightAligned,+ margin: EdgeInsets.zero,+ controller: popoverController,+ onOpen: () => keepEditorFocusNotifier.increase(),+ onClose: () {+ keepEditorFocusNotifier.decrease();+ if (!closed) {+ closed = true;+ return;+ } else {+ closed = false;+ widget.onMenuHided.call();+ }+ setState(() {+ selected = false;+ });+ },+ popupBuilder: (context) => buildMenu(),+ child: FlowyIconButton(+ key: buttonKey,+ isSelected: selected,+ icon: FlowySvg(FlowySvgs.toolbar_more_m),+ onPressed: showPopover,),- child: Row(- children: [- const HSpace(4),- MenuBlockButton(- tooltip: LocaleKeys.document_plugins_urlPreview_convertToLink.tr(),- iconData: FlowySvgs.m_toolbar_link_m,- onTap: () async => convertUrlPreviewNodeToLink(- context.read<EditorState>(),- widget.node,- ),- ),- const HSpace(4),- MenuBlockButton(- tooltip: LocaleKeys.editor_copyLink.tr(),- iconData: FlowySvgs.copy_s,- onTap: copyImageLink,- ),- const _Divider(),- MenuBlockButton(- tooltip: LocaleKeys.button_delete.tr(),- iconData: FlowySvgs.trash_s,- onTap: deleteLinkPreviewNode,- ),- const HSpace(4),- ],+ );+ }++ Widget buildMenu() {+ return MouseRegion(+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children:+ List.generate(LinkPreviewMenuCommand.values.length, (index) {+ final command = LinkPreviewMenuCommand.values[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () => onTap(command),+ ),+ );+ }),+ ),),);}- void copyImageLink() {- final url = widget.node.attributes[CustomImageBlockKeys.url];- if (url != null) {- Clipboard.setData(ClipboardData(text: url));- showToastNotification(- message: LocaleKeys.document_plugins_urlPreview_copiedToPasteBoard.tr(),- );+ Future<void> onTap(LinkPreviewMenuCommand command) async {+ final editorState = context.read<EditorState>();+ final node = widget.node;+ final url = node.attributes[LinkPreviewBlockKeys.url];+ switch (command) {+ case LinkPreviewMenuCommand.convertToMention:+ await convertUrlPreviewNodeToMention(editorState, node);+ break;+ case LinkPreviewMenuCommand.convertToUrl:+ await convertUrlPreviewNodeToLink(editorState, node);+ break;+ case LinkPreviewMenuCommand.convertToEmbed:+ final transaction = editorState.transaction;+ transaction.updateNode(node, {+ LinkPreviewBlockKeys.url: url,+ LinkEmbedKeys.previewType: LinkEmbedKeys.embed,+ });+ await editorState.apply(transaction);+ break;+ case LinkPreviewMenuCommand.copyLink:+ if (url != null) {+ await context.copyLink(url);+ }+ break;+ case LinkPreviewMenuCommand.replace:+ final box = buttonKey.currentContext?.findRenderObject() as RenderBox?;+ if (box == null) return;+ final p = box.localToGlobal(Offset.zero);+ showReplaceMenu(+ context: context,+ editorState: editorState,+ node: node,+ url: url,+ ltrb: LTRB(left: p.dx - 330, top: p.dy),+ onReplace: (url) async {+ await convertLinkBlockToOtherLinkBlock(+ editorState,+ node,+ node.type,+ url: url,+ );+ },+ );+ break;+ case LinkPreviewMenuCommand.reload:+ widget.onReload.call();+ break;+ case LinkPreviewMenuCommand.removeLink:+ await removeUrlPreviewLink(editorState, node);+ break;}+ closePopover();}- Future<void> deleteLinkPreviewNode() async {- final node = widget.node;- final editorState = context.read<EditorState>();- final transaction = editorState.transaction;- transaction.deleteNode(node);- transaction.afterSelection = null;- await editorState.apply(transaction);+ void showPopover() {+ widget.onMenuShowed.call();+ keepEditorFocusNotifier.increase();+ popoverController.show();+ setState(() {+ selected = true;+ });+ }++ void closePopover() {+ popoverController.close();+ widget.onMenuHided.call();}}-class _Divider extends StatelessWidget {- const _Divider();+enum LinkPreviewMenuCommand {+ convertToMention,+ convertToUrl,+ convertToEmbed,+ copyLink,+ replace,+ reload,+ removeLink;- @override- Widget build(BuildContext context) {- return Padding(- padding: const EdgeInsets.all(8),- child: Container(- width: 1,- color: Colors.grey,- ),- );+ String get title {+ switch (this) {+ case convertToMention:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toMetion+ .tr();+ case LinkPreviewMenuCommand.convertToUrl:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toUrl+ .tr();+ case LinkPreviewMenuCommand.convertToEmbed:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toEmbed+ .tr();+ case LinkPreviewMenuCommand.copyLink:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_copyLink+ .tr();+ case LinkPreviewMenuCommand.replace:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_replace+ .tr();+ case LinkPreviewMenuCommand.reload:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_reload+ .tr();+ case LinkPreviewMenuCommand.removeLink:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_removeLink+ .tr();+ }}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dartnew file mode 100644index 0000000000..16febe54cb--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart@@ -0,0 +1,253 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/shared.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/menu/menu_extension.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra/theme_extension_v2.dart';+import 'package:flowy_infra_ui/style_widget/button.dart';+import 'package:flowy_infra_ui/style_widget/text.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++const _menuHeighgt = 188.0, _menuWidth = 288.0;++class PasteAsMenuService {+ PasteAsMenuService({+ required this.context,+ required this.editorState,+ });++ final BuildContext context;+ final EditorState editorState;+ OverlayEntry? _menuEntry;++ void show(String href) {+ WidgetsBinding.instance.addPostFrameCallback((_) => _show(href));+ }++ void dismiss() {+ if (_menuEntry != null) {+ editorState.service.keyboardService?.enable();+ editorState.service.scrollService?.enable();+ keepEditorFocusNotifier.decrease();+ }++ _menuEntry?.remove();+ _menuEntry = null;+ }++ void _show(String href) {+ final Size editorSize = editorState.renderBox?.size ?? Size.zero;+ if (editorSize == Size.zero) return;+ final menuPosition = editorState.calculateMenuOffset(+ menuWidth: _menuWidth,+ menuHeight: _menuHeighgt,+ );+ if (menuPosition == null) return;+ final ltrb = menuPosition.ltrb;++ _menuEntry = OverlayEntry(+ builder: (context) => SizedBox(+ height: editorSize.height,+ width: editorSize.width,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: dismiss,+ child: Stack(+ children: [+ ltrb.buildPositioned(+ child: PasteAsMenu(+ onSelect: (t) {+ final selection = editorState.selection;+ if (selection == null) return;+ final end = selection.end;+ final urlSelection = Selection(+ start: end.copyWith(offset: end.offset - href.length),+ end: end,+ );+ if (t == PasteMenuType.bookmark) {+ convertUrlToLinkPreview(editorState, urlSelection, href);+ } else if (t == PasteMenuType.mention) {+ convertUrlToMention(editorState, urlSelection);+ } else if (t == PasteMenuType.embed) {+ convertUrlToLinkPreview(+ editorState,+ urlSelection,+ href,+ previewType: LinkEmbedKeys.embed,+ );+ }+ dismiss();+ },+ onDismiss: dismiss,+ ),+ ),+ ],+ ),+ ),+ ),+ );++ Overlay.of(context).insert(_menuEntry!);++ editorState.service.keyboardService?.disable(showCursor: true);+ editorState.service.scrollService?.disable();+ }+}++class PasteAsMenu extends StatefulWidget {+ const PasteAsMenu({+ super.key,+ required this.onSelect,+ required this.onDismiss,+ });+ final ValueChanged<PasteMenuType?> onSelect;+ final VoidCallback onDismiss;++ @override+ State<PasteAsMenu> createState() => _PasteAsMenuState();+}++class _PasteAsMenuState extends State<PasteAsMenu> {+ final focusNode = FocusNode(debugLabel: 'paste_as_menu');+ final ValueNotifier<int> selectedIndexNotifier = ValueNotifier(0);++ @override+ void initState() {+ super.initState();+ WidgetsBinding.instance.addPostFrameCallback(+ (_) => focusNode.requestFocus(),+ );+ }++ @override+ void dispose() {+ focusNode.dispose();+ selectedIndexNotifier.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final themeV2 = AFThemeExtensionV2.of(context);+ return Focus(+ focusNode: focusNode,+ onKeyEvent: onKeyEvent,+ child: Container(+ width: _menuWidth,+ height: _menuHeighgt,+ padding: EdgeInsets.all(6),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(8),+ color: Theme.of(context).cardColor,+ boxShadow: [+ BoxShadow(+ offset: Offset(0, 4),+ blurRadius: 16,+ color: themeV2.shadow_medium,+ ),+ ],+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Container(+ height: 32,+ padding: EdgeInsets.all(8),+ child: FlowyText.semibold(+ color: themeV2.text_tertiary,+ LocaleKeys.document_plugins_linkPreview_typeSelection_pasteAs+ .tr(),+ ),+ ),+ ...List.generate(+ PasteMenuType.values.length,+ (i) => buildItem(PasteMenuType.values[i], i),+ ),+ ],+ ),+ ),+ );+ }++ Widget buildItem(PasteMenuType type, int i) {+ return ValueListenableBuilder(+ valueListenable: selectedIndexNotifier,+ builder: (context, value, child) {+ final isSelected = i == value;+ return SizedBox(+ height: 36,+ child: FlowyButton(+ isSelected: isSelected,+ text: FlowyText(+ type.title,+ ),+ onTap: () => onSelect(type),+ ),+ );+ },+ );+ }++ void changeIndex(int index) => selectedIndexNotifier.value = index;++ KeyEventResult onKeyEvent(focus, KeyEvent event) {+ if (event is! KeyDownEvent && event is! KeyRepeatEvent) {+ return KeyEventResult.ignored;+ }++ int index = selectedIndexNotifier.value,+ length = PasteMenuType.values.length;+ if (event.logicalKey == LogicalKeyboardKey.enter) {+ onSelect(PasteMenuType.values[index]);+ } else if (event.logicalKey == LogicalKeyboardKey.escape) {+ dismiss();+ } else if ([LogicalKeyboardKey.arrowUp, LogicalKeyboardKey.arrowLeft]+ .contains(event.logicalKey)) {+ if (index == 0) {+ index = length - 1;+ } else {+ index--;+ }+ changeIndex(index);+ } else if ([LogicalKeyboardKey.arrowDown, LogicalKeyboardKey.arrowRight]+ .contains(event.logicalKey)) {+ if (index == length - 1) {+ index = 0;+ } else {+ index++;+ }+ changeIndex(index);+ }+ return KeyEventResult.handled;+ }++ void onSelect(PasteMenuType type) => widget.onSelect.call(type);++ void dismiss() => widget.onDismiss.call();+}++enum PasteMenuType {+ mention,+ url,+ bookmark,+ embed,+}++extension PasteMenuTypeExtension on PasteMenuType {+ String get title {+ switch (this) {+ case PasteMenuType.mention:+ return LocaleKeys.document_plugins_linkPreview_typeSelection_mention+ .tr();+ case PasteMenuType.url:+ return LocaleKeys.document_plugins_linkPreview_typeSelection_URL.tr();+ case PasteMenuType.bookmark:+ return LocaleKeys.document_plugins_linkPreview_typeSelection_bookmark+ .tr();+ case PasteMenuType.embed:+ return LocaleKeys.document_plugins_linkPreview_typeSelection_embed.tr();+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/shared.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/shared.dartindex 57564c4722..8b193c70fb 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/shared.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/link_preview/shared.dart@@ -1,3 +1,5 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';@@ -9,7 +11,7 @@ Future<void> convertUrlPreviewNodeToLink(return;}- final url = node.attributes[ImageBlockKeys.url];+ final url = node.attributes[LinkPreviewBlockKeys.url];final delta = Delta()..insert(url,@@ -29,3 +31,172 @@ Future<void> convertUrlPreviewNodeToLink();return editorState.apply(transaction);}++Future<void> convertUrlPreviewNodeToMention(+ EditorState editorState,+ Node node,+) async {+ if (node.type != LinkPreviewBlockKeys.type) {+ return;+ }++ final url = node.attributes[LinkPreviewBlockKeys.url];+ final delta = Delta()+ ..insert(+ MentionBlockKeys.mentionChar,+ attributes: {+ MentionBlockKeys.mention: {+ MentionBlockKeys.type: MentionType.externalLink.name,+ MentionBlockKeys.url: url,+ },+ },+ );+ final transaction = editorState.transaction;+ transaction+ ..insertNode(node.path, paragraphNode(delta: delta))+ ..deleteNode(node);+ transaction.afterSelection = Selection.collapsed(+ Position(+ path: node.path,+ offset: url.length,+ ),+ );+ return editorState.apply(transaction);+}++Future<void> removeUrlPreviewLink(+ EditorState editorState,+ Node node,+) async {+ if (node.type != LinkPreviewBlockKeys.type) {+ return;+ }++ final url = node.attributes[LinkPreviewBlockKeys.url];+ final delta = Delta()..insert(url);+ final transaction = editorState.transaction;+ transaction+ ..insertNode(node.path, paragraphNode(delta: delta))+ ..deleteNode(node);+ transaction.afterSelection = Selection.collapsed(+ Position(+ path: node.path,+ offset: url.length,+ ),+ );+ return editorState.apply(transaction);+}++Future<void> convertUrlToLinkPreview(+ EditorState editorState,+ Selection selection,+ String url, {+ String? previewType,+}) async {+ final node = editorState.getNodeAtPath(selection.end.path);+ if (node == null) {+ return;+ }+ final delta = node.delta;+ if (delta == null) return;+ final List<TextInsert> beforeOperations = [], afterOperations = [];+ int index = 0;+ for (final insert in delta.whereType<TextInsert>()) {+ if (index < selection.startIndex) {+ beforeOperations.add(insert);+ } else if (index >= selection.endIndex) {+ afterOperations.add(insert);+ }+ index += insert.length;+ }+ final transaction = editorState.transaction;+ transaction+ ..deleteNode(node)+ ..insertNodes(node.path.next, [+ if (beforeOperations.isNotEmpty)+ paragraphNode(delta: Delta(operations: beforeOperations)),+ if (previewType == LinkEmbedKeys.embed)+ linkEmbedNode(url: url)+ else+ linkPreviewNode(url: url),+ if (afterOperations.isNotEmpty)+ paragraphNode(delta: Delta(operations: afterOperations)),+ ]);+ await editorState.apply(transaction);+}++Future<void> convertUrlToMention(+ EditorState editorState,+ Selection selection,+) async {+ final node = editorState.getNodeAtPath(selection.end.path);+ if (node == null) {+ return;+ }+ final delta = node.delta;+ if (delta == null) return;+ String url = '';+ int index = 0;+ for (final insert in delta.whereType<TextInsert>()) {+ if (index >= selection.startIndex && index < selection.endIndex) {+ final href = insert.attributes?.href ?? '';+ if (href.isNotEmpty) {+ url = href;+ break;+ }+ }+ index += insert.length;+ }+ final transaction = editorState.transaction;+ transaction.replaceText(+ node,+ selection.startIndex,+ selection.length,+ MentionBlockKeys.mentionChar,+ attributes: {+ MentionBlockKeys.mention: {+ MentionBlockKeys.type: MentionType.externalLink.name,+ MentionBlockKeys.url: url,+ },+ },+ );+ await editorState.apply(transaction);+}++Future<void> convertLinkBlockToOtherLinkBlock(+ EditorState editorState,+ Node node,+ String toType, {+ String? url,+}) async {+ final nodeType = node.type;+ if (nodeType != LinkPreviewBlockKeys.type ||+ (nodeType == toType && url == null)) {+ return;+ }+ final insertedNode = <Node>[];++ final afterUrl = url ?? node.attributes[LinkPreviewBlockKeys.url] ?? '';+ final previewType = node.attributes[LinkEmbedKeys.previewType];+ Node afterNode = node.copyWith(+ type: toType,+ attributes: {+ LinkPreviewBlockKeys.url: afterUrl,+ LinkEmbedKeys.previewType: previewType,+ blockComponentBackgroundColor:+ node.attributes[blockComponentBackgroundColor],+ blockComponentTextDirection: node.attributes[blockComponentTextDirection],+ blockComponentDelta: (node.delta ?? Delta()).toJson(),+ },+ );+ afterNode = afterNode.copyWith(children: []);+ insertedNode.add(afterNode);+ insertedNode.addAll(node.children.map((e) => e.deepCopy()));+ final transaction = editorState.transaction;+ transaction.insertNodes(+ node.path,+ insertedNode,+ );+ transaction.deleteNodes([node]);+ await editorState.apply(transaction);+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_block.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_block.dartindex 79c9b31d20..0060d65bb7 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_block.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_block.dart@@ -6,14 +6,18 @@ import 'package:collection/collection.dart';import 'package:flutter/material.dart';import 'package:provider/provider.dart';+import 'mention_link_block.dart';+enum MentionType {page,date,+ externalLink,childPage;static MentionType fromString(String value) => switch (value) {'page' => page,'date' => date,+ 'externalLink' => externalLink,'childPage' => childPage,// Backwards compatibility'reminder' => date,@@ -47,6 +51,7 @@ class MentionBlockKeys {static const pageId = 'page_id';static const blockId = 'block_id';+ static const url = 'url';// Related to Reminder and Date blocksstatic const date = 'date'; // Start Date@@ -157,6 +162,17 @@ class MentionBlock extends StatelessWidget {reminderOption: reminderOption ?? ReminderOption.none,includeTime: mention[MentionBlockKeys.includeTime] ?? false,);+ case MentionType.externalLink:+ final String? url = mention[MentionBlockKeys.url] as String?;+ if (url == null) {+ return const SizedBox.shrink();+ }+ return MentionLinkBlock(+ url: url,+ editorState: editorState,+ node: node,+ index: index,+ );}}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_block.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_block.dartnew file mode 100644index 0000000000..7a807fef64--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_block.dart@@ -0,0 +1,337 @@+import 'dart:async';+import 'dart:math';+import 'package:appflowy/core/helpers/url_launcher.dart';+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_hover_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_embed/link_embed_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/shared.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flowy_infra_ui/style_widget/hover.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++import 'mention_link_error_preview.dart';+import 'mention_link_preview.dart';++class MentionLinkBlock extends StatefulWidget {+ const MentionLinkBlock({+ super.key,+ required this.url,+ required this.editorState,+ required this.node,+ required this.index,+ this.delayToShow = const Duration(milliseconds: 50),+ this.delayToHide = const Duration(milliseconds: 300),+ });++ final String url;+ final Duration delayToShow;+ final Duration delayToHide;+ final EditorState editorState;+ final Node node;+ final int index;++ @override+ State<MentionLinkBlock> createState() => _MentionLinkBlockState();+}++class _MentionLinkBlockState extends State<MentionLinkBlock> {+ final parser = LinkParser();+ _LoadingStatus status = _LoadingStatus.loading;+ final previewController = PopoverController();+ LinkInfo linkInfo = LinkInfo();+ bool isHovering = false;+ int previewFocusNum = 0;+ bool isPreviewHovering = false;+ bool showAtBottom = false;+ final key = GlobalKey();++ bool get isPreviewShowing => previewFocusNum > 0;+ String get url => widget.url;++ EditorState get editorState => widget.editorState;++ Node get node => widget.node;++ int get index => widget.index;++ bool get readyForPreview =>+ status == _LoadingStatus.idle && !linkInfo.isEmpty();++ @override+ void initState() {+ super.initState();++ parser.addLinkInfoListener((v) {+ if (mounted) {+ setState(() {+ if (v.isEmpty() && linkInfo.isEmpty()) {+ status = _LoadingStatus.error;+ } else {+ linkInfo = v;+ status = _LoadingStatus.idle;+ }+ });+ }+ });+ parser.start(url);+ }++ @override+ void dispose() {+ super.dispose();+ parser.dispose();+ previewController.close();+ }++ @override+ Widget build(BuildContext context) {+ return AppFlowyPopover(+ key: ValueKey(showAtBottom),+ controller: previewController,+ direction: showAtBottom+ ? PopoverDirection.bottomWithLeftAligned+ : PopoverDirection.topWithLeftAligned,+ offset: Offset(0, showAtBottom ? -20 : 20),+ onOpen: () {+ keepEditorFocusNotifier.increase();+ previewFocusNum++;+ },+ onClose: () {+ keepEditorFocusNotifier.decrease();+ previewFocusNum--;+ },+ decorationColor: Colors.transparent,+ popoverDecoration: BoxDecoration(),+ margin: EdgeInsets.zero,+ constraints: getConstraints(),+ borderRadius: BorderRadius.circular(16),+ popupBuilder: (context) => readyForPreview+ ? MentionLinkPreview(+ linkInfo: linkInfo,+ showAtBottom: showAtBottom,+ triggerSize: getSizeFromKey(),+ onEnter: (e) {+ isPreviewHovering = true;+ },+ onExit: (e) {+ isPreviewHovering = false;+ tryToDismissPreview();+ },+ onCopyLink: () => copyLink(context),+ onConvertTo: (s) => convertTo(s),+ onRemoveLink: removeLink,+ onOpenLink: openLink,+ )+ : MentionLinkErrorPreview(+ url: url,+ triggerSize: getSizeFromKey(),+ onEnter: (e) {+ isPreviewHovering = true;+ },+ onExit: (e) {+ isPreviewHovering = false;+ tryToDismissPreview();+ },+ onCopyLink: () => copyLink(context),+ onConvertTo: (s) => convertTo(s),+ onRemoveLink: removeLink,+ onOpenLink: openLink,+ ),+ child: buildIconWithTitle(context),+ );+ }++ Widget buildIconWithTitle(BuildContext context) {+ final theme = AppFlowyTheme.of(context);++ return MouseRegion(+ cursor: SystemMouseCursors.click,+ onEnter: onEnter,+ onExit: onExit,+ child: GestureDetector(+ onTap: () async {+ await afLaunchUrlString(url, addingHttpSchemeWhenFailed: true);+ },+ child: FlowyHoverContainer(+ style:+ HoverStyle(hoverColor: Theme.of(context).colorScheme.secondary),+ applyStyle: isHovering,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ key: key,+ children: [+ HSpace(2),+ buildIcon(),+ HSpace(4),+ Flexible(+ child: FlowyText(+ linkInfo.siteName ?? url,+ color: theme.textColorScheme.primary,+ fontSize: 14,+ figmaLineHeight: 20,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ HSpace(2),+ ],+ ),+ ),+ ),+ );+ }++ Widget buildIcon() {+ const defaultWidget = FlowySvg(FlowySvgs.toolbar_link_earth_m);+ Widget icon = defaultWidget;+ if (status == _LoadingStatus.loading) {+ icon = Padding(+ padding: const EdgeInsets.all(2.0),+ child: const CircularProgressIndicator(strokeWidth: 1),+ );+ } else {+ icon = linkInfo.buildIconWidget();+ }+ return SizedBox(+ height: 20,+ width: 20,+ child: icon,+ );+ }++ RenderBox? get box => key.currentContext?.findRenderObject() as RenderBox?;++ Size getSizeFromKey() => box?.size ?? Size.zero;++ Future<void> copyLink(BuildContext context) async {+ await context.copyLink(url);+ previewController.close();+ }++ Future<void> openLink() async {+ await afLaunchUrlString(url, addingHttpSchemeWhenFailed: true);+ }++ Future<void> removeLink() async {+ final transaction = editorState.transaction+ ..replaceText(widget.node, widget.index, 1, url, attributes: {});+ await editorState.apply(transaction);+ }++ Future<void> convertTo(PasteMenuType type) async {+ if (type == PasteMenuType.url) {+ await toUrl();+ } else if (type == PasteMenuType.bookmark) {+ await toLinkPreview();+ } else if (type == PasteMenuType.embed) {+ await toLinkPreview(previewType: LinkEmbedKeys.embed);+ }+ }++ Future<void> toUrl() async {+ final transaction = editorState.transaction+ ..replaceText(+ widget.node,+ widget.index,+ 1,+ url,+ attributes: {+ AppFlowyRichTextKeys.href: url,+ },+ );+ await editorState.apply(transaction);+ }++ Future<void> toLinkPreview({String? previewType}) async {+ final selection = Selection(+ start: Position(path: node.path, offset: index),+ end: Position(path: node.path, offset: index + 1),+ );+ await convertUrlToLinkPreview(+ editorState,+ selection,+ url,+ previewType: previewType,+ );+ }++ void changeHovering(bool hovering) {+ if (isHovering == hovering) return;+ if (mounted) {+ setState(() {+ isHovering = hovering;+ });+ }+ }++ void changeShowAtBottom(bool bottom) {+ if (showAtBottom == bottom) return;+ if (mounted) {+ setState(() {+ showAtBottom = bottom;+ });+ }+ }++ void tryToDismissPreview() {+ Future.delayed(widget.delayToHide, () {+ if (isHovering || isPreviewHovering) {+ return;+ }+ previewController.close();+ });+ }++ void onEnter(PointerEnterEvent e) {+ changeHovering(true);+ final location = box?.localToGlobal(Offset.zero) ?? Offset.zero;+ if (readyForPreview) {+ if (location.dy < 300) {+ changeShowAtBottom(true);+ } else {+ changeShowAtBottom(false);+ }+ }+ Future.delayed(widget.delayToShow, () {+ if (isHovering && !isPreviewShowing && status != _LoadingStatus.loading) {+ showPreview();+ }+ });+ }++ void onExit(PointerExitEvent e) {+ changeHovering(false);+ tryToDismissPreview();+ }++ void showPreview() {+ if (!mounted) return;+ keepEditorFocusNotifier.increase();+ previewController.show();+ previewFocusNum++;+ }++ BoxConstraints getConstraints() {+ final size = getSizeFromKey();+ if (!readyForPreview) {+ return BoxConstraints(+ maxWidth: max(320, size.width),+ maxHeight: 48 + size.height,+ );+ }+ return BoxConstraints(+ maxWidth: max(300, size.width),+ maxHeight: 300,+ );+ }+}++enum _LoadingStatus {+ loading,+ idle,+ error,+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_error_preview.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_error_preview.dartnew file mode 100644index 0000000000..df396108e4--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_error_preview.dart@@ -0,0 +1,232 @@+import 'dart:math';++import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';+import 'package:appflowy/util/theme_extension.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++class MentionLinkErrorPreview extends StatefulWidget {+ const MentionLinkErrorPreview({+ super.key,+ required this.url,+ required this.onEnter,+ required this.onExit,+ required this.onCopyLink,+ required this.onRemoveLink,+ required this.onConvertTo,+ required this.onOpenLink,+ required this.triggerSize,+ });++ final String url;+ final PointerEnterEventListener onEnter;+ final PointerExitEventListener onExit;+ final VoidCallback onCopyLink;+ final VoidCallback onRemoveLink;+ final VoidCallback onOpenLink;+ final ValueChanged<PasteMenuType> onConvertTo;+ final Size triggerSize;++ @override+ State<MentionLinkErrorPreview> createState() =>+ _MentionLinkErrorPreviewState();+}++class _MentionLinkErrorPreviewState extends State<MentionLinkErrorPreview> {+ final menuController = PopoverController();+ bool isConvertButtonSelected = false;++ @override+ void dispose() {+ super.dispose();+ menuController.close();+ }++ @override+ Widget build(BuildContext context) {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ MouseRegion(+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: SizedBox(+ width: max(320, widget.triggerSize.width),+ height: 48,+ child: Align(+ alignment: Alignment.centerLeft,+ child: Container(+ width: 320,+ height: 48,+ decoration: buildToolbarLinkDecoration(context),+ padding: EdgeInsets.fromLTRB(12, 8, 8, 8),+ child: Row(+ children: [+ Expanded(child: buildLinkWidget()),+ Container(+ height: 20,+ width: 1,+ color: Color(0xffE8ECF3)+ .withAlpha(Theme.of(context).isLightMode ? 255 : 40),+ margin: EdgeInsets.symmetric(horizontal: 6),+ ),+ FlowyIconButton(+ icon: FlowySvg(FlowySvgs.toolbar_link_m),+ tooltipText: LocaleKeys.editor_copyLink.tr(),+ preferBelow: false,+ width: 36,+ height: 32,+ onPressed: widget.onCopyLink,+ ),+ buildConvertButton(),+ ],+ ),+ ),+ ),+ ),+ ),+ MouseRegion(+ cursor: SystemMouseCursors.click,+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: GestureDetector(+ onTap: widget.onOpenLink,+ child: Container(+ width: widget.triggerSize.width,+ height: widget.triggerSize.height,+ color: Colors.black.withAlpha(1),+ ),+ ),+ ),+ ],+ );+ }++ Widget buildLinkWidget() {+ final url = widget.url;+ return FlowyTooltip(+ message: url,+ preferBelow: false,+ child: FlowyText.regular(+ url,+ overflow: TextOverflow.ellipsis,+ figmaLineHeight: 20,+ fontSize: 14,+ ),+ );+ }++ Widget buildConvertButton() {+ return AppFlowyPopover(+ offset: Offset(8, 10),+ direction: PopoverDirection.bottomWithRightAligned,+ margin: EdgeInsets.zero,+ controller: menuController,+ onOpen: () => keepEditorFocusNotifier.increase(),+ onClose: () => keepEditorFocusNotifier.decrease(),+ popupBuilder: (context) => buildConvertMenu(),+ child: FlowyIconButton(+ icon: FlowySvg(FlowySvgs.turninto_m),+ isSelected: isConvertButtonSelected,+ tooltipText: LocaleKeys.editor_convertTo.tr(),+ preferBelow: false,+ width: 36,+ height: 32,+ onPressed: () {+ setState(() {+ isConvertButtonSelected = true;+ });+ showPopover();+ },+ ),+ );+ }++ Widget buildConvertMenu() {+ return MouseRegion(+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children: List.generate(MentionLinktErrorMenuCommand.values.length,+ (index) {+ final command = MentionLinktErrorMenuCommand.values[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () => onTap(command),+ ),+ );+ }),+ ),+ ),+ );+ }++ void showPopover() {+ keepEditorFocusNotifier.increase();+ menuController.show();+ }++ void closePopover() {+ menuController.close();+ }++ void onTap(MentionLinktErrorMenuCommand command) {+ switch (command) {+ case MentionLinktErrorMenuCommand.toURL:+ widget.onConvertTo(PasteMenuType.url);+ break;+ case MentionLinktErrorMenuCommand.toBookmark:+ widget.onConvertTo(PasteMenuType.bookmark);+ break;+ case MentionLinktErrorMenuCommand.toEmbed:+ widget.onConvertTo(PasteMenuType.embed);+ break;+ case MentionLinktErrorMenuCommand.removeLink:+ widget.onRemoveLink();+ break;+ }+ closePopover();+ }+}++enum MentionLinktErrorMenuCommand {+ toURL,+ toBookmark,+ toEmbed,+ removeLink;++ String get title {+ switch (this) {+ case toURL:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toUrl+ .tr();+ case toBookmark:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_toBookmark+ .tr();+ case toEmbed:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toEmbed+ .tr();+ case removeLink:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_removeLink+ .tr();+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_preview.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_preview.dartnew file mode 100644index 0000000000..00082f127a--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_link_preview.dart@@ -0,0 +1,271 @@+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_create_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_parser.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/paste_as/paste_as_menu.dart';+import 'package:appflowy/plugins/document/presentation/editor_style.dart';+import 'package:appflowy/shared/appflowy_network_image.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++class MentionLinkPreview extends StatefulWidget {+ const MentionLinkPreview({+ super.key,+ required this.linkInfo,+ required this.onEnter,+ required this.onExit,+ required this.onCopyLink,+ required this.onRemoveLink,+ required this.onConvertTo,+ required this.onOpenLink,+ required this.triggerSize,+ required this.showAtBottom,+ });++ final LinkInfo linkInfo;+ final PointerEnterEventListener onEnter;+ final PointerExitEventListener onExit;+ final VoidCallback onCopyLink;+ final VoidCallback onRemoveLink;+ final VoidCallback onOpenLink;+ final ValueChanged<PasteMenuType> onConvertTo;+ final Size triggerSize;+ final bool showAtBottom;++ @override+ State<MentionLinkPreview> createState() => _MentionLinkPreviewState();+}++class _MentionLinkPreviewState extends State<MentionLinkPreview> {+ final menuController = PopoverController();+ bool isSelected = false;++ LinkInfo get linkInfo => widget.linkInfo;++ @override+ void dispose() {+ super.dispose();+ menuController.close();+ }++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context),+ textColorScheme = theme.textColorScheme;++ final card = MouseRegion(+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: Container(+ decoration: buildToolbarLinkDecoration(context, radius: 16),+ width: 280,+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ ClipRRect(+ borderRadius:+ const BorderRadius.vertical(top: Radius.circular(16)),+ child: FlowyNetworkImage(+ url: linkInfo.imageUrl ?? '',+ width: 280,+ height: 120,+ ),+ ),+ VSpace(12),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: FlowyText.semibold(+ linkInfo.siteName ?? '',+ fontSize: 14,+ figmaLineHeight: 20,+ color: textColorScheme.primary,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ VSpace(4),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: FlowyText(+ linkInfo.description ?? '',+ fontSize: 12,+ figmaLineHeight: 16,+ color: textColorScheme.secondary,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ VSpace(36),+ Container(+ margin: const EdgeInsets.symmetric(horizontal: 16),+ height: 28,+ child: Row(+ children: [+ linkInfo.buildIconWidget(size: Size.square(16)),+ HSpace(6),+ Expanded(+ child: FlowyText(+ linkInfo.description ?? '',+ fontSize: 12,+ figmaLineHeight: 16,+ color: textColorScheme.primary,+ overflow: TextOverflow.ellipsis,+ fontWeight: FontWeight.w700,+ ),+ ),+ buildMoreOptionButton(),+ ],+ ),+ ),+ VSpace(12),+ ],+ ),+ ),+ );++ final clickPlaceHolder = MouseRegion(+ cursor: SystemMouseCursors.click,+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: GestureDetector(+ child: Container(+ height: 20,+ width: widget.triggerSize.width,+ color: Colors.white.withAlpha(1),+ ),+ onTap: () {+ widget.onOpenLink.call();+ closePopover();+ },+ ),+ );+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: widget.showAtBottom+ ? [clickPlaceHolder, card]+ : [card, clickPlaceHolder],+ );+ }++ Widget buildMoreOptionButton() {+ return AppFlowyPopover(+ controller: menuController,+ direction: PopoverDirection.topWithLeftAligned,+ onOpen: () => keepEditorFocusNotifier.increase(),+ onClose: () => keepEditorFocusNotifier.decrease(),+ margin: EdgeInsets.zero,+ borderRadius: BorderRadius.circular(12),+ popupBuilder: (context) => buildConvertMenu(),+ child: FlowyIconButton(+ width: 28,+ height: 28,+ isSelected: isSelected,+ hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),+ icon: FlowySvg(+ FlowySvgs.toolbar_more_m,+ size: Size.square(20),+ ),+ onPressed: () {+ setState(() {+ isSelected = true;+ });+ showPopover();+ },+ ),+ );+ }++ Widget buildConvertMenu() {+ return MouseRegion(+ onEnter: widget.onEnter,+ onExit: widget.onExit,+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: SeparatedColumn(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const VSpace(0.0),+ children:+ List.generate(MentionLinktMenuCommand.values.length, (index) {+ final command = MentionLinktMenuCommand.values[index];+ return SizedBox(+ height: 36,+ child: FlowyButton(+ text: FlowyText(+ command.title,+ fontWeight: FontWeight.w400,+ figmaLineHeight: 20,+ ),+ onTap: () => onTap(command),+ ),+ );+ }),+ ),+ ),+ );+ }++ void showPopover() {+ keepEditorFocusNotifier.increase();+ menuController.show();+ }++ void closePopover() {+ menuController.close();+ }++ void onTap(MentionLinktMenuCommand command) {+ switch (command) {+ case MentionLinktMenuCommand.toURL:+ widget.onConvertTo(PasteMenuType.url);+ break;+ case MentionLinktMenuCommand.toBookmark:+ widget.onConvertTo(PasteMenuType.bookmark);+ break;+ case MentionLinktMenuCommand.toEmbed:+ widget.onConvertTo(PasteMenuType.embed);+ break;+ case MentionLinktMenuCommand.copyLink:+ widget.onCopyLink();+ break;+ case MentionLinktMenuCommand.removeLink:+ widget.onRemoveLink();+ break;+ }+ closePopover();+ }+}++enum MentionLinktMenuCommand {+ toURL,+ toBookmark,+ toEmbed,+ copyLink,+ removeLink;++ String get title {+ switch (this) {+ case toURL:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toUrl+ .tr();+ case toBookmark:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_toBookmark+ .tr();+ case toEmbed:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_toEmbed+ .tr();+ case copyLink:+ return LocaleKeys.document_plugins_linkPreview_linkPreviewMenu_copyLink+ .tr();+ case removeLink:+ return LocaleKeys+ .document_plugins_linkPreview_linkPreviewMenu_removeLink+ .tr();+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/menu/menu_extension.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/menu/menu_extension.dartnew file mode 100644index 0000000000..7dcd21f423--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/menu/menu_extension.dart@@ -0,0 +1,116 @@+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/material.dart';++extension MenuExtension on EditorState {+ MenuPosition? calculateMenuOffset({+ Rect? rect,+ required double menuWidth,+ required double menuHeight,+ Offset menuOffset = const Offset(0, 10),+ }) {+ final selectionService = service.selectionService;+ final selectionRects = selectionService.selectionRects;+ late Rect startRect;+ if (rect != null) {+ startRect = rect;+ } else {+ if (selectionRects.isEmpty) return null;+ startRect = selectionRects.first;+ }++ final editorOffset = renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;+ final editorHeight = renderBox!.size.height;+ final editorWidth = renderBox!.size.width;++ // show below default+ Alignment alignment = Alignment.topLeft;+ final bottomRight = startRect.bottomRight;+ final topRight = startRect.topRight;+ var startOffset = bottomRight + menuOffset;+ Offset offset = Offset(+ startOffset.dx,+ startOffset.dy,+ );++ // show above+ if (startOffset.dy + menuHeight >= editorOffset.dy + editorHeight) {+ startOffset = topRight - menuOffset;+ alignment = Alignment.bottomLeft;++ offset = Offset(+ startOffset.dx,+ editorHeight + editorOffset.dy - startOffset.dy,+ );+ }++ // show on right+ if (offset.dx + menuWidth < editorOffset.dx + editorWidth) {+ offset = Offset(+ offset.dx,+ offset.dy,+ );+ } else if (startOffset.dx - editorOffset.dx > menuWidth) {+ // show on left+ alignment = alignment == Alignment.topLeft+ ? Alignment.topRight+ : Alignment.bottomRight;++ offset = Offset(+ editorWidth - offset.dx + editorOffset.dx,+ offset.dy,+ );+ }+ return MenuPosition(align: alignment, offset: offset);+ }+}++class MenuPosition {+ MenuPosition({+ required this.align,+ required this.offset,+ });++ final Alignment align;+ final Offset offset;++ LTRB get ltrb {+ double? left, top, right, bottom;+ switch (align) {+ case Alignment.topLeft:+ left = offset.dx;+ top = offset.dy;+ break;+ case Alignment.bottomLeft:+ left = offset.dx;+ bottom = offset.dy;+ break;+ case Alignment.topRight:+ right = offset.dx;+ top = offset.dy;+ break;+ case Alignment.bottomRight:+ right = offset.dx;+ bottom = offset.dy;+ break;+ }++ return LTRB(left: left, top: top, right: right, bottom: bottom);+ }+}++class LTRB {+ LTRB({this.left, this.top, this.right, this.bottom});++ final double? left;+ final double? top;+ final double? right;+ final double? bottom;++ Positioned buildPositioned({required Widget child}) => Positioned(+ left: left,+ top: top,+ right: right,+ bottom: bottom,+ child: child,+ );+}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.dartindex 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@overrideWidget 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.dartindex 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 = <Widget>[];final textInserts = delta.whereType<TextInsert>();int index = 0;diff --git a/frontend/appflowy_flutter/lib/plugins/emoji/emoji_handler.dart b/frontend/appflowy_flutter/lib/plugins/emoji/emoji_handler.dartindex 26769ba7d3..3ab578b961 100644--- a/frontend/appflowy_flutter/lib/plugins/emoji/emoji_handler.dart+++ b/frontend/appflowy_flutter/lib/plugins/emoji/emoji_handler.dart@@ -299,7 +299,8 @@ class _EmojiHandlerState extends State<EmojiHandler> {.getTextInSelection(selection.copyWith(start: selection.start.copyWith(offset: startOffset),- end: selection.start.copyWith(offset: startOffset + _search.length + 1),+ end: selection.start+ .copyWith(offset: startOffset + _search.length + 1),),).join();diff --git a/frontend/appflowy_flutter/lib/startup/tasks/app_widget.dart b/frontend/appflowy_flutter/lib/startup/tasks/app_widget.dartindex ed4c4d1623..0ef21267aa 100644--- a/frontend/appflowy_flutter/lib/startup/tasks/app_widget.dart+++ b/frontend/appflowy_flutter/lib/startup/tasks/app_widget.dart@@ -225,12 +225,20 @@ class _ApplicationWidgetState extends State<ApplicationWidget> {Tooltip.dismissAllToolTips();}},- child: AppFlowyTheme(- data: Theme.of(context).brightness == Brightness.light- ? AppFlowyThemeData.light()- : AppFlowyThemeData.dark(),- child: MaterialApp.router(- builder: (context, child) => MediaQuery(+ child: MaterialApp.router(+ debugShowCheckedModeBanner: false,+ theme: state.lightTheme,+ darkTheme: state.darkTheme,+ themeMode: state.themeMode,+ localizationsDelegates: context.localizationDelegates,+ supportedLocales: context.supportedLocales,+ locale: state.locale,+ routerConfig: routerConfig,+ builder: (context, child) => AppFlowyTheme(+ data: Theme.of(context).brightness == Brightness.light+ ? AppFlowyThemeData.light()+ : AppFlowyThemeData.dark(),+ child: MediaQuery(// use the 1.0 as the textScaleFactor to avoid the text size// affected by the system setting.data: MediaQuery.of(context).copyWith(@@ -246,14 +254,6 @@ class _ApplicationWidgetState extends State<ApplicationWidget> {: child,),),- debugShowCheckedModeBanner: false,- theme: state.lightTheme,- darkTheme: state.darkTheme,- themeMode: state.themeMode,- localizationsDelegates: context.localizationDelegates,- supportedLocales: context.supportedLocales,- locale: state.locale,- routerConfig: routerConfig,),),),diff --git a/frontend/appflowy_flutter/lib/util/default_extensions.dart b/frontend/appflowy_flutter/lib/util/default_extensions.dartindex 36bbdcb6b4..603a66d6cf 100644--- a/frontend/appflowy_flutter/lib/util/default_extensions.dart+++ b/frontend/appflowy_flutter/lib/util/default_extensions.dart@@ -13,3 +13,11 @@ const List<String> defaultImageExtensions = ['webp','bmp',];++bool isNotImageUrl(String url) {+ final nonImageSuffixRegex = RegExp(+ r'(\.(io|html|php|json|txt|js|css|xml|md|log)(\?.*)?(#.*)?$)|/$',+ caseSensitive: false,+ );+ return nonImageSuffixRegex.hasMatch(url);+}diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/builder.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/builder.dartindex d48c061c71..ed7e9aec29 100644--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/builder.dart+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/builder.dart@@ -151,7 +151,7 @@ class AppFlowyThemeBuilder {Brightness brightness,) {return switch (brightness) {- Brightness.light => AppFlowyFillColorScheme(+ Brightness.dark => AppFlowyFillColorScheme(primary: colorScheme.neutral.neutral100,primaryHover: colorScheme.neutral.neutral200,secondary: colorScheme.neutral.neutral300,@@ -196,7 +196,7 @@ class AppFlowyThemeBuilder {purpleThick: colorScheme.purple.purple500,purpleThickHover: colorScheme.purple.purple600,),- Brightness.dark => AppFlowyFillColorScheme(+ Brightness.light => AppFlowyFillColorScheme(primary: colorScheme.neutral.neutral1000,primaryHover: colorScheme.neutral.neutral900,secondary: colorScheme.neutral.neutral600,diff --git a/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension_v2.dart b/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension_v2.dartindex 7fac9e07d0..b9136a00bc 100644--- a/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension_v2.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra/lib/theme_extension_v2.dart@@ -13,6 +13,7 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {const AFThemeExtensionV2({required this.icon_primary,required this.icon_tertiary,+ required this.text_tertiary,required this.border_grey_quaternary,required this.fill_theme_select,required this.fill_grey_thick_alpha_1,@@ -21,6 +22,7 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {final Color icon_primary;final Color icon_tertiary;+ final Color text_tertiary;final Color border_grey_quaternary;final Color fill_theme_select;final Color fill_grey_thick_alpha_1;@@ -30,6 +32,7 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {AFThemeExtensionV2 copyWith({Color? icon_primary,Color? icon_tertiary,+ Color? text_tertiary,Color? border_grey_quaternary,Color? fill_theme_select,Color? fill_grey_thick_alpha_1,@@ -38,6 +41,7 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {AFThemeExtensionV2(icon_primary: icon_primary ?? this.icon_primary,icon_tertiary: icon_tertiary ?? this.icon_tertiary,+ text_tertiary: text_tertiary ?? this.text_tertiary,border_grey_quaternary:border_grey_quaternary ?? this.border_grey_quaternary,fill_theme_select: fill_theme_select ?? this.fill_theme_select,@@ -57,6 +61,8 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {Color.lerp(icon_primary, other.icon_primary, t) ?? icon_primary,icon_tertiary:Color.lerp(icon_tertiary, other.icon_tertiary, t) ?? icon_tertiary,+ text_tertiary:+ Color.lerp(text_tertiary, other.text_tertiary, t) ?? text_tertiary,border_grey_quaternary:Color.lerp(border_grey_quaternary, other.border_grey_quaternary, t) ??border_grey_quaternary,@@ -75,6 +81,7 @@ class AFThemeExtensionV2 extends ThemeExtension<AFThemeExtensionV2> {const AFThemeExtensionV2 darkAFThemeV2 = AFThemeExtensionV2(icon_primary: Color(0xFF1F2329),icon_tertiary: Color(0xFF99A1A8),+ text_tertiary: Color(0xFFB5BBD3),border_grey_quaternary: Color(0xFFE8ECF3),fill_theme_select: Color(0x00BCF01F),fill_grey_thick_alpha_1: Color(0x1F23290F),@@ -84,6 +91,7 @@ const AFThemeExtensionV2 darkAFThemeV2 = AFThemeExtensionV2(const AFThemeExtensionV2 lightAFThemeV2 = AFThemeExtensionV2(icon_primary: Color(0xFF1F2329),icon_tertiary: Color(0xFF99A1A8),+ text_tertiary: Color(0xFFB5BBD3),border_grey_quaternary: Color(0xFFE8ECF3),fill_theme_select: Color(0x00BCF01F),fill_grey_thick_alpha_1: Color(0x1F23290F),diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/widget/flowy_tooltip.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/widget/flowy_tooltip.dartindex 8813cad09e..5b0b791c6c 100644--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/widget/flowy_tooltip.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/widget/flowy_tooltip.dart@@ -89,7 +89,6 @@ class _ManualTooltipState extends State<ManualTooltip> {super.initState();}-@overrideWidget build(BuildContext context) {return Tooltip(diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 1c6d66431d..ae44b95eb3 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -673,6 +673,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.3.1"+ favicon:+ dependency: "direct main"+ description:+ name: favicon+ sha256: ebb7423ba7ccc87d3cce9b60de1b5f72004de3cddeedd88d98463fc7f66faf0c+ url: "https://pub.dev"+ source: hosted+ version: "1.1.2"ffi:dependency: transitivedescription:diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex 0cc553d1a7..de26c31c1e 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -31,6 +31,7 @@ dependencies:auto_size_text_field: ^2.2.3auto_updater: ^1.0.0avatar_stack: ^3.0.0+ favicon: ^1.1.2# BitsDojo Window for Windowsbitsdojo_window: ^0.1.6diff --git a/frontend/resources/flowy_icons/20x/embed_fullscreen.svg b/frontend/resources/flowy_icons/20x/embed_fullscreen.svgnew file mode 100644index 0000000000..b8b197fb13--- /dev/null+++ b/frontend/resources/flowy_icons/20x/embed_fullscreen.svg@@ -0,0 +1,3 @@+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M8.36379 11.6362L4 16M4 16H7.65133M4 16V12.3487M11.6362 8.36379L16 4M16 4H12.3487M16 4V7.65133" stroke="#B5BBD3" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/frontend/resources/flowy_icons/20x/turninto.svg b/frontend/resources/flowy_icons/20x/turninto.svgnew file mode 100644index 0000000000..598b870ec7--- /dev/null+++ b/frontend/resources/flowy_icons/20x/turninto.svg@@ -0,0 +1,3 @@+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M4 12H16L13 15M16 8L4 8L7 5" stroke="#21232A" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/frontend/resources/flowy_icons/40x/embed_error.svg b/frontend/resources/flowy_icons/40x/embed_error.svgnew file mode 100644index 0000000000..68196c7b7e--- /dev/null+++ b/frontend/resources/flowy_icons/40x/embed_error.svg@@ -0,0 +1,7 @@+<svg width="64" height="64" fill="none" xmlns="http://www.w3.org/2000/svg">+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18 8a4 4 0 0 0-4 4v40a4 4 0 0 0 4 4h28a4 4 0 0 0 4-4V20L38 8H18Z" fill="#fff"/>+ <rect x="24" y="24" width="3" height="6" rx="1.5" fill="#D3D8E1"/>+ <rect x="37" y="24" width="3" height="6" rx="1.5" fill="#D3D8E1"/>+ <path d="m38 8 12 12H40a2 2 0 0 1-2-2V8Z" fill="#D3D8E1"/>+ <path fill-rule="evenodd" clip-rule="evenodd" d="M38 40a6 6 0 0 0-12 0h12Z" fill="#D3D8E1"/>+</svg>diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex e42660436c..29473d2e00 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -2019,7 +2019,28 @@"failedDuplicateFindView": "Failed to duplicate page - original view not found"}},- "cannotMoveToItsChildren": "Cannot move to its children"+ "cannotMoveToItsChildren": "Cannot move to its children",+ "linkPreview": {+ "typeSelection": {+ "pasteAs": "Paste as",+ "mention": "Mention",+ "URL": "URL",+ "bookmark": "Bookmark",+ "embed": "Embed"+ },+ "linkPreviewMenu": {+ "toMetion": "Convert to Mention",+ "toUrl": "Convert to URL",+ "toEmbed": "Convert to Embed",+ "toBookmark": "Convert to Bookmark",+ "copyLink": "Copy Link",+ "replace": "Replace",+ "reload": "Reload",+ "removeLink": "Remove Link",+ "pasteHint": "Paste in https://...",+ "refuseConnect": "refued to connect."+ }+ }},"outlineBlock": {"placeholder": "Table of Contents"@@ -2513,6 +2534,7 @@"copyLink": "Copy link","removeLink": "Remove link","editLink": "Edit link",+ "convertTo": "Convert to","linkText": "Text","linkTextHint": "Please enter text","linkAddressHint": "Please enter URL",