#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)
Change History (13)
Changed 12 years ago by
Attachment: | 16103081_plain.html added |
---|
comment:1 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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 12 years ago by
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 12 years ago by
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 12 years ago by
OK, I can recreate this with your original 4.1.2 version. I did this:
- Downloaded 4.1.2 from your http://ckeditor.com/builder site. I left everything as it is, created a "full" preset.
- 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.
- In my IE9 I navigated to http://localhost/ckeditor. My index.html and the embedded editor loaded correctly.
- 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.
- I repeated #4 with the attached 16103081_plain.html. After pasting, the background color was black.
comment:5 Changed 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
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 11 years ago by
Component: | General → Plugin : Paste from Word |
---|---|
Keywords: | Oracle added; oracle removed |
test file