Merge 4fad82e94d9963d185c58ae526dbe0afe79efcee into e40a68f409d79d8699d4d2d72c9d3dcc95b78abd

This commit is contained in:
Yogeshwaran C 2026-04-19 21:52:29 +09:00 committed by GitHub
commit 7d7d7e7dc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 0 deletions

View File

@ -24,6 +24,7 @@
],
"activationEvents": [
"onCommand:simpleBrowser.api.open",
"onCommand:simpleBrowser.focusContent",
"onOpenExternalUri:http",
"onOpenExternalUri:https",
"onWebviewPanel:simpleBrowser.view"
@ -40,6 +41,11 @@
"command": "simpleBrowser.show",
"title": "Show",
"category": "Simple Browser"
},
{
"command": "simpleBrowser.focusContent",
"title": "%command.focusContent.title%",
"category": "Simple Browser"
}
],
"menus": {
@ -47,6 +53,10 @@
{
"command": "simpleBrowser.show",
"when": "isWeb"
},
{
"command": "simpleBrowser.focusContent",
"when": "activeWebviewPanelId == 'simpleBrowser.view'"
}
]
},

View File

@ -1,5 +1,6 @@
{
"displayName": "Simple Browser",
"description": "A very basic built-in webview for displaying web content.",
"command.focusContent.title": "Focus Content",
"configuration.focusLockIndicator.enabled.description": "Enable/disable the floating indicator that shows when focused in the simple browser."
}

View File

@ -14,6 +14,7 @@ declare class URL {
const openApiCommand = 'simpleBrowser.api.open';
const showCommand = 'simpleBrowser.show';
const focusContentCommand = 'simpleBrowser.focusContent';
const integratedBrowserCommand = 'workbench.action.browser.open';
const enabledHosts = new Set<string>([
@ -75,6 +76,10 @@ export function activate(context: vscode.ExtensionContext) {
}
}));
context.subscriptions.push(vscode.commands.registerCommand(focusContentCommand, () => {
manager.focusContent();
}));
context.subscriptions.push(vscode.commands.registerCommand(openApiCommand, async (url: vscode.Uri, showOptions?: {
preserveFocus?: boolean;
viewColumn: vscode.ViewColumn;

View File

@ -38,6 +38,10 @@ export class SimpleBrowserManager {
this._activeView ??= view;
}
public focusContent(): void {
this._activeView?.focusContent();
}
private registerWebviewListeners(view: SimpleBrowserView) {
view.onDispose(() => {
if (this._activeView === view) {

View File

@ -110,6 +110,11 @@ export class SimpleBrowserView extends Disposable {
this._webviewPanel.reveal(options?.viewColumn, options?.preserveFocus);
}
public focusContent() {
this._webviewPanel.reveal(undefined, false);
this._webviewPanel.webview.postMessage({ type: 'focus' });
}
private getHtml(url: string) {
const configuration = vscode.workspace.getConfiguration('simpleBrowser');