Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotebookCellData.mime #126280

Open
mjbvz opened this issue Jun 14, 2021 · 6 comments
Open

NotebookCellData.mime #126280

mjbvz opened this issue Jun 14, 2021 · 6 comments
Assignees
Labels
api api-proposal feature-request Request for new features or functionality
Milestone

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 14, 2021

Problem

The notebooks api has the concept of markup cells. The intent is that these cells are rendered as html by default, unlike code cells which are displayed as editors by default with their rendered output below them.

Currently we only support markdown markup cells. However we'd also like to support other markup languages, including ones that an extension may invent. However there's currently no way to set the mime type of a markup cell, which is needed for a custom renderer to be able to support it

Proposal

Add a new NotebookCellData.mime field. If not explicitly provided, this would default to text/plain (or text/markdown it the cell's language is markdown)

The mime field would only be used when rendering the cell. The existing language field would still be used to determine which type of editor to display for the cell

@mjbvz mjbvz added this to the June 2021 milestone Jun 14, 2021
@mjbvz mjbvz self-assigned this Jun 14, 2021
@DonJayamanne
Copy link
Contributor

DonJayamanne commented Jun 15, 2021

Would this allow one to render base64 images?
Assume the text is a base64 encoded image, and we have mime type set to image/png, I'm assuming the renderer could then potentially display that.

I'm assuming this would allow more powerful rendering of content such as rendering images for image/svg+xml, and latex for text/latex

I guess this depends on the definition of markup languages as defined here like to support other markup languages.

Would the rendering architecture/API extensibility be similar to that of renderers?

This means its possible to create something like a transformer (transform the markup text into a visual output). E.g. i could have a cell text containing contents of the XML from a *.drawio file that's renderered as a flowchart.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 15, 2021

@DonJayamanne Yes, you could do that (although for images, you probably just want to use markdown)

In the future we may explore allowing binary cells as well, but for now the big limitation is that you must have text data. Right now though our focus is very much on the cases you listed, such as latex and more traditional markup languages

mjbvz added a commit that referenced this issue Jun 15, 2021
@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 16, 2021

@rebornix @jrieken I believe we may need to add a mime property to NotebookCell. Right now that entire class is immutable, but we likely want to allow extensions to be able to set the mime type of an existing markup cell. This isn't a problem with language since the extensions can just modify the TextDocument

Let me know if you have any thoughts on this. Is adding a read+write property to NotebookCell acceptable or do we need to find a different way to express this?

@jrieken
Copy link
Member

jrieken commented Jun 16, 2021

This isn't a problem with language since the extensions can just modify the TextDocument

Extension cannot do that - only the setTextDocumentLanguage function allows you to do that. Both, TextDocument and NotebookDocument and their descendants are immutable.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 17, 2021

We could also exploring having markup cells use outputs.

Basically this would be a function executeMarkup(markupCell: NotebookCell): NotebookCellOutputItem that maps markup cells to a single output. This output item would then replace the cell when it is not being edited. VS Code could provide a default implementation that handles markdown, but extensions would need to handle more advanced cases

Needs more thought

@rchiodo
Copy link
Contributor

rchiodo commented Jun 17, 2021

+ 1 on the output idea

@mjbvz mjbvz modified the milestones: June 2021, July 2021 Jun 30, 2021
@mjbvz mjbvz modified the milestones: July 2021, On Deck Jul 8, 2021
@mjbvz mjbvz added the feature-request Request for new features or functionality label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api api-proposal feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants