Commit f3bccfde authored by campaign's avatar campaign

by zhanyi

parent e1040310
...@@ -83,7 +83,43 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -83,7 +83,43 @@ KityMinder.registerModule( "TextEditModule", function () {
}, },
'stopTextEdit':function(){ 'stopTextEdit':function(){
sel.setHide(); sel.setHide();
receiver.clear().setTextEditStatus(false);
},
'execCommand':function(e){
var cmds = {
'appendchildnode':1,
'appendsiblingnode':1
};
if(cmds[e.commandName]){
var node = km.getSelectedNode();
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
node.getTextShape().setStyle('cursor','text');
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
.setMinderNode(node)
.setTextShape(textShape)
.setBaseOffset()
.setContainerStyle()
.setSelectionHeight()
.getTextOffsetData()
.setIndex(0)
.updateSelection()
.setRange(range);
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
sel.setShow();
receiver.updateSelectionShow(1)
.updateRange(range);
}
} }
} }
}; };
......
...@@ -77,8 +77,10 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -77,8 +77,10 @@ Minder.Receiver = kity.createClass('Receiver',{
switch(keyCode){ switch(keyCode){
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
if(this.keydownNode === this.minderNode){
this.setTextEditStatus(false); this.setTextEditStatus(false);
this.clear(); this.clear();
}
e.preventDefault(); e.preventDefault();
return; return;
case keymap.Shift: case keymap.Shift:
...@@ -263,5 +265,9 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -263,5 +265,9 @@ Minder.Receiver = kity.createClass('Receiver',{
range.setEnd(node,this.selection.endOffset); range.setEnd(node,this.selection.endOffset);
range.select(); range.select();
return this; return this;
},
setIndex:function(index){
this.index = index;
return this
} }
}); });
\ No newline at end of file
...@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
buildPositionNetwork( this.getRoot() ); buildPositionNetwork( this.getRoot() );
}, },
keydown: function ( e ) { keydown: function ( e ) {
var keys = KityMinder.keymap; var keys = KityMinder.keymap;
if ( this.receiver.isTextEditStatus() ) { if ( this.receiver.isTextEditStatus() ) {
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
...@@ -85,6 +86,8 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -85,6 +86,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
} }
return; return;
} }
var node = e.getTargetNode();
this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case keys.Enter: case keys.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) ); this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment