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

Set the base url to be the resource url instead of the workspace root. #29191

上级 a5c3f024
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
'use strict'; 'use strict';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { IModel } from 'vs/editor/common/editorCommon'; import { IModel } from 'vs/editor/common/editorCommon';
import { Dimension, Builder } from 'vs/base/browser/builder'; import { Dimension, Builder } from 'vs/base/browser/builder';
...@@ -14,7 +13,6 @@ import { empty as EmptyDisposable, IDisposable, dispose, IReference } from 'vs/b ...@@ -14,7 +13,6 @@ import { empty as EmptyDisposable, IDisposable, dispose, IReference } from 'vs/b
import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; import { EditorOptions, EditorInput } from 'vs/workbench/common/editor';
import { Position } from 'vs/platform/editor/common/editor'; import { Position } from 'vs/platform/editor/common/editor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel'; import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel';
import { HtmlInput } from 'vs/workbench/parts/html/common/htmlInput'; import { HtmlInput } from 'vs/workbench/parts/html/common/htmlInput';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
...@@ -37,8 +35,6 @@ export class HtmlPreviewPart extends WebviewEditor { ...@@ -37,8 +35,6 @@ export class HtmlPreviewPart extends WebviewEditor {
private _webviewDisposables: IDisposable[]; private _webviewDisposables: IDisposable[];
private _container: HTMLDivElement; private _container: HTMLDivElement;
private _baseUrl: URI;
private _modelRef: IReference<ITextEditorModel>; private _modelRef: IReference<ITextEditorModel>;
public get model(): IModel { return this._modelRef && this._modelRef.object.textEditorModel; } public get model(): IModel { return this._modelRef && this._modelRef.object.textEditorModel; }
private _modelChangeSubscription = EmptyDisposable; private _modelChangeSubscription = EmptyDisposable;
...@@ -50,14 +46,11 @@ export class HtmlPreviewPart extends WebviewEditor { ...@@ -50,14 +46,11 @@ export class HtmlPreviewPart extends WebviewEditor {
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@ITextModelService private textModelResolverService: ITextModelService, @ITextModelService private textModelResolverService: ITextModelService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IOpenerService private openerService: IOpenerService, @IOpenerService private readonly openerService: IOpenerService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IPartService private partService: IPartService, @IPartService private partService: IPartService,
@IStorageService storageService: IStorageService @IStorageService storageService: IStorageService
) { ) {
super(HtmlPreviewPart.ID, telemetryService, themeService, storageService); super(HtmlPreviewPart.ID, telemetryService, themeService, storageService);
this._baseUrl = contextService.toResource('/');
} }
dispose(): void { dispose(): void {
...@@ -82,11 +75,13 @@ export class HtmlPreviewPart extends WebviewEditor { ...@@ -82,11 +75,13 @@ export class HtmlPreviewPart extends WebviewEditor {
private get webview(): Webview { private get webview(): Webview {
if (!this._webview) { if (!this._webview) {
this._webview = new Webview(this._container, this.partService.getContainer(Parts.EDITOR_PART), { enableJavascript: true }); this._webview = new Webview(this._container, this.partService.getContainer(Parts.EDITOR_PART), { enableJavascript: true });
this._webview.baseUrl = this._baseUrl && this._baseUrl.toString(true);
if (this.input && this.input instanceof HtmlInput) { if (this.input && this.input instanceof HtmlInput) {
const state = this.loadViewState(this.input.getResource()); const state = this.loadViewState(this.input.getResource());
this.scrollYPercentage = state ? state.scrollYPercentage : 0; this.scrollYPercentage = state ? state.scrollYPercentage : 0;
this.webview.initialScrollProgress = this.scrollYPercentage; this.webview.initialScrollProgress = this.scrollYPercentage;
const resourceUri = this.input.getResource();
this.webview.baseUrl = resourceUri.toString(true);
} }
this._webviewDisposables = [ this._webviewDisposables = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册