Open Bug 406488 Opened 17 years ago Updated 2 years ago

Copy highlighted text to clipboard ignores non-inlined CSS styling when pasting as rich text (to HTML editors, MS Word, Excel, Outlook etc.)

Categories

(Core :: DOM: Serializers, defect)

defect

Tracking

()

Webcompat Priority P3
Tracking Status
platform-rel --- -

People

(Reporter: duncan.loveday, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, testcase, Whiteboard: [platform-rel-Microsoft][platform-rel-Outlook][webcompat])

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2pre) Gecko/2007112705 Minefield/3.0b2pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2pre) Gecko/2007112705 Minefield/3.0b2pre

On a windows platform, highlighting a portion of an HTML document and copying it to the clipboard preserves explicit HTML styling and inline CSS styling but ignores references to internal and external stylesheets. IE7 preserves both inline and out of line styles.

Reproducible: Always

Steps to Reproduce:
1. Open the attached HTML test case.
2. Right click->Select all then ctrl-C to copy to clipboard.
3. Paste the result into Microsoft Word
Actual Results:  
HTML and inline styling (the first two rows of the table) are preserved. Internal and External stylesheet references (the last two rows of the table) are lost.

Expected Results:  
Ideally all styling would be preserved.

FWIW, Opera doesn't preserve styling at all.
Attached file External Stylesheet
Attached file HTML test case
Keywords: testcase
Confirming.
There is similar Bug 116083 but it's focused on <pre> tag so I'm not duplicating to it.

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2pre) Gecko/2007120505 Minefield/3.0b2pre ID:2007120505
Status: UNCONFIRMED → NEW
Ever confirmed: true
This was wontfixed per bug 189320 comment 2, but it may be needs to be reconsidered, as Chrome does this (by inserting the computed style inline in the copied elements).
OS: Windows XP → All
Hardware: x86 → All
Summary: Copy highlighted text to clipboard ignores non-inlined CSS styling → Copy highlighted text to clipboard ignores non-inlined CSS styling when pasting as rich text (to HTML editors, MS Word, Excel, Outlook etc.)
Whiteboard: [parity-chrome]
Version: unspecified → Trunk
To test without MS Word you can open this data URL:

data:text/html,<div contenteditable>Text

then focus the div and paste.
Firefox 37.0.2 no longer copies even the inline styles. I'm not sure whether this merits opening a new bug or not. Operating system: MacOS X Yosemite. Safari and Chrome copy rich text properly.
Whiteboard: [parity-chrome] → [parity-chrome][platform-rel-Microsoft][platform-rel-Outlook]
platform-rel: --- → ?
I wouldn't say it's related to Microsoft or Outlook. The reason I added myself to the bug is that on Mac OS, when I try to copy from Firefox to a native Mac application that supports rich text (not a Microsoft application), the styling is not kept, while copying from Chrome/Safari keeps the styling. And it used to work in Firefox in the past.
platform-rel: ? → -
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Keywords: parity-chrome
Whiteboard: [parity-chrome][platform-rel-Microsoft][platform-rel-Outlook] → [platform-rel-Microsoft][platform-rel-Outlook]
This was also reported on webcompat.com for LinkedIn copy-pasting.
Flags: webcompat?
Whiteboard: [platform-rel-Microsoft][platform-rel-Outlook] → [platform-rel-Microsoft][platform-rel-Outlook][webcompat]

Migrating Webcompat whiteboard priorities to project flags. See bug 1547409.

Webcompat Priority: --- → ?

See bug 1547409. Migrating whiteboard priority tags to program flags.

Kagami, should this block blink-editor-compat?

Webcompat Priority: ? → P3
Flags: needinfo?(krosylight)

It seems Chrome adds inline style="background-color: blue" but only when pasting across apps. cc'ing Mirko who have recently done some copy-paste work, as I'm not quite familiar with clipboard things.

Flags: needinfo?(krosylight) → needinfo?(mbrodesser)
Flags: needinfo?(mbrodesser)

Chrome also adds inline style when copy-pasting within the browser (e.g. to data:text/html,<div contentEditable="true">X</div>). Firefox doesn't.

So this should also block "blink-editor-compat".

Chrome inlines each element's style a lot. If we do similar things, cannot we apply same style smarter? (I don't have any concrete idea though.)

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: