singerdmx / flutter-quill

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

Clipboard image pasting not working correctly due to plainText check before #2383

Closed Maksim-Nikolaev closed 5 days ago

Maksim-Nikolaev commented 6 days ago

Is there an existing issue for this?

Flutter Quill version

11.0.0-dev.12

Steps to reproduce

  1. Install the example from https://github.com/singerdmx/flutter-quill/blob/master/example/lib/main.dart
  2. Get image into clipboard, for example by taking a screenshot on Android
  3. Paste the image into the editor
  4. Image data is transcribed as plain text and is not inserted as image block

Expected results

Insert an image if "onImagePaste" is defined. (Currently only works with network images / img urls)

Actual results

Currently that will be ignored due to check of "plainText", which is not null when we have image data in clipboard.

Additional Context

No response

EchoEllet commented 5 days ago

Is this the same issue as #2323?

(Currently only works with network images / img urls)

The image URL will be stored in the document JSON, and how it will be loaded depends on your image embed implementation. If you're using flutter_quill_extensions, you can overimage provider builder.

Maksim-Nikolaev commented 5 days ago

After double checking you are right, the issue & source of problem seems to be the same. I probably overlooked it due to phrasing before creating my own issue.

The image URL will be stored in the document JSON, and how it will be loaded depends on your image embed implementation. If you're using flutter_quill_extensions, you can overimage provider builder.

What I meant with that the current implementation only works with network images is that when we grab the image from the web it gets the "image url" property which is pasted as plain text and then rendered within the image embed. If you would pass an image from paint, like in #2385 , the mechanism doesn't work.

And probably my wording was incorrect here:

Insert an image if "onImagePaste" is defined. (Currently only works with network images / img urls)

In case with network images. pasting still worked via plainText and not via onImagePaste.

And onImagePaste handler would never be reached because there is plainText content that is not null in case if we actually have Uint8List bytes from raw image