singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 839 forks source link

I need help on how to get the content from the clipboard and determine if it is a file. #2247

Closed lingyun000 closed 1 week ago

lingyun000 commented 2 months ago

Is there an existing issue for this?

The question

I need to obtain a file or file path and upload the file to a service or store it in another location. Is there a feature similar to onImagePaste that can be used?

EchoEllet commented 2 months ago

I'm not sure about the question. Can you give me more specific example?

Accessing the clipboard and determining if this is a file or file path is not is not a native functionality supported in Flutter Clipboard.

We're currently using super_clipboard but plan on having our own implementation soon.

Once things are more stable in the library (which unfortunately won't be anytime soon), we will provide a better API to customize the behavior and extend it.

lingyun000 commented 2 months ago

I'm using flutter_quill on the desktop, and I frequently need the copy and paste functionality, especially for pasting files into the editor. I prefer not to use a button to select files, as that can be cumbersome. I've implemented file selection using a button and drag-and-drop; now I'm just missing the direct file copy functionality.

https://github.com/user-attachments/assets/aa117a52-e904-4d1d-b85a-2380a9127f30

EchoEllet commented 2 months ago

missing the direct file copy functionality.

This functionality is being implemented in #2230. This is already a feature when using super_clipboard with flutter_quill but we moved it to another package to make it optional, I would suggest waiting until this feature is implemented for Linux and Windows if you don't want extra transitive dependencies and additional bridge (require installing Rust) but if you want to test this feature while keeping in mind with common issues, you can add flutter_quill_extensions and call:

FlutterQuillExtensions.useSuperClipboardPlugin();

We do plan on moving super_clipboard into quill_super_clipboard or to the example. When using flutter_quill_extensions you will have additional plugins and dependencies that you might not need.

lingyun000 commented 2 months ago

I will be waiting.

EchoEllet commented 1 week ago

Is there a feature similar to onImagePaste that can be used?

Fixed in 11.0.0-dev.12 (see #2350).

You can use QuillClipboardConfig with callbacks to customize the paste behavior.