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: save image should not copy the image (#7370)

Lucas4a7e20b3a571
diff --git a/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml b/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml
index fe9744ef8f..284ce0ffd7 100644
--- a/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml
+++ b/frontend/appflowy_flutter/android/app/src/main/AndroidManifest.xml
@@ -46,6 +46,8 @@
<meta-data android:name="io.flutter.embedding.android.EnableImpeller"
android:value="false" />
</application>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
+ tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to read files from external storage (outside application container).
@@ -68,4 +70,4 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.CAMERA" />
-</manifest>
+</manifest>
\ No newline at end of file
diff --git a/frontend/appflowy_flutter/ios/Podfile.lock b/frontend/appflowy_flutter/ios/Podfile.lock
index c87e0512f8..4b7ed5d639 100644
--- a/frontend/appflowy_flutter/ios/Podfile.lock
+++ b/frontend/appflowy_flutter/ios/Podfile.lock
@@ -66,6 +66,8 @@ PODS:
- permission_handler_apple (9.3.0):
- Flutter
- ReachabilitySwift (5.0.0)
+ - saver_gallery (0.0.1):
+ - Flutter
- SDWebImage (5.14.2):
- SDWebImage/Core (= 5.14.2)
- SDWebImage/Core (5.14.2)
@@ -109,6 +111,7 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
+ - saver_gallery (from `.symlinks/plugins/saver_gallery/ios`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
@@ -160,6 +163,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
+ saver_gallery:
+ :path: ".symlinks/plugins/saver_gallery/ios"
sentry_flutter:
:path: ".symlinks/plugins/sentry_flutter/ios"
share_plus:
@@ -195,6 +200,7 @@ SPEC CHECKSUMS:
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
+ saver_gallery: af2d0c762dafda254e0ad025ef0dabd6506cd490
SDWebImage: b9a731e1d6307f44ca703b3976d18c24ca561e84
Sentry: 1fe34e9c2cbba1e347623610d26db121dcb569f1
sentry_flutter: e24b397f9a61fa5bbefd8279c3b2242ca86faa90
diff --git a/frontend/appflowy_flutter/ios/Runner/Info.plist b/frontend/appflowy_flutter/ios/Runner/Info.plist
index d1afb2a9db..5d6a52bd2e 100644
--- a/frontend/appflowy_flutter/ios/Runner/Info.plist
+++ b/frontend/appflowy_flutter/ios/Runner/Info.plist
@@ -1,75 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
-<dict>
- <key>CADisableMinimumFrameDurationOnPhone</key>
- <true/>
- <key>CFBundleDevelopmentRegion</key>
- <string>$(DEVELOPMENT_LANGUAGE)</string>
- <key>CFBundleExecutable</key>
- <string>$(EXECUTABLE_NAME)</string>
- <key>CFBundleIdentifier</key>
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleLocalizations</key>
- <array>
- <string>en</string>
- </array>
- <key>CFBundleName</key>
- <string>AppFlowy</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>$(FLUTTER_BUILD_NAME)</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleURLTypes</key>
- <array>
+ <dict>
+ <key>CADisableMinimumFrameDurationOnPhone</key>
+ <true />
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleLocalizations</key>
+ <array>
+ <string>en</string>
+ </array>
+ <key>CFBundleName</key>
+ <string>AppFlowy</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>$(FLUTTER_BUILD_NAME)</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string></string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>appflowy-flutter</string>
+ </array>
+ </dict>
+ </array>
+ <key>CFBundleVersion</key>
+ <string>$(FLUTTER_BUILD_NUMBER)</string>
+ <key>FLTEnableImpeller</key>
+ <false />
+ <key>LSRequiresIPhoneOS</key>
+ <true />
+ <key>NSAppTransportSecurity</key>
<dict>
- <key>CFBundleURLName</key>
- <string></string>
- <key>CFBundleURLSchemes</key>
- <array>
- <string>appflowy-flutter</string>
- </array>
+ <key>NSAllowsArbitraryLoads</key>
+ <true />
</dict>
- </array>
- <key>CFBundleVersion</key>
- <string>$(FLUTTER_BUILD_NUMBER)</string>
- <key>FLTEnableImpeller</key>
- <false/>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>NSAppTransportSecurity</key>
- <dict>
- <key>NSAllowsArbitraryLoads</key>
- <true/>
+ <key>NSPhotoLibraryUsageDescription</key>
+ <string>AppFlowy needs access to your photos to let you add images to your documents</string>
+ <key>NSPhotoLibraryAddUsageDescription</key>
+ <string>AppFlowy needs access to your photos to let you add images to your photo library</string>
+ <key>UIApplicationSupportsIndirectInputEvents</key>
+ <true />
+ <key>NSCameraUsageDescription</key>
+ <string>AppFlowy needs access to your camera to let you add images to your documents from
+ camera</string>
+ <key>UILaunchStoryboardName</key>
+ <string>LaunchScreen</string>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ </array>
+ <key>UISupportsDocumentBrowser</key>
+ <true />
+ <key>UIViewControllerBasedStatusBarAppearance</key>
+ <false />
</dict>
- <key>NSPhotoLibraryUsageDescription</key>
- <string>AppFlowy needs access to your photos to let you add images to your documents</string>
- <key>UIApplicationSupportsIndirectInputEvents</key>
- <true/>
- <key>NSCameraUsageDescription</key>
- <string>AppFlowy needs access to your camera to let you add images to your documents from camera</string>
- <key>UILaunchStoryboardName</key>
- <string>LaunchScreen</string>
- <key>UIMainStoryboardFile</key>
- <string>Main</string>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- </array>
- <key>UISupportedInterfaceOrientations~ipad</key>
- <array>
- <string>UIInterfaceOrientationLandscapeLeft</string>
- <string>UIInterfaceOrientationLandscapeRight</string>
- <string>UIInterfaceOrientationPortrait</string>
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
- </array>
- <key>UISupportsDocumentBrowser</key>
- <true/>
- <key>UIViewControllerBasedStatusBarAppearance</key>
- <false/>
-</dict>
-</plist>
+</plist>
\ No newline at end of file
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
index f178808390..e14275ca30 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
@@ -101,7 +101,7 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
styleCustomizer: styleCustomizer,
// the editor is not editable in the chat
editable: false,
- alwaysDistributeSimpleTableColumnWidths: true,
+ alwaysDistributeSimpleTableColumnWidths: UniversalPlatform.isDesktop,
);
return IntrinsicHeight(
child: AppFlowyEditor(
@@ -109,6 +109,7 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
// the editor is not editable in the chat
editable: false,
disableKeyboardService: UniversalPlatform.isMobile,
+ disableSelectionService: UniversalPlatform.isMobile,
editorStyle: editorStyle,
editorScrollController: scrollController,
blockComponentBuilders: blockBuilders,
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart
index b0aa995107..a54d2b8044 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart
@@ -10,7 +10,6 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_chat_core/flutter_chat_core.dart';
-import 'package:universal_platform/universal_platform.dart';
import '../layout_define.dart';
import 'ai_markdown_text.dart';
@@ -106,10 +105,7 @@ class ChatAIMessageWidget extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- IgnorePointer(
- ignoring: UniversalPlatform.isMobile,
- child: AIMarkdownText(markdown: state.text),
- ),
+ AIMarkdownText(markdown: state.text),
if (state.sources.isNotEmpty)
AIMessageMetadata(
sources: state.sources,
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart
index 12d7fd4da6..0471358464 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart
@@ -9,8 +9,9 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_p
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/unsupport_image_widget.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/image_placeholder.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/resizeable_image.dart';
+import 'package:appflowy/shared/custom_image_cache_manager.dart';
+import 'package:appflowy/shared/permission/permission_checker.dart';
import 'package:appflowy/startup/startup.dart';
-import 'package:appflowy/workspace/presentation/home/toast.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy/workspace/presentation/widgets/image_viewer/image_provider.dart';
import 'package:appflowy/workspace/presentation/widgets/image_viewer/interactive_image_viewer.dart';
@@ -19,6 +20,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
+import 'package:saver_gallery/saver_gallery.dart';
import 'package:string_validator/string_validator.dart';
import 'package:universal_platform/universal_platform.dart';
@@ -388,11 +390,8 @@ class CustomImageBlockComponentState extends State<CustomImageBlockComponent>
),
onTap: () async {
context.pop();
- showSnackBarMessage(
- context,
- LocaleKeys.document_plugins_image_copiedToPasteBoard.tr(),
- );
- await getIt<ClipboardService>().setPlainText(url);
+ // save the image to the photo library
+ await _saveImageToGallery(url);
},
),
];
@@ -413,4 +412,28 @@ class CustomImageBlockComponentState extends State<CustomImageBlockComponent>
return true;
}
+
+ Future<void> _saveImageToGallery(String url) async {
+ final permission = await PermissionChecker.checkPhotoPermission(context);
+ if (!permission) {
+ return;
+ }
+
+ final imageFile = await CustomImageCacheManager().getSingleFile(url);
+ if (imageFile.existsSync()) {
+ final result = await SaverGallery.saveImage(
+ imageFile.readAsBytesSync(),
+ fileName: imageFile.basename,
+ skipIfExists: false,
+ );
+ if (mounted) {
+ showToastNotification(
+ context,
+ message: result.isSuccess
+ ? LocaleKeys.document_imageBlock_successToAddImageToGallery.tr()
+ : LocaleKeys.document_imageBlock_failedToAddImageToGallery.tr(),
+ );
+ }
+ }
+ }
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_constants.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_constants.dart
index 79201b38fa..295a636e09 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_constants.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/simple_table/simple_table_constants.dart
@@ -191,7 +191,7 @@ class SimpleTableContext {
class SimpleTableConstants {
/// Table
- static const defaultColumnWidth = 120.0;
+ static const defaultColumnWidth = 160.0;
static const minimumColumnWidth = 36.0;
static const defaultRowHeight = 36.0;
diff --git a/frontend/appflowy_flutter/lib/shared/permission/permission_checker.dart b/frontend/appflowy_flutter/lib/shared/permission/permission_checker.dart
index df260bad71..4b5ad56ab1 100644
--- a/frontend/appflowy_flutter/lib/shared/permission/permission_checker.dart
+++ b/frontend/appflowy_flutter/lib/shared/permission/permission_checker.dart
@@ -9,9 +9,9 @@ import 'package:appflowy/mobile/presentation/widgets/show_flowy_mobile_confirm_d
import 'package:appflowy/startup/tasks/device_info_task.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
+import 'package:universal_platform/universal_platform.dart';
class PermissionChecker {
static Future<bool> checkPhotoPermission(BuildContext context) async {
@@ -48,7 +48,7 @@ class PermissionChecker {
} else if (status.isDenied) {
// https://github.com/Baseflow/flutter-permission-handler/issues/1262#issuecomment-2006340937
Permission permission = Permission.photos;
- if (defaultTargetPlatform == TargetPlatform.android &&
+ if (UniversalPlatform.isAndroid &&
ApplicationInfo.androidSDKVersion <= 32) {
permission = Permission.storage;
}
diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock
index fd9c028f5a..d08161d850 100644
--- a/frontend/appflowy_flutter/pubspec.lock
+++ b/frontend/appflowy_flutter/pubspec.lock
@@ -90,8 +90,8 @@ packages:
dependency: "direct main"
description:
path: "."
- ref: "6f5c957"
- resolved-ref: "6f5c957049c90d942e56314171c7630b3d6d858d"
+ ref: "2745294"
+ resolved-ref: "2745294587cd3e2ff7ac0b6b91135c3ddcbb4274"
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
source: git
version: "5.0.0"
@@ -1764,6 +1764,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
+ saver_gallery:
+ dependency: "direct main"
+ description:
+ name: saver_gallery
+ sha256: bf59475e50b73d666630bed7a5fdb621fed92d637f64e3c61ce81653ec6a833c
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.0.1"
scaled_app:
dependency: "direct main"
description:
diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml
index 244a8dfa9c..39ed088126 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -146,6 +146,7 @@ dependencies:
version: ^3.0.2
xml: ^6.5.0
window_manager: ^0.4.3
+ saver_gallery: ^4.0.1
dev_dependencies:
bloc_test: ^9.1.2
@@ -178,7 +179,7 @@ dependency_overrides:
appflowy_editor:
git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git
- ref: "6f5c957"
+ ref: "2745294"
appflowy_editor_plugins:
git: