提交 dd5ab7d8 编写于 作者: R rebornix

vs loader in webview

上级 15d93779
......@@ -9,6 +9,9 @@ import * as DOM from 'vs/base/browser/dom';
import * as UUID from 'vs/base/common/uuid';
import { Disposable } from 'vs/base/common/lifecycle';
import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { URI } from 'vs/base/common/uri';
import { WebviewResourceScheme } from 'vs/workbench/contrib/webview/common/resourceLoader';
export interface IDimentionMessage {
......@@ -64,7 +67,7 @@ export class BackLayerWebView extends Disposable {
public mapping: Map<string, { cell: ViewCell, offset: number, top: number }> = new Map();
public outputMapping: Map<string, boolean> = new Map();
constructor(public webviewService: IWebviewService, public notebookService: INotebookService, public notebookHandler: NotebookHandler) {
constructor(public webviewService: IWebviewService, public notebookService: INotebookService, public notebookHandler: NotebookHandler, public environmentSerice: IEnvironmentService) {
super();
this.element = document.createElement('div');
......@@ -73,6 +76,8 @@ export class BackLayerWebView extends Disposable {
this.element.style.position = 'absolute';
this.element.style.margin = '0px 0 0px 24px';
const loader = URI.parse(environmentSerice.appRoot + '/out/vs/loader.js').with({ scheme: WebviewResourceScheme });
let content = /* html */`
<html lang="en">
<head>
......@@ -87,6 +92,10 @@ export class BackLayerWebView extends Disposable {
</style>
</head>
<body style="overflow: hidden;">
<script>
self.require = {};
</script>
<script src="${loader}"></script>
<div id='container' class="widgetarea" style="position: absolute;width:100%;"></div>
<script>
(function () {
......@@ -243,7 +252,7 @@ export class BackLayerWebView extends Disposable {
enableFindWidget: false,
}, {
allowScripts: true,
localResourceRoots: this.notebookService.getNotebookProviderResourceRoots()
localResourceRoots: [...this.notebookService.getNotebookProviderResourceRoots(), URI.parse(this.environmentSerice.appRoot)]
});
webview.html = content;
return webview;
......
......@@ -29,6 +29,7 @@ import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { getZoomLevel } from 'vs/base/browser/browser';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
const $ = DOM.$;
const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState';
......@@ -63,7 +64,8 @@ export class NotebookEditor extends BaseEditor implements NotebookHandler {
@IWebviewService private webviewService: IWebviewService,
@INotebookService private notebookService: INotebookService,
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@IEnvironmentService private readonly environmentSerice: IEnvironmentService
) {
super(NotebookEditor.ID, telemetryService, themeService, storageService);
......@@ -141,7 +143,7 @@ export class NotebookEditor extends BaseEditor implements NotebookHandler {
}
);
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this);
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this, this.environmentSerice);
this.list.view.rowsContainer.appendChild(this.webview.element);
this._register(this.list);
}
......@@ -236,7 +238,7 @@ export class NotebookEditor extends BaseEditor implements NotebookHandler {
if (this.webview) {
this.webview?.clearContentWidgets();
} else {
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this);
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this, this.environmentSerice);
this.list?.view.rowsContainer.insertAdjacentElement('afterbegin', this.webview!.element);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册