diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_align_items.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_align_items.dart index df79ad7169..22b1028871 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_align_items.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_align_items.dart @@ -13,23 +13,27 @@ const _center = 'center'; const _right = 'right'; class AlignItems extends StatelessWidget { - const AlignItems({ + AlignItems({ super.key, required this.editorState, }); final EditorState editorState; + final List<(String, FlowySvgData)> _alignMenuItems = [ + (_left, FlowySvgs.m_aa_align_left_s), + (_center, FlowySvgs.m_aa_align_center_s), + (_right, FlowySvgs.m_aa_align_right_s), + ]; @override Widget build(BuildContext context) { final currentAlignItem = _getCurrentAlignItem(); - final alignMenuItems = _getAlignMenuItems(); final theme = ToolbarColorExtension.of(context); return PopupMenu( - itemLength: alignMenuItems.length, + itemLength: _alignMenuItems.length, onSelected: (index) { editorState.alignBlock( - alignMenuItems[index].$1, + _alignMenuItems[index].$1, selectionExtraInfo: { selectionExtraInfoDoNotAttachTextService: true, selectionExtraInfoDisableFloatingToolbar: true, @@ -37,7 +41,7 @@ class AlignItems extends StatelessWidget { ); }, menuBuilder: (context, keys, currentIndex) { - final children = alignMenuItems + final children = _alignMenuItems .mapIndexed( (index, e) => [ PopupMenuItemWrapper( @@ -45,7 +49,7 @@ class AlignItems extends StatelessWidget { isSelected: currentIndex == index, icon: e.$2, ), - if (index != 0 && index != alignMenuItems.length - 1) + if (index != 0 && index != _alignMenuItems.length - 1) const HSpace(12), ], ) @@ -84,36 +88,12 @@ class AlignItems extends StatelessWidget { (String, FlowySvgData) _getCurrentAlignItem() { final align = _getCurrentBlockAlign(); if (align == _center) { - return (_center, FlowySvgs.m_aa_align_center_s); - } else if (align == _right) { return (_right, FlowySvgs.m_aa_align_right_s); + } else if (align == _right) { + return (_left, FlowySvgs.m_aa_align_left_s); + } else { + return (_center, FlowySvgs.m_aa_align_center_s); } - return (_left, FlowySvgs.m_aa_align_left_s); - } - - List<(String, FlowySvgData)> _getAlignMenuItems() { - return [ - (_left, FlowySvgs.m_aa_align_left_s), - (_center, FlowySvgs.m_aa_align_center_s), - (_right, FlowySvgs.m_aa_align_right_s), - ]; - // final align = _getCurrentBlockAlign(); - - // if (align == _center) { - // return [ - // (_left, FlowySvgs.m_aa_align_left_s), - // (_right, FlowySvgs.m_aa_align_right_s), - // ]; - // } else if (align == _right) { - // return [ - // (_left, FlowySvgs.m_aa_align_left_s), - // (_center, FlowySvgs.m_aa_align_center_s), - // ]; - // } - // return [ - // (_center, FlowySvgs.m_aa_align_center_s), - // (_right, FlowySvgs.m_aa_align_right_s), - // ]; } String _getCurrentBlockAlign() { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_heading_and_text_items.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_heading_and_text_items.dart index ff7d495c31..fcd0198799 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_heading_and_text_items.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_heading_and_text_items.dart @@ -80,7 +80,7 @@ class _HeadingOrTextItem extends StatelessWidget { } Future _convert(bool isSelected) async { - editorState.convertBlockType( + await editorState.convertBlockType( blockType, isSelected: isSelected, extraAttributes: level != null @@ -90,6 +90,14 @@ class _HeadingOrTextItem extends StatelessWidget { : null, selectionExtraInfo: { selectionExtraInfoDoNotAttachTextService: true, + selectionExtraInfoDisableFloatingToolbar: true, + }, + ); + await editorState.updateSelectionWithReason( + editorState.selection, + extraInfo: { + selectionExtraInfoDisableFloatingToolbar: true, + selectionExtraInfoDoNotAttachTextService: true, }, ); } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/code_block_node_parser.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/code_block_node_parser.dart deleted file mode 100644 index 82e16871ce..0000000000 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/code_block_node_parser.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; -import 'package:appflowy_editor/appflowy_editor.dart'; - -class CodeBlockNodeParser extends NodeParser { - const CodeBlockNodeParser(); - - @override - String get id => CodeBlockKeys.type; - - @override - String transform(Node node, DocumentMarkdownEncoder? encoder) { - final delta = node.delta; - final language = node.attributes[CodeBlockKeys.language] ?? ''; - if (delta == null) { - throw Exception('Delta is null'); - } - final markdown = DeltaMarkdownEncoder().convert(delta); - final result = '```$language\n$markdown\n```'; - final suffix = node.next == null ? '' : '\n'; - - return '$result$suffix'; - } -} diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/divider_node_parser.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/divider_node_parser.dart deleted file mode 100644 index 808d0e8636..0000000000 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/divider_node_parser.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:appflowy_editor/appflowy_editor.dart'; - -class DividerNodeParser extends NodeParser { - const DividerNodeParser(); - - @override - String get id => DividerBlockKeys.type; - - @override - String transform(Node node, DocumentMarkdownEncoder? encoder) { - return '---\n'; - } -} diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/document_markdown_parsers.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/document_markdown_parsers.dart index 388fbb32a9..0b694f396e 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/document_markdown_parsers.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/document_markdown_parsers.dart @@ -1,6 +1,4 @@ export 'callout_node_parser.dart'; -export 'code_block_node_parser.dart'; export 'custom_image_node_parser.dart'; -export 'divider_node_parser.dart'; export 'math_equation_node_parser.dart'; export 'toggle_list_node_parser.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_parsers.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_parsers.dart index 06f3a10384..3e4fc3a764 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_parsers.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_parsers.dart @@ -1,5 +1,3 @@ export 'callout_node_parser.dart'; -export 'code_block_node_parser.dart'; -export 'divider_node_parser.dart'; export 'math_equation_node_parser.dart'; export 'toggle_list_node_parser.dart'; diff --git a/frontend/appflowy_flutter/lib/workspace/application/export/document_exporter.dart b/frontend/appflowy_flutter/lib/workspace/application/export/document_exporter.dart index e5cd875da1..bb8ce9a953 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/export/document_exporter.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/export/document_exporter.dart @@ -11,9 +11,7 @@ import 'package:dartz/dartz.dart'; import 'package:easy_localization/easy_localization.dart'; const List _customParsers = [ - DividerNodeParser(), MathEquationNodeParser(), - CodeBlockNodeParser(), CalloutNodeParser(), ToggleListNodeParser(), CustomImageNodeParser(), diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index 577bf3a6ad..4e8c121205 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -53,11 +53,11 @@ packages: dependency: "direct main" description: path: "." - ref: "49575bc" - resolved-ref: "49575bc58f0332810e8aebbeae752eac77275d54" + ref: "3d373be" + resolved-ref: "3d373be64d28e13558e43d489728a6e0616821a9" url: "https://github.com/AppFlowy-IO/appflowy-editor.git" source: git - version: "2.2.0" + version: "2.3.0" appflowy_editor_plugins: dependency: "direct main" description: diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index 992294655e..f9625b42b9 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -164,7 +164,7 @@ dependency_overrides: appflowy_editor: git: url: https://github.com/AppFlowy-IO/appflowy-editor.git - ref: "49575bc" + ref: "3d373be" file: ^7.0.0