New issue
Advanced search Search tips

Issue 603417 link

Starred by 4 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

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:
 
after 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

document.execCommand('insertHTML', false, text);
has the correct beheviour
Components: -Blink Blink>DataTransfer
Components: Blink>Editing

Comment 5 by yosin@chromium.org, Apr 15 2016

Components: -Blink>DataTransfer -Blink>Editing Blink>Editing>Command
Labels: -OS-Linux Needs-Feedback OS-All
Summary: NEEDS_FEEBACK InserText inserts <div><br></div> (was: clipboardData.getData('text/plain') returns <div> )
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>.
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/


Project Member

Comment 7 by sheriffbot@chromium.org, Apr 15 2016

Labels: -Needs-Feedback Needs-Review
Owner: yosin@chromium.org
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

Comment 8 by yosin@chromium.org, Apr 19 2016

Owner: ----
Status: Available (was: Unconfirmed)
Summary: InserText inserts <div><br></div> for final newline (was: NEEDS_FEEBACK InserText inserts <div><br></div>)
Thanks for reproduce procedure!

Final newline for "insertText" command argument inserts <div><br></div>.

Example:
document.execCommand('insertText', false, 'foo\nbar\n');

Labels: -Needs-Review
Project Member

Comment 10 by sheriffbot@chromium.org, Aug 8 2017

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
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

Comment 11 by yosin@chromium.org, Aug 21 2017

Status: Available (was: Untriaged)
Labels: Pri-3
Project Member

Comment 13 by sheriffbot@chromium.org, Oct 4

Status: Untriaged (was: Available)
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
Status: Available (was: Untriaged)

Sign in to add a comment