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.

feat: turn into page (sub page block) (#6685)

Mathias Mogensenaf390f584e79
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_sub_page_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_sub_page_test.dart
index ebb3df08da..efcb915468 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_sub_page_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_sub_page_test.dart
@@ -456,6 +456,49 @@ void main() {
expect(afterNode.type, beforeNode.type);
expect(find.byType(SubPageBlockComponent), findsOneWidget);
});
+
+ testWidgets('turn into page', (tester) async {
+ await tester.initializeAppFlowy();
+ await tester.tapAnonymousSignInButton();
+ await tester.createNewPageWithNameUnderParent(name: 'SubPageBlock');
+
+ final editorState = tester.editor.getCurrentEditorState();
+
+ // Insert nested list
+ final transaction = editorState.transaction;
+ transaction.insertNode(
+ [0],
+ bulletedListNode(
+ text: 'Parent',
+ children: [
+ bulletedListNode(text: 'Child 1'),
+ bulletedListNode(text: 'Child 2'),
+ ],
+ ),
+ );
+ await editorState.apply(transaction);
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SubPageBlockComponent), findsNothing);
+
+ await tester.editor.hoverAndClickOptionMenuButton([0]);
+ await tester.tapButtonWithName(
+ LocaleKeys.document_plugins_optionAction_turnInto.tr(),
+ );
+ await tester.pumpAndSettle();
+
+ await tester.tap(find.text(LocaleKeys.editor_page.tr()));
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SubPageBlockComponent), findsOneWidget);
+
+ await tester.expandOrCollapsePage(
+ pageName: 'SubPageBlock',
+ layout: ViewLayoutPB.Document,
+ );
+
+ expect(find.text('Parent'), findsNWidgets(2));
+ });
});
}
diff --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.dart
index 0f4057be7a..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
@@ -6,7 +6,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/image/multi_image_block_component/image_render.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/layouts/image_browser_layout.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_placeholder.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/upload_image_menu/upload_image_menu.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/upload_image_menu/widgets/embed_image_url_widget.dart';
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 043b618634..752e04f6f9 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
@@ -4,10 +4,7 @@ import 'package:appflowy/plugins/document/application/document_bloc.dart';
import 'package:appflowy/plugins/document/presentation/editor_page.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/mobile_block_action_buttons.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/code_block/code_block_copy_button.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/sub_page/sub_page_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_notification.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_notification.dart
index 6c7d4df5c4..fce8b4c16e 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_notification.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_notification.dart
@@ -9,7 +9,8 @@ enum EditorNotificationType {
exitEditing,
paste,
dragStart,
- dragEnd
+ dragEnd,
+ turnInto,
}
class EditorNotification {
@@ -21,6 +22,7 @@ class EditorNotification {
EditorNotification.paste() : type = EditorNotificationType.paste;
EditorNotification.dragStart() : type = EditorNotificationType.dragStart;
EditorNotification.dragEnd() : type = EditorNotificationType.dragEnd;
+ EditorNotification.turnInto() : type = EditorNotificationType.turnInto;
static final PropertyValueNotifier<EditorNotificationType> _notifier =
PropertyValueNotifier(EditorNotificationType.none);
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 86a462667c..f15f39ef44 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
@@ -1,11 +1,17 @@
+import 'dart:math';
+
import 'package:appflowy/plugins/document/application/document_bloc.dart';
+import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';
import 'package:appflowy/plugins/document/presentation/editor_notification.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/shared/share/constants.dart';
import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/workspace/application/view/prelude.dart';
+import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart';
+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -175,6 +181,9 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return false;
}
+ // Notify the transaction service that the next apply is from turn into action
+ EditorNotification.turnInto().post();
+
final toType = type;
// only handle the node in the same depth
@@ -193,6 +202,15 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return true;
}
+ // try to turn into a page block
+ if (await turnIntoPage(
+ type: toType,
+ selectedNodes: selectedNodes,
+ selection: selection,
+ )) {
+ return true;
+ }
+
final insertedNode = <Node>[];
for (final node in selectedNodes) {
@@ -337,6 +355,126 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {
return true;
}
+ Future<bool> turnIntoPage({
+ required String type,
+ required List<Node> selectedNodes,
+ required Selection selection,
+ }) async {
+ if (type != SubPageBlockKeys.type || selectedNodes.isEmpty) {
+ return false;
+ }
+
+ if (selectedNodes.length == 1 &&
+ selectedNodes.first.type == SubPageBlockKeys.type) {
+ return true;
+ }
+
+ Log.info('Turn into page');
+
+ final insertedNodes = selectedNodes.map((n) => n.copyWith()).toList();
+ final document = Document.blank()..insert([0], insertedNodes);
+ final name = _extractNameFromNodes(selectedNodes);
+
+ final viewResult = await ViewBackendService.createView(
+ layoutType: ViewLayoutPB.Document,
+ name: name,
+ parentViewId: getIt<MenuSharedState>().latestOpenView?.id ?? '',
+ initialDataBytes:
+ DocumentDataPBFromTo.fromDocument(document)?.writeToBuffer(),
+ );
+
+ await viewResult.fold(
+ (view) async {
+ final viewIdsToMove = _extractChildViewIds(selectedNodes);
+
+ for (final viewId in viewIdsToMove) {
+ await ViewBackendService.moveViewV2(
+ viewId: viewId,
+ newParentId: view.id,
+ prevViewId: null,
+ );
+ }
+
+ final node = subPageNode(viewId: view.id);
+ final transaction = editorState.transaction;
+ transaction
+ ..insertNode(selection.normalized.start.path.next, node)
+ ..deleteNodes(selectedNodes)
+ ..afterSelection = Selection.collapsed(selection.normalized.start);
+ editorState.selectionType = SelectionType.inline;
+
+ await editorState.apply(transaction);
+ },
+ (err) async => Log.error(err),
+ );
+
+ return true;
+ }
+
+ String _extractNameFromNodes(List<Node>? nodes) {
+ if (nodes == null || nodes.isEmpty) {
+ return '';
+ }
+
+ String name = '';
+ for (final node in nodes) {
+ if (node.delta != null) {
+ final text = node.delta!.toPlainText();
+ if (text == MentionBlockKeys.mentionChar) {
+ continue;
+ }
+
+ name = text.substring(0, min(text.length, 30));
+ if (name.isNotEmpty) {
+ break;
+ }
+ }
+
+ if (node.children.isNotEmpty) {
+ final n = _extractNameFromNodes(node.children);
+ if (n.isNotEmpty) {
+ name = n;
+ break;
+ }
+ }
+ }
+
+ return name;
+ }
+
+ List<String> _extractChildViewIds(List<Node> nodes) {
+ final List<String> viewIds = [];
+ for (final node in nodes) {
+ if (node.type == SubPageBlockKeys.type) {
+ final viewId = node.attributes[SubPageBlockKeys.viewId];
+ viewIds.add(viewId);
+ }
+
+ if (node.children.isNotEmpty) {
+ viewIds.addAll(_extractChildViewIds(node.children));
+ }
+
+ if (node.delta == null || node.delta!.isEmpty) {
+ continue;
+ }
+
+ final textInserts = node.delta!.whereType<TextInsert>();
+ for (final ti in textInserts) {
+ final Map<String, dynamic>? mention =
+ ti.attributes?[MentionBlockKeys.mention];
+ if (mention != null &&
+ mention[MentionBlockKeys.type] == MentionType.childPage.name) {
+ final String? viewId = mention[MentionBlockKeys.pageId];
+ if (viewId != null) {
+ viewIds.add(viewId);
+ }
+ }
+ }
+ }
+
+ return viewIds;
+ }
+
Selection? calculateTurnIntoSelection(
Node selectedNode,
Selection? beforeSelection,
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button_feedback.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button_feedback.dart
index d7faecd506..1f04021569 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button_feedback.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button_feedback.dart
@@ -2,8 +2,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_button.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/string_extension.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/reminder/reminder_bloc.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/option_actions.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/option_actions.dart
index 09b7581918..a654d2de84 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/option_actions.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/option_actions.dart
@@ -29,6 +29,7 @@ enum EditorOptionActionType {
NumberedListBlockKeys.type,
TodoListBlockKeys.type,
ToggleListBlockKeys.type,
+ SubPageBlockKeys.type,
};
case EditorOptionActionType.color:
return {
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 6c1dda404c..806418ffb1 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
@@ -239,6 +239,8 @@ class _TurnInfoButton extends StatelessWidget {
return FlowySvgs.slash_menu_icon_checkbox_s;
} else if (type == CalloutBlockKeys.type) {
return FlowySvgs.slash_menu_icon_callout_s;
+ } else if (type == SubPageBlockKeys.type) {
+ return FlowySvgs.document_s;
} else if (type == ToggleListBlockKeys.type) {
switch (level) {
case 1:
@@ -283,6 +285,8 @@ class _TurnInfoButton extends StatelessWidget {
return LocaleKeys.document_slashMenu_name_todoList.tr();
case CalloutBlockKeys.type:
return LocaleKeys.document_slashMenu_name_callout.tr();
+ case SubPageBlockKeys.type:
+ return LocaleKeys.editor_page.tr();
case ToggleListBlockKeys.type:
switch (level) {
case 1:
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/insert_page_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/insert_page_command.dart
index ff529029f4..af605972de 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/insert_page_command.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/insert_page_command.dart
@@ -1,6 +1,5 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/domain/database_view_service.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/image_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/image_menu.dart
index 8fabb23948..a584acbae1 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/image_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/image_menu.dart
@@ -3,11 +3,9 @@ import 'dart:ui';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/application/document_bloc.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/align_toolbar_item/align_toolbar_item.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/block_menu/block_menu_button.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/common.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation_toolbar_item.dart
index 0311d57c08..061a6fe320 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation_toolbar_item.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation_toolbar_item.dart
@@ -1,6 +1,5 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/child_page_transaction_handler.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/child_page_transaction_handler.dart
index 5c02837329..491bf10fa5 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/child_page_transaction_handler.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/child_page_transaction_handler.dart
@@ -28,9 +28,10 @@ class ChildPageTransactionHandler extends MentionTransactionHandler {
bool isUndoRedo = false,
bool isPaste = false,
bool isDraggingNode = false,
+ bool isTurnInto = false,
String? parentViewId,
}) async {
- if (isDraggingNode) {
+ if (isDraggingNode || isTurnInto) {
return;
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart
index 7535d38852..c6a91b2d81 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart
@@ -34,6 +34,7 @@ import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:universal_platform/universal_platform.dart';
@@ -187,7 +188,11 @@ class _MentionSubPageBlockState extends State<MentionSubPageBlock> {
}
if (state.view!.parentViewId != currentViewId) {
- turnIntoPageRef();
+ SchedulerBinding.instance.addPostFrameCallback((_) {
+ if (context.mounted) {
+ turnIntoPageRef();
+ }
+ });
}
}
},
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/add_block_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/add_block_toolbar_item.dart
index 34daa2bcfc..60d566396f 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/add_block_toolbar_item.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/add_block_toolbar_item.dart
@@ -7,9 +7,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/base/type_option_menu_item.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/image_placeholder.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_placeholder.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mobile_toolbar_item/mobile_add_block_toolbar_item.dart';
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.dart
index a4927f566d..56e34975cb 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
@@ -63,3 +63,7 @@ export 'table/table_option_action.dart';
export 'todo_list/todo_list_icon.dart';
export 'toggle/toggle_block_component.dart';
export 'toggle/toggle_block_shortcuts.dart';
+export 'sub_page/sub_page_block_component.dart';
+export 'mention/mention_block.dart';
+export 'image/custom_image_block_component/custom_image_block_component.dart';
+export 'image/multi_image_block_component/multi_image_block_component.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items.dart
index 7bfcaa68f7..52c643168c 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items.dart
@@ -7,7 +7,6 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/base/selec
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/image_placeholder.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/slash_menu_items.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/sub_page/sub_page_block_component.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_menu_item.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/sub_page/sub_page_transaction_handler.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/sub_page/sub_page_transaction_handler.dart
index 3e3347a36b..b7d784d534 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/sub_page/sub_page_transaction_handler.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/sub_page/sub_page_transaction_handler.dart
@@ -28,9 +28,10 @@ class SubPageTransactionHandler extends BlockTransactionHandler {
bool isUndoRedo = false,
bool isPaste = false,
bool isDraggingNode = false,
+ bool isTurnInto = false,
String? parentViewId,
}) async {
- if (isDraggingNode) {
+ if (isDraggingNode || isTurnInto) {
return;
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_handler.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_handler.dart
index f7517e7fca..334f649341 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_handler.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_handler.dart
@@ -32,6 +32,7 @@ abstract class EditorTransactionHandler<T> {
bool isUndoRedo = false,
bool isPaste = false,
bool isDraggingNode = false,
+ bool isTurnInto = false,
String? parentViewId,
});
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_service.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_service.dart
index a82a6cba70..222671f15c 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_service.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/transaction_handler/editor_transaction_service.dart
@@ -45,6 +45,7 @@ class _EditorTransactionServiceState extends State<EditorTransactionService> {
bool isUndoRedo = false;
bool isPaste = false;
bool isDraggingNode = false;
+ bool isTurnInto = false;
@override
void initState() {
@@ -76,6 +77,8 @@ class _EditorTransactionServiceState extends State<EditorTransactionService> {
isDraggingNode = true;
} else if (type == EditorNotificationType.dragEnd) {
isDraggingNode = false;
+ } else if (type == EditorNotificationType.turnInto) {
+ isTurnInto = true;
}
if (type == EditorNotificationType.undo) {
@@ -224,12 +227,14 @@ class _EditorTransactionServiceState extends State<EditorTransactionService> {
isUndoRedo: isUndoRedo,
isPaste: isPaste,
isDraggingNode: isDraggingNode,
+ isTurnInto: isTurnInto,
parentViewId: widget.viewId,
);
}
isUndoRedo = false;
isPaste = false;
+ isTurnInto = false;
}
/// Takes an iterable of [TextInsert] and returns a list of [MentionBlockData].
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart
index 0303743337..6e6ab845c3 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart
@@ -5,7 +5,6 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/font_colors.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mobile_toolbar_item/utils.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/inline_actions/inline_actions_menu.dart';
diff --git a/frontend/appflowy_flutter/test/unit_test/editor/editor_drop_test.dart b/frontend/appflowy_flutter/test/unit_test/editor/editor_drop_test.dart
index 9d798c3768..b17588674c 100644
--- a/frontend/appflowy_flutter/test/unit_test/editor/editor_drop_test.dart
+++ b/frontend/appflowy_flutter/test/unit_test/editor/editor_drop_test.dart
@@ -1,6 +1,5 @@
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_file.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_image.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:cross_file/cross_file.dart';