mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
Use viewType instead of uri for webviews
As discussed in #45994, move from using a uri to using a viewType. The view type is shared among all webviews of a given type, such as all markdown previews Fixes #44575
This commit is contained in:
@@ -413,8 +413,8 @@ export function createApiFactory(
|
||||
registerDecorationProvider: proposedApiFunction(extension, (provider: vscode.DecorationProvider) => {
|
||||
return extHostDecorations.registerDecorationProvider(provider, extension.id);
|
||||
}),
|
||||
createWebview: proposedApiFunction(extension, (uri: vscode.Uri, title: string, column: vscode.ViewColumn, options: vscode.WebviewOptions) => {
|
||||
return extHostWebviews.createWebview(uri, title, column, options, extension.extensionFolderPath);
|
||||
createWebview: proposedApiFunction(extension, (viewType: string, title: string, column: vscode.ViewColumn, options: vscode.WebviewOptions) => {
|
||||
return extHostWebviews.createWebview(viewType, title, column, options, extension.extensionFolderPath);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ export interface MainThreadTelemetryShape extends IDisposable {
|
||||
export type WebviewHandle = number;
|
||||
|
||||
export interface MainThreadWebviewsShape extends IDisposable {
|
||||
$createWebview(handle: WebviewHandle, uri: URI, title: string, column: EditorPosition, options: vscode.WebviewOptions, extensionFolderPath: string): void;
|
||||
$createWebview(handle: WebviewHandle, viewType: string, title: string, column: EditorPosition, options: vscode.WebviewOptions, extensionFolderPath: string): void;
|
||||
$disposeWebview(handle: WebviewHandle): void;
|
||||
$show(handle: WebviewHandle, column: EditorPosition): void;
|
||||
$setTitle(handle: WebviewHandle, value: string): void;
|
||||
|
||||
@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
export class ExtHostWebview implements vscode.Webview {
|
||||
|
||||
private readonly _viewType: string;
|
||||
private _title: string;
|
||||
private _html: string;
|
||||
private _options: vscode.WebviewOptions;
|
||||
@@ -31,10 +32,11 @@ export class ExtHostWebview implements vscode.Webview {
|
||||
constructor(
|
||||
private readonly _handle: WebviewHandle,
|
||||
private readonly _proxy: MainThreadWebviewsShape,
|
||||
private readonly _uri: vscode.Uri,
|
||||
viewType: string,
|
||||
viewColumn: vscode.ViewColumn,
|
||||
options: vscode.WebviewOptions
|
||||
) {
|
||||
this._viewType = viewType;
|
||||
this._viewColumn = viewColumn;
|
||||
this._options = options;
|
||||
}
|
||||
@@ -52,9 +54,9 @@ export class ExtHostWebview implements vscode.Webview {
|
||||
this.onDidChangeViewStateEmitter.dispose();
|
||||
}
|
||||
|
||||
get uri(): vscode.Uri {
|
||||
get viewType(): string {
|
||||
this.assertNotDisposed();
|
||||
return this._uri;
|
||||
return this._viewType;
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
@@ -141,16 +143,16 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
}
|
||||
|
||||
createWebview(
|
||||
uri: vscode.Uri,
|
||||
viewType: string,
|
||||
title: string,
|
||||
viewColumn: vscode.ViewColumn,
|
||||
options: vscode.WebviewOptions,
|
||||
extensionFolderPath: string
|
||||
): vscode.Webview {
|
||||
const handle = ExtHostWebviews.handlePool++;
|
||||
this._proxy.$createWebview(handle, uri, title, typeConverters.fromViewColumn(viewColumn), options, extensionFolderPath);
|
||||
this._proxy.$createWebview(handle, viewType, title, typeConverters.fromViewColumn(viewColumn), options, extensionFolderPath);
|
||||
|
||||
const webview = new ExtHostWebview(handle, this._proxy, uri, viewColumn, options);
|
||||
const webview = new ExtHostWebview(handle, this._proxy, viewType, viewColumn, options);
|
||||
this._webviews.set(handle, webview);
|
||||
return webview;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user