magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

custom widget with wysiwyg problem on insert widget via pages or blocks #13409

Closed deagleka closed 5 years ago

deagleka commented 6 years ago

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: `

` **TextAreaField** block: `$editor = $this->_factoryElement->create('editor', ['data' => $element->getData()])->setLabel('')->setWysiwyg(true) ->setConfig($this->getWysiwygConfig($element))->setForceLoad(true) ->setForm($element->getForm());` 2. 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** 1. an image of **Magento Widget** should appear ![image](https://user-images.githubusercontent.com/35908737/35492538-0584d220-04e0-11e8-94c0-f2e3dd3d3653.png) 2. 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** 1. If I turn off wysiwyg on my custom widget: it works fine. 2. If I turn wysiwyg on: **Image** and **Code** doesnt show up. 3. 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.
magento-engcom-team commented 6 years ago

@deagleka , thank you for your report. We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue ona clean installation without third party code.

deagleka commented 6 years ago

magento v2.2.2 clean re-installation theme luma.

I created a new module in app/code/ folder which is a magento2 custom widget

VendorName/MyNameSpace/etc/widget.xml

<?xml version="1.0" ?> <widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd"> <widget class="VendorName\MyNameSpace\Block\Widget\CustomWidget" id="customwidget"> <parameter name="custom_title" xsi:type="block" visible="true" required="true"> <label translate="true">TextArea</label> <block class="VendorName\MyNameSpace\Block\Adminhtml\Widget\TextAreaField"/> </parameter> </widget> </widgets>

In VendorName\MyNameSpace\Block\Adminhtml\Widget\TextAreaField.php, I created "Editor field" via \Magento\Framework\Data\Form\Element\Factory.

image image

My Detail Step is below:

1. Go to Content -> Pages , select Home page -> edit 2. In Content Section, click the icon step2

3. In the widget content: There are 2 options 3.a. Input text with wysiwyg off. step3a

Click Insert Widget It works! step3a-worked 3.a.a If I double click on magento widget image and try to edit it with wysiwyg on step3aa

Click Insert Widget. Check Magento-widget Snippet step3aaa-snippet

You can see the content still aaa, it should be aaa now I will modify you with wysiwyg turn on.

3.b Input text with wysiwyg on.

Nothing happen , the icon magento widget doesnt show up, and there is no snippet code in the content.

In lib/web/mage/adminhtml/wysiwyg/widget.js I put a console.log() to get the result widgetjs-modify

Try setup 3.b again , Inspect and check the output widgetjs-output

If I copy the output and paste on content, it works. So I think there is some problem with js binding param.

Here is my source code for testing.

VendorName.zip

magento-engcom-team commented 6 years ago

@deagleka, thank you for your report. We've acknowledged the issue and added to our backlog.

nelero commented 6 years ago

Hi, so, what's the solution ? seems this bug is openend for a while now :(

molovo commented 5 years ago

I just spotted this issue after opening #19742. Has there been any progress with finding a solution, or any workaround someone could recommend?

ghost commented 5 years ago

Hello everyone, we close this ticket and postpone the discussion to the new one ->https://github.com/magento/magento2/issues/19742

magento-engcom-team commented 5 years ago

Hi @deagleka. Thank you for your report. The issue has been fixed in magento/magento2#20174 by @molovo in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.2 release.