Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It doesn't look like the "Force cleanup on standard paste" option does anything at all when enabled on the CKeditor library. This option is referred to as "paste_auto_cleanup_on_paste" in code, but is not referenced anywhere in the ckeditor.inc file (unlike the fckeditor.inc and tinymce.inc files).
This patch adds the proper filter options (since CKeditor 3.1) if this option is enabled.
Comment | File | Size | Author |
---|---|---|---|
wysiwyg_ckeditor_cleanup.patch | 780 bytes | quicksketch |
Comments
Comment #1
TwoDI looked through the plugin code when writing that implementation and I'm pretty sure pasteFromWordRemoveStyles and pasteFromWordRemoveFontStyles do not affect if a forced cleanup is done or not. That only happens if the pastefromword command is issued (via the PasteFromWord button), or if the content matches the RegExp
/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/
while the pastefromword plugin is active.So, it already does a cleanup if Word content is detected, there doesn't seem to be a way to always force one (other than using the PasteFromWord button) and those settings only affect how that cleanup is done, not when.
These options can be set via hook_wysiwyg_editor_settings_alter() until we get #313497: Allow configuration of advanced editor settings in. (One of the many things I'll try to work on when I get back from my vacation.)
Comment #2
quicksketchI tried out these settings before and after the patch, it does indeed affect all pasting, whether or not using the dialog. Try it out!
Comment #3
quicksketchHmm, I may be misled on this. I'm going to take another look at it and post back later. Clearly the checkbox doesn't do anything though. If the cleanup is currently "automatic" it should be not cleaned up if the checkbox is not checked.
Comment #4
TwoDOk. Yes, the checkbox doesn't do anything (and I would have removed it for CKEditor to avoid the UI confusion - but can't do that properly before #313497 is solved).
The cleanup is only automatic (and not possible to turn off, as far as I can see) if the RegExp above finds a match (during a regular paste event) and the word plugin is active, or if the PasteFromWord button was used (a forcecleanup flag is set). That will trigger the filter plugin to do its thing, and how much it removes depends on the two options used in the patch.
Comment #5
hixster CreditAttribution: hixster commentedI've just added this :
To my own custom CKEditor settings module and it auto detects word and displays a message to the user when they paste in, it then cleans up the markup.
Works a treat!
Comment #6
TwoDPlease follow #1963766: Improve support for paste related options for the current status of support for paste related settings.
Even though I mark this a "won't fix", the code put here could easily be included in the patch for the other issue. It isn't yet, but the other patch isn't final yet either.