Paste HTML example is broken.
See original GitHub issueBug
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:
- visit http://slatejs.org/#/paste-html
- select all the text content, and paste
<p>Test</p>
- It will display, verbatim:
<p>Test</p>
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:
- Created 6 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 itstransfer.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’svalue
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 callingchange.insertFragment
and it should work. While I’m not sure this behavior is necessary for this common example.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.