Paste Format allows you to clean-up the text you copy/paste into your content from other web pages, MS documents, e-mail clients, etc.
Currently works only with CKEditor editor either through CKEditor or WYSIWYG module.

I do really appreciate the module and think you've come up with the most foolproof answer yet to paste sanitization issues. (c) David Lesieur

This module allows you to process any text you are pasting into your WYSIWYG editor through the Input format (D6) or Text format (D7) before inserting it into your content.

Dependencies

CKEditor OR WYSIWYG module with CKEditor editor.

Installation and Setup

  • Download, unpack and enable as any other Drupal module.
  • IMPORTANT Create/setup a separate new Input/Text format you want to use as a cleanup format to allow only the markup you need on your site. You might find useful these modules: WYSIWYG Filter, HTML Purifier, htmLawed, etc.
  • Set the newly created Input/Text format as a format to clean up pasted text at 'admin/config/content/pasteformat' for D7 or 'admin/settings/pasteformat' for D6.
  • CKEditor module: Enable "Paste Format: Plugin to cleanup pasted text" on needed CKEditor profiles.
    WYSIWYG module: check the "Paste Format" under "Buttons and plugins" when configuring CKEditor editor.
  • Grant 'use Paste Format' for D7 or 'use pasteformat' for D6 permission to user roles that will be using the above CKEditor profiles.

Motivation

Basically, Drupal always stores the original content you input into node textareas in an unchanged form (and this is the right thing to do) and then runs it through its input/text formats system to render/filter the viewable version of this text. But sometimes you know for sure that there might be some garbage markup copied with the text you paste into your content (like style and font definitions from MS Word or classes for the elements from other web-pages) that you don't need on your site. Furthermore, it might interfere with how your content looks like when you are editing it and you are forced to use the "Paste as plain text" or "Clear all formatting" functions of your WYSIWYG editor - and it ruins all the job you have done setting the headers, bolds and italics in your text editor.
It is great that Drupal will filter all these things out (if you have set the appropriate input/text formats) before showing the content to your site visitors, but it will also still store all the original text with all these garbage in the DB and load it once you edit your content.

Similar modules

Sanitizable (formatted text) - Sanitizable will act just before saving the submitted content to the DB, so the user submits the content, then Sanitizable filters the content and saves it to the DB without showing the cleaned up version to the user before putting it to the DB. This module acts on the 'Paste' operation - it fires the AJAX call to the server to process the text the user is trying to paste into WYSIWYG textarea, receives the filtered text and then inserts it into textarea. So the user still sees the version that will be saved into DB and is able to tell if there are any issues with it.

Credits

  • Module development was partially sponsored by Forbes.ru.

Project information

Releases