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: multiple select menu display issue (#6861)
Lucasb036129efbdf
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dartindex a01356d8db..f3d71a7f0e 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/database/field/mobile_full_field_editor.dart@@ -9,10 +9,10 @@ import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';import 'package:appflowy/mobile/presentation/database/card/card_detail/widgets/widgets.dart';import 'package:appflowy/mobile/presentation/widgets/widgets.dart';import 'package:appflowy/plugins/base/drag_handler.dart';-import 'package:appflowy/plugins/database/domain/field_service.dart';import 'package:appflowy/plugins/database/application/field/type_option/number_format_bloc.dart';-import 'package:appflowy/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart';+import 'package:appflowy/plugins/database/domain/field_service.dart';import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';+import 'package:appflowy/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart';import 'package:appflowy/util/field_type_extension.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';import 'package:collection/collection.dart';@@ -863,6 +863,8 @@ class _SelectOptionListState extends State<_SelectOptionList> {return ListView(shrinkWrap: true,padding: EdgeInsets.zero,+ // disable the inner scroll physics, so the outer ListView can scroll+ physics: const NeverScrollableScrollPhysics(),children: widget.selectOptions.mapIndexed((index, option) => _SelectOptionTile(diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/text_robot.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/text_robot.dartindex 445a504657..bc4a28dbdd 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/text_robot.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/text_robot.dart@@ -1,4 +1,8 @@+import 'dart:async';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/material.dart';+import 'package:synchronized/synchronized.dart';enum TextRobotInputType {character,@@ -7,12 +11,35 @@ enum TextRobotInputType {}class TextRobot {- const TextRobot({+ TextRobot({required this.editorState,});final EditorState editorState;+ final Lock lock = Lock();+ /// This function is used to insert text in a synchronized way+ ///+ /// It is suitable for inserting text in a loop.+ Future<void> autoInsertTextSync(+ String text, {+ TextRobotInputType inputType = TextRobotInputType.word,+ Duration delay = const Duration(milliseconds: 10),+ String separator = '\n',+ }) async {+ await lock.synchronized(() async {+ await autoInsertText(+ text,+ inputType: inputType,+ delay: delay,+ separator: separator,+ );+ });+ }++ /// This function is used to insert text in an asynchronous way+ ///+ /// It is suitable for inserting a long paragraph or a long sentence.Future<void> autoInsertText(String text, {TextRobotInputType inputType = TextRobotInputType.word,@@ -20,15 +47,13 @@ class TextRobot {String separator = '\n',}) async {if (text == separator) {- await editorState.insertNewLine();- await Future.delayed(delay);+ await insertNewParagraph(delay);return;}final lines = _splitText(text, separator);for (final line in lines) {if (line.isEmpty) {- await editorState.insertNewLine();- await Future.delayed(delay);+ await insertNewParagraph(delay);continue;}switch (inputType) {@@ -48,10 +73,7 @@ class TextRobot {Future<void> insertCharacter(String line, Duration delay) async {final iterator = line.runes.iterator;while (iterator.moveNext()) {- await editorState.insertTextAtCurrentSelection(- iterator.currentAsString,- );- await Future.delayed(delay);+ await insertText(iterator.currentAsString, delay);}}@@ -59,22 +81,60 @@ class TextRobot {final words = line.split(' ');if (words.length == 1 ||(words.length == 2 && (words.first.isEmpty || words.last.isEmpty))) {- await editorState.insertTextAtCurrentSelection(- line,- );+ await insertText(line, delay);} else {for (final word in words.map((e) => '$e ')) {- await editorState.insertTextAtCurrentSelection(- word,- );+ await insertText(word, delay);}}await Future.delayed(delay);}Future<void> insertSentence(String line, Duration delay) async {- await editorState.insertTextAtCurrentSelection(line);+ await insertText(line, delay);+ }++ Future<void> insertNewParagraph(Duration delay) async {+ final selection = editorState.selection;+ if (selection == null || !selection.isCollapsed) {+ return;+ }+ final next = selection.end.path.next;+ final transaction = editorState.transaction;+ transaction.insertNode(+ next,+ paragraphNode(),+ );+ transaction.afterSelection = Selection.collapsed(+ Position(path: next),+ );+ await editorState.apply(transaction);+ debugPrint(+ 'AI insertNewParagraph: path: ${editorState.selection!.end.path}, index: ${editorState.selection!.endIndex}',+ );+ await Future.delayed(const Duration(milliseconds: 10));+ }++ Future<void> insertText(String text, Duration delay) async {+ final selection = editorState.selection;+ debugPrint(+ 'AI insertText: get selection, path: ${selection!.end.path}, index: ${selection.endIndex}',+ );+ if (!selection.isCollapsed) {+ return;+ }+ final node = editorState.getNodeAtPath(selection.end.path);+ if (node == null) {+ return;+ }+ final transaction = editorState.transaction;+ transaction.insertText(node, selection.endIndex, text);+ await editorState.apply(transaction);await Future.delayed(delay);++ debugPrint(+ 'AI insertText: path: ${selection.end.path}, index: ${selection.endIndex}, text: "$text"',+ );}}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dartindex 489579e707..b297a93c46 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart@@ -229,7 +229,7 @@ class _AutoCompletionBlockComponentState}},onProcess: (text) async {- await textRobot.autoInsertText(+ await textRobot.autoInsertTextSync(text,separator: r'\n\n',inputType: TextRobotInputType.sentence,@@ -269,10 +269,7 @@ class _AutoCompletionBlockComponentStatestart,end.last - start.last + 1,);- await editorState.apply(- transaction,- options: const ApplyOptions(inMemoryUpdate: true),- );+ await editorState.apply(transaction);await _makeSurePreviousNodeIsEmptyParagraphNode();}}@@ -321,7 +318,7 @@ class _AutoCompletionBlockComponentStateawait _makeSurePreviousNodeIsEmptyParagraphNode();},onProcess: (text) async {- await textRobot.autoInsertText(+ await textRobot.autoInsertTextSync(text,inputType: TextRobotInputType.sentence,separator: r'\n\n',diff --git a/frontend/appflowy_flutter/lib/startup/tasks/app_window_size_manager.dart b/frontend/appflowy_flutter/lib/startup/tasks/app_window_size_manager.dartindex 2a61b72884..7d41f2dceb 100644--- a/frontend/appflowy_flutter/lib/startup/tasks/app_window_size_manager.dart+++ b/frontend/appflowy_flutter/lib/startup/tasks/app_window_size_manager.dart@@ -7,7 +7,7 @@ import 'package:appflowy/startup/startup.dart';class WindowSizeManager {static const double minWindowHeight = 640.0;- static const double minWindowWidth = 960.0;+ static const double minWindowWidth = 640.0;// Preventing failed assertion due to Texture Descriptor Validationstatic const double maxWindowHeight = 8192.0;static const double maxWindowWidth = 8192.0;@@ -35,7 +35,10 @@ class WindowSizeManager {Future<Size> getSize() async {final defaultWindowSize = jsonEncode(- {WindowSizeManager.height: minWindowHeight, WindowSizeManager.width: minWindowWidth},+ {+ WindowSizeManager.height: minWindowHeight,+ WindowSizeManager.width: minWindowWidth,+ },);final windowSize = await getIt<KeyValueStorage>().get(KVKeys.windowSize);final size = json.decode(diff --git a/frontend/appflowy_flutter/test/unit_test/document/text_robot/text_robot_test.dart b/frontend/appflowy_flutter/test/unit_test/document/text_robot/text_robot_test.dartindex ca08e4310b..0186d36c7d 100644--- a/frontend/appflowy_flutter/test/unit_test/document/text_robot/text_robot_test.dart+++ b/frontend/appflowy_flutter/test/unit_test/document/text_robot/text_robot_test.dart@@ -20,7 +20,7 @@ void main() {editorState: editorState,);for (final text in _sample1) {- await textRobot.autoInsertText(+ await textRobot.autoInsertTextSync(text,separator: r'\n\n',inputType: TextRobotInputType.sentence,@@ -58,7 +58,7 @@ void main() {if (text.contains('\n\n')) {breakCount++;}- await textRobot.autoInsertText(+ await textRobot.autoInsertTextSync(text,separator: r'\n\n',inputType: TextRobotInputType.sentence,