You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/08/21 04:06:21 UTC
[1/2] incubator-guacamole-client git commit: GUACAMOLE-82: Move back
to textarea for clipboard for sake of stability (partially reverts
GUACAMOLE-55).
Repository: incubator-guacamole-client
Updated Branches:
refs/heads/master 83c744d27 -> 0ce014428
GUACAMOLE-82: Move back to textarea for clipboard for sake of stability (partially reverts GUACAMOLE-55).
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/70aec4c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/70aec4c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/70aec4c6
Branch: refs/heads/master
Commit: 70aec4c66835d3911f9a890c4f888517a0f69a57
Parents: 39a25db
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Aug 20 19:30:47 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat Aug 20 19:30:47 2016 -0700
----------------------------------------------------------------------
.../app/clipboard/directives/guacClipboard.js | 153 ++-----------------
.../webapp/app/clipboard/styles/clipboard.css | 1 +
.../app/clipboard/templates/guacClipboard.html | 2 +-
3 files changed, 12 insertions(+), 144 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/70aec4c6/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js b/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js
index 97fc6e0..70485d8 100644
--- a/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js
+++ b/guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js
@@ -58,106 +58,15 @@ angular.module('clipboard').directive('guacClipboard', ['$injector',
config.controller = ['$scope', '$injector', '$element',
function guacClipboardController($scope, $injector, $element) {
- // Required services
- var $window = $injector.get('$window');
- var clipboardService = $injector.get('clipboardService');
-
- /**
- * The FileReader to use to read File or Blob data received from the
- * clipboard.
- *
- * @type FileReader
- */
- var reader = new FileReader();
-
/**
- * The content-editable DOM element which will contain the clipboard
- * contents within the user interface provided by this directive.
+ * The DOM element which will contain the clipboard contents within the
+ * user interface provided by this directive.
*
* @type Element
*/
var element = $element[0];
/**
- * Returns all files currently contained within the local clipboard,
- * given a ClipboardEvent which should contain the current clipboard
- * data. If no files are contained within the local clipboard, null
- * is returned.
- *
- * @param {ClipboardEvent} e
- * The ClipboardEvent which should contain the current clipboard
- * data.
- *
- * @returns {File[]}
- * An array of all files currently contained with the clipboard, as
- * provided by the given ClipboardEvent, or null if no files are
- * present.
- */
- var getClipboardFiles = function getClipboardFiles(e) {
-
- // Pull the clipboard data object
- var clipboardData = e.clipboardData || $window.clipboardData;
-
- // Read from the standard clipboard API items collection first
- var items = clipboardData.items;
- if (items) {
-
- var files = [];
-
- // Produce array of all files from clipboard data
- for (var i = 0; i < items.length; i++) {
- if (items[i].kind === 'file')
- files.push(items[i].getAsFile());
- }
-
- return files;
-
- }
-
- // Failing that, try the files collection
- if (clipboardData.files)
- return clipboardData.files;
-
- // No files accessible within given data
- return null;
-
- };
-
- // Intercept paste events, handling image data specifically
- element.addEventListener('paste', function dataPasted(e) {
-
- // Read all files from the clipboard data within the event
- var files = getClipboardFiles(e);
- if (!files)
- return;
-
- // For each item within the clipboard
- for (var i = 0; i < files.length; i++) {
-
- var file = files[i];
-
- // If the file is an image, attempt to read that image
- if (/^image\//.exec(file.type)) {
-
- // Set clipboard data to contents
- $scope.$apply(function setClipboardData() {
- $scope.data = new ClipboardData({
- type : file.type,
- data : file
- });
- });
-
- // Do not paste
- e.preventDefault();
- return;
-
- }
-
- } // end for each item
-
- });
-
- /**
* Rereads the contents of the clipboard field, updating the
* ClipboardData object on the scope as necessary. The type of data
* stored within the ClipboardData object will be heuristically
@@ -165,35 +74,11 @@ angular.module('clipboard').directive('guacClipboard', ['$injector',
*/
var updateClipboardData = function updateClipboardData() {
- // If the clipboard contains a single image, parse and assign the
- // image data to the internal clipboard
- var currentImage = clipboardService.getImageContent(element);
- if (currentImage) {
-
- // Convert the image's data URL into a blob
- var blob = clipboardService.parseDataURL(currentImage);
- if (blob) {
-
- // Complete the assignment if conversion was successful
- $scope.$evalAsync(function assignClipboardData() {
- $scope.data = new ClipboardData({
- type : blob.type,
- data : blob
- });
- });
-
- return;
-
- }
-
- } // end if clipboard is an image
-
- // If data does not appear to be an image, or image decoding fails,
- // assume clipboard contents are text
+ // Read contents of clipboard textarea
$scope.$evalAsync(function assignClipboardText() {
$scope.data = new ClipboardData({
type : 'text/plain',
- data : clipboardService.getTextContent(element)
+ data : element.value
});
});
@@ -201,36 +86,18 @@ angular.module('clipboard').directive('guacClipboard', ['$injector',
// Update the internally-stored clipboard data when events are fired
// that indicate the clipboard field may have been changed
- element.addEventListener('input', updateClipboardData);
- element.addEventListener('DOMCharacterDataModified', updateClipboardData);
- element.addEventListener('DOMNodeInserted', updateClipboardData);
- element.addEventListener('DOMNodeRemoved', updateClipboardData);
+ element.addEventListener('input', updateClipboardData);
+ element.addEventListener('change', updateClipboardData);
- // Watch clipboard for new data, associating it with any pressed keys
+ // Watch clipboard for new data, updating the clipboard textarea as
+ // necessary
$scope.$watch('data', function clipboardDataChanged(data) {
- // Stop any current read process
- if (reader.readyState === 1)
- reader.abort();
-
// If the clipboard data is a string, render it as text
if (typeof data.data === 'string')
- clipboardService.setTextContent(element, data.data);
-
- // Render Blob/File contents based on mimetype
- else if (data.data instanceof Blob) {
-
- // If the copied data was an image, display it as such
- if (/^image\//.exec(data.type)) {
- reader.onload = function updateImageURL() {
- clipboardService.setImageContent(element, reader.result);
- };
- reader.readAsDataURL(data.data);
- }
-
- // Ignore other data types
+ element.value = data.data;
- }
+ // Ignore other data types for now
}); // end $scope.data watch
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/70aec4c6/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 8f4df25..b4513e1 100644
--- a/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
+++ b/guacamole/src/main/webapp/app/clipboard/styles/clipboard.css
@@ -31,6 +31,7 @@
width: 100%;
height: 2in;
white-space: pre;
+ font-size: 1em;
overflow: auto;
padding: 0.25em;
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/70aec4c6/guacamole/src/main/webapp/app/clipboard/templates/guacClipboard.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/clipboard/templates/guacClipboard.html b/guacamole/src/main/webapp/app/clipboard/templates/guacClipboard.html
index b3b604d..b860f03 100644
--- a/guacamole/src/main/webapp/app/clipboard/templates/guacClipboard.html
+++ b/guacamole/src/main/webapp/app/clipboard/templates/guacClipboard.html
@@ -1 +1 @@
-<div class="clipboard" contenteditable="true"></div>
+<textarea class="clipboard"></textarea>
[2/2] incubator-guacamole-client git commit: GUACAMOLE-82: Merge
change to restore original clipboard behavior.
Posted by jm...@apache.org.
GUACAMOLE-82: Merge change to restore original clipboard behavior.
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/0ce01442
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/0ce01442
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/0ce01442
Branch: refs/heads/master
Commit: 0ce0144285f9c557de46d421373041cbaa11d12e
Parents: 83c744d 70aec4c
Author: James Muehlner <ja...@guac-dev.org>
Authored: Sat Aug 20 21:05:47 2016 -0700
Committer: James Muehlner <ja...@guac-dev.org>
Committed: Sat Aug 20 21:05:47 2016 -0700
----------------------------------------------------------------------
.../app/clipboard/directives/guacClipboard.js | 153 ++-----------------
.../webapp/app/clipboard/styles/clipboard.css | 1 +
.../app/clipboard/templates/guacClipboard.html | 2 +-
3 files changed, 12 insertions(+), 144 deletions(-)
----------------------------------------------------------------------