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
Show 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 @@
...
@@ -25,6 +25,8 @@
'core/theme.js'
,
'core/theme.js'
,
'layout/default.js'
,
'layout/default.js'
,
'theme/default.js'
,
'theme/default.js'
,
'module/node.js'
,
'module/text.js'
,
'module/outline.js'
,
'module/outline.js'
,
'module/geometry.js'
,
'module/geometry.js'
,
'module/history.js'
,
'module/history.js'
,
...
...
kity
@
62a846c8
Subproject commit
093f66727667709bbf9054670c9b0cb20bb31998
Subproject commit
62a846c829a0306ba7493885b44c38d68cd3d232
src/core/layout.js
View file @
730566aa
var
Layout
=
kity
.
createClass
(
'Layout'
,
{
var
Layout
=
kity
.
createClass
(
'Layout'
,
{
doLayout
:
function
(
node
)
{
doLayout
:
function
(
node
)
{
throw
new
Error
(
'Not Implement: Layout.doLayout()'
);
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, {
...
@@ -24,31 +67,101 @@ kity.extendClass(MinderNode, {
return
layout
;
return
layout
;
},
},
applyLayoutResult
:
function
(
parentX
,
parentY
)
{
setLayoutTransform
:
function
(
matrix
)
{
var
myX
=
parentX
+
this
.
layoutX
,
this
.
_layoutTransform
=
matrix
;
myY
=
parentY
+
this
.
layoutY
;
this
.
getRenderContainer
().
fxTranslate
(
myX
,
myY
);
this
.
getChildren
().
forEach
(
function
(
node
)
{
node
.
applyLayoutResult
(
myX
,
myY
);
});
},
},
layout
:
function
(
name
)
{
getLayoutTransform
:
function
()
{
return
this
.
_layoutTransform
||
new
kity
.
Matrix
();
},
getLayoutRoot
:
function
()
{
if
(
this
.
isLayoutRoot
())
{
return
this
;
}
return
this
.
parent
.
getLayoutRoot
();
},
isLayoutRoot
:
function
()
{
return
this
.
getData
(
'layout'
)
||
this
.
isRoot
();
},
layout
:
function
(
name
,
duration
)
{
if
(
name
)
{
if
(
name
)
{
if
(
name
==
'inherit'
)
{
this
.
setData
(
'layout'
);
}
else
{
this
.
setData
(
'layout'
,
name
);
this
.
setData
(
'layout'
,
name
);
}
}
var
LayoutClass
=
KityMinder
.
_layout
[
this
.
getLayout
()];
}
var
layout
=
new
LayoutClass
();
layout
.
doLayout
(
this
);
this
.
getMinder
().
layout
(
duration
);
this
.
applyLayoutResult
(
0
,
0
);
return
this
;
return
this
;
},
}
});
getTreeBox
:
function
()
{
kity
.
extendClass
(
Minder
,
{
var
box
=
this
.
getContentBox
();
this
.
getChildren
().
forEach
(
function
(
child
)
{
layout
:
function
(
duration
)
{
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, {
...
@@ -26,7 +26,12 @@ kity.extendClass(Minder, {
if
(
!
modulesPool
[
name
])
continue
;
if
(
!
modulesPool
[
name
])
continue
;
// 执行模块初始化,抛出后续处理对象
// 执行模块初始化,抛出后续处理对象
if
(
typeof
(
modulesPool
[
name
])
==
'function'
)
{
moduleDeals
=
modulesPool
[
name
].
call
(
me
);
moduleDeals
=
modulesPool
[
name
].
call
(
me
);
}
else
{
moduleDeals
=
modulesPool
[
name
];
}
this
.
_modules
[
name
]
=
moduleDeals
;
this
.
_modules
[
name
]
=
moduleDeals
;
if
(
moduleDeals
.
init
)
{
if
(
moduleDeals
.
init
)
{
...
...
src/core/minder.select.js
View file @
730566aa
...
@@ -32,8 +32,8 @@ kity.extendClass(Minder, {
...
@@ -32,8 +32,8 @@ kity.extendClass(Minder, {
this
.
renderChangedSelection
(
nodes
);
this
.
renderChangedSelection
(
nodes
);
return
this
;
return
this
;
},
},
select
:
function
(
nodes
,
is
Tog
gleSelect
)
{
select
:
function
(
nodes
,
is
Sin
gleSelect
)
{
if
(
is
Tog
gleSelect
)
{
if
(
is
Sin
gleSelect
)
{
this
.
removeAllSelectedNodes
();
this
.
removeAllSelectedNodes
();
}
}
var
me
=
this
;
var
me
=
this
;
...
...
src/core/node.js
View file @
730566aa
...
@@ -93,7 +93,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
...
@@ -93,7 +93,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
* @param {String} text 文本数据
* @param {String} text 文本数据
*/
*/
setText
:
function
(
text
)
{
setText
:
function
(
text
)
{
this
.
setData
(
'text'
,
text
);
return
this
.
setData
(
'text'
,
text
);
},
},
/**
/**
...
@@ -207,6 +207,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
...
@@ -207,6 +207,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
this
.
data
[
name
]
=
value
;
this
.
data
[
name
]
=
value
;
}
}
}
}
return
this
;
},
},
getRenderContainer
:
function
()
{
getRenderContainer
:
function
()
{
...
...
src/core/theme.js
View file @
730566aa
...
@@ -88,10 +88,10 @@ kity.extendClass(Minder, {
...
@@ -88,10 +88,10 @@ kity.extendClass(Minder, {
if
(
item
in
theme
)
{
if
(
item
in
theme
)
{
value
=
theme
[
item
];
value
=
theme
[
item
];
if
(
!
isNaN
(
value
))
return
value
;
if
(
Utils
.
isArray
(
value
)
&&
(
matcher
=
cssLikeValueMatcher
[
dir
]))
{
if
(
Utils
.
isArray
(
value
)
&&
(
matcher
=
cssLikeValueMatcher
[
dir
]))
{
return
matcher
(
value
);
return
matcher
(
value
);
}
}
if
(
!
isNaN
(
value
))
return
value
;
}
}
return
null
;
return
null
;
...
...
src/layout/default.js
View file @
730566aa
...
@@ -3,18 +3,89 @@
...
@@ -3,18 +3,89 @@
KityMinder
.
registerLayout
(
'default'
,
kity
.
createClass
({
KityMinder
.
registerLayout
(
'default'
,
kity
.
createClass
({
base
:
Layout
,
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
)
{
doLayout
:
function
(
node
)
{
node
.
getChildren
().
forEach
(
function
(
childNode
)
{
var
layout
=
this
;
childNode
.
layout
();
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
y
=
0
;
node
.
getChildren
().
forEach
(
function
(
childNode
)
{
var
contentBox
=
node
.
getContentBox
();
childNode
.
layoutX
=
node
.
getContentBox
().
right
-
childNode
.
getContentBox
().
x
+
node
.
getStyle
(
'margin-right'
);
var
x
,
y
=
-
height
/
2
;
childNode
.
layoutY
=
y
;
y
+=
50
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
console
.
log
(
childNode
.
layoutX
,
childNode
.
layoutY
);
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
);
});
});
node
.
layoutX
=
0
;
node
.
layoutY
=
0
;
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
;
var
km
=
this
;
return
{
return
{
"commands"
:
{
'commands'
:
{
"bold"
:
kity
.
createClass
(
"boldCommand"
,
{
'bold'
:
kity
.
createClass
(
'boldCommand'
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
()
{
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
if
(
this
.
queryState
(
'bold'
)
==
1
)
{
if
(
this
.
queryState
(
'bold'
)
==
1
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
);
n
.
setData
(
'font-weight'
).
render
();
n
.
getTextShape
().
setAttr
(
'font-weight'
);
km
.
updateLayout
(
n
);
});
});
}
else
{
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
,
true
);
n
.
setData
(
'font-weight'
,
'bold'
).
render
();
n
.
getTextShape
().
setAttr
(
'font-weight'
,
'bold'
);
km
.
updateLayout
(
n
);
});
});
}
}
km
.
layout
();
},
},
queryState
:
function
()
{
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
var
nodes
=
km
.
getSelectedNodes
(),
...
@@ -29,7 +26,7 @@ KityMinder.registerModule("basestylemodule", function() {
...
@@ -29,7 +26,7 @@ KityMinder.registerModule("basestylemodule", function() {
return
-
1
;
return
-
1
;
}
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'
bold
'
))
{
if
(
n
&&
n
.
getData
(
'
font-weight
'
))
{
result
=
1
;
result
=
1
;
return
false
;
return
false
;
}
}
...
@@ -37,25 +34,23 @@ KityMinder.registerModule("basestylemodule", function() {
...
@@ -37,25 +34,23 @@ KityMinder.registerModule("basestylemodule", function() {
return
result
;
return
result
;
}
}
}),
}),
"italic"
:
kity
.
createClass
(
"italicCommand"
,
{
'italic'
:
kity
.
createClass
(
'italicCommand'
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
()
{
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
if
(
this
.
queryState
(
'italic'
)
==
1
)
{
if
(
this
.
queryState
(
'italic'
)
==
1
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
);
n
.
setData
(
'font-style'
).
render
();
n
.
getTextShape
().
setAttr
(
'font-style'
);
km
.
updateLayout
(
n
);
});
});
}
else
{
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
,
true
);
n
.
setData
(
'font-style'
,
'italic'
).
render
();
n
.
getTextShape
().
setAttr
(
'font-style'
,
'italic'
);
km
.
updateLayout
(
n
);
});
});
}
}
km
.
layout
();
},
},
queryState
:
function
()
{
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
var
nodes
=
km
.
getSelectedNodes
(),
...
@@ -64,7 +59,7 @@ KityMinder.registerModule("basestylemodule", function() {
...
@@ -64,7 +59,7 @@ KityMinder.registerModule("basestylemodule", function() {
return
-
1
;
return
-
1
;
}
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'
italic
'
))
{
if
(
n
&&
n
.
getData
(
'
font-style
'
))
{
result
=
1
;
result
=
1
;
return
false
;
return
false
;
}
}
...
@@ -74,20 +69,8 @@ KityMinder.registerModule("basestylemodule", function() {
...
@@ -74,20 +69,8 @@ KityMinder.registerModule("basestylemodule", function() {
})
})
},
},
addShortcutKeys
:
{
addShortcutKeys
:
{
"bold"
:
"ctrl+b"
,
//bold
'bold'
:
'ctrl+b'
,
//bold
"italic"
:
"ctrl+i"
//italic
'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'
);
}
}
}
}
};
};
});
});
\ 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() {
...
@@ -345,32 +345,6 @@ KityMinder.registerModule('TextEditModule', function() {
'textedit.mousewheel'
:
function
()
{
'textedit.mousewheel'
:
function
()
{
receiver
.
setContainerStyle
();
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
KityMinder
.
registerModule
(
"Expand"
,
function
()
{
KityMinder
.
registerModule
(
'Expand'
,
function
()
{
var
minder
=
this
;
var
minder
=
this
;
var
EXPAND_STATE_DATA
=
'expandState'
,
var
EXPAND_STATE_DATA
=
'expandState'
,
STATE_EXPAND
=
'expand'
,
STATE_EXPAND
=
'expand'
,
STATE_COLLAPSE
=
'collapse'
;
STATE_COLLAPSE
=
'collapse'
;
var
layerTravel
=
function
(
root
,
fn
)
{
var
layerTravel
=
function
(
root
,
fn
)
{
var
_buffer
=
[
root
];
var
_buffer
=
[
root
];
while
(
_buffer
.
length
!==
0
)
{
while
(
_buffer
.
length
!==
0
)
{
fn
(
_buffer
[
0
]
);
fn
(
_buffer
[
0
]
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
_buffer
.
shift
();
}
}
}
};
//获取选中的最上层节点
//获取选中的最上层节点
var
filterDuplicate
=
function
(
nodes
)
{
var
filterDuplicate
=
function
(
nodes
)
{
var
_buffer
=
(
[]
).
concat
(
nodes
);
var
_buffer
=
([]).
concat
(
nodes
);
var
resultSet
=
[];
var
resultSet
=
[];
for
(
var
i
=
0
;
i
<
_buffer
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
_buffer
.
length
;
i
++
)
{
var
parent
=
_buffer
[
i
].
getParent
();
var
parent
=
_buffer
[
i
].
getParent
();
if
(
!
parent
)
{
if
(
!
parent
)
{
resultSet
=
[
_buffer
[
i
]
];
resultSet
=
[
_buffer
[
i
]
];
break
;
break
;
}
else
{
}
else
{
//筛选
//筛选
while
(
parent
)
{
while
(
parent
)
{
if
(
_buffer
.
indexOf
(
parent
)
!==
-
1
)
{
if
(
_buffer
.
indexOf
(
parent
)
!==
-
1
)
{
_buffer
[
i
]
=
null
;
_buffer
[
i
]
=
null
;
break
;
break
;
}
}
parent
=
parent
.
getParent
();
parent
=
parent
.
getParent
();
}
}
if
(
_buffer
[
i
]
)
resultSet
.
push
(
_buffer
[
i
]
);
if
(
_buffer
[
i
])
resultSet
.
push
(
_buffer
[
i
]
);
}
}
}
}
return
resultSet
;
return
resultSet
;
}
};
var
expandAll
=
function
(
km
,
deal
)
{
var
expandAll
=
function
(
km
,
deal
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
var
selectedNodes
=
km
.
getSelectedNodes
();
var
topNodes
=
filterDuplicate
(
selectedNodes
);
var
topNodes
=
filterDuplicate
(
selectedNodes
);
if
(
selectedNodes
.
length
===
0
||
selectedNodes
[
0
].
getType
()
===
'root'
||
topNodes
[
0
].
getType
()
===
'root'
)
{
if
(
selectedNodes
.
length
===
0
||
selectedNodes
[
0
].
getType
()
===
'root'
||
topNodes
[
0
].
getType
()
===
'root'
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
if
(
deal
===
'expand'
)
n
.
expand
();
if
(
deal
===
'expand'
)
n
.
expand
();
else
n
.
collapse
();
else
n
.
collapse
();
}
);
}
);
km
.
initStyle
();
km
.
initStyle
();
}
else
{
}
else
{
for
(
var
i
=
0
;
i
<
topNodes
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
topNodes
.
length
;
i
++
)
{
var
node
=
topNodes
[
i
];
var
node
=
topNodes
[
i
];
var
children
=
node
.
getChildren
();
var
children
=
node
.
getChildren
();
if
(
children
.
length
===
0
)
{
if
(
children
.
length
===
0
)
{
continue
;
continue
;
}
else
{
}
else
{
layerTravel
(
node
,
function
(
n
)
{
layerTravel
(
node
,
function
(
n
)
{
if
(
n
!==
node
)
{
if
(
n
!==
node
)
{
if
(
deal
===
'expand'
)
n
.
expand
();
if
(
deal
===
'expand'
)
n
.
expand
();
else
n
.
collapse
();
else
n
.
collapse
();
}
}
}
);
}
);
var
judge_val
;
var
judge_val
;
if
(
deal
===
'expand'
)
{
if
(
deal
===
'expand'
)
{
judge_val
=
!
node
.
isExpanded
();
judge_val
=
!
node
.
isExpanded
();
}
else
{
}
else
{
judge_val
=
node
.
isExpanded
();
judge_val
=
node
.
isExpanded
();
}
}
if
(
judge_val
)
{
if
(
judge_val
)
{
km
.
expandNode
(
node
);
km
.
expandNode
(
node
);
}
else
{
}
else
{
km
.
expandNode
(
node
);
km
.
expandNode
(
node
);
km
.
expandNode
(
node
);
km
.
expandNode
(
node
);
}
}
}
}
}
}
}
}
for
(
var
j
=
0
;
j
<
selectedNodes
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
selectedNodes
.
length
;
j
++
)
{
km
.
highlightNode
(
selectedNodes
[
j
]
);
km
.
highlightNode
(
selectedNodes
[
j
]
);
}
}
}
}
...
@@ -103,23 +104,23 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -103,23 +104,23 @@ KityMinder.registerModule( "Expand", function () {
* @param {int} deep_level 指定的层数
* @param {int} deep_level 指定的层数
* @param {Function} policy_after_level 超过的层数执行的策略
* @param {Function} policy_after_level 超过的层数执行的策略
*/
*/
function
generateDeepPolicy
(
deep_level
,
policy_after_level
)
{
function
generateDeepPolicy
(
deep_level
,
policy_after_level
)
{
return
function
(
node
,
state
,
policy
,
level
)
{
return
function
(
node
,
state
,
policy
,
level
)
{
var
children
,
child
,
i
;
var
children
,
child
,
i
;
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
level
=
level
||
1
;
level
=
level
||
1
;
children
=
node
.
getChildren
();
children
=
node
.
getChildren
();
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
child
=
children
[
i
];
child
=
children
[
i
];
if
(
level
<=
deep_level
)
{
if
(
level
<=
deep_level
)
{
policy
(
child
,
state
,
policy
,
level
+
1
);
policy
(
child
,
state
,
policy
,
level
+
1
);
}
else
if
(
policy_after_level
)
{
}
else
if
(
policy_after_level
)
{
policy_after_level
(
child
,
state
,
policy
,
level
+
1
);
policy_after_level
(
child
,
state
,
policy
,
level
+
1
);
}
}
}
}
...
@@ -140,8 +141,8 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -140,8 +141,8 @@ KityMinder.registerModule( "Expand", function () {
/**
/**
* 策略 1:只修改当前节点的状态,不递归子节点的状态
* 策略 1:只修改当前节点的状态,不递归子节点的状态
*/
*/
KEEP_STATE
:
function
(
node
,
state
,
policy
)
{
KEEP_STATE
:
function
(
node
,
state
,
policy
)
{
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
},
},
generateDeepPolicy
:
generateDeepPolicy
,
generateDeepPolicy
:
generateDeepPolicy
,
...
@@ -149,24 +150,24 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -149,24 +150,24 @@ KityMinder.registerModule( "Expand", function () {
/**
/**
* 策略 2:把操作进行到儿子
* 策略 2:把操作进行到儿子
*/
*/
DEEP_TO_CHILD
:
generateDeepPolicy
(
1
),
DEEP_TO_CHILD
:
generateDeepPolicy
(
1
),
/**
/**
* 策略 3:把操作进行到叶子
* 策略 3:把操作进行到叶子
*/
*/
DEEP_TO_LEAF
:
generateDeepPolicy
(
Number
.
MAX_VALUE
)
DEEP_TO_LEAF
:
generateDeepPolicy
(
Number
.
MAX_VALUE
)
};
};
// 将展开的操作和状态读取接口拓展到 MinderNode 上
// 将展开的操作和状态读取接口拓展到 MinderNode 上
kity
.
extendClass
(
MinderNode
,
{
kity
.
extendClass
(
MinderNode
,
{
/**
/**
* 使用指定的策略展开节点
* 使用指定的策略展开节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
*/
*/
expand
:
function
(
policy
)
{
expand
:
function
(
policy
)
{
policy
=
policy
||
EXPAND_POLICY
.
KEEP_STATE
;
policy
=
policy
||
EXPAND_POLICY
.
KEEP_STATE
;
policy
(
this
,
STATE_EXPAND
,
policy
);
policy
(
this
,
STATE_EXPAND
,
policy
);
return
this
;
return
this
;
},
},
...
@@ -174,44 +175,44 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -174,44 +175,44 @@ KityMinder.registerModule( "Expand", function () {
* 使用指定的策略收起节点
* 使用指定的策略收起节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
*/
*/
collapse
:
function
(
policy
)
{
collapse
:
function
(
policy
)
{
policy
=
policy
||
EXPAND_POLICY
.
KEEP_STATE
;
policy
=
policy
||
EXPAND_POLICY
.
KEEP_STATE
;
policy
(
this
,
STATE_COLLAPSE
,
policy
);
policy
(
this
,
STATE_COLLAPSE
,
policy
);
return
this
;
return
this
;
},
},
/**
/**
* 判断节点当前的状态是否为展开
* 判断节点当前的状态是否为展开
*/
*/
isExpanded
:
function
()
{
isExpanded
:
function
()
{
return
this
.
getData
(
EXPAND_STATE_DATA
)
===
STATE_EXPAND
;
return
this
.
getData
(
EXPAND_STATE_DATA
)
===
STATE_EXPAND
;
}
}
}
);
}
);
var
ExpandNodeCommand
=
kity
.
createClass
(
"ExpandNodeCommand"
,
(
function
()
{
var
ExpandNodeCommand
=
kity
.
createClass
(
"ExpandNodeCommand"
,
(
function
()
{
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
)
{
execute
:
function
(
km
)
{
expandAll
(
km
,
'expand'
);
expandAll
(
km
,
'expand'
);
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
0
;
return
0
;
}
}
};
};
}
)()
);
})()
);
var
CollapseNodeCommand
=
kity
.
createClass
(
"CollapseNodeCommand"
,
(
function
()
{
var
CollapseNodeCommand
=
kity
.
createClass
(
"CollapseNodeCommand"
,
(
function
()
{
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
)
{
execute
:
function
(
km
)
{
expandAll
(
km
,
'collapse'
);
expandAll
(
km
,
'collapse'
);
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
0
;
return
0
;
}
}
};
};
}
)()
);
})()
);
return
{
return
{
'events'
:
{
'events'
:
{
'beforeimport'
:
function
(
e
)
{
'beforeimport'
:
function
(
e
)
{
// var _root = this.getRoot();
// var _root = this.getRoot();
// var options = this.getOptions();
// var options = this.getOptions();
// var defaultExpand = options.defaultExpand;
// var defaultExpand = options.defaultExpand;
...
@@ -228,4 +229,4 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -228,4 +229,4 @@ KityMinder.registerModule( "Expand", function () {
}
}
};
};
}
);
});
\ No newline at end of file
\ No newline at end of file
src/module/font.js
View file @
730566aa
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
return
{
return
{
defaultOptions
:
{
defaultOptions
:
{
'fontfamily'
:
[
{
'fontfamily'
:
[{
name
:
'songti'
,
name
:
'songti'
,
val
:
'宋体,SimSun'
val
:
'宋体,SimSun'
},
{
},
{
...
@@ -38,100 +38,82 @@ KityMinder.registerModule( "fontmodule", function () {
...
@@ -38,100 +38,82 @@ KityMinder.registerModule( "fontmodule", function () {
},
{
},
{
name
:
'sans-serif'
,
name
:
'sans-serif'
,
val
:
'sans-serif'
val
:
'sans-serif'
}
],
}],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
},
},
"commands"
:
{
"commands"
:
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
,
color
)
{
execute
:
function
(
km
,
color
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontcolor'
,
color
);
n
.
setData
(
'color'
,
color
);
n
.
getTextShape
().
fill
(
color
)
n
.
render
();
}
)
}
);
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
},
queryValue
:
function
(
km
)
{
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'
font
color'
);
return
km
.
getSelectedNodes
()[
0
].
getData
(
'color'
);
}
}
return
'mixed'
;
return
'mixed'
;
}
}
}
),
}),
"backgroundcolor"
:
kity
.
createClass
(
"backgroudcolorCommand"
,
{
"backgroundcolor"
:
kity
.
createClass
(
"backgroudcolorCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
,
color
)
{
execute
:
function
(
km
,
color
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'backgroundcolor'
,
color
);
n
.
setData
(
'background'
,
color
);
n
.
getLayout
().
bgRect
.
fill
(
color
);
n
.
render
(
);
}
);
});
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
},
queryValue
:
function
(
km
)
{
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'background
color
'
);
return
km
.
getSelectedNodes
()[
0
].
getData
(
'background'
);
}
}
return
'mixed'
;
return
'mixed'
;
}
}
}
),
}),
"fontfamily"
:
kity
.
createClass
(
"fontfamilyCommand"
,
{
"fontfamily"
:
kity
.
createClass
(
"fontfamilyCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
,
family
)
{
execute
:
function
(
km
,
family
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontfamily'
,
family
);
n
.
setData
(
'font-family'
,
family
);
n
.
getTextShape
().
setAttr
(
'font-family'
,
family
);
n
.
render
(
);
km
.
updateLayout
(
n
)
km
.
layout
();
}
)
}
);
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
}
}
}
),
}),
"fontsize"
:
kity
.
createClass
(
"fontsizeCommand"
,
{
"fontsize"
:
kity
.
createClass
(
"fontsizeCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
,
size
)
{
execute
:
function
(
km
,
size
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontsize'
,
size
);
n
.
setData
(
'font-size'
,
size
);
n
.
getTextShape
().
setSize
(
size
);
n
.
render
(
);
km
.
updateLayout
(
n
)
km
.
layout
(
300
);
}
)
}
);
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
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() {
...
@@ -127,6 +127,7 @@ KityMinder.registerModule("KeyboardModule", function() {
km
.
select
(
nextNode
,
true
);
km
.
select
(
nextNode
,
true
);
}
}
}
}
return
{
return
{
'events'
:
{
'events'
:
{
...
@@ -137,26 +138,27 @@ KityMinder.registerModule("KeyboardModule", function() {
...
@@ -137,26 +138,27 @@ KityMinder.registerModule("KeyboardModule", function() {
var
keys
=
KityMinder
.
keymap
;
var
keys
=
KityMinder
.
keymap
;
var
node
=
e
.
getTargetNode
();
var
node
=
e
.
getTargetNode
();
var
lang
=
this
.
getLang
();
this
.
receiver
.
keydownNode
=
node
;
this
.
receiver
.
keydownNode
=
node
;
switch
(
e
.
originEvent
.
keyCode
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Enter
:
this
.
execCommand
(
'
appendSiblingNode'
,
new
MinderNode
(
this
,
this
.
getLang
().
topic
)
);
this
.
execCommand
(
'
AppendSiblingNode'
,
lang
.
topic
);
e
.
preventDefault
();
e
.
preventDefault
();
break
;
break
;
case
keys
.
Tab
:
case
keys
.
Tab
:
this
.
execCommand
(
'
appendChildNode'
,
new
MinderNode
(
this
,
this
.
getLang
().
topic
)
);
this
.
execCommand
(
'
AppendChildNode'
,
lang
.
topic
);
e
.
preventDefault
();
e
.
preventDefault
();
break
;
break
;
case
keys
.
Backspace
:
case
keys
.
Backspace
:
case
keys
.
Del
:
case
keys
.
Del
:
e
.
preventDefault
();
e
.
preventDefault
();
this
.
execCommand
(
'
removen
ode'
);
this
.
execCommand
(
'
RemoveN
ode'
);
break
;
break
;
case
keys
.
F2
:
case
keys
.
F2
:
e
.
preventDefault
();
e
.
preventDefault
();
this
.
execCommand
(
'
editn
ode'
);
this
.
execCommand
(
'
EditN
ode'
);
break
;
break
;
case
keys
.
Left
:
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 */
/* global Renderer: true */
var
wireframe
=
true
;
KityMinder
.
registerModule
(
'OutlineModule'
,
function
()
{
KityMinder
.
registerModule
(
'OutlineModule'
,
function
()
{
return
{
return
{
renderers
:
{
renderers
:
{
...
@@ -9,6 +11,12 @@ KityMinder.registerModule('OutlineModule', function() {
...
@@ -9,6 +11,12 @@ KityMinder.registerModule('OutlineModule', function() {
create
:
function
(
node
)
{
create
:
function
(
node
)
{
var
outline
=
this
.
outline
=
new
kity
.
Rect
().
setId
(
KityMinder
.
uuid
(
'node_outline'
));
var
outline
=
this
.
outline
=
new
kity
.
Rect
().
setId
(
KityMinder
.
uuid
(
'node_outline'
));
node
.
getRenderContainer
().
prependShape
(
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
)
{
update
:
function
(
node
)
{
...
@@ -30,6 +38,10 @@ KityMinder.registerModule('OutlineModule', function() {
...
@@ -30,6 +38,10 @@ KityMinder.registerModule('OutlineModule', function() {
.
fill
(
node
.
isSelected
()
?
.
fill
(
node
.
isSelected
()
?
node
.
getStyle
(
'selected-background'
)
:
node
.
getStyle
(
'selected-background'
)
:
node
.
getStyle
(
'background'
));
node
.
getStyle
(
'background'
));
if
(
wireframe
)
{
this
.
wireframe
.
setPosition
(
outlineBox
.
x
,
outlineBox
.
y
).
setSize
(
outlineBox
.
width
,
outlineBox
.
height
);
}
return
outlineBox
;
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', {
...
@@ -4,7 +4,7 @@ KityMinder.registerTheme('default', {
'root-stroke'
:
'none'
,
'root-stroke'
:
'none'
,
'root-font-size'
:
24
,
'root-font-size'
:
24
,
'root-padding'
:
[
15
,
25
],
'root-padding'
:
[
15
,
25
],
'root-margin'
:
0
,
'root-margin'
:
3
0
,
'root-radius'
:
30
,
'root-radius'
:
30
,
'root-space'
:
10
,
'root-space'
:
10
,
...
@@ -13,7 +13,7 @@ KityMinder.registerTheme('default', {
...
@@ -13,7 +13,7 @@ KityMinder.registerTheme('default', {
'main-stroke'
:
'none'
,
'main-stroke'
:
'none'
,
'main-font-size'
:
16
,
'main-font-size'
:
16
,
'main-padding'
:
[
6
,
20
],
'main-padding'
:
[
6
,
20
],
'main-margin'
:
[
0
,
10
,
30
,
5
0
],
'main-margin'
:
[
15
,
1
0
],
'main-radius'
:
10
,
'main-radius'
:
10
,
'main-space'
:
5
,
'main-space'
:
5
,
...
@@ -22,8 +22,8 @@ KityMinder.registerTheme('default', {
...
@@ -22,8 +22,8 @@ KityMinder.registerTheme('default', {
'sub-stroke'
:
'white'
,
'sub-stroke'
:
'white'
,
'sub-font-size'
:
12
,
'sub-font-size'
:
12
,
'sub-padding'
:
[
5
,
10
],
'sub-padding'
:
[
5
,
10
],
'sub-margin'
:
[
0
,
10
,
20
,
6
],
'sub-margin'
:
[
5
,
10
],
'sub-radius'
:
0
,
'sub-radius'
:
5
,
'sub-space'
:
5
,
'sub-space'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
'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