From a4744c696f4b108f69fed1757624a94d52f89bb2 Mon Sep 17 00:00:00 2001 From: Grant Nestor Date: Tue, 6 Dec 2016 13:04:10 -0800 Subject: [PATCH 1/2] Expose `OutputArea.mime_types` to allow extensions to calculate `display_order` index --- notebook/static/notebook/js/outputarea.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 1aedcd0b8..6438d14b5 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -1072,7 +1072,11 @@ define([ [MIME_PDF] : append_pdf }; - OutputArea.prototype.register_mime_type = function (mimetype, append, safe) { + OutputArea.prototype.mime_types = function () { + return OutputArea.display_order; + }; + + OutputArea.prototype.register_mime_type = function (mimetype, append, options) { if (mimetype && typeof(append) === 'function') { OutputArea.output_types.push(mimetype); if (safe) OutputArea.safe_outputs[mimetype] = true; From 19c9a791cc21755cdfdc50d4ed768dd8e741b804 Mon Sep 17 00:00:00 2001 From: Grant Nestor Date: Tue, 6 Dec 2016 13:05:41 -0800 Subject: [PATCH 2/2] Pass `options.index` to `OutputArea.register_mime_type` to set `display_order` index --- notebook/static/notebook/js/outputarea.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 6438d14b5..12e72796a 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -1079,8 +1079,8 @@ define([ OutputArea.prototype.register_mime_type = function (mimetype, append, options) { if (mimetype && typeof(append) === 'function') { OutputArea.output_types.push(mimetype); - if (safe) OutputArea.safe_outputs[mimetype] = true; - OutputArea.display_order.unshift(mimetype); + if (options.safe) OutputArea.safe_outputs[mimetype] = true; + OutputArea.display_order.splice(options.index || 0, 0, mimetype); OutputArea.append_map[mimetype] = append; } };