1

Pasting HTML copied from the browser (try CMD-A, CMD-C in gmail) into a contenteditable PRE in Firefox (34.0) puts the new elements after the PRE, not inside (inspect to verify).

<pre contenteditable="true" style="height:200px; width:200px; border:1px solid red"/>

See this jsfiddle: http://jsfiddle.net/w5cs9pzo/1/

I can only reproduce this problem with PREs - DIVs are fine.

Any workaround would be appreciated.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
cvazac
  • 881
  • 6
  • 7
  • My hunch is that this is caused by `
    ` elements in the HTML (versus the well-formed `
    `), specifically `
    `. I worked around this by canceling the default paste and using `document.execCommand("insertHTML", false, );` IE workaround found here: http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div/6691294#6691294.
    – cvazac Mar 03 '15 at 00:33
  • `
    ` could only cause a problem if you are using XHTML. Are you?
    – Tim Down Mar 09 '15 at 12:28
  • Not sure exactly what you are asking, see my jsfiddle. Note: I am using Firefox as the copy source (gmail) and paste target (jsfiddle). – cvazac Mar 11 '15 at 04:23

0 Answers0