mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
* refactor(code-editor): introduce code-editor component * refactor(code-editor): add some extra validation
20 lines
629 B
JavaScript
20 lines
629 B
JavaScript
angular.module('portainer.app')
|
|
.controller('CodeEditorController', ['$document', 'CodeMirrorService',
|
|
function ($document, CodeMirrorService) {
|
|
var ctrl = this;
|
|
|
|
this.$onInit = function() {
|
|
$document.ready(function() {
|
|
var editorElement = $document[0].getElementById(ctrl.identifier);
|
|
if (editorElement) {
|
|
ctrl.editor = CodeMirrorService.applyCodeMirrorOnElement(editorElement, ctrl.yml, ctrl.readOnly);
|
|
if (ctrl.onChange) {
|
|
ctrl.editor.on('change', ctrl.onChange);
|
|
}
|
|
if (ctrl.value) {
|
|
ctrl.editor.setValue(ctrl.value);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
}]);
|