You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by "Michael Jumper (JIRA)" <ji...@apache.org> on 2016/08/08 20:39:20 UTC
[jira] [Issue Comment Deleted] (GUACAMOLE-55) Add client-side
clipboard support for images
[ https://issues.apache.org/jira/browse/GUACAMOLE-55?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Jumper updated GUACAMOLE-55:
------------------------------------
Comment: was deleted
(was: Github user jmuehlner commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/24#discussion_r68854489
--- Diff: guacamole/src/main/webapp/app/clipboard/directives/guacClipboard.js ---
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A directive which exposes the current clipboard contents, if possible,
+ * allowing the user to edit those contents. If the current clipboard contents
+ * cannot be directly accessed, the user can at least directly copy/paste data
+ * within the field provided by this directive. The contents of this clipboard
+ * directive, whether retrieved from the local or manipulated manually by the
+ * user, are exposed via the "data" attribute. In addition to updating the
+ * "data" attribute, changes to clipboard data will be broadcast on the scope
+ * via "guacClipboard" events.
+ */
+angular.module('clipboard').directive('guacClipboard', ['$injector',
+ function guacClipboard($injector) {
+
+ // Required types
+ var ClipboardData = $injector.get('ClipboardData');
+
+ /**
+ * Configuration object for the guacClipboard directive.
+ *
+ * @type Object.<String, Object>
+ */
+ var config = {
+ restrict : 'E',
+ replace : true,
+ templateUrl : 'app/clipboard/templates/guacClipboard.html'
+ };
+
+ // Scope properties exposed by the guacClipboard directive
+ config.scope = {
+
+ /**
+ * The data to display within the field provided by this directive. If
+ * the local clipboard can be accessed by JavaScript, this will be set
+ * automatically as the local clipboard changes. Failing that, this
+ * will be set when the user manually modifies the contents of the
+ * field. Changes to this value will be rendered within the field and,
+ * if possible, will be pushed to the local clipboard.
+ *
+ * @type ClipboardData
+ */
+ data : '='
+
+ };
+
+ // guacClipboard directive controller
+ config.controller = ['$scope', '$injector', '$element',
+ function guacClipboardController($scope, $injector, $element) {
+
+ // Required services
+ var $rootScope = $injector.get('$rootScope');
+ var $window = $injector.get('$window');
+ var clipboardService = $injector.get('clipboardService');
+
+ /**
+ * Reference to the window.document object.
+ *
+ * @private
+ * @type HTMLDocument
+ */
+ var document = $window.document;
+
+ /**
+ * Map of all currently pressed keys by keysym. If a particular key is
+ * currently pressed, the value stored under that key's keysym within
+ * this map will be true. All keys not currently pressed will not have entries
+ * within this map.
+ *
+ * @type Object.<Number, Boolean>
+ */
+ var keysCurrentlyPressed = {};
+
+ /**
+ * Map of all currently pressed keys (by keysym) to the clipboard
+ * contents received while those keys were pressed. All keys not
+ * currently pressed will not have entries within this map.
+ *
+ * @type Object.<Number, Blob>
+ */
+ var clipboardDataFromKey = {};
+
+ /**
+ * 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.
+ *
+ * @type Element
+ */
+ var element = $element[0];
+
+ // Intercept paste events, handling image data specifically
+ element.addEventListener('paste', function dataPasted(e) {
+
+ // Always clear the current clipboard contents upon paste
+ element.innerHTML = '';
+
+ // If we can't read the clipboard contents at all, abort
+ var clipboardData = e.clipboardData;
--- End diff --
Should we keep the existing content if a paste fails? I'm not sure...
)
> Add client-side clipboard support for images
> --------------------------------------------
>
> Key: GUACAMOLE-55
> URL: https://issues.apache.org/jira/browse/GUACAMOLE-55
> Project: Guacamole
> Issue Type: New Feature
> Components: guacamole
> Reporter: Michael Jumper
> Assignee: Michael Jumper
> Fix For: 0.9.10-incubating
>
>
> The Guacamole clipboard currently only supports text, even though the protocol has been written to support arbitrary data. The Guacamole interface should be modified such that users can copy/paste image data, which will be received by the backend (and handled when supported).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)