@@ -21,6 +21,8 @@ import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookS
2121import { IWebviewService , WebviewElement } from 'vs/workbench/contrib/webview/browser/webview' ;
2222import { asWebviewUri } from 'vs/workbench/contrib/webview/common/webviewUri' ;
2323import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
24+ import { dirname } from 'vs/base/common/resources' ;
25+ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
2426
2527export interface IDimensionMessage {
2628 __vscode_notebook_message : boolean ;
@@ -144,10 +146,12 @@ export class BackLayerWebView extends Disposable {
144146 constructor (
145147 public notebookEditor : INotebookEditor ,
146148 public id : string ,
149+ public documentUri : URI ,
147150 @IWebviewService readonly webviewService : IWebviewService ,
148151 @IOpenerService readonly openerService : IOpenerService ,
149152 @INotebookService private readonly notebookService : INotebookService ,
150153 @IEnvironmentService private readonly environmentService : IEnvironmentService ,
154+ @IWorkspaceContextService private readonly contextService : IWorkspaceContextService ,
151155 @IWorkbenchEnvironmentService private readonly workbenchEnvironmentService : IWorkbenchEnvironmentService ,
152156 ) {
153157 super ( ) ;
@@ -168,9 +172,11 @@ export class BackLayerWebView extends Disposable {
168172 resolveFunc = resolve ;
169173 } ) ;
170174
175+ const baseUrl = asWebviewUri ( this . workbenchEnvironmentService , this . id , dirname ( documentUri ) ) ;
176+
171177 if ( ! isWeb ) {
172178 coreDependencies = `<script src="${ loader } "></script>` ;
173- const htmlContent = this . generateContent ( 8 , coreDependencies ) ;
179+ const htmlContent = this . generateContent ( 8 , coreDependencies , baseUrl . toString ( ) ) ;
174180 this . initialize ( htmlContent ) ;
175181 resolveFunc ! ( ) ;
176182 } else {
@@ -186,18 +192,20 @@ export class BackLayerWebView extends Disposable {
186192${ loaderJs }
187193</script>
188194` ;
189- const htmlContent = this . generateContent ( 8 , coreDependencies ) ;
195+
196+ const htmlContent = this . generateContent ( 8 , coreDependencies , baseUrl . toString ( ) ) ;
190197 this . initialize ( htmlContent ) ;
191198 resolveFunc ! ( ) ;
192199 } ) ;
193200 }
194201 }
195202
196- generateContent ( outputNodePadding : number , coreDependencies : string ) {
203+ generateContent ( outputNodePadding : number , coreDependencies : string , baseUrl : string ) {
197204 return html `
198205 < html lang ="en ">
199206 < head >
200207 < meta charset ="UTF-8 ">
208+ < base url ="${ baseUrl } / "/>
201209 < style >
202210 # container > div > div {
203211 width : 100% ;
@@ -565,7 +573,9 @@ ${loaderJs}
565573
566574 private _createInset ( webviewService : IWebviewService , content : string ) {
567575 const rootPath = URI . file ( path . dirname ( getPathFromAmdModule ( require , '' ) ) ) ;
568- this . localResourceRootsCache = [ ...this . notebookService . getNotebookProviderResourceRoots ( ) , rootPath ] ;
576+ const workspaceFolders = this . contextService . getWorkspace ( ) . folders . map ( x => x . uri ) ;
577+
578+ this . localResourceRootsCache = [ ...this . notebookService . getNotebookProviderResourceRoots ( ) , ...workspaceFolders , rootPath ] ;
569579
570580 const webview = webviewService . createWebviewElement ( this . id , {
571581 enableFindWidget : false ,
0 commit comments