mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:04:14 +08:00
Merge 4fad82e94d9963d185c58ae526dbe0afe79efcee into e40a68f409d79d8699d4d2d72c9d3dcc95b78abd
This commit is contained in:
commit
7d7d7e7dc9
@ -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'"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -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."
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user