Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
1711db1e
Commit
1711db1e
authored
Jan 04, 2015
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持归纳命令 && 移除旧代码
parent
67cb3b04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
37 deletions
+28
-37
node.js
src/module/node.js
+28
-37
No files found.
src/module/node.js
View file @
1711db1e
...
...
@@ -94,62 +94,53 @@ define(function(require, exports, module) {
}
});
/**
* @command EditNode
* @description 编辑选中的节点
* @state
* 0: 当前有选中的节点
* -1: 当前没有选中的节点
*/
var
EditNodeCommand
=
kity
.
createClass
(
'EditNodeCommand'
,
{
var
AppendParentCommand
=
kity
.
createClass
(
'AppendParentCommand'
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
null
;
execute
:
function
(
km
,
text
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
!
nodes
.
length
)
return
;
var
parent
=
nodes
[
0
].
parent
;
for
(
var
i
=
1
;
i
<
nodes
.
length
;
i
++
)
{
if
(
nodes
[
i
].
parent
!=
parent
)
return
-
1
;
}
km
.
select
(
selectedNode
,
true
);
km
.
textEditNode
(
selectedNode
);
nodes
.
sort
(
function
(
a
,
b
)
{
return
a
.
getIndex
()
-
b
.
getIndex
();
});
var
newParent
=
km
.
createNode
(
text
,
parent
,
nodes
[
0
].
getIndex
());
nodes
.
forEach
(
function
(
node
)
{
newParent
.
appendChild
(
node
);
});
newParent
.
setGlobalLayoutTransform
(
nodes
[
nodes
.
length
>>
1
].
getGlobalLayoutTransform
());
km
.
select
(
newParent
,
true
);
km
.
layout
(
600
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
var
nodes
=
km
.
getSelectedNodes
();
if
(
!
nodes
.
length
)
return
;
var
parent
=
nodes
[
0
].
parent
;
for
(
var
i
=
1
;
i
<
nodes
.
length
;
i
++
)
{
if
(
nodes
[
i
].
parent
!=
parent
)
return
-
1
;
}
},
isNeedUndo
:
function
()
{
return
false
;
return
0
;
}
});
Module
.
register
(
'NodeModule'
,
function
()
{
return
{
commands
:
{
'AppendChildNode'
:
AppendChildCommand
,
'AppendSiblingNode'
:
AppendSiblingCommand
,
'RemoveNode'
:
RemoveNodeCommand
,
'
EditNode'
:
EditNode
Command
'
AppendParentNode'
:
AppendParent
Command
},
'contextmenu'
:
[{
command
:
'appendsiblingnode'
},
{
command
:
'appendchildnode'
},
{
command
:
'editnode'
},
{
command
:
'removenode'
},
{
divider
:
1
}],
'commandShortcutKeys'
:
{
'appendsiblingnode'
:
'normal::Enter'
,
'appendchildnode'
:
'normal::Insert|Tab'
,
'
editnode'
:
'normal::F2
'
,
'
appendparentnode'
:
'normal::Shift+Tab|normal::Shift+Insert
'
,
'removenode'
:
'normal::Del|Backspace'
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment