Skip to content

Commit c8a059d

Browse files
committed
MAGETWO-91496: Instantiating WYSIWYG in DynamicRows
- Add wysiwyg suffix to html and js
1 parent 752dae4 commit c8a059d

File tree

2 files changed

+24
-4
lines changed
  • app/code/Magento/Ui/view/base/web/js/form/element
  • lib/internal/Magento/Framework/Data/Form/Element

2 files changed

+24
-4
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define([
2020
return Abstract.extend({
2121
defaults: {
2222
elementSelector: 'textarea',
23+
suffixRegExpPattern: '\\${ \\$.wysiwygUniqueSuffix }',
2324
value: '',
2425
$wysiwygEditorButton: '',
2526
links: {
@@ -61,12 +62,23 @@ define([
6162
return this;
6263
},
6364

65+
/** @inheritdoc */
66+
initConfig: function (config) {
67+
var pattern = config.suffixRegExpPattern || this.constructor.defaults.suffixRegExpPattern;
68+
69+
config.content = config.content.replace(new RegExp(pattern, 'g'), this.getUniqueSuffix(config));
70+
this._super();
71+
72+
return this;
73+
},
74+
6475
/**
65-
* @inheritdoc
76+
* Build unique id based on name, underscore separated.
77+
*
78+
* @param {Object} config
6679
*/
67-
destroy: function () {
68-
this._super();
69-
wysiwyg.removeEvents(this.wysiwygId);
80+
getUniqueSuffix: function (config) {
81+
return config.name.replace(/(\.|-)/g, '_');
7082
},
7183

7284
/**

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,4 +542,12 @@ protected function getInlineJs($jsSetupObject, $forceLoad)
542542
</script>';
543543
return $jsString;
544544
}
545+
546+
/**
547+
* @inheritdoc
548+
*/
549+
public function getHtmlId()
550+
{
551+
return parent::getHtmlId() . '${ $.wysiwygUniqueSuffix }';
552+
}
545553
}

0 commit comments

Comments
 (0)