Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use quill_native_bridge as default impl in DefaultClipboardService, fix related bugs in the extensions package #2230

Merged
merged 102 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
4a343e4
feat(quill_native_bridge): add initial implementation for getClipboar…
EchoEllet Sep 15, 2024
013a162
chore(example): use quill_native_bridge from path in dependency_overr…
EchoEllet Sep 15, 2024
9397b6c
feat: use quill_native_bridge for HTML Clipboard in flutter_quill and…
EchoEllet Sep 15, 2024
e6ff099
feat(quill_native_bridge): extend the support for macOS.
EchoEllet Sep 15, 2024
f71f57a
chore(example): clear todos in app module build.gradle
EchoEllet Sep 15, 2024
f9dac24
chore(android): additional check before accessing the clip data item
EchoEllet Sep 16, 2024
ff2f918
fix(flutter_quill_extensions): unrelated bug for copying an image (ne…
EchoEllet Sep 16, 2024
344eea6
feat: add copyImageToClipboard() method channel, an asset file in the…
EchoEllet Sep 16, 2024
660cb0e
docs(readme): add optional step to configure copying images to the cl…
EchoEllet Sep 16, 2024
f7c3589
feat: use copyImageToClipboard() in flutter_quill_extensions, fix com…
EchoEllet Sep 16, 2024
9743d47
chore: correct name of _loadImageBytesFromImageProvider()
EchoEllet Sep 16, 2024
710440b
feat: add web support for copyImageToClipboard()
EchoEllet Sep 16, 2024
9840745
feat: (WIP) retriving image file from clipboard, simplify ClipboardSe…
EchoEllet Sep 17, 2024
6f91fdb
chore(example): rename _flutterQuillAssetImage to _kFlutterQuillAsset…
EchoEllet Sep 17, 2024
0f9986f
chore(example): update error messages in quill_native_bridge example
EchoEllet Sep 17, 2024
1837a37
feat: add support for gif, fix unhandled exception on Android only wh…
EchoEllet Sep 19, 2024
ffba185
chore(example): configure the Android example for copying images to t…
EchoEllet Sep 19, 2024
c9aec82
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 19, 2024
cad0307
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 20, 2024
da77243
feat: support for web (WIP, will be updated soon)
EchoEllet Sep 20, 2024
685f495
chore: merge master branch and fix conflicts
EchoEllet Sep 21, 2024
499bdee
chore: annotate ClipboardService and related classes as experimental
EchoEllet Sep 21, 2024
76246b5
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 21, 2024
d89073a
chore: temporarily add dependency_overrides to fix build failure - re…
EchoEllet Sep 21, 2024
b1ce6a2
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 21, 2024
bfeebcc
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 21, 2024
d8c8f10
feat: seperate web implementation from quill_native_bridge into quill…
EchoEllet Sep 21, 2024
0c36eee
chore: update description of quill_native_bridge_web
EchoEllet Sep 21, 2024
82642da
chore(web): avoid using jsify() when possible
EchoEllet Sep 21, 2024
eb9f100
chore: publish and use quill_native_bridge_web in quill_native_bridge…
EchoEllet Sep 21, 2024
6fa9c05
docs(readme): use pub.dev link of quill_native_bridge in quill_native…
EchoEllet Sep 21, 2024
12c9b92
chore: use .toJS in clipboardItem map (minor change)
EchoEllet Sep 21, 2024
e9d6285
fix: use hosted quill_native_bridge in dependencies and override with…
EchoEllet Sep 21, 2024
7479abc
fix: update minimum required version of Flutter/Dart by quill_native_…
EchoEllet Sep 22, 2024
2beb39e
test: write basic integration tests for getClipboardImage() and copyI…
EchoEllet Sep 22, 2024
36b8f52
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 22, 2024
0dc9a42
feat: add copyHTMLToClipboard(), add integration tests for copyHTMLTo…
EchoEllet Sep 22, 2024
4382209
chore: cleanup QuillNativeBridgeWeb, extract mime constants, organize…
EchoEllet Sep 22, 2024
f0b5241
fix(web): issue caused by previous commit
EchoEllet Sep 22, 2024
2d8b135
docs(web): update methods of QuillNativeBridge to reflect the web sup…
EchoEllet Sep 22, 2024
686e0ff
chore(android): cleanup the check for HTML from the clipboard in getC…
EchoEllet Sep 22, 2024
47f05f4
test: add a test for getClipboardHTML to ensure it's not null only wh…
EchoEllet Sep 22, 2024
351dad8
ci: attempt to fix CI failure by updating outdated path of quill_nati…
EchoEllet Sep 22, 2024
f1c9913
docs: document why platform implementations of QuillNativeBridgePlatf…
EchoEllet Sep 23, 2024
4e65d65
chore(example): add windows platform runner example using Flutter CLI…
EchoEllet Sep 23, 2024
9300c4a
feat: (WIP) add windows experimental support for getClipboardHTML(), …
EchoEllet Sep 23, 2024
219ee7b
fix(docs): update incorrect description of quill_native_bridge_window…
EchoEllet Sep 23, 2024
c036553
refactor: move plugin platform interface to quill_native_bridge_platf…
EchoEllet Sep 23, 2024
1e4d0e2
chore: (WIP): publish quill_native_bridge 10.7.5
EchoEllet Sep 23, 2024
217ef1a
chore: (WIP) publish quill_native_bridge_web to use quill_native_brid…
EchoEllet Sep 23, 2024
e49d6f3
chore(example): add linux platform runner example using Flutter CLI (…
EchoEllet Sep 23, 2024
57a6b8d
feat(linux): (WIP) highly experimental linux support using xclip
EchoEllet Sep 24, 2024
3d6bee6
fix(windows): non case sensitive check in stripWin32HtmlDescription()…
EchoEllet Sep 24, 2024
e1b0eb3
chore(example): unrelated change for windows in Flutter Quill example…
EchoEllet Sep 24, 2024
3cfdf18
chore: merge master branch and fix conflicts
EchoEllet Sep 25, 2024
2b7799b
chore(android): cleanup onMethodCall() in QuillNativeBridgePlugin
EchoEllet Sep 25, 2024
d2cd4e8
docs(readme): update docs to reflect the changes
EchoEllet Sep 25, 2024
86e235d
chore: use hasWebSupport instead of hardcoding the check directly in …
EchoEllet Sep 26, 2024
bf2e462
feat: rename MethodChannelQuillNativeBridge.methodChannel to testMeth…
EchoEllet Sep 26, 2024
d7e3064
refactor: move android implementation from quill_native_bridge to qui…
EchoEllet Sep 26, 2024
fb0f2b8
chore: update QuillNativeBridgeAndroid.registerWith() assert message
EchoEllet Sep 26, 2024
622e087
refactor(apple): move iOS and macOS implementation from quill_native_…
EchoEllet Sep 26, 2024
17845c8
chore: add quill_native_bridge_platform_interface in pubspec_overides…
EchoEllet Sep 26, 2024
d3e9357
refactor: rename copyHTMLToClipboard() and getClipboardHTML() to copy…
EchoEllet Sep 26, 2024
7321ef5
feat: more advance method to check the platform support check allowin…
EchoEllet Sep 26, 2024
707d370
chore(analysis): remove unused imports in quill_native_bridge and qui…
EchoEllet Sep 26, 2024
fd50828
fix(ci): temporarily pub get quill_native_bridge packages in main wor…
EchoEllet Sep 26, 2024
6939289
chore: format dart pigeon generated files as a workaround to CI failure
EchoEllet Sep 26, 2024
8d0cdb1
chore: merge master branch and fix conflicts
EchoEllet Sep 27, 2024
64ae54f
chore: merge master branch and fix conflicts
EchoEllet Sep 27, 2024
7847418
chore(deps): update flutter_lints to 5.0.0 in quill_native_bridge
EchoEllet Sep 27, 2024
f489acf
refactor(windows): move CloseClipboard() to finally block in getClipb…
EchoEllet Sep 27, 2024
6257e70
chore(windows): clear todo related to previous commit
EchoEllet Sep 27, 2024
a54ea77
chore(readme): remove description from the platform support table, us…
EchoEllet Sep 28, 2024
88d6675
chore(readme): use different emoji for platforms that doesn't support…
EchoEllet Sep 28, 2024
877240b
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Sep 28, 2024
2c2b283
style(windows): use TEXT and free from win32 instead of toNativeUtf16…
EchoEllet Sep 28, 2024
0d572c2
refactor(windows): only register HTML format id once
EchoEllet Sep 28, 2024
af80f16
feat(windows): (WIP) highly experimental support for copyHtmlToClipbo…
EchoEllet Sep 28, 2024
b30923f
refactor: extract supported platforms into Set for isSupported()
EchoEllet Sep 29, 2024
6794351
chore(windows): add error code in errors using GetLastError()
EchoEllet Sep 29, 2024
9c7ec6d
chore(windows): avoid passing the locked memory pointer to SetClipboa…
EchoEllet Sep 29, 2024
f69646c
docs(readme): document android platform configuration in quill_native…
EchoEllet Sep 29, 2024
1c6e7b8
fix(windows): (WIP) GlobalUnlock before SetClipboardData and GlobalFr…
EchoEllet Sep 29, 2024
781de0d
docs(readme): slighly improve platform configuration docs in quill_na…
EchoEllet Sep 29, 2024
ec6751f
fix(windows): GlobalUnlock() the handle instead of pointer before cal…
EchoEllet Sep 29, 2024
3c14070
chore(android): add reference to Flutter #63533
EchoEllet Sep 29, 2024
299a976
chore(android): define package in GeneratedMessages.kt, update relate…
EchoEllet Sep 30, 2024
f44a802
chore(android): ignore analysis warning for the generated code messag…
EchoEllet Sep 30, 2024
d5344da
feat: (WIP) add initial support for getClipboardFiles()
EchoEllet Oct 1, 2024
333497c
chore(ci): format generated messages.g.dart file to bypass CI failure
EchoEllet Oct 1, 2024
9ab4fd9
feat(linux): add support for getClipboardFiles()
EchoEllet Oct 1, 2024
a9a549f
docs: update old reference of QuillNativeBridgeFeature, add doc comme…
EchoEllet Oct 1, 2024
9f9faeb
chore(readme): add link for quill_native_bridge, correct minor typo
EchoEllet Oct 1, 2024
cbe6492
chore(docs): minor changes to update doc comment in QuillController
EchoEllet Oct 1, 2024
2f1851f
Merge remote-tracking branch 'origin/master' into feat/default-clipbo…
EchoEllet Oct 13, 2024
ae908ca
chore: move quill_native_bridge to https://github.com/FlutterQuill/qu…
EchoEllet Oct 14, 2024
c0f4e1a
docs(readme): improve the 'Rich Text Paste' section, drop the TODO fo…
EchoEllet Oct 15, 2024
414f5a1
chore: update deprecation message of FlutterQuillExtensions.useSuperC…
EchoEllet Oct 15, 2024
3401bac
chore(example): remove commnet of deprecated method FlutterQuillExten…
EchoEllet Oct 15, 2024
1c33424
chore: rename ClipboardService.copyImageToClipboard() to ClipboardSer…
EchoEllet Oct 15, 2024
6b46df4
chore: add a link to a TODO in DefaultClipboardService._getClipboardF…
EchoEllet Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,32 @@ jobs:
- name: 📦 Install flutter_quill_test dependencies
run: flutter pub get -C flutter_quill_test

# TODO: Remove quill_native_bridge packages from here once moved to it's own repo
# https://github.com/singerdmx/flutter-quill/pull/2230

- name: 📦 Install quill_native_bridge dependencies
run: flutter pub get -C quill_native_bridge
run: flutter pub get -C quill_native_bridge/quill_native_bridge

- name: 📦 Install quill_native_bridge_platform_interface dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_platform_interface

- name: 📦 Install quill_native_bridge_android dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_android

- name: 📦 Install quill_native_bridge_ios dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_ios

- name: 📦 Install quill_native_bridge_macos dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_macos

- name: 📦 Install quill_native_bridge_windows dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_windows

- name: 📦 Install quill_native_bridge_web dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_web

- name: 📦 Install quill_native_bridge_linux dependencies
run: flutter pub get -C quill_native_bridge/quill_native_bridge_linux

- name: 🔍 Run Flutter analysis
run: flutter analyze
Expand Down
71 changes: 62 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ You can join our [Slack Group] for discussion.
- [📦 Embed Blocks](#-embed-blocks)
- [🔄 Conversion to HTML](#-conversion-to-html)
- [📝 Spelling checker](#-spelling-checker)
- [📝 Rich Text Paste](#-rich-text-paste)
- [✂️ Shortcut events](#-shortcut-events)
- [🌐 Translation](#-translation)
- [🧪 Testing](#-testing)
Expand Down Expand Up @@ -108,20 +109,57 @@ dependencies:

The `flutter_quill` package uses the following plugins:

1. [`url_launcher`](https://pub.dev/packages/url_launcher) to open links.
2. [`quill_native_bridge`](https://pub.dev/packages/quill_native_bridge) to access platform-specific APIs for the
1. [`url_launcher`](https://pub.dev/packages/url_launcher): to open links.
2. [`quill_native_bridge`](https://pub.dev/packages/quill_native_bridge): to access platform-specific APIs for the
editor.
3. [`flutter_keyboard_visibility_temp_fork`](https://pub.dev/packages/flutter_keyboard_visibility_temp_fork) to listen for keyboard
visibility
changes.
visibility changes.

All of them don't require any platform-specific setup.
### Android Configuration for `quill_native_bridge`

To support copying images to the clipboard to be accessed by other apps, you need to configure your Android project.
If not set up, a warning will appear in the log during debug mode only.

> [!TIP]
> This is only required on **Android** for this optional feature.
> You should be able to copy images and paste them inside the editor without any additional configuration.

**1. Update `AndroidManifest.xml`**

Open `your_project/android/app/src/main/AndroidManifest.xml` and add the following inside the `<application>` tag:

```xml
<manifest>
<application>
...
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
...
</application>
</manifest>
```

**2. Create `file_paths.xml`**

Create the file `your_project/android/app/src/main/res/xml/file_paths.xml` with the following content:

```xml
<paths>
<cache-path name="cache" path="." />
</paths>
```

> [!NOTE]
> Starting from Flutter Quill `9.4.x`, [super_clipboard](https://pub.dev/packages/super_clipboard) has been moved
> to [FlutterQuill Extensions], to use rich text pasting, support pasting images, and gif files from external apps or
> websites, take a look
> at `flutter_quill_extensions` Readme.
> [super_clipboard](https://pub.dev/packages/super_clipboard) is no longer required
> in recent versions of Flutter Quill in `flutter_quill` or `flutter_quill_extensions`.
> `quill_native_bridge` is a plugin provide clipboard operations functionality for `flutter_quill`.

## 🚀 Usage

Expand Down Expand Up @@ -307,6 +345,21 @@ The following packages can be used:
This feature is currently not implemented and is being planned. Refer to [#2246](https://github.com/singerdmx/flutter-quill/issues/2246)
for discussion.

## 📝 Rich Text Paste

The Rich Text Pasting feature requires platform code to access HTML from
the system clipboard, [`quill_native_bridge`](https://pub.dev/packages/quill_native_bridge)
is a plugin to provide this functionality.

Rich clipboard operations are currently experimental and might be removed in future releases.

<!-- TODO: Provide a clean way to disable each feature and document it in here -->

> [!IMPORTANT]
> Currently this feature is not supported on the web.
> [Issue #1998](https://github.com/singerdmx/flutter-quill/issues/1998) and [Issue #2220](https://github.com/singerdmx/flutter-quill/issues/2220)
for more details

## ✂️ Shortcut events

We can customize some Shorcut events, using the parameters `characterShortcutEvents` or `spaceShortcutEvents` from `QuillEditorConfigurations` to add more functionality to our editor.
Expand Down
11 changes: 11 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,16 @@
android:authorities="com.example.example.SuperClipboardDataProvider"
android:exported="true"
android:grantUriPermissions="true" />

<!-- For `quill_native_bridge` plugin https://github.com/singerdmx/flutter-quill#-platform-specific-configurations -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
3 changes: 3 additions & 0 deletions example/android/app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<paths>
<cache-path name="cache" path="." />
</paths>
5 changes: 2 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:flutter_localizations/flutter_localizations.dart'
GlobalWidgetsLocalizations;
import 'package:flutter_quill/flutter_quill.dart' show Document;
import 'package:flutter_quill/translations.dart' show FlutterQuillLocalizations;
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';

import 'screens/home/widgets/home_screen.dart';
import 'screens/quill/quill_screen.dart';
Expand All @@ -20,8 +19,8 @@ import 'screens/settings/widgets/settings_screen.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
// ignore: deprecated_member_use
FlutterQuillExtensions.useSuperClipboardPlugin();
// TODO: https://github.com/singerdmx/flutter-quill/pull/2230 and related issues
// FlutterQuillExtensions.useSuperClipboardPlugin();
runApp(const MyApp());
}

Expand Down
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import file_selector_macos
import gal
import irondash_engine_context
import path_provider_foundation
import quill_native_bridge_macos
import share_plus
import sqflite
import super_native_extensions
Expand All @@ -24,6 +25,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
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"))
Expand Down
6 changes: 6 additions & 0 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- quill_native_bridge (0.0.1):
- FlutterMacOS
- share_plus (0.0.1):
- FlutterMacOS
- sqflite (0.0.3):
Expand All @@ -40,6 +42,7 @@ DEPENDENCIES:
- 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 (from `Flutter/ephemeral/.symlinks/plugins/quill_native_bridge/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`)
Expand Down Expand Up @@ -67,6 +70,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
quill_native_bridge:
:path: Flutter/ephemeral/.symlinks/plugins/quill_native_bridge/macos
share_plus:
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
sqflite:
Expand All @@ -88,6 +93,7 @@ SPEC CHECKSUMS:
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
quill_native_bridge: 1a3a4bfab7cbe4ed0232a17d8aae201a3ce6d302
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3
Expand Down
12 changes: 12 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ dependency_overrides:
path: ../flutter_quill_extensions
flutter_quill_test:
path: ../flutter_quill_test
quill_native_bridge:
path: ../quill_native_bridge/quill_native_bridge
quill_native_bridge_platform_interface:
path: ../quill_native_bridge/quill_native_bridge_platform_interface
quill_native_bridge_linux:
path: ../quill_native_bridge/quill_native_bridge_linux
quill_native_bridge_android:
path: ../quill_native_bridge/quill_native_bridge_android
quill_native_bridge_ios:
path: ../quill_native_bridge/quill_native_bridge_ios
quill_native_bridge_macos:
path: ../quill_native_bridge/quill_native_bridge_macos


dev_dependencies:
Expand Down
36 changes: 2 additions & 34 deletions flutter_quill_extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ The package uses the following plugins:
platform-specific setup.
2. [`image_picker`](https://pub.dev/packages/image_picker) for picking images.
See the [Installation](https://pub.dev/packages/image_picker#installation) section.
3. [`super_clipboard`](https://pub.dev/packages/super_clipboard) which needs some setup on Android only, it's used to
support copying images and pasting them into editor, it's also required to support rich text pasting feature on
non-web platforms, Open the [Android Support](https://pub.dev/packages/super_clipboard#android-support) page for
instructions.
The `minSdkVersion` for **Android** is `23` as `super_clipboard` requires it

### Loading Images from the Internet

Expand Down Expand Up @@ -151,35 +146,8 @@ This works only for non-web platforms.

### 📝 Rich Text Paste Feature

The Rich Text Pasting feature requires native code to access
the `Clipboard` data as HTML, the plugin `super_clipboard` is required on all platforms except Web.

This package already includes `super_clipboard` and will be used internally in this package, to use it
in `flutter_quill`, call this function before using any of the widgets or functionalities:

```dart
FlutterQuillExtensions.useSuperClipboardPlugin();
```

`super_clipboard` is a comprehensive plugin that provides many clipboard features for reading and writing rich text,
images and other formats.

Calling this function will allow `flutter_quill` to use modern rich text features to paste HTML and Markdown,
support for GIF files, and other formats.

> [!IMPORTANT]
> On web platforms, you can only get the HTML from `Clipboard` on the
> `paste` event, `super_clipboard`, or any plugin is not required.
> The paste feature will not work using the standard paste hotkey logic.
> As such, you will be unable to use the **Rich Text Paste Feature** on a button or in the web app itself.
> So you might want to either display a dialog when pressing the paste button that explains the limitation and shows the
> hotkey they need to press in order to paste or develop an extension for the browser that bypasses this limitation
> similarly to **Google Docs** and provide a link to install the browser extension.
> See [Issue #1998](https://github.com/singerdmx/flutter-quill/issues/1998) for more details.

> [!NOTE]
> We're still planning on how this should be implemented in
> [Issue #1998](https://github.com/singerdmx/flutter-quill/issues/1998).
The rich text paste feature is now supported directly in `flutter_quill`
as platform code is not bundled with the project.

### 🖼️ Image Assets

Expand Down
4 changes: 2 additions & 2 deletions flutter_quill_extensions/lib/flutter_quill_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library;

// ignore: implementation_imports
import 'package:flutter_quill/src/editor_toolbar_controller_shared/clipboard/clipboard_service_provider.dart';
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';
Expand Down
21 changes: 1 addition & 20 deletions flutter_quill_extensions/lib/src/common/utils/utils.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:io' show File;

import 'package:cross_file/cross_file.dart';
import 'package:flutter/foundation.dart' show Uint8List, immutable;
import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart' show immutable;

import '../../editor/image/widgets/image.dart';
import '../../editor_toolbar_shared/image_saver/s_image_saver.dart';
Expand Down Expand Up @@ -51,23 +49,6 @@ class SaveImageResult {
final SaveImageResultMethod method;
}

Future<Uint8List?> convertImageToUint8List(String image) async {
if (isHttpBasedUrl(image)) {
final response = await http.get(Uri.parse(image));
if (response.statusCode == 200) {
return Uint8List.fromList(response.bodyBytes);
}
return null;
}
// TODO: Add support for all image providers like AssetImage
try {
final file = XFile(image);
return await file.readAsBytes();
} catch (e) {
return null;
}
}

Future<SaveImageResult> saveImage({
required String imageUrl,
required ImageSaverService imageSaverService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class QuillEditorImageEmbedBuilder extends EmbedBuilder {
bool inline,
TextStyle textStyle,
) {
// assert(!kIsWeb, 'Please provide image EmbedBuilder for Web');

final imageSource = standardizeImageUrl(node.value.data);
final ((imageSize), margin, alignment) = getElementAttributes(
node,
Expand All @@ -40,7 +38,7 @@ class QuillEditorImageEmbedBuilder extends EmbedBuilder {
final width = imageSize.width;
final height = imageSize.height;

final image = getImageWidgetByImageSource(
final imageWidget = getImageWidgetByImageSource(
context: context,
imageSource,
imageProviderBuilder: configurations.imageProviderBuilder,
Expand Down Expand Up @@ -72,6 +70,7 @@ class QuillEditorImageEmbedBuilder extends EmbedBuilder {
imageSize: imageSize,
isReadOnly: readOnly,
imageSaverService: imageSaverService,
imageProvider: imageWidget.image,
),
),
);
Expand All @@ -81,10 +80,10 @@ class QuillEditorImageEmbedBuilder extends EmbedBuilder {
if (margin != null) {
return Padding(
padding: EdgeInsets.all(margin),
child: image,
child: imageWidget,
);
}
return image;
return imageWidget;
},
),
);
Expand Down
Loading