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: improve the link menu in read-only mode (#8048)
Morn734bb25c0a3d
diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/toolbar/view_database_button.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/toolbar/view_database_button.dartindex 93493e599f..035321d72f 100644--- a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/toolbar/view_database_button.dart+++ b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/toolbar/view_database_button.dart@@ -18,7 +18,7 @@ class ViewDatabaseButton extends StatelessWidget {return MouseRegion(cursor: SystemMouseCursors.click,child: FlowyIconButton(- tooltipText: LocaleKeys.grid_rowPage_openAsFullPage.tr(),+ tooltipText: LocaleKeys.grid_rowPage_viewDatabase.tr(),width: 24,height: 24,iconPadding: const EdgeInsets.all(3),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 04b9d8ceee..7dd1bee160 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@@ -145,6 +145,7 @@ class _LinkHoverTriggerState extends State<LinkHoverTrigger> {popupBuilder: (context) => LinkHoverMenu(attribute: widget.attribute,triggerSize: size,+ editable: editorState.editable,onEnter: (_) {isHoverMenuHovering = true;},@@ -302,6 +303,7 @@ class LinkHoverMenu extends StatefulWidget {required this.attribute,required this.onEnter,required this.onExit,+ required this.editable,required this.triggerSize,required this.onCopyLink,required this.onOpenLink,@@ -318,6 +320,7 @@ class LinkHoverMenu extends StatefulWidget {final VoidCallback onOpenLink;final VoidCallback onEditLink;final VoidCallback onRemoveLink;+ final bool editable;final ValueChanged<LinkConvertMenuCommand> onConvertTo;@override@@ -331,6 +334,8 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {final popoverController = PopoverController();bool isConvertButtonSelected = false;+ bool get editable => widget.editable;+@overridevoid initState() {super.initState();@@ -382,19 +387,21 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {FlowyIconButton(icon: FlowySvg(FlowySvgs.toolbar_link_edit_m),tooltipText: LocaleKeys.editor_editLink.tr(),+ hoverColor: hoverColor,preferBelow: false,width: 36,height: 32,- onPressed: widget.onEditLink,+ onPressed: getTapCallback(widget.onEditLink),),buildConvertButton(),FlowyIconButton(icon: FlowySvg(FlowySvgs.toolbar_link_unlink_m),tooltipText: LocaleKeys.editor_removeLink.tr(),+ hoverColor: hoverColor,preferBelow: false,width: 36,height: 32,- onPressed: widget.onRemoveLink,+ onPressed: getTapCallback(widget.onRemoveLink),),],),@@ -460,6 +467,22 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {}Widget buildConvertButton() {+ final button = FlowyIconButton(+ icon: FlowySvg(FlowySvgs.turninto_m),+ isSelected: isConvertButtonSelected,+ tooltipText: LocaleKeys.editor_convertTo.tr(),+ preferBelow: false,+ hoverColor: hoverColor,+ width: 36,+ height: 32,+ onPressed: getTapCallback(() {+ setState(() {+ isConvertButtonSelected = true;+ });+ showConvertMenu();+ }),+ );+ if (!editable) return button;return AppFlowyPopover(offset: Offset(44, 10.0),direction: PopoverDirection.bottomWithRightAligned,@@ -468,20 +491,7 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {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();- },- ),+ child: button,);}@@ -517,6 +527,13 @@ class _LinkHoverMenuState extends State<LinkHoverMenu> {);}+ Color? get hoverColor => editable ? null : Colors.transparent;++ VoidCallback? getTapCallback(VoidCallback callback) {+ if (editable) return callback;+ return null;+ }+void showConvertMenu() {keepEditorFocusNotifier.increase();popoverController.show();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.dartindex f2015e3aa3..1a5a6c02d7 100644--- 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.dart@@ -45,6 +45,7 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {Node get node => widget.node;EditorState get editorState => widget.editorState;+ bool get editable => editorState.editable;String get url => node.attributes[LinkPreviewBlockKeys.url] ?? '';@@ -103,6 +104,17 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {Widget buildConvertButton() {final theme = AppFlowyTheme.of(context), iconScheme = theme.iconColorScheme;+ final button = FlowyIconButton(+ icon: FlowySvg(+ FlowySvgs.turninto_m,+ color: iconScheme.tertiary,+ ),+ radius: BorderRadius.all(Radius.circular(theme.borderRadius.m)),+ tooltipText: LocaleKeys.editor_convertTo.tr(),+ preferBelow: false,+ onPressed: getTapCallback(showTurnIntoMenu),+ );+ if (!editable) return button;return AppFlowyPopover(offset: Offset(0, 6),direction: PopoverDirection.bottomWithRightAligned,@@ -118,16 +130,7 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {checkToHideMenu();},popupBuilder: (context) => buildConvertMenu(),- child: FlowyIconButton(- icon: FlowySvg(- FlowySvgs.turninto_m,- color: iconScheme.tertiary,- ),- radius: BorderRadius.all(Radius.circular(theme.borderRadius.m)),- tooltipText: LocaleKeys.editor_convertTo.tr(),- preferBelow: false,- onPressed: showTurnIntoMenu,- ),+ child: button,);}@@ -171,6 +174,18 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {Widget buildMoreOptionButton() {final theme = AppFlowyTheme.of(context), iconScheme = theme.iconColorScheme;+ final button = FlowyIconButton(+ key: moreOptionButtonKey,+ icon: FlowySvg(+ FlowySvgs.toolbar_more_m,+ color: iconScheme.tertiary,+ ),+ radius: BorderRadius.all(Radius.circular(theme.borderRadius.m)),+ tooltipText: LocaleKeys.document_toolbar_moreOptions.tr(),+ preferBelow: false,+ onPressed: getTapCallback(showMoreOptionMenu),+ );+ if (!editable) return button;return AppFlowyPopover(offset: Offset(0, 6),direction: PopoverDirection.bottomWithRightAligned,@@ -186,17 +201,7 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {checkToHideMenu();},popupBuilder: (context) => buildMoreOptionMenu(),- child: FlowyIconButton(- key: moreOptionButtonKey,- icon: FlowySvg(- FlowySvgs.toolbar_more_m,- color: iconScheme.tertiary,- ),- radius: BorderRadius.all(Radius.circular(theme.borderRadius.m)),- tooltipText: LocaleKeys.document_toolbar_moreOptions.tr(),- preferBelow: false,- onPressed: showMoreOptionMenu,- ),+ child: button,);}@@ -306,6 +311,11 @@ class _LinkEmbedMenuState extends State<LinkEmbedMenu> {}closeMoreOptionMenu();}++ VoidCallback? getTapCallback(VoidCallback callback) {+ if (editable) return callback;+ return null;+ }}enum LinkEmbedMenuCommand {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 2fb493dda3..1997bb23b7 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@@ -74,6 +74,8 @@ class _CustomLinkPreviewMenuState extends State<CustomLinkPreviewMenu> {}Widget buildMenu() {+ final editorState = context.read<EditorState>(),+ editable = editorState.editable;return MouseRegion(child: Padding(padding: const EdgeInsets.all(8.0),@@ -83,15 +85,18 @@ class _CustomLinkPreviewMenuState extends State<CustomLinkPreviewMenu> {children:List.generate(LinkPreviewMenuCommand.values.length, (index) {final command = LinkPreviewMenuCommand.values[index];+ final isCopyCommand = command == LinkPreviewMenuCommand.copyLink;+ final enableButton = editable || (!editable && isCopyCommand);return SizedBox(height: 36,child: FlowyButton(+ hoverColor: enableButton ? null : Colors.transparent,text: FlowyText(command.title,fontWeight: FontWeight.w400,figmaLineHeight: 20,),- onTap: () => onTap(command),+ onTap: enableButton ? () => onTap(command) : null,),);}),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.dartindex 8bc59d28ef..0570f3fbbc 100644--- 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.dart@@ -56,6 +56,8 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {EditorState get editorState => widget.editorState;+ bool get editable => editorState.editable;+Node get node => widget.node;int get index => widget.index;@@ -119,6 +121,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {popupBuilder: (context) => readyForPreview? MentionLinkPreview(linkInfo: linkInfo,+ editable: editable,showAtBottom: showAtBottom,triggerSize: getSizeFromKey(),onEnter: (e) {@@ -135,6 +138,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {): MentionLinkErrorPreview(url: url,+ editable: editable,triggerSize: getSizeFromKey(),onEnter: (e) {isPreviewHovering = true;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.dartindex df396108e4..592caebb79 100644--- 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.dart@@ -22,6 +22,7 @@ class MentionLinkErrorPreview extends StatefulWidget {required this.onConvertTo,required this.onOpenLink,required this.triggerSize,+ required this.editable,});final String url;@@ -32,6 +33,7 @@ class MentionLinkErrorPreview extends StatefulWidget {final VoidCallback onOpenLink;final ValueChanged<PasteMenuType> onConvertTo;final Size triggerSize;+ final bool editable;@overrideState<MentionLinkErrorPreview> createState() =>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.dartindex 00b161379e..fb2c63b38e 100644--- 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.dart@@ -24,6 +24,7 @@ class MentionLinkPreview extends StatefulWidget {required this.onOpenLink,required this.triggerSize,required this.showAtBottom,+ required this.editable,});final LinkInfo linkInfo;@@ -35,6 +36,7 @@ class MentionLinkPreview extends StatefulWidget {final ValueChanged<PasteMenuType> onConvertTo;final Size triggerSize;final bool showAtBottom;+ final bool editable;@overrideState<MentionLinkPreview> createState() => _MentionLinkPreviewState();@@ -46,6 +48,8 @@ class _MentionLinkPreviewState extends State<MentionLinkPreview> {LinkInfo get linkInfo => widget.linkInfo;+ bool get editable => widget.editable;+@overridevoid dispose() {super.dispose();@@ -197,15 +201,18 @@ class _MentionLinkPreviewState extends State<MentionLinkPreview> {children:List.generate(MentionLinktMenuCommand.values.length, (index) {final command = MentionLinktMenuCommand.values[index];+ final isCopyCommand = command == MentionLinktMenuCommand.copyLink;+ final enableButton = editable || (!editable && isCopyCommand);return SizedBox(height: 36,child: FlowyButton(+ hoverColor: enableButton ? null : Colors.transparent,text: FlowyText(command.title,fontWeight: FontWeight.w400,figmaLineHeight: 20,),- onTap: () => onTap(command),+ onTap: enableButton ? () => onTap(command) : null,),);}),diff --git a/frontend/resources/translations/en-US.json b/frontend/resources/translations/en-US.jsonindex 2ae8cdf044..4e84a97f34 100644--- a/frontend/resources/translations/en-US.json+++ b/frontend/resources/translations/en-US.json@@ -1649,6 +1649,7 @@"other": "Hide {count} hidden fields"},"openAsFullPage": "Open as full page",+ "viewDatabase": "View the original Database","moreRowActions": "More row actions"},"sort": {