CKEditor: How to filter styles but preserve headings and images?

Hi,

I’m new to XWiki but I really it already. I’m using the office importer extension with LibreOffice as well in a sub-wiki and it’s working pretty well, including the filter styles feature.

However, whenever I paste content from Word or a Google Doc into CKEditor and switch to source view, it preserves the styles like font, line-height, etc.:

(% style=“line-height:1.2; margin-top:13px” %)
[[(% style=“font-size: 11pt; font-variant: normal; white-space: pre-wrap; font-family: Arial; color: rgb(0, 0, 0); font-weight: 700; font-style: normal; text-decoration: none” %)Configuration(% style=“font-size: 11pt; font-variant: normal; white-space: pre-wrap; font-family: Arial; color: rgb(0, 0, 0); font-weight: 700; font-style: normal; text-decoration: none; white-space: pre” %)** **(% style=“font-size: 11pt; font-variant: normal; white-space: pre-wrap; font-family: Arial; color: rgb(0, 0, 0); font-weight: 700; font-style: normal; text-decoration: none” %)2>>url:https://docs.google.com/docuxxxA/edit#heading=h.30j0zll|]]

I tried already everthing, like setting

config.pasteFilter = ‘plain-text’;

or

config.pasteFilter = ‘semantic-content’;

without any luck. Is there any possiblity to achieve to preserve elements like headings and images but remove all other formatting, so users can focus on content while pasting older content?

Thanks,
Markus

Did nobody ever had a similar requirement yet?

See Loading...

The workaround is to disable the pastefromlibreoffice plugin from the CKEditor administration section.

Hi. I disabled the plugin via admin section and added the following line into the config-section:

config.pasteFilter = ‘plain-text’;

Still same behavior. After pasting from Google drive:

(% style=“line-height:1.2; margin-bottom:8px” %)
(% style=“font-size: 10pt; font-variant: normal; white-space: pre-wrap; font-family: Arial; color: rgb(0, 0, 0); font-weight: 400; font-style: normal; text-decoration: none” %)

Why this? Is this documented / recommended somewhere on https://extensions.xwiki.org/xwiki/bin/view/Extension/CKEditor+Integration ? Can you try with just the pastefromlibreoffice disabled and no other custom configuration?

Still the same:

(% start=“3” %)

  1. (((
    (% role=“presentation” style=“line-height:1.2; font-size:16pt; font-family:Arial; color:#000000; font-weight:700; font-style:normal; font-variant:normal; text-decoration:none; vertical-align:baseline; white-space:pre; margin-left:-24px; padding-left:3.6000000000000014pt; padding-inline-start:48px” %)
    = (% style=“font-size: 16pt; font-variant: normal; white-space: pre-wrap; font-family: Arial; color: rgb(0, 0, 0); font-weight: 700; font-style: normal; text-decoration: none” %)Frontend Display(%%) =
    )))

I commented on Loading... with a summary of the current behavior when pasting content within the WYSIWYG editor (CKEditor):

  • paste from Google Docs: styles are not removed; you need to disabled the pastefromgdocs plugin for that
  • paste from LibreOffice: styles are not removed; you need to disable the pastefromlibreoffice plugin for that
  • paste from Word: styles are removed, thanks to applyPasteFilterAfterPasteFromWord