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
5e20101c
Commit
5e20101c
authored
Jun 18, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/fex-team/kityminder
into dev
parents
2c77fc41
434b240c
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
603 additions
and
389 deletions
+603
-389
image.js
dialogs/image/image.js
+25
-25
import.js
import.js
+1
-0
index.html
index.html
+0
-1
kity
kity
+1
-1
keymap.js
src/core/keymap.js
+13
-4
layout.js
src/core/layout.js
+24
-7
minder.event.js
src/core/minder.event.js
+1
-1
node.js
src/core/node.js
+7
-4
render.js
src/core/render.js
+2
-18
default.connect.js
src/layout/default.connect.js
+11
-17
default.js
src/layout/default.js
+30
-25
arrange.js
src/module/arrange.js
+96
-0
dragtree.js
src/module/dragtree.js
+160
-98
dropfile.js
src/module/dropfile.js
+76
-73
editor.js
src/module/editor.js
+1
-1
font.js
src/module/font.js
+4
-1
geometry.js
src/module/geometry.js
+10
-2
image.js
src/module/image.js
+113
-99
keyboard.js
src/module/keyboard.js
+7
-4
select.js
src/module/select.js
+8
-5
default.js
src/theme/default.js
+13
-3
No files found.
dialogs/image/image.js
View file @
5e20101c
(
function
(
utils
)
{
(
function
(
utils
)
{
var
content
=
'<div class="image-content" style="padding:20px;width:360px;">'
;
var
content
=
'<div class="image-content" style="padding:20px;width:360px;">'
;
content
+=
'<style>'
;
content
+=
'<style>'
;
content
+=
'.kmui-dialog-<%= container %> input{'
;
content
+=
'.kmui-dialog-<%= container %> input{'
;
...
@@ -36,39 +36,39 @@
...
@@ -36,39 +36,39 @@
KM
.
registerWidget
(
'image'
,
{
KM
.
registerWidget
(
'image'
,
{
tpl
:
content
,
tpl
:
content
,
initContent
:
function
(
km
)
{
initContent
:
function
(
km
)
{
var
lang
=
km
.
getLang
(
'dialogs.image'
),
var
lang
=
km
.
getLang
(
'dialogs.image'
),
html
;
html
;
if
(
lang
)
{
if
(
lang
)
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
'container'
:
'image'
'container'
:
'image'
},
lang
)
);
},
lang
)
);
}
}
this
.
root
().
html
(
html
);
this
.
root
().
html
(
html
);
},
},
initEvent
:
function
(
km
,
$w
)
{
initEvent
:
function
(
km
,
$w
)
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
$w
.
kmui
().
hide
();
}
);
});
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
===
13
)
{
if
(
e
.
keyCode
===
13
)
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
$w
.
kmui
().
hide
();
}
}
}
).
on
(
'input'
,
function
()
{
}).
on
(
'input'
,
function
()
{
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
});
});
var
url
=
km
.
queryCommandValue
(
'image'
);
var
url
=
km
.
queryCommandValue
(
'image'
);
var
$input
=
$w
.
find
(
'#image_href'
);
var
$input
=
$w
.
find
(
'#image_href'
);
$input
.
val
(
url
||
'http://'
);
$input
.
val
(
url
||
'http://'
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$input
.
focus
();
$input
.
focus
();
}
);
});
},
},
width
:
400
width
:
400
}
);
});
}
)(
KM
.
Utils
);
})(
KM
.
Utils
);
\ No newline at end of file
\ No newline at end of file
import.js
View file @
5e20101c
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
'module/nodetext.js'
,
'module/nodetext.js'
,
'module/hyperlink.js'
,
'module/hyperlink.js'
,
'module/expand.js'
,
'module/expand.js'
,
'module/arrange.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/widget.js'
,
'ui/widget.js'
,
'ui/button.js'
,
'ui/button.js'
,
...
...
index.html
View file @
5e20101c
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
<a
href=
"https://github.com/fex-team/kityminder/issues/new"
target=
"_blank"
>
Bug
</a>
|
<a
href=
"https://github.com/fex-team/kityminder/issues/new"
target=
"_blank"
>
Bug
</a>
|
<a
href=
"mailto:kity@baidu.com"
target=
"_blank"
>
Contact Us
</a>
<a
href=
"mailto:kity@baidu.com"
target=
"_blank"
>
Contact Us
</a>
</p>
</p>
<script>
window
.
_bd_share_config
=
{
"common"
:{
"bdSnsKey"
:{},
"bdMini"
:
"2"
,
"bdMiniList"
:[],
"bdPic"
:
""
,
"bdStyle"
:
"1"
,
"bdSize"
:
"32"
},
"share"
:{}};
with
(
document
)
0
[(
getElementsByTagName
(
'head'
)[
0
]
||
body
).
appendChild
(
createElement
(
'script'
)).
src
=
'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='
+~
(
-
new
Date
()
/
36
e5
)];
</script>
</body>
</body>
<script>
<script>
// create km instance
// create km instance
...
...
kity
@
9e420efd
Subproject commit
437d9c160a7961a3843cce3d9e2b01f64090f0df
Subproject commit
9e420efd89ba672f5389e21069eb0009e52ad7b1
src/core/keymap.js
View file @
5e20101c
var
keymap
=
KityMinder
.
keymap
=
{
var
keymap
=
KityMinder
.
keymap
=
(
function
(
origin
)
{
var
ret
=
{};
for
(
var
key
in
origin
)
{
if
(
origin
.
hasOwnProperty
(
key
))
{
ret
[
key
]
=
origin
[
key
];
ret
[
key
.
toLowerCase
()]
=
origin
[
key
];
}
}
return
ret
;
})({
'Backspace'
:
8
,
'Backspace'
:
8
,
'Tab'
:
9
,
'Tab'
:
9
,
'Enter'
:
13
,
'Enter'
:
13
,
...
@@ -37,7 +46,7 @@ var keymap = KityMinder.keymap = {
...
@@ -37,7 +46,7 @@ var keymap = KityMinder.keymap = {
'='
:
187
,
'='
:
187
,
'-'
:
189
,
'-'
:
189
,
"b"
:
66
,
'b'
:
66
,
'i'
:
73
,
'i'
:
73
,
//回退
//回退
'z'
:
90
,
'z'
:
90
,
...
@@ -68,7 +77,7 @@ var keymap = KityMinder.keymap = {
...
@@ -68,7 +77,7 @@ var keymap = KityMinder.keymap = {
38
:
1
,
38
:
1
,
39
:
1
,
39
:
1
,
40
:
1
,
40
:
1
,
113
:
1
113
:
1
},
},
'isSelectedNodeKey'
:
{
'isSelectedNodeKey'
:
{
//上下左右
//上下左右
...
@@ -79,4 +88,4 @@ var keymap = KityMinder.keymap = {
...
@@ -79,4 +88,4 @@ var keymap = KityMinder.keymap = {
13
:
1
,
13
:
1
,
9
:
1
9
:
1
}
}
};
});
\ No newline at end of file
\ No newline at end of file
src/core/layout.js
View file @
5e20101c
...
@@ -30,6 +30,18 @@ kity.extendClass(MinderNode, {
...
@@ -30,6 +30,18 @@ kity.extendClass(MinderNode, {
return
layout
;
return
layout
;
},
},
getOrder
:
function
()
{
return
this
.
getData
(
'order'
)
||
this
.
getIndex
();
},
setOrder
:
function
(
order
)
{
return
this
.
setData
(
'order'
,
order
);
},
getOrderHint
:
function
(
refer
)
{
return
this
.
getLayoutInstance
().
getOrderHint
(
this
);
},
getLayoutInstance
:
function
()
{
getLayoutInstance
:
function
()
{
var
LayoutClass
=
KityMinder
.
_layout
[
this
.
getLayout
()];
var
LayoutClass
=
KityMinder
.
_layout
[
this
.
getLayout
()];
var
layout
=
new
LayoutClass
();
var
layout
=
new
LayoutClass
();
...
@@ -89,10 +101,10 @@ kity.extendClass(MinderNode, {
...
@@ -89,10 +101,10 @@ kity.extendClass(MinderNode, {
},
},
setLayoutOffset
:
function
(
p
)
{
setLayoutOffset
:
function
(
p
)
{
this
.
setData
(
'layout_'
+
this
.
getLayout
()
+
'_offset'
,
{
this
.
setData
(
'layout_'
+
this
.
getLayout
()
+
'_offset'
,
p
?
{
x
:
p
.
x
,
x
:
p
.
x
,
y
:
p
.
y
y
:
p
.
y
});
}
:
null
);
return
this
;
return
this
;
},
},
...
@@ -147,11 +159,13 @@ kity.extendClass(Minder, {
...
@@ -147,11 +159,13 @@ kity.extendClass(Minder, {
layoutNode
(
this
.
getRoot
());
layoutNode
(
this
.
getRoot
());
return
this
.
applyLayoutResult
(
duration
);
this
.
applyLayoutResult
(
this
.
getRoot
(),
duration
);
return
this
.
fire
(
'layout'
);
},
},
applyLayoutResult
:
function
(
duration
)
{
applyLayoutResult
:
function
(
root
,
duration
)
{
var
root
=
this
.
getRoot
();
root
=
root
||
this
.
getRoot
();
var
me
=
this
;
var
me
=
this
;
function
apply
(
node
,
pMatrix
)
{
function
apply
(
node
,
pMatrix
)
{
...
@@ -205,8 +219,7 @@ kity.extendClass(Minder, {
...
@@ -205,8 +219,7 @@ kity.extendClass(Minder, {
}
}
}
}
apply
(
root
,
new
kity
.
Matrix
());
apply
(
root
,
root
.
parent
?
root
.
parent
.
getGlobalLayoutTransform
()
:
new
kity
.
Matrix
());
this
.
fire
(
'layout'
);
return
this
;
return
this
;
},
},
});
});
...
@@ -291,5 +304,9 @@ var Layout = kity.createClass('Layout', {
...
@@ -291,5 +304,9 @@ var Layout = kity.createClass('Layout', {
box
=
g
.
mergeBox
(
box
,
matrix
.
transformBox
(
treeBox
));
box
=
g
.
mergeBox
(
box
,
matrix
.
transformBox
(
treeBox
));
}
}
return
box
;
return
box
;
},
getOrderHint
:
function
(
node
)
{
return
[];
}
}
});
});
\ No newline at end of file
src/core/minder.event.js
View file @
5e20101c
...
@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
...
@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
},
},
// TODO: mousemove lazy bind
// TODO: mousemove lazy bind
_bindPaperEvents
:
function
()
{
_bindPaperEvents
:
function
()
{
this
.
_paper
.
on
(
'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend'
,
this
.
_firePharse
.
bind
(
this
)
);
this
.
_paper
.
on
(
'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend
dragenter dragleave drop
'
,
this
.
_firePharse
.
bind
(
this
)
);
if
(
window
)
{
if
(
window
)
{
window
.
addEventListener
(
'resize'
,
this
.
_firePharse
.
bind
(
this
)
);
window
.
addEventListener
(
'resize'
,
this
.
_firePharse
.
bind
(
this
)
);
window
.
addEventListener
(
'blur'
,
this
.
_firePharse
.
bind
(
this
)
);
window
.
addEventListener
(
'blur'
,
this
.
_firePharse
.
bind
(
this
)
);
...
...
src/core/node.js
View file @
5e20101c
...
@@ -293,19 +293,22 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
...
@@ -293,19 +293,22 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
});
});
MinderNode
.
getCommonAncestor
=
function
(
nodeA
,
nodeB
)
{
MinderNode
.
getCommonAncestor
=
function
(
nodeA
,
nodeB
)
{
if
(
nodeA
instanceof
Array
)
{
return
MinderNode
.
getCommonAncestor
.
apply
(
this
,
nodeA
);
}
switch
(
arguments
.
length
)
{
switch
(
arguments
.
length
)
{
case
1
:
case
1
:
return
nodeA
;
return
nodeA
.
parent
;
case
2
:
case
2
:
if
(
nodeA
.
contains
(
nodeB
))
{
if
(
nodeA
.
isAncestorOf
(
nodeB
))
{
return
nodeA
;
return
nodeA
;
}
}
if
(
nodeB
.
contains
(
nodeA
))
{
if
(
nodeB
.
isAncestorOf
(
nodeA
))
{
return
nodeB
;
return
nodeB
;
}
}
var
ancestor
=
nodeA
.
parent
;
var
ancestor
=
nodeA
.
parent
;
while
(
ancestor
&&
!
ancestor
.
contains
(
nodeB
))
{
while
(
ancestor
&&
!
ancestor
.
isAncestorOf
(
nodeB
))
{
ancestor
=
ancestor
.
parent
;
ancestor
=
ancestor
.
parent
;
}
}
return
ancestor
;
return
ancestor
;
...
...
src/core/render.js
View file @
5e20101c
...
@@ -24,12 +24,6 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
...
@@ -24,12 +24,6 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
}
}
});
});
kity
.
extendClass
(
MinderNode
,
{
getContentBox
:
function
()
{
return
this
.
_contentBox
;
}
});
kity
.
extendClass
(
Minder
,
{
kity
.
extendClass
(
Minder
,
{
_createRendererForNode
:
function
(
node
)
{
_createRendererForNode
:
function
(
node
)
{
...
@@ -122,17 +116,7 @@ kity.extendClass(MinderNode, {
...
@@ -122,17 +116,7 @@ kity.extendClass(MinderNode, {
return
null
;
return
null
;
},
},
getContentBox
:
function
()
{
getContentBox
:
function
()
{
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
{
//if (!this._contentBox) this.render();
x
:
0
,
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
new
kity
.
Box
()
:
this
.
_contentBox
;
y
:
0
,
width
:
0
,
height
:
0
,
left
:
0
,
top
:
0
,
bottom
:
0
,
right
:
0
,
cx
:
0
,
cy
:
0
}
:
this
.
_contentBox
;
}
}
});
});
\ No newline at end of file
src/layout/default.connect.js
View file @
5e20101c
...
@@ -13,7 +13,7 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection)
...
@@ -13,7 +13,7 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection)
var
start
,
end
,
vector
;
var
start
,
end
,
vector
;
var
abs
=
Math
.
abs
;
var
abs
=
Math
.
abs
;
var
pathData
=
[];
var
pathData
=
[];
var
side
=
box
.
cx
>
pBox
.
cx
?
'right'
:
'left'
;
var
side
=
node
.
getLayoutVector
().
x
>
0
?
'right'
:
'left'
;
node
.
getMinder
().
getPaper
().
addResource
(
connectMarker
);
node
.
getMinder
().
getPaper
().
addResource
(
connectMarker
);
...
@@ -38,30 +38,24 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection)
...
@@ -38,30 +38,24 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection)
var
radius
=
node
.
getStyle
(
'connect-radius'
);
var
radius
=
node
.
getStyle
(
'connect-radius'
);
var
underY
=
box
.
bottom
+
2
;
var
underY
=
box
.
bottom
+
2
;
var
p1
,
p2
,
p3
,
p4
,
v12
;
var
startY
=
parent
.
getType
()
==
'sub'
?
pBox
.
bottom
+
2
:
pBox
.
cy
;
var
isTop
=
parent
.
children
.
length
>
1
&&
node
.
getIndex
()
===
0
;
var
p1
,
p2
,
p3
,
mx
;
if
(
side
==
'right'
)
{
if
(
side
==
'right'
)
{
p1
=
new
kity
.
Point
(
pBox
.
right
+
parent
.
getStyle
(
'margin-right'
),
pBox
.
cy
);
p1
=
new
kity
.
Point
(
pBox
.
right
+
10
,
startY
);
p3
=
new
kity
.
Point
(
box
.
left
,
underY
);
p2
=
new
kity
.
Point
(
box
.
left
,
underY
);
p4
=
new
kity
.
Point
(
box
.
right
,
underY
);
p3
=
new
kity
.
Point
(
box
.
right
+
10.5
,
underY
);
p2
=
p3
.
offset
(
-
radius
,
isTop
?
radius
:
-
radius
);
}
else
{
}
else
{
p1
=
new
kity
.
Point
(
pBox
.
left
-
parent
.
getStyle
(
'margin-left'
),
pBox
.
cy
);
p1
=
new
kity
.
Point
(
pBox
.
left
-
10
,
startY
);
p3
=
new
kity
.
Point
(
box
.
right
,
underY
);
p2
=
new
kity
.
Point
(
box
.
right
,
underY
);
p4
=
new
kity
.
Point
(
box
.
left
,
underY
);
p3
=
new
kity
.
Point
(
box
.
left
-
10.5
,
underY
);
p2
=
p3
.
offset
(
radius
,
isTop
?
radius
:
-
radius
);
}
}
v12
=
kity
.
Vector
.
fromPoints
(
p1
,
p2
)
;
mx
=
(
p1
.
x
+
p2
.
x
)
/
2
;
pathData
.
push
(
'M'
,
p1
);
pathData
.
push
(
'M'
,
p1
);
//pathData.push('L', p2);
pathData
.
push
(
'C'
,
mx
,
p1
.
y
,
mx
,
p2
.
y
,
p2
);
// rx, ry, xr, laf, sf, p
var
sf
=
+
(
side
==
'right'
&&
isTop
||
side
==
'left'
&&
!
isTop
);
pathData
.
push
(
'L'
,
p3
);
pathData
.
push
(
'L'
,
p3
);
pathData
.
push
(
'L'
,
p4
);
//var ex = side == 'right' ? (start.x + radius) : (start.x - radius);
connection
.
setMarker
(
null
);
connection
.
setMarker
(
null
);
...
...
src/layout/default.js
View file @
5e20101c
...
@@ -78,11 +78,13 @@ KityMinder.registerLayout('default', kity.createClass({
...
@@ -78,11 +78,13 @@ KityMinder.registerLayout('default', kity.createClass({
x
=
nodeContentBox
.
right
-
childContentBox
.
left
;
x
=
nodeContentBox
.
right
-
childContentBox
.
left
;
x
+=
parent
.
getStyle
(
'margin-right'
)
+
child
.
getStyle
(
'margin-left'
);
x
+=
parent
.
getStyle
(
'margin-right'
)
+
child
.
getStyle
(
'margin-left'
);
// 设置布局矢量
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
right
,
childContentBox
.
cy
));
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
right
,
childContentBox
.
cy
));
}
else
{
}
else
{
x
=
nodeContentBox
.
left
-
childContentBox
.
right
;
x
=
nodeContentBox
.
left
-
childContentBox
.
right
;
x
-=
parent
.
getStyle
(
'margin-left'
)
+
child
.
getStyle
(
'margin-right'
);
x
-=
parent
.
getStyle
(
'margin-left'
)
+
child
.
getStyle
(
'margin-right'
);
// 设置布局矢量
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
left
,
childContentBox
.
cy
));
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
left
,
childContentBox
.
cy
));
}
}
...
@@ -93,6 +95,7 @@ KityMinder.registerLayout('default', kity.createClass({
...
@@ -93,6 +95,7 @@ KityMinder.registerLayout('default', kity.createClass({
y
+=
children
[
i
].
getStyle
(
'margin-top'
);
y
+=
children
[
i
].
getStyle
(
'margin-top'
);
}
}
// 设置布局结果
transform
=
new
kity
.
Matrix
().
translate
(
x
,
y
);
transform
=
new
kity
.
Matrix
().
translate
(
x
,
y
);
child
.
setLayoutTransform
(
transform
);
child
.
setLayoutTransform
(
transform
);
...
@@ -110,32 +113,34 @@ KityMinder.registerLayout('default', kity.createClass({
...
@@ -110,32 +113,34 @@ KityMinder.registerLayout('default', kity.createClass({
}
}
},
},
getLayoutContextPoints
:
function
(
node
)
{
getOrderHint
:
function
(
node
)
{
var
points
=
[];
var
hint
=
[];
var
siblings
=
node
.
parent
&&
node
.
parent
.
children
;
var
box
=
node
.
getLayoutBox
();
var
g
=
KityMinder
.
Geometry
;
var
offset
=
node
.
getLevel
()
>
1
?
3
:
5
;
if
(
!
siblings
)
return
points
;
hint
.
push
({
type
:
'up'
,
siblings
.
forEach
(
function
(
sibling
)
{
node
:
node
,
if
(
sibling
==
node
)
return
;
area
:
{
var
index
=
sibling
.
getIndex
();
x
:
box
.
x
,
var
box
=
node
.
getLayoutBox
();
y
:
box
.
top
-
node
.
getStyle
(
'margin-top'
)
-
offset
,
width
:
box
.
width
,
// top order hint
height
:
node
.
getStyle
(
'margin-top'
)
points
.
push
({
},
type
:
'order'
,
path
:
[
'M'
,
box
.
x
,
box
.
top
-
offset
,
'L'
,
box
.
right
,
box
.
top
-
offset
]
index
:
index
,
area
:
{
x
:
box
.
x
,
y
:
box
.
top
-
2
,
width
:
box
.
width
,
height
:
node
.
getStyle
(
'margin-top'
)
},
hint
:
[
'M'
,
]
});
});
});
return
points
;
hint
.
push
({
type
:
'down'
,
node
:
node
,
area
:
{
x
:
box
.
x
,
y
:
box
.
bottom
+
offset
,
width
:
box
.
width
,
height
:
node
.
getStyle
(
'margin-bottom'
)
},
path
:
[
'M'
,
box
.
x
,
box
.
bottom
+
offset
,
'L'
,
box
.
right
,
box
.
bottom
+
offset
]
});
return
hint
;
}
}
}));
}));
\ No newline at end of file
src/module/arrange.js
0 → 100644
View file @
5e20101c
kity
.
extendClass
(
MinderNode
,
{
arrange
:
function
(
index
)
{
var
parent
=
this
.
parent
;
if
(
!
parent
)
return
;
var
sibling
=
parent
.
children
;
if
(
index
<
0
||
index
>=
sibling
.
length
)
return
;
sibling
.
splice
(
this
.
getIndex
(),
1
);
sibling
.
splice
(
index
,
0
,
this
);
return
this
;
}
});
function
asc
(
nodeA
,
nodeB
)
{
return
nodeA
.
getIndex
()
-
nodeB
.
getIndex
();
}
function
desc
(
nodeA
,
nodeB
)
{
return
-
asc
(
nodeA
,
nodeB
);
}
var
ArrangeUpCommand
=
kity
.
createClass
(
'ArrangeUpCommand'
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
nodes
.
sort
(
asc
);
var
lastIndexes
=
nodes
.
map
(
function
(
node
)
{
return
node
.
getIndex
();
});
nodes
.
forEach
(
function
(
node
,
index
)
{
node
.
arrange
(
lastIndexes
[
index
]
-
1
);
});
km
.
layout
(
300
);
}
});
var
ArrangeDownCommand
=
kity
.
createClass
(
'ArrangeUpCommand'
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
nodes
.
sort
(
desc
);
var
lastIndexes
=
nodes
.
map
(
function
(
node
)
{
return
node
.
getIndex
();
});
nodes
.
forEach
(
function
(
node
,
index
)
{
node
.
arrange
(
lastIndexes
[
index
]
+
1
);
});
km
.
layout
(
300
);
}
});
var
ArrangeCommand
=
kity
.
createClass
(
'ArrangeCommand'
,
{
base
:
Command
,
execute
:
function
(
km
,
nodes
,
index
)
{
nodes
=
nodes
&&
nodes
.
slice
()
||
km
.
getSelectedNodes
().
slice
();
if
(
!
nodes
.
length
)
return
;
var
ancestor
=
MinderNode
.
getCommonAncestor
(
nodes
);
if
(
ancestor
!=
nodes
[
0
].
parent
)
return
;
var
indexed
=
nodes
.
map
(
function
(
node
)
{
return
{
index
:
node
.
getIndex
(),
node
:
node
};
});
var
asc
=
Math
.
min
.
apply
(
Math
,
indexed
.
map
(
function
(
one
)
{
return
one
.
index
;
}))
>=
index
;
indexed
.
sort
(
function
(
a
,
b
)
{
return
asc
?
(
b
.
index
-
a
.
index
)
:
(
a
.
index
-
b
.
index
);
});
indexed
.
forEach
(
function
(
one
)
{
one
.
node
.
arrange
(
index
);
});
km
.
layout
(
300
);
}
});
KityMinder
.
registerModule
(
'ArrangeModule'
,
{
commands
:
{
'arrangeup'
:
ArrangeUpCommand
,
'arrangedown'
:
ArrangeDownCommand
,
'arrange'
:
ArrangeCommand
},
addShortcutKeys
:
{
'arrangeup'
:
'alt+Up'
,
'arrangedown'
:
'alt+Down'
}
});
\ No newline at end of file
src/module/dragtree.js
View file @
5e20101c
This diff is collapsed.
Click to expand it.
src/module/dropfile.js
View file @
5e20101c
KityMinder
.
registerModule
(
"DropFile"
,
function
()
{
KityMinder
.
registerModule
(
'DropFile'
,
function
()
{
var
social
,
var
social
,
draftManager
,
draftManager
,
importing
=
false
;
importing
=
false
;
function
init
()
{
function
init
()
{
var
container
=
this
.
getPaper
().
getContainer
();
var
container
=
this
.
getPaper
().
getContainer
();
container
.
addEventListener
(
'dragover'
,
onDragOver
);
container
.
addEventListener
(
'dragover'
,
onDragOver
);
container
.
addEventListener
(
'drop'
,
onDrop
.
bind
(
this
)
);
container
.
addEventListener
(
'drop'
,
onDrop
.
bind
(
this
)
);
}
}
function
onDragOver
(
e
)
{
function
onDragOver
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
e
.
dataTransfer
.
dropEffect
=
'copy'
;
e
.
dataTransfer
.
dropEffect
=
'copy'
;
}
}
function
onDrop
(
e
)
{
function
onDrop
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
var
minder
=
this
;
var
minder
=
this
;
if
(
kity
.
Browser
.
ie
&&
Number
(
kity
.
Browser
.
version
)
<
10
)
{
if
(
kity
.
Browser
.
ie
&&
Number
(
kity
.
Browser
.
version
)
<
10
)
{
alert
(
'文件导入对IE浏览器仅支持10以上版本'
);
alert
(
'文件导入对IE浏览器仅支持10以上版本'
);
return
;
return
;
}
}
var
files
=
e
.
dataTransfer
.
files
;
var
files
=
e
.
dataTransfer
.
files
;
if
(
files
)
{
if
(
files
)
{
var
file
=
files
[
0
];
var
file
=
files
[
0
];
var
ext
=
file
.
type
||
(
/
(
.
)\w
+$/
).
exec
(
file
.
name
)[
0
];
var
ext
=
file
.
type
||
(
/
(
.
)\w
+$/
).
exec
(
file
.
name
)[
0
];
console
.
log
(
ext
);
if
(
(
/xmind/g
).
test
(
ext
)
)
{
//xmind zip
if
((
/xmind/g
).
test
(
ext
))
{
//xmind zip
importSync
(
minder
,
file
,
'xmind'
);
importSync
(
minder
,
file
,
'xmind'
);
}
else
if
(
(
/mmap/g
).
test
(
ext
)
)
{
// mindmanager zip
}
else
if
((
/mmap/g
).
test
(
ext
))
{
// mindmanager zip
importSync
(
minder
,
file
,
'mindmanager'
);
importSync
(
minder
,
file
,
'mindmanager'
);
}
else
if
(
(
/mm/g
).
test
(
ext
)
)
{
//freemind xml
}
else
if
((
/mm/g
).
test
(
ext
))
{
//freemind xml
importAsync
(
minder
,
file
,
'freemind'
);
importAsync
(
minder
,
file
,
'freemind'
);
}
else
{
// txt json
}
else
if
(
/km/
.
test
(
ext
))
{
// txt json
importAsync
(
minder
,
file
);
importAsync
(
minder
,
file
,
'json'
);
}
}
else
if
(
/txt/
.
test
(
ext
))
{
}
importAsync
(
minder
,
file
,
'plain'
);
}
}
}
}
function
afterImport
()
{
function
afterImport
()
{
if
(
!
importing
)
return
;
if
(
!
importing
)
return
;
createDraft
(
this
);
createDraft
(
this
);
social
.
setRemotePath
(
null
,
false
);
social
.
setRemotePath
(
null
,
false
);
this
.
execCommand
(
'camera'
,
this
.
getRoot
()
);
this
.
execCommand
(
'camera'
,
this
.
getRoot
()
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
social
.
watchChanges
(
true
);
social
.
watchChanges
(
true
);
},
10
);
},
10
);
importing
=
false
;
importing
=
false
;
}
}
// 同步加载文件
// 同步加载文件
function
importSync
(
minder
,
file
,
protocal
)
{
function
importSync
(
minder
,
file
,
protocal
)
{
social
=
social
||
window
.
social
;
social
=
social
||
window
.
social
;
social
.
watchChanges
(
false
);
social
.
watchChanges
(
false
);
importing
=
true
;
importing
=
true
;
minder
.
importData
(
file
,
protocal
);
//zip文件的import是同步的
minder
.
importData
(
file
,
protocal
);
//zip文件的import是同步的
}
}
// 异步加载文件
// 异步加载文件
function
importAsync
(
minder
,
file
,
protocal
)
{
function
importAsync
(
minder
,
file
,
protocal
)
{
var
reader
=
new
FileReader
();
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
reader
.
onload
=
function
(
e
)
{
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
};
};
reader
.
readAsText
(
file
);
reader
.
readAsText
(
file
);
}
}
function
createDraft
(
minder
)
{
function
createDraft
(
minder
)
{
draftManager
=
window
.
draftManager
||
(
window
.
draftManager
=
new
window
.
DraftManager
(
minder
)
);
draftManager
=
window
.
draftManager
||
(
window
.
draftManager
=
new
window
.
DraftManager
(
minder
)
);
draftManager
.
create
();
draftManager
.
create
();
}
}
return
{
return
{
events
:
{
events
:
{
'ready'
:
init
,
'ready'
:
init
,
'import'
:
afterImport
'import'
:
afterImport
}
}
};
};
}
);
});
\ No newline at end of file
\ No newline at end of file
src/module/editor.js
View file @
5e20101c
...
@@ -179,7 +179,7 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -179,7 +179,7 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
browser
.
ipad
)
{
if
(
browser
.
ipad
)
{
receiver
.
container
.
focus
();
receiver
.
container
.
focus
();
}
}
}
else
{
}
else
{
//当选中节点后,输入状态准备
//当选中节点后,输入状态准备
var
node
=
e
.
getTargetNode
();
var
node
=
e
.
getTargetNode
();
if
(
node
)
{
if
(
node
)
{
...
...
src/module/font.js
View file @
5e20101c
...
@@ -4,7 +4,10 @@ KityMinder.registerModule("fontmodule", function() {
...
@@ -4,7 +4,10 @@ KityMinder.registerModule("fontmodule", function() {
}
}
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
text
.
fill
(
getNodeDataOrStyle
(
node
,
'color'
));
var
dataColor
=
node
.
getData
(
'color'
);
var
selectedColor
=
node
.
getStyle
(
'selected-color'
);
var
styleColor
=
node
.
getStyle
(
'color'
);
text
.
fill
(
dataColor
||
(
node
.
isSelected
()
?
selectedColor
:
styleColor
));
text
.
setFont
({
text
.
setFont
({
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
...
...
src/module/geometry.js
View file @
5e20101c
...
@@ -84,16 +84,24 @@ KityMinder.Geometry = (function() {
...
@@ -84,16 +84,24 @@ KityMinder.Geometry = (function() {
};
};
g
.
isPointInsideBox
=
function
(
p
,
b
)
{
g
.
isPointInsideBox
=
function
(
p
,
b
)
{
uniformBox
(
b
);
var
ranges
=
g
.
getBoxRange
(
b
);
var
ranges
=
g
.
getBoxRange
(
b
);
return
g
.
isNumberInRange
(
p
.
x
,
ranges
.
x
)
&&
g
.
isNumberInRange
(
p
.
y
,
ranges
.
y
);
return
g
.
isNumberInRange
(
p
.
x
,
ranges
.
x
)
&&
g
.
isNumberInRange
(
p
.
y
,
ranges
.
y
);
};
};
g
.
isBoxIntersect
=
function
(
b1
,
b2
)
{
g
.
getIntersectBox
=
function
(
b1
,
b2
)
{
uniformBox
(
b1
);
uniformBox
(
b2
);
var
minx
=
max
(
b1
.
left
,
b2
.
left
),
var
minx
=
max
(
b1
.
left
,
b2
.
left
),
miny
=
max
(
b1
.
top
,
b2
.
top
),
miny
=
max
(
b1
.
top
,
b2
.
top
),
maxx
=
min
(
b1
.
right
,
b2
.
right
),
maxx
=
min
(
b1
.
right
,
b2
.
right
),
maxy
=
min
(
b1
.
bottom
,
b2
.
bottom
);
maxy
=
min
(
b1
.
bottom
,
b2
.
bottom
);
return
minx
<
maxx
&&
miny
<
maxy
;
return
minx
<
maxx
&&
miny
<
maxy
?
wrapBox
({
left
:
minx
,
right
:
maxx
,
top
:
miny
,
bottom
:
maxy
})
:
null
;
};
};
g
.
snapToSharp
=
function
(
unknown
)
{
g
.
snapToSharp
=
function
(
unknown
)
{
...
...
src/module/image.js
View file @
5e20101c
KityMinder
.
registerModule
(
"image"
,
function
()
{
KityMinder
.
registerModule
(
'image'
,
function
()
{
function
loadImageSize
(
url
,
callback
)
{
function
loadImageSize
(
url
,
callback
)
{
var
img
=
document
.
createElement
(
'img'
);
var
img
=
document
.
createElement
(
'img'
);
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
callback
(
img
.
width
,
img
.
height
);
callback
(
img
.
width
,
img
.
height
);
};
};
img
.
onerror
=
function
()
{
img
.
onerror
=
function
()
{
callback
(
null
);
callback
(
null
);
};
};
img
.
src
=
url
;
img
.
src
=
url
;
}
}
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
var
ratio
=
width
/
height
,
var
ratio
=
width
/
height
,
fitRatio
=
maxWidth
/
maxHeight
;
fitRatio
=
maxWidth
/
maxHeight
;
// 宽高比大于最大尺寸的宽高比,以宽度为标准适应
// 宽高比大于最大尺寸的宽高比,以宽度为标准适应
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
width
=
maxWidth
;
width
=
maxWidth
;
height
=
maxWidth
/
ratio
;
height
=
maxWidth
/
ratio
;
}
else
if
(
height
>
maxHeight
)
{
}
else
if
(
height
>
maxHeight
)
{
height
=
maxHeight
;
height
=
maxHeight
;
width
=
maxHeight
/
ratio
;
width
=
maxHeight
/
ratio
;
}
}
...
@@ -28,104 +28,118 @@ KityMinder.registerModule( "image", function () {
...
@@ -28,104 +28,118 @@ KityMinder.registerModule( "image", function () {
height
:
height
height
:
height
};
};
}
}
return
{
"defaultOptions"
:
{
var
ImageCommand
=
kity
.
createClass
(
'ImageCommand'
,
{
"maxImageWidth"
:
200
,
base
:
Command
,
"maxImageHeight"
:
200
execute
:
function
(
km
,
url
)
{
var
nodes
=
km
.
getSelectedNodes
();
loadImageSize
(
url
,
function
(
width
,
height
)
{
if
(
!
width
)
return
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
var
size
=
fitImageSize
(
width
,
height
,
km
.
getOptions
(
'maxImageWidth'
),
km
.
getOptions
(
'maxImageHeight'
));
n
.
setData
(
'image'
,
url
);
n
.
setData
(
'imageSize'
,
size
);
n
.
render
();
});
km
.
layout
(
300
);
});
},
},
"commands"
:
{
queryState
:
function
(
km
)
{
"image"
:
kity
.
createClass
(
"ImageCommand"
,
{
var
nodes
=
km
.
getSelectedNodes
(),
base
:
Command
,
result
=
0
;
if
(
nodes
.
length
===
0
)
{
execute
:
function
(
km
,
url
)
{
return
-
1
;
var
nodes
=
km
.
getSelectedNodes
();
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
loadImageSize
(
url
,
function
(
width
,
height
)
{
if
(
n
&&
n
.
getData
(
'image'
))
{
if
(
!
width
)
return
;
result
=
0
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
false
;
n
.
setData
(
'image'
,
url
);
n
.
setData
(
'imageWidth'
,
width
);
n
.
setData
(
'imageHeight'
,
height
);
km
.
updateLayout
(
n
);
}
);
}
);
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
(),
result
=
0
;
if
(
nodes
.
length
===
0
)
{
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'image'
)
)
{
result
=
0
;
return
false
;
}
}
);
return
result
;
},
queryValue
:
function
(
km
)
{
var
node
=
km
.
getSelectedNode
();
return
node
.
getData
(
'image'
);
}
}
}
),
});
"removeimage"
:
kity
.
createClass
(
"RemoveImageCommand"
,
{
return
result
;
base
:
Command
,
},
queryValue
:
function
(
km
)
{
execute
:
function
(
km
)
{
var
node
=
km
.
getSelectedNode
();
var
nodes
=
km
.
getSelectedNodes
();
return
node
.
getData
(
'image'
);
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
}
n
.
setData
(
'image'
);
});
km
.
updateLayout
(
n
);
}
);
var
RemoveImageCommand
=
kity
.
createClass
(
'RemoveImageCommand'
,
{
},
base
:
Command
,
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
nodes
.
length
==
0
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
-
1
;
n
.
setData
(
'image'
).
render
();
}
});
var
image
=
false
;
km
.
layout
(
300
);
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
},
if
(
n
.
getData
(
'image'
)
)
{
queryState
:
function
(
km
)
{
image
=
true
;
var
nodes
=
km
.
getSelectedNodes
();
return
false
;
}
if
(
nodes
.
length
===
0
)
{
}
);
return
-
1
;
if
(
image
)
{
}
return
0
;
var
image
=
false
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
-
1
;
if
(
n
.
getData
(
'image'
))
{
image
=
true
;
return
false
;
}
}
}
)
});
if
(
image
)
{
return
0
;
}
return
-
1
;
}
});
var
ImageRenderer
=
kity
.
createClass
(
'ImageRenderer'
,
{
base
:
KityMinder
.
Renderer
,
create
:
function
(
node
)
{
return
new
kity
.
Image
();
},
},
"events"
:
{
"RenderNodeTop"
:
function
(
e
)
{
var
node
=
e
.
node
,
url
=
node
.
getData
(
'image'
);
var
link
,
img
,
size
,
currentBox
;
if
(
url
)
{
shouldRender
:
function
(
node
)
{
return
node
.
getData
(
'image'
);
},
size
=
fitImageSize
(
update
:
function
(
image
,
node
,
box
)
{
node
.
getData
(
'imageWidth'
),
var
url
=
node
.
getData
(
'image'
);
node
.
getData
(
'imageHeight'
),
var
size
=
node
.
getData
(
'imageSize'
);
this
.
getOptions
(
'maxImageWidth'
),
var
spaceTop
=
node
.
getStyle
(
'space-top'
);
this
.
getOptions
(
'maxImageHeight'
)
);
img
=
new
kity
.
Image
(
url
,
size
.
width
,
size
.
height
)
;
if
(
!
size
)
return
;
link
=
new
kity
.
HyperLink
(
url
);
image
link
.
addShape
(
img
);
.
setUrl
(
url
)
link
.
setTarget
(
'_blank'
);
.
setX
(
box
.
cx
-
size
.
width
/
2
)
link
.
setStyle
(
'cursor'
,
'pointer'
);
.
setY
(
box
.
y
-
size
.
height
-
spaceTop
)
.
setWidth
(
size
.
width
)
.
setHeight
(
size
.
height
);
currentBox
=
node
.
getContRc
().
getBoundaryBox
();
return
new
kity
.
Box
(
image
.
getX
(),
image
.
getY
(),
size
.
width
,
size
.
height
);
node
.
getContRc
().
addShape
(
link
.
setTranslate
(
0
,
currentBox
.
y
-
size
.
height
)
);
}
});
}
return
{
}
'defaultOptions'
:
{
'maxImageWidth'
:
200
,
'maxImageHeight'
:
200
},
'commands'
:
{
'image'
:
ImageCommand
,
'removeimage'
:
RemoveImageCommand
},
'renderers'
:
{
'top'
:
ImageRenderer
}
}
};
};
}
);
});
\ No newline at end of file
\ No newline at end of file
src/module/keyboard.js
View file @
5e20101c
...
@@ -9,7 +9,7 @@ KityMinder.registerModule("KeyboardModule", function() {
...
@@ -9,7 +9,7 @@ KityMinder.registerModule("KeyboardModule", function() {
var
pointIndexes
=
[],
var
pointIndexes
=
[],
p
;
p
;
root
.
traverse
(
function
(
node
)
{
root
.
traverse
(
function
(
node
)
{
p
=
node
.
get
RenderContainer
().
getRenderBox
(
'top'
);
p
=
node
.
get
LayoutBox
(
);
// bugfix: 不应导航到收起的节点(判断其尺寸是否存在)
// bugfix: 不应导航到收起的节点(判断其尺寸是否存在)
if
(
p
.
width
&&
p
.
height
)
{
if
(
p
.
width
&&
p
.
height
)
{
...
@@ -127,11 +127,10 @@ KityMinder.registerModule("KeyboardModule", function() {
...
@@ -127,11 +127,10 @@ KityMinder.registerModule("KeyboardModule", function() {
km
.
select
(
nextNode
,
true
);
km
.
select
(
nextNode
,
true
);
}
}
}
}
return
{
return
{
'events'
:
{
'events'
:
{
'contentchange'
:
function
()
{
'contentchange
layoutfinish
'
:
function
()
{
buildPositionNetwork
(
this
.
getRoot
());
buildPositionNetwork
(
this
.
getRoot
());
},
},
'normal.keydown'
:
function
(
e
)
{
'normal.keydown'
:
function
(
e
)
{
...
@@ -142,7 +141,11 @@ KityMinder.registerModule("KeyboardModule", function() {
...
@@ -142,7 +141,11 @@ KityMinder.registerModule("KeyboardModule", function() {
this
.
receiver
.
keydownNode
=
node
;
this
.
receiver
.
keydownNode
=
node
;
switch
(
e
.
originEvent
.
keyCode
)
{
var
keyEvent
=
e
.
originEvent
;
if
(
keyEvent
.
altKey
||
keyEvent
.
ctrlKey
||
keyEvent
.
metaKey
||
keyEvent
.
shiftKey
)
return
;
switch
(
keyEvent
.
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Enter
:
this
.
execCommand
(
'AppendSiblingNode'
,
lang
.
topic
);
this
.
execCommand
(
'AppendSiblingNode'
,
lang
.
topic
);
e
.
preventDefault
();
e
.
preventDefault
();
...
...
src/module/select.js
View file @
5e20101c
KityMinder
.
registerModule
(
"Select"
,
function
()
{
KityMinder
.
registerModule
(
'Select'
,
function
()
{
var
minder
=
this
;
var
minder
=
this
;
var
g
=
KityMinder
.
Geometry
;
var
g
=
KityMinder
.
Geometry
;
...
@@ -67,8 +67,8 @@ KityMinder.registerModule("Select", function() {
...
@@ -67,8 +67,8 @@ KityMinder.registerModule("Select", function() {
// 计算选中范围
// 计算选中范围
minder
.
getRoot
().
traverse
(
function
(
node
)
{
minder
.
getRoot
().
traverse
(
function
(
node
)
{
var
renderBox
=
node
.
getRenderContainer
().
getRenderBox
(
"top"
);
var
renderBox
=
node
.
getRenderContainer
().
getRenderBox
(
'top'
);
if
(
g
.
isBoxIntersect
(
renderBox
,
marquee
))
{
if
(
g
.
getIntersectBox
(
renderBox
,
marquee
))
{
selectedNodes
.
push
(
node
);
selectedNodes
.
push
(
node
);
}
}
});
});
...
@@ -90,7 +90,7 @@ KityMinder.registerModule("Select", function() {
...
@@ -90,7 +90,7 @@ KityMinder.registerModule("Select", function() {
};
};
})();
})();
var
lastDownNode
=
null
;
var
lastDownNode
=
null
,
lastDownPosition
=
null
;
return
{
return
{
'events'
:
{
'events'
:
{
'normal.mousedown textedit.mousedown'
:
function
(
e
)
{
'normal.mousedown textedit.mousedown'
:
function
(
e
)
{
...
@@ -122,6 +122,7 @@ KityMinder.registerModule("Select", function() {
...
@@ -122,6 +122,7 @@ KityMinder.registerModule("Select", function() {
// 不能马上变为单选,因为可能是需要拖动选中的多个节点
// 不能马上变为单选,因为可能是需要拖动选中的多个节点
else
if
(
!
this
.
isSingleSelect
())
{
else
if
(
!
this
.
isSingleSelect
())
{
lastDownNode
=
downNode
;
lastDownNode
=
downNode
;
lastDownPosition
=
e
.
getPosition
(
this
.
getRenderContainer
());
}
}
},
},
'normal.mousemove textedit.mousemove'
:
marqueeActivator
.
selectMove
,
'normal.mousemove textedit.mousemove'
:
marqueeActivator
.
selectMove
,
...
@@ -130,7 +131,9 @@ KityMinder.registerModule("Select", function() {
...
@@ -130,7 +131,9 @@ KityMinder.registerModule("Select", function() {
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
if
(
upNode
&&
upNode
==
lastDownNode
)
{
if
(
upNode
&&
upNode
==
lastDownNode
)
{
this
.
select
(
lastDownNode
,
true
);
var
upPosition
=
e
.
getPosition
(
this
.
getRenderContainer
());
var
movement
=
kity
.
Vector
.
fromPoints
(
lastDownPosition
,
upPosition
);
if
(
movement
.
length
()
<
1
)
this
.
select
(
lastDownNode
,
true
);
lastDownNode
=
null
;
lastDownNode
=
null
;
}
}
...
...
src/theme/default.js
View file @
5e20101c
...
@@ -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'
:
[
30
,
10
]
,
'main-margin'
:
20
,
'main-radius'
:
10
,
'main-radius'
:
10
,
'main-space'
:
5
,
'main-space'
:
5
,
...
@@ -22,7 +22,7 @@ KityMinder.registerTheme('default', {
...
@@ -22,7 +22,7 @@ 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'
:
10
,
'sub-margin'
:
[
15
,
20
]
,
'sub-tree-margin'
:
30
,
'sub-tree-margin'
:
30
,
'sub-radius'
:
5
,
'sub-radius'
:
5
,
'sub-space'
:
5
,
'sub-space'
:
5
,
...
@@ -31,5 +31,15 @@ KityMinder.registerTheme('default', {
...
@@ -31,5 +31,15 @@ KityMinder.registerTheme('default', {
'connect-width'
:
2
,
'connect-width'
:
2
,
'connect-radius'
:
5
,
'connect-radius'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
'selected-background'
:
'rgb(254, 219, 0)'
,
'selected-color'
:
'black'
,
'drop-hint-color'
:
'yellow'
,
'sub-drop-hint-width'
:
2
,
'main-drop-hint-width'
:
4
,
'root-drop-hint-width'
:
4
,
'order-hint-area-color'
:
'rgba(0, 255, 0, .5)'
,
'order-hint-path-color'
:
'#0f0'
,
'order-hint-path-width'
:
2
});
});
\ No newline at end of file
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