From f12916142336f56d92371f35cecdc30b6aeedf8b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 25 Nov 2020 01:02:05 -0800 Subject: [PATCH] crmMonaco - Accept pass-thru arguments to Monaco --- ang/crmMonaco.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ang/crmMonaco.js b/ang/crmMonaco.js index 58eee405e4..15ff3747d4 100644 --- a/ang/crmMonaco.js +++ b/ang/crmMonaco.js @@ -3,7 +3,8 @@ // "crmMonaco" is a basic skeletal directive. // Example usage:
- angular.module('crmMonaco').directive('crmMonaco', function($timeout) { + // Example usage:
+ angular.module('crmMonaco').directive('crmMonaco', function($timeout, $parse) { return { restrict: 'AE', require: 'ngModel', @@ -13,13 +14,17 @@ var editor; require.config({paths: CRM.crmMonaco.paths}); require(['vs/editor/editor.main'], function() { - var editorEl = $el.find('.crm-monaco-container'); - editorEl.css({height: Math.round(heightPct * $(window).height())}); - editor = monaco.editor.create(editorEl[0], { - value: ngModel.$modelValue, + var options = { + readOnly: false, language: 'html', // theme: 'vs-dark', - theme: 'vs', + theme: 'vs' + }; + if ($attr.crmMonaco) { + angular.extend(options, $parse($attr.crmMonaco)($scope)); + } + angular.extend(options, { + value: ngModel.$modelValue, minimap: { enabled: false }, @@ -36,6 +41,10 @@ } }); + var editorEl = $el.find('.crm-monaco-container'); + editorEl.css({height: Math.round(heightPct * $(window).height())}); + editor = monaco.editor.create(editorEl[0], options); + editor.onDidChangeModelContent(_.debounce(function () { $scope.$apply(function () { ngModel.$setViewValue(editor.getValue()); -- 2.25.1