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.

Paste HTML example is broken.

See original GitHub issue


What’s the current behavior?

The Paste HTML example doesn’t work, and neither does the code in my own project. Pasting a HTML string simply renders that string as-is into the editor.

To reproduce:

What’s the expected behavior?

Pasting HTML should convert that HTML into proper rendered markup. Pasting the above should display “Test”, which should be correctly wrapped in paragraph tags in the DOM.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

doodlewindcommented, Nov 13, 2017

@gggdomi to my knowledge, transfer.type is not under slate’s control. When your perform copy in other apps, say Notepad, Word, PhotoShop…selected content is loaded into clipboard with its transfer.type. Different upstream marks different types of contents. Copying in Notepad results in 'text' type, in Word and browsers you get 'html', in Finder you get 'file'.

By default slate handles 'html' as plain text, the “Paste HTML” example only demonstrates its capability to convert 'html' type into slate’s value with relatively little effort. In the case of plain HTML string, a common case may be copying HTML code from text editor like vim, sublime, etc. Do you expect the HTML code block parsed into rich text?

IMHO you can implement this behavior by parsing HTML string into DOM nodes, putting them into slate-html-serializer, then calling change.insertFragment and it should work. While I’m not sure this behavior is necessary for this common example.

wildlifehexagoncommented, Jun 28, 2018

I was also confused by this example. I thought that we could paste HTML content (i.e. <p>hello</p>) into the editor and it would automatically convert to the rendered markup. I now realize that it works by copying the rendered content directly into the editor rather than copying over HTML syntax.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Paste HTML into String in Python - Stack Overflow
I am trying to parse some HTML by passing in the HTML into a single string object. However, when I paste in the...
Read more >
Word, the Web, and the Dangers of Pasting HTML | build/create
Your site already has a stylesheet, and the HTML you've pasted from that other location could conflict with your site's stylesheet, resulting in ......
Read more >
</body> & </html> broken (Example) | Treehouse Community
Chris Shaw. Hi Thiago, You appear to have an unclosed DIV in your markup which is redundant and can be removed, I'm referring...
Read more >
Forms - lesson broken? Even copy/paste answer won't take ...
I've typed in the answer, copy/pasted from solution - no matter what I do it won't let me advance, so I think maybe...
Read more >
Paste content into the HTML editor
Navigate to an HTML field. For example, the Text field of a Knowledge article. · Paste in content from another application. · From...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found