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: some launch review issues (#7566)
Morn69571f668c6e
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_option_action_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_option_action_test.dartindex d19dee8b6d..6ec12287a8 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_option_action_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_option_action_test.dart@@ -76,9 +76,9 @@ void main() {LocaleKeys.document_slashMenu_name_heading1.tr(): HeadingBlockKeys.type,LocaleKeys.document_slashMenu_name_heading2.tr(): HeadingBlockKeys.type,LocaleKeys.document_slashMenu_name_heading3.tr(): HeadingBlockKeys.type,- LocaleKeys.document_slashMenu_name_bulletedList.tr():+ LocaleKeys.editor_bulletedListShortForm.tr():BulletedListBlockKeys.type,- LocaleKeys.document_slashMenu_name_numberedList.tr():+ LocaleKeys.editor_numberedListShortForm.tr():NumberedListBlockKeys.type,LocaleKeys.document_slashMenu_name_quote.tr(): QuoteBlockKeys.type,LocaleKeys.editor_checkbox.tr(): TodoListBlockKeys.type,@@ -116,9 +116,9 @@ void main() {LocaleKeys.document_slashMenu_name_heading1.tr(): HeadingBlockKeys.type,LocaleKeys.document_slashMenu_name_heading2.tr(): HeadingBlockKeys.type,LocaleKeys.document_slashMenu_name_heading3.tr(): HeadingBlockKeys.type,- LocaleKeys.document_slashMenu_name_bulletedList.tr():+ LocaleKeys.editor_bulletedListShortForm.tr():BulletedListBlockKeys.type,- LocaleKeys.document_slashMenu_name_numberedList.tr():+ LocaleKeys.editor_numberedListShortForm.tr():NumberedListBlockKeys.type,LocaleKeys.document_slashMenu_name_quote.tr(): QuoteBlockKeys.type,LocaleKeys.editor_checkbox.tr(): TodoListBlockKeys.type,diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_math_equation_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_math_equation_test.dartindex 523319abf5..67e0149cd1 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_math_equation_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_math_equation_test.dart@@ -106,11 +106,6 @@ void main() {);await tester.tapButton(moreOptionButton);- // expect to the see the inline math equation button is highlighted- expect(- find.byFlowySvg(FlowySvgs.toolbar_check_m),- findsOneWidget,- );// cancel the formatawait tester.tapButton(inlineMathEquationButton);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dartindex 289b299de1..09685aef5c 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart@@ -22,7 +22,6 @@ import 'package:appflowy/workspace/presentation/home/af_focus_manager.dart';import 'package:appflowy_editor/appflowy_editor.dart' hide QuoteBlockKeys;import 'package:collection/collection.dart';import 'package:flowy_infra/theme_extension.dart';-import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -440,8 +439,9 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>toolbarElevation: 10,),items: toolbarItems,- decoration: context.getPopoverDecoration(- borderRadius: BorderRadius.circular(6),+ decoration: ShapeDecoration(+ color: Theme.of(context).cardColor,+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),),toolbarBuilder: (context, child) => DesktopFloatingToolbar(editorState: editorState,diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dartindex 8c2f99cdd5..35e92d7170 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart@@ -265,6 +265,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {EditorState editorState, {int? level,String? currentViewId,+ bool keepSelection = false,}) async {final selection = editorState.selection;if (selection == null) {@@ -289,6 +290,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {selectedNodes: selectedNodes,level: level,editorState: editorState,+ afterSelection: keepSelection ? selection : null,)) {return true;}@@ -347,6 +349,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {insertedNode,);transaction.deleteNodes(selectedNodes);+ if (keepSelection) transaction.afterSelection = selection;await editorState.apply(transaction);return true;diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/turn_into_option_action.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/turn_into_option_action.dartindex aa519b7265..ffb238303e 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/turn_into_option_action.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/turn_into_option_action.dart@@ -274,40 +274,40 @@ class _TurnInfoButton extends StatelessWidget {FlowySvgData _buildLeftIcon(String type, {int? level}) {if (type == ParagraphBlockKeys.type) {- return FlowySvgs.slash_menu_icon_text_s;+ return FlowySvgs.type_text_m;} else if (type == HeadingBlockKeys.type) {switch (level) {case 1:- return FlowySvgs.slash_menu_icon_h1_s;+ return FlowySvgs.type_h1_m;case 2:- return FlowySvgs.slash_menu_icon_h2_s;+ return FlowySvgs.type_h2_m;case 3:- return FlowySvgs.slash_menu_icon_h3_s;+ return FlowySvgs.type_h3_m;default:- return FlowySvgs.slash_menu_icon_text_s;+ return FlowySvgs.type_text_m;}} else if (type == QuoteBlockKeys.type) {- return FlowySvgs.slash_menu_icon_quote_s;+ return FlowySvgs.type_quote_m;} else if (type == BulletedListBlockKeys.type) {- return FlowySvgs.slash_menu_icon_bulleted_list_s;+ return FlowySvgs.type_bulleted_list_m;} else if (type == NumberedListBlockKeys.type) {- return FlowySvgs.slash_menu_icon_numbered_list_s;+ return FlowySvgs.type_numbered_list_m;} else if (type == TodoListBlockKeys.type) {- return FlowySvgs.slash_menu_icon_checkbox_s;+ return FlowySvgs.type_todo_m;} else if (type == CalloutBlockKeys.type) {- return FlowySvgs.slash_menu_icon_callout_s;+ return FlowySvgs.type_callout_m;} else if (type == SubPageBlockKeys.type) {return FlowySvgs.icon_document_s;} else if (type == ToggleListBlockKeys.type) {switch (level) {case 1:- return FlowySvgs.toggle_heading1_s;+ return FlowySvgs.type_toggle_h1_m;case 2:- return FlowySvgs.toggle_heading2_s;+ return FlowySvgs.type_toggle_h2_m;case 3:- return FlowySvgs.toggle_heading3_s;+ return FlowySvgs.type_toggle_h3_m;default:- return FlowySvgs.slash_menu_icon_toggle_s;+ return FlowySvgs.type_toggle_list_m;}}@@ -335,9 +335,9 @@ class _TurnInfoButton extends StatelessWidget {case QuoteBlockKeys.type:return LocaleKeys.document_slashMenu_name_quote.tr();case BulletedListBlockKeys.type:- return LocaleKeys.document_slashMenu_name_bulletedList.tr();+ return LocaleKeys.editor_bulletedListShortForm.tr();case NumberedListBlockKeys.type:- return LocaleKeys.document_slashMenu_name_numberedList.tr();+ return LocaleKeys.editor_numberedListShortForm.tr();case TodoListBlockKeys.type:return LocaleKeys.editor_checkbox.tr();case CalloutBlockKeys.type:@@ -347,13 +347,13 @@ class _TurnInfoButton extends StatelessWidget {case ToggleListBlockKeys.type:switch (level) {case 1:- return LocaleKeys.document_slashMenu_name_toggleHeading1.tr();+ return LocaleKeys.editor_toggleHeading1ShortForm.tr();case 2:- return LocaleKeys.document_slashMenu_name_toggleHeading2.tr();+ return LocaleKeys.editor_toggleHeading2ShortForm.tr();case 3:- return LocaleKeys.document_slashMenu_name_toggleHeading3.tr();+ return LocaleKeys.editor_toggleHeading3ShortForm.tr();default:- return LocaleKeys.document_slashMenu_name_toggleList.tr();+ return LocaleKeys.editor_toggleListShortForm.tr();}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_toolbar_item.dartindex 1e17a0b321..dc20f2363f 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_toolbar_item.dart@@ -61,7 +61,7 @@ class _AiWriterToolbarActionListState extends State<AiWriterToolbarActionList> {return AppFlowyPopover(controller: popoverController,direction: PopoverDirection.bottomWithLeftAligned,- offset: const Offset(-8.0, 2.0),+ offset: const Offset(0, 2.0),onOpen: () => keepEditorFocusNotifier.increase(),onClose: () {setState(() {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/color_picker.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/color_picker.dartnew file mode 100644index 0000000000..162c7a1c34--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/color_picker.dart@@ -0,0 +1,330 @@+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+// ignore: implementation_imports+import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';+import 'package:flutter/material.dart';++class ColorPicker extends StatefulWidget {+ const ColorPicker({+ super.key,+ required this.title,+ required this.selectedColorHex,+ required this.onSubmittedColorHex,+ required this.colorOptions,+ this.resetText,+ this.customColorHex,+ this.resetIconName,+ this.showClearButton = false,+ });++ final String title;+ final String? selectedColorHex;+ final String? customColorHex;+ final void Function(String? color, bool isCustomColor) onSubmittedColorHex;+ final String? resetText;+ final String? resetIconName;+ final bool showClearButton;++ final List<ColorOption> colorOptions;++ @override+ State<ColorPicker> createState() => _ColorPickerState();+}++class _ColorPickerState extends State<ColorPicker> {+ final TextEditingController _colorHexController = TextEditingController();+ final TextEditingController _colorOpacityController = TextEditingController();++ @override+ void initState() {+ super.initState();+ final selectedColorHex = widget.selectedColorHex,+ customColorHex = widget.customColorHex;+ _colorHexController.text =+ _extractColorHex(customColorHex ?? selectedColorHex) ?? 'FFFFFF';+ _colorOpacityController.text =+ _convertHexToOpacity(customColorHex ?? selectedColorHex) ?? '100';+ }++ @override+ Widget build(BuildContext context) {+ return basicOverlay(+ context,+ width: 300,+ height: 250,+ children: [+ EditorOverlayTitle(text: widget.title),+ const SizedBox(height: 6),+ widget.showClearButton &&+ widget.resetText != null &&+ widget.resetIconName != null+ ? ResetColorButton(+ resetText: widget.resetText!,+ resetIconName: widget.resetIconName!,+ onPressed: (color) =>+ widget.onSubmittedColorHex.call(color, false),+ )+ : const SizedBox.shrink(),+ CustomColorItem(+ colorController: _colorHexController,+ opacityController: _colorOpacityController,+ onSubmittedColorHex: (color) =>+ widget.onSubmittedColorHex.call(color, true),+ ),+ _buildColorItems(+ widget.colorOptions,+ widget.selectedColorHex,+ ),+ ],+ );+ }++ Widget _buildColorItems(+ List<ColorOption> options,+ String? selectedColor,+ ) {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: options+ .map((e) => _buildColorItem(e, e.colorHex == selectedColor))+ .toList(),+ );+ }++ Widget _buildColorItem(ColorOption option, bool isChecked) {+ return SizedBox(+ height: 36,+ child: TextButton.icon(+ onPressed: () {+ widget.onSubmittedColorHex(option.colorHex, false);+ },+ icon: SizedBox.square(+ dimension: 12,+ child: Container(+ decoration: BoxDecoration(+ color: option.colorHex.tryToColor(),+ shape: BoxShape.circle,+ ),+ ),+ ),+ style: buildOverlayButtonStyle(context),+ label: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Expanded(+ child: Text(+ option.name,+ softWrap: false,+ maxLines: 1,+ overflow: TextOverflow.fade,+ style: TextStyle(+ color: Theme.of(context).textTheme.labelLarge?.color,+ ),+ ),+ ),+ // checkbox+ if (isChecked) const FlowySvg(FlowySvgs.toolbar_check_m),+ ],+ ),+ ),+ );+ }++ String? _convertHexToOpacity(String? colorHex) {+ if (colorHex == null) return null;+ final opacityHex = colorHex.substring(2, 4);+ final opacity = int.parse(opacityHex, radix: 16) / 2.55;+ return opacity.toStringAsFixed(0);+ }++ String? _extractColorHex(String? colorHex) {+ if (colorHex == null) return null;+ return colorHex.substring(4);+ }+}++class ResetColorButton extends StatelessWidget {+ const ResetColorButton({+ super.key,+ required this.resetText,+ required this.resetIconName,+ required this.onPressed,+ });++ final Function(String? color) onPressed;+ final String resetText;+ final String resetIconName;++ @override+ Widget build(BuildContext context) {+ return SizedBox(+ width: double.infinity,+ height: 32,+ child: TextButton.icon(+ onPressed: () => onPressed(null),+ icon: EditorSvg(+ name: resetIconName,+ width: 13,+ height: 13,+ color: Theme.of(context).iconTheme.color,+ ),+ label: Text(+ resetText,+ style: TextStyle(+ color: Theme.of(context).hintColor,+ ),+ textAlign: TextAlign.left,+ ),+ style: ButtonStyle(+ backgroundColor: WidgetStateProperty.resolveWith<Color>(+ (Set<WidgetState> states) {+ if (states.contains(WidgetState.hovered)) {+ return Theme.of(context).hoverColor;+ }+ return Colors.transparent;+ },+ ),+ alignment: Alignment.centerLeft,+ ),+ ),+ );+ }+}++class CustomColorItem extends StatefulWidget {+ const CustomColorItem({+ super.key,+ required this.colorController,+ required this.opacityController,+ required this.onSubmittedColorHex,+ });++ final TextEditingController colorController;+ final TextEditingController opacityController;+ final void Function(String color) onSubmittedColorHex;++ @override+ State<CustomColorItem> createState() => _CustomColorItemState();+}++class _CustomColorItemState extends State<CustomColorItem> {+ @override+ Widget build(BuildContext context) {+ return ExpansionTile(+ tilePadding: const EdgeInsets.only(left: 8),+ shape: Border.all(+ color: Colors.transparent,+ ), // remove the default border when it is expanded+ title: Row(+ children: [+ // color sample box+ SizedBox.square(+ dimension: 12,+ child: Container(+ decoration: BoxDecoration(+ color: Color(+ int.tryParse(+ _combineColorHexAndOpacity(+ widget.colorController.text,+ widget.opacityController.text,+ ),+ ) ??+ 0xFFFFFFFF,+ ),+ shape: BoxShape.circle,+ ),+ ),+ ),+ const SizedBox(width: 8),+ Expanded(+ child: Text(+ AppFlowyEditorL10n.current.customColor,+ style: Theme.of(context).textTheme.labelLarge,+ // same style as TextButton.icon+ ),+ ),+ ],+ ),+ children: [+ const SizedBox(height: 6),+ _customColorDetailsTextField(+ labelText: AppFlowyEditorL10n.current.hexValue,+ controller: widget.colorController,+ // update the color sample box when the text changes+ onChanged: (_) => setState(() {}),+ onSubmitted: _submitCustomColorHex,+ ),+ const SizedBox(height: 10),+ _customColorDetailsTextField(+ labelText: AppFlowyEditorL10n.current.opacity,+ controller: widget.opacityController,+ // update the color sample box when the text changes+ onChanged: (_) => setState(() {}),+ onSubmitted: _submitCustomColorHex,+ ),+ const SizedBox(height: 6),+ ],+ );+ }++ Widget _customColorDetailsTextField({+ required String labelText,+ required TextEditingController controller,+ Function(String)? onChanged,+ Function(String)? onSubmitted,+ }) {+ return Padding(+ padding: const EdgeInsets.only(right: 3),+ child: TextField(+ controller: controller,+ decoration: InputDecoration(+ labelText: labelText,+ border: OutlineInputBorder(+ borderSide: BorderSide(+ color: Theme.of(context).colorScheme.outline,+ ),+ ),+ ),+ style: Theme.of(context).textTheme.bodyMedium,+ onChanged: onChanged,+ onSubmitted: onSubmitted,+ ),+ );+ }++ String _combineColorHexAndOpacity(String colorHex, String opacity) {+ colorHex = _fixColorHex(colorHex);+ opacity = _fixOpacity(opacity);+ final opacityHex = (int.parse(opacity) * 2.55).round().toRadixString(16);+ return '0x$opacityHex$colorHex';+ }++ String _fixColorHex(String colorHex) {+ if (colorHex.length > 6) {+ colorHex = colorHex.substring(0, 6);+ }+ if (int.tryParse(colorHex, radix: 16) == null) {+ colorHex = 'FFFFFF';+ }+ return colorHex;+ }++ String _fixOpacity(String opacity) {+ // if opacity is 0 - 99, return it+ // otherwise return 100+ final RegExp regex = RegExp('^(0|[1-9][0-9]?)');+ if (regex.hasMatch(opacity)) {+ return opacity;+ } else {+ return '100';+ }+ }++ void _submitCustomColorHex(String value) {+ final String color = _combineColorHexAndOpacity(+ widget.colorController.text,+ widget.opacityController.text,+ );+ widget.onSubmittedColorHex(color);+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dartindex ee258a002d..4932eb8274 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart@@ -1,8 +1,6 @@import 'package:appflowy_editor/appflowy_editor.dart';import 'package:flutter/material.dart';-import 'toolbar_animation.dart';-class DesktopFloatingToolbar extends StatefulWidget {const DesktopFloatingToolbar({super.key,@@ -41,15 +39,14 @@ class _DesktopFloatingToolbarState extends State<DesktopFloatingToolbar> {left: position!.left,top: position!.top,right: position!.right,- child: ToolbarAnimationWidget(- child: widget.child,- ),+ child: widget.child,);}_Position calculateSelectionMenuOffset(Rect rect,) {+ const toolbarHeight = 40, topLimit = toolbarHeight + 8;final bool isLongMenu = onlyShowInSingleSelectionAndTextType(editorState);final menuWidth = isLongMenu ? 650.0 : 420.0;final editorOffset =@@ -57,7 +54,8 @@ class _DesktopFloatingToolbarState extends State<DesktopFloatingToolbar> {final editorSize = editorState.renderBox?.size ?? Size.zero;final editorRect = editorOffset & editorSize;final left = rect.left, leftStart = 50;- final top = rect.top < 40 ? rect.bottom + 40 : rect.top - 40;+ final top =+ rect.top < topLimit ? rect.bottom + topLimit : rect.top - topLimit;if (left + menuWidth > editorRect.right) {return _Position(editorRect.right - menuWidth,diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_format_toolbar_items.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_format_toolbar_items.dartindex befd97fd52..d020468b37 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_format_toolbar_items.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_format_toolbar_items.dart@@ -1,9 +1,11 @@import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/document/presentation/editor_page.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';import 'package:appflowy_editor/appflowy_editor.dart';// ignore: implementation_importsimport 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/tooltip_util.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/style_widget/icon_button.dart';import 'package:flutter/material.dart';@@ -78,7 +80,10 @@ class _FormatToolbarItem extends ToolbarItem {? Color(0xFF282E3A): Theme.of(context).iconTheme.color,),- onPressed: () => editorState.toggleAttribute(name),+ onPressed: () => editorState.toggleAttribute(+ name,+ selection: selection,+ ),);if (tooltipBuilder != null) {@@ -93,3 +98,46 @@ class _FormatToolbarItem extends ToolbarItem {},);}++String getTooltipText(String id) {+ switch (id) {+ case 'underline':+ return '${LocaleKeys.toolbar_underline.tr()}${shortcutTooltips(+ '⌘ + U',+ 'CTRL + U',+ 'CTRL + U',+ )}';+ case 'bold':+ return '${LocaleKeys.toolbar_bold.tr()}${shortcutTooltips(+ '⌘ + B',+ 'CTRL + B',+ 'CTRL + B',+ )}';+ case 'italic':+ return '${LocaleKeys.toolbar_italic.tr()}${shortcutTooltips(+ '⌘ + I',+ 'CTRL + I',+ 'CTRL + I',+ )}';+ case 'strikethrough':+ return '${LocaleKeys.toolbar_strike.tr()}${shortcutTooltips(+ '⌘ + SHIFT + S',+ 'CTRL + SHIFT + S',+ 'CTRL + SHIFT + S',+ )}';+ case 'code':+ return '${LocaleKeys.document_toolbar_inlineCode.tr()}${shortcutTooltips(+ '⌘ + E',+ 'CTRL + E',+ 'CTRL + E',+ )}';+ case 'align_left':+ return LocaleKeys.document_toolbar_alignLeft.tr();+ case 'align_center':+ return LocaleKeys.document_toolbar_alignCenter.tr();+ case 'align_right':+ return LocaleKeys.document_toolbar_alignRight.tr();+ default:+ return '';+ }+}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 76407482cd..39d216ed9c 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@@ -1,7 +1,8 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/plugins/document/presentation/editor_page.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/color_picker.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';-import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor/appflowy_editor.dart' hide ColorPicker;import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -117,7 +118,7 @@ class _HighlightColorPickerWidgetStatefinal List<String> colors = [];final selection = editorState.selection!;final nodes = editorState.getNodesInSelection(selection);- nodes.allSatisfyInSelection(selection, (delta) {+ final isHighLight = nodes.allSatisfyInSelection(selection, (delta) {if (delta.everyAttributes((attr) => attr.isEmpty)) {return false;}@@ -130,7 +131,7 @@ class _HighlightColorPickerWidgetState});final colorLength = colors.length;- if (colors.isEmpty) {+ if (colors.isEmpty || !isHighLight) {return Container(width: 20,height: 4,@@ -158,7 +159,7 @@ class _HighlightColorPickerWidgetStatefinal selection = editorState.selection!;final nodes = editorState.getNodesInSelection(selection);- nodes.allSatisfyInSelection(selection, (delta) {+ final isHighlight = nodes.allSatisfyInSelection(selection, (delta) {if (delta.everyAttributes((attr) => attr.isEmpty)) {return false;}@@ -186,7 +187,8 @@ class _HighlightColorPickerWidgetStatechild: ColorPicker(title: AppFlowyEditorL10n.current.highlightColor,showClearButton: showClearButton,- selectedColorHex: colors.length == 1 ? colors.first : null,+ selectedColorHex:+ (colors.length == 1 && isHighlight) ? colors.first : null,customColorHex: _customHighlightColorHex,colorOptions: generateHighlightColorOptions(),onSubmittedColorHex: (color, isCustomColor) {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dartindex b531ecc0a2..2253ac7f75 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dart@@ -17,7 +17,7 @@ final ToolbarItem customPlaceholderItem = ToolbarItem(padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 5),child: Container(width: 1,- color: Color(0xffE8ECF3).withAlpha(isDark ? 40 : 100),+ color: Color(0xffE8ECF3).withAlpha(isDark ? 40 : 255),),);},diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_align_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_align_toolbar_item.dartindex 3a5cabe6ee..659f637250 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_align_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_align_toolbar_item.dart@@ -63,7 +63,7 @@ class _TextAlignActionListState extends State<TextAlignActionList> {return AppFlowyPopover(controller: popoverController,direction: PopoverDirection.bottomWithLeftAligned,- offset: const Offset(-8.0, 2.0),+ offset: const Offset(0, 2.0),onOpen: () => keepEditorFocusNotifier.increase(),onClose: () {setState(() {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_color_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_color_toolbar_item.dartindex 37ca253eb7..4b266eaa8e 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_color_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_text_color_toolbar_item.dart@@ -1,7 +1,10 @@import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/document/presentation/editor_page.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/desktop_toolbar/color_picker.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';-import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor/appflowy_editor.dart' hide ColorPicker;+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -114,7 +117,7 @@ class _TextColorPickerWidgetState extends State<TextColorPickerWidget> {final List<String> colors = [];final selection = editorState.selection!;final nodes = editorState.getNodesInSelection(selection);- nodes.allSatisfyInSelection(selection, (delta) {+ final isHighLight = nodes.allSatisfyInSelection(selection, (delta) {if (delta.everyAttributes((attr) => attr.isEmpty)) {return false;}@@ -127,7 +130,7 @@ class _TextColorPickerWidgetState extends State<TextColorPickerWidget> {});final colorLength = colors.length;- if (colors.isEmpty) {+ if (colors.isEmpty || !isHighLight) {return Container(width: 20,height: 4,@@ -155,7 +158,7 @@ class _TextColorPickerWidgetState extends State<TextColorPickerWidget> {final List<String> colors = [];final selection = editorState.selection!;final nodes = editorState.getNodesInSelection(selection);- nodes.allSatisfyInSelection(selection, (delta) {+ final isHighLight = nodes.allSatisfyInSelection(selection, (delta) {if (delta.everyAttributes((attr) => attr.isEmpty)) {return false;}@@ -182,9 +185,10 @@ class _TextColorPickerWidgetState extends State<TextColorPickerWidget> {);return MouseRegion(child: ColorPicker(- title: AppFlowyEditorL10n.current.textColor,+ title: LocaleKeys.document_toolbar_textColor.tr(),showClearButton: showClearButton,- selectedColorHex: colors.length == 1 ? colors.first : null,+ selectedColorHex:+ (colors.length == 1 && isHighLight) ? colors.first : null,customColorHex: _customColorHex,colorOptions: generateTextColorOptions(),onSubmittedColorHex: (color, isCustomColor) {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/more_option_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/more_option_toolbar_item.dartindex 8d92b4a4b3..6ac63254f9 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/more_option_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/more_option_toolbar_item.dart@@ -1,15 +1,16 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_page.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_editor/appflowy_editor.dart';+// ignore: implementation_imports+import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/tooltip_util.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';-import '../../editor_page.dart';-const _kMoreOptionItemId = 'editor.more_option';const kFontToolbarItemId = 'editor.font';@@ -152,8 +153,7 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {Widget buildPopoverContent() {final showFormula = onlyShowInSingleSelectionAndTextType(editorState);- final strikethroughColor = getStrikethroughColor();- final Color? formulaColor = showFormula ? getFormulaColor() : null;+ const fontColor = Color(0xff99A1A8);return MouseRegion(child: SeparatedColumn(mainAxisSize: MainAxisSize.min,@@ -162,16 +162,32 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {buildFontSelector(),buildCommandItem(MoreOptionCommand.strikethrough,- rightIcon: strikethroughColor != null- ? FlowySvg(FlowySvgs.toolbar_check_m)- : null,+ rightIcon: FlowyText(+ shortcutTooltips(+ '⌘⇧S',+ 'CTRL+SHIFT+S',+ 'CTRL+SHIFT+S',+ ).trim(),+ color: fontColor,+ fontSize: 12,+ figmaLineHeight: 16,+ fontWeight: FontWeight.w400,+ ),),if (showFormula)buildCommandItem(MoreOptionCommand.formula,- rightIcon: formulaColor != null- ? FlowySvg(FlowySvgs.toolbar_check_m)- : null,+ rightIcon: FlowyText(+ shortcutTooltips(+ '⌘⇧E',+ 'CTRL+SHIFT+E',+ 'CTRL+SHIFT+E',+ ).trim(),+ color: fontColor,+ fontSize: 12,+ figmaLineHeight: 16,+ fontWeight: FontWeight.w400,+ ),),],),diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_heading_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_heading_toolbar_item.dartindex 4d1ef3d12a..d7be4b23fd 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_heading_toolbar_item.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/text_heading_toolbar_item.dart@@ -58,7 +58,7 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {return AppFlowyPopover(controller: popoverController,direction: PopoverDirection.bottomWithLeftAligned,- offset: const Offset(-8.0, 2.0),+ offset: const Offset(0, 2.0),onOpen: () => keepEditorFocusNotifier.increase(),onClose: () {setState(() {@@ -220,10 +220,7 @@ enum TextHeadingCommand {node,state,level: level,- );- await state.updateSelectionWithReason(- selection,- reason: SelectionUpdateReason.uiEvent,+ keepSelection: true,);}}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 e805689fc8..ffeecdcbbe 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@@ -85,7 +85,7 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {return AppFlowyPopover(controller: popoverController,direction: PopoverDirection.bottomWithLeftAligned,- offset: const Offset(-8.0, 2.0),+ offset: const Offset(0, 2.0),onOpen: () => keepEditorFocusNotifier.increase(),onClose: () {setState(() {@@ -193,6 +193,7 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {}Widget buildItem(SuggestionItem item) {+ final isSelected = item.type == currentSuggestionItem.type;return SizedBox(height: 36,child: FlowyButton(@@ -204,6 +205,7 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {fontWeight: FontWeight.w400,figmaLineHeight: 20,),+ rightIcon: isSelected ? FlowySvg(FlowySvgs.toolbar_check_m) : null,onTap: () {item.onTap(widget.editorState);popoverController.close();@@ -412,10 +414,7 @@ Future<void> _turnInto(EditorState state, String type, {int? level}) async {node,state,level: level,- );- await state.updateSelectionWithReason(- selection,- reason: SelectionUpdateReason.uiEvent,+ keepSelection: true,);}diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex ff09cb537e..1e50ff07ab 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -2105,19 +2105,22 @@},"toolbar": {"resetToDefaultFont": "Reset to default",- "textSize": "Text Size",+ "textSize": "Text size",+ "textColor": "Text color","h1": "Heading 1","h2": "Heading 2","h3": "Heading 3",- "alignLeft": "Align Left",- "alignRight": "Align Right",- "alignCenter": "Align Center",+ "alignLeft": "Align left",+ "alignRight": "Align right",+ "alignCenter": "Align center","link": "Link",- "textAlign": "Text Align",- "moreOptions": "More Options",+ "textAlign": "Text align",+ "moreOptions": "More options","font": "Font",+ "inlineCode": "Inline code",+"suggestions": "Suggestions",- "turnInto": "Turn Into",+ "turnInto": "Turn into","equation": "Equation"},"errorBlock": {