add raw cell toolbar preset

This commit is contained in:
MinRK 2013-11-06 12:13:19 -08:00
parent 0fb011ef68
commit d087a213b3
3 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,60 @@
//----------------------------------------------------------------------------
// Copyright (C) 2012 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// CellToolbar Example
//============================================================================
(function(IPython) {
"use strict";
var CellToolbar = IPython.CellToolbar;
var raw_cell_preset = [];
var select_type = CellToolbar.utils.select_ui_generator([
["None", "-"],
["LaTeX", "text/latex"],
["restructuredText", "text/restructuredtext"],
["HTML", "text/html"],
["markdown", "text/markdown"],
["Python", "text/python"],
["Custom", , "dialog"],
],
// setter
function(cell, value) {
if (value === '-') {
delete cell.metadata.raw_mime;
} else if (value === 'dialog'){
// IPython.dialog.modal(
// "Set custom raw cell format",
//
// OK
// )
//
} else {
cell.metadata.raw_mime = value;
}
},
//getter
function(cell) {
return cell.metadata.raw_mime || "-";
},
// name
"Raw NBConvert Format",
// cell_types
["raw"]
);
CellToolbar.register_callback('raw_cell.select', select_type);
raw_cell_preset.push('raw_cell.select');
CellToolbar.register_preset('Raw Cell Format', raw_cell_preset);
console.log('Raw Cell Format toolbar preset loaded.');
}(IPython));

View File

@ -125,7 +125,7 @@ var IPython = (function (IPython) {
// .addClass('ui-widget-content')
.append($('<option/>').attr('value','code').text('Code'))
.append($('<option/>').attr('value','markdown').text('Markdown'))
.append($('<option/>').attr('value','raw').text('Raw Text'))
.append($('<option/>').attr('value','raw').text('Raw NBConvert'))
.append($('<option/>').attr('value','heading1').text('Heading 1'))
.append($('<option/>').attr('value','heading2').text('Heading 2'))
.append($('<option/>').attr('value','heading3').text('Heading 3'))

View File

@ -296,6 +296,7 @@ class="notebook_app"
<script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
<script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("notebook/js/celltoolbarpresets/rawcell.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}