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
chore: Merge branch 'main' into develop
nathanb8ade5af1220
diff --cc frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dartindex fae8652fad,ff12cc9afd..5b8d899343--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart@@@ -1,19 -1,55 +1,53 @@@+ import 'package:appflowy/generated/locale_keys.g.dart';+ import 'package:appflowy/plugins/database_view/application/database_view_service.dart';import 'package:appflowy/plugins/document/presentation/plugins/board/board_node_widget.dart';import 'package:appflowy/plugins/document/presentation/plugins/grid/grid_node_widget.dart';+import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';+ import 'package:appflowy/workspace/application/app/app_service.dart';-import 'package:appflowy_backend/protobuf/flowy-folder/app.pb.dart';-import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_editor/appflowy_editor.dart';+ import 'package:easy_localization/easy_localization.dart';const String kAppID = 'app_id';const String kViewID = 'view_id';extension InsertPage on EditorState {- void insertPage(ViewPB appPB, ViewPB viewPB) {- Future<void> insertPage(AppPB appPB, ViewPB viewPB) async {++ Future<void> insertPage(ViewPB appPB, ViewPB viewPB) async {final selection = service.selectionService.currentSelection.value;final textNodes =service.selectionService.currentSelectedNodes.whereType<TextNode>();if (selection == null || textNodes.isEmpty) {return;}++ // get the database that the view is associated with+ final database =+ await DatabaseViewBackendService(viewId: viewPB.id).openGrid().then(+ (value) => value.getLeftOrNull(),+ );++ if (database == null) {+ throw StateError(+ 'The database associated with ${viewPB.id} could not be found while attempting to create a referenced ${viewPB.layout.name}.');+ }++ final prefix = referencedBoardPrefix(viewPB.layout);++ final ref = await AppBackendService().createView(+ appId: appPB.id,+ name: "$prefix ${viewPB.name}",- desc: appPB.desc,+ layoutType: viewPB.layout,+ ext: {+ 'database_id': database.id,+ },+ ).then(+ (value) => value.getLeftOrNull(),+ );++ // TODO(a-wallen): Show error dialog here.+ if (ref == null) {+ return;+ }+final transaction = this.transaction;transaction.insertNode(selection.end.path,@@@ -28,11 -64,22 +62,22 @@@apply(transaction);}- String referencedBoardPrefix(ViewLayoutTypePB layout) {++ String referencedBoardPrefix(ViewLayoutPB layout) {+ switch (layout) {- case ViewLayoutTypePB.Grid:++ case ViewLayoutPB.Grid:+ return LocaleKeys.grid_referencedGridPrefix.tr();- case ViewLayoutTypePB.Board:++ case ViewLayoutPB.Board:+ return LocaleKeys.board_referencedBoardPrefix.tr();+ default:+ throw UnimplementedError();+ }+ }+String _convertPageType(ViewPB viewPB) {switch (viewPB.layout) {- case ViewLayoutTypePB.Grid:+ case ViewLayoutPB.Grid:return kGridType;- case ViewLayoutTypePB.Board:+ case ViewLayoutPB.Board:return kBoardType;default:throw Exception('Unknown layout type');diff --cc frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dartindex bf7670dd1f,d59d679141..3f8cb5b1ef--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart@@@ -91,7 -93,42 +92,42 @@@ class LinkToPageMenu extends StatefulWi}class _LinkToPageMenuState extends State<LinkToPageMenu> {+ final _focusNode = FocusNode(debugLabel: 'reference_list_widget');EditorStyle get style => widget.editorState.editorStyle;+ int _selectedIndex = 0;+ int _totalItems = 0;- Future<List<dartz.Tuple2<AppPB, List<ViewPB>>>>? _availableLayout;- final Map<int, dartz.Tuple2<AppPB, ViewPB>> _items = {};++ Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>? _availableLayout;++ final Map<int, dartz.Tuple2<ViewPB, ViewPB>> _items = {};+- Future<List<dartz.Tuple2<AppPB, List<ViewPB>>>> fetchItems() async {++ Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>> fetchItems() async {+ final items = await AppBackendService().fetchViews(widget.layoutType);++ int index = 0;+ for (final app in items) {+ for (final view in app.value2) {+ _items.putIfAbsent(index, () => dartz.Tuple2(app.value1, view));+ index += 1;+ }+ }++ _totalItems = _items.length;+ return items;+ }++ @override+ void initState() {+ _availableLayout = fetchItems();+ WidgetsBinding.instance.addPostFrameCallback((_) {+ _focusNode.requestFocus();+ });+ super.initState();+ }++ @override+ void dispose() {+ _focusNode.dispose();+ super.dispose();+ }@overrideWidget build(BuildContext context) {@@@ -116,8 -154,50 +153,53 @@@);}- Widget _buildListWidget(BuildContext context) {+ KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {+ if (event is! RawKeyDownEvent ||+ _availableLayout == null ||+ _items.isEmpty) {+ return KeyEventResult.ignored;+ }++ final acceptedKeys = [+ LogicalKeyboardKey.arrowUp,+ LogicalKeyboardKey.arrowDown,+ LogicalKeyboardKey.tab,+ LogicalKeyboardKey.enter+ ];++ if (!acceptedKeys.contains(event.logicalKey)) {+ return KeyEventResult.handled;+ }++ var newSelectedIndex = _selectedIndex;+ if (event.logicalKey == LogicalKeyboardKey.arrowDown &&+ newSelectedIndex != _totalItems - 1) {+ newSelectedIndex += 1;+ } else if (event.logicalKey == LogicalKeyboardKey.arrowUp &&+ newSelectedIndex != 0) {+ newSelectedIndex -= 1;+ } else if (event.logicalKey == LogicalKeyboardKey.tab) {+ newSelectedIndex += 1;+ newSelectedIndex %= _totalItems;+ } else if (event.logicalKey == LogicalKeyboardKey.enter) {+ widget.onSelected(+ _items[_selectedIndex]!.value1, _items[_selectedIndex]!.value2);+ }++ setState(() {+ _selectedIndex = newSelectedIndex;+ });++ return KeyEventResult.handled;+ }+- Widget _buildListWidget(BuildContext context, int selectedIndex,- Future<List<dartz.Tuple2<AppPB, List<ViewPB>>>>? items) {++ Widget _buildListWidget(++ BuildContext context,++ int selectedIndex,++ Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>? items,++ ) {+ int index = 0;- return FutureBuilder<List<dartz.Tuple2<AppPB, List<ViewPB>>>>(+ return FutureBuilder<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>(builder: (context, snapshot) {if (snapshot.hasData &&snapshot.connectionState == ConnectionState.done) {@@@ -143,17 -223,20 +225,20 @@@),),);- for (final value in app.value2) {+ for (final value in view.value2) {children.add(FlowyButton(+ isSelected: index == _selectedIndex,leftIcon: svgWidget(_iconName(value),color: Theme.of(context).iconTheme.color,),text: FlowyText.regular(value.name),- onTap: () => widget.onSelected(app.value1, value),+ onTap: () => widget.onSelected(view.value1, value),),);++ index += 1;}}}diff --cc frontend/appflowy_flutter/pubspec.lockindex f6e21acf11,c785f0285f..bd3d354c76--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@@ -60,12 -64,13 +64,13 @@@ packagessource: pathversion: "0.0.1"archive:-- dependency: transitive++ dependency: "direct main"description:name: archive- url: "https://pub.dartlang.org"+ sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb"+ url: "https://pub.dev"source: hosted- version: "3.3.0"+ version: "3.3.2"args:dependency: transitivedescription:@@@ -119,7 -131,8 +131,8 @@@dependency: transitivedescription:name: build_daemon- url: "https://pub.dartlang.org"- sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf"++ sha256: "757153e5d9cd88253cb13f28c2fb55a537dc31fefd98137549895b5beb7c6169"+ url: "https://pub.dev"source: hostedversion: "3.1.1"build_resolvers:@@@ -154,7 -171,8 +171,8 @@@dependency: transitivedescription:name: built_value- url: "https://pub.dartlang.org"- sha256: "169565c8ad06adb760c3645bf71f00bff161b00002cace266cad42c5d22a7725"++ sha256: "31b7c748fd4b9adf8d25d72a4c4a59ef119f12876cf414f94f8af5131d5fa2b0"+ url: "https://pub.dev"source: hostedversion: "8.4.4"calendar_view:@@@ -498,7 -527,8 +527,8 @@@dependency: transitivedescription:name: flutter_plugin_android_lifecycle- url: "https://pub.dartlang.org"- sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b"++ sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf+ url: "https://pub.dev"source: hostedversion: "2.0.9"flutter_svg:@@@ -522,7 -553,8 +553,8 @@@dependency: "direct main"description:name: fluttertoast- url: "https://pub.dartlang.org"- sha256: "7cc92eabe01e3f1babe1571c5560b135dfc762a34e41e9056881e2196b178ec1"++ sha256: "2f9c4d3f4836421f7067a28f8939814597b27614e021da9d63e5d3fb6e212d25"+ url: "https://pub.dev"source: hostedversion: "8.2.1"freezed:@@@ -597,7 -638,8 +638,8 @@@dependency: transitivedescription:name: html- url: "https://pub.dartlang.org"- sha256: d9793e10dbe0e6c364f4c59bf3e01fb33a9b2a674bc7a1081693dba0614b6269++ sha256: "79d498e6d6761925a34ee5ea8fa6dfef38607781d2fa91e37523474282af55cb"+ url: "https://pub.dev"source: hostedversion: "0.15.2"http:@@@ -707,7 -763,8 +763,8 @@@dependency: transitivedescription:name: logger- url: "https://pub.dartlang.org"- sha256: "5076f09225f91dc49289a4ccb92df2eeea9ea01cf7c26d49b3a1f04c6a49eec1"++ sha256: db2ff852ed77090ba9f62d3611e4208a3d11dfa35991a81ae724c113fcb3e3f7+ url: "https://pub.dev"source: hostedversion: "1.3.0"logging:@@@ -777,7 -843,8 +843,8 @@@dependency: transitivedescription:name: node_preamble- url: "https://pub.dartlang.org"- sha256: "8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d"++ sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"+ url: "https://pub.dev"source: hostedversion: "2.0.2"package_config:@@@ -854,35 -923,40 +923,40 @@@dependency: "direct main"description:name: path_provider- url: "https://pub.dartlang.org"- sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95++ sha256: c7edf82217d4b2952b2129a61d3ad60f1075b9299e629e149a8d2e39c2e6aad4+ url: "https://pub.dev"source: hostedversion: "2.0.14"path_provider_android:dependency: transitivedescription:name: path_provider_android- url: "https://pub.dartlang.org"- sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e++ sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7"+ url: "https://pub.dev"source: hostedversion: "2.0.24"path_provider_foundation:dependency: transitivedescription:name: path_provider_foundation- url: "https://pub.dartlang.org"- sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74"++ sha256: "12eee51abdf4d34c590f043f45073adbb45514a108bd9db4491547a2fd891059"+ url: "https://pub.dev"source: hostedversion: "2.2.0"path_provider_linux:dependency: transitivedescription:name: path_provider_linux- url: "https://pub.dartlang.org"- sha256: "2e32f1640f07caef0d3cb993680f181c79e54a3827b997d5ee221490d131fbd9"++ sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1"+ url: "https://pub.dev"source: hostedversion: "2.1.10"path_provider_platform_interface:dependency: transitivedescription:name: path_provider_platform_interface- url: "https://pub.dartlang.org"- sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76++ sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec"+ url: "https://pub.dev"source: hostedversion: "2.0.6"path_provider_windows:@@@ -896,7 -971,8 +971,8 @@@dependency: "direct main"description:name: percent_indicator- url: "https://pub.dartlang.org"- sha256: cec41f67181fbd5322aa68b355621d1a4eea827426b8eeb613f6cbe195ff7b4a++ sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c+ url: "https://pub.dev"source: hostedversion: "4.2.3"petitparser:@@@ -917,7 -995,8 +995,8 @@@dependency: transitivedescription:name: plugin_platform_interface- url: "https://pub.dartlang.org"- sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a++ sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc"+ url: "https://pub.dev"source: hostedversion: "2.1.4"pool:@@@ -1022,7 -1115,8 +1115,8 @@@dependency: transitivedescription:name: rich_clipboard_windows- url: "https://pub.dartlang.org"- sha256: "03decfbd9bf6c50c663f8c4a0db14063e2a4d9ad5dd053fdb72875aa8bc4fd1b"++ sha256: fa2a28e75ce4bcc9efc6d5d0e9788b76716cdaf3b7063c141fe8af12a315f414+ url: "https://pub.dev"source: hostedversion: "1.0.2"screen_retriever:@@@ -1036,49 -1131,56 +1131,56 @@@dependency: "direct main"description:name: shared_preferences- url: "https://pub.dartlang.org"- sha256: "5949029e70abe87f75cfe59d17bf5c397619c4b74a099b10116baeb34786fad9"++ sha256: "78528fd87d0d08ffd3e69551173c026e8eacc7b7079c82eb6a77413957b7e394"+ url: "https://pub.dev"source: hostedversion: "2.0.20"shared_preferences_android:dependency: transitivedescription:name: shared_preferences_android- url: "https://pub.dartlang.org"- sha256: "955e9736a12ba776bdd261cf030232b30eadfcd9c79b32a3250dd4a494e8c8f7"++ sha256: ad423a80fe7b4e48b50d6111b3ea1027af0e959e49d485712e134863d9c1c521+ url: "https://pub.dev"source: hostedversion: "2.0.17"shared_preferences_foundation:dependency: transitivedescription:name: shared_preferences_foundation- url: "https://pub.dartlang.org"- sha256: "2b55c18636a4edc529fa5cd44c03d3f3100c00513f518c5127c951978efcccd0"++ sha256: "1e755f8583229f185cfca61b1d80fb2344c9d660e1c69ede5450d8f478fa5310"+ url: "https://pub.dev"source: hostedversion: "2.1.5"shared_preferences_linux:dependency: transitivedescription:name: shared_preferences_linux- url: "https://pub.dartlang.org"- sha256: f8ea038aa6da37090093974ebdcf4397010605fd2ff65c37a66f9d28394cb874++ sha256: "3a59ed10890a8409ad0faad7bb2957dab4b92b8fbe553257b05d30ed8af2c707"+ url: "https://pub.dev"source: hostedversion: "2.1.5"shared_preferences_platform_interface:dependency: transitivedescription:name: shared_preferences_platform_interface- url: "https://pub.dartlang.org"- sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3++ sha256: "824bfd02713e37603b2bdade0842e47d56e7db32b1dcdd1cae533fb88e2913fc"+ url: "https://pub.dev"source: hostedversion: "2.1.1"shared_preferences_web:dependency: transitivedescription:name: shared_preferences_web- url: "https://pub.dartlang.org"- sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958++ sha256: "0dc2633f215a3d4aa3184c9b2c5766f4711e4e5a6b256e62aafee41f89f1bfb8"+ url: "https://pub.dev"source: hostedversion: "2.0.6"shared_preferences_windows:dependency: transitivedescription:name: shared_preferences_windows- url: "https://pub.dartlang.org"- sha256: "5eaf05ae77658d3521d0e993ede1af962d4b326cd2153d312df716dc250f00c9"++ sha256: "71bcd669bb9cdb6b39f22c4a7728b6d49e934f6cba73157ffa5a54f1eed67436"+ url: "https://pub.dev"source: hostedversion: "2.1.5"shelf:@@@ -1120,7 -1227,8 +1227,8 @@@dependency: "direct main"description:name: sized_context- url: "https://pub.dartlang.org"- sha256: "4da0ecbb6a58afc3f51ba1984dc25eef6ee0e8176f8923b686c96ee1cfba23ac"++ sha256: "9921e6c09e018132c3e1c6a18e14febbc1cc5c87a200d64ff7578cb49991f6e7"+ url: "https://pub.dev"source: hostedversion: "1.0.0+4"sky_engine:@@@ -1153,7 -1264,8 +1264,8 @@@dependency: transitivedescription:name: source_maps- url: "https://pub.dartlang.org"- sha256: "490098075234dcedb83c5d949b4c93dad5e6b7702748de000be2b57b8e6b2427"++ sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"+ url: "https://pub.dev"source: hostedversion: "0.10.12"source_span:@@@ -1293,56 -1424,64 +1424,64 @@@dependency: "direct main"description:name: url_launcher- url: "https://pub.dartlang.org"- sha256: e8f2efc804810c0f2f5b485f49e7942179f56eabcfe81dce3387fec4bb55876b++ sha256: "75f2846facd11168d007529d6cd8fcb2b750186bea046af9711f10b907e1587e"+ url: "https://pub.dev"source: hostedversion: "6.1.10"url_launcher_android:dependency: transitivedescription:name: url_launcher_android- url: "https://pub.dartlang.org"- sha256: "3e2f6dfd2c7d9cd123296cab8ef66cfc2c1a13f5845f42c7a0f365690a8a7dd1"++ sha256: dd729390aa936bf1bdf5cd1bc7468ff340263f80a2c4f569416507667de8e3c8+ url: "https://pub.dev"source: hostedversion: "6.0.26"url_launcher_ios:dependency: transitivedescription:name: url_launcher_ios- url: "https://pub.dartlang.org"- sha256: "0a5af0aefdd8cf820dd739886efb1637f1f24489900204f50984634c07a54815"++ sha256: "3dedc66ca3c0bef9e6a93c0999aee102556a450afcc1b7bcfeace7a424927d92"+ url: "https://pub.dev"source: hostedversion: "6.1.3"url_launcher_linux:dependency: transitivedescription:name: url_launcher_linux- url: "https://pub.dartlang.org"- sha256: "318c42cba924e18180c029be69caf0a1a710191b9ec49bb42b5998fdcccee3cc"++ sha256: "206fb8334a700ef7754d6a9ed119e7349bc830448098f21a69bf1b4ed038cabc"+ url: "https://pub.dev"source: hostedversion: "3.0.4"url_launcher_macos:dependency: transitivedescription:name: url_launcher_macos- url: "https://pub.dartlang.org"- sha256: "41988b55570df53b3dd2a7fc90c76756a963de6a8c5f8e113330cb35992e2094"++ sha256: "0ef2b4f97942a16523e51256b799e9aa1843da6c60c55eefbfa9dbc2dcb8331a"+ url: "https://pub.dev"source: hostedversion: "3.0.4"url_launcher_platform_interface:dependency: transitivedescription:name: url_launcher_platform_interface- url: "https://pub.dartlang.org"- sha256: "4eae912628763eb48fc214522e58e942fd16ce195407dbf45638239523c759a6"++ sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370"+ url: "https://pub.dev"source: hostedversion: "2.1.2"url_launcher_web:dependency: transitivedescription:name: url_launcher_web- url: "https://pub.dartlang.org"- sha256: "44d79408ce9f07052095ef1f9a693c258d6373dc3944249374e30eff7219ccb0"++ sha256: "81fe91b6c4f84f222d186a9d23c73157dc4c8e1c71489c4d08be1ad3b228f1aa"+ url: "https://pub.dev"source: hostedversion: "2.0.16"url_launcher_windows:dependency: transitivedescription:name: url_launcher_windows- url: "https://pub.dartlang.org"- sha256: b6217370f8eb1fd85c8890c539f5a639a01ab209a36db82c921ebeacefc7a615++ sha256: a83ba3607a507758669cfafb03f9de09bf6e6280c14d9b9cb18f013e406dcacd+ url: "https://pub.dev"source: hostedversion: "3.0.5"uuid:@@@ -1405,7 -1576,8 +1576,8 @@@dependency: "direct main"description:name: window_manager- url: "https://pub.dartlang.org"- sha256: "5bdd29dc5f1f3185fc90696373a571d77968e03e5e820fb1ecdbdade3f5d8fff"++ sha256: "492806c69879f0d28e95472bbe5e8d5940ac8c6e99cc07052fe14946974555ba"+ url: "https://pub.dev"source: hostedversion: "0.3.1"xdg_directories: