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

Commit 959258d

Browse files
committed
Updated to use new tinymce event api
1 parent 4a10f6b commit 959258d

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

src/tinymce.js

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,27 @@ angular.module('ui.tinymce', [])
1515
attrs.$set('id', 'uiTinymce' + generatedIds++);
1616
}
1717
options = {
18-
// Update model on button click
19-
onchange_callback: function (inst) {
20-
if (inst.isDirty()) {
21-
inst.save();
18+
// Update model when calling setContent (such as from the source editor popup)
19+
setup: function (ed) {
20+
ed.on('init', function(args) {
21+
ngModel.$render();
22+
});
23+
// Update model on button click
24+
ed.on('ExecCommand', function (e) {
25+
ed.save();
2226
ngModel.$setViewValue(elm.val());
2327
if (!scope.$$phase) {
2428
scope.$apply();
2529
}
26-
}
27-
},
28-
// Update model on keypress
29-
handle_event_callback: function (e) {
30-
if (this.isDirty()) {
31-
this.save();
30+
});
31+
// Update model on keypress
32+
ed.on('KeyUp', function (e) {
33+
console.log(ed.isDirty());
34+
ed.save();
3235
ngModel.$setViewValue(elm.val());
3336
if (!scope.$$phase) {
3437
scope.$apply();
3538
}
36-
}
37-
return true; // Continue handling
38-
},
39-
// Update model when calling setContent (such as from the source editor popup)
40-
setup: function (ed) {
41-
ed.on('init', function(args) {
42-
ngModel.$render();
43-
});
44-
ed.on('change', function (e) {
45-
if (ed.isDirty()) {
46-
ed.save();
47-
ngModel.$setViewValue(elm.val());
48-
if (!scope.$$phase) {
49-
scope.$apply();
50-
}
51-
}
5239
});
5340
},
5441
mode: 'exact',

0 commit comments

Comments
 (0)