Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why I can't paste text of clipboard in the terminal of vscode embedded in iframe? #6623

Unanswered
ether-wang asked this question in Q&A
Discussion options

  • 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

You must be logged in to vote

Replies: 1 comment 9 replies

Comment options

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.

You must be logged in to vote
9 replies
Comment options

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)

Comment options

Hmm I am not too sure why it would only break in the terminal. Do you see any errors in the browser log?

Comment options

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
Comment options

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?

Comment options

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /