Skip to content

Commit

Permalink
fix: remove super_clipboard from flutter_quill_extensions and move it…
Browse files Browse the repository at this point in the history
… to quill_super_clipboard (#2322)
  • Loading branch information
EchoEllet authored Oct 17, 2024
1 parent b9279d7 commit 5f2058d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 198 deletions.
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {

defaultConfig {
applicationId = "com.example.example"
minSdk = 23
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
Expand Down
7 changes: 0 additions & 7 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
android:name="flutterEmbedding"
android:value="2" />

<!-- For `super_clipboard` plugin https://pub.dev/packages/super_clipboard -->
<provider
android:name="com.superlist.super_native_extensions.DataProvider"
android:authorities="com.example.example.SuperClipboardDataProvider"
android:exported="true"
android:grantUriPermissions="true" />

<!-- For `quill_native_bridge` plugin https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge#-platform-configuration -->
<provider
android:name="androidx.core.content.FileProvider"
Expand Down
8 changes: 0 additions & 8 deletions example/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include <desktop_drop/desktop_drop_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <irondash_engine_context/irondash_engine_context_plugin.h>
#include <super_native_extensions/super_native_extensions_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
Expand All @@ -19,12 +17,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) irondash_engine_context_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "IrondashEngineContextPlugin");
irondash_engine_context_plugin_register_with_registrar(irondash_engine_context_registrar);
g_autoptr(FlPluginRegistrar) super_native_extensions_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SuperNativeExtensionsPlugin");
super_native_extensions_plugin_register_with_registrar(super_native_extensions_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
2 changes: 0 additions & 2 deletions example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST
desktop_drop
file_selector_linux
irondash_engine_context
super_native_extensions
url_launcher_linux
)

Expand Down
8 changes: 1 addition & 7 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ import FlutterMacOS
import Foundation

import desktop_drop
import device_info_plus
import file_selector_macos
import gal
import irondash_engine_context
import path_provider_foundation
import quill_native_bridge_macos
import share_plus
import sqflite_darwin
import super_native_extensions
import sqflite
import url_launcher_macos
import video_player_avfoundation

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
QuillNativeBridgePlugin.register(with: registry.registrar(forPlugin: "QuillNativeBridgePlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
}
22 changes: 2 additions & 20 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
PODS:
- desktop_drop (0.0.1):
- FlutterMacOS
- device_info_plus (0.0.1):
- FlutterMacOS
- file_selector_macos (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- gal (1.0.0):
- Flutter
- FlutterMacOS
- irondash_engine_context (0.0.1):
- FlutterMacOS
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -21,8 +17,6 @@ PODS:
- sqflite (0.0.3):
- Flutter
- FlutterMacOS
- super_native_extensions (0.0.1):
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS
- video_player_avfoundation (0.0.1):
Expand All @@ -31,32 +25,25 @@ PODS:

DEPENDENCIES:
- desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`)
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
- file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- gal (from `Flutter/ephemeral/.symlinks/plugins/gal/darwin`)
- irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- quill_native_bridge_macos (from `Flutter/ephemeral/.symlinks/plugins/quill_native_bridge_macos/macos`)
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
- super_native_extensions (from `Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
- video_player_avfoundation (from `Flutter/ephemeral/.symlinks/plugins/video_player_avfoundation/darwin`)

EXTERNAL SOURCES:
desktop_drop:
:path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos
device_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
file_selector_macos:
:path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
gal:
:path: Flutter/ephemeral/.symlinks/plugins/gal/darwin
irondash_engine_context:
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
quill_native_bridge_macos:
Expand All @@ -65,26 +52,21 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
sqflite:
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin
super_native_extensions:
:path: Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
video_player_avfoundation:
:path: Flutter/ephemeral/.symlinks/plugins/video_player_avfoundation/darwin

SPEC CHECKSUMS:
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2
file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
quill_native_bridge_macos: f90985c5269ac7ba84d933605b463d96e5f544fe
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3

PODFILE CHECKSUM: 7159dd71cf9f57a5669bb2dee7a5030dbcc0483f
Expand Down
6 changes: 0 additions & 6 deletions example/windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include <desktop_drop/desktop_drop_plugin.h>
#include <file_selector_windows/file_selector_windows.h>
#include <gal/gal_plugin_c_api.h>
#include <irondash_engine_context/irondash_engine_context_plugin_c_api.h>
#include <share_plus/share_plus_windows_plugin_c_api.h>
#include <super_native_extensions/super_native_extensions_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
Expand All @@ -21,12 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("FileSelectorWindows"));
GalPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GalPluginCApi"));
IrondashEngineContextPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("IrondashEngineContextPluginCApi"));
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
SuperNativeExtensionsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}
2 changes: 0 additions & 2 deletions example/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
desktop_drop
file_selector_windows
gal
irondash_engine_context
share_plus
super_native_extensions
url_launcher_windows
)

