Cribbed from #1260052-133: Candidate WYSIWYG editors & #1260052-148: Candidate WYSIWYG editors.

We need the ability to configure CKEditor’s pasting to match the currently active text format; specifically to strip tags and/or attributes that are not allowed in the active text format.

Problem/Motivation

In the demo at http://quicksketch.org/wysiwyg/node/9/edit, if I copy/paste the rendered version of:

This is <u>underlined</u> text!
This is <em>emphasized</em> text!
This is <strong>strong</strong> text!
This is <i>italics</i> text!
This is <b>bold</b> text!
This is <strike>strike</strike> text!

Then all formatting is stripped away!

(Note that the Drupal text format only allows the <em> and <strong> tags. That means the others should be stripped, but those two should be retained. CKEditor is configured to only have the buttons for <strong>, <em> and <strike>, note that the latter is not allowed by the Drupal text format.)

If I use the "paste from Word" button, then paste in the pop-up that I get, then press "ok" and finally get to see the result, then only the strong and bold formatting is retained (both are mapped to , which is fine), but all other formatting is stripped away. I'm not sure what's wrong here, but no matter if you look at the Drupal text format settings or the CKEditor UI settings, in neither case this extremely simple pasting example at least seems very much broken. If I'm doing something wrong, I'd love to hear it.

Proposed resolution

https://dev.ckeditor.com/ticket/9829

Remaining tasks

TBD

User interface changes

TBD

API changes

Should be none.

Comments

Wim Leers’s picture

Issue tags: +Spark, +CKEditor in core

Tagging; this helps the CKEditor folks track the "CKEditor in core" status on the Drupal side. On the CKEditor side, see http://dev.ckeditor.com/query?keywords=~Drupal.

duozersk’s picture

Greetings!

Have you guys evaluated what contrib has for this issue? I'm the author of the Paste Format module - http://drupal.org/project/pasteformat - that allows to configure a text format to filter the text pasted into the CKEditor. It works by sending the pasted text to the AJAX callback and getting back the text that was filtered by the configured text format. This way allows to have the filtering to be configured in one place and processed by completely the same code (the same php code that powers any filter we have in the text format, including the filters from contrib).

The only thing is that the module currently doesn't match against the text format choosen on the content editing form - it uses the globally defined text format for this AJAX filtering. The idea was that this text format should really be different from the applied one as the text formats applied to the content when displaying it could process some tokens into the HTML code that is not really allowed to be inserted into the WYSIWYG area, but to be only produced by the filtering process.

Thanks
AndyB

Wim Leers’s picture

Project: CKEditor for WYSIWYG Module » Drupal core
Version: 8.x-1.x-dev » 8.x-dev
Component: Code » ckeditor.module
Assigned: Unassigned » Wim Leers
Status: Active » Closed (duplicate)

#2: Hah, that's a very creative solution :) Unfortunately, it requires a round trip to the server, which is deadly for performance on mobile.

We've worked to address this issue, a related security issue and a related UI issue, all in one well-designed approach — designed & implemented by the CKEditor folks.

Sadly, I somehow forgot/lost track of this issue, so I created a new issue where all of the above is explained much better and in more detail over at #1936392: Configure CKEditor's "Advanced Content Filter" (ACF) to match Drupal's text filters settings. It also contains the patch that makes it all work :)

Wim Leers’s picture