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: the cursor will jump up when creating a new document on desktop. (#5269)

Lucas.Xu9f44ae959ab8
diff --git a/frontend/appflowy_flutter/integration_test/desktop/uncategorized/appearance_settings_test.dart b/frontend/appflowy_flutter/integration_test/desktop/uncategorized/appearance_settings_test.dart
index af283bb9cf..b968ccfd8d 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/uncategorized/appearance_settings_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/uncategorized/appearance_settings_test.dart
@@ -73,7 +73,7 @@ void main() {
await tester.openSettingsPage(SettingsPage.files);
await tester.openSettingsPage(SettingsPage.appearance);
- final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonkey);
+ final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonKey);
await tester.tap(resetButton);
await tester.pumpAndSettle();
diff --git a/frontend/appflowy_flutter/ios/Podfile.lock b/frontend/appflowy_flutter/ios/Podfile.lock
index f734473d65..e62299792d 100644
--- a/frontend/appflowy_flutter/ios/Podfile.lock
+++ b/frontend/appflowy_flutter/ios/Podfile.lock
@@ -170,7 +170,7 @@ SPEC CHECKSUMS:
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
flowy_infra_ui: 0455e1fa8c51885aa1437848e361e99419f34ebc
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
- fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
+ fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
integration_test: 13825b8a9334a850581300559b8839134b124670
@@ -191,4 +191,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: d0d9b4ff572d8695c38eb3f9b490f55cdfc57eca
-COCOAPODS: 1.11.3
+COCOAPODS: 1.15.2
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_picker_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_picker_screen.dart
index 7fd930de42..93e89d7c29 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_picker_screen.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_picker_screen.dart
@@ -106,12 +106,14 @@ class _FontSelectorState extends State<FontSelector> {
}
final fontFamilyName = availableFonts[index - 1];
- final fontFamily = fontFamilyName != builtInFontFamily()
+ final usingDefaultFontFamily = fontFamilyName == builtInFontFamily();
+ final fontFamily = !usingDefaultFontFamily
? getGoogleFontSafely(fontFamilyName).fontFamily
: TextStyle(fontFamily: builtInFontFamily()).fontFamily;
return FlowyOptionTile.checkbox(
// display the default font name if the font family name is empty
- text: fontFamilyName.isNotEmpty
+ // or using the default font family
+ text: fontFamilyName.isNotEmpty && !usingDefaultFontFamily
? fontFamilyName.parseFontFamilyName()
: LocaleKeys.settings_appearance_fontFamily_defaultFont.tr(),
isSelected: widget.selectedFontFamilyName == fontFamilyName,
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_setting.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_setting.dart
index ec4d70992b..8e3827bf94 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_setting.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/font/font_setting.dart
@@ -4,6 +4,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/setting/font/font_picker_screen.dart';
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
+import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
@@ -21,13 +22,16 @@ class FontSetting extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final selectedFont = context.watch<AppearanceSettingsCubit>().state.font;
+ final name = selectedFont == builtInFontFamily()
+ ? LocaleKeys.settings_appearance_fontFamily_defaultFont.tr()
+ : selectedFont;
return MobileSettingItem(
name: LocaleKeys.settings_appearance_fontFamily_label.tr(),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
FlowyText(
- selectedFont,
+ name,
color: theme.colorScheme.onSurface,
),
const Icon(Icons.chevron_right),
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart
index 2bc4a05d22..7a606f33ef 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart
@@ -89,7 +89,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
bool get hasIcon => viewIcon.isNotEmpty;
bool get hasCover =>
coverType != CoverType.none ||
- cover?.type != PageStyleCoverImageType.none;
+ (cover != null && cover?.type != PageStyleCoverImageType.none);
String viewIcon = '';
PageStyleCover? cover;
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/service/openai_client.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/service/openai_client.dart
index 60306540a8..eb688b2c56 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/service/openai_client.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/service/openai_client.dart
@@ -18,7 +18,7 @@ enum OpenAIRequestType {
case OpenAIRequestType.textCompletion:
return Uri.parse('https://api.openai.com/v1/completions');
case OpenAIRequestType.textEdit:
- return Uri.parse('https://api.openai.com/v1/v1/chat/completions');
+ return Uri.parse('https://api.openai.com/v1/chat/completions');
case OpenAIRequestType.imageGenerations:
return Uri.parse('https://api.openai.com/v1/images/generations');
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_layout.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_layout.dart
index cd0d3df000..c5cebd7ed3 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_layout.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_layout.dart
@@ -163,6 +163,11 @@ class _FontButton extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<DocumentPageStyleBloc, DocumentPageStyleState>(
builder: (context, state) {
+ String fontFamily = state.fontFamily ?? builtInFontFamily();
+ if (fontFamily == builtInFontFamily()) {
+ fontFamily =
+ LocaleKeys.settings_appearance_fontFamily_defaultFont.tr();
+ }
return GestureDetector(
onTap: () => _showFontSelector(context),
behavior: HitTestBehavior.opaque,
@@ -177,7 +182,7 @@ class _FontButton extends StatelessWidget {
const HSpace(16.0),
FlowyText(LocaleKeys.titleBar_font.tr()),
const Spacer(),
- FlowyText(state.fontFamily ?? builtInFontFamily()),
+ FlowyText(fontFamily),
const HSpace(6.0),
const FlowySvg(FlowySvgs.m_page_style_arrow_right_s),
const HSpace(12.0),
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_appearance/font_family_setting.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_appearance/font_family_setting.dart
index 73477eb622..f88f3387d4 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_appearance/font_family_setting.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_appearance/font_family_setting.dart
@@ -24,7 +24,7 @@ class ThemeFontFamilySetting extends StatefulWidget {
final String currentFontFamily;
static Key textFieldKey = const Key('FontFamilyTextField');
- static Key resetButtonkey = const Key('FontFamilyResetButton');
+ static Key resetButtonKey = const Key('FontFamilyResetButton');
static Key popoverKey = const Key('FontFamilyPopover');
@override
@@ -36,7 +36,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
Widget build(BuildContext context) {
return FlowySettingListTile(
label: LocaleKeys.settings_appearance_fontFamily_label.tr(),
- resetButtonKey: ThemeFontFamilySetting.resetButtonkey,
+ resetButtonKey: ThemeFontFamilySetting.resetButtonKey,
onResetRequested: () {
context.read<AppearanceSettingsCubit>().resetFontFamily();
context
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
index ca291a51b4..9d65cc06a1 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
@@ -31,12 +31,14 @@ class ViewTitleBar extends StatefulWidget {
class _ViewTitleBarState extends State<ViewTitleBar> {
late Future<List<ViewPB>> ancestors;
+ late String viewId;
@override
void initState() {
super.initState();
- _reloadAncestors();
+ viewId = widget.view.id;
+ _reloadAncestors(viewId);
}
@override
@@ -44,7 +46,8 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
super.didUpdateWidget(oldWidget);
if (oldWidget.view.id != widget.view.id) {
- _reloadAncestors();
+ viewId = widget.view.id;
+ _reloadAncestors(viewId);
}
}
@@ -54,10 +57,11 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
future: ancestors,
builder: (context, snapshot) {
final ancestors = snapshot.data;
- if (ancestors == null) {
+ if (ancestors == null ||
+ snapshot.connectionState != ConnectionState.done) {
return const SizedBox.shrink();
}
- const maxWidth = WindowSizeManager.minWindowWidth - 200;
+ const maxWidth = WindowSizeManager.minWindowWidth / 2.0;
final replacement = Row(
// refresh the view title bar when the ancestors changed
key: ValueKey(ancestors.hashCode),
@@ -73,7 +77,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
key: ValueKey(ancestors.last),
view: ancestors.last,
maxTitleWidth: constraints.maxWidth,
- onUpdated: () => setState(() => _reloadAncestors()),
+ onUpdated: () => setState(() => _reloadAncestors(viewId)),
),
);
},
@@ -129,7 +133,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
behavior: i == views.length - 1
? _ViewTitleBehavior.editable // only the last one is editable
: _ViewTitleBehavior.uneditable, // others are not editable
- onUpdated: () => setState(() => _reloadAncestors()),
+ onUpdated: () => setState(() => _reloadAncestors(viewId)),
),
);
}
@@ -144,8 +148,8 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
return children;
}
- void _reloadAncestors() {
- ancestors = ViewBackendService.getViewAncestors(widget.view.id)
+ void _reloadAncestors(String viewId) {
+ ancestors = ViewBackendService.getViewAncestors(viewId)
.fold((s) => s.items, (f) => []);
}
}
diff --git a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart
index a1ff33e36a..eed8f177b2 100644
--- a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart
+++ b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart
@@ -25,7 +25,7 @@ class TrashTestContext {
section: ViewSectionPB.Public,
),
);
- await blocResponseFuture();
+ await blocResponseFuture(millisecond: 300);
viewBloc.add(
const ViewEvent.createView(
@@ -34,7 +34,7 @@ class TrashTestContext {
section: ViewSectionPB.Public,
),
);
- await blocResponseFuture();
+ await blocResponseFuture(millisecond: 300);
viewBloc.add(
const ViewEvent.createView(
@@ -43,7 +43,7 @@ class TrashTestContext {
section: ViewSectionPB.Public,
),
);
- await blocResponseFuture();
+ await blocResponseFuture(millisecond: 300);
allViews = [...viewBloc.state.view.childViews];
assert(allViews.length == 3, 'but receive ${allViews.length}');
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index db3c5b14af..691bdf3d7b 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -412,7 +412,7 @@
"fontFamily": {
"label": "Font Family",
"search": "Search",
- "defaultFont": "Default Font"
+ "defaultFont": "System"
},
"themeMode": {
"label": "Theme Mode",