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
feat: support columns block in editor on desktop (#7402)
Lucasc760a1b1feb0
diff --git a/frontend/appflowy_flutter/integration_test/desktop/cloud/document/document_option_actions_test.dart b/frontend/appflowy_flutter/integration_test/desktop/cloud/document/document_option_actions_test.dartindex 0289fbe176..1bc9bd8f92 100644--- a/frontend/appflowy_flutter/integration_test/desktop/cloud/document/document_option_actions_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/cloud/document/document_option_actions_test.dart@@ -57,7 +57,7 @@ void main() {// move the checkbox to the child of the block at path [9]await tester.editor.dragBlock([10],- const Offset(80, -30),+ const Offset(120, -20),);// wait for the move animation to completediff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_multi_image_block_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_multi_image_block_test.dartindex 68ad7db7e5..d8b0784a39 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_with_multi_image_block_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_with_multi_image_block_test.dart@@ -48,7 +48,7 @@ void main() {await tester.editor.showSlashMenu();await tester.editor.tapSlashMenuItemWithName(LocaleKeys.document_slashMenu_name_photoGallery.tr(),- offset: 80,+ offset: 100,);expect(find.byType(MultiImageBlockComponent), findsOneWidget);expect(find.byType(MultiImagePlaceholder), findsOneWidget);@@ -146,7 +146,7 @@ void main() {await tester.editor.showSlashMenu();await tester.editor.tapSlashMenuItemWithName(LocaleKeys.document_slashMenu_name_photoGallery.tr(),- offset: 80,+ offset: 100,);expect(find.byType(MultiImageBlockComponent), findsOneWidget);expect(find.byType(MultiImagePlaceholder), findsOneWidget);diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/selection_menu/mobile_selection_menu_item_widget.dart b/frontend/appflowy_flutter/lib/mobile/presentation/selection_menu/mobile_selection_menu_item_widget.dartindex 1ed84a73d5..ae5b0b11ac 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/selection_menu/mobile_selection_menu_item_widget.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/selection_menu/mobile_selection_menu_item_widget.dart@@ -86,6 +86,15 @@ class MobileSelectionMenuStyle extends SelectionMenuStyle {required super.selectionMenuItemSelectedTextColor,required super.selectionMenuItemSelectedIconColor,required super.selectionMenuItemSelectedColor,+ required super.selectionMenuUnselectedLabelColor,+ required super.selectionMenuDividerColor,+ required super.selectionMenuLinkBorderColor,+ required super.selectionMenuInvalidLinkColor,+ required super.selectionMenuButtonColor,+ required super.selectionMenuButtonTextColor,+ required super.selectionMenuButtonIconColor,+ required super.selectionMenuButtonBorderColor,+ required super.selectionMenuTabIndicatorColor,required this.selectionMenuItemRightIconColor,});@@ -99,6 +108,15 @@ class MobileSelectionMenuStyle extends SelectionMenuStyle {selectionMenuItemRightIconColor: Color(0xB31E2022),selectionMenuItemSelectedTextColor: Color.fromARGB(255, 56, 91, 247),selectionMenuItemSelectedIconColor: Color.fromARGB(255, 56, 91, 247),+ selectionMenuUnselectedLabelColor: Color(0xFF333333),+ selectionMenuDividerColor: Color(0xFF00BCF0),+ selectionMenuLinkBorderColor: Color(0xFF00BCF0),+ selectionMenuInvalidLinkColor: Color(0xFFE53935),+ selectionMenuButtonColor: Color(0xFF00BCF0),+ selectionMenuButtonTextColor: Color(0xFF333333),+ selectionMenuButtonIconColor: Color(0xFF333333),+ selectionMenuButtonBorderColor: Color(0xFF00BCF0),+ selectionMenuTabIndicatorColor: Color(0xFF00BCF0),);static const MobileSelectionMenuStyle dark = MobileSelectionMenuStyle(@@ -109,5 +127,14 @@ class MobileSelectionMenuStyle extends SelectionMenuStyle {selectionMenuItemRightIconColor: Color(0xB3FFFFFF),selectionMenuItemSelectedTextColor: Color(0xFF131720),selectionMenuItemSelectedIconColor: Color(0xFF131720),+ selectionMenuUnselectedLabelColor: Color(0xFFBBC3CD),+ selectionMenuDividerColor: Color(0xFF3A3F44),+ selectionMenuLinkBorderColor: Color(0xFF3A3F44),+ selectionMenuInvalidLinkColor: Color(0xFFE53935),+ selectionMenuButtonColor: Color(0xFF00BCF0),+ selectionMenuButtonTextColor: Color(0xFFFFFFFF),+ selectionMenuButtonIconColor: Color(0xFFFFFFFF),+ selectionMenuButtonBorderColor: Color(0xFF00BCF0),+ selectionMenuTabIndicatorColor: Color(0xFF00BCF0),);}diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dartindex 641344cf27..268863664b 100644--- a/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart@@ -6,6 +6,7 @@ import 'package:appflowy/plugins/document/application/document_awareness_metadatimport 'package:appflowy/plugins/document/application/document_collab_adapter.dart';import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';import 'package:appflowy/plugins/document/application/document_listener.dart';+import 'package:appflowy/plugins/document/application/document_rules.dart';import 'package:appflowy/plugins/document/application/document_service.dart';import 'package:appflowy/plugins/document/application/editor_transaction_adapter.dart';import 'package:appflowy/plugins/trash/application/trash_service.dart';@@ -26,13 +27,7 @@ import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_editor/appflowy_editor.dart'- show- AppFlowyEditorLogLevel,- EditorState,- Position,- Selection,- TransactionTime,- paragraphNode;+ show AppFlowyEditorLogLevel, EditorState, TransactionTime;import 'package:appflowy_result/appflowy_result.dart';import 'package:flutter/foundation.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -90,6 +85,8 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {documentService: _documentService,);+ late final DocumentRules _documentRules;+StreamSubscription? _transactionSubscription;bool isClosing = false;@@ -262,13 +259,14 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {final editorState = EditorState(document: document);_documentCollabAdapter = DocumentCollabAdapter(editorState, documentId);+ _documentRules = DocumentRules(editorState: editorState);// subscribe to the document change from the editor_transactionSubscription = editorState.transactionStream.listen(- (event) async {- final time = event.$1;- final transaction = event.$2;- final options = event.$3;+ (value) async {+ final time = value.$1;+ final transaction = value.$2;+ final options = value.$3;if (time != TransactionTime.before) {return;}@@ -288,7 +286,7 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {await _transactionAdapter.apply(transaction, editorState);// check if the document is empty.- await _applyRules();+ await _documentRules.applyRules(value: value);if (enableDocumentInternalLog) {Log.debug(@@ -319,28 +317,6 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {return editorState;}- Future<void> _applyRules() async {- await Future.wait([- _ensureAtLeastOneParagraphExists(),- ]);- }-- Future<void> _ensureAtLeastOneParagraphExists() async {- final editorState = state.editorState;- if (editorState == null) {- return;- }- final document = editorState.document;- if (document.root.children.isEmpty) {- final transaction = editorState.transaction;- transaction.insertNode([0], paragraphNode());- transaction.afterSelection = Selection.collapsed(- Position(path: [0]),- );- await editorState.apply(transaction);- }- }-Future<void> _onDocumentStateUpdate(DocEventPB docEvent) async {if (!docEvent.isRemote || !FeatureFlag.syncDocument.isOn) {return;diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/document_rules.dart b/frontend/appflowy_flutter/lib/plugins/document/application/document_rules.dartnew file mode 100644index 0000000000..230a5b8fa7--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/application/document_rules.dart@@ -0,0 +1,118 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy_editor/appflowy_editor.dart';++/// Apply rules to the document+///+/// 1. ensure there is at least one paragraph in the document, otherwise the user will be blocked from typing+/// 2. remove columns block if its children are empty+class DocumentRules {+ DocumentRules({+ required this.editorState,+ });++ final EditorState editorState;++ Future<void> applyRules({+ required EditorTransactionValue value,+ }) async {+ await Future.wait([+ _ensureAtLeastOneParagraphExists(value: value),+ _removeColumnIfItIsEmpty(value: value),+ ]);+ }++ Future<void> _ensureAtLeastOneParagraphExists({+ required EditorTransactionValue value,+ }) async {+ final document = editorState.document;+ if (document.root.children.isEmpty) {+ final transaction = editorState.transaction;+ transaction+ ..insertNode([0], paragraphNode())+ ..afterSelection = Selection.collapsed(+ Position(path: [0]),+ );+ await editorState.apply(transaction);+ }+ }++ Future<void> _removeColumnIfItIsEmpty({+ required EditorTransactionValue value,+ }) async {+ final transaction = value.$2;+ final options = value.$3;++ if (options.inMemoryUpdate) {+ return;+ }++ for (final operation in transaction.operations) {+ final deleteColumnsTransaction = editorState.transaction;+ if (operation is DeleteOperation) {+ final path = operation.path;+ final column = editorState.document.nodeAtPath(path.parent);+ if (column != null && column.type == SimpleColumnBlockKeys.type) {+ // check if the column is empty+ final children = column.children;+ if (children.isEmpty) {+ // delete the column or the columns+ final columns = column.parent;++ if (columns != null &&+ columns.type == SimpleColumnsBlockKeys.type) {+ final nonEmptyColumnCount = columns.children.fold(+ 0,+ (p, c) => c.children.isEmpty ? p : p + 1,+ );++ // Example:+ // columns+ // - column 1+ // - paragraph 1-1+ // - paragraph 1-2+ // - column 2+ // - paragraph 2+ // - column 3+ // - paragraph 3+ //+ // case 1: delete the paragraph 3 from column 3.+ // because there is only one child in column 3, we should delete the column 3 as well.+ // the result should be:+ // columns+ // - column 1+ // - paragraph 1-1+ // - paragraph 1-2+ // - column 2+ // - paragraph 2+ //+ // case 2: delete the paragraph 3 from column 3 and delete the paragraph 2 from column 2.+ // in this case, there will be only one column left, so we should delete the columns block and flatten the children.+ // the result should be:+ // paragraph 1-1+ // paragraph 1-2++ // if there is only one empty column left, delete the columns block and flatten the children+ if (nonEmptyColumnCount <= 1) {+ // move the children in columns out of the column+ final children = columns.children+ .map((e) => e.children)+ .expand((e) => e)+ .map((e) => e.deepCopy())+ .toList();+ deleteColumnsTransaction.insertNodes(columns.path, children);+ deleteColumnsTransaction.deleteNode(columns);+ } else {+ // otherwise, delete the column+ deleteColumnsTransaction.deleteNode(column);+ }+ }+ }+ }+ }++ if (deleteColumnsTransaction.operations.isNotEmpty) {+ await editorState.apply(deleteColumnsTransaction);+ }+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dartindex 0bac8aae19..48e48e812d 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart@@ -31,6 +31,10 @@ final Set<String> supportSlashMenuNodeTypes = {SimpleTableBlockKeys.type,SimpleTableRowBlockKeys.type,SimpleTableCellBlockKeys.type,++ // Columns+ SimpleColumnsBlockKeys.type,+ SimpleColumnBlockKeys.type,};/// Build the block component builders.@@ -372,6 +376,14 @@ Map<String, BlockComponentBuilder> _buildBlockComponentBuilderMap(configuration,alwaysDistributeColumnWidths: alwaysDistributeSimpleTableColumnWidths,),+ SimpleColumnsBlockKeys.type: _buildSimpleColumnsBlockComponentBuilder(+ context,+ configuration,+ ),+ SimpleColumnBlockKeys.type: _buildSimpleColumnBlockComponentBuilder(+ context,+ configuration,+ ),};final builders = {@@ -946,6 +958,28 @@ SubPageBlockComponentBuilder _buildSubPageBlockComponentBuilder();}+SimpleColumnsBlockComponentBuilder _buildSimpleColumnsBlockComponentBuilder(+ BuildContext context,+ BlockComponentConfiguration configuration,+) {+ return SimpleColumnsBlockComponentBuilder(+ configuration: configuration.copyWith(+ padding: (_) => EdgeInsets.zero,+ ),+ );+}++SimpleColumnBlockComponentBuilder _buildSimpleColumnBlockComponentBuilder(+ BuildContext context,+ BlockComponentConfiguration configuration,+) {+ return SimpleColumnBlockComponentBuilder(+ configuration: configuration.copyWith(+ padding: (_) => EdgeInsets.zero,+ ),+ );+}+TextStyle _buildTextStyleInTableCell(BuildContext context, {required Node node,diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_button.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_button.dartindex aed2de9abf..3561bd33a0 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_button.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_button.dart@@ -48,8 +48,6 @@ class BlockActionButton extends StatelessWidget {);}- return Align(- child: child,- );+ return child;}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dartindex 8ab16aea4c..044f0ca595 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dart@@ -1,6 +1,7 @@import 'package:appflowy/plugins/document/presentation/editor_notification.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_popover/appflowy_popover.dart';import 'package:flutter/material.dart';@@ -9,7 +10,6 @@ import 'draggable_option_button_feedback.dart';import 'option_button.dart';// this flag is used to disable the tooltip of the block when it is dragged-@visibleForTestingValueNotifier<bool> isDraggingAppFlowyEditorBlock = ValueNotifier(false);class DraggableOptionButton extends StatefulWidget {@@ -82,8 +82,34 @@ class _DraggableOptionButtonState extends State<DraggableOptionButton> {void _onDragUpdate(DragUpdateDetails details) {isDraggingAppFlowyEditorBlock.value = true;+ final offset = details.globalPosition;+widget.editorState.selectionService.renderDropTargetForOffset(- details.globalPosition,+ offset,+ interceptor: (context, targetNode) {+ // if the cursor node is in a columns block or a column block,+ // we will return the node's parent instead to support dragging a node to the inside of a columns block or a column block.+ final parentColumnNode = targetNode.parentColumn;+ if (parentColumnNode != null) {+ final position = getDragAreaPosition(+ context,+ targetNode,+ offset,+ );++ if (position != null && position.$2 == HorizontalPosition.right) {+ return parentColumnNode;+ }++ if (position != null &&+ position.$2 == HorizontalPosition.left &&+ position.$1 == VerticalPosition.middle) {+ return parentColumnNode;+ }+ }++ return targetNode;+ },builder: (context, data) {return VisualDragArea(editorState: widget.editorState,@@ -112,6 +138,30 @@ class _DraggableOptionButtonState extends State<DraggableOptionButton> {final data = widget.editorState.selectionService.getDropTargetRenderData(globalPosition!,+ interceptor: (context, targetNode) {+ // if the cursor node is in a columns block or a column block,+ // we will return the node's parent instead to support dragging a node to the inside of a columns block or a column block.+ final parentColumnNode = targetNode.parentColumn;+ if (parentColumnNode != null) {+ final position = getDragAreaPosition(+ context,+ targetNode,+ globalPosition!,+ );++ if (position != null && position.$2 == HorizontalPosition.right) {+ return parentColumnNode;+ }++ if (position != null &&+ position.$2 == HorizontalPosition.left &&+ position.$1 == VerticalPosition.middle) {+ return parentColumnNode;+ }+ }++ return targetNode;+ },);dragToMoveNode(context,diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dartindex fcafe9f8de..99b13add54 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dart@@ -1,4 +1,4 @@-import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:flutter/material.dart';@@ -8,6 +8,15 @@ enum HorizontalPosition { left, center, right }enum VerticalPosition { top, middle, bottom }+List<String> nodeTypesThatCanContainChildNode = [+ ParagraphBlockKeys.type,+ BulletedListBlockKeys.type,+ NumberedListBlockKeys.type,+ QuoteBlockKeys.type,+ TodoListBlockKeys.type,+ ToggleListBlockKeys.type,+];+Future<void> dragToMoveNode(BuildContext context, {required Node node,@@ -35,17 +44,75 @@ Future<void> dragToMoveNode(final (verticalPosition, horizontalPosition, _) = position;Path newPath = targetNode.path;+ // if the horizontal position is right, creating a column block to contain the target node and the drag node+ if (horizontalPosition == HorizontalPosition.right) {+ // 1. if the targetNode is a column block, it means we should create a column block to contain the node and insert the column node to the target node's parent+ // 2. if the targetNode is not a column block, it means we should create a columns block to contain the target node and the drag node+ final transaction = editorState.transaction;+ final targetNodeParent = targetNode.parentColumnsBlock;+ if (targetNodeParent != null) {+ final columnNode = simpleColumnNode(+ children: [node.deepCopy()],+ );++ transaction.insertNode(targetNode.path.next, columnNode);+ transaction.deleteNode(node);+ } else {+ final columnsNode = simpleColumnsNode(+ children: [+ simpleColumnNode(children: [targetNode.deepCopy()]),+ simpleColumnNode(children: [node.deepCopy()]),+ ],+ );++ transaction.insertNode(newPath, columnsNode);+ transaction.deleteNode(targetNode);+ transaction.deleteNode(node);+ }++ if (transaction.operations.isNotEmpty) {+ await editorState.apply(transaction);+ }+ return;+ } else if (horizontalPosition == HorizontalPosition.left &&+ verticalPosition == VerticalPosition.middle) {+ // 1. if the target node is a column block, we should create a column block to contain the node and insert the column node to the target node's parent+ // 2. if the target node is not a column block, we should create a columns block to contain the target node and the drag node+ final transaction = editorState.transaction;+ final targetNodeParent = targetNode.parentColumnsBlock;+ if (targetNodeParent != null) {+ final columnNode = simpleColumnNode(+ children: [node.deepCopy()],+ );++ transaction.insertNode(targetNode.path.previous, columnNode);+ transaction.deleteNode(node);+ } else {+ final columnsNode = simpleColumnsNode(+ children: [+ simpleColumnNode(children: [node.deepCopy()]),+ simpleColumnNode(children: [targetNode.deepCopy()]),+ ],+ );++ transaction.insertNode(newPath, columnsNode);+ transaction.deleteNode(targetNode);+ transaction.deleteNode(node);+ }++ if (transaction.operations.isNotEmpty) {+ await editorState.apply(transaction);+ }+ return;+ }// Determine the new path based on drop position// For VerticalPosition.top, we keep the target node's pathif (verticalPosition == VerticalPosition.bottom) {if (horizontalPosition == HorizontalPosition.left) {newPath = newPath.next;- final node = editorState.document.nodeAtPath(newPath);- if (node == null) {- // if node is null, it means the node is the last one of the document.- newPath = targetNode.path;- }- } else {+ } else if (horizontalPosition == HorizontalPosition.center &&+ nodeTypesThatCanContainChildNode.contains(targetNode.type)) {+ // check if the target node can contain a child nodenewPath = newPath.child(0);}}@@ -103,22 +170,40 @@ Future<void> dragToMoveNode(HorizontalPosition horizontalPosition = HorizontalPosition.left;VerticalPosition verticalPosition;- // Horizontal position+ // | ----------------------------- block ----------------------------- |+ // | 1. -- 88px --| 2. ---------------------------- | 3. ---- 1/5 ---- |+ // 1. drag the node under the block as a sibling node+ // 2. drag the node inside the block as a child node+ // 3. create a column block to contain the node and the drag node++ // Horizontal position, please refer to the diagram above+ // 88px is a hardcoded value, it can be changed based on the project's designif (dragOffset.dx < globalBlockRect.left + 88) {horizontalPosition = HorizontalPosition.left;- } else if (indentableBlockTypes.contains(dragTargetNode.type)) {- // For indentable blocks, it means the block can contain a child block.- // ignore the middle here, it's not used in this example+ } else if (dragOffset.dx > globalBlockRect.right * 4.0 / 5.0) {horizontalPosition = HorizontalPosition.right;+ } else if (nodeTypesThatCanContainChildNode.contains(dragTargetNode.type)) {+ horizontalPosition = HorizontalPosition.center;}+ // | ----------------------------------------------------------------- | <- if the drag position is in this area, the vertical position is top+ // | ----------------------------- block ----------------------------- | <- if the drag position is in this area, the vertical position is middle+ // | ----------------------------------------------------------------- | <- if the drag position is in this area, the vertical position is bottom+// Vertical position- if (dragOffset.dy < globalBlockRect.top + globalBlockRect.height / 2) {+ final heightThird = globalBlockRect.height / 3;+ if (dragOffset.dy < globalBlockRect.top + heightThird) {verticalPosition = VerticalPosition.top;+ } else if (dragOffset.dy < globalBlockRect.top + heightThird * 2) {+ verticalPosition = VerticalPosition.middle;} else {verticalPosition = VerticalPosition.bottom;}+ debugPrint(+ 'verticalPosition: $verticalPosition, horizontalPosition: $horizontalPosition',+ );+return (verticalPosition, horizontalPosition, globalBlockRect);}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dartindex b4b4ffa904..2be8710a8a 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dart@@ -58,7 +58,36 @@ class VisualDragArea extends StatelessWidget {color: Theme.of(context).colorScheme.primary,);+ // if the horizontal position is right, we need to show the indicator on the right side of the target node+ // which represent moving the target node and drag node inside the column block.+ if (horizontalPosition == HorizontalPosition.left &&+ verticalPosition == VerticalPosition.middle) {+ return Positioned(+ top: globalBlockRect.top,+ height: globalBlockRect.height,+ left: globalBlockRect.left + indicatorWidth,+ child: Container(+ width: 2,+ color: Theme.of(context).colorScheme.primary,+ ),+ );+ }+if (horizontalPosition == HorizontalPosition.right) {+ return Positioned(+ top: globalBlockRect.top,+ height: globalBlockRect.height,+ left: globalBlockRect.right - 2,+ child: Container(+ width: 2,+ color: Theme.of(context).colorScheme.primary,+ ),+ );+ }++ // If the horizontal position is center, we need to show two indicators+ //which represent moving the block as the child of the target node.+ if (horizontalPosition == HorizontalPosition.center) {const breakWidth = 22.0;const padding = 8.0;child = Row(diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_component.dartnew file mode 100644index 0000000000..611f7ec67f--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_component.dart@@ -0,0 +1,194 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:collection/collection.dart';+import 'package:flutter/material.dart';+import 'package:provider/provider.dart';++Node simpleColumnNode({+ List<Node>? children,+ double? width,+}) {+ return Node(+ type: SimpleColumnBlockKeys.type,+ children: children ?? [paragraphNode()],+ attributes: {+ SimpleColumnBlockKeys.width: width,+ },+ );+}++class SimpleColumnBlockKeys {+ const SimpleColumnBlockKeys._();++ static const String type = 'simple_column';++ static const String width = 'width';+}++class SimpleColumnBlockComponentBuilder extends BlockComponentBuilder {+ SimpleColumnBlockComponentBuilder({super.configuration});++ @override+ BlockComponentWidget build(BlockComponentContext blockComponentContext) {+ final node = blockComponentContext.node;+ return SimpleColumnBlockComponent(+ key: node.key,+ node: node,+ showActions: showActions(node),+ configuration: configuration,+ actionBuilder: (_, state) => actionBuilder(blockComponentContext, state),+ );+ }++ @override+ BlockComponentValidate get validate => (node) => node.children.isNotEmpty;+}++class SimpleColumnBlockComponent extends BlockComponentStatefulWidget {+ const SimpleColumnBlockComponent({+ super.key,+ required super.node,+ super.showActions,+ super.actionBuilder,+ super.configuration = const BlockComponentConfiguration(),+ });++ @override+ State<SimpleColumnBlockComponent> createState() =>+ SimpleColumnBlockComponentState();+}++class SimpleColumnBlockComponentState extends State<SimpleColumnBlockComponent>+ with SelectableMixin, BlockComponentConfigurable {+ @override+ BlockComponentConfiguration get configuration => widget.configuration;++ @override+ Node get node => widget.node;++ RenderBox? get _renderBox => context.findRenderObject() as RenderBox?;++ final columnKey = GlobalKey();++ late final EditorState editorState = context.read<EditorState>();++ @override+ void initState() {+ super.initState();+ }++ @override+ void dispose() {+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ Widget child = Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: node.children.map(+ (e) {+ Widget child = IntrinsicHeight(+ child: editorState.renderer.build(context, e),+ );+ if (e.type == CustomImageBlockKeys.type) {+ child = IntrinsicWidth(child: child);+ }+ if (SimpleColumnsBlockConstants.enableDebugBorder) {+ child = DecoratedBox(+ decoration: BoxDecoration(+ border: Border.all(+ color: Colors.blue,+ ),+ ),+ child: child,+ );+ }+ return child;+ },+ ).toList(),+ );++ child = Padding(+ key: columnKey,+ padding: padding,+ child: child,+ );++ if (SimpleColumnsBlockConstants.enableDebugBorder) {+ child = Container(+ color: Colors.green.withValues(+ alpha: 0.2,+ ),+ child: child,+ );+ }++ // the column block does not support the block actions and selection+ // because the column block is a layout wrapper, it does not have a content+ return child;+ }++ @override+ Position start() => Position(path: widget.node.path);++ @override+ Position end() => Position(path: widget.node.path, offset: 1);++ @override+ Position getPositionInOffset(Offset start) => end();++ @override+ bool get shouldCursorBlink => false;++ @override+ CursorStyle get cursorStyle => CursorStyle.cover;++ @override+ Rect getBlockRect({+ bool shiftWithBaseOffset = false,+ }) {+ return getRectsInSelection(Selection.invalid()).first;+ }++ @override+ Rect? getCursorRectInPosition(+ Position position, {+ bool shiftWithBaseOffset = false,+ }) {+ final rects = getRectsInSelection(+ Selection.collapsed(position),+ shiftWithBaseOffset: shiftWithBaseOffset,+ );+ return rects.firstOrNull;+ }++ @override+ List<Rect> getRectsInSelection(+ Selection selection, {+ bool shiftWithBaseOffset = false,+ }) {+ if (_renderBox == null) {+ return [];+ }+ final parentBox = context.findRenderObject();+ final renderBox = columnKey.currentContext?.findRenderObject();+ if (parentBox is RenderBox && renderBox is RenderBox) {+ return [+ renderBox.localToGlobal(Offset.zero, ancestor: parentBox) &+ renderBox.size,+ ];+ }+ return [Offset.zero & _renderBox!.size];+ }++ @override+ Selection getSelectionInRange(Offset start, Offset end) =>+ Selection.single(path: widget.node.path, startOffset: 0, endOffset: 1);++ @override+ Offset localToGlobal(Offset offset, {bool shiftWithBaseOffset = false}) =>+ _renderBox!.localToGlobal(offset);+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_width_resizer.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_width_resizer.dartnew file mode 100644index 0000000000..34d751520d--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_width_resizer.dart@@ -0,0 +1,124 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/material.dart';++class ColumnBlockWidthResizer extends StatefulWidget {+ const ColumnBlockWidthResizer({+ super.key,+ required this.columnNode,+ required this.editorState,+ });++ final Node columnNode;+ final EditorState editorState;++ @override+ State<ColumnBlockWidthResizer> createState() =>+ _ColumnBlockWidthResizerState();+}++class _ColumnBlockWidthResizerState extends State<ColumnBlockWidthResizer> {+ bool isDragging = false;++ ValueNotifier<bool> isHovering = ValueNotifier(false);++ @override+ Widget build(BuildContext context) {+ return MouseRegion(+ onEnter: (_) => isHovering.value = true,+ onExit: (_) {+ // delay the hover state change to avoid flickering+ Future.delayed(const Duration(milliseconds: 100), () {+ if (!isDragging) {+ isHovering.value = false;+ }+ });+ },+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onHorizontalDragStart: _onHorizontalDragStart,+ onHorizontalDragUpdate: _onHorizontalDragUpdate,+ onHorizontalDragEnd: _onHorizontalDragEnd,+ onHorizontalDragCancel: _onHorizontalDragCancel,+ child: ValueListenableBuilder<bool>(+ valueListenable: isHovering,+ builder: (context, isHovering, child) {+ if (isDraggingAppFlowyEditorBlock.value) {+ return SizedBox.shrink();+ }+ return MouseRegion(+ cursor: SystemMouseCursors.resizeLeftRight,+ child: Container(+ width: 2,+ margin: EdgeInsets.symmetric(horizontal: 2),+ color: isHovering+ ? Theme.of(context).colorScheme.primary+ : Colors.transparent,+ ),+ );+ },+ ),+ ),+ );+ }++ void _onHorizontalDragStart(DragStartDetails details) {+ isDragging = true;+ }++ void _onHorizontalDragUpdate(DragUpdateDetails details) {+ if (!isDragging) {+ return;+ }++ // update the column width in memory+ final columnNode = widget.columnNode;+ final rect = columnNode.rect;+ final width =+ columnNode.attributes[SimpleColumnBlockKeys.width] ?? rect.width;+ final newWidth = width + details.delta.dx;+ final transaction = widget.editorState.transaction;+ transaction.updateNode(columnNode, {+ ...columnNode.attributes,+ SimpleColumnBlockKeys.width: newWidth.clamp(+ SimpleColumnsBlockConstants.minimumColumnWidth,+ double.infinity,+ ),+ });+ final columnsNode = columnNode.parent;+ if (columnsNode != null) {+ transaction.updateNode(columnsNode, {+ ...columnsNode.attributes,+ ColumnsBlockKeys.columnCount: columnsNode.children.length,+ });+ }+ widget.editorState.apply(+ transaction,+ options: ApplyOptions(inMemoryUpdate: true),+ );+ }++ void _onHorizontalDragEnd(DragEndDetails details) {+ isHovering.value = false;++ if (!isDragging) {+ return;+ }++ // apply the transaction again to make sure the width is updated+ final transaction = widget.editorState.transaction;+ transaction.updateNode(widget.columnNode, {+ ...widget.columnNode.attributes,+ });+ widget.editorState.apply(transaction);++ isDragging = false;+ }++ void _onHorizontalDragCancel() {+ isDragging = false;+ isHovering.value = false;+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_node_extension.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_node_extension.dartnew file mode 100644index 0000000000..3f4f73fd49--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_node_extension.dart@@ -0,0 +1,34 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy_editor/appflowy_editor.dart';++extension SimpleColumnNodeExtension on Node {+ /// Returns the parent [Node] of the current node if it is a [SimpleColumnsBlock].+ Node? get parentColumnsBlock {+ Node? currentNode = parent;+ while (currentNode != null) {+ if (currentNode.type == SimpleColumnsBlockKeys.type) {+ return currentNode;+ }+ currentNode = currentNode.parent;+ }+ return null;+ }++ /// Returns the parent [Node] of the current node if it is a [SimpleColumnBlock].+ Node? get parentColumn {+ Node? currentNode = parent;+ while (currentNode != null) {+ if (currentNode.type == SimpleColumnBlockKeys.type) {+ return currentNode;+ }+ currentNode = currentNode.parent;+ }+ return null;+ }++ /// Returns whether the current node is in a [SimpleColumnsBlock].+ bool get isInColumnsBlock => parentColumnsBlock != null;++ /// Returns whether the current node is in a [SimpleColumnBlock].+ bool get isInColumnBlock => parentColumn != null;+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_component.dartnew file mode 100644index 0000000000..cd7b2190cd--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_component.dart@@ -0,0 +1,224 @@+import 'package:appflowy/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy_backend/log.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:collection/collection.dart';+import 'package:flutter/material.dart';+import 'package:provider/provider.dart';++// if the children is not provided, it will create two columns by default.+// if the columnCount is provided, it will create the specified number of columns.+Node simpleColumnsNode({+ List<Node>? children,+ int? columnCount,+}) {+ columnCount ??= 2;+ children ??= List.generate(+ columnCount,+ (index) => simpleColumnNode(children: [paragraphNode()]),+ );++ // check the type of children+ for (final child in children) {+ if (child.type != SimpleColumnBlockKeys.type) {+ Log.error('the type of children must be column, but got ${child.type}');+ }+ }++ return Node(+ type: SimpleColumnsBlockKeys.type,+ children: children,+ );+}++class SimpleColumnsBlockKeys {+ const SimpleColumnsBlockKeys._();++ static const String type = 'simple_columns';+}++class SimpleColumnsBlockComponentBuilder extends BlockComponentBuilder {+ SimpleColumnsBlockComponentBuilder({super.configuration});++ @override+ BlockComponentWidget build(BlockComponentContext blockComponentContext) {+ final node = blockComponentContext.node;+ return ColumnsBlockComponent(+ key: node.key,+ node: node,+ showActions: showActions(node),+ configuration: configuration,+ actionBuilder: (_, state) => actionBuilder(blockComponentContext, state),+ );+ }++ @override+ BlockComponentValidate get validate => (node) => node.children.isNotEmpty;+}++class ColumnsBlockComponent extends BlockComponentStatefulWidget {+ const ColumnsBlockComponent({+ super.key,+ required super.node,+ super.showActions,+ super.actionBuilder,+ super.configuration = const BlockComponentConfiguration(),+ });++ @override+ State<ColumnsBlockComponent> createState() => ColumnsBlockComponentState();+}++class ColumnsBlockComponentState extends State<ColumnsBlockComponent>+ with SelectableMixin, BlockComponentConfigurable {+ @override+ BlockComponentConfiguration get configuration => widget.configuration;++ @override+ Node get node => widget.node;++ RenderBox? get _renderBox => context.findRenderObject() as RenderBox?;++ final columnsKey = GlobalKey();++ late final EditorState editorState = context.read<EditorState>();++ @override+ void initState() {+ super.initState();+ }++ @override+ void dispose() {+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ Widget child = IntrinsicHeight(+ child: Row(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: _buildChildren(),+ ),+ );++ child = Padding(+ key: columnsKey,+ padding: padding,+ child: child,+ );++ if (SimpleColumnsBlockConstants.enableDebugBorder) {+ child = DecoratedBox(+ decoration: BoxDecoration(+ border: Border.all(+ color: Colors.red,+ width: 3.0,+ ),+ ),+ child: child,+ );+ }++ // the columns block does not support the block actions and selection+ // because the columns block is a layout wrapper, it does not have a content+ return child;+ }++ List<Widget> _buildChildren() {+ final children = <Widget>[];+ for (var i = 0; i < node.children.length; i++) {+ final childNode = node.children[i];+ final double? width = childNode.attributes[SimpleColumnBlockKeys.width];+ Widget child = editorState.renderer.build(context, childNode);++ if (width != null) {+ child = SizedBox(+ width: width.clamp(+ SimpleColumnsBlockConstants.minimumColumnWidth,+ double.infinity,+ ),+ child: child,+ );+ } else {+ child = Expanded(+ child: child,+ );+ }++ children.add(child);++ if (i != node.children.length - 1) {+ children.add(+ ColumnBlockWidthResizer(+ columnNode: childNode,+ editorState: editorState,+ ),+ );+ }+ }+ return children;+ }++ @override+ Position start() => Position(path: widget.node.path);++ @override+ Position end() => Position(path: widget.node.path, offset: 1);++ @override+ Position getPositionInOffset(Offset start) => end();++ @override+ bool get shouldCursorBlink => false;++ @override+ CursorStyle get cursorStyle => CursorStyle.cover;++ @override+ Rect getBlockRect({+ bool shiftWithBaseOffset = false,+ }) {+ return getRectsInSelection(Selection.invalid()).first;+ }++ @override+ Rect? getCursorRectInPosition(+ Position position, {+ bool shiftWithBaseOffset = false,+ }) {+ final rects = getRectsInSelection(+ Selection.collapsed(position),+ shiftWithBaseOffset: shiftWithBaseOffset,+ );+ return rects.firstOrNull;+ }++ @override+ List<Rect> getRectsInSelection(+ Selection selection, {+ bool shiftWithBaseOffset = false,+ }) {+ if (_renderBox == null) {+ return [];+ }+ final parentBox = context.findRenderObject();+ final renderBox = columnsKey.currentContext?.findRenderObject();+ if (parentBox is RenderBox && renderBox is RenderBox) {+ return [+ renderBox.localToGlobal(Offset.zero, ancestor: parentBox) &+ renderBox.size,+ ];+ }+ return [Offset.zero & _renderBox!.size];+ }++ @override+ Selection getSelectionInRange(Offset start, Offset end) =>+ Selection.single(path: widget.node.path, startOffset: 0, endOffset: 1);++ @override+ Offset localToGlobal(Offset offset, {bool shiftWithBaseOffset = false}) =>+ _renderBox!.localToGlobal(offset);+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dartnew file mode 100644index 0000000000..977974a32e--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_columns_block_constant.dart@@ -0,0 +1,6 @@+class SimpleColumnsBlockConstants {+ const SimpleColumnsBlockConstants._();++ static const double minimumColumnWidth = 128;+ static const bool enableDebugBorder = false;+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dartindex 99211920fa..e56ccfc941 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart@@ -1,8 +1,7 @@import 'dart:convert';import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';-import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table.dart';-import 'package:appflowy/plugins/document/presentation/editor_plugins/sub_page/sub_page_block_component.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:flutter/material.dart';@@ -98,7 +97,13 @@ Document _buildCopiedDocument(// if the node is a table cell, we will fetch its children instead.filteredNodes.addAll(node.children);} else if (node.type == SimpleTableRowBlockKeys.type) {- // if the node is a table row, we will fetch its children instead.+ // if the node is a table row, we will fetch its children's children instead.+ filteredNodes.addAll(node.children.expand((e) => e.children));+ } else if (node.type == SimpleColumnBlockKeys.type) {+ // if the node is a column block, we will fetch its children instead.+ filteredNodes.addAll(node.children);+ } else if (node.type == SimpleColumnsBlockKeys.type) {+ // if the node is a columns block, we will fetch its children's children instead.filteredNodes.addAll(node.children.expand((e) => e.children));} else {filteredNodes.add(node);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dartindex a7d63f2786..baf9a21b3a 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart@@ -1,5 +1,8 @@export 'actions/block_action_list.dart';export 'actions/option/option_actions.dart';+export 'ai/ai_writer_block_component.dart';+export 'ai/ask_ai_block_component.dart';+export 'ai/ask_ai_toolbar_item.dart';export 'align_toolbar_item/align_toolbar_item.dart';export 'base/backtick_character_command.dart';export 'base/cover_title_command.dart';@@ -8,6 +11,10 @@ export 'bulleted_list/bulleted_list_icon.dart';export 'callout/callout_block_component.dart';export 'code_block/code_block_language_selector.dart';export 'code_block/code_block_menu_item.dart';+export 'columns/simple_column_block_component.dart';+export 'columns/simple_column_block_width_resizer.dart';+export 'columns/simple_column_node_extension.dart';+export 'columns/simple_columns_block_component.dart';export 'context_menu/custom_context_menu.dart';export 'copy_and_paste/custom_copy_command.dart';export 'copy_and_paste/custom_cut_command.dart';@@ -53,9 +60,6 @@ export 'mobile_toolbar_v3/toolbar_item_builder.dart';export 'mobile_toolbar_v3/undo_redo_toolbar_item.dart';export 'mobile_toolbar_v3/util.dart';export 'numbered_list/numbered_list_icon.dart';-export 'ai/ai_writer_block_component.dart';-export 'ai/ask_ai_block_component.dart';-export 'ai/ask_ai_toolbar_item.dart';export 'outline/outline_block_component.dart';export 'parsers/document_markdown_parsers.dart';export 'parsers/markdown_parsers.dart';diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/columns_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/columns_item.dartnew file mode 100644index 0000000000..2deabd3e9e--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/columns_item.dart@@ -0,0 +1,92 @@+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/base/selectable_svg_widget.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/slash_menu_item_builder.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:easy_localization/easy_localization.dart';++final _baseKeywords = [+ 'columns',+ 'column block',+];++final _twoColumnsKeywords = [+ ..._baseKeywords,+ 'two columns',+ '2 columns',+];++final _threeColumnsKeywords = [+ ..._baseKeywords,+ 'three columns',+ '3 columns',+];++final _fourColumnsKeywords = [+ ..._baseKeywords,+ 'four columns',+ '4 columns',+];++final _fiveColumnsKeywords = [+ ..._baseKeywords,+ 'five columns',+ '5 columns',+];++// 2 columns menu item+SelectionMenuItem twoColumnsSlashMenuItem = SelectionMenuItem.node(+ getName: () => LocaleKeys.document_slashMenu_name_twoColumns.tr(),+ keywords: _twoColumnsKeywords,+ nodeBuilder: (_, __) => simpleColumnsNode(columnCount: 2),+ replace: (_, node) => node.delta?.isEmpty ?? false,+ nameBuilder: slashMenuItemNameBuilder,+ iconBuilder: (_, isSelected, style) => SelectableSvgWidget(+ data: FlowySvgs.slash_menu_icon_two_columns_s,+ isSelected: isSelected,+ style: style,+ ),+);++// 3 columns menu item+SelectionMenuItem threeColumnsSlashMenuItem = SelectionMenuItem.node(+ getName: () => LocaleKeys.document_slashMenu_name_threeColumns.tr(),+ keywords: _threeColumnsKeywords,+ nodeBuilder: (_, __) => simpleColumnsNode(columnCount: 3),+ replace: (_, node) => node.delta?.isEmpty ?? false,+ nameBuilder: slashMenuItemNameBuilder,+ iconBuilder: (_, isSelected, style) => SelectableSvgWidget(+ data: FlowySvgs.slash_menu_icon_three_columns_s,+ isSelected: isSelected,+ style: style,+ ),+);++// 4 columns menu item+SelectionMenuItem fourColumnsSlashMenuItem = SelectionMenuItem.node(+ getName: () => LocaleKeys.document_slashMenu_name_fourColumns.tr(),+ keywords: _fourColumnsKeywords,+ nodeBuilder: (_, __) => simpleColumnsNode(columnCount: 4),+ replace: (_, node) => node.delta?.isEmpty ?? false,+ nameBuilder: slashMenuItemNameBuilder,+ iconBuilder: (_, isSelected, style) => SelectableSvgWidget(+ data: FlowySvgs.slash_menu_icon_four_columns_s,+ isSelected: isSelected,+ style: style,+ ),+);++// 5 columns menu item+SelectionMenuItem fiveColumnsSlashMenuItem = SelectionMenuItem.node(+ getName: () => '5 Columns',+ keywords: _fiveColumnsKeywords,+ nodeBuilder: (_, __) => simpleColumnsNode(columnCount: 5),+ replace: (_, node) => node.delta?.isEmpty ?? false,+ nameBuilder: slashMenuItemNameBuilder,+ iconBuilder: (_, isSelected, style) => SelectableSvgWidget(+ data: FlowySvgs.slash_menu_icon_code_block_s,+ isSelected: isSelected,+ style: style,+ ),+);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/slash_menu_items.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/slash_menu_items.dartindex ee76bc0ea3..223d8e742b 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/slash_menu_items.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/slash_menu_items.dart@@ -2,6 +2,7 @@ export 'ai_writer_item.dart';export 'bulleted_list_item.dart';export 'callout_item.dart';export 'code_block_item.dart';+export 'columns_item.dart';export 'database_items.dart';export 'date_item.dart';export 'divider_item.dart';diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items_builder.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items_builder.dartindex 2cbc723a57..eb4ce5946b 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items_builder.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items_builder.dart@@ -80,6 +80,12 @@ List<SelectionMenuItem> _defaultSlashMenuItems({// link to pagelinkToPageSlashMenuItem,+ // columns+ // 2-4 columns+ twoColumnsSlashMenuItem,+ threeColumnsSlashMenuItem,+ fourColumnsSlashMenuItem,+// gridif (documentBloc != null) gridSlashMenuItem(documentBloc),referencedGridSlashMenuItem,diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dartindex c5df72dd0c..1f32c94cf4 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart@@ -280,6 +280,15 @@ class EditorStyleCustomizer {selectionMenuItemSelectedIconColor: theme.colorScheme.onSurface,selectionMenuItemSelectedTextColor: theme.colorScheme.onSurface,selectionMenuItemSelectedColor: afThemeExtension.greyHover,+ selectionMenuUnselectedLabelColor: afThemeExtension.onBackground,+ selectionMenuDividerColor: afThemeExtension.greyHover,+ selectionMenuLinkBorderColor: afThemeExtension.greyHover,+ selectionMenuInvalidLinkColor: afThemeExtension.onBackground,+ selectionMenuButtonColor: afThemeExtension.greyHover,+ selectionMenuButtonTextColor: afThemeExtension.onBackground,+ selectionMenuButtonIconColor: afThemeExtension.onBackground,+ selectionMenuButtonBorderColor: afThemeExtension.greyHover,+ selectionMenuTabIndicatorColor: afThemeExtension.greyHover,);}diff --git a/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart b/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dartindex 58d6aacbc3..a0f5b0bafe 100644--- a/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart+++ b/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart@@ -6,8 +6,8 @@ import 'package:appflowy/env/cloud_env.dart';import 'package:appflowy/user/application/auth/device_id.dart';import 'package:appflowy_backend/appflowy_backend.dart';import 'package:flutter/foundation.dart';-import 'package:path_provider/path_provider.dart';import 'package:path/path.dart' as path;+import 'package:path_provider/path_provider.dart';import '../startup.dart';diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex d08161d850..3174f2f1c5 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -90,8 +90,8 @@ packages:dependency: "direct main"description:path: "."- ref: "2745294"- resolved-ref: "2745294587cd3e2ff7ac0b6b91135c3ddcbb4274"+ ref: "400083f"+ resolved-ref: "400083fde6a1a77229416a55c50279f5f5b3f55b"url: "https://github.com/AppFlowy-IO/appflowy-editor.git"source: gitversion: "5.0.0"diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex 39ed088126..8f72fcafc9 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -179,7 +179,7 @@ dependency_overrides:appflowy_editor:git:url: https://github.com/AppFlowy-IO/appflowy-editor.git- ref: "2745294"+ ref: "400083f"appflowy_editor_plugins:git:diff --git a/frontend/resources/flowy_icons/16x/slash_menu_icon_four_columns.svg b/frontend/resources/flowy_icons/16x/slash_menu_icon_four_columns.svgnew file mode 100644index 0000000000..aa4dbff160--- /dev/null+++ b/frontend/resources/flowy_icons/16x/slash_menu_icon_four_columns.svg@@ -0,0 +1,3 @@+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M6 17.5V2.5M10 17.5V2.5M14 17.5V2.5M2 9.16667C2 6.02397 2 4.45263 2.93726 3.47631C3.87452 2.5 5.38301 2.5 8.4 2.5H11.6C14.617 2.5 16.1255 2.5 17.0627 3.47631C18 4.45263 18 6.02397 18 9.16667V10.8333C18 13.976 18 15.5474 17.0627 16.5237C16.1255 17.5 14.617 17.5 11.6 17.5H8.4C5.38301 17.5 3.87452 17.5 2.93726 16.5237C2 15.5474 2 13.976 2 10.8333V9.16667Z" stroke="#1F2329" stroke-width="1.25" stroke-linecap="round"/>+</svg>diff --git a/frontend/resources/flowy_icons/16x/slash_menu_icon_three_columns.svg b/frontend/resources/flowy_icons/16x/slash_menu_icon_three_columns.svgnew file mode 100644index 0000000000..6eb3aeab2b--- /dev/null+++ b/frontend/resources/flowy_icons/16x/slash_menu_icon_three_columns.svg@@ -0,0 +1,3 @@+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M7 17.5V2.5M13 17.5V2.5M2 9.16667C2 6.02397 2 4.45263 2.93726 3.47631C3.87452 2.5 5.38301 2.5 8.4 2.5H11.6C14.617 2.5 16.1255 2.5 17.0627 3.47631C18 4.45263 18 6.02397 18 9.16667V10.8333C18 13.976 18 15.5474 17.0627 16.5237C16.1255 17.5 14.617 17.5 11.6 17.5H8.4C5.38301 17.5 3.87452 17.5 2.93726 16.5237C2 15.5474 2 13.976 2 10.8333V9.16667Z" stroke="#1F2329" stroke-width="1.25" stroke-linecap="round"/>+</svg>diff --git a/frontend/resources/flowy_icons/16x/slash_menu_icon_two_columns.svg b/frontend/resources/flowy_icons/16x/slash_menu_icon_two_columns.svgnew file mode 100644index 0000000000..b3b3e55452--- /dev/null+++ b/frontend/resources/flowy_icons/16x/slash_menu_icon_two_columns.svg@@ -0,0 +1,3 @@+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M10 17.5V2.5M2 9.16667C2 6.02397 2 4.45263 2.93726 3.47631C3.87452 2.5 5.38301 2.5 8.4 2.5H11.6C14.617 2.5 16.1255 2.5 17.0627 3.47631C18 4.45263 18 6.02397 18 9.16667V10.8333C18 13.976 18 15.5474 17.0627 16.5237C16.1255 17.5 14.617 17.5 11.6 17.5H8.4C5.38301 17.5 3.87452 17.5 2.93726 16.5237C2 15.5474 2 13.976 2 10.8333V9.16667Z" stroke="#1F2329" stroke-width="1.25" stroke-linecap="round"/>+</svg>diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex bd054dabd3..d5be5f22f7 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -1736,7 +1736,10 @@"aiWriter": "AI Writer","dateOrReminder": "Date or Reminder","photoGallery": "Photo Gallery",- "file": "File"+ "file": "File",+ "twoColumns": "Two Columns",+ "threeColumns": "Three Columns",+ "fourColumns": "Four Columns"},"subPage": {"name": "Document",