volto icon indicating copy to clipboard operation
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.

Open sneridagh opened this issue 1 year ago • 8 comments

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:

  1. Edit any content with blocks
  2. Click on an empty slate block
  3. Copy an image
  4. Paste directly from the clipboard into a slate block
  5. Two blocks, one pure slate and an image block are created.

Expected behavior Only the image block is created.

sneridagh avatar Jan 25 '24 11:01 sneridagh

/cc @avoinea @tiberiuichim @ichim-david Does your users not try this feature? I'm so used to do this in Gitlab/Github...

sneridagh avatar Jan 25 '24 11:01 sneridagh

@sneridagh I think I've noticed this problem at some point. It needs to be fixed.

tiberiuichim avatar Jan 25 '24 12:01 tiberiuichim

/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 avatar Jan 25 '24 21:01 AnshulKahar2729

@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.

tiberiuichim avatar Jan 26 '24 07:01 tiberiuichim

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 avatar Jan 26 '24 08:01 AnshulKahar2729

@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.

tiberiuichim avatar Jan 26 '24 10:01 tiberiuichim

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

ichim-david avatar Mar 02 '24 09:03 ichim-david

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.

adityaa3pathi avatar Mar 13 '24 21:03 adityaa3pathi