From fe4f85a59725963dbb0cb5493ab9abafd0ffff13 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 6 Nov 2024 09:08:59 +0800 Subject: [PATCH] fix: align the namespace and toggle shortcuts (#6726) * chore: update translations, url to URL * fix: children disapper when using toggle shortcuts * fix: add tooltip for namespace button * test: add toggle shortcut test --- .../toggle/toggle_block_shortcuts.dart | 1 + .../pages/sites/domain/domain_item.dart | 44 ++++++++++--------- frontend/appflowy_flutter/pubspec.lock | 4 +- frontend/appflowy_flutter/pubspec.yaml | 2 +- .../shortcuts/toggle_list_shortcut_test.dart | 35 +++++++++++++++ frontend/resources/translations/en.json | 2 +- 6 files changed, 64 insertions(+), 24 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart index f806eaf200..c715330c54 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_shortcuts.dart @@ -67,6 +67,7 @@ Future _formatGreaterToToggleHeading( node.path, toggleListBlockNode( delta: delta, + children: node.children.map((e) => e.copyWith()).toList(), ), ) ..deleteNode(node); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/domain_item.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/domain_item.dart index 57c8f4d636..f7a96db510 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/domain_item.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/domain_item.dart @@ -42,11 +42,7 @@ class DomainItem extends StatelessWidget { ), // Homepage Expanded( - child: Padding( - padding: const EdgeInsets.only( - left: SettingsPageSitesConstants.alignPadding,), - child: _buildHomepage(context), - ), + child: _buildHomepage(context), ), // ... button DomainMoreAction(namespace: namespace), @@ -58,20 +54,23 @@ class DomainItem extends StatelessWidget { return Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.only(right: 12.0), - child: FlowyButton( - useIntrinsicWidth: true, - text: FlowyText( - namespaceUrl, - fontSize: 14.0, - overflow: TextOverflow.ellipsis, + child: FlowyTooltip( + message: '${LocaleKeys.shareAction_visitSite.tr()}\n$namespaceUrl', + child: FlowyButton( + useIntrinsicWidth: true, + text: FlowyText( + namespaceUrl, + fontSize: 14.0, + overflow: TextOverflow.ellipsis, + ), + onTap: () { + final namespaceUrl = ShareConstants.buildNamespaceUrl( + nameSpace: namespace, + withHttps: true, + ); + afLaunchUrlString(namespaceUrl); + }, ), - onTap: () { - final namespaceUrl = ShareConstants.buildNamespaceUrl( - nameSpace: namespace, - withHttps: true, - ); - afLaunchUrlString(namespaceUrl); - }, ), ); } @@ -85,7 +84,12 @@ class DomainItem extends StatelessWidget { final isFreePlan = plan == WorkspacePlanPB.FreePlan; if (isFreePlan) { - return const _FreePlanUpgradeButton(); + return const Padding( + padding: EdgeInsets.only( + left: SettingsPageSitesConstants.alignPadding, + ), + child: _FreePlanUpgradeButton(), + ); } return const _HomePageButton(); @@ -178,7 +182,7 @@ class _HomePageButton extends StatelessWidget { }, text: const FlowySvg( FlowySvgs.close_m, - size: Size.square(18.0), + size: Size.square(19.0), ), ), ), diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index c0f8465004..27ee616618 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -61,8 +61,8 @@ packages: dependency: "direct main" description: path: "." - ref: "2903792" - resolved-ref: "2903792fa319e1b4077164eeb684f6e8d1c63e27" + ref: "76daa96" + resolved-ref: "76daa96af51f0ad4e881c10426a91780977544e5" url: "https://github.com/AppFlowy-IO/appflowy-editor.git" source: git version: "4.0.0" diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index 8826e9d408..153324b1b6 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -172,7 +172,7 @@ dependency_overrides: appflowy_editor: git: url: https://github.com/AppFlowy-IO/appflowy-editor.git - ref: "2903792" + ref: "76daa96" appflowy_editor_plugins: git: diff --git a/frontend/appflowy_flutter/test/unit_test/document/shortcuts/toggle_list_shortcut_test.dart b/frontend/appflowy_flutter/test/unit_test/document/shortcuts/toggle_list_shortcut_test.dart index d7c68f66aa..048fd7d8e9 100644 --- a/frontend/appflowy_flutter/test/unit_test/document/shortcuts/toggle_list_shortcut_test.dart +++ b/frontend/appflowy_flutter/test/unit_test/document/shortcuts/toggle_list_shortcut_test.dart @@ -49,5 +49,40 @@ void main() { editorState.dispose(); }); + + testWidgets('convert block contains children to toggle list', + (tester) async { + const paragraph1 = '>paragraph 1'; + const paragraph1_1 = 'paragraph 1.1'; + const paragraph1_2 = 'paragraph 1.2'; + + final document = createDocument([ + paragraphNode( + text: paragraph1, + children: [ + paragraphNode(text: paragraph1_1), + paragraphNode(text: paragraph1_2), + ], + ), + ]); + + final editorState = EditorState(document: document); + editorState.selection = Selection.collapsed( + Position(path: [0], offset: 1), + ); + + final result = await formatGreaterToToggleList.execute(editorState); + expect(result, true); + + expect(editorState.document.root.children.length, 1); + final node = editorState.document.root.children[0]; + expect(node.type, ToggleListBlockKeys.type); + expect(node.delta!.toPlainText(), 'paragraph 1'); + expect(node.children.length, 2); + expect(node.children[0].delta!.toPlainText(), paragraph1_1); + expect(node.children[1].delta!.toPlainText(), paragraph1_2); + + editorState.dispose(); + }); }); } diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json index edef7529b2..10a2e36e51 100644 --- a/frontend/resources/translations/en.json +++ b/frontend/resources/translations/en.json @@ -445,7 +445,7 @@ "removeHomepage": "Remove homepage", "selectHomePage": "Select a page", "clearHomePage": "Clear the home page for this namespace", - "customUrl": "Custom url", + "customUrl": "Custom URL", "namespace": { "description": "This change will apply to all the published pages live on this namespace", "tooltip": "We reserve the rights to remove any inappropriate namespaces",