Slate: Paste-HTML Example Produces Duplicate Text

Created on 20 Aug 2019  路  1Comment  路  Source: ianstormtaylor/slate

Bug

Current Behavior

Pasting formatted text from a website into the Paste-HTML example duplicates the text that is pasted.
This happens on all types of text:

  • Plain text
  • Links
  • Bold text
  • Italicized text
  • Code blocks
  • Header tags
  • Pre tags

The bug exists in the current Paste-HTML example -- https://www.slatejs.org/#/paste-html. I hope the Slate live demo can substitute for a JS Fiddle snippet

SlateBug
(sorry for the short gif, only had 30 secs to record - I was pasting from this wikipedia article if you want to try yourself. )

Expected Behavior

Pasting text from another website does not duplicate the text and keeps the formatting

Most helpful comment

Hello
Need to change the onPaste

  onPaste = (event, editor, next) => {
    event.preventDefault()  // <---- add me

    const transfer = getEventTransfer(event)
    if (transfer.type !== 'html') return next()
    const { document } = serializer.deserialize(transfer.html)
    editor.insertFragment(document)
  }

>All comments

Hello
Need to change the onPaste

  onPaste = (event, editor, next) => {
    event.preventDefault()  // <---- add me

    const transfer = getEventTransfer(event)
    if (transfer.type !== 'html') return next()
    const { document } = serializer.deserialize(transfer.html)
    editor.insertFragment(document)
  }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

varoot picture varoot  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

bengotow picture bengotow  路  3Comments

ezakto picture ezakto  路  3Comments