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

@@ -6,7 +6,10 @@
import { OnDestroy } from '@angular/core';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { ICellEditorProvider, NotebookRange } from 'sql/workbench/services/notebook/browser/notebookService';
import { MarkdownRenderOptions } from 'vs/base/browser/markdownRenderer';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
import { nb } from 'azdata';
export abstract class CellView extends AngularDisposable implements OnDestroy, ICellEditorProvider {
constructor() {
@@ -29,3 +32,11 @@ export abstract class CellView extends AngularDisposable implements OnDestroy, I
}
}
export interface IMarkdownStringWithCellAttachments extends IMarkdownString {
readonly cellAttachments?: nb.ICellAttachment
}
export interface MarkdownRenderOptionsWithCellAttachments extends MarkdownRenderOptions {
readonly cellAttachments?: nb.ICellAttachment
}

View File

@@ -227,7 +227,8 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
this.markdownRenderer.setNotebookURI(this.cellModel.notebookModel.notebookUri);
this.markdownResult = this.markdownRenderer.render({
isTrusted: true,
value: Array.isArray(this._content) ? this._content.join('') : this._content
value: Array.isArray(this._content) ? this._content.join('') : this._content,
cellAttachments: this.cellModel.attachments
});
this.markdownResult.element.innerHTML = this.sanitizeContent(this.markdownResult.element.innerHTML);
this.setLoading(false);