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
730566aa
Commit
730566aa
authored
Jun 08, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stash
parent
df4b9823
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
936 additions
and
674 deletions
+936
-674
import.js
import.js
+2
-0
kity
kity
+1
-1
layout.js
src/core/layout.js
+133
-20
minder.module.js
src/core/minder.module.js
+6
-1
minder.select.js
src/core/minder.select.js
+2
-2
node.js
src/core/node.js
+2
-1
theme.js
src/core/theme.js
+1
-1
default.js
src/layout/default.js
+83
-12
basestyle.js
src/module/basestyle.js
+17
-34
dragtree.js
src/module/dragtree.js
+275
-277
editor.js
src/module/editor.js
+0
-26
expand.js
src/module/expand.js
+232
-231
font.js
src/module/font.js
+42
-60
keyboard.js
src/module/keyboard.js
+6
-4
node.js
src/module/node.js
+79
-0
outline.js
src/module/outline.js
+12
-0
text.js
src/module/text.js
+39
-0
default.js
src/theme/default.js
+4
-4
No files found.
import.js
View file @
730566aa
...
...
@@ -25,6 +25,8 @@
'core/theme.js'
,
'layout/default.js'
,
'theme/default.js'
,
'module/node.js'
,
'module/text.js'
,
'module/outline.js'
,
'module/geometry.js'
,
'module/history.js'
,
...
...
kity
@
62a846c8
Subproject commit
093f66727667709bbf9054670c9b0cb20bb31998
Subproject commit
62a846c829a0306ba7493885b44c38d68cd3d232
src/core/layout.js
View file @
730566aa
var
Layout
=
kity
.
createClass
(
'Layout'
,
{
doLayout
:
function
(
node
)
{
throw
new
Error
(
'Not Implement: Layout.doLayout()'
);
},
getBranchBox
:
function
(
nodes
)
{
var
box
=
{
x
:
0
,
y
:
0
,
height
:
0
,
width
:
0
};
var
g
=
KityMinder
.
Geometry
;
var
i
,
node
,
matrix
,
contentBox
;
for
(
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
node
=
nodes
[
i
];
matrix
=
node
.
getLayoutTransform
();
contentBox
=
node
.
getContentBox
();
box
=
g
.
mergeBox
(
box
,
matrix
.
transformBox
(
contentBox
));
}
return
box
;
},
getTreeBox
:
function
(
nodes
)
{
var
box
=
{
x
:
0
,
y
:
0
,
height
:
0
,
width
:
0
};
var
g
=
KityMinder
.
Geometry
;
var
i
,
node
,
matrix
,
treeBox
;
for
(
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
node
=
nodes
[
i
];
matrix
=
node
.
getLayoutTransform
();
treeBox
=
node
.
getContentBox
();
if
(
node
.
children
.
length
)
{
treeBox
=
g
.
mergeBox
(
treeBox
,
this
.
getTreeBox
(
node
.
children
));
}
box
=
g
.
mergeBox
(
box
,
matrix
.
transformBox
(
treeBox
));
}
return
box
;
}
});
...
...
@@ -24,31 +67,101 @@ kity.extendClass(MinderNode, {
return
layout
;
},
applyLayoutResult
:
function
(
parentX
,
parentY
)
{
var
myX
=
parentX
+
this
.
layoutX
,
myY
=
parentY
+
this
.
layoutY
;
this
.
getRenderContainer
().
fxTranslate
(
myX
,
myY
);
this
.
getChildren
().
forEach
(
function
(
node
)
{
node
.
applyLayoutResult
(
myX
,
myY
);
});
setLayoutTransform
:
function
(
matrix
)
{
this
.
_layoutTransform
=
matrix
;
},
getLayoutTransform
:
function
()
{
return
this
.
_layoutTransform
||
new
kity
.
Matrix
();
},
getLayoutRoot
:
function
()
{
if
(
this
.
isLayoutRoot
())
{
return
this
;
}
return
this
.
parent
.
getLayoutRoot
();
},
layout
:
function
(
name
)
{
isLayoutRoot
:
function
()
{
return
this
.
getData
(
'layout'
)
||
this
.
isRoot
();
},
layout
:
function
(
name
,
duration
)
{
if
(
name
)
{
this
.
setData
(
'layout'
,
name
);
if
(
name
==
'inherit'
)
{
this
.
setData
(
'layout'
);
}
else
{
this
.
setData
(
'layout'
,
name
);
}
}
var
LayoutClass
=
KityMinder
.
_layout
[
this
.
getLayout
()];
var
layout
=
new
LayoutClass
();
layout
.
doLayout
(
this
);
this
.
applyLayoutResult
(
0
,
0
);
this
.
getMinder
().
layout
(
duration
);
return
this
;
},
}
});
kity
.
extendClass
(
Minder
,
{
layout
:
function
(
duration
)
{
getTreeBox
:
function
()
{
var
box
=
this
.
getContentBox
();
this
.
getChildren
().
forEach
(
function
(
child
)
{
box
=
KityMinder
.
Geometry
.
mergeBox
(
child
.
getTreeBox
(),
box
);
this
.
getRoot
().
traverse
(
function
(
node
)
{
node
.
setLayoutTransform
(
null
);
});
return
box
;
}
function
layoutNode
(
node
)
{
// layout all children first
node
.
children
.
forEach
(
function
(
child
)
{
layoutNode
(
child
);
});
var
LayoutClass
=
KityMinder
.
_layout
[
node
.
getLayout
()];
var
layout
=
new
LayoutClass
();
layout
.
doLayout
(
node
);
}
layoutNode
(
this
.
getRoot
());
return
this
.
applyLayoutResult
(
duration
);
},
applyLayoutResult
:
function
(
duration
)
{
var
root
=
this
.
getRoot
();
function
apply
(
node
,
pMatrix
)
{
var
matrix
=
node
.
getLayoutTransform
().
merge
(
pMatrix
);
var
lastMatrix
=
node
.
_lastLayoutTransform
||
new
kity
.
Matrix
();
if
(
!
matrix
.
equals
(
lastMatrix
))
{
// 如果当前有动画,停止动画
if
(
node
.
_layoutTimeline
)
{
node
.
_layoutTimeline
.
stop
();
delete
node
.
_layoutTimeline
;
}
// 如果要求以动画形式来更新,创建动画
if
(
duration
>
0
)
{
node
.
_layoutTimeline
=
new
kity
.
Animator
(
lastMatrix
,
matrix
,
function
(
rc
,
value
)
{
rc
.
setMatrix
(
node
.
_lastLayoutTransform
=
value
);
}).
start
(
node
.
getRenderContainer
(),
duration
,
'ease'
);
}
// 否则直接更新
else
{
node
.
getRenderContainer
().
setMatrix
(
matrix
);
node
.
_lastLayoutTransform
=
matrix
;
}
}
for
(
var
i
=
0
;
i
<
node
.
children
.
length
;
i
++
)
{
apply
(
node
.
children
[
i
],
matrix
);
}
}
apply
(
root
,
new
kity
.
Matrix
());
return
this
;
},
});
\ No newline at end of file
src/core/minder.module.js
View file @
730566aa
...
...
@@ -26,7 +26,12 @@ kity.extendClass(Minder, {
if
(
!
modulesPool
[
name
])
continue
;
// 执行模块初始化,抛出后续处理对象
moduleDeals
=
modulesPool
[
name
].
call
(
me
);
if
(
typeof
(
modulesPool
[
name
])
==
'function'
)
{
moduleDeals
=
modulesPool
[
name
].
call
(
me
);
}
else
{
moduleDeals
=
modulesPool
[
name
];
}
this
.
_modules
[
name
]
=
moduleDeals
;
if
(
moduleDeals
.
init
)
{
...
...
src/core/minder.select.js
View file @
730566aa
...
...
@@ -32,8 +32,8 @@ kity.extendClass(Minder, {
this
.
renderChangedSelection
(
nodes
);
return
this
;
},
select
:
function
(
nodes
,
is
Tog
gleSelect
)
{
if
(
is
Tog
gleSelect
)
{
select
:
function
(
nodes
,
is
Sin
gleSelect
)
{
if
(
is
Sin
gleSelect
)
{
this
.
removeAllSelectedNodes
();
}
var
me
=
this
;
...
...
src/core/node.js
View file @
730566aa
...
...
@@ -93,7 +93,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
* @param {String} text 文本数据
*/
setText
:
function
(
text
)
{
this
.
setData
(
'text'
,
text
);
return
this
.
setData
(
'text'
,
text
);
},
/**
...
...
@@ -207,6 +207,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
this
.
data
[
name
]
=
value
;
}
}
return
this
;
},
getRenderContainer
:
function
()
{
...
...
src/core/theme.js
View file @
730566aa
...
...
@@ -88,10 +88,10 @@ kity.extendClass(Minder, {
if
(
item
in
theme
)
{
value
=
theme
[
item
];
if
(
!
isNaN
(
value
))
return
value
;
if
(
Utils
.
isArray
(
value
)
&&
(
matcher
=
cssLikeValueMatcher
[
dir
]))
{
return
matcher
(
value
);
}
if
(
!
isNaN
(
value
))
return
value
;
}
return
null
;
...
...
src/layout/default.js
View file @
730566aa
...
...
@@ -3,18 +3,89 @@
KityMinder
.
registerLayout
(
'default'
,
kity
.
createClass
({
base
:
Layout
,
getSide
:
function
(
node
)
{
while
(
!
node
.
parent
.
isLayoutRoot
())
{
node
=
node
.
parent
;
}
var
mainIndex
=
node
.
getIndex
();
return
{
0
:
'right'
,
1
:
'right'
,
2
:
'left'
,
3
:
'left'
}[
mainIndex
]
||
(
mainIndex
%
2
?
'right'
:
'left'
);
},
doLayout
:
function
(
node
)
{
node
.
getChildren
().
forEach
(
function
(
childNode
)
{
childNode
.
layout
();
});
var
y
=
0
;
node
.
getChildren
().
forEach
(
function
(
childNode
)
{
childNode
.
layoutX
=
node
.
getContentBox
().
right
-
childNode
.
getContentBox
().
x
+
node
.
getStyle
(
'margin-right'
);
childNode
.
layoutY
=
y
;
y
+=
50
;
console
.
log
(
childNode
.
layoutX
,
childNode
.
layoutY
);
});
node
.
layoutX
=
0
;
node
.
layoutY
=
0
;
var
layout
=
this
;
function
arrange
(
node
,
children
,
side
)
{
//if (!children.length) return;
var
height
=
0
;
var
childBoxes
=
children
.
map
(
function
(
node
,
index
,
children
)
{
var
box
=
layout
.
getTreeBox
([
node
]);
height
+=
box
.
height
;
if
(
index
>
0
)
{
height
+=
children
[
index
-
1
].
getStyle
(
'margin-bottom'
);
height
+=
node
.
getStyle
(
'margin-top'
);
}
return
box
;
});
var
contentBox
=
node
.
getContentBox
();
var
x
,
y
=
-
height
/
2
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
if
(
side
==
'right'
)
{
x
=
contentBox
.
x
+
contentBox
.
width
-
children
[
i
].
getContentBox
().
x
;
x
+=
node
.
getStyle
(
'margin-right'
)
+
node
.
children
[
i
].
getStyle
(
'margin-left'
);
}
else
{
x
=
contentBox
.
x
-
children
[
i
].
getContentBox
().
width
-
children
[
i
].
getContentBox
().
x
;
x
-=
node
.
getStyle
(
'margin-left'
)
+
node
.
children
[
i
].
getStyle
(
'margin-right'
);
}
y
+=
childBoxes
[
i
].
height
/
2
;
if
(
i
>
0
)
{
y
+=
children
[
i
].
getStyle
(
'margin-top'
);
}
children
[
i
].
setLayoutTransform
(
new
kity
.
Matrix
().
translate
(
x
,
y
));
y
+=
childBoxes
[
i
].
height
/
2
+
children
[
i
].
getStyle
(
'margin-bottom'
);
}
var
branchBox
=
layout
.
getBranchBox
(
children
);
var
dy
=
(
branchBox
.
y
+
branchBox
.
height
/
2
)
-
(
contentBox
.
y
+
contentBox
.
height
/
2
);
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getLayoutTransform
().
translate
(
0
,
-
dy
);
}
}
function
layoutRoot
(
node
)
{
var
mains
=
node
.
getChildren
();
var
group
=
{
left
:
[],
right
:
[]
};
mains
.
forEach
(
function
(
main
)
{
group
[
layout
.
getSide
(
main
)].
push
(
main
);
});
arrange
(
node
,
group
.
left
,
'left'
);
arrange
(
node
,
group
.
right
,
'right'
);
}
if
(
node
.
isLayoutRoot
())
{
layoutRoot
(
node
);
}
else
{
arrange
(
node
,
node
.
children
,
layout
.
getSide
(
node
));
}
}
}));
\ No newline at end of file
src/module/basestyle.js
View file @
730566aa
KityMinder
.
registerModule
(
"basestylemodule"
,
function
()
{
KityMinder
.
registerModule
(
'basestylemodule'
,
function
()
{
var
km
=
this
;
return
{
"commands"
:
{
"bold"
:
kity
.
createClass
(
"boldCommand"
,
{
'commands'
:
{
'bold'
:
kity
.
createClass
(
'boldCommand'
,
{
base
:
Command
,
execute
:
function
()
{
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
this
.
queryState
(
'bold'
)
==
1
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
);
n
.
getTextShape
().
setAttr
(
'font-weight'
);
km
.
updateLayout
(
n
);
n
.
setData
(
'font-weight'
).
render
();
});
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-weight'
,
'bold'
);
km
.
updateLayout
(
n
);
n
.
setData
(
'font-weight'
,
'bold'
).
render
();
});
}
km
.
layout
();
},
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
...
...
@@ -29,7 +26,7 @@ KityMinder.registerModule("basestylemodule", function() {
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'
bold
'
))
{
if
(
n
&&
n
.
getData
(
'
font-weight
'
))
{
result
=
1
;
return
false
;
}
...
...
@@ -37,25 +34,23 @@ KityMinder.registerModule("basestylemodule", function() {
return
result
;
}
}),
"italic"
:
kity
.
createClass
(
"italicCommand"
,
{
'italic'
:
kity
.
createClass
(
'italicCommand'
,
{
base
:
Command
,
execute
:
function
()
{
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
this
.
queryState
(
'italic'
)
==
1
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
);
n
.
getTextShape
().
setAttr
(
'font-style'
);
km
.
updateLayout
(
n
);
n
.
setData
(
'font-style'
).
render
();
});
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-style'
,
'italic'
);
km
.
updateLayout
(
n
);
n
.
setData
(
'font-style'
,
'italic'
).
render
();
});
}
km
.
layout
();
},
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
...
...
@@ -64,7 +59,7 @@ KityMinder.registerModule("basestylemodule", function() {
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'
italic
'
))
{
if
(
n
&&
n
.
getData
(
'
font-style
'
))
{
result
=
1
;
return
false
;
}
...
...
@@ -74,20 +69,8 @@ KityMinder.registerModule("basestylemodule", function() {
})
},
addShortcutKeys
:
{
"bold"
:
"ctrl+b"
,
//bold
"italic"
:
"ctrl+i"
//italic
},
"events"
:
{
"afterrendernodecenter"
:
function
(
e
)
{
//加粗
if
(
e
.
node
.
getData
(
'bold'
))
{
e
.
node
.
getTextShape
().
setAttr
(
'font-weight'
,
'bold'
);
}
if
(
e
.
node
.
getData
(
'italic'
))
{
e
.
node
.
getTextShape
().
setAttr
(
'font-style'
,
'italic'
);
}
}
'bold'
:
'ctrl+b'
,
//bold
'italic'
:
'ctrl+i'
//italic
}
};
});
\ No newline at end of file
src/module/dragtree.js
View file @
730566aa
This diff is collapsed.
Click to expand it.
src/module/editor.js
View file @
730566aa
...
...
@@ -345,32 +345,6 @@ KityMinder.registerModule('TextEditModule', function() {
'textedit.mousewheel'
:
function
()
{
receiver
.
setContainerStyle
();
}
},
'renderers'
:
{
center
:
kity
.
createClass
(
'TextRenderer'
,
{
base
:
Renderer
,
create
:
function
(
node
)
{
var
textShape
=
new
kity
.
Text
()
.
setVerticalAlign
(
'middle'
)
.
setId
(
KityMinder
.
uuid
(
'node_text'
));
node
.
getRenderContainer
().
addShape
(
textShape
);
node
.
getTextShape
=
function
()
{
return
textShape
;
};
},
update
:
function
(
node
)
{
return
node
.
getTextShape
()
.
setContent
(
node
.
getText
())
.
setFont
({
family
:
node
.
getStyle
(
'font-family'
),
size
:
node
.
getStyle
(
'font-size'
)
})
.
fill
(
node
.
getData
(
'color'
)
||
node
.
getStyle
(
'color'
))
.
getBoundaryBox
();
}
})
}
};
});
\ No newline at end of file
src/module/expand.js
View file @
730566aa
This diff is collapsed.
Click to expand it.
src/module/font.js
View file @
730566aa
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
return
{
defaultOptions
:
{
'fontfamily'
:
[
{
'fontfamily'
:
[{
name
:
'songti'
,
val
:
'宋体,SimSun'
},
{
...
...
@@ -38,100 +38,82 @@ KityMinder.registerModule( "fontmodule", function () {
},
{
name
:
'sans-serif'
,
val
:
'sans-serif'
}
],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
}],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
},
"commands"
:
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
color
)
{
execute
:
function
(
km
,
color
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontcolor'
,
color
);
n
.
getTextShape
().
fill
(
color
)
}
)
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'color'
,
color
);
n
.
render
();
}
);
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'
font
color'
);
return
km
.
getSelectedNodes
()[
0
].
getData
(
'color'
);
}
return
'mixed'
;
}
}
),
"backgroundcolor"
:
kity
.
createClass
(
"backgroudcolorCommand"
,
{
}),
"backgroundcolor"
:
kity
.
createClass
(
"backgroudcolorCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
color
)
{
execute
:
function
(
km
,
color
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'backgroundcolor'
,
color
);
n
.
getLayout
().
bgRect
.
fill
(
color
);
}
);
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'background'
,
color
);
n
.
render
(
);
});
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
queryValue
:
function
(
km
)
{
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'background
color
'
);
return
km
.
getSelectedNodes
()[
0
].
getData
(
'background'
);
}
return
'mixed'
;
}
}
),
"fontfamily"
:
kity
.
createClass
(
"fontfamilyCommand"
,
{
}),
"fontfamily"
:
kity
.
createClass
(
"fontfamilyCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
family
)
{
execute
:
function
(
km
,
family
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontfamily'
,
family
);
n
.
getTextShape
().
setAttr
(
'font-family'
,
family
);
km
.
updateLayout
(
n
)
}
)
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'font-family'
,
family
);
n
.
render
(
);
km
.
layout
();
}
);
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
}
}
),
"fontsize"
:
kity
.
createClass
(
"fontsizeCommand"
,
{
}),
"fontsize"
:
kity
.
createClass
(
"fontsizeCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
size
)
{
execute
:
function
(
km
,
size
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontsize'
,
size
);
n
.
getTextShape
().
setSize
(
size
);
km
.
updateLayout
(
n
)
}
)
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'font-size'
,
size
);
n
.
render
(
);
km
.
layout
(
300
);
}
);
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
}
}
)
},
"events"
:
{
"afterrendernodecenter"
:
function
(
e
)
{
var
val
;
if
(
val
=
e
.
node
.
getData
(
'fontfamily'
)
)
{
e
.
node
.
getTextShape
().
setAttr
(
'font-family'
,
val
);
}
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
e
.
node
.
getTextShape
().
fill
(
val
);
}
if
(
val
=
e
.
node
.
getData
(
'backgroundcolor'
)
)
{
e
.
node
.
getLayout
().
bgRect
.
fill
(
val
);
}
if
(
val
=
e
.
node
.
getData
(
'fontsize'
)
)
{
e
.
node
.
getTextShape
().
setSize
(
val
);
}
}
})
}
};
}
);
\ No newline at end of file
});
\ No newline at end of file
src/module/keyboard.js
View file @
730566aa
...
...
@@ -127,6 +127,7 @@ KityMinder.registerModule("KeyboardModule", function() {
km
.
select
(
nextNode
,
true
);
}
}
return
{
'events'
:
{
...
...
@@ -137,26 +138,27 @@ KityMinder.registerModule("KeyboardModule", function() {
var
keys
=
KityMinder
.
keymap
;
var
node
=
e
.
getTargetNode
();
var
lang
=
this
.
getLang
();
this
.
receiver
.
keydownNode
=
node
;
switch
(
e
.
originEvent
.
keyCode
)
{
case
keys
.
Enter
:
this
.
execCommand
(
'
appendSiblingNode'
,
new
MinderNode
(
this
,
this
.
getLang
().
topic
)
);
this
.
execCommand
(
'
AppendSiblingNode'
,
lang
.
topic
);
e
.
preventDefault
();
break
;
case
keys
.
Tab
:
this
.
execCommand
(
'
appendChildNode'
,
new
MinderNode
(
this
,
this
.
getLang
().
topic
)
);
this
.
execCommand
(
'
AppendChildNode'
,
lang
.
topic
);
e
.
preventDefault
();
break
;
case
keys
.
Backspace
:
case
keys
.
Del
:
e
.
preventDefault
();
this
.
execCommand
(
'
removen
ode'
);
this
.
execCommand
(
'
RemoveN
ode'
);
break
;
case
keys
.
F2
:
e
.
preventDefault
();
this
.
execCommand
(
'
editn
ode'
);
this
.
execCommand
(
'
EditN
ode'
);
break
;
case
keys
.
Left
:
...
...
src/module/node.js
0 → 100644
View file @
730566aa
kity
.
extendClass
(
Minder
,
{
appendChildNode
:
function
(
parent
,
node
,
index
)
{
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendSiblingNode
.
call
(
this
,
sibling
,
node
);
},
});
var
AppendChildCommand
=
kity
.
createClass
(
'AppendChildCommand'
,
{
base
:
Command
,
execute
:
function
(
km
,
text
)
{
var
parent
=
km
.
getSelectedNode
();
var
node
=
km
.
createNode
(
text
);
if
(
!
parent
)
{
return
null
;
}
//parent.expand();
parent
.
appendChild
(
node
);
km
.
select
(
node
,
true
);
node
.
render
();
km
.
layout
(
300
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
return
selectedNode
?
0
:
-
1
;
}
});
var
AppendSiblingCommand
=
kity
.
createClass
(
'AppendSiblingCommand'
,
{
base
:
Command
,
execute
:
function
(
km
,
text
)
{
var
sibling
=
km
.
getSelectedNode
();
var
parent
=
sibling
.
parent
;
var
node
=
km
.
createNode
(
text
);
if
(
!
parent
)
{
return
null
;
}
parent
.
insertChild
(
node
,
sibling
.
getIndex
()
+
1
);
km
.
select
(
node
,
true
);
node
.
render
();
km
.
layout
(
300
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
return
selectedNode
?
0
:
-
1
;
}
});
var
RemoveNodeCommand
=
kity
.
createClass
(
'RemoverNodeCommand'
,
{
base
:
Command
,
execute
:
function
(
km
,
text
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
ancestor
=
km
.
getSelectedAncestors
()[
0
];
nodes
.
forEach
(
function
(
node
)
{
km
.
removeNode
(
node
);
});
km
.
select
(
ancestor
,
true
);
km
.
layout
(
300
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
return
selectedNode
?
0
:
-
1
;
}
});
KityMinder
.
registerModule
(
'NodeModule'
,
function
()
{
return
{
commands
:
{
'AppendChildNode'
:
AppendChildCommand
,
'AppendSiblingNode'
:
AppendSiblingCommand
,
'RemoveNode'
:
RemoveNodeCommand
}
};
});
\ No newline at end of file
src/module/outline.js
View file @
730566aa
/* global Renderer: true */
var
wireframe
=
true
;
KityMinder
.
registerModule
(
'OutlineModule'
,
function
()
{
return
{
renderers
:
{
...
...
@@ -9,6 +11,12 @@ KityMinder.registerModule('OutlineModule', function() {
create
:
function
(
node
)
{
var
outline
=
this
.
outline
=
new
kity
.
Rect
().
setId
(
KityMinder
.
uuid
(
'node_outline'
));
node
.
getRenderContainer
().
prependShape
(
outline
);
if
(
wireframe
)
{
var
oxy
=
this
.
oxy
=
new
kity
.
Path
().
stroke
(
'white'
).
setPathData
(
'M0,-50L0,50M-50,0L50,0'
).
setOpacity
(
0.5
);
var
box
=
this
.
wireframe
=
new
kity
.
Rect
().
stroke
(
'lightgreen'
);
node
.
getRenderContainer
().
addShapes
([
oxy
,
box
]);
}
},
update
:
function
(
node
)
{
...
...
@@ -30,6 +38,10 @@ KityMinder.registerModule('OutlineModule', function() {
.
fill
(
node
.
isSelected
()
?
node
.
getStyle
(
'selected-background'
)
:
node
.
getStyle
(
'background'
));
if
(
wireframe
)
{
this
.
wireframe
.
setPosition
(
outlineBox
.
x
,
outlineBox
.
y
).
setSize
(
outlineBox
.
width
,
outlineBox
.
height
);
}
return
outlineBox
;
}
})
...
...
src/module/text.js
0 → 100644
View file @
730566aa
/* global Renderer: true */
kity
.
extendClass
(
MinderNode
,
{
getTextShape
:
function
()
{
return
this
.
_textShape
;
}
});
KityMinder
.
registerModule
(
'text'
,
{
'renderers'
:
{
center
:
kity
.
createClass
(
'TextRenderer'
,
{
base
:
Renderer
,
create
:
function
(
node
)
{
var
textShape
=
new
kity
.
Text
().
setId
(
KityMinder
.
uuid
(
'node_text'
));
node
.
getRenderContainer
().
addShape
(
textShape
);
node
.
_textShape
=
textShape
;
},
update
:
function
(
node
)
{
function
dataOrStyle
(
name
)
{
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
}
return
node
.
getTextShape
()
.
setContent
(
node
.
getText
())
.
setFont
({
family
:
dataOrStyle
(
'font-family'
),
size
:
dataOrStyle
(
'font-size'
),
weight
:
dataOrStyle
(
'font-weight'
),
style
:
dataOrStyle
(
'font-style'
)
})
.
setVerticalAlign
(
'middle'
)
.
fill
(
node
.
getData
(
'color'
)
||
node
.
getStyle
(
'color'
))
.
getBoundaryBox
();
}
})
}
});
\ No newline at end of file
src/theme/default.js
View file @
730566aa
...
...
@@ -4,7 +4,7 @@ KityMinder.registerTheme('default', {
'root-stroke'
:
'none'
,
'root-font-size'
:
24
,
'root-padding'
:
[
15
,
25
],
'root-margin'
:
0
,
'root-margin'
:
3
0
,
'root-radius'
:
30
,
'root-space'
:
10
,
...
...
@@ -13,7 +13,7 @@ KityMinder.registerTheme('default', {
'main-stroke'
:
'none'
,
'main-font-size'
:
16
,
'main-padding'
:
[
6
,
20
],
'main-margin'
:
[
0
,
10
,
30
,
5
0
],
'main-margin'
:
[
15
,
1
0
],
'main-radius'
:
10
,
'main-space'
:
5
,
...
...
@@ -22,8 +22,8 @@ KityMinder.registerTheme('default', {
'sub-stroke'
:
'white'
,
'sub-font-size'
:
12
,
'sub-padding'
:
[
5
,
10
],
'sub-margin'
:
[
0
,
10
,
20
,
6
],
'sub-radius'
:
0
,
'sub-margin'
:
[
5
,
10
],
'sub-radius'
:
5
,
'sub-space'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
...
...
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