KASM-3744 Fix copy/paste for files and folders (#53)
This commit is contained in:
parent
f223cfcafe
commit
31b1a93335
17
core/rfb.js
17
core/rfb.js
|
@ -2881,16 +2881,23 @@ export default class RFB extends EventTargetMixin {
|
||||||
if (Object.keys(clipItemData).length > 0) {
|
if (Object.keys(clipItemData).length > 0) {
|
||||||
if (this.clipboardBinary) {
|
if (this.clipboardBinary) {
|
||||||
this._clipHash = 0;
|
this._clipHash = 0;
|
||||||
|
|
||||||
navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
|
navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
|
||||||
function() {},
|
() => {
|
||||||
function(err) {
|
if (textdata) {
|
||||||
|
this._clipHash = hashUInt8Array(textdata);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
Log.Error("Error writing to client clipboard: " + err);
|
Log.Error("Error writing to client clipboard: " + err);
|
||||||
// Lets try writeText
|
// Lets try writeText
|
||||||
if (textdata.length > 0) {
|
if (textdata.length > 0) {
|
||||||
navigator.clipboard.writeText(textdata).then(
|
navigator.clipboard.writeText(textdata).then(
|
||||||
function() {},
|
() => {
|
||||||
function(err2) {
|
this._clipHash = hashUInt8Array(textdata);
|
||||||
Log.Error("Error writing text to client clipboard: " + err2);
|
},
|
||||||
|
(err) => {
|
||||||
|
Log.Error("Error writing text to client clipboard: " + err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,15 @@ export function toSignedRelative16bit(toConvert) {
|
||||||
|
|
||||||
/* Fast hashing function with low entropy */
|
/* Fast hashing function with low entropy */
|
||||||
export function hashUInt8Array(data) {
|
export function hashUInt8Array(data) {
|
||||||
let h;
|
if (typeof data === "string") {
|
||||||
|
data = [...data].map(character => character.charCodeAt(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
let h = 0;
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
h = Math.imul(31, h) + data[i] | 0;
|
h = Math.imul(31, h) + data[i] | 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue