Skip to content

Commit b2d1b7a

Browse files
Merge branch 'v.3' into version3
2 parents 0a8a57c + a7ca071 commit b2d1b7a

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-froala",
3-
"version": "2.9.2",
3+
"version": "2.9.3",
44
"authors": [
55
"Cameron Gallarno <cgallarno@gmail.com>"
66
],
@@ -29,7 +29,7 @@
2929
"tests"
3030
],
3131
"dependencies": {
32-
"froala-wysiwyg-editor": "2.9.2",
32+
"froala-wysiwyg-editor": "2.9.3",
3333
"angular": ">=1.0"
3434
},
3535
"devDependencies": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-froala",
3-
"version": "2.9.2",
3+
"version": "2.9.3",
44
"description": "Angular.js bindings for Froala WYSIWYG HTML rich text editor",
55
"main": "src/angular-froala.js",
66
"scripts": {
@@ -51,6 +51,6 @@
5151
},
5252
"dependencies": {
5353
"coffee-script": "^1.12.7",
54-
"froala-editor": "2.9.2"
54+
"froala-editor": "2.9.3"
5555
}
5656
}

src/angular-froala.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@
8282
else {
8383
if (ctrl.editorInitialized) {
8484
// Set HTML.
85-
element.froalaEditor('html.set', ngModel.$viewValue || '', true);
86-
85+
element.froalaEditor.html.set(ngModel.$viewValue || '')
8786
//This will reset the undo stack everytime the model changes externally. Can we fix this?
88-
element.froalaEditor('undo.reset');
89-
element.froalaEditor('undo.saveStep');
87+
element.froalaEditor.undo.reset();
88+
element.froalaEditor.undo.saveStep();
9089
}
9190
}
9291
};
@@ -97,7 +96,7 @@
9796
}
9897

9998
if (ctrl.editorInitialized) {
100-
return element.froalaEditor('node.isEmpty', jQuery('<div>' + value + '</div>').get(0));
99+
return element.froalaEditor.node.isEmpty(jQuery('<div>' + value + '</div>')).get(0);
101100
}
102101

103102
return true;
@@ -110,11 +109,11 @@
110109
froalaInitOptions = (froalaInitOptions || {});
111110
ctrl.options = angular.extend({}, defaultConfig, froalaConfig, scope.froalaOptions, froalaInitOptions);
112111

113-
ctrl.registerEventsWithCallbacks('froalaEditor.initializationDelayed', function() {
112+
ctrl.registerEventsWithCallbacks('initializationDelayed', function() {
114113
ngModel.$render()
115114
});
116115

117-
ctrl.registerEventsWithCallbacks('froalaEditor.initialized', function () {
116+
ctrl.registerEventsWithCallbacks('initialized', function () {
118117
ctrl.editorInitialized = true;
119118
ngModel.$render()
120119
})
@@ -127,10 +126,9 @@
127126
}
128127
}
129128

130-
element.innerHTML =
131-
ctrl.froalaElement = element.froalaEditor(ctrl.options).data('froala.editor').$el;
132-
ctrl.froalaEditor = angular.bind(element, element.froalaEditor);
133-
ctrl.initListeners();
129+
ctrl.froalaEditor = element.froalaEditor = new FroalaEditor('#'+element.attr('id'),ctrl.options);
130+
element.innerHTML = ctrl.froalaElement = ctrl.froalaEditor.$el[0];
131+
ctrl.initListeners();
134132

135133
//assign the froala instance to the options object to make methods available in parent scope
136134
if (scope.froalaOptions) {
@@ -141,24 +139,27 @@
141139

142140
ctrl.initListeners = function() {
143141
if (ctrl.options.immediateAngularModelUpdate) {
144-
ctrl.froalaElement.on('froalaEditor.keyup', function() {
142+
ctrl.registerEventsWithCallbacks('keyup', function() {
145143
scope.$evalAsync(ctrl.updateModelView);
146144
});
147145
}
148146

149-
element.on('froalaEditor.contentChanged', function() {
147+
ctrl.registerEventsWithCallbacks('contentChanged', function() {
150148
scope.$evalAsync(ctrl.updateModelView);
151149
});
152150

153151
element.bind('$destroy', function() {
154152
if (element) {
155-
element.froalaEditor('destroy');
153+
element.froalaEditor.destroy();
156154
element = null;
157155
}
158156
});
159157
};
160158

161159
ctrl.updateModelView = function() {
160+
if (!element) {
161+
return;
162+
}
162163

163164
var modelContent = null;
164165

@@ -178,7 +179,7 @@
178179
}
179180
modelContent = attrs;
180181
} else {
181-
var returnedHtml = element.froalaEditor('html.get');
182+
var returnedHtml = element.froalaEditor.html.get();
182183
if (angular.isString(returnedHtml)) {
183184
modelContent = returnedHtml;
184185
}
@@ -193,7 +194,10 @@
193194
ctrl.registerEventsWithCallbacks = function(eventName, callback) {
194195
if (eventName && callback) {
195196
ctrl.listeningEvents.push(eventName);
196-
element.on(eventName, callback);
197+
if(!ctrl.options.events){
198+
ctrl.options.events = {};
199+
}
200+
ctrl.options.events[eventName] = callback;
197201
}
198202
};
199203

@@ -203,7 +207,7 @@
203207
initialize: ctrl.createEditor,
204208
destroy: function() {
205209
if (_ctrl.froalaEditor) {
206-
_ctrl.froalaEditor('destroy');
210+
_ctrl.froalaEditor.destroy();
207211
_ctrl.editorInitialized = false;
208212
}
209213
},
@@ -234,4 +238,4 @@
234238
}
235239
};
236240
}]);
237-
})(window, window.angular, window.jQuery);
241+
})(window, window.angular, window.jQuery);

0 commit comments

Comments
 (0)