diff --git a/core/rfb.js b/core/rfb.js index 1073a878..cb9aa8f1 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -2335,11 +2335,13 @@ export default class RFB extends EventTargetMixin { _writeClipboard(text) { if (this._viewOnly) return; - if (this._asyncClipboard.writeClipboard(text)) return; - // Fallback clipboard - this.dispatchEvent( - new CustomEvent("clipboard", {detail: {text: text}}) - ); + if (!(this._asyncClipboard.writeClipboard(text))) { + // Fallback clipboard + this.dispatchEvent( + new CustomEvent("clipboard", {detail: {text: text}}) + ); + } + this.dispatchEvent(new CustomEvent("clipboardreceived")); } _handleServerCutText() { diff --git a/docs/API.md b/docs/API.md index c1f6fac9..ea80f89a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -96,6 +96,12 @@ protocol stream. - The `clipboard` event is fired when clipboard data is received from the server. +['clipboardreceived'](#clipboardreceived) + - The `clipboardreceived` event is fired after the `clipboard` event + or after the clipboard has been updated through the + [Clipboard module](API-internal.md#11-module-list). The copied text + has already been written to the system clipboard or the clipboard panel. + [`clippingviewport`](#clippingviewport) - The `clippingviewport` event is fired when `RFB.clippingViewport` is updated.