Repository navigation
fix(vscode): bridge clipboard and forward keystrokes in webview - #970
Merged
backnotprop merged 1 commit intoJun 26, 2026
Merged
Conversation
The Plannotator app runs in a nested cross-origin iframe inside the VS Code
webview, where two input paths break:
- Clipboard: the iframe document never holds focus, so the async Clipboard
API is rejected ("Document is not focused") and native copy/cut/paste
events never fire. Copy, cut, and paste all silently fail.
- Keybindings: keydown events don't cross the iframe boundary, so VS Code
never sees global shortcuts (Cmd+P, etc.) while a Plannotator tab is focused.
Fix both off the one input signal the iframe still receives — keydown:
- Route clipboard reads/writes through the extension host, which owns the
system clipboard via vscode.env.clipboard. The injected script overrides
navigator.clipboard and handles Cmd+C/X/V, relaying through the wrapper to
an onDidReceiveMessage handler and back.
- Forward all other keystrokes to the wrapper, which re-dispatches a synthetic
KeyboardEvent on the webview document so VS Code can resolve its keybindings.
Undo/redo/select-all stay native.
Fixes backnotprop#864
Fixes backnotprop#969
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Owner
|
thanks! |
backnotprop
added a commit
that referenced
this pull request
Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #864. Closes #969.
The Plannotator app runs inside a nested cross-origin iframe within the VS
Code webview. Two separate input paths break there, both rooted in the same
constraint — the inner document never holds focus and events don't cross the
iframe boundary:
Root cause
Clipboard API is rejected (
NotAllowedError: Document is not focused) andnative
copy/cut/pasteevents never fire. Grantingallow="clipboard-*"on the iframe does not help — the rejection is about focus, not
Permissions Policy (this is why the earlier fix(vscode): enable clipboard in webview iframe #968 approach was insufficient).
keydownevents don't bubble past the nested iframeboundary, so VS Code's keybinding service never sees them.
The one input signal the iframe still receives is
keydown. Both fixes hang off it.Fix
owns the system clipboard via
vscode.env.clipboard. The injected scriptoverrides
navigator.clipboard(for app buttons) and handles Cmd+C/X/V onkeydown (for native shortcuts), relaying through the wrapper to an
onDidReceiveMessagehandler and back.re-dispatches a synthetic
KeyboardEventon the webview document so VS Codecan resolve its shortcuts. Undo/redo/select-all stay native.
Testing
bun test apps/vscode-extension/src/→ 23 pass.bun run build:vscodesucceeds;tscclean.buttons, and Cmd+P all work in a focused Plannotator tab.
🤖 Generated with Claude Code