feat: add serverCut support for extended messages
This commit is contained in:
parent
f6f54d8257
commit
85ae083c08
33
core/rfb.js
33
core/rfb.js
|
|
@ -2180,6 +2180,21 @@ export default class RFB extends EventTargetMixin {
|
||||||
return this._fail("Unexpected SetColorMapEntries message");
|
return this._fail("Unexpected SetColorMapEntries message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_triggerClipboardEvent(text) {
|
||||||
|
this.dispatchEvent(new CustomEvent("clipboard", { detail: { text: text } }));
|
||||||
|
|
||||||
|
if (Clipboard.isSupported) {
|
||||||
|
const clipboardData = new DataTransfer();
|
||||||
|
clipboardData.setData("text/plain", text);
|
||||||
|
const clipboardEvent = new ClipboardEvent('copy', { clipboardData });
|
||||||
|
// Force initialization since the constructor is broken in Firefox
|
||||||
|
if (!clipboardEvent.clipboardData.items.length) {
|
||||||
|
clipboardEvent.clipboardData.items.add(text, "text/plain");
|
||||||
|
}
|
||||||
|
this._canvas.dispatchEvent(clipboardEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_handleServerCutText() {
|
_handleServerCutText() {
|
||||||
Log.Debug("ServerCutText");
|
Log.Debug("ServerCutText");
|
||||||
|
|
||||||
|
|
@ -2199,19 +2214,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent("clipboard", { detail: { text: text } }));
|
this._triggerClipboardEvent(text);
|
||||||
|
|
||||||
if (Clipboard.isSupported) {
|
|
||||||
const clipboardData = new DataTransfer();
|
|
||||||
clipboardData.setData("text/plain", text);
|
|
||||||
const clipboardEvent = new ClipboardEvent('copy', { clipboardData });
|
|
||||||
// Force initialization since the constructor is broken in Firefox
|
|
||||||
if (!clipboardEvent.clipboardData.items.length) {
|
|
||||||
clipboardEvent.clipboardData.items.add(text, "text/plain");
|
|
||||||
}
|
|
||||||
this._canvas.dispatchEvent(clipboardEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Extended msg.
|
//Extended msg.
|
||||||
length = Math.abs(length);
|
length = Math.abs(length);
|
||||||
|
|
@ -2346,9 +2349,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
|
|
||||||
textData = textData.replace("\r\n", "\n");
|
textData = textData.replace("\r\n", "\n");
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent(
|
this._triggerClipboardEvent(textData);
|
||||||
"clipboard",
|
|
||||||
{ detail: { text: textData } }));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return this._fail("Unexpected action in extended clipboard message: " + actions);
|
return this._fail("Unexpected action in extended clipboard message: " + actions);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue