mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 00:59:03 +01:00
WebviewEditorInput -> WebviewInput
This commit is contained in:
@@ -16,7 +16,7 @@ import { IProductService } from 'vs/platform/product/common/product';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelShowOptions, WebviewPanelViewStateData } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
|
||||
import { WebviewEditorInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
|
||||
import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
|
||||
import { ICreateWebViewShowOptions, IWebviewEditorService, WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewEditorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -28,19 +28,19 @@ import { CustomFileEditorInput } from 'vs/workbench/contrib/customEditor/browser
|
||||
* Bi-directional map between webview handles and inputs.
|
||||
*/
|
||||
class WebviewHandleStore {
|
||||
private readonly _handlesToInputs = new Map<string, WebviewEditorInput>();
|
||||
private readonly _inputsToHandles = new Map<WebviewEditorInput, string>();
|
||||
private readonly _handlesToInputs = new Map<string, WebviewInput>();
|
||||
private readonly _inputsToHandles = new Map<WebviewInput, string>();
|
||||
|
||||
public add(handle: string, input: WebviewEditorInput): void {
|
||||
public add(handle: string, input: WebviewInput): void {
|
||||
this._handlesToInputs.set(handle, input);
|
||||
this._inputsToHandles.set(input, handle);
|
||||
}
|
||||
|
||||
public getHandleForInput(input: WebviewEditorInput): string | undefined {
|
||||
public getHandleForInput(input: WebviewInput): string | undefined {
|
||||
return this._inputsToHandles.get(input);
|
||||
}
|
||||
|
||||
public getInputForHandle(handle: string): WebviewEditorInput | undefined {
|
||||
public getInputForHandle(handle: string): WebviewInput | undefined {
|
||||
return this._handlesToInputs.get(handle);
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
// This reviver's only job is to activate webview panel extensions
|
||||
// This should trigger the real reviver to be registered from the extension host side.
|
||||
this._register(_webviewEditorService.registerResolver({
|
||||
canResolve: (webview: WebviewEditorInput) => {
|
||||
if (!webview.webview.state && webview.getTypeId() === WebviewEditorInput.typeId) { // TODO: The typeid check is a workaround for the CustomFileEditorInput case
|
||||
canResolve: (webview: WebviewInput) => {
|
||||
if (!webview.webview.state && webview.getTypeId() === WebviewInput.typeId) { // TODO: The typeid check is a workaround for the CustomFileEditorInput case
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
|
||||
this._editorProviders.set(viewType, this._webviewEditorService.registerResolver({
|
||||
canResolve: (webviewEditorInput) => {
|
||||
return webviewEditorInput.getTypeId() !== WebviewEditorInput.typeId && webviewEditorInput.viewType === viewType;
|
||||
return webviewEditorInput.getTypeId() !== WebviewInput.typeId && webviewEditorInput.viewType === viewType;
|
||||
},
|
||||
resolveWebview: async (webview) => {
|
||||
const handle = `resolved-${MainThreadWebviews.revivalPool++}`;
|
||||
@@ -292,7 +292,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
return viewType.replace(/^mainThreadWebview-/, '');
|
||||
}
|
||||
|
||||
private hookupWebviewEventDelegate(handle: WebviewPanelHandle, input: WebviewEditorInput) {
|
||||
private hookupWebviewEventDelegate(handle: WebviewPanelHandle, input: WebviewInput) {
|
||||
input.webview.onDidClickLink((uri: URI) => this.onDidClickLink(handle, uri));
|
||||
input.webview.onMessage((message: any) => this._proxy.$onMessage(handle, message));
|
||||
input.onDispose(() => {
|
||||
@@ -319,7 +319,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
const viewStates: WebviewPanelViewStateData = {};
|
||||
for (const group of this._editorGroupService.groups) {
|
||||
for (const input of group.editors) {
|
||||
if (!(input instanceof WebviewEditorInput)) {
|
||||
if (!(input instanceof WebviewInput)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
}
|
||||
}
|
||||
|
||||
private isSupportedLink(webview: WebviewEditorInput, link: URI): boolean {
|
||||
private isSupportedLink(webview: WebviewInput, link: URI): boolean {
|
||||
if (MainThreadWebviews.standardSupportedLinkSchemes.has(link.scheme)) {
|
||||
return true;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
return !!webview.webview.contentOptions.enableCommandUris && link.scheme === 'command';
|
||||
}
|
||||
|
||||
private getWebviewEditorInput(handle: WebviewPanelHandle): WebviewEditorInput {
|
||||
private getWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput {
|
||||
const webview = this.tryGetWebviewEditorInput(handle);
|
||||
if (!webview) {
|
||||
throw new Error('Unknown webview handle:' + handle);
|
||||
@@ -366,7 +366,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
|
||||
return webview;
|
||||
}
|
||||
|
||||
private tryGetWebviewEditorInput(handle: WebviewPanelHandle): WebviewEditorInput | undefined {
|
||||
private tryGetWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput | undefined {
|
||||
return this._webviewEditorInputs.getInputForHandle(handle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user