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