question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pasting external HTML does not work with Slate example

See original GitHub issue

Current behaviour

Right now pasting HTML into PasteHTML example works only if I was to copy HTML from Slate editor:

slate-to-slate-paste

However, if I am to paste HTML from any other source Chrome 60 throws an error:

html-to-slate-paste

build.prod.js:4902 Uncaught TypeError: Cannot read property 'find' of undefined
    at Object.deserialize (build.prod.js:4902)
    at Html.deserializeElement (build.prod.js:98382)
    at build.prod.js:98341
    at Array.forEach (<anonymous>)
    at Html.deserializeElements (build.prod.js:98340)
    at next (build.prod.js:98368)
    at Html.deserializeElement (build.prod.js:98402)
    at build.prod.js:98341
    at Array.forEach (<anonymous>)
    at Html.deserializeElements (build.prod.js:98340)

Expected behaviour

Pasting HTML from any source should work.

Context

I am using Chrome 60 on macOS 10.12.6, presumably Slate v0.24.1 - since that’s the latest version posted (but I can’t guarantee that’s the same version as what slatejs.org uses in the above examples; above gifs were created shortly after v0.24.1 release was posted).

There’s an issue #734 which addresses a similar problem but I don’t think it’s relevant anymore, since it described actions with much older versions of Slate. It was opened mentioning v0.19.16.

More context

v0.20.7 > v0.21.0 parse5 replaced cheerio but pasting caused JavaScript errors (see #948) which were fixed with #985. I’m not sure if pasting HTML has been tested for with the above PR, since the functionality never returned for pasting form the external sources.

My understanding

After DOMParser has replaced Cherio in Slate pasting HTML from external sources became broken. Most likely it’s because there’s no test to check for this case and a bug has slipped in.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ianstormtaylorcommented, Oct 12, 2017

Hey @ppvolto can you open a new issue with a GIF explaining your use case? I believe this one was solved.

1reaction
YurkaninRyancommented, Sep 16, 2017

Hey everyone,

This bug is due to to the fact that the upgrade makes it so we now get HTML-like elements. .find won’t work for two reasons.

  1. node.attrs isn’t a thing anymore, you need to do .attributes
  2. .find isn’t going to work, because you get a named node map back from .attributes so you would have to turn it into an object.

Basically, the example just needs to be updated to handle the new nodes

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the slate-react.getEventRange function in ... - Snyk
To help you get started, we've selected a few slate-react.getEventRange examples, based on popular ways it is used in public projects.
Read more >
slate-drop-or-paste-images examples - CodeSandbox
Learn how to use slate-drop-or-paste-images by viewing and forking example apps that make use of slate-drop-or-paste-images on CodeSandbox.
Read more >
can blackboard tell if you screenshot - Feudo 43
Workaround, Blackboard is That way you will know they are temporarily not engaged in the session. 75 hours. ac. The system cannot detect...
Read more >
Branding Editor - Slate Knowledge Base - Technolutions
This template initially includes a simple header with a background ... Technolutions does not support the use of custom JavaScript in the ...
Read more >
Paste HTML - Slate Examples
Copy and paste some rendered HTML rich text content (not the source code) from another site into this editor and it's formatting should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found