3

I am working with Magento 2.3. But everytime I try to create an instance of

Magento\Cms\Model\Wysiwyg\Config by ObjectManager

I meet this error

Exception #0 (BadMethodCallException): Missing required argument $variablePluginConfigProvider of Magento\Cms\Model\Wysiwyg\CompositeConfigProvider.

Did anyone meet and resolve this one?

1 Answer 1

7

Add below code on your module frontend di.xml file

<type name="Magento\Cms\Model\Wysiwyg\CompositeConfigProvider">
    <arguments>
        <argument name="variablePluginConfigProvider" xsi:type="array">
            <item name="default" xsi:type="string">Magento\Variable\Model\Variable\ConfigProvider</item>
        </argument>
        <argument name="widgetPluginConfigProvider" xsi:type="array">
            <item name="default" xsi:type="string">Magento\Widget\Model\Widget\Config</item>
        </argument>
        <argument name="wysiwygConfigPostProcessor" xsi:type="array">
            <item name="default" xsi:type="string">Magento\Cms\Model\Wysiwyg\DefaultConfigProvider</item>
        </argument>
        <argument name="galleryConfigProvider" xsi:type="array">
            <item name="default" xsi:type="string">Magento\Cms\Model\Wysiwyg\Gallery\DefaultConfigProvider</item>
        </argument>
    </arguments>
</type>




And also change Editor call js on frontend :


             <script>
                    require([
                        'jquery',
                        'mage/adminhtml/wysiwyg/tiny_mce/setup'
                    ], function (jQuery) {

                        var config = '<?php echo $block->getWysiwygConfig() ?>',
                            editor;

                        jQuery.extend(config, {
                            settings: {
                                theme_advanced_buttons1: 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
                                'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
                                theme_advanced_buttons2: null,
                                theme_advanced_buttons3: null,
                                theme_advanced_buttons4: null,
                                theme_advanced_statusbar_location: null
                            },
                            files_browser_window_url: false
                        });

                        editor = new tinyMceWysiwygSetup(
                            'short_description',
                            config
                        );

                        editor.turnOn();

                        jQuery('#short_description')
                            .addClass('wysiwyg-editor')
                            .data(
                                'wysiwygEditor',
                                editor
                            );
                    });
                </script>

           Replace: <script>
                    require([
                        "jquery",
                        "mage/translate",
                        "mage/adminhtml/events",
                        "mage/adminhtml/wysiwyg/tiny_mce/setup"
                    ], function(jQuery){
                        wysiwygcompany_description = new wysiwygSetup("short_description", {
                            "width":"99%",  // defined width of editor
                            "height":"200px", // height of editor
                            "plugins":[{"name":"image"}], // for image
                            "tinymce4":{"toolbar":"formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap","plugins":"advlist autolink lists link charmap media noneditable table contextmenu paste code help table",
                            }
                        });
                        wysiwygcompany_description.setup("exact");
                    });
                </script>
1
  • Worked nicely, thanks!
    – jackcar
    Aug 1, 2019 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.