Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/11040.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure images in workspace folder are supported within markdown cells in a `Notebook`.
5 changes: 5 additions & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,11 @@ export interface IWebPanelOptions {
listener: IWebPanelMessageListener;
title: string;
rootPath: string;
/**
* Additional paths apart from cwd and rootPath, that webview would allow loading resources/files from.
* E.g. required for webview to serve images from worksapces when nb is in a nested folder.
*/
additionalPaths?: string[];
scripts: string[];
startHttpServer: boolean;
cwd: string;
Expand Down
3 changes: 3 additions & 0 deletions src/client/common/application/webPanels/webPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export class WebPanelProvider implements IWebPanelProvider {
// Allow loading resources from the `<extension folder>/tmp` folder when in webiviews.
// Used by widgets to place files that are not otherwise accessible.
const additionalRootPaths = [Uri.file(path.join(this.context.extensionPath, 'tmp'))];
if (Array.isArray(options.additionalPaths)) {
additionalRootPaths.push(...options.additionalPaths.map((item) => Uri.file(item)));
}
return new WebPanel(
this.fs,
this.disposableRegistry,
Expand Down
5 changes: 4 additions & 1 deletion src/client/datascience/webViewHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ export abstract class WebViewHost<IMapping> implements IDisposable {

traceWarning(`startHttpServer=${startHttpServer}, will not be used. Temporarily turned off`);

const workspaceFolder = this.workspaceService.getWorkspaceFolder(Uri.file(cwd))?.uri;

// Use this script to create our web view panel. It should contain all of the necessary
// script to communicate with this class.
this.webPanel = await this.provider.create({
Expand All @@ -267,7 +269,8 @@ export abstract class WebViewHost<IMapping> implements IDisposable {
settings,
startHttpServer: false,
cwd,
webViewPanel
webViewPanel,
additionalPaths: workspaceFolder ? [workspaceFolder.fsPath] : []
});

traceInfo('Web view created.');
Expand Down