Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I just updated to TinyMCE 3.3.2.
When I toggle the "paste as plain text" function on, the text is pasted with html markup, not as plain text.
Maybe this is an issue that belongs to TinyMCE and not Wysiwyg.
Does someone have a solution? Thanks
Comment | File | Size | Author |
---|---|---|---|
#12 | wysiwyg_paste_as_plain_text_d7.patch | 2.54 KB | janchojnacki |
#11 | wysiwyg_paste_as_plain_text.patch | 3.07 KB | Roobarb |
Comments
Comment #1
TwoDWysiwyg doesn't have a GUI option to toggle any "paste as plain text" option. If you mean "Force cleanup on standard paste", it won't remove all markup from an HTML selection, just the most annoying parts of what Word produces.
There's also the "Paste text" button you can enable, but it uses a dialog which forces the browser to use the text/plain variant if the clipboard has an HTML selection. (Note that selecting "source HTML markup" from text editors like Notepad will still select it as text/plain, which isn't a HTML selection. Then all the < and > will be escaped by the editor to < and > etc.
The rewritten Paste plugin will try to autodetect Word contents when pasting and clean it up. But to paste plain text, you need to use the "Paste text" button/dialog.
I don't think TinyMCE even has a way to force text/plain pastes like CKEditor does (need to enabled that via hook_wysiwyg_editor_settings_alter() for now).
Comment #2
tomsm CreditAttribution: tomsm commentedWhen I revert back to TinyMCE version 3.2.7 the problem is fixed because "paste as plain text" uses a popup window in which the text needs to be pasted.
In version 3.3.2 this popup window has been replaced by a toggle function that does not work.
Comment #3
TwoDAh, you meant the button in the toolbar. I thought you were talking about an option provided by Wysiwyg.
I can confirm that contents are not pasted as text when the button is toggled, but it works in the official TinyMCE demo. I don't know why it doesn't work yet, but I suspect it may be something related to the invisible div TinyMCE uses to catch the pasted contents.
Comment #4
tomsm CreditAttribution: tomsm commentedIndeed, that is the button I meant.
Comment #5
superfedya CreditAttribution: superfedya commentedsame here, with tinymce 3.3.8. any fix?
Comment #6
tomsm CreditAttribution: tomsm commentedsame with 6.x-2.2 and tinyMCE 3.3.9.3
Comment #7
TwoDI tested this with Wysiwyg 6.x-2.x-dev and TinyMCE 3.3.9.3 (and the 3.4beta) and it does work, but one must check the "Force cleanup on standard paste" option under "Cleanup and output" when configuring the editor profile.
The description for that checkbox is wrong:
It should instead look more like the official description of TinyMCE's paste_auto_cleanup_on_paste setting:
Note that this applies to TinyMCE only, other editors use this options in other ways, and that Wysiwyg currently has this disabled by default. It used to disabled in TinyMCE too but later versions changed that.
When "Force cleanup on standard paste" has been checked (or in practice, the paste_auto_cleanup_on_paste setting is enabled) TinyMCE will process the pasted contents, but plain text will only be generated if the "Plain text" button is ON.
TinyMCE automatically detects pasted MS Word contents by matching against a Regular Expression:
/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i
. If it's a positive match, MS Word cleanup will happen automatically as part of the paste processing.When "Force cleanup on standard paste" is not checked, TinyMCE doesn't care much what happens when pasting, it's all up to the browser.
Paste processing always takes place if the mceInsertClipboardContent command is fired by some "external" script - such as the "Paste from Word" dialog, or the "Paste as text" dialog if the paste_text_use_dialog option has been set. The "Paste from Word" dialog additionally sets an internal "wordContent" flag to always force the MS Word cleanup, but users can't request this without going through that dialog.
paste_text_use_dialog can currently only be enabled via Wysiwyg by implementing hook_wysiwyg_editor_settings_alter():
To summarise
There seems to be no setting to always force a paste (keyboard shortcut or via context-menu) to be inserted as plain text or go through a MS Word cleanup. Hence, the checkbox description is wrong and needs to change. For some editors it should even be removed because they don't support this kind of operation.
I'm not sure yet if we should mark this issue a duplicate of #313497: Allow configuration of advanced editor settings - we'll have to go through all the settings for every editor in there anyway - or leave it open for now.
Comment #8
Jorrit CreditAttribution: Jorrit commentedI have made a module with the following callback:
Using CSS I hide the paste as text button:
Now the user can't disable the paste as text button, it is on by default and it will not toggle after one paste.
Comment #9
fenstratThe method in #8 works flawlessly for those looking to silently run all paste commands through a plain text cleanup.
Comment #10
chromix CreditAttribution: chromix commented#8 works like a charm. I would just change the CSS to the following:
Depending on what skin you're using the display:none property might get overridden.
Comment #11
Roobarb CreditAttribution: Roobarb commentedThe attached patch adds a new option to Wysiwyg (for TinyMCE only), called Activate "Paste as Plain Text" button and make it sticky. If you select this option and display the Paste as Plain Text button, that button will be enabled by default and won't be deactivated after pasting text (you can deactivate it manually by clicking the button though).
Comment #12
janchojnacki CreditAttribution: janchojnacki commentedThanks Roobarb!
Created D7 version of patch
Comment #13
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", much of the code from #12 will be incorporated within the patch for that issue and the authors will be credited for it.