1

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

1

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.

answered Dec 12, 2019 at 6:12
1
  • 1+...Thnk You.. Commented Dec 13, 2019 at 9:24
0

if this is not working please use: confiuration

answered Jul 31, 2024 at 10:33
2
  • <?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> Commented Jul 31, 2024 at 10:35
  • 1
    Please edit instead of commenting to update. Commented Jul 31, 2024 at 12:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.