diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 2c8a4b446b0..d6008024b92 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -1396,6 +1396,24 @@ export interface WorkspaceCommentProvider { onDidChangeCommentThreads(): Event; } +/** + * @internal + */ +export interface IWebviewOptions { + readonly enableScripts?: boolean; + readonly enableCommandUris?: boolean; + readonly localResourceRoots?: ReadonlyArray; + readonly portMapping?: ReadonlyArray<{ port: number, resolvedPort: number }>; +} + +/** + * @internal + */ +export interface IWebviewPanelOptions { + readonly enableFindWidget?: boolean; + readonly retainContextWhenHidden?: boolean; +} + export interface ICodeLensSymbol { range: IRange; id?: string; diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 22f06f004e6..7ce7fb2eb6f 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -504,27 +504,16 @@ export interface WebviewPanelShowOptions { readonly preserveFocus?: boolean; } -export interface IWebviewPanelOptions { - readonly enableFindWidget?: boolean; - readonly retainContextWhenHidden?: boolean; -} - -export interface IWebviewOptions { - readonly enableScripts?: boolean; - readonly enableCommandUris?: boolean; - readonly localResourceRoots?: ReadonlyArray; -} - export interface MainThreadWebviewsShape extends IDisposable { - $createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: IWebviewPanelOptions & IWebviewOptions, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void; - $createWebviewCodeInset(handle: WebviewInsetHandle, symbolId: string, options: IWebviewOptions, extensionLocation: UriComponents | undefined): void; + $createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: modes.IWebviewPanelOptions & modes.IWebviewOptions, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void; + $createWebviewCodeInset(handle: WebviewInsetHandle, symbolId: string, options: modes.IWebviewOptions, extensionLocation: UriComponents | undefined): void; $disposeWebview(handle: WebviewPanelHandle): void; $reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void; $setTitle(handle: WebviewPanelHandle, value: string): void; $setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void; $setHtml(handle: WebviewPanelHandle | WebviewInsetHandle, value: string): void; - $setOptions(handle: WebviewPanelHandle | WebviewInsetHandle, options: IWebviewOptions): void; + $setOptions(handle: WebviewPanelHandle | WebviewInsetHandle, options: modes.IWebviewOptions): void; $postMessage(handle: WebviewPanelHandle | WebviewInsetHandle, value: any): Promise; $registerSerializer(viewType: string): void; @@ -541,7 +530,7 @@ export interface ExtHostWebviewsShape { $onMessage(handle: WebviewPanelHandle, message: any): void; $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, newState: WebviewPanelViewState): void; $onDidDisposeWebviewPanel(handle: WebviewPanelHandle): Promise; - $deserializeWebviewPanel(newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorViewColumn, options: IWebviewOptions): Promise; + $deserializeWebviewPanel(newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorViewColumn, options: modes.IWebviewOptions): Promise; } export interface MainThreadUrlsShape extends IDisposable { diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index fa937a25591..a16e2ddd5c7 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -13,7 +13,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewInsetHandle, WebviewPanelHandle, WebviewPanelShowOptions, IWebviewOptions } from 'vs/workbench/api/common/extHost.protocol'; +import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewInsetHandle, WebviewPanelHandle, WebviewPanelShowOptions } from 'vs/workbench/api/common/extHost.protocol'; import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor'; import { CodeInsetController } from 'vs/workbench/contrib/codeinset/electron-browser/codeInset.contribution'; import { WebviewEditor } from 'vs/workbench/contrib/webview/electron-browser/webviewEditor'; @@ -25,6 +25,7 @@ import { ACTIVE_GROUP, IEditorService } from 'vs/workbench/services/editor/commo import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService'; import { extHostNamedCustomer } from '../common/extHostCustomers'; +import { IWebviewOptions } from 'vs/editor/common/modes'; @extHostNamedCustomer(MainContext.MainThreadWebviews) export class MainThreadWebviews extends Disposable implements MainThreadWebviewsShape { diff --git a/src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts b/src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts index 3ac966a7057..93b7532ed29 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts @@ -9,9 +9,8 @@ import { URI } from 'vs/base/common/uri'; import { IEditorModel } from 'vs/platform/editor/common/editor'; import { EditorInput, EditorModel, GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor'; import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService'; -import * as vscode from 'vscode'; import { WebviewEvents, WebviewInputOptions } from './webviewEditorService'; -import { WebviewElement } from './webviewElement'; +import { WebviewElement, WebviewOptions } from './webviewElement'; export class WebviewEditorInput extends EditorInput { private static handlePool = 0; @@ -195,7 +194,7 @@ export class WebviewEditorInput extends EditorInput { return this._options; } - public setOptions(value: vscode.WebviewOptions) { + public setOptions(value: WebviewOptions) { this._options = { ...this._options, ...value diff --git a/src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts b/src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts index 2ebaa192575..a7917fcf632 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts @@ -11,8 +11,8 @@ import { createDecorator, IInstantiationService } from 'vs/platform/instantiatio import { GroupIdentifier } from 'vs/workbench/common/editor'; import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP_TYPE } from 'vs/workbench/services/editor/common/editorService'; -import * as vscode from 'vscode'; import { RevivedWebviewEditorInput, WebviewEditorInput } from './webviewEditorInput'; +import { IWebviewOptions, IWebviewPanelOptions } from 'vs/editor/common/modes'; export const IWebviewEditorService = createDecorator('webviewEditorService'); @@ -72,10 +72,10 @@ export interface WebviewReviver { export interface WebviewEvents { onMessage?(message: any): void; onDispose?(): void; - onDidClickLink?(link: URI, options: vscode.WebviewOptions): void; + onDidClickLink?(link: URI, options: IWebviewOptions): void; } -export interface WebviewInputOptions extends vscode.WebviewOptions, vscode.WebviewPanelOptions { +export interface WebviewInputOptions extends IWebviewOptions, IWebviewPanelOptions { tryRestoreScrollPosition?: boolean; } @@ -129,7 +129,7 @@ export class WebviewEditorService implements IWebviewEditorService { viewType: string, title: string, showOptions: ICreateWebViewShowOptions, - options: vscode.WebviewOptions, + options: IWebviewOptions, extensionLocation: URI | undefined, events: WebviewEvents ): WebviewEditorInput {