-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add ability to copy & paste images that are in uploading state. #17327
Conversation
After upload is done, will the copied image have |
@arkflpc It's updated to the target, as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@niegowski , wdyt?
@Mati365 We've finished testing the PR with @kubaklatt - it fixes the issue and looks good to us 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you trigger editor.getData()
while an image is not fully uploaded, the editor data would contain the data:
URL. For the user, it would look like the image is successfully uploaded but the URL would not point to the real asset on the server.
The proposed solution restarts the upload after the drop, but we should just keep the uploadId
so the loader can match the given element and continue uploading.
@niegowski we cannot, as it'll be no longer possible to paste such image to another instance of the editor. The second thing is that uploadId will be no longer valid after successful upload of original image, as it's removed from registry to avoid mem leak. |
@juliaflejterska / @charlttsie We changed a bit the behavior of this fix, so large |
Together with @juliaflejterska, we’ve retested the fix and image upload works the same as before the recent changes - copying and pasting images that are in the uploading state works well. We also haven’t found any regressions, so it looks good to us 🎉 However, as we didn’t have a lot of time for the retests, let’s pay special attention to this area during the testing phase 🙂 |
This part surprised me as we know it should not work (especially after the upload is completed). I'd suggest writing down all scenarios and analyzing what happens and what is expected.
The above should also include scenarios with drop/paste outside the editor. As we checked during the review, not all scenarios behave as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed F2F we need to write down all scenarios and make sure those all work as expected.
@charlttsie Can you take a look again? Please check these scenarios described by Kuba. There are few exceptions:
|
Undoing the pasting of an uploading image paste results in a crashSteps
Result
undo-error.mp4Additional info |
Copying an image while the upload is in progress and pasting after upload results in inconsistent behaviorSteps
ResultThe first paste successfully inserts the image. The second (and any subsequent) paste results in a blank img element. copy-paste.mov |
We've finished the retest with @juliaflejterska and have found the two issues reported above:
The remaining scenarios behave as expected, also in the multi-root editor, and when pasting into a different editor. |
@charlttsie Thanks. I pushed some modifications and hope these issues should be no longer present. Can you check again? Commits: |
@Mati365 According to our tests, both issues are fixed. The rest of the scenarios behave as before and we have not found anything new, so the PR looks good to us 🎉 |
Suggested merge commit message (convention)
Fix (image): Copying and pasting images in the uploading state is now possible. Closes #16967
Additional information
It looks like we forgot to dump images that contain
uploadId
to clipboard data. It resulted in blankimg
being exported to the HTML:I added a converter that lookups in file repository and checks if there is matching
uploadId
entry containingdata
. If so, it storesbase64
of loaded image insrc
ofimg
element, which is already pretty well handled later on.Easily reproducible on http://localhost:8125/ckeditor5-image/tests/manual/imageupload.html
Before
before-image-upload-fix-2024-10-25_12.58.54.mp4
After
after-image-upload-fix-2024-10-25_12.55.59.mp4