-
-
Notifications
You must be signed in to change notification settings - Fork 739
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
Fix issue of duplicated blocks upon pasting an image into the Slate E… #5818
Conversation
✅ Deploy Preview for volto canceled.
|
✅ Deploy Preview for plone-components canceled.
|
Co-authored-by: Steve Piercy <web@stevepiercy.com>
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.
News looks good, PR needs review by a maintainer.
@plone/volto-team review requested. |
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.
Change log is OK. Code needs review by a maintainer. @plone/volto-team
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.
@aryan7081 I wonder how did you test that this code change fixes the issue?
I will attach a video where I record testing your fix and the issue is still present
exactly as it was flagged into the issue so I don't understand what made you belive that this issue would be fixed by your change.
slate-image-pasting.mp4
If you still want to try to work on this issue, your pull request needs to contain
a cypress test that uploads an image, you copy the image to the clipboard and you paste it in a page as you can see from this video:
copy-uploaded-image.mp4
EDIT:
Then your test should show that when you paste the image inside the empty slate block, the image is pasted inside that
block instead of leaving that initial slate block empty.
@aryan7081 A couple of extra context as upon further testing I noticed the following:
|
@ichim-david Sorry for the delay. Working on this and adding tests as well. Can I test this on linux and windows vm? |
@aryan7081 do the minimum test first on whatever platform you're working on and if you can reproduce the issue there then try to fix it, there is no point in doing cross-testing until necessary. |
The
This change ensures that a block is inserted at the (index - 1) position if the current(index) block is empty. Otherwise, it proceeds to create another block as usual. Will push cypress tests once this approach is validated. Screen.Recording.2024-03-07.at.9.01.39.PM.MOV |
@aryan7081 please run code quality checks locally before pushing commits. See Linting. However our documentation lacks the specific commands that need to be run, so I don't blame you for not running undocumented commands. See #5341 The CI jobs call https://github.com/plone/volto/blob/main/.github/workflows/code-analysis.yml. You can look at it for the commands that do not pass the checks, and try running them locally. |
@stevepiercy Working on cypress tests. |
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.
@aryan7081 I tried it out, and it does work well indeed.
We would need the tests if possible. We improved the documentation lately:
https://6.docs.plone.org/volto/contributing/acceptance-tests.html
Also, the code analysis checks are failing.
Could you imagine in work on this?
* main: (42 commits) Release 18.0.0-alpha.35 Release @plone/types 1.0.0-alpha.16 (fix): export getFieldURL from Url.js in helpers (plone#6100) Improve container detection, `config.settings.containerBlockTypes` is no longer needed (plone#6099) Support nested directories in public folder add-on sync folders both … (plone#6098) Release 18.0.0-alpha.34 Add generated new declarations for a34, just in case (plone#6097) Release @plone/slate 18.0.0-alpha.13 Release @plone/registry 1.6.0 Release @plone/types 1.0.0-alpha.15 Add support for reading the add-ons `tsconfig.json` paths (plone#6096) Fixes plone#6046 pass proper defaults to align and size fields of Image block (plone#6093) bug fix. relations control panel. Restrict eglible relation targets a… (plone#6092) Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format (plone#6088) Add optional `token` parameter to ploneClient initialization (plone#6077) Blocks Layout Navigator (plone#5642) Fix internalUrl Widget to Reflect Prop Changes via onChangeBlock (plone#6036) [types] Improve styleClassNameExtenders types, Icon component JSDoc t… (plone#6095) Fix link in pop-up RelationsMatrix.jsx (plone#6085) Fix deselecting lists. (plone#6080) ...
@plone/volto-team This works fine for me, pity is that we don't have any Cypress test for it. I don't even know if it's possible to model that interaction I've investigated it a bit this morning, we have clipboard mocks for pasting text but I have no clue how to mock the image data. I've tried though, if someone wants to take over: https://github.com/plone/volto/tree/testingpasteimages For the rest I'd merge it. @ichim-david I'd appreciate another review from you! |
@sneridagh will have a look at this tonight. |
@sneridagh Tonight ended up this morning :) Pasting from os clipboard will upload and use an image block. Not saying that it's the fault of this ticket. It just seems to me less useful this img tag linking since you don't have |
@ichim-david paste from a website you mean copy the html with along text or only the image? Is this different than before? |
@sneridagh right click copy image only. It's not different from before. Ready for merging from my part. |
* main: Make dynamic/live teaser without additional requests (#6024) Fix issue of duplicated blocks upon pasting an image into the Slate E… (#5818) Remove `api` folder. Add `backend` folder using latest backend best practices (#6110) Rename files with wrong extension `js->jsx` when they contain JSX. (#6114) Improve shadowing by including the support for `js->jsx` extensions in… (#6113) issue-5452 markdown shortcut (#5495)
* main: Make dynamic/live teaser without additional requests (#6024) Fix issue of duplicated blocks upon pasting an image into the Slate E… (#5818) Remove `api` folder. Add `backend` folder using latest backend best practices (#6110) Rename files with wrong extension `js->jsx` when they contain JSX. (#6114) Improve shadowing by including the support for `js->jsx` extensions in… (#6113) issue-5452 markdown shortcut (#5495)
* main: (73 commits) Release 18.0.0-alpha.36 Rename missing command Image widget PR as breaking (#6125) Release @plone/slate 18.0.0-alpha.14 Release @plone/registry 1.7.0 Rename Makefile targets (#6104) fix: nonContentRoutes diff path (#6102) Automatically set the label to `03 type: feature (plip)` for PLIPs (#6122) Add ImageWidget with upload/drop/external and inline/widget capabilities (#5607) Ensure that sidebar field will not steal focus when metadata is edited (#5983) Prevent duplicated UUUIDs in inner blocks when copying container blocks (#6112) feat: handle breakList in detached TextBlockEditor (#6106) Make dynamic/live teaser without additional requests (#6024) Fix issue of duplicated blocks upon pasting an image into the Slate E… (#5818) Remove `api` folder. Add `backend` folder using latest backend best practices (#6110) Rename files with wrong extension `js->jsx` when they contain JSX. (#6114) Improve shadowing by including the support for `js->jsx` extensions in… (#6113) issue-5452 markdown shortcut (#5495) Release 18.0.0-alpha.35 Release @plone/types 1.0.0-alpha.16 ...
Fixes Issue
Inside the onImageLoad function in withDeserializers extension of Volto Slate.
uploadContent adds the block using Redux and FormData, but the .then promise callback of uploadContent also adds a new Node in the Slate Editor using
Transforms.insertNodes(editor, image);
which eventually leads to adding multiple images in the editor.