Closed dmitrizzle closed 6 years ago
Hey @dmitrizzle thanks for opening this. Can you try with copying a more regularly structured piece of content? Like maybe just a section of a GitHub readme. It could be just a problem with certain bits of HTML in the copy.
A simple example is pasting a div with an inline link.
Source
<div>This is a <a href="#">link</a> in line with text</div>
It seems that pasting any text that isn't plaintext causes this error. Below are gifs of me pasting a large section of readme and Travis' simple link example:
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.
node
.attrs isn't a thing anymore, you need to do .attributes
.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
Hey everyone, i current have the same Problem with Pasting and this error only triggers when i have All elements in the Editor selected for Replacement when one Element is not Fully Replaced then it works without a Problem...
Hey @ppvolto can you open a new issue with a GIF explaining your use case? I believe this one was solved.
Current behaviour
Right now pasting HTML into
PasteHTML
example works only if I was to copy HTML from Slate editor:However, if I am to paste HTML from any other source Chrome 60 throws an error:
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
replacedcheerio
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.