Skip to content

Commit 83f34a8

Browse files
authored
Merge pull request #9 from gnestor/inject-mime
Inject static HTML in mime bundle in classic notebook
2 parents aa4573a + 2031c54 commit 83f34a8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

labextension/src/output.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class OutputWidget extends Widget {
4242
const { resources: [ props ] } = this._data.get(this._mimeType);
4343
// const metadata = this._metadata.get(this._mimeType);
4444
if (props) ReactDOM.render(<JSONTable {...props} />, this.node);
45+
// Inject static HTML into mime bundle
4546
this._data.set(
4647
'text/html',
4748
ReactDOMServer.renderToStaticMarkup(<JSONTable {...props} />)

nbextension/src/renderer.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import ReactDOMServer from 'react-dom/server';
34
import { VirtualizedTable as JSONTable } from 'jupyterlab_table_react';
45
import './index.css';
56

@@ -28,7 +29,14 @@ export function register_renderer(notebook) {
2829
const type = MIME_TYPE;
2930
const toinsert = this.create_output_subarea(md, CLASS_NAME, type);
3031
this.keyboard_manager.register_events(toinsert);
31-
render(json, toinsert[(0)]);
32+
render(json, toinsert[0]);
33+
// Inject static HTML into mime bundle
34+
this.outputs.filter(output => output.data[MIME_TYPE]).forEach(output => {
35+
const { resources: [ props ] } = json;
36+
ReactDOMServer.renderToStaticMarkup(
37+
<JSONTable {...props} />
38+
)
39+
});
3240
element.append(toinsert);
3341
return toinsert;
3442
};

0 commit comments

Comments
 (0)