Commit 0bcbb851 authored by Ronny's avatar Ronny

修bug,删除根节点操作导致报错,修改方法,根节点不能删除,直接return

同时几处调用之前先检测变量
parent 8d6d33e3
// 选区管理 // 选区管理
kity.extendClass( Minder, function () { kity.extendClass( Minder, function () {
function highlightNode( km, node ) { function highlightNode( km, node ) {
node.setTmpData( "highlight", true ); if( node ){
km.highlightNode( node ); node.setTmpData( "highlight", true );
km.highlightNode( node );
}
} }
function unhighlightNode( km, node ) { function unhighlightNode( km, node ) {
node.setTmpData( "highlight", false ); if( node ){
km.highlightNode( node ); node.setTmpData( "highlight", false );
km.highlightNode( node );
}
} }
return { return {
_initSelection: function () { _initSelection: function () {
......
...@@ -30,7 +30,7 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -30,7 +30,7 @@ KityMinder.registerModule( "basestylemodule", function () {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
if(n.getData('bold')){ if( n && n.getData('bold') ){
result = 1; result = 1;
return false; return false;
} }
...@@ -65,7 +65,7 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -65,7 +65,7 @@ KityMinder.registerModule( "basestylemodule", function () {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
if(n.getData('italic')){ if( n && n.getData('italic') ){
result = 1; result = 1;
return false; return false;
} }
......
...@@ -162,6 +162,11 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -162,6 +162,11 @@ KityMinder.registerModule( "LayoutModule", function () {
return { return {
base: Command, base: Command,
execute: function ( km ) { execute: function ( km ) {
if( km.getRoot().children.length == 0 ){
return;
}
var selectedNodes = km.getSelectedNodes(); var selectedNodes = km.getSelectedNodes();
var _root = km.getRoot(); var _root = km.getRoot();
var _buffer = []; var _buffer = [];
......
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