File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change
1
+ Ensure images in workspace folder are supported within markdown cells in a ` Notebook ` .
Original file line number Diff line number Diff line change @@ -1094,6 +1094,11 @@ export interface IWebPanelOptions {
1094
1094
listener : IWebPanelMessageListener ;
1095
1095
title : string ;
1096
1096
rootPath : string ;
1097
+ /**
1098
+ * Additional paths apart from cwd and rootPath, that webview would allow loading resources/files from.
1099
+ * E.g. required for webview to serve images from worksapces when nb is in a nested folder.
1100
+ */
1101
+ additionalPaths ?: string [ ] ;
1097
1102
scripts : string [ ] ;
1098
1103
startHttpServer : boolean ;
1099
1104
cwd : string ;
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ export class WebPanelProvider implements IWebPanelProvider {
30
30
// Allow loading resources from the `<extension folder>/tmp` folder when in webiviews.
31
31
// Used by widgets to place files that are not otherwise accessible.
32
32
const additionalRootPaths = [ Uri . file ( path . join ( this . context . extensionPath , 'tmp' ) ) ] ;
33
+ if ( Array . isArray ( options . additionalPaths ) ) {
34
+ additionalRootPaths . push ( ...options . additionalPaths . map ( ( item ) => Uri . file ( item ) ) ) ;
35
+ }
33
36
return new WebPanel (
34
37
this . fs ,
35
38
this . disposableRegistry ,
Original file line number Diff line number Diff line change @@ -256,6 +256,8 @@ export abstract class WebViewHost<IMapping> implements IDisposable {
256
256
257
257
traceWarning ( `startHttpServer=${ startHttpServer } , will not be used. Temporarily turned off` ) ;
258
258
259
+ const workspaceFolder = this . workspaceService . getWorkspaceFolder ( Uri . file ( cwd ) ) ?. uri ;
260
+
259
261
// Use this script to create our web view panel. It should contain all of the necessary
260
262
// script to communicate with this class.
261
263
this . webPanel = await this . provider . create ( {
@@ -267,7 +269,8 @@ export abstract class WebViewHost<IMapping> implements IDisposable {
267
269
settings,
268
270
startHttpServer : false ,
269
271
cwd,
270
- webViewPanel
272
+ webViewPanel,
273
+ additionalPaths : workspaceFolder ? [ workspaceFolder . fsPath ] : [ ]
271
274
} ) ;
272
275
273
276
traceInfo ( 'Web view created.' ) ;
You can’t perform that action at this time.
0 commit comments