Description
Preconditions
Magento v2.2.2
Cache disabled
Steps to reproduce
1.created a custom widget with text field using editor to activate wysiwyg
widget.xml file:
<parameter name="custom_title" xsi:type="block" visible="true" required="true"> <label translate="true">Title</label><block class="VendorName\NameSpace\Block\Adminhtml\Widget\TextAreaField"/></parameter>
TextAreaField block:
$editor = $this->_factoryElement->create('editor', ['data' => $element->getData()])->setLabel('')->setWysiwyg(true) ->setConfig($this->getWysiwygConfig($element))->setForceLoad(true) ->setForm($element->getForm());
- Create custom widget with 2 different ways:
a. via Admin -> Content -> Widgets : This works fine, everything is ok.
b. via Admin -> Content -> Pages -> Home Page -> Content -> Insert Widget : Problem starting from here.
Expected result
- an image of Magento Widget should appear
- if check via code, it should have this below code:
{{widget type="VendorName\NameSpace\Block\Widget\CustomWidget" custom_title="abc" template="VendorName_NameSpace::widget/master-template.phtml"}}
Actual result
-
If I turn off wysiwyg on my custom widget: it works fine.
-
If I turn wysiwyg on: Image and Code doesnt show up.
-
If I turn off wysiwyg and make my widget code appear -> then edit it by double click on the image -> change the text into wysiwyg -> save.
The image still there, however if checking the value : content not change -> there is another widget image appear in the content if turn on wysiwyg.
Note
I think it is some kind of duplicate wysiwyg command mceInsertContent in lib/web/mage/adminhtml/wysiwyg/widget.js line 383
this.getWysiwyg().execCommand('mceInsertContent', false, content);
Hope this help. Have been stucked for this problem more than 2 days. Need help. Thank you.