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");
|
||||
}
|
||||
|
||||
_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() {
|
||||
Log.Debug("ServerCutText");
|
||||
|
||||
|
|
@ -2199,19 +2214,7 @@ export default class RFB extends EventTargetMixin {
|
|||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
this._triggerClipboardEvent(text);
|
||||
} else {
|
||||
//Extended msg.
|
||||
length = Math.abs(length);
|
||||
|
|
@ -2346,9 +2349,7 @@ export default class RFB extends EventTargetMixin {
|
|||
|
||||
textData = textData.replace("\r\n", "\n");
|
||||
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"clipboard",
|
||||
{ detail: { text: textData } }));
|
||||
this._triggerClipboardEvent(textData);
|
||||
}
|
||||
} else {
|
||||
return this._fail("Unexpected action in extended clipboard message: " + actions);
|
||||
|
|
|
|||
Loading…
Reference in New Issue