diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts index e6204e2b05..5dece342c6 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts @@ -272,6 +272,8 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { private updateCellSource(): void { let textOutputElement = this.output.nativeElement; let newCellSource: string = this._htmlMarkdownConverter.convert(textOutputElement.innerHTML); + // reset cell attachments to remove unused image data since we're going to go through each of them again + this.cellModel.attachments = {}; this.cellModel.source = newCellSource; this._changeRef.detectChanges(); } diff --git a/src/sql/workbench/services/notebook/browser/models/cell.ts b/src/sql/workbench/services/notebook/browser/models/cell.ts index 3de022e0f6..7445d83df6 100644 --- a/src/sql/workbench/services/notebook/browser/models/cell.ts +++ b/src/sql/workbench/services/notebook/browser/models/cell.ts @@ -83,7 +83,7 @@ export class CellModel extends Disposable implements ICellModel { private _isInjectedParameter: boolean; private _previousChartState: IInsightOptions[] = []; private _outputCounter = 0; // When re-executing the same cell, ensure that we apply chart options in the same order - private _attachments: nb.ICellAttachments; + private _attachments: nb.ICellAttachments | undefined; private _preventNextChartCache: boolean = false; constructor(cellData: nb.ICellContents, @@ -149,6 +149,10 @@ export class CellModel extends Disposable implements ICellModel { return this._attachments; } + public set attachments(attachments: nb.ICellAttachments | undefined) { + this._attachments = attachments ?? {}; + } + addAttachment(mimeType: string, base64Encoding: string, name: string): string { // base64Encoded value looks like: data:application/octet-stream;base64, // get the from the string diff --git a/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts b/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts index 3c8c7e6b8f..12b4eeafaa 100644 --- a/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts +++ b/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts @@ -533,7 +533,7 @@ export interface ICellModel { sendChangeToNotebook(change: NotebookChangeType): void; cellSourceChanged: boolean; readonly savedConnectionName: string | undefined; - readonly attachments: nb.ICellAttachments; + attachments: nb.ICellAttachments | undefined; readonly currentMode: CellEditModes; /** * Adds image as an attachment to cell metadata