volto
volto copied to clipboard
Pasting an image directly from the clipboard in a slate block triggers the creation of both a slate block and a (proper) image block.
Describe the bug Pasting an image directly from the clipboard in a slate block triggers the creation of both a slate block and a (proper) image block.
To Reproduce Steps to reproduce the behavior:
- Edit any content with blocks
- Click on an empty slate block
- Copy an image
- Paste directly from the clipboard into a slate block
- Two blocks, one pure slate and an image block are created.
Expected behavior Only the image block is created.
/cc @avoinea @tiberiuichim @ichim-david Does your users not try this feature? I'm so used to do this in Gitlab/Github...
@sneridagh I think I've noticed this problem at some point. It needs to be fixed.
/cc @avoinea @tiberiuichim @ichim-david Does your users not try this feature? I'm so used to do this in Gitlab/Github...
Can you attach the screenshots or recording, it will be better for understanding
@AnshulKahar2729 Go to Google Docs, create a new document using a template that also uses an image. From the google doc, copy everything, go to Volto to a new page, paste the clipboard. If you get two images pasted, it's a problem.
Ok, I got the problem. I tried to reproduce the problem and it happended. One more question, is it happening in all the blocks, or some specifics?
@AnshulKahar2729 it's concerning the integration between volto-slate and the volto blocks.
The problem is that the image slate node is not properly removed once a volto block is emitted.
https://github.com/plone/volto/blob/4bb07b9b7392879e7aed72b871f73936f2187f5c/packages/volto-slate/src/utils/volto-blocks.js#L278
https://github.com/plone/volto/blob/4bb07b9b7392879e7aed72b871f73936f2187f5c/packages/volto-slate/src/blocks/Text/index.js#L95
https://github.com/plone/volto/blob/4bb07b9b7392879e7aed72b871f73936f2187f5c/packages/volto-slate/src/editor/plugins/Image/deconstruct.js#L24-L27
Somehow the slate tree transformation is not properly done.
For extra context, I've tried on the demo site to paste an image and it works just fine on a Mac. Where you have issues is when you try to paste an image from the OS files, such as using the Finder and copying an image from the HDD and then you paste in the browser. When I did right click -> copy image, I got the image pasted just fine from the demo site as well from external site images
Hey, @ichim-david Just want to ask, is this issue resolved? cause I'm not able to reproduce it in my local volto. It works just fine on Ubuntu 22.04.4 LTS. On uploading images through HDD or from clipboard, no duplicate images are created.