Initial work adding NotebookCellData.mime

For #126280
For #126417
This commit is contained in:
Matt Bierner
2021-06-15 15:16:24 -07:00
parent 92160bf660
commit cd08aa0081
11 changed files with 100 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ export namespace NotebookDto {
return {
cellKind: cell.cellKind,
language: cell.language,
mime: cell.mime,
source: cell.source,
internalMetadata: cell.internalMetadata,
metadata: cell.metadata,
@@ -61,6 +62,7 @@ export namespace NotebookDto {
return {
cellKind: cell.cellKind,
language: cell.language,
mime: cell.mime,
source: cell.source,
outputs: cell.outputs.map(fromNotebookOutputDto),
metadata: cell.metadata,

View File

@@ -1930,6 +1930,7 @@ export interface NotebookOutputDto {
export interface NotebookCellDataDto {
source: string;
language: string;
mime: string | undefined;
cellKind: notebookCommon.CellKind;
outputs: NotebookOutputDto[];
metadata?: notebookCommon.NotebookCellMetadata;
@@ -1947,6 +1948,7 @@ export interface NotebookCellDto {
eol: string;
source: string[];
language: string;
mime?: string;
cellKind: notebookCommon.CellKind;
outputs: NotebookOutputDto[];
metadata?: notebookCommon.NotebookCellMetadata;
@@ -2000,6 +2002,7 @@ export type NotebookRawContentEventDto =
readonly append: boolean;
}
| notebookCommon.NotebookCellsChangeLanguageEvent
| notebookCommon.NotebookCellsChangeMimeEvent
| notebookCommon.NotebookCellsChangeMetadataEvent
| notebookCommon.NotebookCellsChangeInternalMetadataEvent
// | notebookCommon.NotebookDocumentChangeMetadataEvent

View File

@@ -54,6 +54,7 @@ export class ExtHostCell {
readonly cellKind: notebookCommon.CellKind;
private _apiCell: vscode.NotebookCell | undefined;
private _mime: string | undefined;
constructor(
readonly notebook: ExtHostNotebookDocument,
@@ -85,6 +86,8 @@ export class ExtHostCell {
notebook: that.notebook.apiNotebook,
kind: extHostTypeConverters.NotebookCellKind.to(this._cellData.cellKind),
document: data.document,
get mime() { return that._mime; },
set mime(value: string | undefined) { that._mime = value; },
get outputs() { return that._outputs.slice(0); },
get metadata() { return that._metadata; },
get executionSummary() { return that._previousResult; }
@@ -116,6 +119,10 @@ export class ExtHostCell {
this._internalMetadata = newInternalMetadata;
this._previousResult = extHostTypeConverters.NotebookCellExecutionSummary.to(newInternalMetadata);
}
setMime(newMime: string | undefined) {
}
}
export interface INotebookEventEmitter {
@@ -223,6 +230,8 @@ export class ExtHostNotebookDocument {
this._setCellOutputItems(rawEvent.index, rawEvent.outputId, rawEvent.append, rawEvent.outputItems);
} else if (rawEvent.kind === notebookCommon.NotebookCellsChangeType.ChangeLanguage) {
this._changeCellLanguage(rawEvent.index, rawEvent.language);
} else if (rawEvent.kind === notebookCommon.NotebookCellsChangeType.ChangeCellMime) {
this._changeCellMime(rawEvent.index, rawEvent.mime);
} else if (rawEvent.kind === notebookCommon.NotebookCellsChangeType.ChangeCellMetadata) {
this._changeCellMetadata(rawEvent.index, rawEvent.metadata);
} else if (rawEvent.kind === notebookCommon.NotebookCellsChangeType.ChangeCellInternalMetadata) {
@@ -345,6 +354,11 @@ export class ExtHostNotebookDocument {
}
}
private _changeCellMime(index: number, newMime: string | undefined): void {
const cell = this._cells[index];
cell.apiCell.mime = newMime;
}
private _changeCellMetadata(index: number, newMetadata: notebookCommon.NotebookCellMetadata): void {
const cell = this._cells[index];

View File

@@ -1448,6 +1448,7 @@ export namespace NotebookCellData {
return {
cellKind: NotebookCellKind.from(data.kind),
language: data.languageId,
mime: data.mime,
source: data.value,
metadata: data.metadata,
internalMetadata: NotebookCellExecutionSummary.from(data.executionSummary ?? {}),
@@ -1460,6 +1461,7 @@ export namespace NotebookCellData {
NotebookCellKind.to(data.cellKind),
data.source,
data.language,
data.mime,
data.outputs ? data.outputs.map(NotebookCellOutput.to) : undefined,
data.metadata,
data.internalMetadata ? NotebookCellExecutionSummary.to(data.internalMetadata) : undefined

View File

@@ -3015,14 +3015,16 @@ export class NotebookCellData {
kind: NotebookCellKind;
value: string;
languageId: string;
mime?: string;
outputs?: vscode.NotebookCellOutput[];
metadata?: Record<string, any>;
executionSummary?: vscode.NotebookCellExecutionSummary;
constructor(kind: NotebookCellKind, value: string, languageId: string, outputs?: vscode.NotebookCellOutput[], metadata?: Record<string, any>, executionSummary?: vscode.NotebookCellExecutionSummary) {
constructor(kind: NotebookCellKind, value: string, languageId: string, mime?: string, outputs?: vscode.NotebookCellOutput[], metadata?: Record<string, any>, executionSummary?: vscode.NotebookCellExecutionSummary) {
this.kind = kind;
this.value = value;
this.languageId = languageId;
this.mime = mime;
this.outputs = outputs ?? [];
this.metadata = metadata;
this.executionSummary = executionSummary;