提交 e13875b7 编写于 作者: M Matt Bierner

Only prevent default for copy paste in webviews when on electron

Fixes #106383

For web VS Code, we want the browser to handle these events instead. This means we can skip the dispatch entirely
上级 51dc3193
......@@ -111,6 +111,7 @@
onMessage: hostMessaging.onMessage.bind(hostMessaging),
ready: workerReady,
fakeLoad: !onElectron,
onElectron: onElectron,
rewriteCSP: onElectron
? (csp) => {
return csp.replace(/vscode-resource:(?=(\s|;|$))/g, 'vscode-webview-resource:');
......
......@@ -13,6 +13,7 @@
* onIframeLoaded?: (iframe: HTMLIFrameElement) => void,
* fakeLoad?: boolean,
* rewriteCSP: (existingCSP: string, endpoint?: string) => string,
* onElectron?: boolean
* }} WebviewHost
*/
......@@ -286,8 +287,14 @@
// make sure we block the browser from dispatching it. Instead VS Code
// handles these events and will dispatch a copy/paste back to the webview
// if needed
if (isCopyPasteOrCut(e) || isUndoRedo(e)) {
if (isUndoRedo(e)) {
e.preventDefault();
} else if (isCopyPasteOrCut(e)) {
if (host.onElectron) {
e.preventDefault();
} else {
return; // let the browser handle this
}
}
host.postMessage('did-keydown', {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册