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
feat: support readonly table (#6997)
Lucas867d515a35eb
diff --git a/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml b/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xmlindex 49118a1532..74d5c5e494 100644--- a/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml+++ b/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml@@ -36,10 +36,6 @@<data android:scheme="http" /><data android:scheme="https" /><data android:scheme="appflowy-flutter" />- <data android:scheme="https" android:host="test.appflowy.io" />- <data android:scheme="https" android:host="appflowy.io" />- <data android:scheme="https" android:host="test.appflowy.com" />- <data android:scheme="https" android:host="appflowy.com" /></intent-filter></activity><!--diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_image.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_image.dartindex ce62fa60f6..6e6c9b1772 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_image.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_image.dart@@ -101,8 +101,10 @@ extension PasteFromImage on EditorState {await File(copyToPath).writeAsBytes(imageBytes);final String? path;+ CustomImageType type;if (isLocalMode) {path = await saveImageToLocalStorage(copyToPath);+ type = CustomImageType.local;} else {final result = await saveImageToCloudStorage(copyToPath, documentId);@@ -117,10 +119,11 @@ extension PasteFromImage on EditorState {}path = result.$1;+ type = CustomImageType.internal;}if (path != null) {- await insertImageNode(path, selection: selection);+ await insertImageNode(path, selection: selection, type: type);}return true;@@ -140,6 +143,7 @@ extension PasteFromImage on EditorState {Future<void> insertImageNode(String src, {Selection? selection,+ required CustomImageType type,}) async {selection ??= this.selection;if (selection == null || !selection.isCollapsed) {@@ -156,16 +160,18 @@ extension PasteFromImage on EditorState {transaction..insertNode(node.path,- imageNode(+ customImageNode(url: src,+ type: type,),)..deleteNode(node);} else {transaction.insertNode(node.path.next,- imageNode(+ customImageNode(url: src,+ type: type,),);}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation.dartindex a5ede15906..8daaa9f86f 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/inline_math_equation/inline_math_equation.dart@@ -36,7 +36,6 @@ class _InlineMathEquationState extends State<InlineMathEquation> {@overrideWidget build(BuildContext context) {- final theme = Theme.of(context);return _IgnoreParentPointer(child: AppFlowyPopover(controller: popoverController,@@ -60,33 +59,42 @@ class _InlineMathEquationState extends State<InlineMathEquation> {},offset: const Offset(0, 10),child: Padding(- padding: const EdgeInsets.symmetric(vertical: 8.0),+ padding: const EdgeInsets.symmetric(vertical: 2.0),child: MouseRegion(cursor: SystemMouseCursors.click,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- const HSpace(2),- Math.tex(- widget.formula,- options: MathOptions(- style: MathStyle.text,- mathFontOptions: const FontOptions(- fontShape: FontStyle.italic,- ),- fontSize: 14.0,- color: widget.textStyle?.color ??- theme.colorScheme.onSurface,- ),- ),- const HSpace(2),- ],- ),+ child: _buildMathEquation(context),),),),);}++ Widget _buildMathEquation(BuildContext context) {+ final theme = Theme.of(context);+ final longEq = Math.tex(+ widget.formula,+ textStyle: widget.textStyle,+ mathStyle: MathStyle.text,+ options: MathOptions(+ style: MathStyle.text,+ mathFontOptions: const FontOptions(+ fontShape: FontStyle.italic,+ ),+ fontSize: 14.0,+ color: widget.textStyle?.color ?? theme.colorScheme.onSurface,+ ),+ onErrorFallback: (errmsg) {+ return FlowyText(+ errmsg.message,+ );+ },+ );+ return Row(+ children: [+ longEq,+ ],+ );+ }}class MathInputTextField extends StatefulWidget {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_cell_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_cell_block_component.dartindex ca072b6e32..23c9df08f3 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_cell_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_cell_block_component.dart@@ -124,27 +124,30 @@ class SimpleTableCellBlockWidgetState extends State<SimpleTableCellBlockWidget>clipBehavior: Clip.none,children: [_buildCell(),- if (node.columnIndex == 0)+ if (editorState.editable) ...[+ if (node.columnIndex == 0)+ Positioned(+ top: 0,+ bottom: 0,+ left: -SimpleTableConstants.tableLeftPadding,+ child: _buildRowMoreActionButton(),+ ),+ if (node.rowIndex == 0)+ Positioned(+ left: 0,+ right: 0,+ child: _buildColumnMoreActionButton(),+ ),Positioned(- top: 0,- bottom: 0,- left: -SimpleTableConstants.tableLeftPadding,- child: _buildRowMoreActionButton(),- ),- if (node.rowIndex == 0)- Positioned(- left: 0,right: 0,- child: _buildColumnMoreActionButton(),- ),- Positioned(- right: 0,- top: node.rowIndex == 0 ? SimpleTableConstants.tableTopPadding : 0,- bottom: 0,- child: SimpleTableColumnResizeHandle(- node: node,+ top:+ node.rowIndex == 0 ? SimpleTableConstants.tableTopPadding : 0,+ bottom: 0,+ child: SimpleTableColumnResizeHandle(+ node: node,+ ),),- ),+ ],],),);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_border_builder.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_border_builder.dartindex f44c394694..b24498c599 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_border_builder.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_border_builder.dart@@ -1,6 +1,7 @@import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:flutter/material.dart';+import 'package:provider/provider.dart';class SimpleTableBorderBuilder {SimpleTableBorderBuilder({@@ -38,7 +39,13 @@ class SimpleTableBorderBuilder {// check if the cell is in the reordering columnfinal isReordering = simpleTableContext.isReordering;- if (isReordering && (isCellInHoveringColumn || isCellInHoveringRow)) {+ final editorState = context.read<EditorState>();+ final editable = editorState.editable;++ if (!editable) {+ return buildCellBorder();+ } else if (isReordering &&+ (isCellInHoveringColumn || isCellInHoveringRow)) {return buildReorderingBorder();} else if (simpleTableContext.isSelectingTable.value) {return buildSelectingTableBorder();diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_widget.dartindex 563570bf27..17472029de 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_widget.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_widgets/simple_table_widget.dart@@ -130,21 +130,23 @@ class _SimpleTableWidgetState extends State<SimpleTableWidget> {},child: child,),- if (widget.enableAddColumnButton)- SimpleTableAddColumnHoverButton(- editorState: editorState,- tableNode: widget.node,- ),- if (widget.enableAddRowButton)- SimpleTableAddRowHoverButton(- editorState: editorState,- tableNode: widget.node,- ),- if (widget.enableAddColumnAndRowButton)- SimpleTableAddColumnAndRowHoverButton(- editorState: editorState,- node: widget.node,- ),+ if (editorState.editable) ...[+ if (widget.enableAddColumnButton)+ SimpleTableAddColumnHoverButton(+ editorState: editorState,+ tableNode: widget.node,+ ),+ if (widget.enableAddRowButton)+ SimpleTableAddRowHoverButton(+ editorState: editorState,+ tableNode: widget.node,+ ),+ if (widget.enableAddColumnAndRowButton)+ SimpleTableAddColumnAndRowHoverButton(+ editorState: editorState,+ node: widget.node,+ ),+ ],],),),diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dartindex 003ed82ecf..24287ad411 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart@@ -359,12 +359,12 @@ class EditorStyleCustomizer {final formula = attributes[InlineMathEquationKeys.formula];if (formula is String) {return WidgetSpan(- alignment: PlaceholderAlignment.middle,+ style: after.style,child: InlineMathEquation(node: node,index: index,formula: formula,- textStyle: style().textStyleConfiguration.text,+ textStyle: after.style ?? style().textStyleConfiguration.text,),);}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/image_provider.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/image_provider.dartindex 359458c6e4..7fb9f1edbe 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/image_provider.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/image_provider.dart@@ -1,8 +1,8 @@-import 'package:flutter/widgets.dart';-import 'package:appflowy/plugins/document/presentation/editor_plugins/image/common.dart';import 'package:appflowy/shared/appflowy_network_image.dart';+import 'package:appflowy/shared/patterns/common_patterns.dart';import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';+import 'package:flutter/widgets.dart';/// Abstract class for providing images to the [InteractiveImageViewer].///@@ -54,7 +54,8 @@ class AFBlockImageProvider implements AFImageProvider {]) {final image = getImage(index);- if (image.type == CustomImageType.local) {+ if (image.type == CustomImageType.local &&+ localPathRegex.hasMatch(image.url)) {return Image(image: image.toImageProvider());}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/interactive_image_toolbar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/interactive_image_toolbar.dartindex c1d9823bd1..a602aaed58 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/interactive_image_toolbar.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/image_viewer/interactive_image_toolbar.dart@@ -218,14 +218,13 @@ class InteractiveImageToolbar extends StatelessWidget {}Future<void> _locateOrDownloadImage(BuildContext context) async {- if (currentImage.isLocal) {+ if (currentImage.isLocal || currentImage.isNotInternal) {/// If the image type is local, we simply open the image- await afLaunchUri(Uri.file(currentImage.url));- } else if (currentImage.isNotInternal) {- // In case of eg. Unsplash images (images without extension type in URL),+ ///+ /// // In case of eg. Unsplash images (images without extension type in URL),// we don't know their mimetype. In the future we can write a parser// using the Mime package and read the image to get the proper extension.- await afLaunchUri(Uri.parse(currentImage.url));+ await afLaunchUrlString(currentImage.url);} else {if (userProfile == null) {return showSnapBar(diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex d06a7de798..c83b5456a1 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -803,10 +803,10 @@ packages:dependency: "direct main"description:name: flutter_math_fork- sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8"+ sha256: "284bab89b2fbf1bc3a0baf13d011c1dd324d004e35d177626b77f2fc056366ac"url: "https://pub.dev"source: hosted- version: "0.7.2"+ version: "0.7.3"flutter_plugin_android_lifecycle:dependency: transitivedescription:@@ -860,6 +860,14 @@ packages:description: fluttersource: sdkversion: "0.0.0"+ flutter_tex:+ dependency: "direct main"+ description:+ name: flutter_tex+ sha256: "816074d8a49dd2301704aaf481f9b052b935b8790018a88b69a60d003d5e89e4"+ url: "https://pub.dev"+ source: hosted+ version: "4.0.9"flutter_web_plugins:dependency: transitivedescription: flutter@@ -2306,6 +2314,46 @@ packages:url: "https://pub.dev"source: hostedversion: "1.2.1"+ webview_flutter:+ dependency: transitive+ description:+ name: webview_flutter+ sha256: "6869c8786d179f929144b4a1f86e09ac0eddfe475984951ea6c634774c16b522"+ url: "https://pub.dev"+ source: hosted+ version: "4.8.0"+ webview_flutter_android:+ dependency: transitive+ description:+ name: webview_flutter_android+ sha256: ed021f27ae621bc97a6019fb601ab16331a3db4bf8afa305e9f6689bdb3edced+ url: "https://pub.dev"+ source: hosted+ version: "3.16.8"+ webview_flutter_platform_interface:+ dependency: transitive+ description:+ name: webview_flutter_platform_interface+ sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d+ url: "https://pub.dev"+ source: hosted+ version: "2.10.0"+ webview_flutter_plus:+ dependency: transitive+ description:+ name: webview_flutter_plus+ sha256: "57ec757eada4e23bfb015f5d5f84a45108cb2c29b1e77e23956768cd5e0c8468"+ url: "https://pub.dev"+ source: hosted+ version: "0.4.7"+ webview_flutter_wkwebview:+ dependency: transitive+ description:+ name: webview_flutter_wkwebview+ sha256: "9c62cc46fa4f2d41e10ab81014c1de470a6c6f26051a2de32111b2ee55287feb"+ url: "https://pub.dev"+ source: hosted+ version: "3.14.0"win32:dependency: transitivedescription:diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex 59e53c8e20..684858ee91 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -74,10 +74,11 @@ dependencies:git:url: https://github.com/LucasXu0/emoji_mart.gitref: "38c2c42"- flutter_math_fork: ^0.7.2+ flutter_math_fork: ^0.7.3flutter_slidable: ^3.0.0flutter_staggered_grid_view: ^0.7.0+ flutter_tex: ^4.0.9fluttertoast: ^8.2.6freezed_annotation: ^2.2.0get_it: ^7.6.0