added attachment and metadata support back in... rebasing is scary

This commit is contained in:
Michael Lively 2022-07-19 13:13:18 -07:00
parent 3981a5804c
commit 735ead82f5
4 changed files with 9 additions and 5 deletions

View file

@ -20,10 +20,9 @@ export async function activate(ctx: RendererContext<void>) {
// addCellAttachmentRendering(md);
// const originalRender = md.render;
md.renderInline = function () {
md.render = function () {
const outputInfo = arguments[1].outputItem;
const text = outputInfo.text();
let markdownText = outputInfo.mime.startsWith('text/x-') ? `\`\`\`${outputInfo.mime.substr(7)}\n${text}\n\`\`\``
: (outputInfo.mime.startsWith('application/') ? `\`\`\`${outputInfo.mime.substr(12)}\n${text}\n\`\`\`` : text);

View file

@ -1650,6 +1650,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
content: model.getText(),
offset: offset,
visible: false,
metadata: model.metadata,
});
}
@ -2587,6 +2588,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
content: cell.getText(),
offset: cellTop + top,
visible: true,
metadata: cell.metadata,
});
}

View file

@ -5,6 +5,7 @@
import type { RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import type { PreloadOptions } from 'vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads';
import { NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
interface BaseToWebviewMessage {
readonly __vscode_notebook_message: true;
@ -329,6 +330,7 @@ export interface IMarkupCellInitialization {
content: string;
offset: number;
visible: boolean;
metadata: NotebookCellMetadata;
}
export interface IInitializeMarkupCells {

View file

@ -6,6 +6,7 @@
import type { Event } from 'vs/base/common/event';
import type { IDisposable } from 'vs/base/common/lifecycle';
import type * as webviewMessages from 'vs/workbench/contrib/notebook/browser/view/renderers/webviewMessages';
import { NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import type * as rendererApi from 'vscode-notebook-renderer';
// !! IMPORTANT !! ----------------------------------------------------------------------------------
@ -1435,7 +1436,7 @@ async function webviewPreloads(ctx: PreloadContext) {
return existing;
}
const cell = new MarkupCell(init.cellId, init.mime, init.content, top);
const cell = new MarkupCell(init.cellId, init.mime, init.content, top, init.metadata);
cell.element.style.visibility = visible ? 'visible' : 'hidden';
this._markupCells.set(init.cellId, cell);
@ -1634,7 +1635,7 @@ async function webviewPreloads(ctx: PreloadContext) {
/// Internal field that holds text content
private _content: { readonly value: string; readonly version: number };
constructor(id: string, mime: string, content: string, top: number) {
constructor(id: string, mime: string, content: string, top: number, metadata: NotebookCellMetadata) {
this.id = id;
this._content = { value: content, version: 0 };
@ -1645,7 +1646,7 @@ async function webviewPreloads(ctx: PreloadContext) {
this.outputItem = Object.freeze(<rendererApi.OutputItem>{
id,
mime,
metadata: undefined,
metadata,
text: (): string => {
return this._content.value;