Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#10558 closed Bug (invalid)

COPIED TABLE TD STYLE LOSES BACKGROUND COLOR, ETC. ON PASTE

Reported by: Zoltan Koszegi Owned by:
Priority: Normal Milestone:
Component: Plugin : Paste from Word Version: 4.1.1
Keywords: Oracle Cc:

Description

The content we are pasting was copied from Office and therefore CK's paste-from-word rules are applied. These rules are controlled by the 'pasteFromWordRemoveFontStyles' and 'pasteFromWordRemoveStyles' configuration settings. Our implementation sets both to false meaning that all formatting should be preserved during paste. The 'background' CSS property is still filtered out, though, and this should not happen.(BTW, if you try to paste the same content into the CK demo page, you lose *all* formatting, obviously because they set the above config settings to true.)

Note that if I strip the office mumbo-jumbo from the page and copy/paste the content, the paste-from-word rules are not applied and the content is pasted correctly.

Attachments (3)

16103081_plain.html (10.7 KB) - added by Zoltan Koszegi 6 years ago.
test file
16103081_office.htm (78.1 KB) - added by Zoltan Koszegi 6 years ago.
test file
index.html (954 bytes) - added by Tamas Szvitacs 6 years ago.
Test page that loads CK.

Download all attachments as: .zip

Change History (13)

Changed 6 years ago by Zoltan Koszegi

Attachment: 16103081_plain.html added

test file

Changed 6 years ago by Zoltan Koszegi

Attachment: 16103081_office.htm added

test file

comment:1 Changed 6 years ago by Jakub Ś

Resolution: invalid
Status: newclosed

You have forgotten about ACF.

Just set in editor instance extraAllowedContent or disable ACF:

pasteFromWordRemoveFontStyles : false,
pasteFromWordRemoveStyles : false, 	
//allowedContent : true		
//or instead of disabling ACF
extraAllowedContent : 'td{background}'

comment:2 Changed 6 years ago by Zoltan Koszegi

We of course have not forgotten about ACF. The “background” style is enabled on all tags using the *{background} rule. If we load a page with something with the background style, it correctly displays. As I wrote above, if we paste from some other source, not Word, the content is pasted correctly too. The problem occurs on pasting from Word only. By the time the filter rules are applied, the background style is already gone even if the two pasteFromWordxxx config settings are set to false. We actually have a transformation that converts the “background” style to the individual “background-xxx” styles. The elements passed to the transformation don’t have a “background” style if we paste from Word. In every other case our transformation is successfully applied.

comment:3 Changed 6 years ago by Jakub Ś

I have tried doc, docx files and HTML files you have provided. I have got black background in all cases. I have also tried both versions 4.1.1 and 4.1.2.

I have either missed something or you haven't for example applied changes correctly, cleared browsers cache, have some custom plugins or core changes thus you get this result. Please check this and provide file that is causing problems for you.
Are you able to create file causing problems every time or perhaps this is some special case file where such file was created by accident and all others work fine?

comment:4 Changed 6 years ago by Tamas Szvitacs

OK, I can recreate this with your original 4.1.2 version. I did this:

  1. Downloaded 4.1.2 from your http://ckeditor.com/builder site. I left everything as it is, created a "full" preset.
  2. I have IIS installed on my windows system, I expanded the downloaded zip into the C:\inetpub\wwwroot\ckeditor folder. I added the attached index.html.
  3. In my IE9 I navigated to http://localhost/ckeditor. My index.html and the embedded editor loaded correctly.
  4. I loaded the attached 16103081_office.html into another browser instance, selected all and copy. Pasted into the ckeditor page. The black background was gone, it's all white.
  5. I repeated #4 with the attached 16103081_plain.html. After pasting, the background color was black.

Changed 6 years ago by Tamas Szvitacs

Attachment: index.html added

Test page that loads CK.

comment:5 Changed 6 years ago by Piotrek Koszuliński

I tried to reproduce this issue: IE9, index.html, pasted content of 16103081_office.html and black header's background is preserved.

Although, what I noticed is that because of license comment your page is running in quirks mode. This may influence how editor works. E.g. uiColor is not applied to editor's interface because of this.

comment:6 Changed 6 years ago by Tamas Szvitacs

You are right about the quirks mode. However, if I remove the copyright and the page is rendered in standards mode, it still doesn't work. The problem is not with rendering. The background style is lost during paste.

Can you point to a publicly available CK instance where this works? I can't try it on the demo page because all instances seem to be configured to remove styles on paste from word. This way, we just keep telling each other 'it works for me' and it 'doesn't work for me'. I'd like to figure out what's going on.

comment:7 Changed 6 years ago by Jakub Ś

I was finally able to reproduce this. Could you guys provide less awkward test cases next time?

Correct TC is simply to create table with black background in MS Word and paste it into Webkit – not open some word generated HTML in Webkit and copy it into IE9. When open HTML in Webkit you should copy it into editor in Webkit. There are browser differences, quirks etc. so such tests are incorrect.

Problem is that in Webkit background-color property is seen as background. Paste from Word filter should recognize this.

It has already been mentioned in #10364 and #9991 (comment:8)

comment:8 Changed 6 years ago by Jakub Ś

I believe a simple fix would be adding to pastefromword\filter\default.js

There is below rule:

[ ( /^background-color$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'colorButton_backStyle' ], 'color' ) : null ]

adding another one like:

[ ( /^background$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'colorButton_backStyle' ], 'color' ) : null ]

plus allowedContent:true or extraAllowedContent : 'td{background}' will solve the problem

comment:9 Changed 6 years ago by Piotrek Koszuliński

I loaded the attached 16103081_office.html into another browser instance, selected all and copy. Pasted into the ckeditor page. The black background was gone, it's all white.

Hmm... j.swiderski may be right. I haven't read this point carefully enough. If you're indeed opening that HTML file in other browser than IE9, then it may not work. Every browser generates different HTML for Word files. This HTML is not even close to any standard and cannot be opened in other browsers. That's why your testing scenario is broken.

So to be precise - I'm opening your attached HTML in IE9 and paste that in the editor running in IE9. Then everything works ok.

The question is - what was the initial case? On which browsers do you have problem with background?

comment:10 Changed 5 years ago by Frederico Caldeira Knabben

Component: GeneralPlugin : Paste from Word
Keywords: Oracle added; oracle removed
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy