Skip to content

Commit 14646d2

Browse files
tjwiebellirenelagno
authored andcommitted
MAGETWO-72114: TinyMCE v4.6 as a native WYSIWYG editor
- Squashed merge of Sprint 2, includes 72207, 70412, 72120, 81766, 51829, 72365, 72137, and 71249 - Add TinyMCE4 library to Magento core - Move TinyMCE3 to new compatibility module which will be removed from core - Add WYSIWYG fascade and adapter to support easy swapping of editors - Make Editor configuration easily extensible - Fix bug in Category Content area to remove extreneous buttons
1 parent 4bbb256 commit 14646d2

File tree

485 files changed

+3470
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+3470
-556
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ atlassian*
3434
/.php_cs.cache
3535
/grunt-config.json
3636
/dev/tools/grunt/configs/local-themes.js
37-
3837
/pub/media/*.*
3938
!/pub/media/.htaccess
4039
/pub/media/attribute/*

app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,6 @@ public function getAfterElementHtml()
102102
var config = $config,
103103
editor;
104104
105-
jQuery.extend(config, {
106-
settings: {
107-
theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
108-
'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
109-
theme_advanced_buttons2: null,
110-
theme_advanced_buttons3: null,
111-
theme_advanced_buttons4: null,
112-
theme_advanced_statusbar_location: null
113-
},
114-
files_browser_window_url: false
115-
});
116-
117105
editor = new tinyMceWysiwygSetup(
118106
'{$this->getHtmlId()}',
119107
config

app/code/Magento/Catalog/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public function isUsingStaticUrlsAllowed()
436436
return $this->scopeConfig->isSetFlag(
437437
self::CONFIG_USE_STATIC_URLS,
438438
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
439-
$this->_storeId
439+
(int) $this->_storeId
440440
);
441441
}
442442

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Magento\Store\Model\StoreManagerInterface;
2525
use Magento\Ui\Component\Form\Field;
2626
use Magento\Ui\DataProvider\EavValidationRules;
27+
use Magento\Ui\DataProvider\Modifier\PoolInterface;
2728

2829
/**
2930
* Class DataProvider
@@ -33,7 +34,7 @@
3334
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3435
* @since 101.0.0
3536
*/
36-
class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
37+
class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider
3738
{
3839
/**
3940
* @var string
@@ -160,6 +161,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
160161
* @param CategoryFactory $categoryFactory
161162
* @param array $meta
162163
* @param array $data
164+
* @param PoolInterface $pool
163165
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
164166
*/
165167
public function __construct(
@@ -174,7 +176,8 @@ public function __construct(
174176
\Magento\Framework\App\RequestInterface $request,
175177
CategoryFactory $categoryFactory,
176178
array $meta = [],
177-
array $data = []
179+
array $data = [],
180+
PoolInterface $pool = null
178181
) {
179182
$this->eavValidationRules = $eavValidationRules;
180183
$this->collection = $categoryCollectionFactory->create();
@@ -185,7 +188,7 @@ public function __construct(
185188
$this->request = $request;
186189
$this->categoryFactory = $categoryFactory;
187190

188-
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
191+
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
189192
}
190193

191194
/**
@@ -202,7 +205,7 @@ public function getMeta()
202205
if ($category) {
203206
$meta = $this->addUseDefaultValueCheckbox($category, $meta);
204207
}
205-
208+
// Default and custom settings
206209
return $meta;
207210
}
208211

@@ -305,6 +308,7 @@ public function getData()
305308

306309
$this->loadedData[$category->getId()] = $categoryData;
307310
}
311+
308312
return $this->loadedData;
309313
}
310314

app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Registry;
1717
use Magento\Store\Model\StoreManagerInterface;
1818
use Magento\Ui\DataProvider\EavValidationRules;
19+
use Magento\Ui\DataProvider\Modifier\PoolInterface;
1920

2021
/**
2122
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -72,6 +73,11 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
7273
*/
7374
private $fileInfo;
7475

76+
/**
77+
* @var PoolInterface|\PHPUnit_Framework_MockObject_MockObject
78+
*/
79+
private $modifierPool;
80+
7581
protected function setUp()
7682
{
7783
$this->eavValidationRules = $this->getMockBuilder(EavValidationRules::class)
@@ -120,6 +126,8 @@ protected function setUp()
120126
$this->fileInfo = $this->getMockBuilder(FileInfo::class)
121127
->disableOriginalConstructor()
122128
->getMock();
129+
130+
$this->modifierPool = $this->getMockBuilder(PoolInterface::class)->getMockForAbstractClass();
123131
}
124132

125133
/**
@@ -137,6 +145,8 @@ private function getModel()
137145
->willReturn($this->eavEntityMock);
138146

139147
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
148+
149+
/** @var DataProvider $model */
140150
$model = $objectManager->getObject(
141151
DataProvider::class,
142152
[
@@ -147,6 +157,7 @@ private function getModel()
147157
'eavConfig' => $this->eavConfig,
148158
'request' => $this->request,
149159
'categoryFactory' => $this->categoryFactory,
160+
'pool' => $this->modifierPool
150161
]
151162
);
152163

@@ -336,6 +347,10 @@ public function testGetMetaWithoutParentInheritanceResolving()
336347
$categoryMock->expects($this->never())
337348
->method('getParentId');
338349

350+
$this->modifierPool->expects($this->once())
351+
->method('getModifiersInstances')
352+
->willReturn([]);
353+
339354
$this->getModel()->getMeta();
340355
}
341356
}

app/code/Magento/Catalog/Ui/Component/Category/Form/Element/Wysiwyg.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -63,43 +63,5 @@ public function __construct(
6363

6464
$config['wysiwyg'] = (bool)$attrRepository->get($data['name'])->getIsWysiwygEnabled();
6565
parent::__construct($context, $formFactory, $wysiwygConfig, $components, $data, $config);
66-
$this->setData($this->prepareData($this->getData()));
67-
}
68-
69-
/**
70-
* Prepare wysiwyg content
71-
*
72-
* @param array $data
73-
* @return array
74-
*/
75-
private function prepareData($data)
76-
{
77-
if ($this->editor->isEnabled()) {
78-
$data['config']['content'] .= $this->getWysiwygButtonHtml();
79-
}
80-
return $data;
81-
}
82-
83-
/**
84-
* Return wysiwyg button html
85-
*
86-
* @return string
87-
*/
88-
private function getWysiwygButtonHtml()
89-
{
90-
return $this->layout->createBlock(
91-
Button::class,
92-
'',
93-
[
94-
'data' => [
95-
'label' => __('WYSIWYG Editor'),
96-
'type' => 'button',
97-
'class' => 'action-wysiwyg',
98-
'onclick' => 'catalogWysiwygEditor.open(\'' . $this->backendHelper->getUrl(
99-
'catalog/product/wysiwyg'
100-
) . '\', \'' . $this->editor->getHtmlId() . '\')',
101-
]
102-
]
103-
)->toHtml();
10466
}
10567
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Ui\DataProvider\Category\Form\Modifier;
7+
8+
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
9+
10+
class WysiwygConfigModifier implements ModifierInterface
11+
{
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
public function modifyData(array $data)
16+
{
17+
return $data;
18+
}
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
public function modifyMeta(array $meta)
24+
{
25+
$settings = [
26+
'height' => '100px',
27+
'add_variables' => false,
28+
'add_widgets' => false,
29+
'add_images' => true,
30+
'add_directives' => true
31+
];
32+
33+
$meta['content']['children']['description']['arguments']['data']['config']['wysiwygConfigData']
34+
= $settings;
35+
36+
return $meta;
37+
}
38+
}

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@
184184
<argument name="scopeOverriddenValue" xsi:type="object">Magento\Catalog\Model\Attribute\ScopeOverriddenValue</argument>
185185
</arguments>
186186
</type>
187+
<virtualType name="UiModifierPool" type="Magento\Ui\DataProvider\Modifier\Pool">
188+
<arguments>
189+
<argument name="modifiers" xsi:type="array">
190+
<item name="wysiwyg-category" xsi:type="array">
191+
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Category\Form\Modifier\WysiwygConfigModifier</item>
192+
<item name="sortOrder" xsi:type="number">10</item>
193+
</item>
194+
</argument>
195+
</arguments>
196+
</virtualType>
197+
<type name="Magento\Catalog\Model\Category\DataProvider">
198+
<arguments>
199+
<argument name="pool" xsi:type="object">UiModifierPool</argument>
200+
</arguments>
201+
</type>
187202
<type name="Magento\Eav\Api\AttributeSetRepositoryInterface">
188203
<plugin name="remove_products" type="Magento\Catalog\Plugin\Model\AttributeSetRepository\RemoveProducts"/>
189204
</type>

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,27 +177,6 @@
177177
</formElements>
178178
</field>
179179
<field name="description" template="ui/form/field" sortOrder="50" formElement="wysiwyg">
180-
<argument name="data" xsi:type="array">
181-
<item name="config" xsi:type="array">
182-
<item name="wysiwygConfigData" xsi:type="array">
183-
<item name="settings" xsi:type="array">
184-
<item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code</item>
185-
<item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
186-
<item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
187-
<item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
188-
<item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
189-
</item>
190-
<item name="files_browser_window_url" xsi:type="boolean">false</item>
191-
<item name="height" xsi:type="string">100px</item>
192-
<item name="toggle_button" xsi:type="boolean">false</item>
193-
<item name="add_variables" xsi:type="boolean">false</item>
194-
<item name="add_widgets" xsi:type="boolean">false</item>
195-
<item name="add_images" xsi:type="boolean">false</item>
196-
<item name="add_directives" xsi:type="boolean">true</item>
197-
</item>
198-
<item name="source" xsi:type="string">category</item>
199-
</item>
200-
</argument>
201180
<settings>
202181
<label translate="true">Description</label>
203182
<dataScope>description</dataScope>

app/code/Magento/Catalog/view/adminhtml/web/js/edit-tree.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
require([
1010
'jquery',
11-
'tinymce',
1211
'Magento_Ui/js/modal/confirm',
1312
'Magento_Ui/js/modal/alert',
1413
'loadingPopup',
1514
'mage/backend/floating-header'
16-
], function (jQuery, tinyMCE, confirm) {
15+
], function (jQuery, confirm) {
1716
'use strict';
1817

1918
/**

0 commit comments

Comments
 (0)