Skip to content

Commit 43eeaa5

Browse files
committed
MC-17823: Access Images/Widgets/Variable from HTML content type
- add translations - remove disable ESLint rules - improve method params
1 parent 9f1b6e2 commit 43eeaa5

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

app/code/Magento/PageBuilder/Component/Form/HtmlCode.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
class HtmlCode extends \Magento\Ui\Component\Form\Field
1919
{
20-
const HTML_ID = 'HTML_ID';
20+
const HTML_ID_PLACEHOLDER = 'HTML_ID_PLACEHOLDER';
2121

2222
/**
2323
* @var BackendUrlInterface
@@ -75,15 +75,19 @@ public function __construct(
7575
public function prepare()
7676
{
7777
$config = $this->getData('config');
78-
$config['widgetUrl'] = $this->backendUrl->getUrl('adminhtml/widget/index')
79-
. 'widget_target_id/' . self::HTML_ID . '/';
80-
81-
$fileBrowserUrlParams = [
82-
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
83-
];
84-
85-
$config['imageUrl'] = $this->backendUrl->getUrl('cms/wysiwyg_images/index', $fileBrowserUrlParams)
86-
. 'target_element_id/' . self::HTML_ID . '/';
78+
$config['widgetUrl'] = $this->backendUrl->getUrl(
79+
'adminhtml/widget/index',
80+
[
81+
'widget_target_id' => self::HTML_ID_PLACEHOLDER
82+
]
83+
);
84+
$config['imageUrl'] = $this->backendUrl->getUrl(
85+
'cms/wysiwyg_images/index',
86+
[
87+
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
88+
'target_element_id' => self::HTML_ID_PLACEHOLDER
89+
]
90+
);
8791
$config['variableUrl'] = $this->variableConfig->getVariablesWysiwygActionUrl();
8892
$this->setData('config', $config);
8993
parent::prepare();

app/code/Magento/PageBuilder/i18n/en_US.csv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,7 @@ OK,OK
290290
"We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field.","We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field."
291291
"Nested links are not allowed","Nested links are not allowed"
292292
"Close Full Screen","Close Full Screen"
293-
"Open in Full Screen","Open in Full Screen"
293+
"Open in Full Screen","Open in Full Screen"
294+
"Insert Widget...","Insert Widget..."
295+
"Insert Image...","Insert Image..."
296+
"Insert Variable...","Insert Variable..."

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/html-code.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
/*eslint-disable vars-on-top, strict */
7-
86
define([
97
'Magento_Ui/js/form/element/textarea',
10-
'mage/adminhtml/wysiwyg/widget',
8+
'mage/adminhtml/wysiwyg/widget'
119
], function (Textarea) {
1210
'use strict';
1311

12+
const HTML_ID_PLACEHOLDER = 'HTML_ID_PLACEHOLDER';
13+
1414
return Textarea.extend({
1515
defaults: {
16-
elementTmpl: 'Magento_PageBuilder/form/element/html-code',
17-
htmlId: 'HTML_ID'
16+
elementTmpl: 'Magento_PageBuilder/form/element/html-code'
1817
},
1918

2019
/**
2120
* Click event for Insert Widget Button
2221
*/
2322
clickInsertWidget: function () {
2423
return widgetTools.openDialog(
25-
this.widgetUrl.replace(this.htmlId, this.uid)
24+
this.widgetUrl.replace(HTML_ID_PLACEHOLDER, this.uid)
2625
);
2726
},
2827

@@ -31,7 +30,7 @@ define([
3130
*/
3231
clickInsertImage: function () {
3332
return MediabrowserUtility.openDialog(
34-
this.imageUrl.replace(this.htmlId, this.uid)
33+
this.imageUrl.replace(HTML_ID_PLACEHOLDER, this.uid)
3534
);
3635
},
3736

@@ -40,7 +39,8 @@ define([
4039
*/
4140
clickInsertVariable: function () {
4241
return MagentovariablePlugin.loadChooser(
43-
this.variableUrl, this.uid
42+
this.variableUrl,
43+
this.uid
4444
);
4545
},
4646
});

app/code/Magento/PageBuilder/view/adminhtml/web/template/form/element/html-code.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
click="clickInsertWidget">
1313
<span>
1414
<span>
15-
<span>Insert Widget...</span>
15+
<span translate="'Insert Widget...'"/>
1616
</span>
1717
</span>
1818
</button>
@@ -21,7 +21,7 @@
2121
click="clickInsertImage">
2222
<span>
2323
<span>
24-
<span>Insert Image...</span>
24+
<span translate="'Insert Image...'"/>
2525
</span>
2626
</span>
2727
</button>
@@ -30,7 +30,7 @@
3030
click="clickInsertVariable">
3131
<span>
3232
<span>
33-
<span>Insert Variable...</span>
33+
<span translate="'Insert Variable...'"/>
3434
</span>
3535
</span>
3636
</button>

0 commit comments

Comments
 (0)