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
fix: do not rely on getIt in turnIntoBlock (#6693)
Mathias Mogensen7cf0c4b16b60
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.dartindex f15f39ef44..3621707ac6 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@@ -8,7 +8,6 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.daimport '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';@@ -175,6 +174,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {String type,Node node, {int? level,+ String? currentViewId,}) async {final selection = editorState.selection;if (selection == null) {@@ -203,11 +203,13 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {}// try to turn into a page block- if (await turnIntoPage(- type: toType,- selectedNodes: selectedNodes,- selection: selection,- )) {+ if (currentViewId != null &&+ await turnIntoPage(+ type: toType,+ selectedNodes: selectedNodes,+ selection: selection,+ currentViewId: currentViewId,+ )) {return true;}@@ -359,6 +361,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {required String type,required List<Node> selectedNodes,required Selection selection,+ required String currentViewId,}) async {if (type != SubPageBlockKeys.type || selectedNodes.isEmpty) {return false;@@ -378,7 +381,7 @@ class BlockActionOptionCubit extends Cubit<BlockActionOptionState> {final viewResult = await ViewBackendService.createView(layoutType: ViewLayoutPB.Document,name: name,- parentViewId: getIt<MenuSharedState>().latestOpenView?.id ?? '',+ parentViewId: currentViewId,initialDataBytes:DocumentDataPBFromTo.fromDocument(document)?.writeToBuffer(),);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.dartindex 806418ffb1..8dec2eaf66 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@@ -2,6 +2,8 @@ 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_option_cubit.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:easy_localization/easy_localization.dart';@@ -178,6 +180,7 @@ class _TurnInfoButton extends StatelessWidget {type,node,level: level,+ currentViewId: getIt<MenuSharedState>().latestOpenView?.id,);},);diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 6011fbc02e..24305a7cff 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -994,10 +994,10 @@ packages:dependency: transitivedescription:name: image- sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8"+ sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7durl: "https://pub.dev"source: hosted- version: "4.2.0"+ version: "4.3.0"image_picker:dependency: "direct main"description: