Skip to content

Commit

Permalink
fix: prevent from pasting image twice in pasteimage plugin
Browse files Browse the repository at this point in the history
fix #628
  • Loading branch information
Alex-D committed Apr 30, 2019
1 parent 45b2576 commit 12f830b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/pasteimage/trumbowyg.pasteimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
trumbowyg.pasteHandlers.push(function (pasteEvent) {
try {
var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items,
mustPreventDefault = false,
reader;

for (var i = items.length - 1; i >= 0; i -= 1) {
Expand All @@ -29,8 +30,15 @@
};
/* jshint +W083 */
reader.readAsDataURL(items[i].getAsFile());

mustPreventDefault = true;
}
}

if (mustPreventDefault) {
pasteEvent.stopPropagation();
pasteEvent.preventDefault();
}
} catch (c) {
}
});
Expand Down

0 comments on commit 12f830b

Please sign in to comment.