diff --git a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart index 83fc24c204..5c695fa508 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart @@ -190,9 +190,10 @@ class _DocumentPageState extends State ), header: buildCoverAndIcon(context, state), initialSelection: initialSelection, - placeholderText: (node) => node.type == ParagraphBlockKeys.type - ? LocaleKeys.editor_slashPlaceHolder.tr() - : '', + placeholderText: (node) => + node.type == ParagraphBlockKeys.type && !node.isInTable + ? LocaleKeys.editor_slashPlaceHolder.tr() + : '', ), ); } 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 20bba4f083..d2716fd716 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart @@ -162,13 +162,12 @@ class _AppFlowyEditorPageState extends State editorLaunchUrl = (url) { if (url != null) { - afLaunchUrlString(url); + afLaunchUrlString(url, addingHttpSchemeWhenFailed: true); } return Future.value(true); }; - effectiveScrollController = widget.scrollController ?? ScrollController(); // disable the color parse in the HTML decoder. DocumentHTMLDecoder.enableColorParse = false; 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.dart index bf9b1bdc7a..f38d1d7257 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,3 +1,4 @@ +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'; @@ -51,17 +52,36 @@ Future dragToMoveNode( final transaction = editorState.transaction; final targetNodeParent = targetNode.parentColumnsBlock; if (targetNodeParent != null) { + final length = targetNodeParent.children.length; final columnNode = simpleColumnNode( children: [node.deepCopy()], + width: (node.rect.width * 1 / (length + 1)).clamp( + SimpleColumnsBlockConstants.minimumColumnWidth, + double.infinity, + ), ); + for (final column in targetNodeParent.children) { + final width = + column.attributes[SimpleColumnBlockKeys.width]?.toDouble() ?? + SimpleColumnsBlockConstants.minimumColumnWidth; + transaction.updateNode(column, { + ...column.attributes, + SimpleColumnBlockKeys.width: (width * length / (length + 1)).clamp( + SimpleColumnsBlockConstants.minimumColumnWidth, + double.infinity, + ), + }); + } + transaction.insertNode(targetNode.path.next, columnNode); transaction.deleteNode(node); } else { + final width = targetNode.rect.width / 2 - 16; final columnsNode = simpleColumnsNode( children: [ - simpleColumnNode(children: [targetNode.deepCopy()]), - simpleColumnNode(children: [node.deepCopy()]), + simpleColumnNode(children: [targetNode.deepCopy()], width: width), + simpleColumnNode(children: [node.deepCopy()], width: width), ], ); @@ -82,14 +102,28 @@ Future dragToMoveNode( final targetNodeParent = targetNode.parentColumnsBlock; if (targetNodeParent != null) { // find the previous sibling node of the target node - final width = (node.rect.width / - (targetNode.parentColumnsBlock?.children.length ?? 2)) - - 16; + final length = targetNodeParent.children.length; final columnNode = simpleColumnNode( children: [node.deepCopy()], - width: width, + width: (node.rect.width * 1 / (length + 1)).clamp( + SimpleColumnsBlockConstants.minimumColumnWidth, + double.infinity, + ), ); + for (final column in targetNodeParent.children) { + final width = + column.attributes[SimpleColumnBlockKeys.width]?.toDouble() ?? + SimpleColumnsBlockConstants.minimumColumnWidth; + transaction.updateNode(column, { + ...column.attributes, + SimpleColumnBlockKeys.width: (width * length / (length + 1)).clamp( + SimpleColumnsBlockConstants.minimumColumnWidth, + double.infinity, + ), + }); + } + transaction.insertNode(targetNode.path.previous, columnNode); transaction.deleteNode(node); } else { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart index 36936f36a9..e818e9437b 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart @@ -235,7 +235,7 @@ class MarkdownTextRobot { List? children; if (node.children.isNotEmpty) { children = node.children - .map((child) => _styleDelta(node: node, attributes: attributes)) + .map((child) => _styleDelta(node: child, attributes: attributes)) .toList(); } 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.dart index 849d5afd4c..43fd779d33 100644 --- 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.dart @@ -88,13 +88,12 @@ class ColumnsBlockComponentState extends State late final EditorState editorState = context.read(); - @override - void initState() { - super.initState(); - } + final ScrollController scrollController = ScrollController(); @override void dispose() { + scrollController.dispose(); + super.dispose(); } @@ -102,6 +101,7 @@ class ColumnsBlockComponentState extends State Widget build(BuildContext context) { Widget child = SingleChildScrollView( scrollDirection: Axis.horizontal, + controller: scrollController, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: _buildChildren(), @@ -111,6 +111,7 @@ class ColumnsBlockComponentState extends State if (UniversalPlatform.isDesktop) { // only show the scrollbar on desktop child = Scrollbar( + controller: scrollController, child: child, ); } @@ -149,8 +150,9 @@ class ColumnsBlockComponentState extends State final children = []; for (var i = 0; i < node.children.length; i++) { final childNode = node.children[i]; - final width = childNode.attributes[SimpleColumnBlockKeys.width] ?? - SimpleColumnsBlockConstants.minimumColumnWidth; + final width = + childNode.attributes[SimpleColumnBlockKeys.width]?.toDouble() ?? + SimpleColumnsBlockConstants.minimumColumnWidth; Widget child = editorState.renderer.build(context, childNode); child = SizedBox( 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.dart index 977974a32e..d8820f8613 100644 --- 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.dart @@ -1,6 +1,6 @@ class SimpleColumnsBlockConstants { const SimpleColumnsBlockConstants._(); - static const double minimumColumnWidth = 128; + static const double minimumColumnWidth = 128.0; static const bool enableDebugBorder = false; }