Skip to content

Commit a607761

Browse files
committed
Merge pull request #106 from dedycds/master
Give ability to pass options when editor instantiated manually
2 parents b083a19 + 2023359 commit a607761

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/angular-froala.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ value('froalaConfig', {})
5555
};
5656
};
5757

58-
ctrl.createEditor = function () {
58+
ctrl.createEditor = function (froalaInitOptions) {
5959
ctrl.listeningEvents = ['froalaEditor'];
6060
if (!ctrl.editorInitialized) {
61-
ctrl.options = angular.extend({}, defaultConfig, froalaConfig, scope.froalaOptions);
61+
froalaInitOptions = (froalaInitOptions || {});
62+
ctrl.options = angular.extend({}, defaultConfig, froalaConfig, scope.froalaOptions,froalaInitOptions);
6263

6364
if (ctrl.options.immediateAngularModelUpdate) {
6465
ctrl.listeningEvents.push('keyup');

test/angular-froala.spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,21 @@ describe("froala", function () {
297297

298298
});
299299

300-
it('Sets the view to the value of the model', function () {
300+
it('Sets the view to the value of the model', function () {
301301
$rootScope.content = '<i>New Text</i>';
302302

303303
compileViewElement();
304304
$rootScope.$digest();
305305

306306
expect(view.html()).toEqual("<i>New Text</i>");
307-
});
307+
});
308+
309+
it('Sets options when the editor is instantiated manually', function () {
310+
createEditorInManualMode();
311+
312+
$rootScope.initControls.initialize({initOnClick: false});
313+
314+
expect(froalaEditorStub.called).toBeTruthy();
315+
expect(froalaEditorStub.args[0][0].initOnClick).toBeFalsy();
316+
});
308317
});

0 commit comments

Comments
 (0)