- 
  Notifications
 You must be signed in to change notification settings 
- Fork 6.3k
Why I can't paste text of clipboard in the terminal of vscode embedded in iframe? #6623
-
- System: Windows 11
- Browser: Chrome - Version 120.0.6099.200
 I embedded the vs code web IDE in an iframe with a different origin, I found that I can't use the CTRL+V shortcut to paste the command in the terminal editor, but the SHIFT+INSERT can do it.
 So I opened the vs code web IDE in the browser directly, the CTRL+V still prompted I should grant access although I allowed the reading from the clipboard.
 The SHIFT+INSERT still works for me, nonetheless, I still want to figure out the real reason for the CTRL+V is invalid.
 By the way, the Mac don't have the SHIFT+INSERT shortcut, and the SHIFT+COMMAND+V don't work, so is there any way of pasting in MAC OS?
 Regards
When I try to paste a command with CTRL+C -
image 
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 9 replies
-
I think probably shift+insert is doing a native paste while ctrl+v is being caught by VS Code and using the clipboard API, and maybe the clipboard API is not allowed in the iframe? Do you see any errors in the console log? Maybe you need allow="clipboard-read" on the iframe or something.
Beta Was this translation helpful? Give feedback.
All reactions
-
Sorry for necro-bumping, but I've found that ctrl+v and shift+ins and ctrl+shift+v are perfectly working within and outside of an iframe for every text field, except for the Terminal window.
Terminal only accepts ctrl+shift+v as pasting from the clipboard if it is not included in an iframe. Unfortunately, it does not work within an iframe....
(Edge 139.0.3405.111 (64bit) on Linux, code-server: v4.103.2, Code: 1.103.2)
Beta Was this translation helpful? Give feedback.
All reactions
-
Hmm I am not too sure why it would only break in the terminal. Do you see any errors in the browser log?
Beta Was this translation helpful? Give feedback.
All reactions
-
Do you see any errors in the browser log?
clipboardService.ts:52 [Violation] Permissions policy violation: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://crbug.com/414348233 for more details.
readText @ clipboardService.ts:52
paste @ terminal.clipboard.contribution.ts:84
run @ terminal.clipboard.contribution.ts:297
run @ terminalActions.ts:238
run @ terminalActions.ts:160
handler @ actions.ts:665
invokeFunction @ instantiationService.ts:109
n @ commandService.ts:99
executeCommand @ commandService.ts:63
run @ actions.ts:587
u @ terminalContextMenu.ts:44
run @ actions.ts:185
onClick @ actionViewItems.ts:173
(anonymous) @ actionViewItems.ts:124
D @ touch.ts:292
z @ touch.ts:200
(anonymous) @ touch.ts:96
notificationsAlerts.ts:42 Unable to read from the browser's clipboard. Please make sure you have granted access for this website to read from the clipboard.
c @ notificationsAlerts.ts:42
(anonymous) @ notificationsAlerts.ts:28
C @ event.ts:1219
D @ event.ts:1230
fire @ event.ts:1254
addNotification @ notifications.ts:228
notify @ notificationService.ts:234
prompt @ notificationService.ts:312
(anonymous) @ clipboardService.ts:60
readText @ clipboardService.ts:56
await in readText
paste @ terminal.clipboard.contribution.ts:84
run @ terminal.clipboard.contribution.ts:297
run @ terminalActions.ts:238
run @ terminalActions.ts:160
handler @ actions.ts:665
invokeFunction @ instantiationService.ts:109
n @ commandService.ts:99
executeCommand @ commandService.ts:63
run @ actions.ts:587
u @ terminalContextMenu.ts:44
run @ actions.ts:185
onClick @ actionViewItems.ts:173
(anonymous) @ actionViewItems.ts:124
D @ touch.ts:292
z @ touch.ts:200
(anonymous) @ touch.ts:96
Beta Was this translation helpful? Give feedback.
All reactions
-
Ah yeah so looks like it is using the clipboard API, which is not allowed in cross-origin iframes, and I am not sure there is a way to get around it. Maybe adding allow="clipboard-read; clipboard-write" to the iframe would work?
Beta Was this translation helpful? Give feedback.
All reactions
-
Maybe adding
allow="clipboard-read; clipboard-write"to the iframe would work?
Yes, exactly! This was the problem, and your suggestion worked!
As of now, the issue has been completely eliminated; pasting text into any field is working through the iframe.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
- 
 🎉 1