From 687bc83446dea39f24f91abb6fcac045ff634a11 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 20 Jun 2021 17:16:24 -0700 Subject: [PATCH] crmMonaco - Provide internal access to `$ctrl.editor` / `crmMonaco.editor` instances --- ang/crmMonaco.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ang/crmMonaco.js b/ang/crmMonaco.js index 156753a0b7..d232391578 100644 --- a/ang/crmMonaco.js +++ b/ang/crmMonaco.js @@ -7,9 +7,13 @@ angular.module('crmMonaco').directive('crmMonaco', function($timeout, $parse) { return { restrict: 'AE', - require: 'ngModel', + require: ['ngModel', 'crmMonaco'], template: '
', - link: function($scope, $el, $attr, ngModel) { + controller: function() { + this.editor = null; // Filled in by link(). + }, + link: function($scope, $el, $attr, controllers) { + var ngModel = controllers[0], crmMonaco = controllers[1]; var heightPct = 0.70; var editor; require.config({paths: CRM.crmMonaco.paths}); @@ -78,9 +82,12 @@ editor.onDidFocusEditorWidget(bodyScrollSuspend); editor.onDidBlurEditorWidget(bodyScrollRestore); + crmMonaco.editor = editor; + $scope.$on('$destroy', function () { bodyScrollRestore(); if (editor) editor.dispose(); + delete crmMonaco.editor; }); }); } -- 2.25.1