@@ -21,6 +21,8 @@ import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookS
21
21
import { IWebviewService , WebviewElement } from 'vs/workbench/contrib/webview/browser/webview' ;
22
22
import { asWebviewUri } from 'vs/workbench/contrib/webview/common/webviewUri' ;
23
23
import { 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' ;
24
26
25
27
export interface IDimensionMessage {
26
28
__vscode_notebook_message : boolean ;
@@ -144,10 +146,12 @@ export class BackLayerWebView extends Disposable {
144
146
constructor (
145
147
public notebookEditor : INotebookEditor ,
146
148
public id : string ,
149
+ public documentUri : URI ,
147
150
@IWebviewService readonly webviewService : IWebviewService ,
148
151
@IOpenerService readonly openerService : IOpenerService ,
149
152
@INotebookService private readonly notebookService : INotebookService ,
150
153
@IEnvironmentService private readonly environmentService : IEnvironmentService ,
154
+ @IWorkspaceContextService private readonly contextService : IWorkspaceContextService ,
151
155
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService : IWorkbenchEnvironmentService ,
152
156
) {
153
157
super ( ) ;
@@ -168,9 +172,11 @@ export class BackLayerWebView extends Disposable {
168
172
resolveFunc = resolve ;
169
173
} ) ;
170
174
175
+ const baseUrl = asWebviewUri ( this . workbenchEnvironmentService , this . id , dirname ( documentUri ) ) ;
176
+
171
177
if ( ! isWeb ) {
172
178
coreDependencies = `<script src="${ loader } "></script>` ;
173
- const htmlContent = this . generateContent ( 8 , coreDependencies ) ;
179
+ const htmlContent = this . generateContent ( 8 , coreDependencies , baseUrl . toString ( ) ) ;
174
180
this . initialize ( htmlContent ) ;
175
181
resolveFunc ! ( ) ;
176
182
} else {
@@ -186,18 +192,20 @@ export class BackLayerWebView extends Disposable {
186
192
${ loaderJs }
187
193
</script>
188
194
` ;
189
- const htmlContent = this . generateContent ( 8 , coreDependencies ) ;
195
+
196
+ const htmlContent = this . generateContent ( 8 , coreDependencies , baseUrl . toString ( ) ) ;
190
197
this . initialize ( htmlContent ) ;
191
198
resolveFunc ! ( ) ;
192
199
} ) ;
193
200
}
194
201
}
195
202
196
- generateContent ( outputNodePadding : number , coreDependencies : string ) {
203
+ generateContent ( outputNodePadding : number , coreDependencies : string , baseUrl : string ) {
197
204
return html `
198
205
< html lang ="en ">
199
206
< head >
200
207
< meta charset ="UTF-8 ">
208
+ < base url ="${ baseUrl } / "/>
201
209
< style >
202
210
# container > div > div {
203
211
width : 100% ;
@@ -565,7 +573,9 @@ ${loaderJs}
565
573
566
574
private _createInset ( webviewService : IWebviewService , content : string ) {
567
575
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 ] ;
569
579
570
580
const webview = webviewService . createWebviewElement ( this . id , {
571
581
enableFindWidget : false ,
0 commit comments