mirror of
https://github.com/novnc/noVNC.git
synced 2026-08-29 08:34:26 +08:00
Disable clipboard button with async clipboard
With async clipboard available, the fallback clipboard textarea adds mostly confusion. If async clipboard is out right denied, users most likely don't want to see any clipboard activity.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
import * as Log from '../core/util/logging.js';
|
||||
import _, { l10n } from './localization.js';
|
||||
import { isTouchDevice, isMac, isIOS, isAndroid, isChromeOS, isSafari,
|
||||
hasScrollbarGutter, dragThreshold }
|
||||
hasScrollbarGutter, dragThreshold, browserAsyncClipboardSupport }
|
||||
from '../core/util/browser.js';
|
||||
import { setCapture, getPointerEvent } from '../core/util/events.js';
|
||||
import KeyTable from "../core/input/keysym.js";
|
||||
@@ -1103,6 +1103,7 @@ const UI = {
|
||||
UI.rfb.showDotCursor = UI.getSetting('show_dot');
|
||||
|
||||
UI.updateViewOnly(); // requires UI.rfb
|
||||
UI.updateClipboard();
|
||||
},
|
||||
|
||||
disconnect() {
|
||||
@@ -1754,6 +1755,31 @@ const UI = {
|
||||
}
|
||||
},
|
||||
|
||||
updateClipboard() {
|
||||
browserAsyncClipboardSupport()
|
||||
.then((support) => {
|
||||
if (support === 'unsupported') {
|
||||
// Use fallback clipboard panel
|
||||
return;
|
||||
}
|
||||
if (support === 'denied' || support === 'available') {
|
||||
UI.closeClipboardPanel();
|
||||
document.getElementById('noVNC_clipboard_button')
|
||||
.classList.add('noVNC_hidden');
|
||||
document.getElementById('noVNC_clipboard_button')
|
||||
.removeEventListener('click', UI.toggleClipboardPanel);
|
||||
document.getElementById('noVNC_clipboard_text')
|
||||
.removeEventListener('change', UI.clipboardSend);
|
||||
if (UI.rfb) {
|
||||
UI.rfb.removeEventListener('clipboard', UI.clipboardReceive);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// Treat as unsupported
|
||||
});
|
||||
},
|
||||
|
||||
updateShowDotCursor() {
|
||||
if (!UI.rfb) return;
|
||||
UI.rfb.showDotCursor = UI.getSetting('show_dot');
|
||||
|
||||
Reference in New Issue
Block a user