Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit b0f02ce

Browse files
committed
Merge branch 'danfinnie-master'
2 parents c7953e7 + 8cc7e03 commit b0f02ce

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ This will copy the UI.Ace files into a `bower_components` folder, along with its
112112
}"></div>
113113
```
114114

115+
To include options applicable to the ACE renderer, you can use the `rendererOptions` key:
116+
117+
```html
118+
<div ui-ace="{
119+
rendererOptions: {
120+
maxLinks: Infinity
121+
}
122+
}"></div>
123+
```
124+
115125
## Support for concatenated bundles
116126

117127
Trying to use ace with concatenated javascript files usually fails because it changes the physical location of the `workerPath`. If you

src/ui-ace.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,25 @@ angular.module('ui.ace', [])
9898
}
9999

100100
// advanced options
101+
var key, obj;
101102
if (angular.isDefined(opts.advanced)) {
102-
for (var key in opts.advanced) {
103+
for (key in opts.advanced) {
103104
// create a javascript object with the key and value
104-
var obj = { name: key, value: opts.advanced[key] };
105+
obj = { name: key, value: opts.advanced[key] };
105106
// try to assign the option to the ace editor
106107
acee.setOption(obj.name, obj.value);
107108
}
108109
}
110+
111+
// advanced options for the renderer
112+
if (angular.isDefined(opts.rendererOptions)) {
113+
for (key in opts.rendererOptions) {
114+
// create a javascript object with the key and value
115+
obj = { name: key, value: opts.rendererOptions[key] };
116+
// try to assign the option to the ace editor
117+
acee.renderer.setOption(obj.name, obj.value);
118+
}
119+
}
109120
};
110121

111122
return {

test/ace.spec.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ describe('uiAce', function () {
8080
_ace.setOption = jasmine
8181
.createSpy('ace.setOption')
8282
.and.callThrough();
83+
_ace.renderer.setOption = jasmine
84+
.createSpy('ace.setOption')
85+
.and.callThrough();
8386
return _ace;
8487
});
8588
});
@@ -88,16 +91,23 @@ describe('uiAce', function () {
8891
window.ace.edit = aceEditFunction;
8992
});
9093

91-
it('Given advanced option is null if not defined.', function () {
94+
it('should not trigger ace#setOption.', function () {
9295
$compile('<div ui-ace>')(scope);
9396
expect(_ace.setOption.calls.count()).toEqual(0);
9497
});
9598

96-
it('given advanced options are properly defined.', function () {
97-
$compile('<div ui-ace=\'{ advanced: { enableSnippets: true } }\'>')(scope);
99+
it('should trigger ace#setOption with "advanced" options.', function () {
100+
$compile('<div ui-ace=\'{ advanced: { enableSnippets: true } }\'>')(scope);
98101
expect(_ace.setOption.calls.count()).toEqual(1);
99102
expect(_ace.setOption).toHaveBeenCalledWith('enableSnippets', true);
100103
});
104+
105+
it('should trigger renderer#setOption with "rendererOptions" options.', function () {
106+
$compile('<div ui-ace=\'{ rendererOptions: { maxLines: 42 } }\'>')(scope);
107+
expect(_ace.renderer.setOption.calls.count()).toEqual(2);
108+
expect(_ace.renderer.setOption).toHaveBeenCalledWith('showGutter', false);
109+
expect(_ace.renderer.setOption).toHaveBeenCalledWith('maxLines', 42);
110+
});
101111
});
102112

103113
describe('basic behavior', function () {

0 commit comments

Comments
 (0)