Skip to content

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.

fix: toolbar launch review issues (#7532)

Morn6dd83675fc6d
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.dart
index cbc634cf02..d19dee8b6d 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
@@ -81,8 +81,7 @@ void main() {
LocaleKeys.document_slashMenu_name_numberedList.tr():
NumberedListBlockKeys.type,
LocaleKeys.document_slashMenu_name_quote.tr(): QuoteBlockKeys.type,
- LocaleKeys.document_slashMenu_name_todoList.tr():
- TodoListBlockKeys.type,
+ LocaleKeys.editor_checkbox.tr(): TodoListBlockKeys.type,
LocaleKeys.document_slashMenu_name_callout.tr(): CalloutBlockKeys.type,
LocaleKeys.document_slashMenu_name_text.tr(): ParagraphBlockKeys.type,
};
@@ -122,8 +121,7 @@ void main() {
LocaleKeys.document_slashMenu_name_numberedList.tr():
NumberedListBlockKeys.type,
LocaleKeys.document_slashMenu_name_quote.tr(): QuoteBlockKeys.type,
- LocaleKeys.document_slashMenu_name_todoList.tr():
- TodoListBlockKeys.type,
+ LocaleKeys.editor_checkbox.tr(): TodoListBlockKeys.type,
LocaleKeys.document_slashMenu_name_callout.tr(): CalloutBlockKeys.type,
LocaleKeys.document_slashMenu_name_text.tr(): ParagraphBlockKeys.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.dart
index c29de9f72f..523319abf5 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
@@ -42,7 +42,7 @@ void main() {
// tap the inline math equation button
final inlineMathEquationButton = find.text(
- LocaleKeys.editor_mathEquationShortForm.tr(),
+ LocaleKeys.document_toolbar_equation.tr(),
);
await tester.tapButton(inlineMathEquationButton);
@@ -108,8 +108,8 @@ void main() {
await tester.tapButton(moreOptionButton);
// expect to the see the inline math equation button is highlighted
expect(
- tester.widget<FlowySvg>(inlineMathEquationButton).color != null,
- isTrue,
+ find.byFlowySvg(FlowySvgs.toolbar_check_m),
+ findsOneWidget,
);
// cancel the format
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
index 4ed434cfa1..289b299de1 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
@@ -28,9 +28,11 @@ import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:universal_platform/universal_platform.dart';
+import 'editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart';
import 'editor_plugins/toolbar_item/custom_format_toolbar_items.dart';
import 'editor_plugins/toolbar_item/custom_hightlight_color_toolbar_item.dart';
import 'editor_plugins/toolbar_item/custom_link_toolbar_item.dart';
+import 'editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dart';
import 'editor_plugins/toolbar_item/custom_text_align_toolbar_item.dart';
import 'editor_plugins/toolbar_item/custom_text_color_toolbar_item.dart';
import 'editor_plugins/toolbar_item/more_option_toolbar_item.dart';
@@ -93,14 +95,22 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>
final List<ToolbarItem> toolbarItems = [
improveWritingItem,
+ group0PaddingItem,
aiWriterItem,
customTextHeadingItem,
+ buildPaddingPlaceholderItem(
+ 1,
+ isActive: onlyShowInSingleTextTypeSelectionAndExcludeTable,
+ ),
...customMarkdownFormatItems,
+ group1PaddingItem,
customTextColorItem,
+ group1PaddingItem,
customHighlightColorItem,
customInlineCodeItem,
suggestionsItem,
customLinkItem,
+ group4PaddingItem,
customTextAlignItem,
moreOptionItem,
];
@@ -426,12 +436,18 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>
padding: EdgeInsets.symmetric(horizontal: 6),
style: FloatingToolbarStyle(
backgroundColor: Theme.of(context).cardColor,
+ toolbarActiveColor: Color(0xffe0f8fd),
toolbarElevation: 10,
),
items: toolbarItems,
decoration: context.getPopoverDecoration(
borderRadius: BorderRadius.circular(6),
),
+ toolbarBuilder: (context, child) => DesktopFloatingToolbar(
+ editorState: editorState,
+ child: child,
+ ),
+ placeHolderBuilder: (_) => customPlaceholderItem,
editorState: editorState,
editorScrollController: editorScrollController,
textDirection: textDirection,
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.dart
index f3074781b4..8c2f99cdd5 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
@@ -259,9 +259,10 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
emit(BlockActionOptionState()); // Emit a new state to trigger UI update
}
- Future<bool> turnIntoBlock(
+ static Future<bool> turnIntoBlock(
String type,
- Node node, {
+ Node node,
+ EditorState editorState, {
int? level,
String? currentViewId,
}) async {
@@ -287,6 +288,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
type: toType,
selectedNodes: selectedNodes,
level: level,
+ editorState: editorState,
)) {
return true;
}
@@ -298,6 +300,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
selectedNodes: selectedNodes,
selection: selection,
currentViewId: currentViewId,
+ editorState: editorState,
)) {
return true;
}
@@ -353,7 +356,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
///
/// Returns the altered [Node] with the delta as the Views' name.
///
- Future<Node> _handleSubPageNode(Node node, Node subPageNode) async {
+ static Future<Node> _handleSubPageNode(Node node, Node subPageNode) async {
if (subPageNode.type != SubPageBlockKeys.type) {
return node;
}
@@ -370,7 +373,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
/// Returns the [Delta] from a SubPage [Node], where the
/// [Delta] is the views' name.
///
- Future<Delta?> _deltaFromSubPageNode(Node node) async {
+ static Future<Delta?> _deltaFromSubPageNode(Node node) async {
if (node.type != SubPageBlockKeys.type) {
return null;
}
@@ -400,9 +403,10 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
// - paragraph 1
// - paragraph 2
// when turning "Toggle Heading 1" into toggle heading, the bulleted items will be moved into the toggle heading
- Future<bool> turnIntoSingleToggleHeading({
+ static Future<bool> turnIntoSingleToggleHeading({
required String type,
required List<Node> selectedNodes,
+ required EditorState editorState,
int? level,
Delta? delta,
Selection? afterSelection,
@@ -492,11 +496,12 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return true;
}
- Future<bool> turnIntoPage({
+ static Future<bool> turnIntoPage({
required String type,
required List<Node> selectedNodes,
required Selection selection,
required String currentViewId,
+ required EditorState editorState,
}) async {
if (type != SubPageBlockKeys.type || selectedNodes.isEmpty) {
return false;
@@ -552,7 +557,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return true;
}
- Future<String> _extractNameFromNodes(List<Node>? nodes) async {
+ static Future<String> _extractNameFromNodes(List<Node>? nodes) async {
if (nodes == null || nodes.isEmpty) {
return '';
}
@@ -602,7 +607,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return name.substring(0, name.length > 30 ? 30 : name.length);
}
- List<String> _extractChildViewIds(List<Node> nodes) {
+ static List<String> _extractChildViewIds(List<Node> nodes) {
final List<String> viewIds = [];
for (final node in nodes) {
if (node.type == SubPageBlockKeys.type) {
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.dart
index c69233e440..aa519b7265 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
@@ -237,12 +237,13 @@ class _TurnInfoButton extends StatelessWidget {
leftIcon: FlowySvg(leftIcon),
rightIcon: rightIcon,
itemHeight: ActionListSizes.itemHeight,
- onTap: () => context.read<BlockActionOptionCubit>().turnIntoBlock(
- type,
- node,
- level: level,
- currentViewId: getIt<MenuSharedState>().latestOpenView?.id,
- ),
+ onTap: () => BlockActionOptionCubit.turnIntoBlock(
+ type,
+ node,
+ context.read<BlockActionOptionCubit>().editorState,
+ level: level,
+ currentViewId: getIt<MenuSharedState>().latestOpenView?.id,
+ ),
);
}
@@ -338,7 +339,7 @@ class _TurnInfoButton extends StatelessWidget {
case NumberedListBlockKeys.type:
return LocaleKeys.document_slashMenu_name_numberedList.tr();
case TodoListBlockKeys.type:
- return LocaleKeys.document_slashMenu_name_todoList.tr();
+ return LocaleKeys.editor_checkbox.tr();
case CalloutBlockKeys.type:
return LocaleKeys.document_slashMenu_name_callout.tr();
case SubPageBlockKeys.type:
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.dart
index 3f8307bf13..1e17a0b321 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
@@ -120,7 +120,7 @@ class _AiWriterToolbarActionListState extends State<AiWriterToolbarActionList> {
Widget buildChild(BuildContext context) {
final iconColor = Theme.of(context).iconTheme.color;
final child = FlowyIconButton(
- width: 52,
+ width: 48,
height: 32,
isSelected: isSelected,
hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
@@ -132,9 +132,10 @@ class _AiWriterToolbarActionListState extends State<AiWriterToolbarActionList> {
size: Size.square(20),
color: iconColor,
),
+ HSpace(4),
FlowySvg(
FlowySvgs.toolbar_arrow_down_m,
- size: Size.square(20),
+ size: Size(12, 20),
color: iconColor,
),
],
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_entities.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_entities.dart
index e0cc944b3f..5c1909564e 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_entities.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_entities.dart
@@ -90,7 +90,7 @@ enum AiWriterCommand {
FlowySvgData get icon => switch (this) {
userQuestion => FlowySvgs.ai_sparks_s,
- explain => FlowySvgs.ai_explain_s,
+ explain => FlowySvgs.ai_explain_m,
// summarize => FlowySvgs.ai_summarize_s,
continueWriting || improveWriting => FlowySvgs.ai_improve_writing_s,
fixSpellingAndGrammar => FlowySvgs.ai_fix_spelling_grammar_s,
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.dart
new file mode 100644
index 0000000000..ee258a002d
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart
@@ -0,0 +1,81 @@
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:flutter/material.dart';
+
+import 'toolbar_animation.dart';
+
+class DesktopFloatingToolbar extends StatefulWidget {
+ const DesktopFloatingToolbar({
+ super.key,
+ required this.editorState,
+ required this.child,
+ });
+
+ final EditorState editorState;
+ final Widget child;
+
+ @override
+ State<DesktopFloatingToolbar> createState() => _DesktopFloatingToolbarState();
+}
+
+class _DesktopFloatingToolbarState extends State<DesktopFloatingToolbar> {
+ EditorState get editorState => widget.editorState;
+
+ _Position? position;
+
+ @override
+ void initState() {
+ super.initState();
+ final selection = editorState.selection;
+ if (selection == null || selection.isCollapsed) {
+ return;
+ }
+ final selectionRect = editorState.selectionRects();
+ if (selectionRect.isEmpty) return;
+ position = calculateSelectionMenuOffset(selectionRect.first);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ if (position == null) return Container();
+ return Positioned(
+ left: position!.left,
+ top: position!.top,
+ right: position!.right,
+ child: ToolbarAnimationWidget(
+ child: widget.child,
+ ),
+ );
+ }
+
+ _Position calculateSelectionMenuOffset(
+ Rect rect,
+ ) {
+ final bool isLongMenu = onlyShowInSingleSelectionAndTextType(editorState);
+ final menuWidth = isLongMenu ? 650.0 : 420.0;
+ final editorOffset =
+ editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
+ 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;
+ if (left + menuWidth > editorRect.right) {
+ return _Position(
+ editorRect.right - menuWidth,
+ top,
+ null,
+ );
+ } else if (rect.left - leftStart > 0) {
+ return _Position(rect.left - leftStart, top, null);
+ } else {
+ return _Position(rect.left, top, null);
+ }
+ }
+}
+
+class _Position {
+ _Position(this.left, this.top, this.right);
+
+ final double? left;
+ final double? top;
+ final double? right;
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/toolbar_animation.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/toolbar_animation.dart
new file mode 100644
index 0000000000..7598a2b657
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/toolbar_animation.dart
@@ -0,0 +1,87 @@
+import 'package:flutter/material.dart';
+
+class ToolbarAnimationWidget extends StatefulWidget {
+ const ToolbarAnimationWidget({
+ super.key,
+ required this.child,
+ this.duration = const Duration(milliseconds: 150),
+ this.beginOpacity = 0.0,
+ this.endOpacity = 1.0,
+ this.beginScaleFactor = 0.95,
+ this.endScaleFactor = 1.0,
+ });
+
+ final Widget child;
+ final Duration duration;
+ final double beginScaleFactor;
+ final double endScaleFactor;
+ final double beginOpacity;
+ final double endOpacity;
+
+ @override
+ State<ToolbarAnimationWidget> createState() => _ToolbarAnimationWidgetState();
+}
+
+class _ToolbarAnimationWidgetState extends State<ToolbarAnimationWidget>
+ with SingleTickerProviderStateMixin {
+ late AnimationController controller;
+ late Animation<double> fadeAnimation;
+ late Animation<double> scaleAnimation;
+
+ @override
+ void initState() {
+ super.initState();
+ controller = AnimationController(
+ vsync: this,
+ duration: widget.duration,
+ );
+ fadeAnimation = _buildFadeAnimation();
+ scaleAnimation = _buildScaleAnimation();
+ controller.forward();
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: controller,
+ builder: (_, child) => Opacity(
+ opacity: fadeAnimation.value,
+ child: Transform.scale(
+ scale: scaleAnimation.value,
+ child: child,
+ ),
+ ),
+ child: widget.child,
+ );
+ }
+
+ Animation<double> _buildFadeAnimation() {
+ return Tween<double>(
+ begin: widget.beginOpacity,
+ end: widget.endOpacity,
+ ).animate(
+ CurvedAnimation(
+ parent: controller,
+ curve: Curves.easeInOut,
+ ),
+ );
+ }
+
+ Animation<double> _buildScaleAnimation() {
+ return Tween<double>(
+ begin: widget.beginScaleFactor,
+ end: widget.endScaleFactor,
+ ).animate(
+ CurvedAnimation(
+ parent: controller,
+ curve: Curves.easeInOut,
+ ),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/todo_list_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/todo_list_item.dart
index 74ffa7e075..518dccb35e 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/todo_list_item.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/todo_list_item.dart
@@ -15,7 +15,7 @@ final _keywords = [
];
final todoListSlashMenuItem = SelectionMenuItem(
- getName: () => LocaleKeys.document_slashMenu_name_todoList.tr(),
+ getName: () => LocaleKeys.editor_checkbox.tr(),
keywords: _keywords,
handler: (editorState, _, __) async => insertCheckboxAfterSelection(
editorState,
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart
index 212be0f7bf..f3059bf1be 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart
@@ -47,15 +47,12 @@ Future<void> _formatGreaterToToggleHeading(
delta = delta.compose(Delta()..delete(_greater.length));
// if the previous block is heading block, convert it to toggle heading block
if (type == HeadingBlockKeys.type && level != null) {
- final cubit = BlockActionOptionCubit(
- editorState: editorState,
- blockComponentBuilder: {},
- );
- await cubit.turnIntoSingleToggleHeading(
+ await BlockActionOptionCubit.turnIntoSingleToggleHeading(
type: ToggleListBlockKeys.type,
selectedNodes: [node],
level: level,
delta: delta,
+ editorState: editorState,
afterSelection: afterSelection,
);
return;
@@ -98,7 +95,8 @@ CharacterShortcutEvent insertChildNodeInsideToggleList = CharacterShortcutEvent(
}
final slicedDelta = delta.slice(selection.start.offset);
final transaction = editorState.transaction;
- final collapsed = node.attributes[ToggleListBlockKeys.collapsed] as bool;
+ final bool collapsed =
+ node.attributes[ToggleListBlockKeys.collapsed] ?? false;
if (collapsed) {
// if the delta is empty, clear the format
if (delta.isEmpty) {
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.dart
index 68d439ddfe..befd97fd52 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,23 +1,27 @@
import 'package:appflowy/generated/flowy_svgs.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_imports
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/tooltip_util.dart';
-import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
import 'package:flutter/material.dart';
+import 'custom_placeholder_toolbar_item.dart';
+
final List<ToolbarItem> customMarkdownFormatItems = [
_FormatToolbarItem(
id: 'bold',
name: 'bold',
svg: FlowySvgs.toolbar_bold_m,
),
+ group1PaddingItem,
_FormatToolbarItem(
id: 'underline',
name: 'underline',
svg: FlowySvgs.toolbar_underline_m,
),
+ group1PaddingItem,
_FormatToolbarItem(
id: 'italic',
name: 'italic',
@@ -57,19 +61,21 @@ class _FormatToolbarItem extends ToolbarItem {
delta.everyAttributes((attr) => attr[name] == true),
);
- final hoverColor = Theme.of(context).brightness == Brightness.dark
- ? Theme.of(context).hoverColor
- : AFThemeExtension.of(context).toolbarHoverColor;
+ final hoverColor = isHighlight
+ ? highlightColor
+ : EditorStyleCustomizer.toolbarHoverColor(context);
+ final isDark = Theme.of(context).brightness == Brightness.dark;
final child = FlowyIconButton(
width: 36,
height: 32,
hoverColor: hoverColor,
+ isSelected: isHighlight,
icon: FlowySvg(
svg,
size: Size.square(20.0),
- color: isHighlight
- ? highlightColor
+ color: (isDark && isHighlight)
+ ? Color(0xFF282E3A)
: Theme.of(context).iconTheme.color,
),
onPressed: () => editorState.toggleAttribute(name),
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.dart
index 53cc9ce4ca..76407482cd 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
@@ -2,74 +2,218 @@ import 'package:appflowy/generated/flowy_svgs.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';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
const _kHighlightColorItemId = 'editor.highlightColor';
+String? _customHighlightColorHex;
final customHighlightColorItem = ToolbarItem(
id: _kHighlightColorItemId,
group: 1,
isActive: showInAnyTextType,
- builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
- String? highlightColorHex;
+ builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) =>
+ HighlightColorPickerWidget(
+ editorState: editorState,
+ tooltipBuilder: tooltipBuilder,
+ highlightColor: highlightColor,
+ ),
+);
- final selection = editorState.selection!;
- final nodes = editorState.getNodesInSelection(selection);
- final isHighlight = nodes.allSatisfyInSelection(selection, (delta) {
- if (delta.everyAttributes((attr) => attr.isEmpty)) {
- return false;
- }
+class HighlightColorPickerWidget extends StatefulWidget {
+ const HighlightColorPickerWidget({
+ super.key,
+ required this.editorState,
+ this.tooltipBuilder,
+ required this.highlightColor,
+ });
- return delta.everyAttributes((attributes) {
- highlightColorHex = attributes[AppFlowyRichTextKeys.backgroundColor];
- return highlightColorHex != null;
- });
- });
+ final EditorState editorState;
+ final ToolbarTooltipBuilder? tooltipBuilder;
+ final Color highlightColor;
+
+ @override
+ State<HighlightColorPickerWidget> createState() =>
+ _HighlightColorPickerWidgetState();
+}
+
+class _HighlightColorPickerWidgetState
+ extends State<HighlightColorPickerWidget> {
+ final popoverController = PopoverController();
+
+ bool isSelected = false;
+
+ EditorState get editorState => widget.editorState;
+
+ Color get highlightColor => widget.highlightColor;
+
+ @override
+ void dispose() {
+ super.dispose();
+ popoverController.close();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final selectionRectList = editorState.selectionRects();
+ final top =
+ selectionRectList.isEmpty ? 0.0 : selectionRectList.first.height;
+ return AppFlowyPopover(
+ controller: popoverController,
+ direction: PopoverDirection.bottomWithLeftAligned,
+ offset: Offset(0, top),
+ onOpen: () => keepEditorFocusNotifier.increase(),
+ onClose: () {
+ setState(() {
+ isSelected = false;
+ });
+ keepEditorFocusNotifier.decrease();
+ },
+ margin: EdgeInsets.zero,
+ popupBuilder: (context) => buildPopoverContent(),
+ child: buildChild(context),
+ );
+ }
+
+ Widget buildChild(BuildContext context) {
+ final iconColor = Theme.of(context).iconTheme.color;
final child = FlowyIconButton(
width: 36,
height: 32,
hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
- icon: FlowySvg(
- FlowySvgs.toolbar_text_highlight_m,
- size: Size.square(20.0),
- color: isHighlight ? highlightColor : Theme.of(context).iconTheme.color,
+ icon: SizedBox(
+ width: 20,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ FlowySvg(
+ FlowySvgs.toolbar_text_highlight_m,
+ size: Size(20, 16),
+ color: iconColor,
+ ),
+ buildColorfulDivider(iconColor),
+ ],
+ ),
),
onPressed: () {
- bool showClearButton = false;
- nodes.allSatisfyInSelection(selection, (delta) {
- if (!showClearButton) {
- showClearButton = delta.whereType<TextInsert>().any(
- (element) {
- return element
- .attributes?[AppFlowyRichTextKeys.backgroundColor] !=
- null;
- },
- );
- }
- return true;
+ setState(() {
+ isSelected = true;
});
- showColorMenu(
- context,
- editorState,
- selection,
- currentColorHex: highlightColorHex,
- isTextColor: false,
- showClearButton: showClearButton,
- );
+ showPopover();
},
);
- if (tooltipBuilder != null) {
- return tooltipBuilder(
- context,
- _kHighlightColorItemId,
- AppFlowyEditorL10n.current.highlightColor,
- child,
+ return widget.tooltipBuilder?.call(
+ context,
+ _kHighlightColorItemId,
+ AppFlowyEditorL10n.current.highlightColor,
+ child,
+ ) ??
+ child;
+ }
+
+ Widget buildColorfulDivider(Color? iconColor) {
+ final List<String> colors = [];
+ final selection = editorState.selection!;
+ final nodes = editorState.getNodesInSelection(selection);
+ nodes.allSatisfyInSelection(selection, (delta) {
+ if (delta.everyAttributes((attr) => attr.isEmpty)) {
+ return false;
+ }
+
+ return delta.everyAttributes((attr) {
+ final textColorHex = attr[AppFlowyRichTextKeys.backgroundColor];
+ if (textColorHex != null) colors.add(textColorHex);
+ return (textColorHex != null);
+ });
+ });
+
+ final colorLength = colors.length;
+ if (colors.isEmpty) {
+ return Container(
+ width: 20,
+ height: 4,
+ color: iconColor,
);
}
+ return SizedBox(
+ width: 20,
+ height: 4,
+ child: Row(
+ children: List.generate(colorLength, (index) {
+ final currentColor = int.tryParse(colors[index]);
+ return Container(
+ width: 20 / colorLength,
+ height: 4,
+ color: currentColor == null ? iconColor : Color(currentColor),
+ );
+ }),
+ ),
+ );
+ }
- return child;
- },
-);
+ Widget buildPopoverContent() {
+ final List<String> colors = [];
+
+ final selection = editorState.selection!;
+ final nodes = editorState.getNodesInSelection(selection);
+ nodes.allSatisfyInSelection(selection, (delta) {
+ if (delta.everyAttributes((attr) => attr.isEmpty)) {
+ return false;
+ }
+
+ return delta.everyAttributes((attributes) {
+ final highlightColorHex =
+ attributes[AppFlowyRichTextKeys.backgroundColor];
+ if (highlightColorHex != null) colors.add(highlightColorHex);
+ return highlightColorHex != null;
+ });
+ });
+ bool showClearButton = false;
+ nodes.allSatisfyInSelection(selection, (delta) {
+ if (!showClearButton) {
+ showClearButton = delta.whereType<TextInsert>().any(
+ (element) {
+ return element.attributes?[AppFlowyRichTextKeys.backgroundColor] !=
+ null;
+ },
+ );
+ }
+ return true;
+ });
+ return MouseRegion(
+ child: ColorPicker(
+ title: AppFlowyEditorL10n.current.highlightColor,
+ showClearButton: showClearButton,
+ selectedColorHex: colors.length == 1 ? colors.first : null,
+ customColorHex: _customHighlightColorHex,
+ colorOptions: generateHighlightColorOptions(),
+ onSubmittedColorHex: (color, isCustomColor) {
+ if (isCustomColor) {
+ _customHighlightColorHex = color;
+ }
+ formatHighlightColor(
+ editorState,
+ editorState.selection,
+ color,
+ withUpdateSelection: true,
+ );
+ hidePopover();
+ },
+ resetText: AppFlowyEditorL10n.current.clearHighlightColor,
+ resetIconName: 'clear_highlight_color',
+ ),
+ );
+ }
+
+ void showPopover() {
+ keepEditorFocusNotifier.increase();
+ popoverController.show();
+ }
+
+ void hidePopover() {
+ popoverController.close();
+ keepEditorFocusNotifier.decrease();
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_link_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_link_toolbar_item.dart
index 048e330f70..f6dc8bce7b 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_link_toolbar_item.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_link_toolbar_item.dart
@@ -19,14 +19,19 @@ final customLinkItem = ToolbarItem(
);
});
+ final hoverColor = isHref
+ ? highlightColor
+ : EditorStyleCustomizer.toolbarHoverColor(context);
+
final child = FlowyIconButton(
width: 36,
height: 32,
- hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
+ hoverColor: hoverColor,
+ isSelected: isHref,
icon: FlowySvg(
FlowySvgs.toolbar_link_m,
size: Size.square(20.0),
- color: isHref ? highlightColor : Theme.of(context).iconTheme.color,
+ color: Theme.of(context).iconTheme.color,
),
onPressed: () => showLinkMenu(context, editorState, selection, isHref),
);
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.dart
new file mode 100644
index 0000000000..b531ecc0a2
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toolbar_item/custom_placeholder_toolbar_item.dart
@@ -0,0 +1,48 @@
+import 'package:appflowy/plugins/document/presentation/editor_page.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/ai/ai_writer_toolbar_item.dart';
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
+
+const placeholderItemId = 'editor.placeholder';
+const paddingPlaceholderItemId = 'editor.padding_placeholder';
+
+final ToolbarItem customPlaceholderItem = ToolbarItem(
+ id: placeholderItemId,
+ group: -1,
+ isActive: (editorState) => true,
+ builder: (context, __, ___, ____, _____) {
+ final isDark = Theme.of(context).brightness == Brightness.dark;
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 5),
+ child: Container(
+ width: 1,
+ color: Color(0xffE8ECF3).withAlpha(isDark ? 40 : 100),
+ ),
+ );
+ },
+);
+
+ToolbarItem buildPaddingPlaceholderItem(
+ int group, {
+ bool Function(EditorState editorState)? isActive,
+}) =>
+ ToolbarItem(
+ id: paddingPlaceholderItemId,
+ group: group,
+ isActive: isActive,
+ builder: (context, __, ___, ____, _____) => HSpace(4),
+ );
+
+ToolbarItem group0PaddingItem = buildPaddingPlaceholderItem(
+ 0,
+ isActive: onlyShowInTextTypeAndExcludeTable,
+);
+
+ToolbarItem group1PaddingItem =
+ buildPaddingPlaceholderItem(1, isActive: showInAnyTextType);
+
+ToolbarItem group4PaddingItem = buildPaddingPlaceholderItem(
+ 4,
+ isActive: onlyShowInSingleSelectionAndTextType,
+);
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.dart
index a5f4d59559..3a5cabe6ee 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
@@ -84,7 +84,7 @@ class _TextAlignActionListState extends State<TextAlignActionList> {
Widget buildChild(BuildContext context) {
final iconColor = Theme.of(context).iconTheme.color;
final child = FlowyIconButton(
- width: 52,
+ width: 48,
height: 32,
isSelected: isSelected,
hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
@@ -96,9 +96,10 @@ class _TextAlignActionListState extends State<TextAlignActionList> {
size: Size.square(20),
color: iconColor,
),
+ HSpace(4),
FlowySvg(
FlowySvgs.toolbar_arrow_down_m,
- size: Size.square(20),
+ size: Size(12, 20),
color: iconColor,
),
],
@@ -132,24 +133,20 @@ class _TextAlignActionListState extends State<TextAlignActionList> {
final isHighlight = nodes.every(
(n) => n.attributes[blockComponentAlign] == command.name,
);
- final color =
- isHighlight ? highlightColor : Theme.of(context).iconTheme.color;
return SizedBox(
height: 36,
child: FlowyButton(
leftIconSize: const Size.square(20),
- leftIcon: FlowySvg(
- command.svg,
- color: color,
- ),
+ leftIcon: FlowySvg(command.svg),
iconPadding: 12,
text: FlowyText(
command.title,
fontWeight: FontWeight.w400,
figmaLineHeight: 20,
- color: color,
),
+ rightIcon:
+ isHighlight ? FlowySvg(FlowySvgs.toolbar_check_m) : null,
onTap: () {
command.onAlignChanged(editorState);
popoverController.close();
@@ -193,6 +190,10 @@ enum TextAlignCommand {
blockComponentAlign: name,
},
),
+ selectionExtraInfo: {
+ selectionExtraInfoDoNotAttachTextService: true,
+ selectionExtraInfoDisableFloatingToolbar: true,
+ },
);
}
}
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.dart
index 7cb7f47bfb..37ca253eb7 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
@@ -2,75 +2,216 @@ import 'package:appflowy/generated/flowy_svgs.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';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
const _kTextColorItemId = 'editor.textColor';
+String? _customColorHex;
final customTextColorItem = ToolbarItem(
id: _kTextColorItemId,
group: 1,
isActive: showInAnyTextType,
- builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
- String? textColorHex;
+ builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) =>
+ TextColorPickerWidget(
+ editorState: editorState,
+ tooltipBuilder: tooltipBuilder,
+ highlightColor: highlightColor,
+ ),
+);
+
+class TextColorPickerWidget extends StatefulWidget {
+ const TextColorPickerWidget({
+ super.key,
+ required this.editorState,
+ this.tooltipBuilder,
+ required this.highlightColor,
+ });
+
+ final EditorState editorState;
+ final ToolbarTooltipBuilder? tooltipBuilder;
+ final Color highlightColor;
+
+ @override
+ State<TextColorPickerWidget> createState() => _TextColorPickerWidgetState();
+}
+
+class _TextColorPickerWidgetState extends State<TextColorPickerWidget> {
+ final popoverController = PopoverController();
+
+ bool isSelected = false;
+
+ EditorState get editorState => widget.editorState;
+
+ Color get highlightColor => widget.highlightColor;
+
+ @override
+ void dispose() {
+ super.dispose();
+ popoverController.close();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final selectionRectList = editorState.selectionRects();
+ final top =
+ selectionRectList.isEmpty ? 0.0 : selectionRectList.first.height;
+ return AppFlowyPopover(
+ controller: popoverController,
+ direction: PopoverDirection.bottomWithLeftAligned,
+ offset: Offset(0, top),
+ onOpen: () => keepEditorFocusNotifier.increase(),
+ onClose: () {
+ setState(() {
+ isSelected = false;
+ });
+ keepEditorFocusNotifier.decrease();
+ },
+ margin: EdgeInsets.zero,
+ popupBuilder: (context) => buildPopoverContent(),
+ child: buildChild(context),
+ );
+ }
+
+ Widget buildChild(BuildContext context) {
+ final iconColor = Theme.of(context).iconTheme.color;
+ final child = FlowyIconButton(
+ width: 36,
+ height: 32,
+ hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
+ icon: SizedBox(
+ width: 20,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ FlowySvg(
+ FlowySvgs.toolbar_text_color_m,
+ size: Size(20, 16),
+ color: iconColor,
+ ),
+ buildColorfulDivider(iconColor),
+ ],
+ ),
+ ),
+ onPressed: () {
+ setState(() {
+ isSelected = true;
+ });
+ showPopover();
+ },
+ );
+
+ return widget.tooltipBuilder?.call(
+ context,
+ _kTextColorItemId,
+ AppFlowyEditorL10n.current.textColor,
+ child,
+ ) ??
+ child;
+ }
+
+ Widget buildColorfulDivider(Color? iconColor) {
+ final List<String> colors = [];
final selection = editorState.selection!;
final nodes = editorState.getNodesInSelection(selection);
- final isHighlight = nodes.allSatisfyInSelection(selection, (delta) {
+ nodes.allSatisfyInSelection(selection, (delta) {
if (delta.everyAttributes((attr) => attr.isEmpty)) {
return false;
}
return delta.everyAttributes((attr) {
- textColorHex = attr[AppFlowyRichTextKeys.textColor];
+ final textColorHex = attr[AppFlowyRichTextKeys.textColor];
+ if (textColorHex != null) colors.add(textColorHex);
return (textColorHex != null);
});
});
- final child = FlowyIconButton(
- width: 36,
- height: 32,
- hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
- icon: FlowySvg(
- FlowySvgs.toolbar_text_color_m,
- size: Size.square(20.0),
- color: isHighlight ? highlightColor : Theme.of(context).iconTheme.color,
+ final colorLength = colors.length;
+ if (colors.isEmpty) {
+ return Container(
+ width: 20,
+ height: 4,
+ color: iconColor,
+ );
+ }
+ return SizedBox(
+ width: 20,
+ height: 4,
+ child: Row(
+ children: List.generate(colorLength, (index) {
+ final currentColor = int.tryParse(colors[index]);
+ return Container(
+ width: 20 / colorLength,
+ height: 4,
+ color: currentColor == null ? iconColor : Color(currentColor),
+ );
+ }),
),
- onPressed: () {
- bool showClearButton = false;
- nodes.allSatisfyInSelection(
- selection,
- (delta) {
- if (!showClearButton) {
- showClearButton = delta.whereType<TextInsert>().any(
- (element) {
- return element.attributes?[AppFlowyRichTextKeys.textColor] !=
- null;
- },
- );
- }
- return true;
- },
- );
- showColorMenu(
- context,
- editorState,
- selection,
- currentColorHex: textColorHex,
- isTextColor: true,
- showClearButton: showClearButton,
- );
+ );
+ }
+
+ Widget buildPopoverContent() {
+ bool showClearButton = false;
+ final List<String> colors = [];
+ final selection = editorState.selection!;
+ final nodes = editorState.getNodesInSelection(selection);
+ nodes.allSatisfyInSelection(selection, (delta) {
+ if (delta.everyAttributes((attr) => attr.isEmpty)) {
+ return false;
+ }
+
+ return delta.everyAttributes((attr) {
+ final textColorHex = attr[AppFlowyRichTextKeys.textColor];
+ if (textColorHex != null) colors.add(textColorHex);
+ return (textColorHex != null);
+ });
+ });
+ nodes.allSatisfyInSelection(
+ selection,
+ (delta) {
+ if (!showClearButton) {
+ showClearButton = delta.whereType<TextInsert>().any(
+ (element) {
+ return element.attributes?[AppFlowyRichTextKeys.textColor] !=
+ null;
+ },
+ );
+ }
+ return true;
},
);
+ return MouseRegion(
+ child: ColorPicker(
+ title: AppFlowyEditorL10n.current.textColor,
+ showClearButton: showClearButton,
+ selectedColorHex: colors.length == 1 ? colors.first : null,
+ customColorHex: _customColorHex,
+ colorOptions: generateTextColorOptions(),
+ onSubmittedColorHex: (color, isCustomColor) {
+ if (isCustomColor) {
+ _customColorHex = color;
+ }
+ formatFontColor(
+ editorState,
+ editorState.selection,
+ color,
+ withUpdateSelection: true,
+ );
+ hidePopover();
+ },
+ resetText: AppFlowyEditorL10n.current.resetToDefaultColor,
+ resetIconName: 'reset_text_color',
+ ),
+ );
+ }
- if (tooltipBuilder != null) {
- return tooltipBuilder(
- context,
- _kTextColorItemId,
- AppFlowyEditorL10n.current.textColor,
- child,
- );
- }
+ void showPopover() {
+ keepEditorFocusNotifier.increase();
+ popoverController.show();
+ }
- return child;
- },
-);
+ void hidePopover() {
+ popoverController.close();
+ keepEditorFocusNotifier.decrease();
+ }
+}
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.dart
index 7a3e072246..8d92b4a4b3 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
@@ -73,7 +73,7 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {
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(() {
@@ -152,6 +152,8 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {
Widget buildPopoverContent() {
final showFormula = onlyShowInSingleSelectionAndTextType(editorState);
+ final strikethroughColor = getStrikethroughColor();
+ final Color? formulaColor = showFormula ? getFormulaColor() : null;
return MouseRegion(
child: SeparatedColumn(
mainAxisSize: MainAxisSize.min,
@@ -160,36 +162,39 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {
buildFontSelector(),
buildCommandItem(
MoreOptionCommand.strikethrough,
- getStrikethroughColor(),
+ rightIcon: strikethroughColor != null
+ ? FlowySvg(FlowySvgs.toolbar_check_m)
+ : null,
),
if (showFormula)
buildCommandItem(
MoreOptionCommand.formula,
- getFormulaColor(),
+ rightIcon: formulaColor != null
+ ? FlowySvg(FlowySvgs.toolbar_check_m)
+ : null,
),
],
),
);
}
- Widget buildCommandItem(MoreOptionCommand command, Color? color) {
+ Widget buildCommandItem(
+ MoreOptionCommand command, {
+ Widget? rightIcon,
+ }) {
+ final isFontCommand = command == MoreOptionCommand.font;
return SizedBox(
height: 36,
child: FlowyButton(
- key: command == MoreOptionCommand.font
- ? kFontFamilyToolbarItemKey
- : null,
+ key: isFontCommand ? kFontFamilyToolbarItemKey : null,
leftIconSize: const Size.square(20),
- leftIcon: FlowySvg(
- command.svg,
- color: color,
- ),
+ leftIcon: FlowySvg(command.svg),
+ rightIcon: rightIcon,
iconPadding: 12,
text: FlowyText(
command.title,
figmaLineHeight: 20,
fontWeight: FontWeight.w400,
- color: color,
),
onTap: () {
command.onExecute(editorState);
@@ -228,7 +233,10 @@ class _MoreOptionActionListState extends State<MoreOptionActionList> {
await editorState
.formatDelta(selection, {AppFlowyRichTextKeys.fontFamily: null});
},
- child: buildCommandItem(MoreOptionCommand.font, null),
+ child: buildCommandItem(
+ MoreOptionCommand.font,
+ rightIcon: FlowySvg(FlowySvgs.toolbar_arrow_right_m),
+ ),
);
}
}
@@ -249,7 +257,7 @@ enum MoreOptionCommand {
case strikethrough:
return LocaleKeys.editor_strikethrough.tr();
case formula:
- return LocaleKeys.editor_mathEquationShortForm.tr();
+ return LocaleKeys.document_toolbar_equation.tr();
}
}
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.dart
index 5a4f5e2ce1..4d1ef3d12a 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
@@ -1,5 +1,6 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
@@ -78,7 +79,7 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {
Widget buildChild(BuildContext context) {
final iconColor = Theme.of(context).iconTheme.color;
final child = FlowyIconButton(
- width: 52,
+ width: 48,
height: 32,
isSelected: isSelected,
hoverColor: EditorStyleCustomizer.toolbarHoverColor(context),
@@ -90,9 +91,10 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {
size: Size.square(20),
color: iconColor,
),
+ HSpace(4),
FlowySvg(
FlowySvgs.toolbar_arrow_down_m,
- size: Size.square(20),
+ size: Size(12, 20),
color: iconColor,
),
],
@@ -115,6 +117,7 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {
}
Widget buildPopoverContent() {
+ final selectingCommand = getSelectingCommand();
return MouseRegion(
child: SeparatedColumn(
mainAxisSize: MainAxisSize.min,
@@ -132,7 +135,11 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {
fontWeight: FontWeight.w400,
figmaLineHeight: 20,
),
+ rightIcon: selectingCommand == command
+ ? FlowySvg(FlowySvgs.toolbar_check_m)
+ : null,
onTap: () {
+ if (command == selectingCommand) return;
command.onExecute(widget.editorState);
popoverController.close();
},
@@ -142,6 +149,27 @@ class _TextHeadingActionListState extends State<TextHeadingActionList> {
),
);
}
+
+ TextHeadingCommand? getSelectingCommand() {
+ final editorState = widget.editorState;
+ final selection = editorState.selection;
+ if (selection == null || !selection.isSingle) {
+ return null;
+ }
+ final node = editorState.getNodeAtPath(selection.start.path);
+ if (node == null || node.delta == null) {
+ return null;
+ }
+ final nodeType = node.type;
+ if (nodeType == ParagraphBlockKeys.type) return TextHeadingCommand.text;
+ if (nodeType == HeadingBlockKeys.type) {
+ final level = node.attributes[HeadingBlockKeys.level] ?? 1;
+ if (level == 1) return TextHeadingCommand.h1;
+ if (level == 2) return TextHeadingCommand.h2;
+ if (level == 3) return TextHeadingCommand.h3;
+ }
+ return null;
+ }
}
enum TextHeadingCommand {
@@ -167,22 +195,37 @@ enum TextHeadingCommand {
}
}
- void onExecute(EditorState editorState) {
+ void onExecute(EditorState state) {
switch (this) {
case text:
- formatNodeToText(editorState);
+ formatNodeToText(state);
break;
case h1:
- onHeadingLevelChanged(editorState, 1);
+ _turnInto(state, 1);
break;
case h2:
- onHeadingLevelChanged(editorState, 2);
+ _turnInto(state, 2);
break;
case h3:
- onHeadingLevelChanged(editorState, 3);
+ _turnInto(state, 3);
break;
}
}
+
+ Future<void> _turnInto(EditorState state, int level) async {
+ final selection = state.selection!;
+ final node = state.getNodeAtPath(selection.start.path)!;
+ await BlockActionOptionCubit.turnIntoBlock(
+ HeadingBlockKeys.type,
+ node,
+ state,
+ level: level,
+ );
+ await state.updateSelectionWithReason(
+ selection,
+ reason: SelectionUpdateReason.uiEvent,
+ );
+ }
}
void formatNodeToText(EditorState editorState) {
@@ -203,111 +246,3 @@ void formatNodeToText(EditorState editorState) {
),
);
}
-
-Future<void> onHeadingLevelChanged(
- EditorState editorState,
- int newLevel,
-) async {
- final selection = editorState.selection!;
- final node = editorState.getNodeAtPath(selection.start.path)!;
- final delta = (node.delta ?? Delta()).toJson();
- final level = node.attributes[HeadingBlockKeys.level] ?? 1;
- final originLevel = level;
- final type = newLevel == originLevel && node.type == HeadingBlockKeys.type
- ? ParagraphBlockKeys.type
- : HeadingBlockKeys.type;
-
- if (type == HeadingBlockKeys.type) {
- // from paragraph to heading
- final newNode = node.copyWith(
- type: type,
- attributes: {
- HeadingBlockKeys.level: newLevel,
- blockComponentBackgroundColor:
- node.attributes[blockComponentBackgroundColor],
- blockComponentTextDirection:
- node.attributes[blockComponentTextDirection],
- blockComponentDelta: delta,
- },
- );
- final children = node.children.map((child) => child.deepCopy());
-
- final transaction = editorState.transaction;
- transaction.insertNodes(
- selection.start.path.next,
- [newNode, ...children],
- );
- transaction.deleteNode(node);
- await editorState.apply(transaction);
- } else {
- // from heading to paragraph
- await editorState.formatNode(
- selection,
- (node) => node.copyWith(
- type: type,
- attributes: {
- HeadingBlockKeys.level: newLevel,
- blockComponentBackgroundColor:
- node.attributes[blockComponentBackgroundColor],
- blockComponentTextDirection:
- node.attributes[blockComponentTextDirection],
- blockComponentDelta: delta,
- },
- ),
- );
- }
-}
-
-Future<void> onToggleLevelChanged(
- EditorState editorState,
- int? newLevel,
-) async {
- final selection = editorState.selection!;
- final node = editorState.getNodeAtPath(selection.start.path)!;
- final delta = (node.delta ?? Delta()).toJson();
- final level = node.attributes[ToggleListBlockKeys.level];
- final originLevel = level;
-
- final type = newLevel == originLevel && node.type == ToggleListBlockKeys.type
- ? ParagraphBlockKeys.type
- : ToggleListBlockKeys.type;
-
- if (type == ToggleListBlockKeys.type) {
- // from paragraph to heading
- final newNode = node.copyWith(
- type: type,
- attributes: {
- if (newLevel != null) ToggleListBlockKeys.level: newLevel,
- blockComponentBackgroundColor:
- node.attributes[blockComponentBackgroundColor],
- blockComponentTextDirection:
- node.attributes[blockComponentTextDirection],
- blockComponentDelta: delta,
- },
- );
- final children = node.children.map((child) => child.deepCopy());
-
- final transaction = editorState.transaction;
- transaction.insertNodes(
- selection.start.path.next,
- [newNode, ...children],
- );
- transaction.deleteNode(node);
- await editorState.apply(transaction);
- } else {
- // from heading to paragraph
- await editorState.formatNode(
- selection,
- (node) => node.copyWith(
- type: type,
- attributes: {
- blockComponentBackgroundColor:
- node.attributes[blockComponentBackgroundColor],
- blockComponentTextDirection:
- node.attributes[blockComponentTextDirection],
- blockComponentDelta: delta,
- },
- ),
- );
- }
-}
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.dart
index 946d76b9ab..e805689fc8 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
@@ -2,6 +2,7 @@ import 'dart:collection';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy_editor/appflowy_editor.dart'
@@ -143,9 +144,10 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {
fontWeight: FontWeight.w400,
figmaLineHeight: 20,
),
+ HSpace(4),
FlowySvg(
FlowySvgs.toolbar_arrow_down_m,
- size: Size.square(20),
+ size: Size(12, 20),
color: iconColor,
),
],
@@ -263,7 +265,8 @@ class _SuggestionsActionListState extends State<SuggestionsActionList> {
suggestionItems.clear();
turnIntoItems.clear();
for (final item in suggestions) {
- if (item.type.group == suggestionType.group) {
+ if (item.type.group == suggestionType.group &&
+ item.type != suggestionType) {
suggestionItems.add(item);
} else {
turnIntoItems.add(item);
@@ -321,138 +324,101 @@ final h1SuggestionItem = SuggestionItem(
type: SuggestionType.h1,
title: LocaleKeys.document_toolbar_h1.tr(),
svg: FlowySvgs.type_h1_m,
- onTap: (state) => onHeadingLevelChanged(state, 1),
+ onTap: (state) => _turnInto(state, HeadingBlockKeys.type, level: 1),
);
final h2SuggestionItem = SuggestionItem(
type: SuggestionType.h2,
title: LocaleKeys.document_toolbar_h2.tr(),
svg: FlowySvgs.type_h2_m,
- onTap: (state) => onHeadingLevelChanged(state, 2),
+ onTap: (state) => _turnInto(state, HeadingBlockKeys.type, level: 2),
);
final h3SuggestionItem = SuggestionItem(
type: SuggestionType.h3,
title: LocaleKeys.document_toolbar_h3.tr(),
svg: FlowySvgs.type_h3_m,
- onTap: (state) => onHeadingLevelChanged(state, 3),
+ onTap: (state) => _turnInto(state, HeadingBlockKeys.type, level: 3),
);
final checkboxSuggestionItem = SuggestionItem(
type: SuggestionType.checkbox,
title: LocaleKeys.editor_checkbox.tr(),
svg: FlowySvgs.type_todo_m,
- onTap: (state) {
- final selection = state.selection!;
- final node = state.getNodeAtPath(selection.start.path)!;
- final isHighlight = node.type == TodoListBlockKeys.type;
- state.formatNode(
- selection,
- (node) => node.copyWith(
- type: isHighlight ? ParagraphBlockKeys.type : TodoListBlockKeys.type,
- ),
- );
- },
+ onTap: (state) => _turnInto(state, TodoListBlockKeys.type),
);
final bulletedSuggestionItem = SuggestionItem(
type: SuggestionType.bulleted,
title: LocaleKeys.editor_bulletedListShortForm.tr(),
svg: FlowySvgs.type_bulleted_list_m,
- onTap: (state) {
- final selection = state.selection!;
- final node = state.getNodeAtPath(selection.start.path)!;
- final isHighlight = node.type == BulletedListBlockKeys.type;
- state.formatNode(
- selection,
- (node) => node.copyWith(
- type:
- isHighlight ? ParagraphBlockKeys.type : BulletedListBlockKeys.type,
- ),
- );
- },
+ onTap: (state) => _turnInto(state, BulletedListBlockKeys.type),
);
final numberedSuggestionItem = SuggestionItem(
type: SuggestionType.numbered,
title: LocaleKeys.editor_numberedListShortForm.tr(),
svg: FlowySvgs.type_numbered_list_m,
- onTap: (state) {
- final selection = state.selection!;
- final node = state.getNodeAtPath(selection.start.path)!;
- final isHighlight = node.type == NumberedListBlockKeys.type;
- state.formatNode(
- selection,
- (node) => node.copyWith(
- type:
- isHighlight ? ParagraphBlockKeys.type : NumberedListBlockKeys.type,
- ),
- );
- },
+ onTap: (state) => _turnInto(state, NumberedListBlockKeys.type),
);
final toggleSuggestionItem = SuggestionItem(
type: SuggestionType.toggle,
title: LocaleKeys.editor_toggleListShortForm.tr(),
svg: FlowySvgs.type_toggle_list_m,
- onTap: (state) => onToggleLevelChanged(state, null),
+ onTap: (state) => _turnInto(state, ToggleListBlockKeys.type),
);
final toggleH1SuggestionItem = SuggestionItem(
type: SuggestionType.toggleH1,
title: LocaleKeys.editor_toggleHeading1ShortForm.tr(),
svg: FlowySvgs.type_toggle_h1_m,
- onTap: (state) => onToggleLevelChanged(state, 1),
+ onTap: (state) => _turnInto(state, ToggleListBlockKeys.type, level: 1),
);
final toggleH2SuggestionItem = SuggestionItem(
type: SuggestionType.toggleH2,
title: LocaleKeys.editor_toggleHeading2ShortForm.tr(),
svg: FlowySvgs.type_toggle_h2_m,
- onTap: (state) => onToggleLevelChanged(state, 2),
+ onTap: (state) => _turnInto(state, ToggleListBlockKeys.type, level: 2),
);
final toggleH3SuggestionItem = SuggestionItem(
type: SuggestionType.toggleH3,
title: LocaleKeys.editor_toggleHeading3ShortForm.tr(),
svg: FlowySvgs.type_toggle_h3_m,
- onTap: (state) => onToggleLevelChanged(state, 3),
+ onTap: (state) => _turnInto(state, ToggleListBlockKeys.type, level: 3),
);
final callOutSuggestionItem = SuggestionItem(
type: SuggestionType.callOut,
title: LocaleKeys.document_plugins_callout.tr(),
svg: FlowySvgs.type_callout_m,
- onTap: (state) {
- final selection = state.selection!;
- final node = state.getNodeAtPath(selection.start.path)!;
- final isHighlight = node.type == CalloutBlockKeys.type;
- state.formatNode(
- selection,
- (node) => node.copyWith(
- type: isHighlight ? ParagraphBlockKeys.type : CalloutBlockKeys.type,
- ),
- );
- },
+ onTap: (state) => _turnInto(state, CalloutBlockKeys.type),
);
final quoteSuggestionItem = SuggestionItem(
type: SuggestionType.quote,
title: LocaleKeys.editor_quote.tr(),
svg: FlowySvgs.type_quote_m,
- onTap: (state) {
- final selection = state.selection!;
- final node = state.getNodeAtPath(selection.start.path)!;
- final isHighlight = node.type == QuoteBlockKeys.type;
- state.formatNode(
- selection,
- (node) => node.copyWith(
- type: isHighlight ? ParagraphBlockKeys.type : QuoteBlockKeys.type,
- ),
- );
- },
+ onTap: (state) => _turnInto(state, QuoteBlockKeys.type),
);
+Future<void> _turnInto(EditorState state, String type, {int? level}) async {
+ final selection = state.selection!;
+ final node = state.getNodeAtPath(selection.start.path)!;
+ await BlockActionOptionCubit.turnIntoBlock(
+ type,
+ node,
+ state,
+ level: level,
+ );
+ await state.updateSelectionWithReason(
+ selection,
+ reason: SelectionUpdateReason.uiEvent,
+ );
+}
+
final suggestions = UnmodifiableListView([
textSuggestionItem,
h1SuggestionItem,
diff --git a/frontend/appflowy_flutter/test/unit_test/document/turn_into/turn_into_test.dart b/frontend/appflowy_flutter/test/unit_test/document/turn_into/turn_into_test.dart
index adf2857edb..d2432557eb 100644
--- a/frontend/appflowy_flutter/test/unit_test/document/turn_into/turn_into_test.dart
+++ b/frontend/appflowy_flutter/test/unit_test/document/turn_into/turn_into_test.dart
@@ -24,11 +24,6 @@ void main() {
void Function(EditorState editorState, Node node)? afterTurnInto,
}) async {
final editorState = EditorState(document: document);
- final cubit = BlockActionOptionCubit(
- editorState: editorState,
- blockComponentBuilder: {},
- );
-
final types = toType == null
? EditorOptionActionType.turnInto.supportTypes
: [toType];
@@ -43,7 +38,12 @@ void main() {
final node = editorState.getNodeAtPath([0])!;
expect(node.type, originalType);
- final result = await cubit.turnIntoBlock(type, node, level: level);
+ final result = await BlockActionOptionCubit.turnIntoBlock(
+ type,
+ node,
+ editorState,
+ level: level,
+ );
expect(result, true);
final newNode = editorState.getNodeAtPath([0])!;
expect(newNode.type, type);
@@ -59,9 +59,10 @@ void main() {
Selection.collapsed(
Position(path: [0]),
);
- await cubit.turnIntoBlock(
+ await BlockActionOptionCubit.turnIntoBlock(
originalType,
newNode,
+ editorState,
);
expect(result, true);
}
diff --git a/frontend/resources/flowy_icons/16x/ai_explain.svg b/frontend/resources/flowy_icons/16x/ai_explain.svg
deleted file mode 100644
index 173b35b543..0000000000
--- a/frontend/resources/flowy_icons/16x/ai_explain.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M1.75 8C1.75 9.6576 2.40848 11.2473 3.58058 12.4194C4.75268 13.5915 6.3424 14.25 8 14.25C9.6576 14.25 11.2473 13.5915 12.4194 12.4194C13.5915 11.2473 14.25 9.6576 14.25 8C14.25 6.3424 13.5915 4.75268 12.4194 3.58058C11.2473 2.40848 9.6576 1.75 8 1.75C6.3424 1.75 4.75268 2.40848 3.58058 3.58058C2.40848 4.75268 1.75 6.3424 1.75 8Z" stroke="black"/>
-<path d="M6.82812 6.04688C6.82812 5.39967 7.35281 4.875 8 4.875C8.64719 4.875 9.17188 5.39967 9.17188 6.04688C9.17188 6.47653 8.94062 6.85219 8.59587 7.05619C8.29875 7.23194 8 7.49856 8 7.84375V8.625" stroke="black" stroke-linecap="round"/>
-<path d="M7.375 10.5C7.375 10.6658 7.44085 10.8247 7.55806 10.9419C7.67527 11.0592 7.83424 11.125 8 11.125C8.16576 11.125 8.32473 11.0592 8.44194 10.9419C8.55915 10.8247 8.625 10.6658 8.625 10.5C8.625 10.3342 8.55915 10.1753 8.44194 10.0581C8.32473 9.94085 8.16576 9.875 8 9.875C7.83424 9.875 7.67527 9.94085 7.55806 10.0581C7.44085 10.1753 7.375 10.3342 7.375 10.5Z" fill="black"/>
-</svg>
diff --git a/frontend/resources/flowy_icons/20x/ai_explain.svg b/frontend/resources/flowy_icons/20x/ai_explain.svg
new file mode 100644
index 0000000000..f490472688
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/ai_explain.svg
@@ -0,0 +1,4 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.97294 13.8714C9.80435 13.8714 9.64266 13.8045 9.52344 13.6853C9.40423 13.566 9.33725 13.4043 9.33725 13.2358C9.33725 13.0672 9.40423 12.9055 9.52344 12.7863C9.64266 12.667 9.80435 12.6001 9.97294 12.6001C10.1415 12.6001 10.3032 12.667 10.4224 12.7863C10.5417 12.9055 10.6086 13.0672 10.6086 13.2358C10.6086 13.4043 10.5417 13.566 10.4224 13.6853C10.3032 13.8045 10.1415 13.8714 9.97294 13.8714ZM8.25444 8.86425C8.19161 8.8638 8.12958 8.85006 8.07243 8.82393C8.01529 8.79781 7.96431 8.75988 7.92287 8.71265C7.88142 8.66542 7.85044 8.60995 7.83196 8.5499C7.81348 8.48984 7.80791 8.42655 7.81563 8.36419C7.8445 8.117 7.89044 7.91488 7.95344 7.75782C8.06024 7.4975 8.22638 7.26573 8.43863 7.081C8.65412 6.88624 8.90661 6.73686 9.18107 6.64176C9.45925 6.54639 9.75149 6.49847 10.0456 6.50001C10.6581 6.50001 11.1678 6.68025 11.5755 7.04119C11.9833 7.40082 12.1876 7.88119 12.1876 8.48057C12.1876 8.75007 12.1351 8.99419 12.0301 9.21294C11.9259 9.43213 11.7037 9.70513 11.3638 10.0315C11.0229 10.3583 10.7981 10.5906 10.6865 10.7289C10.5709 10.8757 10.4853 11.0438 10.4345 11.2237C10.4039 11.3248 10.382 11.4442 10.3702 11.5816C10.3492 11.8134 10.1628 11.9972 9.93007 11.9972C9.86815 11.9968 9.807 11.9835 9.75051 11.9582C9.69402 11.9329 9.64343 11.896 9.60197 11.85C9.56052 11.8041 9.5291 11.7499 9.50974 11.6911C9.49037 11.6323 9.48348 11.5701 9.4895 11.5085C9.50481 11.3493 9.528 11.2106 9.56038 11.0924C9.62031 10.8671 9.71132 10.6703 9.83294 10.5018C9.95413 10.3329 10.1729 10.0853 10.4892 9.7585C10.8059 9.43213 11.0098 9.19413 11.1017 9.04669C11.1918 8.89838 11.2868 8.65732 11.2868 8.36419C11.2868 8.07107 11.1323 7.83263 10.9245 7.60688C10.7154 7.38113 10.4122 7.26782 10.0145 7.26782C9.23838 7.26782 8.79825 7.66725 8.695 8.46613C8.66569 8.691 8.48282 8.86425 8.25619 8.86425H8.25444Z" fill="#1F2329"/>
+<circle cx="10" cy="10" r="6.5" stroke="#1F2329"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/toolbar_arrow_down.svg b/frontend/resources/flowy_icons/20x/toolbar_arrow_down.svg
index 6253ec74d4..e6ef664403 100644
--- a/frontend/resources/flowy_icons/20x/toolbar_arrow_down.svg
+++ b/frontend/resources/flowy_icons/20x/toolbar_arrow_down.svg
@@ -1,3 +1,3 @@
-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M13 8.5L10 11.5L7 8.5" stroke="#99A1A8" stroke-linecap="round" stroke-linejoin="round"/>
+<svg width="12" height="20" viewBox="0 0 12 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9 8.5L6 11.5L3 8.5" stroke="#99A1A8" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
diff --git a/frontend/resources/flowy_icons/20x/toolbar_text_color.svg b/frontend/resources/flowy_icons/20x/toolbar_text_color.svg
index f4b396705f..e96b00ac35 100644
--- a/frontend/resources/flowy_icons/20x/toolbar_text_color.svg
+++ b/frontend/resources/flowy_icons/20x/toolbar_text_color.svg
@@ -1,3 +1,3 @@
-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M5 13L6.66667 9.66666M6.66667 9.66666L9.46334 4.07331C9.68446 3.63108 10.3155 3.63108 10.5367 4.07331L13.3333 9.66666M6.66667 9.66666H13.3333M13.3333 9.66666L15 13M3 16H17" stroke="#1F2329" stroke-linecap="round"/>
+<svg width="20" height="16" viewBox="0 0 20 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M4.55279 12.7764C4.42929 13.0234 4.5294 13.3237 4.77639 13.4472C5.02338 13.5707 5.32372 13.4706 5.44721 13.2236L4.55279 12.7764ZM10 3L10.4472 2.77639C10.3625 2.607 10.1894 2.5 10 2.5C9.81061 2.5 9.63748 2.607 9.55279 2.77639L10 3ZM14.5528 13.2236C14.6763 13.4706 14.9766 13.5707 15.2236 13.4472C15.4706 13.3237 15.5707 13.0234 15.4472 12.7764L14.5528 13.2236ZM5.44721 13.2236L7.11388 9.89027L6.21945 9.44306L4.55279 12.7764L5.44721 13.2236ZM7.11388 9.89027L10.4472 3.22361L9.55279 2.77639L6.21945 9.44306L7.11388 9.89027ZM9.55279 3.22361L12.8861 9.89027L13.7805 9.44306L10.4472 2.77639L9.55279 3.22361ZM12.8861 9.89027L14.5528 13.2236L15.4472 12.7764L13.7805 9.44306L12.8861 9.89027ZM6.66667 10.1667H13.3333V9.16667H6.66667V10.1667Z" fill="#1F2329"/>
</svg>
diff --git a/frontend/resources/flowy_icons/20x/toolbar_text_highlight.svg b/frontend/resources/flowy_icons/20x/toolbar_text_highlight.svg
index 49add4ba87..ab53a64b38 100644
--- a/frontend/resources/flowy_icons/20x/toolbar_text_highlight.svg
+++ b/frontend/resources/flowy_icons/20x/toolbar_text_highlight.svg
@@ -1,3 +1,3 @@
-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M10 5C10.2367 6.60777 11.4697 7.83689 13 8M3 16H17M10.7911 3.86693L5.65847 9.10195C5.46467 9.30075 5.27712 9.69232 5.23961 9.96341L5.0083 11.9152C4.92702 12.6201 5.45217 13.102 6.17736 12.9815L8.19041 12.6502C8.47174 12.602 8.8656 12.4032 9.0594 12.1984L14.192 6.96336C15.0798 6.05974 15.4799 5.0296 14.0983 3.77054C12.7229 2.52354 11.6789 2.9633 10.7911 3.86693Z" stroke="#1F2329" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<svg width="20" height="16" viewBox="0 0 20 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M10 4.66667C10.2498 6.36375 11.5514 7.66117 13.1667 7.83333M10.7911 3.86693L5.65847 9.10195C5.46467 9.30075 5.27712 9.69232 5.23961 9.96341L5.0083 11.9152C4.92702 12.6201 5.45217 13.102 6.17736 12.9815L8.19041 12.6502C8.47174 12.602 8.8656 12.4032 9.0594 12.1984L14.192 6.96336C15.0798 6.05974 15.4799 5.0296 14.0983 3.77054C12.7229 2.52354 11.6789 2.9633 10.7911 3.86693Z" stroke="#1F2329" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index da50dc2504..edbe2b07f1 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -2116,7 +2116,8 @@
"moreOptions": "More Options",
"font": "Font",
"suggestions": "Suggestions",
- "turnInto": "Turn Into"
+ "turnInto": "Turn Into",
+ "equation": "Equation"
},
"errorBlock": {
"theBlockIsNotSupported": "Unable to parse the block content",
@@ -2418,9 +2419,9 @@
"link": "Link",
"numberedList": "Numbered list",
"numberedListShortForm": "Numbered",
- "toggleHeading1ShortForm": "Toggle h1",
- "toggleHeading2ShortForm": "Toggle h2",
- "toggleHeading3ShortForm": "Toggle h3",
+ "toggleHeading1ShortForm": "Toggle H1",
+ "toggleHeading2ShortForm": "Toggle H2",
+ "toggleHeading3ShortForm": "Toggle H3",
"quote": "Quote",
"strikethrough": "Strikethrough",
"text": "Text",