Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: share link and publish issues on mobile (#6579)

Lucas634017492759
diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml
index 15ca158632..c68eb7ca06 100644
--- a/.github/workflows/flutter_ci.yaml
+++ b/.github/workflows/flutter_ci.yaml
@@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: true
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
@@ -74,9 +74,9 @@ jobs:
strategy:
fail-fast: true
matrix:
- os: [ windows-2019 ]
+ os: [windows-latest]
include:
- - os: windows-2019
+ - os: windows-latest
flutter_profile: development-windows-x86
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
@@ -101,7 +101,7 @@ jobs:
strategy:
fail-fast: true
matrix:
- os: [ macos-latest ]
+ os: [macos-latest]
include:
- os: macos-latest
flutter_profile: development-mac-x86_64
@@ -123,12 +123,12 @@ jobs:
flutter_profile: ${{ matrix.flutter_profile }}
unit_test:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
@@ -217,11 +217,11 @@ jobs:
shell: bash
cloud_integration_test:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
@@ -326,12 +326,12 @@ jobs:
# split the integration tests into different machines to minimize the time
integration_test_1:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
@@ -350,12 +350,12 @@ jobs:
rust_target: ${{ matrix.target }}
integration_test_2:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
@@ -374,12 +374,12 @@ jobs:
rust_target: ${{ matrix.target }}
integration_test_3:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
@@ -398,12 +398,12 @@ jobs:
rust_target: ${{ matrix.target }}
integration_test_4:
- needs: [ prepare-linux ]
+ needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-latest ]
+ os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
diff --git a/.github/workflows/ios_ci.yaml b/.github/workflows/ios_ci.yaml
index e1be95894d..1a099a7761 100644
--- a/.github/workflows/ios_ci.yaml
+++ b/.github/workflows/ios_ci.yaml
@@ -22,6 +22,7 @@ on:
env:
FLUTTER_VERSION: "3.22.0"
RUST_TOOLCHAIN: "1.80.1"
+ CLOUD_VERSION: 0.6.34-amd64
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -48,13 +49,13 @@ jobs:
model: "iPhone 15"
shutdown_after_job: false
- build-macos:
+ integration-tests:
if: github.event.pull_request.head.repo.full_name != github.repository
- runs-on: macos-13
+ runs-on: macos-latest
steps:
- name: Checkout source code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
@@ -96,11 +97,11 @@ jobs:
cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios
cargo make --profile development-ios-arm64-sim code_generation
- - uses: futureware-tech/simulator-action@v3
- id: simulator-action
- with:
- model: "iPhone 15"
- shutdown_after_job: false
+ # - uses: futureware-tech/simulator-action@v3
+ # id: simulator-action
+ # with:
+ # model: "iPhone 15"
+ # shutdown_after_job: false
# - name: Run AppFlowy on simulator
# working-directory: frontend/appflowy_flutter
@@ -111,7 +112,6 @@ jobs:
# kill $pid
# continue-on-error: true
- # enable it again if the 12 mins timeout is fixed
# - name: Run integration tests
# working-directory: frontend/appflowy_flutter
# run: flutter test integration_test/runner.dart -d ${{ steps.simulator-action.outputs.udid }}
diff --git a/frontend/appflowy_flutter/integration_test/mobile/cloud/cloud_runner.dart b/frontend/appflowy_flutter/integration_test/mobile/cloud/cloud_runner.dart
index b2964d4ae5..9cea0ff57f 100644
--- a/frontend/appflowy_flutter/integration_test/mobile/cloud/cloud_runner.dart
+++ b/frontend/appflowy_flutter/integration_test/mobile/cloud/cloud_runner.dart
@@ -1,5 +1,9 @@
+import 'document/publish_test.dart' as publish_test;
+import 'document/share_link_test.dart' as share_link_test;
import 'workspace/workspace_operations_test.dart' as workspace_operations_test;
Future<void> main() async {
workspace_operations_test.main();
+ share_link_test.main();
+ publish_test.main();
}
diff --git a/frontend/appflowy_flutter/integration_test/mobile/cloud/document/publish_test.dart b/frontend/appflowy_flutter/integration_test/mobile/cloud/document/publish_test.dart
new file mode 100644
index 0000000000..dfde191284
--- /dev/null
+++ b/frontend/appflowy_flutter/integration_test/mobile/cloud/document/publish_test.dart
@@ -0,0 +1,89 @@
+// ignore_for_file: unused_import
+
+import 'dart:io';
+import 'dart:math';
+
+import 'package:appflowy/env/cloud_env.dart';
+import 'package:appflowy/generated/flowy_svgs.g.dart';
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
+import 'package:appflowy/mobile/presentation/base/app_bar/app_bar_actions.dart';
+import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart';
+import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_buttons.dart';
+import 'package:appflowy/mobile/presentation/home/home.dart';
+import 'package:appflowy/plugins/document/presentation/editor_page.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/cover/document_immersive_cover.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/cover/document_immersive_cover_bloc.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/page_style/_page_style_layout.dart';
+import 'package:appflowy/shared/patterns/common_patterns.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/user/presentation/screens/sign_in_screen/widgets/widgets.dart';
+import 'package:appflowy/workspace/application/settings/prelude.dart';
+import 'package:appflowy/workspace/application/view/view_ext.dart';
+import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.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/services.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/dir.dart';
+import '../../../shared/mock/mock_file_picker.dart';
+import '../../../shared/util.dart';
+
+void main() {
+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+ group('publish:', () {
+ testWidgets('publish document', (tester) async {
+ await tester.initializeAppFlowy(
+ cloudType: AuthenticatorType.appflowyCloudSelfHost,
+ );
+ await tester.tapGoogleLoginInButton();
+ await tester.expectToSeeHomePageWithGetStartedPage();
+
+ await tester.openPage(Constants.gettingStartedPageName);
+ await tester.editor.openMoreActionMenuOnMobile();
+
+ // click the publish button
+ await tester.editor.clickMoreActionItemOnMobile(
+ LocaleKeys.shareAction_publish.tr(),
+ );
+
+ // wait the notification dismiss
+ final publishSuccessText = find.findTextInFlowyText(
+ LocaleKeys.publish_publishSuccessfully.tr(),
+ );
+ expect(publishSuccessText, findsOneWidget);
+ await tester.pumpUntilNotFound(publishSuccessText);
+
+ // open the menu again, to check the publish status
+ await tester.editor.openMoreActionMenuOnMobile();
+ // expect to see the unpublish button and the visit site button
+ expect(
+ find.text(LocaleKeys.shareAction_unPublish.tr()),
+ findsOneWidget,
+ );
+ expect(
+ find.text(LocaleKeys.shareAction_visitSite.tr()),
+ findsOneWidget,
+ );
+
+ // unpublish the document
+ await tester.editor.clickMoreActionItemOnMobile(
+ LocaleKeys.shareAction_unPublish.tr(),
+ );
+ final unPublishSuccessText = find.findTextInFlowyText(
+ LocaleKeys.publish_unpublishSuccessfully.tr(),
+ );
+ expect(unPublishSuccessText, findsOneWidget);
+ await tester.pumpUntilNotFound(unPublishSuccessText);
+ });
+ });
+}
diff --git a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart
index c915ebadfd..6e94eed1b8 100644
--- a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart
+++ b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart
@@ -57,10 +57,11 @@ void main() {
.single
.widget as AppFlowyEditorPage;
return editorPage.styleCustomizer
- .style()
- .textStyleConfiguration
- .text
- .height!;
+ .style()
+ .textStyleConfiguration
+ .text
+ .height ??
+ PageStyleLineHeightLayout.normal.lineHeight;
}
testWidgets('change font size in page style settings', (tester) async {
@@ -126,7 +127,6 @@ void main() {
// click done button to exit the page style settings
await tester.tapButton(find.byType(BottomSheetDoneButton).first);
- await tester.tapButton(find.byType(BottomSheetDoneButton).first);
// check the cover
final builtInCover = find.descendant(
diff --git a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart
index 8e3724a583..ae4e5ddea5 100644
--- a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart
+++ b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart
@@ -3,10 +3,11 @@
import 'dart:io';
import 'package:appflowy/env/cloud_env.dart';
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/mobile/presentation/editor/mobile_editor_screen.dart';
import 'package:appflowy/mobile/presentation/home/home.dart';
import 'package:appflowy/mobile/presentation/home/section_folder/mobile_home_section_folder_header.dart';
+import 'package:appflowy/mobile/presentation/presentation.dart';
import 'package:appflowy/plugins/document/document_page.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart';
@@ -34,13 +35,12 @@ void main() {
cloudType: AuthenticatorType.local,
);
- // click the anonymousSignInButton
- final anonymousSignInButton = find.byType(SignInAnonymousButtonV2);
- expect(anonymousSignInButton, findsOneWidget);
- await tester.tapButton(anonymousSignInButton);
-
// tap the create page button
- final createPageButton = find.byKey(mobileCreateNewPageButtonKey);
+ final createPageButton = find.byWidgetPredicate(
+ (widget) =>
+ widget is FlowySvg &&
+ widget.svg.path == FlowySvgs.m_home_unselected_m.path,
+ );
await tester.tapButton(createPageButton);
expect(find.byType(MobileDocumentScreen), findsOneWidget);
});
diff --git a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart
index 65f48a87ff..427e554733 100644
--- a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart
+++ b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart
@@ -29,11 +29,6 @@ void main() {
testWidgets('anon user and then sign in', (tester) async {
await tester.initializeAppFlowy();
- // click the anonymousSignInButton
- final anonymousSignInButton = find.byType(SignInAnonymousButtonV2);
- expect(anonymousSignInButton, findsOneWidget);
- await tester.tapButton(anonymousSignInButton);
-
// expect to see the home page
expect(find.byType(MobileHomeScreen), findsOneWidget);
});
diff --git a/frontend/appflowy_flutter/integration_test/mobile_runner.dart b/frontend/appflowy_flutter/integration_test/mobile_runner.dart
index fa5d4c40bd..3f47f83997 100644
--- a/frontend/appflowy_flutter/integration_test/mobile_runner.dart
+++ b/frontend/appflowy_flutter/integration_test/mobile_runner.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy_backend/log.dart';
import 'package:integration_test/integration_test.dart';
import 'mobile/document/page_style_test.dart' as page_style_test;
@@ -5,7 +6,9 @@ import 'mobile/home_page/create_new_page_test.dart' as create_new_page_test;
import 'mobile/sign_in/anonymous_sign_in_test.dart' as anonymous_sign_in_test;
Future<void> runIntegrationOnMobile() async {
+ Log.shared.disableLog = true;
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
anonymous_sign_in_test.main();
create_new_page_test.main();
page_style_test.main();
diff --git a/frontend/appflowy_flutter/integration_test/shared/base.dart b/frontend/appflowy_flutter/integration_test/shared/base.dart
index 9ac3d87464..f6baa52721 100644
--- a/frontend/appflowy_flutter/integration_test/shared/base.dart
+++ b/frontend/appflowy_flutter/integration_test/shared/base.dart
@@ -17,6 +17,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
+import 'package:universal_platform/universal_platform.dart';
class FlowyTestContext {
FlowyTestContext({required this.applicationDataDirectory});
@@ -105,7 +106,7 @@ extension AppFlowyTestBase on WidgetTester {
}
Future<void> waitUntilSignInPageShow() async {
- if (isAuthEnabled) {
+ if (isAuthEnabled || UniversalPlatform.isMobile) {
final finder = find.byType(SignInAnonymousButtonV2);
await pumpUntilFound(finder, timeout: const Duration(seconds: 30));
expect(finder, findsOneWidget);
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart
index 569cdd5fe6..8b13ca4e15 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart
@@ -5,6 +5,7 @@ import 'package:appflowy/mobile/presentation/base/app_bar/app_bar.dart';
import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart';
import 'package:appflowy/mobile/presentation/presentation.dart';
import 'package:appflowy/mobile/presentation/widgets/flowy_mobile_state_container.dart';
+import 'package:appflowy/plugins/document/application/prelude.dart';
import 'package:appflowy/plugins/document/presentation/document_collaborators.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
@@ -94,6 +95,10 @@ class _MobileViewPageState extends State<MobileViewPage> {
BlocProvider.value(
value: getIt<ReminderBloc>(),
),
+ BlocProvider(
+ create: (_) =>
+ ShareBloc(view: view)..add(const ShareEvent.initial()),
+ ),
if (view.layout.isDocumentView)
BlocProvider(
create: (_) => DocumentPageStyleBloc(view: view)
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/base/view_page/app_bar_buttons.dart b/frontend/appflowy_flutter/lib/mobile/presentation/base/view_page/app_bar_buttons.dart
index 8c49d70d0b..a228ac0229 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/base/view_page/app_bar_buttons.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/base/view_page/app_bar_buttons.dart
@@ -100,10 +100,7 @@ class MobileViewPageMoreButton extends StatelessWidget {
BlocProvider.value(value: context.read<ViewBloc>()),
BlocProvider.value(value: context.read<FavoriteBloc>()),
BlocProvider.value(value: context.read<MobileViewPageBloc>()),
- BlocProvider(
- create: (_) =>
- ShareBloc(view: view)..add(const ShareEvent.initial()),
- ),
+ BlocProvider.value(value: context.read<ShareBloc>()),
],
child: MobileViewPageMoreBottomSheet(view: view),
),
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 271293ea28..180c3e4db3 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
@@ -261,31 +261,17 @@ class _MentionPageBlockContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final text = _getDisplayText(context, view, content);
- final emojiSize = textStyle?.fontSize ?? 12.0;
- final iconSize = textStyle?.fontSize ?? 16.0;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
- if (_shouldDisplayViewName(context, view.id, content)) ...[
- const HSpace(4),
- view.icon.value.isNotEmpty
- ? FlowyText.emoji(
- view.icon.value,
- fontSize: emojiSize,
- lineHeight: textStyle?.height,
- optimizeEmojiAlign: true,
- )
- : FlowySvg(
- view.layout.icon,
- size: Size.square(iconSize + 2.0),
- ),
- ],
+ ..._buildPrefixIcons(context, view, content),
const HSpace(2),
Flexible(
child: FlowyText(
text,
decoration: TextDecoration.underline,
+ decorationThickness: 0.5,
fontSize: textStyle?.fontSize,
fontWeight: textStyle?.fontWeight,
lineHeight: textStyle?.height,
@@ -297,6 +283,51 @@ class _MentionPageBlockContent extends StatelessWidget {
);
}
+ List<Widget> _buildPrefixIcons(
+ BuildContext context,
+ ViewPB view,
+ String? content,
+ ) {
+ final isSameDocument = _isSameDocument(context, view.id);
+ final shouldDisplayViewName = _shouldDisplayViewName(
+ context,
+ view.id,
+ content,
+ );
+
+ // if the block is from the same doc, display the paragraph mark icon '¶'
+ if (isSameDocument) {
+ return [
+ const HSpace(2),
+ FlowySvg(
+ FlowySvgs.paragraph_mark_s,
+ size: const Size.square(14.0),
+ color: Theme.of(context).hintColor,
+ ),
+ ];
+ } else if (shouldDisplayViewName) {
+ final emojiSize = textStyle?.fontSize ?? 12.0;
+ final iconSize = textStyle?.fontSize ?? 16.0;
+
+ return [
+ const HSpace(4),
+ view.icon.value.isNotEmpty
+ ? FlowyText.emoji(
+ view.icon.value,
+ fontSize: emojiSize,
+ lineHeight: textStyle?.height,
+ optimizeEmojiAlign: true,
+ )
+ : FlowySvg(
+ view.layout.icon,
+ size: Size.square(iconSize + 2.0),
+ ),
+ ];
+ }
+
+ return [];
+ }
+
String _getDisplayText(
BuildContext context,
ViewPB view,
@@ -413,15 +444,12 @@ class _DesktopMentionPageBlock extends StatelessWidget {
return GestureDetector(
onTap: handleTap,
behavior: HitTestBehavior.opaque,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 2),
- child: FlowyHover(
- cursor: SystemMouseCursors.click,
- child: _MentionPageBlockContent(
- view: view,
- content: content,
- textStyle: textStyle,
- ),
+ child: FlowyHover(
+ cursor: SystemMouseCursors.click,
+ child: _MentionPageBlockContent(
+ view: view,
+ content: content,
+ textStyle: textStyle,
),
),
);
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_bloc.dart
index 252c427c3a..bf78c1e4eb 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_bloc.dart
@@ -46,7 +46,7 @@ class SmartEditBloc extends Bloc<SmartEditEvent, SmartEditState> {
isCanceled = true;
await _exit();
},
- update: (result, isLoading, aiError) async {
+ update: (result, isLoading, aiError) {
emit(
state.copyWith(
result: result,
diff --git a/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
index 98e031b987..302c2a46ce 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
@@ -94,7 +94,9 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {
);
if (shouldShowUpgradeDialog && !integrationMode().isTest) {
- add(const SpaceEvent.migrate());
+ if (!isClosed) {
+ add(const SpaceEvent.migrate());
+ }
}
if (openFirstPage) {
diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
index 3ab1d42f14..c02a5b1cfd 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
@@ -13,6 +13,7 @@ class FlowyText extends StatelessWidget {
final int? maxLines;
final Color? color;
final TextDecoration? decoration;
+ final double? decorationThickness;
final bool selectable;
final String? fontFamily;
final List<String>? fallbackFontFamily;
@@ -48,6 +49,7 @@ class FlowyText extends StatelessWidget {
this.isEmoji = false,
this.strutStyle,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
});
FlowyText.small(
@@ -67,6 +69,7 @@ class FlowyText extends StatelessWidget {
this.strutStyle,
this.figmaLineHeight,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
}) : fontWeight = FontWeight.w400,
fontSize = (Platform.isIOS || Platform.isAndroid) ? 14 : 12;
@@ -88,6 +91,7 @@ class FlowyText extends StatelessWidget {
this.strutStyle,
this.figmaLineHeight,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
}) : fontWeight = FontWeight.w400;
const FlowyText.medium(
@@ -108,6 +112,7 @@ class FlowyText extends StatelessWidget {
this.strutStyle,
this.figmaLineHeight,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
}) : fontWeight = FontWeight.w500;
const FlowyText.semibold(
@@ -128,6 +133,7 @@ class FlowyText extends StatelessWidget {
this.strutStyle,
this.figmaLineHeight,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
}) : fontWeight = FontWeight.w600;
// Some emojis are not supported on Linux and Android, fallback to noto color emoji
@@ -148,6 +154,7 @@ class FlowyText extends StatelessWidget {
this.fontFamily,
this.figmaLineHeight,
this.optimizeEmojiAlign = false,
+ this.decorationThickness,
}) : fontWeight = FontWeight.w400,
fallbackFontFamily = null;
@@ -187,6 +194,7 @@ class FlowyText extends StatelessWidget {
fontWeight: fontWeight,
color: color,
decoration: decoration,
+ decorationThickness: decorationThickness,
fontFamily: fontFamily,
fontFamilyFallback: fallbackFontFamily,
height: lineHeight,
diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock
index fd7f833e88..16bf375bce 100644
--- a/frontend/appflowy_flutter/pubspec.lock
+++ b/frontend/appflowy_flutter/pubspec.lock
@@ -53,8 +53,8 @@ packages:
dependency: "direct main"
description:
path: "."
- ref: "4509123"
- resolved-ref: "450912305a2cdf98776b09ad4dbdb11498bdf9ce"
+ ref: e7d9560
+ resolved-ref: e7d956099aea85727973e5518c50bc4da9fc92bc
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 ef183a7e45..58163151ec 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -171,7 +171,7 @@ dependency_overrides:
appflowy_editor:
git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git
- ref: "4509123"
+ ref: "e7d9560"
appflowy_editor_plugins:
git:
diff --git a/frontend/appflowy_flutter/test/bloc_test/smart_edit_test/smart_editor_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/smart_edit_test/smart_editor_bloc_test.dart
index 67de5bc4b4..717cc7c141 100644
--- a/frontend/appflowy_flutter/test/bloc_test/smart_edit_test/smart_editor_bloc_test.dart
+++ b/frontend/appflowy_flutter/test/bloc_test/smart_edit_test/smart_editor_bloc_test.dart
@@ -9,6 +9,10 @@ import 'package:bloc_test/bloc_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
+import '../../util.dart';
+
+const _aiResponse = 'UPDATED:';
+
class _MockAIRepository extends Mock implements AIRepository {
@override
Future<void> streamCompletion({
@@ -22,7 +26,43 @@ class _MockAIRepository extends Mock implements AIRepository {
await onStart();
final lines = text.split('\n\n');
for (var i = 0; i < lines.length; i++) {
- await onProcess('UPDATED: ${lines[i]}\n\n');
+ await onProcess('$_aiResponse ${lines[i]}\n\n');
+ }
+ await onEnd();
+ }
+}
+
+class _MockAIRepositoryLess extends Mock implements AIRepository {
+ @override
+ Future<void> streamCompletion({
+ required String text,
+ required CompletionTypePB completionType,
+ required Future<void> Function() onStart,
+ required Future<void> Function(String text) onProcess,
+ required Future<void> Function() onEnd,
+ required void Function(AIError error) onError,
+ }) async {
+ await onStart();
+ // only return 1 line.
+ await onProcess('Hello World');
+ await onEnd();
+ }
+}
+
+class _MockAIRepositoryMore extends Mock implements AIRepository {
+ @override
+ Future<void> streamCompletion({
+ required String text,
+ required CompletionTypePB completionType,
+ required Future<void> Function() onStart,
+ required Future<void> Function(String text) onProcess,
+ required Future<void> Function() onEnd,
+ required void Function(AIError error) onError,
+ }) async {
+ await onStart();
+ // return 10 lines
+ for (var i = 0; i < 10; i++) {
+ await onProcess('Hello World\n\n');
}
await onEnd();
}
@@ -50,13 +90,14 @@ class _MockErrorRepository extends Mock implements AIRepository {
void main() {
group('SmartEditorBloc: ', () {
+ const text1 = '1. Select text to style using the toolbar menu.';
+ const text2 = '2. Discover more styling options in Aa.';
+ const text3 =
+ '3. AppFlowy empowers you to beautifully and effortlessly style your content.';
+
blocTest<SmartEditBloc, SmartEditState>(
'send request before the bloc is initialized',
build: () {
- const text1 = '1. Select text to style using the toolbar menu.';
- const text2 = '2. Discover more styling options in Aa.';
- const text3 =
- '3. AppFlowy empowers you to beautifully and effortlessly style your content.';
final document = Document(
root: pageNode(
children: [
@@ -149,5 +190,133 @@ void main() {
),
],
);
+
+ test('summary - the result contains the same number of paragraphs',
+ () async {
+ final document = Document(
+ root: pageNode(
+ children: [
+ paragraphNode(text: text1),
+ paragraphNode(text: text2),
+ paragraphNode(text: text3),
+ ],
+ ),
+ );
+ final editorState = EditorState(document: document);
+ editorState.selection = Selection(
+ start: Position(path: [0]),
+ end: Position(path: [2], offset: text3.length),
+ );
+
+ final node = smartEditNode(
+ action: SmartEditAction.makeItLonger,
+ content: [text1, text2, text3].join('\n\n'),
+ );
+ final bloc = SmartEditBloc(
+ node: node,
+ editorState: editorState,
+ action: SmartEditAction.summarize,
+ enableLogging: false,
+ );
+ bloc.add(SmartEditEvent.initial(Future.value(_MockAIRepository())));
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.started());
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.replace());
+ await blocResponseFuture();
+ expect(editorState.document.root.children.length, 3);
+ expect(
+ editorState.getNodeAtPath([0])!.delta!.toPlainText(),
+ '$_aiResponse $text1',
+ );
+ expect(
+ editorState.getNodeAtPath([1])!.delta!.toPlainText(),
+ '$_aiResponse $text2',
+ );
+ expect(
+ editorState.getNodeAtPath([2])!.delta!.toPlainText(),
+ '$_aiResponse $text3',
+ );
+ });
+
+ test('summary - the result less than the original text', () async {
+ final document = Document(
+ root: pageNode(
+ children: [
+ paragraphNode(text: text1),
+ paragraphNode(text: text2),
+ paragraphNode(text: text3),
+ ],
+ ),
+ );
+ final editorState = EditorState(document: document);
+ editorState.selection = Selection(
+ start: Position(path: [0]),
+ end: Position(path: [2], offset: text3.length),
+ );
+
+ final node = smartEditNode(
+ action: SmartEditAction.makeItLonger,
+ content: [text1, text2, text3].join('\n'),
+ );
+ final bloc = SmartEditBloc(
+ node: node,
+ editorState: editorState,
+ action: SmartEditAction.summarize,
+ enableLogging: false,
+ );
+ bloc.add(SmartEditEvent.initial(Future.value(_MockAIRepositoryLess())));
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.started());
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.replace());
+ await blocResponseFuture();
+ expect(editorState.document.root.children.length, 1);
+ expect(
+ editorState.getNodeAtPath([0])!.delta!.toPlainText(),
+ 'Hello World',
+ );
+ });
+
+ test('summary - the result more than the original text', () async {
+ final document = Document(
+ root: pageNode(
+ children: [
+ paragraphNode(text: text1),
+ paragraphNode(text: text2),
+ paragraphNode(text: text3),
+ ],
+ ),
+ );
+ final editorState = EditorState(document: document);
+ editorState.selection = Selection(
+ start: Position(path: [0]),
+ end: Position(path: [2], offset: text3.length),
+ );
+
+ final node = smartEditNode(
+ action: SmartEditAction.makeItLonger,
+ content: [text1, text2, text3].join('\n'),
+ );
+ final bloc = SmartEditBloc(
+ node: node,
+ editorState: editorState,
+ action: SmartEditAction.summarize,
+ enableLogging: false,
+ );
+ bloc.add(SmartEditEvent.initial(Future.value(_MockAIRepositoryMore())));
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.started());
+ await blocResponseFuture();
+ bloc.add(const SmartEditEvent.replace());
+ await blocResponseFuture();
+ expect(editorState.document.root.children.length, 10);
+ for (var i = 0; i < 10; i++) {
+ expect(
+ editorState.getNodeAtPath([i])!.delta!.toPlainText(),
+ 'Hello World',
+ );
+ }
+ });
});
}
diff --git a/frontend/resources/flowy_icons/16x/paragraph_mark.svg b/frontend/resources/flowy_icons/16x/paragraph_mark.svg
new file mode 100644
index 0000000000..be4b14bffd
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/paragraph_mark.svg
@@ -0,0 +1,3 @@
+<svg width="9" height="10" viewBox="0 0 9 10" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M4.05969 10C3.92616 10 3.81509 9.95506 3.72656 9.86516C3.63803 9.77537 3.59375 9.66406 3.59375 9.53125V5.9375H2.96875C2.14741 5.9375 1.44725 5.64788 0.868281 5.06859C0.289428 4.48944 0 3.78891 0 2.96703C0 2.14525 0.289428 1.44531 0.868281 0.867188C1.44725 0.289062 2.14741 0 2.96875 0H8.28125C8.41406 0 8.52541 0.0452093 8.61531 0.135625C8.70509 0.225937 8.75 0.337916 8.75 0.471562C8.75 0.605103 8.70509 0.716156 8.61531 0.804688C8.52541 0.893219 8.41406 0.9375 8.28125 0.9375H7.03125V9.53125C7.03125 9.66406 6.98603 9.77537 6.89563 9.86516C6.80531 9.95506 6.69334 10 6.55969 10C6.42616 10 6.31509 9.95506 6.22656 9.86516C6.13803 9.77537 6.09375 9.66406 6.09375 9.53125V0.9375H4.53125V9.53125C4.53125 9.66406 4.48603 9.77537 4.39563 9.86516C4.30531 9.95506 4.19334 10 4.05969 10Z" fill="black"/>
+</svg>