Commit af830a57 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of github.com:fex-team/kityminder into dev

parents 52868ca8 79033689
......@@ -49,7 +49,8 @@ KityMinder.LANG[ 'zh-cn' ] = {
'node': {
'appendsiblingnode': '插入同级节点',
'appendchildnode': '插入子节点',
'removenode': '删除节点'
'removenode': '删除节点',
'editnode': '编辑节点'
},
'layout': {
'default': '左右展开',
......
......@@ -2,7 +2,8 @@ KM.registerToolbarUI( 'node', function ( name ) {
var shortcutKeys = {
"appendsiblingnode": "enter",
"appendchildnode": "tab",
"removenode": "del|backspace"
"removenode": "del|backspace",
"editnode": "F2"
};
var me = this,
......
......@@ -3,41 +3,45 @@ var keymap = KityMinder.keymap = {
'Tab' : 9,
'Enter' : 13,
'Shift':16,
'Control':17,
'Alt':18,
'CapsLock':20,
'Shift' : 16,
'Control' : 17,
'Alt' : 18,
'CapsLock' : 20,
'Esc':27,
'Esc': 27,
'Spacebar':32,
'Spacebar' : 32,
'PageUp':33,
'PageDown':34,
'End':35,
'Home':36,
'PageUp' : 33,
'PageDown' : 34,
'End' : 35,
'Home' : 36,
'Left':37,
'Up':38,
'Right':39,
'Down':40,
'Left' : 37,
'Up' : 38,
'Right' : 39,
'Down' : 40,
'Insert':45,
'Insert' : 45,
'Del':46,
'Del' : 46,
'NumLock':144,
'NumLock' : 144,
'Cmd':91,
'Cmd' : 91,
'=':187,
'-':189,
'F2' : 113,
'F3' : 114,
'F4' : 115,
"b":66,
'i':73,
'=' : 187,
'-' : 189,
"b" : 66,
'i' : 73,
//回退
'z':90,
'y':89,
'z' : 90,
'y' : 89,
//粘贴
'v' : 86,
'x' : 88,
......
......@@ -135,12 +135,13 @@ KityMinder.registerModule( "TextEditModule", function () {
"resize": function ( e ) {
sel.setHide();
},
'execCommand':function(e){
"execCommand": function( e ) {
var cmds = {
'appendchildnode':1,
'appendsiblingnode':1
'appendchildnode' : 1,
'appendsiblingnode' : 1,
'editnode' : 1
};
if(cmds[e.commandName]){
if ( cmds[ e.commandName ] ){
var node = km.getSelectedNode();
if( !node ){
......
......@@ -175,6 +175,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
switch ( keyCode ) {
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus();
this.setTextEditStatus( false );
......
......@@ -146,6 +146,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break;
case keys.F2:
e.preventDefault();
if ( this.queryCommandState( 'editnode' ) !== -1 ) this.execCommand( 'editnode' );
break;
case keys.Left:
navigateTo( this, 'left' );
......
......@@ -195,12 +195,33 @@ KityMinder.registerModule( "LayoutModule", function () {
}
};
} )() );
var EditNodeCommand = kity.createClass( "EditNodeCommand", ( function () {
return {
base: Command,
execute: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return null;
}
km.select( selectedNode, true );
},
queryState: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return -1;
} else {
return 0;
}
}
};
} )() );
return {
"commands": {
"appendchildnode": AppendChildNodeCommand,
"appendsiblingnode": AppendSiblingNodeCommand,
"removenode": RemoveNodeCommand,
"editnode": EditNodeCommand,
"switchlayout": SwitchLayoutCommand
},
"events": {
......@@ -251,6 +272,12 @@ KityMinder.registerModule( "LayoutModule", function () {
this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
},
cmdName: 'appendchildnode'
}, {
label: this.getLang( 'node.editnode' ),
exec: function () {
this.execCommand( 'editnode', null );
},
cmdName: 'editnode'
}, {
label: this.getLang( 'node.removenode' ),
cmdName: 'removenode'
......@@ -264,6 +291,7 @@ KityMinder.registerModule( "LayoutModule", function () {
"node": {
'appendsiblingnode': 'appendsiblingnode',
'appendchildnode': 'appendchildnode',
'editnode': 'editnode',
'removenode': 'removenode'
},
'defaultExpand': {
......
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