From 4cf93c8c5769b035df598796b7d43153ef3c5b89 Mon Sep 17 00:00:00 2001 From: Grant Nestor Date: Tue, 1 Nov 2016 22:39:09 -0700 Subject: [PATCH] Add a `register_mime_type` method to OutputArea --- notebook/static/notebook/js/notebook.js | 3 ++- notebook/static/notebook/js/outputarea.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 6f0694bf3..a04b99727 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -526,7 +526,8 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor'; * @return {jQuery} A selector of all cell elements */ Notebook.prototype.get_cell_elements = function () { - return this.container.find(".cell").not('.cell .cell'); + var container = this.container || $('#notebook-container') + return container.find(".cell").not('.cell .cell'); }; /** diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index fd9f7d0a2..01a79c865 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -996,6 +996,15 @@ define([ [MIME_JAVASCRIPT] : append_javascript, [MIME_PDF] : append_pdf }; + + OutputArea.prototype.register_mime_type = function (mimetype, append, safe) { + if (mimetype && typeof(append) === 'function') { + OutputArea.output_types.push(mimetype); + if (safe) OutputArea.safe_outputs[mimetype] = true; + OutputArea.display_order.unshift(mimetype); + OutputArea.append_map[mimetype] = append; + } + }; return {'OutputArea': OutputArea}; });