diff --git a/src/vs/workbench/parts/html/browser/html.contribution.ts b/src/vs/workbench/parts/html/browser/html.contribution.ts index 8201c1cfe1d..cebedb5d247 100644 --- a/src/vs/workbench/parts/html/browser/html.contribution.ts +++ b/src/vs/workbench/parts/html/browser/html.contribution.ts @@ -17,7 +17,6 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { MenuRegistry } from 'vs/platform/actions/common/actions'; -import { WebviewElement } from 'vs/workbench/parts/html/browser/webview'; import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions'; import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor'; @@ -118,7 +117,7 @@ CommandsRegistry.registerCommand('_webview.openDevTools', function () { const elements = document.querySelectorAll('webview.ready'); for (let i = 0; i < elements.length; i++) { try { - (elements.item(i) as WebviewElement).openDevTools(); + (elements.item(i) as Electron.WebviewTag).openDevTools(); } catch (e) { console.error(e); } diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index da5b27f0b22..9b0aa8f243e 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -16,22 +16,6 @@ import { WebviewFindWidget } from './webviewFindWidget'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextKey } from 'vs/platform/contextkey/common/contextkey'; -export declare interface WebviewElement extends HTMLElement { - src: string; - preload: string; - send(channel: string, ...args: any[]); - openDevTools(): any; - getWebContents(): any; - findInPage(value: string, options?: WebviewElementFindInPageOptions); - stopFindInPage(action: string); -} - -export class StopFindInPageActions { - static clearSelection = 'clearSelection'; - static keepSelection = 'keepSelection'; - static activateSelection = 'activateSelection'; -} - export interface WebviewElementFindInPageOptions { forward?: boolean; findNext?: boolean; @@ -58,7 +42,7 @@ export interface WebviewOptions { export default class Webview { private static index: number = 0; - private _webview: WebviewElement; + private readonly _webview: Electron.WebviewTag; private _ready: TPromise; private _disposables: IDisposable[] = []; private _onDidClickLink = new Emitter(); @@ -70,14 +54,14 @@ export default class Webview { private _findStarted: boolean = false; constructor( - private parent: HTMLElement, - private _styleElement: Element, - @IContextViewService private _contextViewService: IContextViewService, - private _contextKey: IContextKey, - private _findInputContextKey: IContextKey, + private readonly parent: HTMLElement, + private readonly _styleElement: Element, + @IContextViewService private readonly _contextViewService: IContextViewService, + private readonly _contextKey: IContextKey, + private readonly _findInputContextKey: IContextKey, private _options: WebviewOptions = {}, ) { - this._webview = document.createElement('webview'); + this._webview = document.createElement('webview'); this._webview.setAttribute('partition', this._options.allowSvgs ? 'webview' : `webview${Webview.index++}`); // disable auxclick events (see https://developers.google.com/web/updates/2016/10/auxclick) @@ -119,7 +103,7 @@ export default class Webview { return; } - contents.session.webRequest.onBeforeRequest((details, callback) => { + (contents.session.webRequest as any).onBeforeRequest((details, callback) => { if (details.url.indexOf('.svg') > 0) { const uri = URI.parse(details.url); if (uri && !uri.scheme.match(/file/i) && (uri.path as any).endsWith('.svg') && !this.isAllowedSvg(uri)) { @@ -130,7 +114,7 @@ export default class Webview { return callback({}); }); - contents.session.webRequest.onHeadersReceived((details, callback) => { + (contents.session.webRequest as any).onHeadersReceived((details, callback) => { const contentType: string[] = (details.responseHeaders['content-type'] || details.responseHeaders['Content-Type']) as any; if (contentType && Array.isArray(contentType) && contentType.some(x => x.toLowerCase().indexOf('image/svg') >= 0)) { const uri = URI.parse(details.url); @@ -295,7 +279,6 @@ export default class Webview { styles['scrollbar-thumb-hover'] = 'rgba(100, 100, 100, 0.7)'; styles['scrollbar-thumb-active'] = 'rgba(85, 85, 85, 0.8)'; activeTheme = 'vscode-dark'; - } else { styles['scrollbar-thumb'] = 'rgba(111, 195, 223, 0.3)'; styles['scrollbar-thumb-hover'] = 'rgba(111, 195, 223, 0.8)'; @@ -392,7 +375,7 @@ export default class Webview { public stopFind(keepSelection?: boolean): void { this._findStarted = false; - this._webview.stopFindInPage(keepSelection ? StopFindInPageActions.keepSelection : StopFindInPageActions.clearSelection); + this._webview.stopFindInPage(keepSelection ? 'keepSelection' : 'clearSelection'); } public showFind() {