// afterCommandExec, afterInsertHtml, afterPaste, afterSetData, change, insertElement,
// insertHtml, insertText, pasteState. It seems that 'pasteState' is the general equivalent of
// what 'change' should be, except (in the case of image insertion) it fires too soon.
- ck.on('pasteState', function(evt) {
- $timeout(function() {
- ngModel.$setViewValue(ck.getData());
- }, 50);
+ // The 'key' event is needed to detect changes in "Source" mode.
+ var debounce = null;
+ angular.forEach(['key', 'pasteState'], function(evName){
+ ck.on(evName, function(evt) {
+ $timeout.cancel(debounce);
+ debounce = $timeout(function() {
+ ngModel.$setViewValue(ck.getData());
+ }, 50);
+ });
});
ngModel.$render = function (value) {