mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 (#7404)
* Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 * readd svgs
This commit is contained in:
@@ -13,7 +13,7 @@ import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { asWebviewUri, WebviewInitData } from 'vs/workbench/api/common/shared/webview';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewStateData } from './extHost.protocol';
|
||||
import { Disposable, WebviewEditorState } from './extHostTypes';
|
||||
import { Disposable, WebviewContentState } from './extHostTypes';
|
||||
|
||||
type IconPath = URI | { light: URI, dark: URI };
|
||||
|
||||
@@ -93,7 +93,9 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
|
||||
private _viewColumn: vscode.ViewColumn | undefined;
|
||||
private _visible: boolean = true;
|
||||
private _active: boolean = true;
|
||||
private _state = WebviewEditorState.Readonly;
|
||||
private _state: vscode.WebviewEditorState = {
|
||||
contentState: WebviewContentState.Readonly,
|
||||
};
|
||||
|
||||
_isDisposed: boolean = false;
|
||||
|
||||
@@ -103,7 +105,6 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
|
||||
readonly _onDidChangeViewStateEmitter = new Emitter<vscode.WebviewPanelOnDidChangeViewStateEvent>();
|
||||
public readonly onDidChangeViewState: Event<vscode.WebviewPanelOnDidChangeViewStateEvent> = this._onDidChangeViewStateEmitter.event;
|
||||
|
||||
|
||||
constructor(
|
||||
handle: WebviewPanelHandle,
|
||||
proxy: MainThreadWebviewsShape,
|
||||
@@ -214,13 +215,13 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
|
||||
this._visible = value;
|
||||
}
|
||||
|
||||
public get state(): vscode.WebviewEditorState {
|
||||
public get editorState(): vscode.WebviewEditorState {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
public set state(newState: vscode.WebviewEditorState) {
|
||||
public set editorState(newState: vscode.WebviewEditorState) {
|
||||
this._state = newState;
|
||||
this._proxy.$setState(this._handle, typeConverters.WebviewEditorState.from(newState));
|
||||
this._proxy.$setState(this._handle, typeConverters.WebviewContentState.from(newState.contentState));
|
||||
}
|
||||
|
||||
private readonly _onWillSave = new Emitter<{ waitUntil: (thenable: Thenable<boolean>) => void }>();
|
||||
@@ -264,7 +265,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
private readonly _proxy: MainThreadWebviewsShape;
|
||||
private readonly _webviewPanels = new Map<WebviewPanelHandle, ExtHostWebviewEditor>();
|
||||
private readonly _serializers = new Map<string, vscode.WebviewPanelSerializer>();
|
||||
private readonly _editorProviders = new Map<string, vscode.WebviewEditorProvider>();
|
||||
private readonly _editorProviders = new Map<string, { readonly provider: vscode.WebviewEditorProvider, readonly extension: IExtensionDescription }>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext,
|
||||
@@ -313,14 +314,15 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
}
|
||||
|
||||
public registerWebviewEditorProvider(
|
||||
extension: IExtensionDescription,
|
||||
viewType: string,
|
||||
provider: vscode.WebviewEditorProvider
|
||||
provider: vscode.WebviewEditorProvider,
|
||||
): vscode.Disposable {
|
||||
if (this._editorProviders.has(viewType)) {
|
||||
throw new Error(`Editor provider for '${viewType}' already registered`);
|
||||
}
|
||||
|
||||
this._editorProviders.set(viewType, provider);
|
||||
this._editorProviders.set(viewType, { extension, provider, });
|
||||
this._proxy.$registerEditorProvider(viewType);
|
||||
|
||||
return new Disposable(() => {
|
||||
@@ -415,21 +417,24 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
|
||||
async $resolveWebviewEditor(
|
||||
resource: UriComponents,
|
||||
webviewHandle: WebviewPanelHandle,
|
||||
handle: WebviewPanelHandle,
|
||||
viewType: string,
|
||||
title: string,
|
||||
state: any,
|
||||
position: EditorViewColumn,
|
||||
options: modes.IWebviewOptions & modes.IWebviewPanelOptions
|
||||
): Promise<void> {
|
||||
const provider = this._editorProviders.get(viewType);
|
||||
if (!provider) {
|
||||
const entry = this._editorProviders.get(viewType);
|
||||
if (!entry) {
|
||||
return Promise.reject(new Error(`No provider found for '${viewType}'`));
|
||||
}
|
||||
const { provider, extension } = entry;
|
||||
|
||||
const webview = new ExtHostWebview(webviewHandle, this._proxy, options, this.initData);
|
||||
const revivedPanel = new ExtHostWebviewEditor(webviewHandle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
|
||||
this._webviewPanels.set(webviewHandle, revivedPanel);
|
||||
this._proxy.$setExtension(handle, extension.identifier, extension.extensionLocation);
|
||||
|
||||
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData);
|
||||
const revivedPanel = new ExtHostWebviewEditor(handle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
|
||||
this._webviewPanels.set(handle, revivedPanel);
|
||||
return Promise.resolve(provider.resolveWebviewEditor(URI.revive(resource), revivedPanel));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user