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: 0.7.0 launch review issues (#6365)
Lucasf0a494b41dd4
diff --git a/frontend/appflowy_flutter/integration_test/cloud/cloud_runner.dart b/frontend/appflowy_flutter/integration_test/cloud/cloud_runner.dartindex 3a72f012d6..da20597f45 100644--- a/frontend/appflowy_flutter/integration_test/cloud/cloud_runner.dart+++ b/frontend/appflowy_flutter/integration_test/cloud/cloud_runner.dart@@ -1,6 +1,8 @@import 'anon_user_continue_test.dart' as anon_user_continue_test;import 'appflowy_cloud_auth_test.dart' as appflowy_cloud_auth_test;+import 'document/document_drag_block_test.dart' as document_drag_block_test;import 'empty_test.dart' as preset_af_cloud_env_test;+import 'sidebar/sidebar_move_page_test.dart' as sidebar_move_page_test;import 'user_setting_sync_test.dart' as user_sync_test;import 'workspace/change_name_and_icon_test.dart'as change_workspace_name_and_icon_test;@@ -16,4 +18,10 @@ Future<void> main() async {// workspacecollaboration_workspace_test.main();change_workspace_name_and_icon_test.main();++ // document+ document_drag_block_test.main();++ // sidebar+ sidebar_move_page_test.main();}diff --git a/frontend/appflowy_flutter/integration_test/cloud/document/document_drag_block_test.dart b/frontend/appflowy_flutter/integration_test/cloud/document/document_drag_block_test.dartnew file mode 100644index 0000000000..43b4c29dc5--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/cloud/document/document_drag_block_test.dart@@ -0,0 +1,91 @@+// ignore_for_file: unused_import++import 'dart:io';++import 'package:appflowy/env/cloud_env.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart';+import 'package:appflowy/shared/feature_flags.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart';+import 'package:appflowy/user/application/auth/auth_service.dart';+import 'package:appflowy/workspace/application/settings/prelude.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart';+import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra/uuid.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';+import 'package:path/path.dart' as p;++import '../../shared/constants.dart';+import '../../shared/database_test_op.dart';+import '../../shared/dir.dart';+import '../../shared/emoji.dart';+import '../../shared/mock/mock_file_picker.dart';+import '../../shared/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ group('document drag block: ', () {+ testWidgets('drag block to the top', (tester) async {+ await tester.initializeAppFlowy(+ cloudType: AuthenticatorType.appflowyCloudSelfHost,+ );+ await tester.tapGoogleLoginInButton();+ await tester.expectToSeeHomePageWithGetStartedPage();++ // open getting started page+ await tester.openPage(Constants.gettingStartedPageName);++ // before move+ final beforeMoveBlock = tester.editor.getNodeAtPath([1]);++ // move the desktop guide to the top, above the getting started+ await tester.editor.dragBlock(+ [1],+ const Offset(20, -80),+ );++ // wait for the move animation to complete+ await tester.pumpAndSettle(Durations.short1);++ // check if the block is moved to the top+ final afterMoveBlock = tester.editor.getNodeAtPath([0]);+ expect(afterMoveBlock.delta, beforeMoveBlock.delta);+ });++ testWidgets('drag block to other block\'s child', (tester) async {+ await tester.initializeAppFlowy(+ cloudType: AuthenticatorType.appflowyCloudSelfHost,+ );+ await tester.tapGoogleLoginInButton();+ await tester.expectToSeeHomePageWithGetStartedPage();++ // open getting started page+ await tester.openPage(Constants.gettingStartedPageName);++ // before move+ final beforeMoveBlock = tester.editor.getNodeAtPath([10]);++ // move the checkbox to the child of the block at path [9]+ await tester.editor.dragBlock(+ [10],+ const Offset(80, -30),+ );++ // wait for the move animation to complete+ await tester.pumpAndSettle(Durations.short1);++ // check if the block is moved to the child of the block at path [9]+ final afterMoveBlock = tester.editor.getNodeAtPath([9, 0]);+ expect(afterMoveBlock.delta, beforeMoveBlock.delta);+ });+ });+}diff --git a/frontend/appflowy_flutter/integration_test/cloud/sidebar/sidebar_move_page_test.dart b/frontend/appflowy_flutter/integration_test/cloud/sidebar/sidebar_move_page_test.dartnew file mode 100644index 0000000000..8b72c8cd3d--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/cloud/sidebar/sidebar_move_page_test.dart@@ -0,0 +1,111 @@+// ignore_for_file: unused_import++import 'dart:io';++import 'package:appflowy/env/cloud_env.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart';+import 'package:appflowy/shared/feature_flags.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart';+import 'package:appflowy/user/application/auth/auth_service.dart';+import 'package:appflowy/workspace/application/settings/prelude.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart';+import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra/uuid.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';+import 'package:path/path.dart' as p;++import '../../shared/constants.dart';+import '../../shared/database_test_op.dart';+import '../../shared/dir.dart';+import '../../shared/emoji.dart';+import '../../shared/mock/mock_file_picker.dart';+import '../../shared/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ group('sidebar move page: ', () {+ testWidgets('create a new document and move it to Getting started',+ (tester) async {+ await tester.initializeAppFlowy(+ cloudType: AuthenticatorType.appflowyCloudSelfHost,+ );+ await tester.tapGoogleLoginInButton();+ await tester.expectToSeeHomePageWithGetStartedPage();++ const pageName = 'Document';++ await tester.createNewPageInSpace(+ spaceName: Constants.generalSpaceName,+ layout: ViewLayoutPB.Document,+ pageName: pageName,+ );++ // click the ... button and move to Getting started+ await tester.hoverOnPageName(+ pageName,+ onHover: () async {+ await tester.tapPageOptionButton();+ await tester.tapButtonWithName(+ LocaleKeys.disclosureAction_moveTo.tr(),+ );+ },+ );++ // expect to see two pages+ // 1. Getting started+ // 2. To-dos+ final gettingStarted = find.text(Constants.gettingStartedPageName);+ // one is in the sidebar, the other is in the move to page list+ expect(gettingStarted, findsNWidgets(2));+ final toDos = find.text(Constants.toDosPageName);+ expect(toDos, findsNWidgets(2));++ // hover on the todos page, and will see a forbidden icon+ await tester.hoverOnWidget(+ toDos.last,+ onHover: () async {+ final tooltips = find.byTooltip(+ LocaleKeys.space_cannotMovePageToDatabase.tr(),+ );+ expect(tooltips, findsOneWidget);+ },+ );+ await tester.pumpAndSettle();++ // move the current page to Getting started+ await tester.tapButton(+ gettingStarted.last,+ );++ await tester.pumpAndSettle();++ // after moving, expect to not see the page name in the sidebar+ final page = tester.findPageName(pageName);+ expect(page, findsNothing);++ // click to expand the getting started page+ await tester.expandOrCollapsePage(+ pageName: Constants.gettingStartedPageName,+ layout: ViewLayoutPB.Document,+ );+ await tester.pumpAndSettle();++ // expect to see the page name in the getting started page+ final pageInGettingStarted = tester.findPageName(+ pageName,+ parentName: Constants.gettingStartedPageName,+ );+ expect(pageInGettingStarted, findsOneWidget);+ });+ });+}diff --git a/frontend/appflowy_flutter/integration_test/cloud/workspace/collaborative_workspace_test.dart b/frontend/appflowy_flutter/integration_test/cloud/workspace/collaborative_workspace_test.dartindex 059b609fc7..c33c4b7424 100644--- a/frontend/appflowy_flutter/integration_test/cloud/workspace/collaborative_workspace_test.dart+++ b/frontend/appflowy_flutter/integration_test/cloud/workspace/collaborative_workspace_test.dart@@ -32,69 +32,66 @@ import '../../shared/util.dart';void main() {IntegrationTestWidgetsFlutterBinding.ensureInitialized();- // final email = '${uuid()}@appflowy.io';-- group('collaborative workspace', () {+ group('collaborative workspace: ', () {// combine the create and delete workspace test to reduce the timetestWidgets('create a new workspace, open it and then delete it',(tester) async {// only run the test when the feature flag is on- // if (!FeatureFlag.collaborativeWorkspace.isOn) {- // return;- // }+ if (!FeatureFlag.collaborativeWorkspace.isOn) {+ return;+ }- // await tester.initializeAppFlowy(- // cloudType: AuthenticatorType.appflowyCloudSelfHost,- // email: email,- // );- // await tester.tapGoogleLoginInButton();- // await tester.expectToSeeHomePageWithGetStartedPage();+ await tester.initializeAppFlowy(+ cloudType: AuthenticatorType.appflowyCloudSelfHost,+ );+ await tester.tapGoogleLoginInButton();+ await tester.expectToSeeHomePageWithGetStartedPage();- // const name = 'AppFlowy.IO';- // // the workspace will be opened after created- // await tester.createCollaborativeWorkspace(name);+ const name = 'AppFlowy.IO';+ // the workspace will be opened after created+ await tester.createCollaborativeWorkspace(name);- // final loading = find.byType(Loading);- // await tester.pumpUntilNotFound(loading);+ final loading = find.byType(Loading);+ await tester.pumpUntilNotFound(loading);- // Finder success;+ Finder success;- // final Finder items = find.byType(WorkspaceMenuItem);+ final Finder items = find.byType(WorkspaceMenuItem);- // // delete the newly created workspace- // await tester.openCollaborativeWorkspaceMenu();- // await tester.pumpUntilFound(items);+ // delete the newly created workspace+ await tester.openCollaborativeWorkspaceMenu();+ await tester.pumpUntilFound(items);- // expect(items, findsNWidgets(2));- // expect(- // tester.widget<WorkspaceMenuItem>(items.last).workspace.name,- // name,- // );+ expect(items, findsNWidgets(2));+ expect(+ tester.widget<WorkspaceMenuItem>(items.last).workspace.name,+ name,+ );- // final secondWorkspace = find.byType(WorkspaceMenuItem).last;- // await tester.hoverOnWidget(- // secondWorkspace,- // onHover: () async {- // // click the more button- // final moreButton = find.byType(WorkspaceMoreActionList);- // expect(moreButton, findsOneWidget);- // await tester.tapButton(moreButton);- // // click the delete button- // final deleteButton = find.text(LocaleKeys.button_delete.tr());- // expect(deleteButton, findsOneWidget);- // await tester.tapButton(deleteButton);- // // see the delete confirm dialog- // final confirm =- // find.text(LocaleKeys.workspace_deleteWorkspaceHintText.tr());- // expect(confirm, findsOneWidget);- // await tester.tapButton(find.text(LocaleKeys.button_ok.tr()));- // // delete success- // success = find.text(LocaleKeys.workspace_createSuccess.tr());- // await tester.pumpUntilFound(success);- // expect(success, findsOneWidget);- // await tester.pumpUntilNotFound(success);- // },- // );+ final secondWorkspace = find.byType(WorkspaceMenuItem).last;+ await tester.hoverOnWidget(+ secondWorkspace,+ onHover: () async {+ // click the more button+ final moreButton = find.byType(WorkspaceMoreActionList);+ expect(moreButton, findsOneWidget);+ await tester.tapButton(moreButton);+ // click the delete button+ final deleteButton = find.text(LocaleKeys.button_delete.tr());+ expect(deleteButton, findsOneWidget);+ await tester.tapButton(deleteButton);+ // see the delete confirm dialog+ final confirm =+ find.text(LocaleKeys.workspace_deleteWorkspaceHintText.tr());+ expect(confirm, findsOneWidget);+ await tester.tapButton(find.text(LocaleKeys.button_ok.tr()));+ // delete success+ success = find.text(LocaleKeys.workspace_createSuccess.tr());+ await tester.pumpUntilFound(success);+ expect(success, findsOneWidget);+ await tester.pumpUntilNotFound(success);+ },+ );});});}diff --git a/frontend/appflowy_flutter/integration_test/cloud/workspace/workspace_settings_test.dart b/frontend/appflowy_flutter/integration_test/cloud/workspace/workspace_settings_test.dartnew file mode 100644index 0000000000..4cdb75e8ab--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/cloud/workspace/workspace_settings_test.dart@@ -0,0 +1,96 @@+// ignore_for_file: unused_import++import 'dart:io';++import 'package:appflowy/env/cloud_env.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart';+import 'package:appflowy/plugins/document/presentation/editor_style.dart';+import 'package:appflowy/shared/feature_flags.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart';+import 'package:appflowy/user/application/auth/auth_service.dart';+import 'package:appflowy/workspace/application/settings/prelude.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart';+import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart';+import 'package:appflowy/workspace/presentation/settings/shared/setting_list_tile.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart';+import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra/uuid.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';+import 'package:path/path.dart' as p;++import '../../shared/database_test_op.dart';+import '../../shared/dir.dart';+import '../../shared/emoji.dart';+import '../../shared/mock/mock_file_picker.dart';+import '../../shared/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ group('workspace settings: ', () {+ testWidgets(+ 'change document width',+ (tester) async {+ await tester.initializeAppFlowy(+ cloudType: AuthenticatorType.appflowyCloudSelfHost,+ );+ await tester.tapGoogleLoginInButton();+ await tester.expectToSeeHomePageWithGetStartedPage();++ await tester.openSettings();+ await tester.openSettingsPage(SettingsPage.workspace);++ final documentWidthSettings = find.findTextInFlowyText(+ LocaleKeys.settings_appearance_documentSettings_width.tr(),+ );++ final scrollable = find.ancestor(+ of: find.byType(SettingsWorkspaceView),+ matching: find.descendant(+ of: find.byType(SingleChildScrollView),+ matching: find.byType(Scrollable),+ ),+ );++ await tester.scrollUntilVisible(+ documentWidthSettings,+ 0,+ scrollable: scrollable,+ );+ await tester.pumpAndSettle();++ // change the document width+ final slider = find.byType(Slider);+ final oldValue = tester.widget<Slider>(slider).value;+ await tester.drag(slider, const Offset(100, 0));+ await tester.pumpAndSettle();++ // check the document width is changed+ expect(tester.widget<Slider>(slider).value, greaterThan(oldValue));++ // click the reset button+ final resetButton = find.descendant(+ of: find.byType(DocumentPaddingSetting),+ matching: find.byType(SettingsResetButton),+ );+ await tester.tap(resetButton);+ await tester.pumpAndSettle();++ // check the document width is reset+ expect(+ tester.widget<Slider>(slider).value,+ EditorStyleCustomizer.maxDocumentWidth,+ );+ },+ );+ });+}diff --git a/frontend/appflowy_flutter/integration_test/desktop/reminder/document_reminder_test.dart b/frontend/appflowy_flutter/integration_test/desktop/reminder/document_reminder_test.dartindex 2a1f0fe3e4..bdfe2dae9f 100644--- a/frontend/appflowy_flutter/integration_test/desktop/reminder/document_reminder_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/reminder/document_reminder_test.dart@@ -15,7 +15,7 @@ import 'package:integration_test/integration_test.dart';import '../../shared/base.dart';import '../../shared/common_operations.dart';-import '../../shared/editor_test_operations.dart';+import '../../shared/document_test_operations.dart';import '../../shared/expectation.dart';import '../../shared/keyboard.dart';diff --git a/frontend/appflowy_flutter/integration_test/shared/common_operations.dart b/frontend/appflowy_flutter/integration_test/shared/common_operations.dartindex 2d0fba0e95..aad72c7f53 100644--- a/frontend/appflowy_flutter/integration_test/shared/common_operations.dart+++ b/frontend/appflowy_flutter/integration_test/shared/common_operations.dart@@ -12,11 +12,14 @@ import 'package:appflowy/startup/startup.dart';import 'package:appflowy/user/presentation/screens/screens.dart';import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/widgets.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/sidebar_new_page_button.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/shared_widget.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart';import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart';+import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_more_action_button.dart';import 'package:appflowy/workspace/presentation/notifications/widgets/flowy_tab.dart';import 'package:appflowy/workspace/presentation/notifications/widgets/notification_button.dart';@@ -243,6 +246,17 @@ extension CommonOperations on WidgetTester {await tapButton(okButton);}+ /// Expand or collapse the page.+ Future<void> expandOrCollapsePage({+ required String pageName,+ required ViewLayoutPB layout,+ }) async {+ final page = findPageName(pageName, layout: layout);+ await hoverOnWidget(page);+ final expandButton = find.byType(ViewItemDefaultLeftIcon);+ await tapButton(expandButton.first);+ }+/// Tap the restore button.////// the restore button will show after the current page is deleted.@@ -324,6 +338,67 @@ extension CommonOperations on WidgetTester {}}+ /// Create a new page in the space+ Future<void> createNewPageInSpace({+ required String spaceName,+ required ViewLayoutPB layout,+ bool openAfterCreated = true,+ String? pageName,+ }) async {+ final currentSpace = find.byWidgetPredicate(+ (widget) => widget is CurrentSpace && widget.space.name == spaceName,+ );+ if (currentSpace.evaluate().isEmpty) {+ throw Exception('Current space not found');+ }++ await hoverOnWidget(+ currentSpace,+ onHover: () async {+ // click the + button+ await clickAddPageButtonInSpaceHeader();+ await tapButtonWithName(layout.menuName);+ },+ );+ await pumpAndSettle();++ if (pageName != null) {+ // move the cursor to other place to disable to tooltips+ await tapAt(Offset.zero);++ // hover on new created page and change it's name+ await hoverOnPageName(+ LocaleKeys.menuAppHeader_defaultNewPageName.tr(),+ layout: layout,+ onHover: () async {+ await renamePage(pageName);+ await pumpAndSettle();+ },+ );+ await pumpAndSettle();+ }++ // open the page after created+ if (openAfterCreated) {+ await openPage(+ // if the name is null, use the default name+ pageName ?? LocaleKeys.menuAppHeader_defaultNewPageName.tr(),+ layout: layout,+ );+ await pumpAndSettle();+ }+ }++ /// Click the + button in the space header+ Future<void> clickAddPageButtonInSpaceHeader() async {+ final addPageButton = find.descendant(+ of: find.byType(SidebarSpaceHeader),+ matching: find.byType(ViewAddButton),+ );+ await tapButton(addPageButton);+ }++ /// Create a new page on the top levelFuture<void> createNewPage({ViewLayoutPB layout = ViewLayoutPB.Document,bool openAfterCreated = true,diff --git a/frontend/appflowy_flutter/integration_test/shared/constants.dart b/frontend/appflowy_flutter/integration_test/shared/constants.dartnew file mode 100644index 0000000000..ffb0109355--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/shared/constants.dart@@ -0,0 +1,6 @@+class Constants {+ // this page name is default page name in the new workspace+ static const gettingStartedPageName = 'Getting started';+ static const toDosPageName = 'To-dos';+ static const generalSpaceName = 'General';+}diff --git a/frontend/appflowy_flutter/integration_test/shared/editor_test_operations.dart b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dartsimilarity index 84%rename from frontend/appflowy_flutter/integration_test/shared/editor_test_operations.dartrename to frontend/appflowy_flutter/integration_test/shared/document_test_operations.dartindex 7189a958be..d754519ffa 100644--- a/frontend/appflowy_flutter/integration_test/shared/editor_test_operations.dart+++ b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart@@ -5,6 +5,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/base/emoji/emoji_picker.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_add_button.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_option_button.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/draggable_option_button.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/header/cover_editor.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart';@@ -33,6 +34,11 @@ class EditorOperations {EditorState getCurrentEditorState() =>tester.widget<AppFlowyEditor>(find.byType(AppFlowyEditor)).editorState;+ Node getNodeAtPath(Path path) {+ final editorState = getCurrentEditorState();+ return editorState.getNodeAtPath(path)!;+ }+/// Tap the line of editor at [index]Future<void> tapLineOfEditorAt(int index) async {final textBlocks = find.byType(AppFlowyRichText);@@ -266,4 +272,55 @@ class EditorOperations {},);}++ /// Drag block+ ///+ /// [offset] is the offset to move the block.+ ///+ /// [path] is the path of the block to move.+ Future<void> dragBlock(+ Path path,+ Offset offset,+ ) async {+ final dragToMoveAction = find.byWidgetPredicate(+ (widget) =>+ widget is DraggableOptionButton &&+ widget.blockComponentContext.node.path.equals(path),+ );++ await tester.hoverOnWidget(+ dragToMoveAction,+ onHover: () async {+ final dragToMoveTooltip = find.findFlowyTooltip(+ LocaleKeys.blockActions_dragTooltip.tr(),+ );+ await tester.pumpUntilFound(dragToMoveTooltip);+ final location = tester.getCenter(dragToMoveAction);+ final gesture = await tester.startGesture(+ location,+ pointer: 7,+ );+ await tester.pump();++ // divide the steps to small move to avoid the drag area not found error+ const steps = 5;+ final stepOffset = Offset(offset.dx / steps, offset.dy / steps);++ for (var i = 0; i < steps; i++) {+ await gesture.moveBy(stepOffset);+ await tester.pump(Durations.short1);+ }++ // check if the drag to move action is dragging+ expect(+ isDraggingAppFlowyEditorBlock.value,+ isTrue,+ );++ await gesture.up();+ await tester.pump();+ },+ );+ await tester.pumpAndSettle(Durations.short1);+ }}diff --git a/frontend/appflowy_flutter/integration_test/shared/util.dart b/frontend/appflowy_flutter/integration_test/shared/util.dartindex 283db5f4c0..5073425cad 100644--- a/frontend/appflowy_flutter/integration_test/shared/util.dart+++ b/frontend/appflowy_flutter/integration_test/shared/util.dart@@ -1,9 +1,9 @@+export 'auth_operation.dart';export 'base.dart';export 'common_operations.dart';-export 'settings.dart';export 'data.dart';+export 'document_test_operations.dart';export 'expectation.dart';-export 'editor_test_operations.dart';-export 'mock/mock_url_launcher.dart';export 'ime.dart';-export 'auth_operation.dart';+export 'mock/mock_url_launcher.dart';+export 'settings.dart';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 0822d04db7..339f011d02 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@@ -11,34 +11,42 @@ class BlockActionButton extends StatelessWidget {required this.svg,required this.richMessage,required this.onTap,+ this.showTooltip = true,});final FlowySvgData svg;+ final bool showTooltip;final InlineSpan richMessage;final VoidCallback onTap;@overrideWidget build(BuildContext context) {- return Align(- child: FlowyTooltip(- richMessage: richMessage,- child: MouseRegion(- cursor: Platform.isWindows- ? SystemMouseCursors.click- : SystemMouseCursors.grab,- child: IgnoreParentGestureWidget(- child: GestureDetector(- onTap: onTap,- behavior: HitTestBehavior.deferToChild,- child: FlowySvg(- svg,- size: const Size.square(18.0),- color: Theme.of(context).iconTheme.color,- ),- ),+ Widget child = MouseRegion(+ cursor: Platform.isWindows+ ? SystemMouseCursors.click+ : SystemMouseCursors.grab,+ child: IgnoreParentGestureWidget(+ child: GestureDetector(+ onTap: onTap,+ behavior: HitTestBehavior.deferToChild,+ child: FlowySvg(+ svg,+ size: const Size.square(18.0),+ color: Theme.of(context).iconTheme.color,),),),);++ if (showTooltip) {+ child = FlowyTooltip(+ richMessage: richMessage,+ child: child,+ );+ }++ return Align(+ child: 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 4af564939a..5b58a37a72 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,11 +1,14 @@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/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/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_backend/log.dart';+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/user/application/reminder/reminder_bloc.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_popover/appflowy_popover.dart';import 'package:easy_localization/easy_localization.dart';@@ -13,6 +16,10 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:provider/provider.dart';+// this flag is used to disable the tooltip of the block when it is dragged+@visibleForTesting+ValueNotifier<bool> isDraggingAppFlowyEditorBlock = ValueNotifier(false);+class DraggableOptionButton extends StatefulWidget {const DraggableOptionButton({super.key,@@ -55,59 +62,68 @@ class _DraggableOptionButtonState extends State<DraggableOptionButton> {Widget build(BuildContext context) {return Draggable<Node>(data: node,+ onDragStarted: _onDragStart,+ onDragUpdate: _onDragUpdate,+ onDragEnd: _onDragEnd,feedback: _OptionButtonFeedback(controller: widget.controller,editorState: widget.editorState,blockComponentContext: widget.blockComponentContext,blockComponentBuilder: widget.blockComponentBuilder,),- onDragStarted: () {- widget.editorState.selectionService.removeDropTarget();- },- onDragUpdate: (details) {- widget.editorState.selectionService- .renderDropTargetForOffset(details.globalPosition);+ child: _OptionButton(+ isDragging: isDraggingAppFlowyEditorBlock,+ controller: widget.controller,+ editorState: widget.editorState,+ blockComponentContext: widget.blockComponentContext,+ ),+ );+ }++ void _onDragStart() {+ isDraggingAppFlowyEditorBlock.value = true;+ widget.editorState.selectionService.removeDropTarget();+ }- globalPosition = details.globalPosition;+ void _onDragUpdate(DragUpdateDetails details) {+ isDraggingAppFlowyEditorBlock.value = true;- // auto scroll the page when the drag position is at the edge of the screen- widget.editorState.scrollService?.startAutoScroll(- details.localPosition,+ widget.editorState.selectionService.renderDropTargetForOffset(+ details.globalPosition,+ builder: (context, data) {+ return VisualDragArea(+ data: data,+ dragNode: widget.blockComponentContext.node,);},- onDragEnd: (details) {- widget.editorState.selectionService.removeDropTarget();-- if (globalPosition == null) {- return;- }+ );- final data = widget.editorState.selectionService- .getDropTargetRenderData(globalPosition!);- final acceptedPath = data?.dropPath;+ globalPosition = details.globalPosition;- _moveNodeToNewPosition(node, acceptedPath);- },- child: _OptionButton(- controller: widget.controller,- editorState: widget.editorState,- blockComponentContext: widget.blockComponentContext,- ),+ // auto scroll the page when the drag position is at the edge of the screen+ widget.editorState.scrollService?.startAutoScroll(+ details.localPosition,);}- Future<void> _moveNodeToNewPosition(Node node, Path? acceptedPath) async {- if (acceptedPath == null) {- Log.info('acceptedPath is null');+ void _onDragEnd(DraggableDetails details) {+ isDraggingAppFlowyEditorBlock.value = false;++ widget.editorState.selectionService.removeDropTarget();++ if (globalPosition == null) {return;}- Log.info('move node($node) to path($acceptedPath)');-- final transaction = widget.editorState.transaction;- // use the node in document instead of the local node- transaction.moveNode(acceptedPath, widget.blockComponentContext.node);- await widget.editorState.apply(transaction);+ final data = widget.editorState.selectionService.getDropTargetRenderData(+ globalPosition!,+ );+ dragToMoveNode(+ context,+ node: widget.blockComponentContext.node,+ acceptedPath: data?.cursorNode?.path,+ dragOffset: globalPosition!,+ );}}@@ -204,8 +220,11 @@ class _OptionButtonFeedbackState extends State<_OptionButtonFeedback> {}return IntrinsicHeight(- child: Provider.value(- value: widget.editorState,+ child: MultiProvider(+ providers: [+ Provider.value(value: widget.editorState),+ Provider.value(value: getIt<ReminderBloc>()),+ ],child: builder.build(blockComponentContext),),);@@ -229,42 +248,50 @@ class _OptionButton extends StatelessWidget {required this.controller,required this.editorState,required this.blockComponentContext,+ required this.isDragging,});final PopoverController controller;final EditorState editorState;final BlockComponentContext blockComponentContext;+ final ValueNotifier<bool> isDragging;@overrideWidget build(BuildContext context) {- return BlockActionButton(- svg: FlowySvgs.drag_element_s,- richMessage: TextSpan(- children: [- TextSpan(- text: LocaleKeys.document_plugins_optionAction_drag.tr(),- style: context.tooltipTextStyle(),- ),- TextSpan(- text: LocaleKeys.document_plugins_optionAction_toMove.tr(),- style: context.tooltipTextStyle(),- ),- const TextSpan(text: '\n'),- TextSpan(- text: LocaleKeys.document_plugins_optionAction_click.tr(),- style: context.tooltipTextStyle(),- ),- TextSpan(- text: LocaleKeys.document_plugins_optionAction_toOpenMenu.tr(),- style: context.tooltipTextStyle(),+ return ValueListenableBuilder(+ valueListenable: isDragging,+ builder: (context, isDragging, child) {+ return BlockActionButton(+ svg: FlowySvgs.drag_element_s,+ showTooltip: !isDragging,+ richMessage: TextSpan(+ children: [+ TextSpan(+ text: LocaleKeys.document_plugins_optionAction_drag.tr(),+ style: context.tooltipTextStyle(),+ ),+ TextSpan(+ text: LocaleKeys.document_plugins_optionAction_toMove.tr(),+ style: context.tooltipTextStyle(),+ ),+ const TextSpan(text: '\n'),+ TextSpan(+ text: LocaleKeys.document_plugins_optionAction_click.tr(),+ style: context.tooltipTextStyle(),+ ),+ TextSpan(+ text: LocaleKeys.document_plugins_optionAction_toOpenMenu.tr(),+ style: context.tooltipTextStyle(),+ ),+ ],),- ],- ),- onTap: () {- controller.show();+ onTap: () {+ controller.show();- // update selection- _updateBlockSelection();+ // update selection+ _updateBlockSelection();+ },+ );},);}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.dartnew file mode 100644index 0000000000..32dd53b915--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/util.dart@@ -0,0 +1,128 @@+import 'package:appflowy_backend/log.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/material.dart';+import 'package:provider/provider.dart';++enum HorizontalPosition { left, center, right }++enum VerticalPosition { top, middle, bottom }++Future<void> dragToMoveNode(+ BuildContext context, {+ required Node node,+ required Offset dragOffset,+ Path? acceptedPath,+}) async {+ if (acceptedPath == null) {+ Log.info('acceptedPath is null');+ return;+ }++ final editorState = context.read<EditorState>();+ final targetNode = editorState.getNodeAtPath(acceptedPath);+ if (targetNode == null) {+ Log.info('targetNode is null');+ return;+ }++ final position = getDragAreaPosition(context, targetNode, dragOffset);+ if (position == null) {+ Log.info('position is null');+ return;+ }++ final (verticalPosition, horizontalPosition, _) = position;+ Path newPath = targetNode.path;++ // Determine the new path based on drop position+ // For VerticalPosition.top, we keep the target node's path+ if (verticalPosition == VerticalPosition.bottom) {+ newPath = horizontalPosition == HorizontalPosition.left+ ? newPath.next // Insert after target node+ : newPath.child(0); // Insert as first child of target node+ }++ // Check if the drop should be ignored+ if (shouldIgnoreDragTarget(node, newPath)) {+ Log.info(+ 'Drop ignored: node($node, ${node.path}), path($acceptedPath)',+ );+ return;+ }++ Log.info('Moving node($node, ${node.path}) to path($newPath)');++ // Perform the node move operation+ final transaction = editorState.transaction;+ transaction.deleteNode(node);+ transaction.insertNode(newPath, node.copyWith());+ await editorState.apply(transaction);+}++(VerticalPosition, HorizontalPosition, Rect)? getDragAreaPosition(+ BuildContext context,+ Node dragTargetNode,+ Offset dragOffset,+) {+ final selectable = dragTargetNode.selectable;+ final renderBox = selectable?.context.findRenderObject() as RenderBox?;+ if (selectable == null || renderBox == null) {+ return null;+ }++ // disable the table cell block+ if (dragTargetNode.parent?.type == TableCellBlockKeys.type) {+ return null;+ }++ final globalBlockOffset = renderBox.localToGlobal(Offset.zero);+ final globalBlockRect = globalBlockOffset & renderBox.size;++ // Check if the dragOffset is within the globalBlockRect+ final isInside = globalBlockRect.contains(dragOffset);++ if (!isInside) {+ Log.info(+ 'the drag offset is not inside the block, dragOffset($dragOffset), globalBlockRect($globalBlockRect)',+ );+ return null;+ }++ // Determine the relative position+ HorizontalPosition horizontalPosition = HorizontalPosition.left;+ VerticalPosition verticalPosition;++ // Horizontal position+ if (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+ horizontalPosition = HorizontalPosition.right;+ }++ // Vertical position+ if (dragOffset.dy < globalBlockRect.top + globalBlockRect.height / 2) {+ verticalPosition = VerticalPosition.top;+ } else {+ verticalPosition = VerticalPosition.bottom;+ }++ return (verticalPosition, horizontalPosition, globalBlockRect);+}++bool shouldIgnoreDragTarget(Node dragNode, Path? targetPath) {+ if (targetPath == null) {+ return true;+ }++ if (dragNode.path.equals(targetPath)) {+ return true;+ }++ if (dragNode.path.isAncestorOf(targetPath)) {+ return true;+ }++ return false;+}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.dartnew file mode 100644index 0000000000..c8889cd2e1--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/visual_drag_area.dart@@ -0,0 +1,83 @@+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/material.dart';++import 'util.dart';++class VisualDragArea extends StatelessWidget {+ const VisualDragArea({+ super.key,+ required this.data,+ required this.dragNode,+ });++ final DragAreaBuilderData data;+ final Node dragNode;++ @override+ Widget build(BuildContext context) {+ final targetNode = data.targetNode;++ final ignore = shouldIgnoreDragTarget(dragNode, targetNode.path);+ if (ignore) {+ return const SizedBox.shrink();+ }++ final selectable = targetNode.selectable;+ final renderBox = selectable?.context.findRenderObject() as RenderBox?;+ if (selectable == null || renderBox == null) {+ return const SizedBox.shrink();+ }++ final position = getDragAreaPosition(+ context,+ targetNode,+ data.dragOffset,+ );++ if (position == null) {+ return const SizedBox.shrink();+ }++ final (verticalPosition, horizontalPosition, globalBlockRect) = position;++ // 44 is the width of the drag indicator+ const indicatorWidth = 44.0;+ final width = globalBlockRect.width - indicatorWidth;++ Widget child = Container(+ height: 2,+ width: width,+ color: Theme.of(context).colorScheme.primary,+ );++ if (horizontalPosition == HorizontalPosition.right) {+ const breakWidth = 22.0;+ const padding = 8.0;+ child = Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Container(+ height: 2,+ width: breakWidth,+ color: Theme.of(context).colorScheme.primary,+ ),+ const SizedBox(width: padding),+ Container(+ height: 2,+ width: width - breakWidth - padding,+ color: Theme.of(context).colorScheme.primary,+ ),+ ],+ );+ }++ return Positioned(+ top: verticalPosition == VerticalPosition.top+ ? globalBlockRect.top+ : globalBlockRect.bottom,+ // 44 is the width of the drag indicator+ left: globalBlockRect.left + 44,+ child: child,+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/move_to/move_page_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/move_to/move_page_menu.dartindex 4bd69ad752..feb8253ab6 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/move_to/move_page_menu.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/move_to/move_page_menu.dart@@ -126,10 +126,18 @@ class _MovePageMenuState extends State<MovePageMenu> {space: space,isHovered: isHoveredNotifier,isExpandedNotifier: isExpandedNotifier,- shouldIgnoreView: (view) => _shouldIgnoreView(- view,- widget.sourceView,- ),+ shouldIgnoreView: (view) {+ debugPrint(+ 'view: ${view.id}, layout: ${view.layout}, sourceView: ${widget.sourceView.id}',+ );+ if (_shouldIgnoreView(view, widget.sourceView)) {+ return IgnoreViewType.hide;+ }+ if (view.layout != ViewLayoutPB.Document) {+ return IgnoreViewType.disable;+ }+ return IgnoreViewType.none;+ },// hide the hover status and disable the editing actionsdisableSelectedStatus: true,// hide the ... and + buttons@@ -157,31 +165,29 @@ class _MovePageGroupedViews extends StatelessWidget {return SingleChildScrollView(child: Column(mainAxisSize: MainAxisSize.min,- children: views- .map(- (e) => ViewItem(- key: ValueKey(e.id),- view: e,- spaceType: FolderSpaceType.unknown,- level: 0,- onSelected: (_, view) => onSelected(view),- isFeedback: false,- isDraggable: false,- shouldRenderChildren: false,- leftIconBuilder: (_, __) => const HSpace(0.0),- rightIconsBuilder: (_, view) => [],- ),- )- .toList(),+ children: views.map(+ (e) {+ final child = ViewItem(+ key: ValueKey(e.id),+ view: e,+ spaceType: FolderSpaceType.unknown,+ level: 0,+ onSelected: (_, view) => onSelected(view),+ isFeedback: false,+ isDraggable: false,+ shouldRenderChildren: false,+ leftIconBuilder: (_, __) => const HSpace(0.0),+ rightIconsBuilder: (_, view) => [],+ );++ return child;+ },+ ).toList(),),);}}bool _shouldIgnoreView(ViewPB view, ViewPB sourceView) {- // ignore the source view and database view, don't render it in the list.- if (view.layout != ViewLayoutPB.Document) {- return true;- }return view.id == sourceView.id;}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dartindex 38c42de895..d8831109a4 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart@@ -558,7 +558,7 @@ class SpacePages extends StatelessWidget {final ViewItemRightIconsBuilder? rightIconsBuilder;final ViewItemOnSelected onSelected;final ViewItemOnSelected? onTertiarySelected;- final bool Function(ViewPB view)? shouldIgnoreView;+ final IgnoreViewType Function(ViewPB view)? shouldIgnoreView;@overrideWidget build(BuildContext context) {@@ -571,7 +571,10 @@ class SpacePages extends StatelessWidget {var childViews = state.view.childViews;if (shouldIgnoreView != null) {childViews = childViews- .where((childView) => !shouldIgnoreView!(childView))+ .where(+ (childView) =>+ shouldIgnoreView!(childView) != IgnoreViewType.hide,+ ).toList();}return Column(diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dartindex 4b84c20bb3..ac96ece98f 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart@@ -41,6 +41,12 @@ typedef ViewItemRightIconsBuilder = List<Widget> Function(ViewPB view,);+enum IgnoreViewType {+ none,+ hide,+ disable,+}+class ViewItem extends StatelessWidget {const ViewItem({super.key,@@ -125,7 +131,7 @@ class ViewItem extends StatelessWidget {final bool? disableSelectedStatus;// ignore the views when rendering the child views- final bool Function(ViewPB view)? shouldIgnoreView;+ final IgnoreViewType Function(ViewPB view)? shouldIgnoreView;@overrideWidget build(BuildContext context) {@@ -144,10 +150,14 @@ class ViewItem extends StatelessWidget {var childViews = state.view.childViews;if (shouldIgnoreView != null) {childViews = childViews- .where((childView) => !shouldIgnoreView!(childView))+ .where(+ (childView) =>+ shouldIgnoreView!(childView) != IgnoreViewType.hide,+ ).toList();}- return InnerViewItem(++ final Widget child = InnerViewItem(view: state.view,parentView: parentView,childViews: childViews,@@ -173,6 +183,23 @@ class ViewItem extends StatelessWidget {extendBuilder: extendBuilder,shouldIgnoreView: shouldIgnoreView,);++ if (shouldIgnoreView?.call(view) == IgnoreViewType.disable) {+ return Opacity(+ opacity: 0.5,+ child: FlowyTooltip(+ message: LocaleKeys.space_cannotMovePageToDatabase.tr(),+ child: MouseRegion(+ cursor: SystemMouseCursors.forbidden,+ child: IgnorePointer(+ child: child,+ ),+ ),+ ),+ );+ }++ return child;},),);@@ -239,7 +266,7 @@ class InnerViewItem extends StatefulWidget {final PropertyValueNotifier<bool>? isExpandedNotifier;final List<Widget> Function(ViewPB view)? extendBuilder;- final bool Function(ViewPB view)? shouldIgnoreView;+ final IgnoreViewType Function(ViewPB view)? shouldIgnoreView;@overrideState<InnerViewItem> createState() => _InnerViewItemState();@@ -441,7 +468,7 @@ class SingleInnerViewItem extends StatefulWidget {final ViewItemRightIconsBuilder? rightIconsBuilder;final List<Widget> Function(ViewPB view)? extendBuilder;- final bool Function(ViewPB view)? shouldIgnoreView;+ final IgnoreViewType Function(ViewPB view)? shouldIgnoreView;final bool isSelected;@override@@ -612,39 +639,13 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {// show > if the view is expandable.// show · if the view can't contain child views.Widget _buildLeftIcon() {- if (isReferencedDatabaseView(widget.view, widget.parentView)) {- return const _DotIconWidget();- }-- if (context.read<ViewBloc>().state.view.childViews.isEmpty) {- return HSpace(widget.leftPadding);- }-- final child = FlowyHover(- child: GestureDetector(- child: FlowySvg(- widget.isExpanded- ? FlowySvgs.view_item_expand_s- : FlowySvgs.view_item_unexpand_s,- size: const Size.square(16.0),- ),- onTap: () => context- .read<ViewBloc>()- .add(ViewEvent.setIsExpanded(!widget.isExpanded)),- ),+ return ViewItemDefaultLeftIcon(+ view: widget.view,+ parentView: widget.parentView,+ isExpanded: widget.isExpanded,+ leftPadding: widget.leftPadding,+ isHovered: widget.isHovered,);-- if (widget.isHovered != null) {- return ValueListenableBuilder<bool>(- valueListenable: widget.isHovered!,- builder: (_, isHovered, child) {- return Opacity(opacity: isHovered ? 1.0 : 0.0, child: child);- },- child: child,- );- }-- return child;}// + button@@ -693,92 +694,100 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {Widget _buildViewMoreActionButton(BuildContext context) {return FlowyTooltip(message: LocaleKeys.menuAppHeader_moreButtonToolTip.tr(),- child: ViewMoreActionButton(- view: widget.view,- isExpanded: widget.isExpanded,- spaceType: widget.spaceType,- onEditing: (value) =>- context.read<ViewBloc>().add(ViewEvent.setIsEditing(value)),- onAction: (action, data) async {- switch (action) {- case ViewMoreActionType.favorite:- case ViewMoreActionType.unFavorite:- context- .read<FavoriteBloc>()- .add(FavoriteEvent.toggle(widget.view));- break;- case ViewMoreActionType.rename:- unawaited(- NavigatorTextFieldDialog(- title: LocaleKeys.disclosureAction_rename.tr(),- autoSelectAllText: true,- value: widget.view.name,- maxLength: 256,- onConfirm: (newValue, _) {- context.read<ViewBloc>().add(ViewEvent.rename(newValue));- },- ).show(context),- );- break;- case ViewMoreActionType.delete:- // get if current page contains published child views- final (containPublishedPage, _) =- await ViewBackendService.containPublishedPage(- widget.view,- );- if (containPublishedPage && context.mounted) {- await showConfirmDeletionDialog(- context: context,- name: widget.view.name,- description: LocaleKeys.publish_containsPublishedPage.tr(),- onConfirm: () {- context.read<ViewBloc>().add(const ViewEvent.delete());- },+ child: BlocProvider(+ create: (context) => SpaceBloc(+ userProfile: context.read<SpaceBloc>().userProfile,+ workspaceId: context.read<SpaceBloc>().workspaceId,+ )..add(const SpaceEvent.initial(openFirstPage: false)),+ child: ViewMoreActionButton(+ view: widget.view,+ isExpanded: widget.isExpanded,+ spaceType: widget.spaceType,+ onEditing: (value) =>+ context.read<ViewBloc>().add(ViewEvent.setIsEditing(value)),+ onAction: (action, data) async {+ switch (action) {+ case ViewMoreActionType.favorite:+ case ViewMoreActionType.unFavorite:+ context+ .read<FavoriteBloc>()+ .add(FavoriteEvent.toggle(widget.view));+ break;+ case ViewMoreActionType.rename:+ unawaited(+ NavigatorTextFieldDialog(+ title: LocaleKeys.disclosureAction_rename.tr(),+ autoSelectAllText: true,+ value: widget.view.name,+ maxLength: 256,+ onConfirm: (newValue, _) {+ context.read<ViewBloc>().add(ViewEvent.rename(newValue));+ },+ ).show(context),);- } else if (context.mounted) {- context.read<ViewBloc>().add(const ViewEvent.delete());- }- break;- case ViewMoreActionType.duplicate:- context.read<ViewBloc>().add(const ViewEvent.duplicate());- break;- case ViewMoreActionType.openInNewTab:- context.read<TabsBloc>().openTab(widget.view);- break;- case ViewMoreActionType.collapseAllPages:- context.read<ViewBloc>().add(const ViewEvent.collapseAllPages());- break;- case ViewMoreActionType.changeIcon:- if (data is! EmojiPickerResult) {- return;- }- final result = data;- await ViewBackendService.updateViewIcon(- viewId: widget.view.id,- viewIcon: result.emoji,- iconType: result.type.toProto(),- );- break;- case ViewMoreActionType.moveTo:- final value = data;- if (value is! (ViewPB, ViewPB)) {- return;- }- final space = value.$1;- final target = value.$2;- moveViewCrossSpace(- context,- space,- widget.view,- widget.parentView,- widget.spaceType,- widget.view,- target.id,- );- default:- throw UnsupportedError('$action is not supported');- }- },+ break;+ case ViewMoreActionType.delete:+ // get if current page contains published child views+ final (containPublishedPage, _) =+ await ViewBackendService.containPublishedPage(+ widget.view,+ );+ if (containPublishedPage && context.mounted) {+ await showConfirmDeletionDialog(+ context: context,+ name: widget.view.name,+ description: LocaleKeys.publish_containsPublishedPage.tr(),+ onConfirm: () {+ context.read<ViewBloc>().add(const ViewEvent.delete());+ },+ );+ } else if (context.mounted) {+ context.read<ViewBloc>().add(const ViewEvent.delete());+ }+ break;+ case ViewMoreActionType.duplicate:+ context.read<ViewBloc>().add(const ViewEvent.duplicate());+ break;+ case ViewMoreActionType.openInNewTab:+ context.read<TabsBloc>().openTab(widget.view);+ break;+ case ViewMoreActionType.collapseAllPages:+ context+ .read<ViewBloc>()+ .add(const ViewEvent.collapseAllPages());+ break;+ case ViewMoreActionType.changeIcon:+ if (data is! EmojiPickerResult) {+ return;+ }+ final result = data;+ await ViewBackendService.updateViewIcon(+ viewId: widget.view.id,+ viewIcon: result.emoji,+ iconType: result.type.toProto(),+ );+ break;+ case ViewMoreActionType.moveTo:+ final value = data;+ if (value is! (ViewPB, ViewPB)) {+ return;+ }+ final space = value.$1;+ final target = value.$2;+ moveViewCrossSpace(+ context,+ space,+ widget.view,+ widget.parentView,+ widget.spaceType,+ widget.view,+ target.id,+ );+ default:+ throw UnsupportedError('$action is not supported');+ }+ },+ ),),);}@@ -877,3 +886,56 @@ void moveViewCrossSpace(),);}++class ViewItemDefaultLeftIcon extends StatelessWidget {+ const ViewItemDefaultLeftIcon({+ super.key,+ required this.view,+ required this.parentView,+ required this.isExpanded,+ required this.leftPadding,+ required this.isHovered,+ });++ final ViewPB view;+ final ViewPB? parentView;+ final bool isExpanded;+ final double leftPadding;+ final ValueNotifier<bool>? isHovered;++ @override+ Widget build(BuildContext context) {+ if (isReferencedDatabaseView(view, parentView)) {+ return const _DotIconWidget();+ }++ if (context.read<ViewBloc>().state.view.childViews.isEmpty) {+ return HSpace(leftPadding);+ }++ final child = FlowyHover(+ child: GestureDetector(+ child: FlowySvg(+ isExpanded+ ? FlowySvgs.view_item_expand_s+ : FlowySvgs.view_item_unexpand_s,+ size: const Size.square(16.0),+ ),+ onTap: () =>+ context.read<ViewBloc>().add(ViewEvent.setIsExpanded(!isExpanded)),+ ),+ );++ if (isHovered != null) {+ return ValueListenableBuilder<bool>(+ valueListenable: isHovered!,+ builder: (_, isHovered, child) {+ return Opacity(opacity: isHovered ? 1.0 : 0.0, child: child);+ },+ child: child,+ );+ }++ return child;+ }+}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dartindex 5ff8b815a8..f64971d8dd 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart@@ -6,6 +6,7 @@ import 'package:appflowy/workspace/presentation/home/menu/sidebar/move_to/move_pimport 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.dart';import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_popover/appflowy_popover.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -180,37 +181,44 @@ class ViewMoreActionTypeWrapper extends CustomActionCell {BuildContext context,PopoverController controller,) {+ final userProfile = context.read<SpaceBloc>().userProfile;// move to feature doesn't support in local mode- if (context.read<SpaceBloc>().state.spaces.isEmpty) {+ if (userProfile.authenticator != AuthenticatorPB.AppFlowyCloud) {return const SizedBox.shrink();}-- final child = _buildActionButton(context, null);-- return AppFlowyPopover(- constraints: const BoxConstraints(- maxWidth: 260,- maxHeight: 345,- ),- margin: const EdgeInsets.symmetric(- horizontal: 14.0,- vertical: 12.0,- ),- clickHandler: PopoverClickHandler.gestureDetector,- direction: moveActionDirection ?? PopoverDirection.rightWithTopAligned,- offset: moveActionOffset,- popupBuilder: (_) {- return BlocProvider.value(- value: context.read<SpaceBloc>(),- child: MovePageMenu(- sourceView: sourceView,- onSelected: (space, view) {- onTap(controller, (space, view));+ return BlocProvider.value(+ value: context.read<SpaceBloc>(),+ child: BlocBuilder<SpaceBloc, SpaceState>(+ builder: (context, state) {+ final child = _buildActionButton(context, null);+ return AppFlowyPopover(+ constraints: const BoxConstraints(+ maxWidth: 260,+ maxHeight: 345,+ ),+ margin: const EdgeInsets.symmetric(+ horizontal: 14.0,+ vertical: 12.0,+ ),+ clickHandler: PopoverClickHandler.gestureDetector,+ direction:+ moveActionDirection ?? PopoverDirection.rightWithTopAligned,+ offset: moveActionOffset,+ popupBuilder: (_) {+ return BlocProvider.value(+ value: context.read<SpaceBloc>(),+ child: MovePageMenu(+ sourceView: sourceView,+ onSelected: (space, view) {+ onTap(controller, (space, view));+ },+ ),+ );},- ),- );- },- child: child,+ child: child,+ );+ },+ ),);}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dartindex 52aaf2af8c..e93397bed6 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart@@ -125,7 +125,7 @@ class SettingsWorkspaceView extends StatelessWidget {_ThemeDropdown(),_DocumentCursorColorSetting(),_DocumentSelectionColorSetting(),- _DocumentPaddingSetting(),+ DocumentPaddingSetting(),],),const SettingsCategorySpacer(),@@ -1268,8 +1268,10 @@ class _SelectionColorValueWidget extends StatelessWidget {}}-class _DocumentPaddingSetting extends StatelessWidget {- const _DocumentPaddingSetting();+class DocumentPaddingSetting extends StatelessWidget {+ const DocumentPaddingSetting({+ super.key,+ });@overrideWidget build(BuildContext context) {@@ -1329,28 +1331,35 @@ class _DocumentPaddingSliderState extends State<_DocumentPaddingSlider> {@overrideWidget build(BuildContext context) {- return SliderTheme(- data: Theme.of(context).sliderTheme.copyWith(- showValueIndicator: ShowValueIndicator.never,- thumbShape: const RoundSliderThumbShape(- enabledThumbRadius: 8,+ return BlocBuilder<DocumentAppearanceCubit, DocumentAppearance>(+ builder: (context, state) {+ if (state.width != width) {+ width = state.width;+ }+ return SliderTheme(+ data: Theme.of(context).sliderTheme.copyWith(+ showValueIndicator: ShowValueIndicator.never,+ thumbShape: const RoundSliderThumbShape(+ enabledThumbRadius: 8,+ ),+ overlayShape: SliderComponentShape.noThumb,+ ),+ child: Slider(+ value: width.clamp(+ EditorStyleCustomizer.minDocumentWidth,+ EditorStyleCustomizer.maxDocumentWidth,),- overlayShape: SliderComponentShape.noThumb,+ min: EditorStyleCustomizer.minDocumentWidth,+ max: EditorStyleCustomizer.maxDocumentWidth,+ divisions: 10,+ onChanged: (value) {+ setState(() => width = value);++ widget.onPaddingChanged(value);+ },),- child: Slider(- value: width.clamp(- EditorStyleCustomizer.minDocumentWidth,- EditorStyleCustomizer.maxDocumentWidth,- ),- min: EditorStyleCustomizer.minDocumentWidth,- max: EditorStyleCustomizer.maxDocumentWidth,- divisions: 10,- onChanged: (value) {- setState(() => width = value);-- widget.onPaddingChanged(value);- },- ),+ );+ },);}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dartindex 33bacdbe53..99f20809b4 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart@@ -168,7 +168,7 @@ class _SimpleSettingsDialogState extends State<SimpleSettingsDialog> {@overrideWidget build(BuildContext context) {- context.watch<AppearanceSettingsCubit>();+ final settings = context.watch<AppearanceSettingsCubit>().state;return FlowyDialog(width: MediaQuery.of(context).size.width * 0.7,@@ -188,15 +188,15 @@ class _SimpleSettingsDialogState extends State<SimpleSettingsDialog> {const VSpace(18.0),// language- const _LanguageSettings(),+ _LanguageSettings(key: ValueKey('language${settings.hashCode}')),const VSpace(22.0),// self-host cloud- const _SelfHostSettings(),+ _SelfHostSettings(key: ValueKey('selfhost${settings.hashCode}')),const VSpace(22.0),// support- const _SupportSettings(),+ _SupportSettings(key: ValueKey('support${settings.hashCode}')),],),),@@ -205,7 +205,9 @@ class _SimpleSettingsDialogState extends State<SimpleSettingsDialog> {}class _LanguageSettings extends StatelessWidget {- const _LanguageSettings();+ const _LanguageSettings({+ super.key,+ });@overrideWidget build(BuildContext context) {@@ -217,7 +219,9 @@ class _LanguageSettings extends StatelessWidget {}class _SelfHostSettings extends StatefulWidget {- const _SelfHostSettings();+ const _SelfHostSettings({+ super.key,+ });@overrideState<_SelfHostSettings> createState() => _SelfHostSettingsState();@@ -313,7 +317,9 @@ class _SelfHostSettingsState extends State<_SelfHostSettings> {}class _SupportSettings extends StatelessWidget {- const _SupportSettings();+ const _SupportSettings({+ super.key,+ });@overrideWidget build(BuildContext context) {diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 500791e3f1..5c14ff904c 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -53,8 +53,8 @@ packages:dependency: "direct main"description:path: "."- ref: "0a0154ff7d10d13de755623e56527aa4bed26241"- resolved-ref: "0a0154ff7d10d13de755623e56527aa4bed26241"+ ref: "8582191"+ resolved-ref: "8582191b0670ebccfb551b04c97d96d2f1c471fe"url: "https://github.com/AppFlowy-IO/appflowy-editor.git"source: gitversion: "3.3.0"diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex d5e96b47ef..1faf306777 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -1,5 +1,7 @@name: appflowy-description: Bring projects, wikis, and teams together with AI. AppFlowy is an AI collaborative workspace where you achieve more without losing control of your data. The best open source alternative to Notion.+description: Bring projects, wikis, and teams together with AI. AppFlowy is an+ AI collaborative workspace where you achieve more without losing control of+ your data. The best open source alternative to Notion.publish_to: "none"version: 0.7.0@@ -175,7 +177,7 @@ dependency_overrides:appflowy_editor:git:url: https://github.com/AppFlowy-IO/appflowy-editor.git- ref: "0a0154ff7d10d13de755623e56527aa4bed26241"+ ref: "8582191"appflowy_editor_plugins:git:diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex 110ad23b90..984c569d8d 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -1728,7 +1728,8 @@"uploadedAt": "Uploaded on {}","linkedAt": "Link added on {}","failedToOpenMsg": "Failed to open, file not found"- }+ },+ "cannotMoveToItsChildren": "Cannot move to its children"},"outlineBlock": {"placeholder": "Table of Contents"@@ -2383,6 +2384,7 @@"quicklySwitch": "Quickly switch to the next space","duplicate": "Duplicate Space","movePageToSpace": "Move page to space",+ "cannotMovePageToDatabase": "Cannot move page to database","switchSpace": "Switch space","spaceNameCannotBeEmpty": "Space name cannot be empty"},