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
fix: link menu issues (#7661)
Mornedd59cf4627b
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_toolbar_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_toolbar_test.dartindex aaecd0ff10..f455cd479d 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_toolbar_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_toolbar_test.dart@@ -184,6 +184,45 @@ void main() {3,);});++ testWidgets('toolbar will not rebuild after click item', (tester) async {+ const text = 'Test rebuilding';+ await prepareForToolbar(tester, text);+ Finder toolbar = find.byType(DesktopFloatingToolbar);+ Element toolbarElement = toolbar.evaluate().first;+ final elementHashcode = toolbarElement.hashCode;+ final boldButton = find.byFlowySvg(FlowySvgs.toolbar_bold_m),+ underlineButton = find.byFlowySvg(FlowySvgs.toolbar_underline_m),+ italicButton = find.byFlowySvg(FlowySvgs.toolbar_inline_italic_m);++ /// tap format buttons+ await tester.tapButton(boldButton);+ await tester.tapButton(underlineButton);+ await tester.tapButton(italicButton);+ toolbar = find.byType(DesktopFloatingToolbar);+ toolbarElement = toolbar.evaluate().first;++ /// check if the toolbar is not rebuilt+ expect(elementHashcode, toolbarElement.hashCode);+ final editorState = tester.editor.getCurrentEditorState();++ /// check text formats+ expect(+ editorState+ .getDeltaAttributeValueInSelection(AppFlowyRichTextKeys.bold),+ true,+ );+ expect(+ editorState+ .getDeltaAttributeValueInSelection(AppFlowyRichTextKeys.italic),+ true,+ );+ expect(+ editorState+ .getDeltaAttributeValueInSelection(AppFlowyRichTextKeys.underline),+ true,+ );+ });});group('document toolbar: link', () {@@ -228,6 +267,7 @@ void main() {expect(toolbar, findsNothing);/// show toolbar again+ await tester.editor.tapLineOfEditorAt(0);await selectText(tester, text);await tester.tapButton(linkButton);diff --git a/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dartindex 491ac9432c..398a3f9657 100644--- a/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart+++ b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart@@ -307,9 +307,11 @@ class EditorOperations {Future<void> openTurnIntoMenu(Path path) async {await hoverAndClickOptionMenuButton(path);await tester.tapButton(- find.findTextInFlowyText(- LocaleKeys.document_plugins_optionAction_turnInto.tr(),- ),+ find+ .findTextInFlowyText(+ LocaleKeys.document_plugins_optionAction_turnInto.tr(),+ )+ .first,);await tester.pumpUntilFound(find.byType(TurnIntoOptionMenu));}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dartindex ee3a852cc1..c2c18e48eb 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart@@ -459,7 +459,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>child: DesktopFloatingToolbar(editorState: editorState,onDismiss: onDismiss,- enableAnimation: false,+ enableAnimation: !isMetricsChanged,child: child,),),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 b07d2949d9..0d71611516 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@@ -221,7 +221,7 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {if (isPage) {final viewId = href.split('/').lastOrNull ?? '';if (viewId.isEmpty) {- await afLaunchUrlString(href);+ await afLaunchUrlString(href, addingHttpSchemeWhenFailed: true);} else {final (view, isInTrash, isDeleted) =await ViewBackendService.getMentionPageStatus(viewId);@@ -230,7 +230,7 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {}}} else {- await afLaunchUrlString(href);+ await afLaunchUrlString(href, addingHttpSchemeWhenFailed: true);}}@@ -486,8 +486,7 @@ class LinkHoverTriggers {void call(HoverTriggerKey key) {final callbacks = _map[key] ?? {};- for (final callback in callbacks) {- callback.call();- }+ if (callbacks.isEmpty) return;+ callbacks.first.call();}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_styles.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_styles.dartindex f29583c9b4..cabc00a312 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_styles.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_styles.dart@@ -9,7 +9,7 @@ class LinkStyle {static const textPrimary = Color(0xFF1F2329);static Color borderColor(BuildContext context) =>- Theme.of(context).isLightMode ? Color(0xFFE8ECF3) : Color(0xffbdbdbd);+ Theme.of(context).isLightMode ? Color(0xFFE8ECF3) : Color(0x64BDBDBD);static InputDecoration buildLinkTextFieldInputDecoration(String hintText,@@ -18,9 +18,7 @@ class LinkStyle {}) {final border = OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(8.0)),- borderSide: BorderSide(- color: borderColor(context),- ),+ borderSide: BorderSide(color: borderColor(context)),);final enableBorder = border.copyWith(borderSide: BorderSide(diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_suggestions_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_suggestions_toolbar_item.dartindex c7f3b513f3..a0aded3f8e 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_suggestions_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_suggestions_toolbar_item.dart@@ -84,12 +84,14 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {void initState() {super.initState();refreshSuggestions();+ editorState.selectionNotifier.addListener(refreshSuggestions);}@overridevoid dispose() {- super.dispose();+ editorState.selectionNotifier.removeListener(refreshSuggestions);popoverController.close();+ super.dispose();}@override@@ -290,6 +292,7 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {}currentSuggestionItem =suggestions.where((item) => item.type == suggestionType).first;+ if (mounted) setState(() {});}}diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 1e156a4530..5c8beaaed8 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -98,8 +98,8 @@ packages:dependency: "direct main"description:path: "."- ref: "5ad9d77"- resolved-ref: "5ad9d771a8496dea95a9c5b1ec77f76df3983037"+ ref: d5c9f64+ resolved-ref: d5c9f64ebe23642f8c0e12282816992da8b8180aurl: "https://github.com/AppFlowy-IO/appflowy-editor.git"source: gitversion: "5.1.0"diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex f623932a16..59871276b8 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -184,7 +184,7 @@ dependency_overrides:appflowy_editor:git:url: https://github.com/AppFlowy-IO/appflowy-editor.git- ref: "5ad9d77"+ ref: "d5c9f64"appflowy_editor_plugins:git: