You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/09/04 00:43:45 UTC

[1/5] incubator-guacamole-client git commit: GUACAMOLE-310: Use input element select() function when available.

Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master 96e9318db -> ab88eb2ff


GUACAMOLE-310: Use input element select() function when available.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/7e0cdd2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/7e0cdd2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/7e0cdd2a

Branch: refs/heads/master
Commit: 7e0cdd2adf156b6aa15ddf96a7e78a41c8f47c9a
Parents: 47acaf5
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Sep 3 17:07:24 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Sep 3 17:08:34 2017 -0700

----------------------------------------------------------------------
 .../app/clipboard/services/clipboardService.js  | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/7e0cdd2a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
index 311dbc0..07091f3 100644
--- a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
+++ b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
@@ -135,14 +135,23 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
      */
     var selectAll = function selectAll(element) {
 
-        // Generate a range which selects all nodes within the given element
-        var range = document.createRange();
-        range.selectNodeContents(element);
+        // Use the select() function defined for input elements, if available
+        if (element.select)
+            element.select();
 
-        // Replace any current selection with the generated range
-        var selection = $window.getSelection();
-        selection.removeAllRanges();
-        selection.addRange(range);
+        // Fallback to manual manipulation of the selection
+        else {
+
+            // Generate a range which selects all nodes within the given element
+            var range = document.createRange();
+            range.selectNodeContents(element);
+
+            // Replace any current selection with the generated range
+            var selection = $window.getSelection();
+            selection.removeAllRanges();
+            selection.addRange(range);
+
+        }
 
     };
 
@@ -175,6 +184,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
         }
 
         // Select all data within the clipboard target
+        clipboardContent.focus();
         selectAll(clipboardContent);
 
         // Attempt to copy data from clipboard element into local clipboard


[4/5] incubator-guacamole-client git commit: GUACAMOLE-310: Ensure clipboard service target remains hidden (1x1 px may be below browser's minimum dimensions for a textarea).

Posted by vn...@apache.org.
GUACAMOLE-310: Ensure clipboard service target remains hidden (1x1 px may be below browser's minimum dimensions for a textarea).

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/cc22f23c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/cc22f23c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/cc22f23c

Branch: refs/heads/master
Commit: cc22f23c027bc4dd688eb71372c90a7b31e71e40
Parents: 535b70f
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Aug 29 11:39:08 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Sep 3 17:08:34 2017 -0700

----------------------------------------------------------------------
 guacamole/src/main/webapp/app/clipboard/styles/clipboard.css | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cc22f23c/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css b/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
index b4513e1..3d61c2b 100644
--- a/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
+++ b/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
@@ -52,10 +52,10 @@
 
 .clipboard-service-target {
     position: fixed;
-    left: -1px;
-    right: -1px;
-    width: 1px;
-    height: 1px;
+    left: -1em;
+    right: -1em;
+    width: 1em;
+    height: 1em;
     white-space: pre;
     overflow: hidden;
 }


[2/5] incubator-guacamole-client git commit: GUACAMOLE-310: Wait until clipboard target is actually focused before attempting paste.

Posted by vn...@apache.org.
GUACAMOLE-310: Wait until clipboard target is actually focused before attempting paste.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/47acaf5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/47acaf5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/47acaf5b

Branch: refs/heads/master
Commit: 47acaf5b41c911d402a9f242cc58619bc74c4cb9
Parents: cc22f23
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Aug 29 11:39:49 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Sep 3 17:08:34 2017 -0700

----------------------------------------------------------------------
 .../app/clipboard/services/clipboardService.js  | 102 ++++++++++++-------
 1 file changed, 65 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/47acaf5b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
index ff626ea..311dbc0 100644
--- a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
+++ b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
@@ -398,52 +398,80 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
             var originalElement = document.activeElement;
             pushSelection();
 
-            // Clear and select the clipboard DOM element
-            clipboardContent.value = '';
-            clipboardContent.focus();
-            selectAll(clipboardContent);
-
-            // Attempt paste local clipboard into clipboard DOM element
-            if (document.activeElement === clipboardContent && document.execCommand('paste')) {
-
-                // If the pasted data is a single image, resolve with a blob
-                // containing that image
-                var currentImage = service.getImageContent(clipboardContent);
-                if (currentImage) {
-
-                    // Convert the image's data URL into a blob
-                    var blob = service.parseDataURL(currentImage);
-                    if (blob) {
+            /**
+             * Attempts to paste the clipboard contents into the
+             * currently-focused element. The promise related to the current
+             * attempt to read the clipboard will be resolved or rejected
+             * depending on whether the attempt to paste succeeds.
+             */
+            var performPaste = function performPaste() {
+
+                // Attempt paste local clipboard into clipboard DOM element
+                if (document.execCommand('paste')) {
+
+                    // If the pasted data is a single image, resolve with a blob
+                    // containing that image
+                    var currentImage = service.getImageContent(clipboardContent);
+                    if (currentImage) {
+
+                        // Convert the image's data URL into a blob
+                        var blob = service.parseDataURL(currentImage);
+                        if (blob) {
+                            deferred.resolve(new ClipboardData({
+                                type : blob.type,
+                                data : blob
+                            }));
+                        }
+
+                        // Reject if conversion fails
+                        else
+                            deferred.reject();
+
+                    } // end if clipboard is an image
+
+                    // Otherwise, assume the clipboard contains plain text
+                    else
                         deferred.resolve(new ClipboardData({
-                            type : blob.type,
-                            data : blob
+                            type : 'text/plain',
+                            data : clipboardContent.value
                         }));
-                    }
-
-                    // Reject if conversion fails
-                    else
-                        deferred.reject();
 
-                } // end if clipboard is an image
+                }
 
-                // Otherwise, assume the clipboard contains plain text
+                // Otherwise, reading from the clipboard has failed
                 else
-                    deferred.resolve(new ClipboardData({
-                        type : 'text/plain',
-                        data : clipboardContent.value
-                    }));
+                    deferred.reject();
 
-            }
+            };
 
-            // Otherwise, reading from the clipboard has failed
-            else
-                deferred.reject();
+            // Clean up event listener and selection once the paste attempt has
+            // completed
+            deferred.promise['finally'](function cleanupReadAttempt() {
+
+                // Do not use future changes in focus
+                clipboardContent.removeEventListener('focus', performPaste);
+
+                // Unfocus the clipboard DOM event to avoid mobile keyboard opening,
+                // restoring whichever element was originally focused
+                clipboardContent.blur();
+                originalElement.focus();
+                popSelection();
 
-            // Unfocus the clipboard DOM event to avoid mobile keyboard opening,
-            // restoring whichever element was originally focused
+            });
+
+            // Ensure clipboard element is blurred (and that the "focus" event
+            // will fire)
             clipboardContent.blur();
-            originalElement.focus();
-            popSelection();
+            clipboardContent.addEventListener('focus', performPaste);
+
+            // Clear and select the clipboard DOM element
+            clipboardContent.value = '';
+            clipboardContent.focus();
+            selectAll(clipboardContent);
+
+            // If focus failed to be set, we cannot read the clipboard
+            if (document.activeElement !== clipboardContent)
+                deferred.reject();
 
         }, CLIPBOARD_READ_DELAY);
 


[3/5] incubator-guacamole-client git commit: GUACAMOLE-310: Switch clipboard service back to using textarea for contents.

Posted by vn...@apache.org.
GUACAMOLE-310: Switch clipboard service back to using textarea for contents.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/535b70fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/535b70fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/535b70fd

Branch: refs/heads/master
Commit: 535b70fdce8ff5df2405e23b30897f65ecda66bf
Parents: 96e9318
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Aug 29 11:38:05 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Sep 3 17:08:34 2017 -0700

----------------------------------------------------------------------
 .../main/webapp/app/clipboard/services/clipboardService.js  | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/535b70fd/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
index f0529d8..ff626ea 100644
--- a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
+++ b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js
@@ -57,10 +57,9 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
      *
      * @type Element
      */
-    var clipboardContent = document.createElement('div');
+    var clipboardContent = document.createElement('textarea');
 
     // Ensure clipboard target is selectable but not visible
-    clipboardContent.setAttribute('contenteditable', 'true');
     clipboardContent.className = 'clipboard-service-target';
 
     // Add clipboard target to DOM
@@ -167,7 +166,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
 
         // Copy the given value into the clipboard DOM element
         if (typeof data.data === 'string')
-            clipboardContent.textContent = data.data;
+            clipboardContent.value = data.data;
         else {
             clipboardContent.innerHTML = '';
             var img = document.createElement('img');
@@ -400,7 +399,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
             pushSelection();
 
             // Clear and select the clipboard DOM element
-            clipboardContent.innerHTML = '';
+            clipboardContent.value = '';
             clipboardContent.focus();
             selectAll(clipboardContent);
 
@@ -431,7 +430,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
                 else
                     deferred.resolve(new ClipboardData({
                         type : 'text/plain',
-                        data : clipboardContent.textContent
+                        data : clipboardContent.value
                     }));
 
             }


[5/5] incubator-guacamole-client git commit: GUACAMOLE-310: Merge fix clipboard handling of newlines.

Posted by vn...@apache.org.
GUACAMOLE-310: Merge fix clipboard handling of newlines.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/ab88eb2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/ab88eb2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/ab88eb2f

Branch: refs/heads/master
Commit: ab88eb2ff3ea1840b3e9a8a50ddc3585704abba8
Parents: 96e9318 7e0cdd2
Author: Nick Couchman <vn...@apache.org>
Authored: Sun Sep 3 20:42:50 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sun Sep 3 20:42:50 2017 -0400

----------------------------------------------------------------------
 .../app/clipboard/services/clipboardService.js  | 131 ++++++++++++-------
 .../webapp/app/clipboard/styles/clipboard.css   |   8 +-
 2 files changed, 88 insertions(+), 51 deletions(-)
----------------------------------------------------------------------