InserText inserts <div><br></div> for final newline
Reported by
jvanoost...@gmail.com,
Apr 14 2016
|
||||||||||||
Issue description
UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Steps to reproduce the problem:
1. make html element with a paste listner
element.on('paste', function(e) {
e.preventDefault(); // prevent default paste
var text = (e.originalEvent || e).clipboardData.getData('text/plain');
2. copy a webpage
3. paste the contents
What is the expected behavior?
no style information like <div> should be included in 'text'
What went wrong?
the pasted text includes <div></div>
all other style information is removed
Did this work before? N/A
Chrome version: 49.0.2623.112 Channel: stable
OS Version: Ubuntu 15.10
Flash Version:
,
Apr 14 2016
document.execCommand('insertHTML', false, text);
has the correct beheviour
,
Apr 15 2016
,
Apr 15 2016
,
Apr 15 2016
Could you tell me a tag name where you paste? When I run insertText into <div contenteditable></div>, pasted text is wrapped in PRE and I don't see <div><br></div>.
,
Apr 15 2016
see this fiddle: When pasting some HTML in Chrome the newlines are converted to <div><br></div> use 'Inspect' to see the result, note the difference when using FireFox. http://jsfiddle.net/hzxa4sah/
,
Apr 15 2016
Thank you for providing more feedback. Adding requester "yosin@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://sites.google.com/a/chromium.org/dev/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 19 2016
Thanks for reproduce procedure!
Final newline for "insertText" command argument inserts <div><br></div>.
Example:
document.execCommand('insertText', false, 'foo\nbar\n');
,
Apr 29 2016
,
Aug 8 2017
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Aug 21 2017
,
Oct 4 2017
,
Oct 4
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 5
|
||||||||||||
►
Sign in to add a comment |
||||||||||||
Comment 1 by jvanoost...@gmail.com
, Apr 14 2016after further analyses this may be cause be the next line of code document.execCommand('insertText', false, text); this causes the html element to contain <div><br></div> for each newline in the pasted html