Reputation: 46393
Try to run this simple code, give the text the focus, select all the text (CTRL+A), cut it (CTRL+X), and paste it (CTRL+V). Strangely, the text is not pasted. Why?
<span contenteditable="true" id="mytext">Hello world</span>
How to enable normal copy/cut/paste features in contenteditable
elements ?
Note : the problem is present (at least) for Firefox 32/Win 7. Not present with Chrome, nor IE10, nor Safari (tested on Windows).
Upvotes: 2
Views: 1217
Reputation: 137171
This is a Firefox bug :
see https://bugzilla.mozilla.org/show_bug.cgi?id=858918
when you copy paste into the span, it actually copies the span itself, but not the node text contained.
You can see it by assigning a border to spans :
span {
border: 1px solid black;
}
<span contenteditable="true" id="mytext">Hello world</span>
As a workaround,
You may want to change your span
to p
or other html tag that doesn't behave like that.
:Aryeh Gregor should be working on it right now and he already published patches.
Ps : Confirmed on Firefox 32.0.3 and Nightly Build 33.0 on osx 10.9.5
Pps : Even oddier : when you copy text from span
and paste it to a div
(or other non buggy elements) with contenteditable="true"
, it will add a linebreak, whereas when pasting to text editor with invisibles shown, it only paste the string copied. I don't know how but my guess is that it copies/pastes the textNode
as a new textNode
, interpreted as a string
by other softwares.
Upvotes: 2