Skip to content

Commit

Permalink
Inject static HTML in mime bundle in classic notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
gnestor committed Mar 7, 2017
1 parent 151b2ad commit 98a63e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion labextension/src/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class OutputWidget extends Widget {
_render() {
const { data, schema } = this._data.get(this._mimeType);
// const metadata = this._metadata.get(this._mimeType);
// if (data)
ReactDOM.render(<JSONTable data={data} schema={schema} />, this.node);
// Inject static HTML into mime bundle
this._data.set(
'text/html',
ReactDOMServer.renderToStaticMarkup(<JSONTable data={data} schema={schema} />)
Expand Down
9 changes: 4 additions & 5 deletions nbextension/src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ export function register_renderer(notebook) {
render(json, toinsert[0]);
// Inject static HTML into mime bundle
this.outputs.filter(output => output.data[MIME_TYPE]).forEach(output => {
const { resources: [ props ] } = json;
ReactDOMServer.renderToStaticMarkup(
<JSONTable {...props} />
<JSONTable data={data} schema={schema} />
)
});
element.append(toinsert);
Expand Down Expand Up @@ -65,9 +64,9 @@ export function render_cells(notebook) {
notebook.get_cells().forEach(cell => {
// If a cell has output data of 'application/vnd.dataresource+json' mime type
if (
cell.output_area &&
cell.output_area.outputs.find(output =>
output.data && output.data[MIME_TYPE]
cell.output_area &&
cell.output_area.outputs.find(
output => output.data && output.data[MIME_TYPE]
)
) {
// Re-render the cell by executing it
Expand Down

0 comments on commit 98a63e0

Please sign in to comment.