From 4a5c27e3755f4276c298c4aab123eb32f9da3f18 Mon Sep 17 00:00:00 2001 From: Yves Riel Date: Fri, 13 May 2016 10:41:23 -0400 Subject: [PATCH 1/2] Fixed tests broken by commit: https://github.com/froala/angular-froala/commit/d4d5db8988b88b3bb785e6938f912042c41c3120 --- test/angular-froala.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/angular-froala.spec.js b/test/angular-froala.spec.js index c88daa6..49b1a92 100644 --- a/test/angular-froala.spec.js +++ b/test/angular-froala.spec.js @@ -150,6 +150,7 @@ describe("froala", function () { }); froalaEditorOnStub.callArgOn(1); + $rootScope.$digest(); expect($rootScope.content).toEqual('My String'); }); @@ -160,6 +161,7 @@ describe("froala", function () { }); element.trigger('froalaEditor.contentChanged'); + $rootScope.$digest(); expect($rootScope.content).toEqual('My String'); }); From eccca4f56e29bea2028528f067350cd15ee66cf5 Mon Sep 17 00:00:00 2001 From: Yves Riel Date: Fri, 13 May 2016 11:22:30 -0400 Subject: [PATCH 2/2] Fixed failure on undo.reset (https://github.com/froala/angular-froala/issues/92#issuecomment-219026602) when initOnClick option is used. --- src/angular-froala.js | 16 +++++++++++++--- test/angular-froala.spec.js | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/angular-froala.js b/src/angular-froala.js index 9ecbd75..e8f5f09 100644 --- a/src/angular-froala.js +++ b/src/angular-froala.js @@ -43,8 +43,10 @@ value('froalaConfig', {}) ngModel.$render = function () { element.froalaEditor('html.set', ngModel.$viewValue || '', true); //This will reset the undo stack everytime the model changes externally. Can we fix this? - element.froalaEditor('undo.reset'); - element.froalaEditor('undo.saveStep'); + if (ctrl.editorInitialized) { + element.froalaEditor('undo.reset'); + element.froalaEditor('undo.saveStep'); + } }; ngModel.$isEmpty = function (value) { @@ -79,8 +81,16 @@ value('froalaConfig', {}) scope.froalaOptions.froalaEditor = ctrl.froalaEditor; } - ctrl.editorInitialized = ctrl.froalaEditor ? true : false; + if (ctrl.options.initOnClick) { + ctrl.registerEventsWithCallbacks('froalaEditor.initialized', function() { + ctrl.editorInitialized = true; + }); + } else { + ctrl.editorInitialized = ctrl.froalaEditor ? true : false; + } } + + }; ctrl.initListeners = function () { diff --git a/test/angular-froala.spec.js b/test/angular-froala.spec.js index 49b1a92..f92f134 100644 --- a/test/angular-froala.spec.js +++ b/test/angular-froala.spec.js @@ -56,7 +56,7 @@ describe("froala", function () { if (scope.froalaOptions === undefined) { scope.froalaOptions = {}; } - scope.froalaOptions.initOnClick = true; + scope.froalaOptions.disableRightClick = true; scope.content = ''; }; @@ -88,7 +88,7 @@ describe("froala", function () { compileElement(); expect(froalaEditorStub.args[0][0].placeholderText).toEqual('Placeholder'); - expect(froalaEditorStub.args[0][0].initOnClick).toBeTruthy(); + expect(froalaEditorStub.args[0][0].disableRightClick).toBeTruthy(); }); it('Uses default option values when no options are provided', function () {