mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
Move webview content state into webviewPanel instead of webviewEditor
Split out from #77131 The current webview editor api is very procedural. This model has some problems when it comes to supporting editing resources, but actually does make a lot of sense for webviews that aren't backed by real file system resources. For example, if you have a webview that edits some document in the cloud, you should not be required to implement a custom file system provider just to enable basic saving. This change moves the `onWillSave` and `webviewEditorState` properties back onto `WebviewPanel` instead of keeping them specific to `WebviewEditor`. The save implementation does not fully work yet, as the will require #81521
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 }>();
|
||||
|
||||
Reference in New Issue
Block a user