Expand Down
8 changes: 4 additions & 4 deletions flutter_quill_extensions/lib/flutter_quill_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'package:flutter_quill/flutter_quill_internal.dart'
show ClipboardServiceProvider;
import 'package:meta/meta.dart' show experimental;

import 'src/editor_toolbar_controller_shared/clipboard/super_clipboard_service.dart';

export 'src/common/extensions/controller_ext.dart';
export 'src/common/utils/utils.dart';
export 'src/editor/image/image_embed.dart';
Expand Down Expand Up @@ -67,11 +65,13 @@ class FlutterQuillExtensions {
'The functionality of super_clipboard is now built-in in recent versions of flutter_quill.\n'
'To migrate, remove this function call and see '
'https://pub.dev/packages/quill_native_bridge#-platform-configuration (optional for copying images on Android) to use quill_native_bridge implementation (the new default).\n'
'Or if you want to use super_clipboard implementation (support might discontinued in newer versions), use the package https://pub.dev/packages/quill_super_clipboard\n'
'Or if you want to use super_clipboard implementation (support might discontinued in newer versions), use the experimental package: https://pub.dev/packages/quill_super_clipboard\n'
'See https://github.com/singerdmx/flutter-quill/pull/2230 for more details.',
)
@experimental
static void useSuperClipboardPlugin() {
ClipboardServiceProvider.setInstance(SuperClipboardService());
throw UnimplementedError(
'The super_clipboard plugin is no longer a dependency. See the deprecation message of FlutterQuillExtensions.useSuperClipboardPlugin()',
);
}
}
Original file line number Diff line number Diff line change
@@ -1,144 +1,16 @@
import 'dart:async' show Completer;
import 'dart:convert' show utf8;
@Deprecated(
'The super_clipboard implementation has been moved into a separate package: https://pub.dev/packages/quill_super_clipboard and this class will be removed in future releases.\n'
'The new default implementation of flutter_quill is https://pub.dev/packages/quill_native_bridge and supports required features for rich text pasting.\n'
'Also see https://github.com/singerdmx/flutter-quill/pull/2230 and https://pub.dev/packages/quill_native_bridge#-platform-configuration',
)
library;

import 'package:flutter/foundation.dart';
import 'package:flutter_quill/flutter_quill_internal.dart'
show ClipboardService;
import 'package:meta/meta.dart' show experimental;

import 'package:super_clipboard/super_clipboard.dart';

