Skip to content

Commit

Permalink
Option to specify textarea ID. Trigger change on editor value changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tangar76 committed Nov 11, 2019
1 parent 08a65bb commit bfd5e52
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion view/adminhtml/web/js/form/element/editor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define([
'jquery',
'underscore',
'Magento_Ui/js/form/element/textarea',
'../../codemirror/lib/codemirror',
Expand All @@ -11,7 +12,7 @@ define([
'../../codemirror/addon/edit/closetag',
'../../codemirror/addon/edit/matchbrackets',
'../../codemirror/addon/edit/matchtags'
], function (_, Textarea, CodeMirror) {
], function ($, _, Textarea, CodeMirror) {
'use strict';

function loadCss(url) {
Expand Down Expand Up @@ -73,6 +74,8 @@ define([
*/
listenEditorChanges: function (editor) {
this.value(editor.getValue());
// Force update in other binded KO veiw models.
$(this.editor.getTextArea()).trigger('change');
},

/**
Expand All @@ -84,6 +87,24 @@ define([
) {
this.editor.setValue(newValue);
}
},

/**
* {@inheritdoc}
*/
initConfig: function () {
this._super();

// Force uid when input id is set in element config.
if (this.inputId) {
_.extend(this, {
uid: this.inputId,
noticeId: 'notice-' + this.inputId,
errorId: 'error-' + this.inputId
});
}

return this;
}
});
});

0 comments on commit bfd5e52

Please sign in to comment.