I want to add wysiwyg editor in store configuration. I added also. But, when I click on "Insert Variable" it's return error :
Uncaught ReferenceError: MagentovariablePlugin is not defined
How to solve this error?
Any help would be appreciated !!
Thanks!!
2 Answers 2
I found answer for that. Follow this below steps to solve this issue :
Add Field in system.xml file :
<field id="wysiwyg_editor" translate="wysiwyg" sortOrder="4" type="editor" showInStore="1" showInDefault="1" >
 <label>wysiwyg editor</label>
 <frontend_model>Vendor\Module\Block\Adminhtml\System\Config\Editor</frontend_model>
</field>
Now, create file for add wysiwyg editor in element :
app\code\Vendor\Module\Block\Adminhtml\System\Config\Editor.php
<?php
namespace Vendor\Module\Block\Adminhtml\System\Config;
use Magento\Framework\Registry;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Editor extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var Registry
*/
protected $_coreRegistry;
/**
* @param Context $context
* @param WysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
 Context $context,
 WysiwygConfig $wysiwygConfig,
 array $data = []
) {
 $this->_wysiwygConfig = $wysiwygConfig;
 parent::__construct($context, $data);
}
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
 // set wysiwyg for element
 $element->setWysiwyg(true);
 // set configuration values
 $element->setConfig($this->_wysiwygConfig->getConfig($element));
 return parent::_getElementHtml($element);
}
}
Now, create adminhtml_system_config_edit.xml for update editor handle :
app\code\Vendor\Module\view\adminhtml\layout\adminhtml_system_config_edit.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <update handle="editor"/>
</page>
Clean cache and it's working.
- 
 1+...Thnk You..Ronak Rathod– Ronak Rathod2019年12月13日 09:24:59 +00:00Commented Dec 13, 2019 at 9:24
if this is not working please use: confiuration
- 
 <?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <link src="Magento_Backend::js/bootstrap/editor.js"/> </head> </page>Hardik Patel– Hardik Patel2024年07月31日 10:35:19 +00:00Commented Jul 31, 2024 at 10:35
- 
 1Please edit instead of commenting to update.General Grievance– General Grievance2024年07月31日 12:30:41 +00:00Commented Jul 31, 2024 at 12:30
Explore related questions
See similar questions with these tags.