/// Implementation using the https://pub.dev/packages/super_clipboard plugin.
@experimental
class SuperClipboardService extends ClipboardService {
/// [Null] if the Clipboard API is not supported on this platform
/// https://pub.dev/packages/super_clipboard#usage
SystemClipboard? _getSuperClipboard() {
return SystemClipboard.instance;
}

SystemClipboard _getSuperClipboardOrThrow() {
final clipboard = _getSuperClipboard();
if (clipboard == null) {
// To avoid getting this exception, use _canProvide()
throw UnsupportedError(
'Clipboard API is not supported on this platform.',
);
}
return clipboard;
}

Future<bool> _canProvide({required DataFormat format}) async {
final clipboard = _getSuperClipboard();
if (clipboard == null) {
return false;
}
final reader = await clipboard.read();
return reader.canProvide(format);
}

Future<Uint8List> _provideFileAsBytes({
required SimpleFileFormat format,
}) async {
final clipboard = _getSuperClipboardOrThrow();
final reader = await clipboard.read();
final completer = Completer<Uint8List>();

reader.getFile(
format,
(file) async {
final bytes = await file.readAll();
completer.complete(bytes);
},
onError: completer.completeError,
);
final bytes = await completer.future;
return bytes;
}

Future<String> _provideFileAsString({
required SimpleFileFormat format,
}) async {
final fileBytes = await _provideFileAsBytes(format: format);
final fileText = utf8.decode(fileBytes);
return fileText;
}

/// According to super_clipboard docs, will return `null` if the value
/// is not available or the data is virtual (macOS and Windows)
Future<String?> _provideSimpleValueFormatAsString({
required SimpleValueFormat<String> format,
}) async {
final clipboard = _getSuperClipboardOrThrow();
final reader = await clipboard.read();
final value = await reader.readValue<String>(format);
return value;
}

@override
Future<String?> getHtmlText() async {
if (!(await _canProvide(format: Formats.htmlText))) {
return null;
}
return _provideSimpleValueFormatAsString(format: Formats.htmlText);
}

@override
Future<String?> getHtmlFile() async {
if (!(await _canProvide(format: Formats.htmlFile))) {
return null;
}
return await _provideFileAsString(format: Formats.htmlFile);
}

@override
Future<Uint8List?> getGifFile() async {
if (!(await _canProvide(format: Formats.gif))) {
return null;
}
return await _provideFileAsBytes(format: Formats.gif);
}

@override
Future<Uint8List?> getImageFile() async {
final canProvidePngFile = await _canProvide(format: Formats.png);
if (canProvidePngFile) {
return _provideFileAsBytes(format: Formats.png);
}
final canProvideJpegFile = await _canProvide(format: Formats.jpeg);
if (canProvideJpegFile) {
return _provideFileAsBytes(format: Formats.jpeg);
}
return null;
}

@override
Future<String?> getMarkdownFile() async {
// Formats.md is for markdown files
if (!(await _canProvide(format: Formats.md))) {
return null;
}
return await _provideFileAsString(format: Formats.md);
}

@override
Future<void> copyImage(Uint8List imageBytes) async {
final clipboard = SystemClipboard.instance;
if (clipboard == null) {
return;
}
final item = DataWriterItem()..add(Formats.png(imageBytes));
await clipboard.write([item]);
}

@override
Future<bool> get hasClipboardContent async {
final clipboard = _getSuperClipboard();
if (clipboard == null) {
return false;
}
final reader = await clipboard.read();
final availablePlatformFormats = reader.platformFormats;
return availablePlatformFormats.isNotEmpty;
}
}
@Deprecated(
'The super_clipboard implementation has been moved into a separate package: https://pub.dev/packages/quill_super_clipboard and this class will be removed in future releases.\n'
'The new default implementation of flutter_quill is https://pub.dev/packages/quill_native_bridge and supports required features for rich text pasting.\n'
'Also see https://github.com/singerdmx/flutter-quill/pull/2230 and https://pub.dev/packages/quill_native_bridge#-platform-configuration',
)
class SuperClipboardService {}
1 change: 0 additions & 1 deletion flutter_quill_extensions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dependencies:
# Plugins
video_player: ^2.8.1
url_launcher: ^6.2.1
super_clipboard: ^0.8.22
gal: ^2.3.0
gal_linux: ^0.1.0
image_picker: ^1.0.4
Expand Down

0 comments on commit 5f2058d

Please sign in to comment.