Notebooks: Add Support for Cell Attachment Images (#14449)

* Add to interfaces

* Works E2E

* Consolidate interface

* Add comments, cleanup

* Add some tests

* Cleanup

* interface cleanup

* Add more tests

* Add comments

* Add type for cell attachment

* wip
This commit is contained in:
Chris LaFreniere
2021-02-28 16:40:41 -08:00
committed by GitHub
parent 8ce32215ba
commit 48a63e1f50
12 changed files with 127 additions and 11 deletions

View File

@@ -80,6 +80,7 @@ export class CellModel extends Disposable implements ICellModel {
private _isParameter: boolean;
private _onParameterStateChanged = new Emitter<boolean>();
private _isInjectedParameter: boolean;
private _attachments: nb.ICellAttachment;
constructor(cellData: nb.ICellContents,
private _options: ICellModelOptions,
@@ -140,6 +141,10 @@ export class CellModel extends Disposable implements ICellModel {
return this._metadata;
}
public get attachments() {
return this._attachments;
}
public get isEditMode(): boolean {
return this._isEditMode;
}
@@ -845,6 +850,8 @@ export class CellModel extends Disposable implements ICellModel {
if (this._configurationService?.getValue('notebook.saveConnectionName')) {
metadata.connection_name = this._savedConnectionName;
}
} else if (this._cellType === CellTypes.Markdown) {
cellJson.attachments = this._attachments;
}
return cellJson as nb.ICellContents;
}
@@ -866,7 +873,7 @@ export class CellModel extends Disposable implements ICellModel {
this._isParameter = false;
this._isInjectedParameter = false;
}
this._attachments = cell.attachments || {};
this._cellGuid = cell.metadata && cell.metadata.azdata_cell_guid ? cell.metadata.azdata_cell_guid : generateUuid();
this.setLanguageFromContents(cell);
this._savedConnectionName = this._metadata.connection_name;

View File

@@ -530,6 +530,7 @@ export interface ICellModel {
sendChangeToNotebook(change: NotebookChangeType): void;
cellSourceChanged: boolean;
readonly savedConnectionName: string | undefined;
readonly attachments: nb.ICellAttachment;
readonly currentMode: CellEditModes;
}

View File

@@ -4,6 +4,7 @@
|----------------------------------------------------------------------------*/
import * as widgets from 'sql/workbench/contrib/notebook/browser/outputs/widgets';
import { ImageMimeTypes } from 'sql/workbench/services/notebook/common/contracts';
import { IRenderMime } from './renderMimeInterfaces';
/**
@@ -21,7 +22,7 @@ export const htmlRendererFactory: IRenderMime.IRendererFactory = {
*/
export const imageRendererFactory: IRenderMime.IRendererFactory = {
safe: true,
mimeTypes: ['image/bmp', 'image/png', 'image/jpeg', 'image/gif'],
mimeTypes: ImageMimeTypes,
defaultRank: 90,
createRenderer: options => new widgets.RenderedImage(options)
};