mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 02:26:04 +00:00
parent
e05609d5ec
commit
58a169f3f5
|
@ -12,10 +12,12 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
|
||||||
import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from './webviewEditor';
|
import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from './webviewEditor';
|
||||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindTermCommand, HideWebViewEditorFindCommand, OpenWebviewDeveloperToolsAction } from './webviewCommands';
|
import { ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindTermCommand, HideWebViewEditorFindCommand, OpenWebviewDeveloperToolsAction, ReloadWebviewAction } from './webviewCommands';
|
||||||
|
|
||||||
|
|
||||||
const category = 'Webview';
|
const category = 'Webview';
|
||||||
|
const webviewDeveloperCategory = nls.localize('developer', "Developer");
|
||||||
|
|
||||||
const actionRegistry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions);
|
const actionRegistry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions);
|
||||||
|
|
||||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetAction.ID, ShowWebViewEditorFindWidgetAction.LABEL, {
|
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetAction.ID, ShowWebViewEditorFindWidgetAction.LABEL, {
|
||||||
|
@ -58,4 +60,9 @@ KeybindingsRegistry.registerCommandAndKeybindingRule(hideCommand.toCommandAndKey
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
new SyncActionDescriptor(OpenWebviewDeveloperToolsAction, OpenWebviewDeveloperToolsAction.ID, OpenWebviewDeveloperToolsAction.LABEL),
|
new SyncActionDescriptor(OpenWebviewDeveloperToolsAction, OpenWebviewDeveloperToolsAction.ID, OpenWebviewDeveloperToolsAction.LABEL),
|
||||||
'Webview Tools',
|
'Webview Tools',
|
||||||
nls.localize('developer', "Developer"));
|
webviewDeveloperCategory);
|
||||||
|
|
||||||
|
actionRegistry.registerWorkbenchAction(
|
||||||
|
new SyncActionDescriptor(ReloadWebviewAction, ReloadWebviewAction.ID, ReloadWebviewAction.LABEL),
|
||||||
|
'Reload Webview',
|
||||||
|
webviewDeveloperCategory);
|
|
@ -33,6 +33,7 @@ export class Webview {
|
||||||
|
|
||||||
private _webviewFindWidget: WebviewFindWidget;
|
private _webviewFindWidget: WebviewFindWidget;
|
||||||
private _findStarted: boolean = false;
|
private _findStarted: boolean = false;
|
||||||
|
private _contents: string = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly parent: HTMLElement,
|
private readonly parent: HTMLElement,
|
||||||
|
@ -84,7 +85,6 @@ export class Webview {
|
||||||
|
|
||||||
const contents = this._webview.getWebContents();
|
const contents = this._webview.getWebContents();
|
||||||
this.registerFileProtocols(contents);
|
this.registerFileProtocols(contents);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +245,7 @@ export class Webview {
|
||||||
}
|
}
|
||||||
|
|
||||||
set contents(value: string) {
|
set contents(value: string) {
|
||||||
|
this._contents = value;
|
||||||
this._send('content', {
|
this._send('content', {
|
||||||
contents: value,
|
contents: value,
|
||||||
options: this._options
|
options: this._options
|
||||||
|
@ -406,6 +407,10 @@ export class Webview {
|
||||||
public showPreviousFindTerm() {
|
public showPreviousFindTerm() {
|
||||||
this._webviewFindWidget.showPreviousFindTerm();
|
this._webviewFindWidget.showPreviousFindTerm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public reload() {
|
||||||
|
this.contents = this._contents;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,4 +106,31 @@ export class OpenWebviewDeveloperToolsAction extends Action {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class ReloadWebviewAction extends Action {
|
||||||
|
static readonly ID = 'workbench.action.webview.reloadWebviewAction';
|
||||||
|
static LABEL = nls.localize('refreshWebviewLabel', "Reload Webviews");
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
@IWorkbenchEditorService private readonly workbenchEditorService: IWorkbenchEditorService
|
||||||
|
) {
|
||||||
|
super(id, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public run(): TPromise<any> {
|
||||||
|
for (const webview of this.getVisibleWebviews()) {
|
||||||
|
webview.reload();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getVisibleWebviews() {
|
||||||
|
return this.workbenchEditorService.getVisibleEditors()
|
||||||
|
.filter(c => c && (c as any).isWebviewEditor)
|
||||||
|
.map(e => e as WebviewEditor);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -84,6 +84,12 @@ export abstract class WebviewEditor extends BaseWebviewEditor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public reload() {
|
||||||
|
if (this._webview) {
|
||||||
|
this._webview.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract createEditor(parent: Builder): void;
|
protected abstract createEditor(parent: Builder): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue