Fixes microsoft/monaco-editor#2313: navigator.clipboard is not defined when loading not secure, via http

This commit is contained in:
Alexandru Dima
2021-01-21 16:08:30 +01:00
parent d3fbbece82
commit ad437ef958
+2 -1
View File
@@ -27,7 +27,8 @@ const supportsCopy = (platform.isNative || document.queryCommandSupported('copy'
const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdge);
// Firefox only supports navigator.clipboard.readText() in browser extensions.
// See https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText#Browser_compatibility
const supportsPaste = (browser.isFirefox ? document.queryCommandSupported('paste') : true);
// When loading over http, navigator.clipboard can be undefined. See https://github.com/microsoft/monaco-editor/issues/2313
const supportsPaste = (typeof navigator.clipboard === 'undefined' || browser.isFirefox) ? document.queryCommandSupported('paste') : true;
function registerCommand<T extends Command>(command: T): T {
command.register();