This issue replaces or follows-up on some older issues in order to better coordinate them:
#474588: 'Force cleanup on standard paste' not working
#776278: Toggle paste as plain text does not work
#875404: "Force cleanup on standard paste" does not do anything with CKeditor
#1762462: Unable to force cleanup on standard paste

The only editors having paste-related options are TinyMCE, FCKeditor,and CKEditor. I've search through all other supported editors and from what I can tell, no other editors have options affecting how content is treated when pasted. Other editors are known to have buttons/commands for pasting via a toolbar or context menu, but there are no known ways to change its behavior.

What this patch does

TinyMCE

  • Renames the "Force cleanup on standard paste" setting to "Process contents on paste" and changes the description to better clarify that no paste related processing will be done unless this is enabled.
  • Allow to change the 'paste_text_sticky' setting via a 'Sticky "Paste Text" button' checkbox
  • Allow to change the 'paste_text_sticky_default' via a 'Paste as plain text by default' checkbox - essentially makes the "Paste text" toolbar button enabled by default. Note: This is the closest you get to "forcing plain text" you get using simple settings tweaking.
  • Added widgets for 'paste_block_drop', 'paste_retain_style_properties', 'paste_strip_class_attributes', 'paste_remove_spans', 'paste_remove_styles', 'paste_remove_styles_if_webkit', 'paste_convert_middot_lists', 'paste_convert_headers_to_strong', 'paste_max_consecutive_linebreaks', 'paste_text_use_dialog', 'paste_text_sticky', 'paste_text_sticky_default', 'paste_text_notifyalways' and 'paste_text_linebreaktype'.
  • Some of the above are enabled by default in the profile configuration GUI to reflect actual editor defaults.

FCKeditor

  • Allow to change the 'AutoDetectPasteFromWord' setting via a "Auto detect paste from Word" checkbox. Enabled by default in the Wysiwyg GUI to reflect it's default state in the FCKEditor library.
  • Allow to change the 'ForcePasteAsPlainText' setting via a "Force paste as plain text" checkbox (Disables Word cleanup)
  • Updates existing FCKeditor profiles and renames the 'paste_auto_cleanup_on_paste' setting to 'ForcePasteAsPlainText', if it's been previously set.

CKEditor

  • "Force paste as plain text" now toggles the 'forcePasteAsPlainText' setting instead of using 'paste_auto_cleanup_on_paste' internally (TinyMCE-specific internal name which didn't actually reflect what it did. It's actually only used in the current -dev snapshots.)
  • Updates existing CKEditor profiles and renames the 'paste_auto_cleanup_on_paste' setting to 'forcePasteAsPlainText', if it's been previously set.
  • Adds widgets for 'pasteFromWordNumberedHeadingToList', 'pasteFromWordPromptCleanup', 'pasteFromWordRemoveFontStyles' and 'pasteFromWordRemoveStyles' for CKEditor => 3.1.0.
  • Some of the above are enabled by default in the profile configuration GUI to reflect actual editor defaults.

Others

  • The "Force cleanup on standard paste" checkbox will no longer show up in the GUI since it has been moved to the TinyMCE implementation.

Thoughts

  • Add new 'editor defaults settings callback'-callback for editor definitions, and eventually 'settings defaults callback' for plugins (needs 'settings form callback' first), to avoid storing a really large JSON object and passing lots of settings to the client which do not actually override defaults.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sarenc’s picture

Looking forward to the patch! :)

TwoD’s picture

Status: Active » Needs review
FileSize
21.45 KB

Here you go. :)

It's a pretty big patch with lots of potential for typos so I probably missed something here and there.
The setting descriptions are taken from the official editor documentations where available, reverse engineered from source where needed and reworded to [hopefully] make more sense to Drupal/Wysiwyg module users.

TwoD’s picture

Issue summary: View changes

Updated issue summary with additional changes.

Sarenc’s picture

Patch working great for me.

This is very much appreciated. I told my boss this was possible then discovered it wasn't working. I will be happy to tell her it's working now! :D

