Closed Bug 583980 Opened 14 years ago Closed 6 years ago

Select all + Copy in a contenteditable div selects the div element itself

Categories

(Core :: DOM: Editor, defect)

x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: tsaregradsky, Unassigned, NeedInfo)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; uk; rv:1.9.2.8) Gecko/20100722 AskTbFXTV5/3.8.0.12304 Firefox/3.6.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; uk; rv:1.9.2.8) Gecko/20100722 AskTbFXTV5/3.8.0.12304 Firefox/3.6.8

When a div has the contenteditable attribute set to true, and the user selects all contents (cmd + a, mouse selection, execCommand or range.selectAllChildren(DOMNode) ) and copies the contents,the <div> element itself is copied to the clipboard. 
In https://bugzilla.mozilla.org/show_bug.cgi?id=436703 a case was fixed when a user pastes the copied contents into that contenteditable div, but the problem seems much deeper. 
Normally you can't see how html is stored in a clipboard (only with special clipboard viewers), but if you paste the copied contents in any of the Rich Text Editors like CKEditor, FCKEditor, tinyMCE, you'll see an additional <div contenteditable="true"> element.

Reproducible: Always

Steps to Reproduce:
1. Download any Rich Text Editor (like CKeditor, tinyMCE etc.) or clipboard viewers (like Inside Clipboard). Create an html-page with such contents:
<html>
<head>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>  
</head>
<body>
	<div contenteditable="true" style="width: 300px; height: 200px; border: 1px solid black;"></div>
	<textarea cols="80" id="editor1" name="editor1" rows="10"></textarea>
	<script type="text/javascript">
		CKEDITOR.replace( 'editor1' );
	</script>
</body>
</html>
2. Type any text in the conteneditable div, e.g. "This is an example."
3. Then press ctrl+a and ctrl+c.
4. Then paste with ctrl+v into the ckeditor (or look into the clipboard viewer).
Actual Results:  
Contents wrapped in an external <div contenteditable="true"> like:
<div contenteditable="true" style="width: 300px; height: 200px; border: 1px solid black;">This is an example.</div>

Expected Results:  
Only contents with no external <div contenteditable="true"> like:
This is an example.

In Opera, IE, Chrome the sample works correctly.
See Also: → 436703
OS: Windows 7 → All
See Also: → 1072600
I think it's fixed by bug 858918 in Nightly (FF36).
Constantine, could you download Nightly and confirm on your side, please?
https://nightly.mozilla.org/
Flags: needinfo?(tsaregradsky)
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.