jupyter / jupyter/notebook

Question - Custom mime-types

Open
#3,244 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I am trying to create a custom mime type following [this cookiecutter](https://github.com/jupyterlab/mimerender-cookiecutter/tree/master). However, the ``element`` that we get [here](https://github.com/jupyterlab/mimerender-cookiecutter/blob/master/%7B%7Bcookiecutter.extension_name%7D%7D/src/renderer.js#L56) as a parameter to the ``append_mime`` function is a detached DOM node.
Some js libs (Slickgrid in my case) need a valid DOM node to render.

I worked around this by adding something like this

```
$(this.element[0]).one('changed', function() {
// Call a DOM manipulating render function here
});

```
This code assumes that the [changed event](https://github.com/jupyter/notebook/blob/9f7ee6830e40c805176f034d60df3b3cd19c8f39/notebook/static/notebook/js/outputarea.js#L470) will be fired, when the element is attached to the DOM.

Is there a better way of handling mime types for js libs that cannot work with a detached DOM node ?

Thanks

Contributor guide

Open the contributing guide

Research direction

Start with the cookiecutter's src/renderer.js at the append_mime call and the linked outputarea.js changed event. Determine the supported lifecycle for a custom MIME renderer that needs an attached DOM node; done means the issue has a clear implementation or documented usage path, with a relevant test if the repository provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jupyter-notebook
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.