Are there any contexts when specified WebView panel is active in VSCode extension keybinding contribution points?

Viewed 857

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.

2 Answers

I believe this new context value is what you need:

New activeWebviewPanelId context key

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

Related