TinyMCE Paste Issue / Configuration

Wildcat Media

Well-known member
Well, I converted yet another forum to XF, and have had another round of complaints about the editor window pasting text in with formatting. The support over at TinyMCE has been less than helpful, but some pitiful little ol' user like me has no clout over there, and other than a few suggestions to start disabling editor features, nothing has materialized. However, they do have an option to add a new button that will paste in your text as plaintext for you. (I feel that if this is possible via a button, it should also be possible as a default configuration value.)

Basically, I want TinyMCE to paste in text as plaintext by default. It does not seem possible given their configuration values.

Aha! Now, this brings up an idea that I had earlier today. What if the TinyMCE configuration were put into its own template? That would make it easy to find, and easy to edit if needed. Commented so that we know what we are changing.

And if I were to take this a step further, it would be a nice feature (even if via an addon) to create an admin interface to allow us to configure some of the default TinyMCE settings and behaviors, without having to dig into the code.

I realize I could split my own template out and to it myself, but the whole idea is to leave default XF templates untouched. Having an easier method to configure TinyMCE would be most welcomed here at Casa Rudy. :)
 
Upvote 7
I did find where you could hook into the TinyMCE configuration via a template (it is the hook named "editor_tinymce_init"), but if you want to add any of the plugins, those are outside the hook and you still have to edit the list of plugins above. (I have not yet experimented to see if additional plugins can be added into the main init body for TinyMCE. I would think it's possible. XF creates a variable in JS called "plugins" that is created above the init hook section.)

For the paste issue, I found that there is a paste plugin which gives additional parameters to configure, but none of them allowed plain text pasting by default. One that looked promising was paste_remove_styles, but setting it to "true" did nothing. Neither did the others. Something must be working, though, as I was able to add a "paste plain text" button from that plugin, and was able to set the paste_text_sticky parameter to "true" which makes the button stay selected while you are working in the editor.

The one flaw in adding a button is that the tooltip text is incorrect. So, I am guessing some sort of phrase needs to be added to the system...? I tried adding the standard copy/cut/paste buttons, and for the copy button as an example, "xenforo.copy_desc" shows as the tooltip text. For the paste plugin, the button reads "paste.paste_text_desc".

I realize it would probably add to the JS burden, but having a default XF editor, with easy options to set additional buttons and activate TinyMCE plugins as needed, might be useful down the road a bit.
 
Not really agreeing or disagreeing with your suggestion, but is the "remove formatting" button (found at the top left of the editor) not working for you?
 
That is an extra step. Ultimately the editor should be set so it never styles pasted text, and arguably that should be the default. A lot of members on most of the forums I run paste in text from sites, and it is an annoyance even for me. If I'm pasting in even as simple as a product or serial number, why should I have to go back and continually remove formatting from my own post? I even had to do it above--I pasted in the "paste_text_sticky" option from TinyMCE and it was in grey and not very readable. Useless.

I blame MS Word--for some boneheaded reason, they must have felt it was cool to have something paste into a Word document with the formatting from the source. So now, everyone wants to do it because it's "cool." As someone who writes a lot for both work and school, and posts actively in forums, it is one of the most annoying "features" (I call it a "bug", sorry) to have any editor paste in formatting unless you specifically ask. When you are writing and/or doing research, the majority of the time you are just copying small snippets up to an entire paragraph of text to quote it. There is never a reason I would ever want formatted text pasted.

That is one of the few reasons I do not like TinyMCE. Until they correct this, I consider it a bug.
 
You can always use the plain text editor and set it as the default in your account preferences.
 
I regularly switch from TinyMCE to plain text if I want to copy and paste without formatting.

A WYSIWYG editor is suppose to keep the formatting after all, which is why the plain text option exists.
 
I regularly switch from TinyMCE to plain text if I want to copy and paste without formatting.

A WYSIWYG editor is suppose to keep the formatting after all, which is why the plain text option exists.
I think this is wrong. A wysiwyg editor lets you edit a post and keep formatting. I hate how it keeps formatting from paste. Think about it this way, my forum has a light and dark skin... some people cut and paste text from MY site, and because of it, half the users can't read posts.
 
Bump. This is very annoying!
Having an easier method to configure TinyMCE would be most welcomed here at Casa Rudy.

Does this work ?
Open /js/tinymce/themes/xenforo/editor_template.js

Find:
Code:
theme_xenforo_buttons1 : 'removeformat,|,fontselect,fontsizeselect,forecolor,xenforo_smilies,|,undo,redo',

Replace with:

Code:
theme_xenforo_buttons1 : 'removeformat,|,xenforo_smilies,|,undo,redo',

That should be enough, I think!

If not ask twollert to see if he can help you.
 
You think that's annoying? TextEditor and Notes on Mac work exactly like that. Difficult to get rid of formatting sometimes. I'll abstain from voting here.
 
I think this is wrong. A wysiwyg editor lets you edit a post and keep formatting. I hate how it keeps formatting from paste. Think about it this way, my forum has a light and dark skin... some people cut and paste text from MY site, and because of it, half the users can't read posts.

Agreed--even Microsoft Word lets you set a default to paste in text as plain text, without formatting. I cannot think of one single reason I would ever want to copy someone else's text formatting into a forum post I am making.
 
This technically is a TinyMCE issue, so I doubt there is anything XF could do to change it (unless they have more clout over on the TinyMCE support forum...I certainly don't). About all I was able to do was add a "paste plain text" button on the toolbar, but it does not display correctly since I don't know what the heck I'm doing. *sigh* But as I mentioned, default behavior should always be for plain text pasting. We are pasting in content from all over the web, and it really bothers me to have someone else's dysfunctional formatting in my posts.
 
Thats not what we're asking for... We dont want to disable any bbcode; we just dont want formatting retained on paste. If someone wants to format their stuff, they should be able to... but it should not be formatted automatically.
that can be adapted to do just that. the different edits listed do different things, such as remove the button, remove the paste formatting, and removing the ability to manually use code.
 
that can be adapted to do just that. the different edits listed do different things, such as remove the button, remove the paste formatting, and removing the ability to manually use code.
I did not see anything that stopped paste formatting.
 
Top Bottom