@ -136,7 +136,42 @@ var IPython = (function (IPython) {
that . control _key _active = false ;
return false ;
} else if ( event . which === 84 && that . control _key _active ) {
// Toggle output = t
// To Plaintext = t
that . to _plaintext ( ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 49 && that . control _key _active ) {
// To Heading 1 = 1
that . to _heading ( undefined , 1 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 50 && that . control _key _active ) {
// To Heading 2 = 2
that . to _heading ( undefined , 2 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 51 && that . control _key _active ) {
// To Heading 3 = 3
that . to _heading ( undefined , 3 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 52 && that . control _key _active ) {
// To Heading 4 = 4
that . to _heading ( undefined , 4 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 53 && that . control _key _active ) {
// To Heading 5 = 5
that . to _heading ( undefined , 5 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 54 && that . control _key _active ) {
// To Heading 6 = 6
that . to _heading ( undefined , 6 ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 79 && that . control _key _active ) {
// Toggle output = o
that . toggle _output ( ) ;
that . control _key _active = false ;
return false ;
@ -366,7 +401,11 @@ var IPython = (function (IPython) {
} ;
var cell = this . get _cell ( index )
cell . select ( ) ;
IPython . toolbar . set _cell _type ( cell . cell _type ) ;
if ( cell . cell _type === 'heading' ) {
IPython . toolbar . set _cell _type ( cell . cell _type + cell . level ) ;
} else {
IPython . toolbar . set _cell _type ( cell . cell _type )
}
} ;
return this ;
} ;
@ -467,15 +506,19 @@ var IPython = (function (IPython) {
// type = ('code','html','markdown')
// index = cell index or undefined to insert below selected
index = this . index _or _selected ( index ) ;
var cell = null ;
if ( this . ncells ( ) === 0 || this . is _valid _cell _index ( index ) ) {
var cell = null ;
if ( type === 'code' ) {
var cell = new IPython . CodeCell ( this ) ;
cell = new IPython . CodeCell ( this ) ;
cell . set _input _prompt ( ) ;
} else if ( type === 'markdown' ) {
var cell = new IPython . MarkdownCell ( this ) ;
cell = new IPython . MarkdownCell ( this ) ;
} else if ( type === 'html' ) {
var cell = new IPython . HTMLCell ( this ) ;
cell = new IPython . HTMLCell ( this ) ;
} else if ( type === 'plaintext' ) {
cell = new IPython . PlaintextCell ( this ) ;
} else if ( type === 'heading' ) {
cell = new IPython . HeadingCell ( this ) ;
} ;
if ( cell !== null ) {
if ( this . ncells ( ) === 0 ) {
@ -489,6 +532,7 @@ var IPython = (function (IPython) {
return cell ;
} ;
} ;
return cell ;
} ;
@ -496,15 +540,19 @@ var IPython = (function (IPython) {
// type = ('code','html','markdown')
// index = cell index or undefined to insert above selected
index = this . index _or _selected ( index ) ;
var cell = null ;
if ( this . ncells ( ) === 0 || this . is _valid _cell _index ( index ) ) {
var cell = null ;
if ( type === 'code' ) {
var cell = new IPython . CodeCell ( this ) ;
cell = new IPython . CodeCell ( this ) ;
cell . set _input _prompt ( ) ;
} else if ( type === 'markdown' ) {
var cell = new IPython . MarkdownCell ( this ) ;
cell = new IPython . MarkdownCell ( this ) ;
} else if ( type === 'html' ) {
var cell = new IPython . HTMLCell ( this ) ;
cell = new IPython . HTMLCell ( this ) ;
} else if ( type === 'plaintext' ) {
cell = new IPython . PlaintextCell ( this ) ;
} else if ( type === 'heading' ) {
cell = new IPython . HeadingCell ( this ) ;
} ;
if ( cell !== null ) {
if ( this . ncells ( ) === 0 ) {
@ -518,6 +566,7 @@ var IPython = (function (IPython) {
return cell ;
} ;
} ;
return cell ;
} ;
@ -534,8 +583,8 @@ var IPython = (function (IPython) {
}
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
this . dirty = true ;
} ;
this . dirty = true ;
} ;
} ;
@ -545,19 +594,16 @@ var IPython = (function (IPython) {
if ( this . is _valid _cell _index ( i ) ) {
var source _element = this . get _cell _element ( i ) ;
var source _cell = source _element . data ( "cell" ) ;
var target _cell = null ;
if ( ! ( source _cell instanceof IPython . MarkdownCell ) ) {
target _cell = this . insert _cell _below ( 'markdown' , i ) ;
var text = source _cell . get _text ( ) ;
if ( text === source _cell . placeholder ) {
text = '' ;
} ;
if ( target _cell !== null ) {
// The edit must come before the set_text.
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
}
// The edit must come before the set_text.
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
this . dirty = true ;
} ;
} ;
@ -576,14 +622,61 @@ var IPython = (function (IPython) {
if ( text === source _cell . placeholder ) {
text = '' ;
} ;
if ( target _cell !== null ) {
// The edit must come before the set_text.
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
}
// The edit must come before the set_text.
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
this . dirty = true ;
} ;
} ;
} ;
Notebook . prototype . to _plaintext = function ( index ) {
var i = this . index _or _selected ( index ) ;
if ( this . is _valid _cell _index ( i ) ) {
var source _element = this . get _cell _element ( i ) ;
var source _cell = source _element . data ( "cell" ) ;
var target _cell = null ;
if ( ! ( source _cell instanceof IPython . PlaintextCell ) ) {
target _cell = this . insert _cell _below ( 'plaintext' , i ) ;
var text = source _cell . get _text ( ) ;
if ( text === source _cell . placeholder ) {
text = '' ;
} ;
// The edit must come before the set_text.
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
this . dirty = true ;
} ;
} ;
} ;
Notebook . prototype . to _heading = function ( index , level ) {
level = level || 1 ;
var i = this . index _or _selected ( index ) ;
if ( this . is _valid _cell _index ( i ) ) {
var source _element = this . get _cell _element ( i ) ;
var source _cell = source _element . data ( "cell" ) ;
var target _cell = null ;
if ( source _cell instanceof IPython . HeadingCell ) {
source _cell . set _level ( level ) ;
} else {
target _cell = this . insert _cell _below ( 'heading' , i ) ;
var text = source _cell . get _text ( ) ;
if ( text === source _cell . placeholder ) {
text = '' ;
} ;
// The edit must come before the set_text.
target _cell . set _level ( level ) ;
target _cell . edit ( ) ;
target _cell . set _text ( text ) ;
source _element . remove ( ) ;
this . dirty = true ;
} ;
IPython . toolbar . set _cell _type ( "heading" + level ) ;
} ;
} ;
@ -1098,7 +1191,7 @@ var IPython = (function (IPython) {
// We may want to move the name/id/nbformat logic inside toJSON?
var data = this . toJSON ( ) ;
data . metadata . name = nbname ;
data . nbformat = 2 ;
data . nbformat = 3 ;
// We do the call with settings so we can set cache to false.
var settings = {
processData : false ,