diff --git a/frontend/src/lib/components/Dev.svelte b/frontend/src/lib/components/Dev.svelte
index 9c5de746c9..b85c3b7c9b 100644
--- a/frontend/src/lib/components/Dev.svelte
+++ b/frontend/src/lib/components/Dev.svelte
@@ -1,5 +1,6 @@
-
+
-
+
{
diff --git a/frontend/src/lib/components/SimpleEditor.svelte b/frontend/src/lib/components/SimpleEditor.svelte
index 083bb30577..884fab737c 100644
--- a/frontend/src/lib/components/SimpleEditor.svelte
+++ b/frontend/src/lib/components/SimpleEditor.svelte
@@ -360,6 +360,21 @@
}
keepModelAroundToAvoidDisposalOfWorkers()
+ // In VSCode webview (iframe), clipboard operations need special handling
+ // because the webview has restricted clipboard API access
+ if (window.parent !== window) {
+ editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyC, function () {
+ document.execCommand('copy')
+ })
+ editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyX, function () {
+ document.execCommand('cut')
+ })
+ editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyV, async function () {
+ inputEl?.focus()
+ document.execCommand('paste')
+ })
+ }
+
let timeoutModel: number | undefined = undefined
editor.onDidChangeModelContent((event) => {
timeoutModel && clearTimeout(timeoutModel)
@@ -583,8 +598,38 @@
}
updatePlaceholderVisibility(code ?? '')
+
+ let inputEl = $state(null)
+ let pasteValue = $state('')
+ $effect(() => {
+ if (inputEl && pasteValue) {
+ untrack(() => {
+ editor?.executeEdits('paste', [
+ {
+ range: editor?.getSelection() ?? {
+ startLineNumber: 1,
+ startColumn: 1,
+ endLineNumber: 1,
+ endColumn: 1
+ },
+ text: pasteValue,
+ forceMoveMarkers: true
+ }
+ ])
+ pasteValue = ''
+ })
+ }
+ })
+{#if parent.window !== window}
+
+{/if}
{#if !editor || suggestion}
{
dispatch('focus')