CRM-16445 - crmUiRichtext - Fix image insertion. Wait 50ms.
authorTim Otten <totten@civicrm.org>
Mon, 18 May 2015 21:28:56 +0000 (14:28 -0700)
committerTim Otten <totten@civicrm.org>
Mon, 18 May 2015 21:38:05 +0000 (14:38 -0700)
ang/crmUi.js

index 312e921cdd9ddd811762aa35ffd9cdc1dffa6b51..0c571c691dc3fc17738fffa90ee95f1a3756787b 100644 (file)
             });
           }
 
-          ck.on('pasteState', function () {
-            scope.$apply(function () {
+          // CRM-16445 - When one inserts an image, none of these events seem to fire at the right time:
+          // 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());
-            });
-          });
-
-          ck.on('insertText', function () {
-            $timeout(function () {
-              ngModel.$setViewValue(ck.getData());
-            });
+            }, 50);
           });
 
           ngModel.$render = function (value) {