I saw the when-clause-contexts document but I can't find something like that... Is there any conditions WebView panel is active or alternatives?
I'm now making copy & paste feature in my extension but if when
is not specified, some default keybindings may be blocked.
I believe this new context value is what you need:
The new activeWebviewPanelId
context key tracks the viewType
of the currently focused webview panel. You can use it in when clauses to enable commands or menu items when your webview is focused
"when": "activeWebviewPanelId == 'markdown.preview'"
from v1.71 Release Notes: active webview panel context key
There is not a generic context key for when a webview is active. However using the setContext
command, you can create a custom context that tracks just when one of your webviews is active
Here's what VS code's markdown preview (which also uses a webview) does to create a custom context key that is set when the preview is active:
https://github.com/Microsoft/vscode/blob/cd7c7c5fa2c16c6e8281436c35e9a7709cfbd89d/extensions/markdown-language-features/src/features/previewManager.ts#L152
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With