diff --git a/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js b/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js index 3a44d382f..b4099b3b7 100644 --- a/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js +++ b/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js @@ -288,9 +288,9 @@ angular.module('clipboard').directive('guacClipboard', ['$injector', }; // Attempt to read the clipboard if it may have changed - $window.addEventListener('copy', checkClipboard, true); - $window.addEventListener('cut', checkClipboard, true); - $window.addEventListener('focus', checkClipboard, true); + $window.addEventListener('copy', checkClipboard); + $window.addEventListener('cut', checkClipboard); + $window.addEventListener('focus', checkClipboard); // Clean up on destruction $scope.$on('$destroy', function destroyClipboard() { diff --git a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js index 0dc2b7aa3..d15781672 100644 --- a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js +++ b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js @@ -54,6 +54,22 @@ angular.module('clipboard').factory('clipboardService', ['$injector', // Add clipboard target to DOM document.body.appendChild(clipboardContent); + /** + * Stops the propogation of the given event through the DOM tree. This is + * identical to invoking stopPropogation() on the event directly, except + * that this function is usable as an event handler itself. + * + * @param {Event} e + * The event whose propogation through the DOM tree should be stopped. + */ + var stopEventPropagation = function stopEventPropagation(e) { + e.stopPropagation(); + }; + + // Prevent events generated due to execCommand() from disturbing external things + clipboardContent.addEventListener('copy', stopEventPropagation); + clipboardContent.addEventListener('paste', stopEventPropagation); + /** * A stack of past node selection ranges. A range convering the nodes * currently selected within the document can be pushed onto this stack