#12256 closed Bug (fixed)
Paste from Word plugin removes classes
| Reported by: | Boris Lykah | Owned by: | Piotr Jasiun |
|---|---|---|---|
| Priority: | Normal | Milestone: | CKEditor 4.4.8 |
| Component: | General | Version: | |
| Keywords: | Support | Cc: |
Description
When pasting content from word the classes assigned to the elements by filter are removed.
Use config with Bold definition that involves classes.
coreStyles_bold: {
element: 'span',
attributes: { 'class': 'myboldclass' },
overrides: ['strong', 'b']
},
When pasting bold text from Word, the result is <span> without class. The offending line that always removes class is
'class': falsyFilter,
in pastefromword/filter/default.js.
Change History (9)
comment:1 Changed 11 years ago by
| Keywords: | Support added |
|---|
comment:2 Changed 11 years ago by
| Milestone: | → CKEditor 4.5.0 |
|---|---|
| Owner: | set to Piotr Jasiun |
| Status: | new → assigned |
comment:3 Changed 11 years ago by
comment:4 Changed 11 years ago by
The custom class added in the paste from Word plugin is removed by the pasteFilter introduced recently (#11621). There are multiple possible solution for this issue:
- disable
pasteFilter(by addingpasteFilter: nullinto the config), but withoutpasteFilercontent pasted from Chrome will contain all the mess, - add
myboldclassclass to thepasteFilterrules, but it is not that easy at the moment becausepasteFilterusesemantic-contentwhich is generated dynamically and there is no easy way to add some custom rule in the config, - automatically add classes from custom styles to
pasteFilter:semantic-contentfilter, what seems to be the best way, but allcoreStyles_*configs need to be checked, - remove form the paste from word filter code which apply custom styles (remove these lines), custom styles will be applied anyway by ACF and, because ACF will handle the content after
pasteFilteris applied, the custom styles will not be removed; but if ACF is disabled custom styles will not be applied.
comment:5 Changed 11 years ago by
add myboldclass class to the pasteFilter rules, but it is not that easy at the moment because pasteFilter use semantic-content which is generated dynamically and there is no easy way to add some custom rule in the config,
On instanceReady use editor.pasteFilter.allow() - that's it. That's how you're supposed to extend paste filter's settings.
comment:6 Changed 11 years ago by
| Status: | assigned → review |
|---|
So the changes in code are done. Changes in t/12256. To enable pasting from word in Chrome additional rule in paste filter is needed:
editor.on( 'instanceReady', function( evt ) {
editor.pasteFilter.allow( 'span(myboldclass)' );
} );
comment:7 Changed 11 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | review → closed |
Fixed on master with git:e8a747d.
Since 4.5.0 this patch to work will need the code mentioned in comment:6. This lack of automation comes from the fact that PFW plugin is a bit outdated. Instead of using the ACF to transform one styles into another it does it by itself, but it does it too early. The paste filter is not aware of such things and strips classes that are not supposed to exist at this point. We plan to resolve this situation in the future by rebuilding the PFW filter.
comment:8 Changed 11 years ago by
After bit of thinking I reported #13093, because the conflict between paste filter and PFW is far more general.
comment:9 Changed 11 years ago by
| Milestone: | CKEditor 4.5.0 → CKEditor 4.4.8 |
|---|

Bug in the pasteFromWord plugin is fixed. Fix and tests pushed to t/12256.
Unfortunately working on this issue I found another problem with pasting on Chrome. Classes added by paste from Word are later removed by the filter.