Magento 2 - TinyMCE enable all the option

Create plugin of Wysiwyg configuration file

etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Ui\Component\Wysiwyg\ConfigInterface">
<plugin name="Saphal_tinymce" type="Saphal\Tinymce\Plugin\Config" sortOrder="5"/>
    </type>
</config>


Now create plugin class:  Saphal/Tinymce/Plugin/Config.php

namespace Saphal\Tinymce\Plugin;

class Config 
{

protected $activeEditor;

    public function __construct(\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor)
    {
        $this->activeEditor = $activeEditor;
    }

    public function afterGetConfig(
        \Magento\Ui\Component\Wysiwyg\ConfigInterface $configInterface,
        \Magento\Framework\DataObject $result
    ) {

        $editor = $this->activeEditor->getWysiwygAdapterPath();

        if(strpos($editor,'tinymce4Adapter')){

        if (($result->getDataByPath('settings/menubar')) || ($result->getDataByPath('settings/toolbar')) || ($result->getDataByPath('settings/plugins'))){
            return $result;
        }

        $settings = $result->getData('settings');

        if (!is_array($settings)) {
            $settings = [];
        }

        $settings['toolbar'] = 'undo redo | styleselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | image | code | bold | italic | underline | strikethrough | alignleft | aligncenter | alignright | alignjustify | alignnone | formatselect | fontselect | cut | copy | paste | outdent | indent | blockquote | undo | redo | removeformat | subscript | superscript | visualaid | insert | hr | bullist | numlist | link | unlink | openlink | charmap | pastetext | print | preview | anchor | pagebreak | spellchecker | searchreplace | visualblocks | visualchars | help | fullscreen | insertdatetime | media | nonbreaking | save | cancel | tabledelete | tablecellprops | tablemergecells | tablesplitcells | tableinsertrowbefore | tableinsertrowafter | tabledeleterow | tablerowprops | tablecutrow | tablecopyrow | tablepasterowbefore | tablepasterowafter | tableinsertcolbefore | tableinsertcolafter | tabledeletecol | rotateleft | rotateright | flipv | fliph | editimage | imageoptions | fullpage | ltr | rtl | emoticons | template | forecolor | backcolor | restoredraft | insertfile | a11ycheck | toc | quickimage | quicktable | quicklink';

        $result->setData('settings', $settings);
            return $result;
        }
        else{
            return $result;
        }
    }
}

Comments