Skip to content
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

[deserialize-html] Pasting Image from clipboard into empty paragraph creates node image without url #926

Closed
PibeG opened this issue Aug 11, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@PibeG
Copy link

PibeG commented Aug 11, 2021

Description

After copying an image (eg. from wikimedia) and pasting it into an empty paragraph, an 'image' node without the "url" property is created.

Steps

  1. Copy an image (eg. https://commons.wikimedia.org/wiki/Main_Page).
  2. Go to https://platejs.org
  3. paste the image on a paragraph without text.

Sandbox

https://codesandbox.io/s/plate-reproduction-image-deserializing-o2g4m

Expectation

If you paste the same image in any other paragraph, the editor splits the content and creates the 'image' node correctly.

Environment

  • slate: 63.0
  • slate-react: 65.2
  • browser: chrome

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@PibeG PibeG added the bug Something isn't working label Aug 11, 2021
@siliconeidolon
Copy link

siliconeidolon commented Sep 10, 2021

This behaviour is also seen when copy-pasting slate (ast) images within the editor, so I imagine it's not specifically related to the HTML deserialization, but more likely one of the insertion helper functions:
https://codesandbox.io/s/plate-reproduction-image-ast-deserializing-7cler?file=/index.tsx
Try copying the image and pasting it into an empty paragraph.

@dylans
Copy link
Collaborator

dylans commented Sep 10, 2021

This should be fixed on Slate 0.66 gets released, namely with ianstormtaylor/slate#4489 and then after we land #995 and release. So probably sometime next week this should work.

In the interim, you could add a custom preInsert method that does not attempt to rewrite the first node type.

@siliconeidolon
Copy link

Ah great, thanks for the update.

@PibeG
Copy link
Author

PibeG commented Sep 15, 2021

Thanks @dylans, I'll close this since #995 is just waiting review

@PibeG PibeG closed this as completed Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants