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: nested list issue in quote/callout block (#7513)

Lucas1f76412790ce
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
index c22cbb648c..3889a7d1d3 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
@@ -37,6 +37,7 @@ final Set<String> supportSlashMenuNodeTypes = {
NumberedListBlockKeys.type,
QuoteBlockKeys.type,
ToggleListBlockKeys.type,
+ CalloutBlockKeys.type,
// Simple table
SimpleTableBlockKeys.type,
@@ -130,7 +131,8 @@ BlockComponentConfiguration _buildDefaultConfiguration(BuildContext context) {
// in the quote block, we reduce the indent padding for the first level block.
// So we have to add more padding for the second level to avoid the drag menu overlay the quote icon.
- if (node.isInQuote && node.level == 2 && UniversalPlatform.isDesktop) {
+ if (node.parent?.type == QuoteBlockKeys.type &&
+ UniversalPlatform.isDesktop) {
padding += 22;
}
@@ -615,6 +617,13 @@ QuoteBlockComponentBuilder _buildQuoteBlockComponentBuilder(
if (UniversalPlatform.isMobile) {
return configuration.indentPadding(node, textDirection);
}
+
+ if (node.isInTable) {
+ return textDirection == TextDirection.ltr
+ ? EdgeInsets.only(left: 24)
+ : EdgeInsets.only(right: 24);
+ }
+
return EdgeInsets.zero;
},
),
@@ -1096,16 +1105,3 @@ TextAlign _buildTextAlignInTableCell(
return node.tableAlign.textAlign;
}
-
-extension on Node {
- bool get isInQuote {
- Node? parent = this.parent;
- while (parent != null) {
- if (parent.type == QuoteBlockKeys.type) {
- return true;
- }
- parent = parent.parent;
- }
- return false;
- }
-}
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 9c5302bcd8..97cceb1aa8 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
@@ -19,7 +19,7 @@ import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy/workspace/application/view/view_lock_status_bloc.dart';
import 'package:appflowy/workspace/application/view_info/view_info_bloc.dart';
import 'package:appflowy/workspace/presentation/home/af_focus_manager.dart';
-import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:appflowy_editor/appflowy_editor.dart' hide QuoteBlockKeys;
import 'package:collection/collection.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flutter/material.dart';
@@ -158,10 +158,12 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>
indentableBlockTypes.addAll([
ToggleListBlockKeys.type,
CalloutBlockKeys.type,
+ QuoteBlockKeys.type,
]);
convertibleBlockTypes.addAll([
ToggleListBlockKeys.type,
CalloutBlockKeys.type,
+ QuoteBlockKeys.type,
]);
editorLaunchUrl = (url) {
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 733da3fd71..f3074781b4 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
@@ -322,9 +322,8 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
},
);
- // heading block and callout block should not have children
- if ([HeadingBlockKeys.type, CalloutBlockKeys.type, QuoteBlockKeys.type]
- .contains(toType)) {
+ // heading block should not have children
+ if ([HeadingBlockKeys.type].contains(toType)) {
afterNode = afterNode.copyWith(children: []);
afterNode = await _handleSubPageNode(afterNode, node);
insertedNode.add(afterNode);
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 c816934976..ca99491b94 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
@@ -188,7 +188,6 @@ Future<void> dragToMoveNode(
Node dragTargetNode,
Offset dragOffset,
) {
- debugPrint('getDragAreaPosition - dragTargetNode: ${dragTargetNode.type}');
final selectable = dragTargetNode.selectable;
final renderBox = selectable?.context.findRenderObject() as RenderBox?;
if (selectable == null || renderBox == null) {
@@ -247,10 +246,6 @@ Future<void> dragToMoveNode(
verticalPosition = VerticalPosition.bottom;
}
- debugPrint(
- 'verticalPosition: $verticalPosition, horizontalPosition: $horizontalPosition',
- );
-
return (verticalPosition, horizontalPosition, globalBlockRect);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart
index 1e8d981c15..522b694edb 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart
@@ -185,6 +185,22 @@ class _CalloutBlockComponentWidgetState
return result;
}
+ @override
+ Widget build(BuildContext context) {
+ Widget child = node.children.isEmpty
+ ? buildComponent(context)
+ : buildComponentWithChildren(context);
+
+ if (UniversalPlatform.isDesktop) {
+ child = Padding(
+ padding: EdgeInsets.symmetric(vertical: 2.0),
+ child: child,
+ );
+ }
+
+ return child;
+ }
+
@override
Widget buildComponentWithChildren(BuildContext context) {
Widget child = Stack(
@@ -287,7 +303,7 @@ class _CalloutBlockComponentWidgetState
child: child,
);
} else {
- child = Padding(
+ child = Container(
key: blockComponentKey,
padding: EdgeInsets.zero,
child: child,
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.dart
index a7259d54b1..979dd92ce0 100644
--- 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.dart
@@ -1,5 +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_editor/appflowy_editor.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
@@ -119,9 +118,6 @@ class SimpleColumnBlockComponentState extends State<SimpleColumnBlockComponent>
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(
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/callout_node_parser.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/callout_node_parser.dart
index b16a44cf6f..d9cf060e3b 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/callout_node_parser.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/callout_node_parser.dart
@@ -10,7 +10,6 @@ class CalloutNodeParser extends NodeParser {
@override
String transform(Node node, DocumentMarkdownEncoder? encoder) {
- assert(node.children.isEmpty);
final delta = node.delta ?? Delta()
..insert('');
final String markdown = DeltaMarkdownEncoder()
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_component.dart
index 211a99c1bf..76f42c54b1 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_component.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_component.dart
@@ -267,8 +267,13 @@ class _QuoteBlockComponentWidgetState extends State<QuoteBlockComponentWidget>
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final renderObject = layoutBuilderKey.currentContext?.findRenderObject();
if (renderObject != null && renderObject is RenderBox) {
- quoteBlockHeightNotifier.value =
- renderObject.size.height - padding.top * 2;
+ if (UniversalPlatform.isMobile) {
+ quoteBlockHeightNotifier.value =
+ renderObject.size.height - padding.top;
+ } else {
+ quoteBlockHeightNotifier.value =
+ renderObject.size.height - padding.top * 2;
+ }
} else {
quoteBlockHeightNotifier.value = 0;
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_shortcuts.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_shortcuts.dart
index 835d7bb47a..914aa7163c 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_shortcuts.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/quote/quote_block_shortcuts.dart
@@ -31,7 +31,9 @@ CharacterShortcutEventHandler _insertNewLineHandler = (editorState) async {
if (HardwareKeyboard.instance.isShiftPressed) {
await editorState.insertNewLine();
- } else if (node.children.isEmpty) {
+ return true;
+ } else if (node.children.isEmpty &&
+ selection.endIndex == node.delta?.length) {
// insert a new paragraph within the callout block
final path = node.path.child(0);
final transaction = editorState.transaction;
@@ -45,7 +47,8 @@ CharacterShortcutEventHandler _insertNewLineHandler = (editorState) async {
),
);
await editorState.apply(transaction);
+ return true;
}
- return true;
+ return false;
};
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_shortcuts/simple_table_enter_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_shortcuts/simple_table_enter_command.dart
index 74bdc3fc62..bfc31e8abc 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_shortcuts/simple_table_enter_command.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_shortcuts/simple_table_enter_command.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table_cell_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table_shortcuts/simple_table_command_extension.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
@@ -40,7 +41,9 @@ KeyEventResult _enterInTableCellHandler(EditorState editorState) {
return KeyEventResult.handled;
}
}
- return convertToParagraphCommand.execute(editorState);
+ if (node.type != CalloutBlockKeys.type) {
+ return convertToParagraphCommand.execute(editorState);
+ }
}
return KeyEventResult.ignored;
diff --git a/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart b/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart
index a0f5b0bafe..55f2f53512 100644
--- a/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart
+++ b/frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart
@@ -5,7 +5,6 @@ import 'package:appflowy/env/backend_env.dart';
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/path.dart' as path;
import 'package:path_provider/path_provider.dart';
@@ -29,7 +28,6 @@ class InitRustSDKTask extends LaunchTask {
final dir = customApplicationPath ?? applicationPath;
final deviceId = await getDeviceId();
- debugPrint('application path: ${applicationPath.path}');
// Pass the environment variables to the Rust SDK
final env = _makeAppFlowyConfiguration(
root.path,
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 d4b0bfa45c..adf2857edb 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
@@ -164,8 +164,6 @@ void main() {
for (final type in [
HeadingBlockKeys.type,
- QuoteBlockKeys.type,
- CalloutBlockKeys.type,
]) {
test('from nested bulleted list to $type', () async {
const text = 'bulleted list';
@@ -230,8 +228,6 @@ void main() {
for (final type in [
HeadingBlockKeys.type,
- QuoteBlockKeys.type,
- CalloutBlockKeys.type,
]) {
test('from nested numbered list to $type', () async {
const text = 'numbered list';
@@ -296,8 +292,6 @@ void main() {
for (final type in [
HeadingBlockKeys.type,
- QuoteBlockKeys.type,
- CalloutBlockKeys.type,
]) {
// numbered list, bulleted list, todo list
// before
@@ -392,6 +386,8 @@ void main() {
BulletedListBlockKeys.type,
NumberedListBlockKeys.type,
TodoListBlockKeys.type,
+ QuoteBlockKeys.type,
+ CalloutBlockKeys.type,
]) {
// numbered list, bulleted list, todo list
// before