From e9bfb31494995801cc2d02b089b47f79bba2d023 Mon Sep 17 00:00:00 2001 From: Fredrik Holm Date: Tue, 14 Mar 2017 21:46:58 +0100 Subject: [PATCH 1/3] Add basePath option in a non-breaking way --- src/ui-ace.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index a664fb1..96f293b 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -30,12 +30,16 @@ angular.module('ui.ace', []) */ var setOptions = function(acee, session, opts) { - // sets the ace worker path, if running from concatenated - // or minified source + // sets the ace base and/or worker path, + // if running from concatenated or minified source + var config = window.ace.require('ace/config'); + if (angular.isDefined(opts.basePath)) { + config.set('basePath', opts.basePath); + } if (angular.isDefined(opts.workerPath)) { - var config = window.ace.require('ace/config'); config.set('workerPath', opts.workerPath); } + // ace requires loading if (angular.isDefined(opts.require)) { opts.require.forEach(function (n) { From 4893467371a52ef2c65cf1b3900c78daa63eae7c Mon Sep 17 00:00:00 2001 From: Fredrik Holm Date: Tue, 14 Mar 2017 22:38:17 +0100 Subject: [PATCH 2/3] Add info about basePath to the readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 17e3553..9d24ef6 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,14 @@ This should be the folder on disk where `ace.js` resides. workerPath: '/path/to/ace/folder' }"> ``` +You could also set the `basePath` option, which will force ace to look for all workers and themes in the folder you specify. + +```html +
+``` +Please note that ace requests workers and themes dynamically, so bundling them and referencing the bundle using `basePath` doesn't work. ### Working with ng-model From 235efeaf6808222650d7c833ca8cbb5214a198df Mon Sep 17 00:00:00 2001 From: Fredrik Holm Date: Wed, 15 Mar 2017 16:55:11 +0100 Subject: [PATCH 3/3] Check if options are used before using config --- src/ui-ace.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index 96f293b..e7e4164 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -32,14 +32,15 @@ angular.module('ui.ace', []) // sets the ace base and/or worker path, // if running from concatenated or minified source - var config = window.ace.require('ace/config'); - if (angular.isDefined(opts.basePath)) { - config.set('basePath', opts.basePath); - } - if (angular.isDefined(opts.workerPath)) { - config.set('workerPath', opts.workerPath); + if (angular.isDefined(opts.workerPath) || angular.isDefined(opts.basePath)) { + var config = window.ace.require('ace/config'); + if (angular.isDefined(opts.basePath)) { + config.set('basePath', opts.basePath); + } + if (angular.isDefined(opts.workerPath)) { + config.set('workerPath', opts.workerPath); + } } - // ace requires loading if (angular.isDefined(opts.require)) { opts.require.forEach(function (n) {