Tinymce Plaintext Paste


#1

With the new Tinymce 4 used in SS4, there is that annoying “You are now in paste mode yadda yadda” message that appears whenever you click on the Plaintext Paste button.

Although it disappears when you close it, it reappears whenever there is a page load and you click the paste button again; none of my clients are thrilled by this.

There is an easy way to disable this, in your _config.php, add in the following code:

use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
call_user_func(function () {
    $config = TinyMCEConfig::get('cms');
    $config->setOption('paste_plaintext_inform', false);
});

And watch your clients thank you for this!


#2

I would only suggest to add an if statement around it, to check if the user is actually in the CMS. It’s minor, but it may impact performance a bit. And every little bit of thing that could save load, is worth the effort nowadays :slight_smile:


#3

This is absolutely marvellous @CW_Chong thank you for posting this Tip.

It also works on individual DataObjects in the public function getCMSFields() method so you can customise it for certain users or certain DOs / Pages.