When there is a table in the Web page, a single line of text, becomes multiple lines after being copied and pasted.
Categories
(Core :: DOM: Serializers, defect)
Tracking
()
People
(Reporter: lyboot, Unassigned)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
Steps to reproduce:
When there is a table in the Web page, a single line of text, becomes multiple lines after being copied and pasted.
When there is a table in a web page.
User want to use "Ctrl + A" to select it , then use "Ctrl + C" to copy it .
And then use "Ctrl + V" to paste it in a notepad txt file.
We can see the result is very awful compared to the text copied frome google chrome.
Text copied from Chrome, a line in a table, is still a line after being copied.
Text copied from Firefox, a single line of text in a table, becomes multiple lines.
For example:
http://fund.eastmoney.com/data/fbsfundranking.html#tct;c0;r;szzf;ddesc;pn50;
This web page as an example.
We open it using Firefox and Goofle chrome web broswer respectively.
And then copy it separately.
You'll see very different results.
Expected results:
When there is a table in the Web page, a single line of text, becomes multiple lines after being copied and pasted.
When there is a table in a web page.
User want to use "Ctrl + A" to select it , then use "Ctrl + C" to copy it .
And then use "Ctrl + V" to paste it in a notepad txt file.
We can see the result is very awful compared to the text copied frome google chrome.
Text copied from Chrome, a line in a table, is still a line after being copied.
Text copied from Firefox, a single line of text in a table, becomes multiple lines.
For example:
http://fund.eastmoney.com/data/fbsfundranking.html#tct;c0;r;szzf;ddesc;pn50;
This web page as an example.
We open it using Firefox and Goofle chrome web broswer respectively.
And then copy it separately.
You'll see very different results.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout: Tables' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•3 years ago
|
||
It looks like one issue here, at least, is that when table cells (<td>
elements) in a row simply contain text, they end up on the same line (tab-separated) in the copied text; but if they contain other elements, even inline elements such as <a>
, then they get split onto separate lines. That does seem less than ideal.
I think this is more of a DOM Serialization issue than Layout, though; moving to that component.
Comment 3•2 years ago
|
||
I created a minimum test case https://jsfiddle.net/g34L7kxd/
The issue happens when the float
property is set and applied to <a>
.
If <a>
is not a floating element, the issue is not reproducible.
According to this, do you think if something can go wrong in Layout: Floats code? Thanks!
Comment 5•2 years ago
|
||
According to this, do you think if something can go wrong in Layout: Floats code? Thanks!
I don't think the bug related to float layout. If we change <a>
to be display: block
, and copy the whole page, I got the following in a plain text editor. The result is the same as testcase 1.
No. 1
link
2022-07-27
Comment 6•2 years ago
|
||
With testcase 2 (comment 5), I also get the content on separate lines when copying from Chrome to a plain-text document. Which makes sense, I think: when <a>
is display: block
, it's pretty clear that its content should not be inlined with the preceding and following content.
But when the float
property is used, there is a difference: when copying to plain-text, Chrome leaves the text of the floated element inline in its context, whereas Firefox makes it a separate paragraph. I don't see that there's any reasonable way for the browser to know what is "better' in this case. In general, there's no way to represent a float
in a plain-text version of the content. On the whole, I think it makes more sense to keep the float
separate rather than to leave it as inline content -- after all, a key aspect of float
is that it removes its content from its context and displays it somehow separately.
Description
•