flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

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

Open lingyun000 opened this issue 1 year ago • 4 comments

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?

lingyun000 avatar Sep 19 '24 14:09 lingyun000

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.

EchoEllet avatar Sep 19 '24 17:09 EchoEllet

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

lingyun000 avatar Sep 20 '24 03:09 lingyun000

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.

EchoEllet avatar Sep 20 '24 11:09 EchoEllet

I will be waiting.

lingyun000 avatar Sep 20 '24 12:09 lingyun000

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.

EchoEllet avatar Nov 14 '24 21:11 EchoEllet