agoradesign’s picture

FileSize
21.46 KB

Thank you very much for the patch. You're right, there's a lot of potential for typos ;):

  1. the big one: in your update function, you're correctly unserializing the settings array, but don't use it. This causes an error during update, failing to complete it - only if it would really change something in the DB
  2. the small one: you wrote "Promt on cleanup" instead of "Prompt on cleanup"

Attached the modified patch that addresses both issues

best regards,
Andi

TwoD’s picture

Thanks agoradesign! This is exactly why I try to always post a patch before committing anything!

I've decided to perform a general cleanup of the settings form and move all editor-specific settings out to the individual integrations and later rebase this patch on that. I've done most of it already but I'm not quite done. That first patch will take care of removing unused settings (including those removed by this patch) and performing the internal renaming update. This patch will then focus on just adding the new paste settings widgets for each editor. I'll post a link here when that patch is up. (I work this weekend and then I go on vacation so I'll have more time to spend here).

dawnbuie’s picture

Would this patch work for 6.x-2.x-dev as well?

thank you.

TwoD’s picture

I don't think it'll apply cleanly as-is, but I do plan to backport to D6 soon after D7 is done. No plans for D5.

dddave’s picture

What's the status here? Would love to test this as this is an annoying as heck problem.

TwoD’s picture

Status: Needs review » Needs work

This needs a re-roll since #2018439: Move editor-specific options out of the default profile UI. got in, sorry I forgot to post the link to that issue earlier. And guess what, "vacation" appears to mean you get even less time over when you're a house owner. Should have seen that one coming... Anyways, I'm back at work now, both on the job paying my bills and work here. I'll reroll this when I'm back home unless someone beats me to it.

TwoD’s picture

Issue summary: View changes

Tag typo fix.

TwoD’s picture

Status: Needs work » Needs review
FileSize
14.91 KB

Rerolled against current 7.x-2.x.

The update function is no longer needed since #2018439: Move editor-specific options out of the default profile UI. took care of all that for us. That update hook does not explicitly remove old paste-related options from all existing profiles where they aren't used, but they will be skipped when those editor profiles are saved again anyway.

Sarenc’s picture

Tested new patch. It applied cleanly and everything still working. The error during update went away.

Sarenc’s picture

Issue summary: View changes

Removed irrelevant point.

BWPanda’s picture

FileSize
14.89 KB

Here's an updated patch for the latest dev version (applying the last patch failed for me).

Could someone please explain what the difference is between the following TinyMCE buttons/plugins (I'm using version 3.5.8)?

  • Paste
  • Paste text
  • Paste from Word

Which do I need to use for this functionality?

BWPanda’s picture

FileSize
14.8 KB

Same as #12 patch, updated for latest dev.

gmclelland’s picture

The patch in #13 works for me with TinyMCE 3.5.8. Thanks everyone. I would set this to RBTC, but I'm not using CKeditor or FCKeditor.

gmclelland’s picture

@BWPanda - On your wysiwyg profile, enable the Paste text and Paste from Word plugin. Save the profile and reedit the profile. There should now be a "Paste plugin" vertical tab with options.

If you want plain text to be the default, choose the following options:

  • Process contents on paste - checked
  • Retain style properties: none
  • Strip class attributes: all
  • Remove Spans - checked
  • Remove styles in Webkit - checked
  • Convert Word lists - checked
  • Paste as plain text by default - checked

Hope that helps

BWPanda’s picture

FileSize
14.43 KB

Updated patch for latest dev.

Chris Charlton’s picture

Cool, so where do we want to take this? It's been 1-2 years since any patches/changes.

  • TwoD committed 5ea11c4 on 6.x-2.x
    - #1963766 by TwoD, agoradesign, BWPanda: Improved support for paste...
  • TwoD committed 913ec3e on 7.x-2.x
    - #1963766 by TwoD, agoradesign, BWPanda: Improved support for paste...
TwoD’s picture

Status: Needs review » Fixed

Thank you all for helping with this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.