提交 a9892200 编写于 作者: M Matt Bierner

Add title to webviewCreate

Part of #44579
上级 724217df
......@@ -300,6 +300,7 @@ class MarkdownPreview {
this.uri = vscode.Uri.parse(`${MarkdownPreview.previewScheme}:${MarkdownPreview.previewCount++}`);
this.webview = vscode.window.createWebview(
this.uri,
this.getPreviewTitle(this._resource),
previewColumn, {
enableScripts: true,
localResourceRoots: this.getLocalResourceRoots(_resource)
......
......@@ -555,10 +555,11 @@ declare module 'vscode' {
* Create and show a new webview.
*
* @param uri Unique identifier for the webview.
* @param title Title of the webview.
* @param column Editor column to show the new webview in.
* @param options Content settings for the webview.
*/
export function createWebview(uri: Uri, column: ViewColumn, options: WebviewOptions): Webview;
export function createWebview(uri: Uri, title: string, column: ViewColumn, options: WebviewOptions): Webview;
/**
* Event fired when the active editor changes.
......
......@@ -429,8 +429,8 @@ export class MainThreadWebviews implements MainThreadWebviewsShape {
this._toDispose = dispose(this._toDispose);
}
$createWebview(handle: WebviewHandle, uri: URI, options: vscode.WebviewOptions): void {
const webviewInput = WebviewInput.create(URI.revive(uri), '', options, '', {
$createWebview(handle: WebviewHandle, uri: URI, title: string, column: Position, options: vscode.WebviewOptions): void {
const webviewInput = WebviewInput.create(URI.revive(uri), title, options, '', {
onMessage: message => this._proxy.$onMessage(handle, message),
onDidChangePosition: position => this._proxy.$onDidChangePosition(handle, position),
onDispose: () => this._proxy.$onDidDisposeWeview(handle),
......@@ -438,6 +438,8 @@ export class MainThreadWebviews implements MainThreadWebviewsShape {
}, this._partService);
this._webviews.set(handle, webviewInput);
this._editorService.openEditor(webviewInput, { pinned: true }, column);
}
$disposeWebview(handle: WebviewHandle): void {
......
......@@ -405,8 +405,8 @@ export function createApiFactory(
registerDecorationProvider: proposedApiFunction(extension, (provider: vscode.DecorationProvider) => {
return extHostDecorations.registerDecorationProvider(provider, extension.id);
}),
createWebview: proposedApiFunction(extension, (uri: vscode.Uri, column: vscode.ViewColumn, options: vscode.WebviewOptions) => {
return extHostWebviews.createWebview(uri, column, options);
createWebview: proposedApiFunction(extension, (uri: vscode.Uri, title: string, column: vscode.ViewColumn, options: vscode.WebviewOptions) => {
return extHostWebviews.createWebview(uri, title, column, options);
}),
onDidChangeActiveEditor: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
return extHostDocumentsAndEditors.onDidChangeActiveEditor(listener, thisArg, disposables);
......
......@@ -345,7 +345,7 @@ export interface MainThreadTelemetryShape extends IDisposable {
export type WebviewHandle = number;
export interface MainThreadWebviewsShape extends IDisposable {
$createWebview(handle: WebviewHandle, uri: URI, options: vscode.WebviewOptions): void;
$createWebview(handle: WebviewHandle, uri: URI, title: string, column: EditorPosition, options: vscode.WebviewOptions): void;
$disposeWebview(handle: WebviewHandle): void;
$show(handle: WebviewHandle, column: EditorPosition): void;
$setTitle(handle: WebviewHandle, value: string): void;
......
......@@ -127,18 +127,15 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
createWebview(
uri: vscode.Uri,
title: string,
viewColumn: vscode.ViewColumn,
options: vscode.WebviewOptions
): vscode.Webview {
const handle = ExtHostWebviews.handlePool++;
if (!this._webviews.has(handle)) {
this._proxy.$createWebview(handle, uri, options);
this._proxy.$createWebview(handle, uri, title, typeConverters.fromViewColumn(viewColumn), options);
const webview = new ExtHostWebview(handle, this._proxy, uri, viewColumn, options);
this._webviews.set(handle, webview);
}
this._proxy.$show(handle, typeConverters.fromViewColumn(viewColumn));
const webview = new ExtHostWebview(handle, this._proxy, uri, viewColumn, options);
this._webviews.set(handle, webview);
return this._webviews.get(handle);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册