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
721273a5
Commit
721273a5
authored
Jun 12, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:fex-team/kityminder into dev
parents
fc1feab1
61fdd29e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
49 deletions
+107
-49
index.html
index.html
+12
-0
minder.data.js
src/core/minder.data.js
+24
-19
hyperlink.js
src/module/hyperlink.js
+36
-14
freemind.js
src/protocal/freemind.js
+9
-6
mindmanager.js
src/protocal/mindmanager.js
+8
-4
xmind.js
src/protocal/xmind.js
+18
-6
No files found.
index.html
View file @
721273a5
...
...
@@ -75,6 +75,18 @@
localStorage
.
lastKMVersion
=
KM
.
version
;
}
});
km
.
on
(
'unziperror'
,
function
(
ev
){
alert
(
'unziperror'
);
});
km
.
on
(
'parseerror'
,
function
(
ev
){
alert
(
'parseerror'
);
});
km
.
on
(
'unknownprotocal'
,
function
(
ev
){
alert
(
'unknownprotocal'
);
});
</script>
<!--Baidu Tongji Code-->
...
...
src/core/minder.data.js
View file @
721273a5
...
...
@@ -89,6 +89,7 @@ kity.extendClass(Minder, {
}
if
(
!
protocal
)
{
this
.
fire
(
'unknownprotocal'
);
throw
new
Error
(
'Unsupported protocal: '
+
protocalName
);
}
...
...
@@ -104,7 +105,7 @@ kity.extendClass(Minder, {
json
=
params
.
json
||
(
params
.
json
=
protocal
.
decode
(
local
));
if
(
typeof
json
===
'object'
&&
'then'
in
json
)
{
if
(
typeof
json
===
'object'
&&
'then'
in
json
){
var
self
=
this
;
json
.
then
(
local
,
function
(
data
)
{
self
.
_doImport
(
data
,
params
);
...
...
@@ -116,28 +117,32 @@ kity.extendClass(Minder, {
},
_doImport
:
function
(
json
,
params
)
{
this
.
_fire
(
new
MinderEvent
(
'preimport'
,
params
,
false
));
try
{
this
.
_fire
(
new
MinderEvent
(
'preimport'
,
params
,
false
));
// 删除当前所有节点
while
(
this
.
_root
.
getChildren
().
length
)
{
this
.
removeNode
(
this
.
_root
.
getChildren
()[
0
]);
}
// 删除当前所有节点
while
(
this
.
_root
.
getChildren
().
length
)
{
this
.
removeNode
(
this
.
_root
.
getChildren
()[
0
]);
}
importNode
(
this
.
_root
,
json
,
this
);
this
.
_root
.
preTraverse
(
function
(
node
)
{
node
.
render
();
});
this
.
_root
.
layout
();
importNode
(
this
.
_root
,
json
,
this
);
this
.
_root
.
preTraverse
(
function
(
node
)
{
node
.
render
();
});
this
.
_root
.
layout
();
this
.
fire
(
'beforeimport'
,
params
);
this
.
fire
(
'import'
,
params
);
this
.
fire
(
'beforeimport'
,
params
);
this
.
fire
(
'import'
,
params
);
this
.
_firePharse
({
type
:
'contentchange'
});
this
.
_firePharse
({
type
:
'interactchange'
});
this
.
_firePharse
({
type
:
'contentchange'
});
this
.
_firePharse
({
type
:
'interactchange'
});
}
catch
(
e
){
this
.
fire
(
'rendererror'
);
}
}
});
\ No newline at end of file
src/module/hyperlink.js
View file @
721273a5
...
...
@@ -9,9 +9,9 @@ KityMinder.registerModule( "hyperlink", function () {
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
,
url
);
km
.
updateLayout
(
n
);
n
.
render
(
);
}
);
km
.
layout
();
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
(),
...
...
@@ -39,8 +39,9 @@ KityMinder.registerModule( "hyperlink", function () {
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
);
km
.
updateLayout
(
n
);
n
.
render
(
);
}
);
km
.
layout
();
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
...
...
@@ -62,33 +63,54 @@ KityMinder.registerModule( "hyperlink", function () {
}
}
)
},
"events"
:
{
"RenderNodeRight"
:
function
(
e
)
{
var
node
=
e
.
node
,
url
=
node
.
getData
(
'hyperlink'
);
if
(
url
)
{
var
link
=
new
kity
.
HyperLink
(
url
);
'renderers'
:
{
right
:
kity
.
createClass
(
'hyperlinkrender'
,
{
base
:
KityMinder
.
Renderer
,
create
:
function
()
{
var
link
=
new
kity
.
HyperLink
();
var
linkshape
=
new
kity
.
Path
();
var
outline
=
new
kity
.
Rect
(
24
,
22
,
-
2
,
-
6
,
4
).
fill
(
'rgba(255, 255, 255, 0)'
);
var
box
=
node
.
getContRc
().
getBoundaryBox
();
var
style
=
this
.
getCurrentLayoutStyle
()[
node
.
getType
()
];
linkshape
.
setPathData
(
linkShapePath
).
fill
(
'#666'
);
link
.
setAttr
(
'xlink:title'
,
url
);
link
.
addShape
(
outline
);
link
.
addShape
(
linkshape
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
node
.
getContRc
().
addShape
(
link
.
setTranslate
(
box
.
x
+
box
.
width
+
style
.
spaceLeft
+
5
,
-
5
)
);
link
.
on
(
'mouseover'
,
function
()
{
outline
.
fill
(
'rgba(255, 255, 200, .8)'
);
}).
on
(
'mouseout'
,
function
()
{
outline
.
fill
(
'rgba(255, 255, 255, 0)'
);
});
return
link
;
},
shouldRender
:
function
(
node
)
{
return
node
.
getData
(
'hyperlink'
);
},
update
:
function
(
link
,
node
,
box
)
{
var
href
=
node
.
getData
(
'hyperlink'
);
link
.
setHref
(
href
);
link
.
setAttr
(
'xlink:title'
,
href
);
var
spaceRight
=
node
.
getStyle
(
'space-right'
);
link
.
setTranslate
(
box
.
right
+
spaceRight
+
2
,
-
5
);
return
{
x
:
box
.
right
+
spaceRight
,
y
:
-
11
,
width
:
24
,
height
:
22
};
}
}
}
)
}
};
}
);
\ No newline at end of file
src/protocal/freemind.js
View file @
721273a5
...
...
@@ -73,15 +73,18 @@ KityMinder.registerProtocal( 'freemind', function () {
}
return
{
fileDescription
:
'
x
mind格式文件'
,
fileExtension
:
'.
xmind
'
,
fileDescription
:
'
free
mind格式文件'
,
fileExtension
:
'.
mm
'
,
decode
:
function
(
local
)
{
var
json
=
xml2km
(
local
);
return
json
;
try
{
return
xml2km
(
local
);
}
catch
(
e
){
km
.
fire
(
'parseerror'
);
return
undefined
;
}
},
// recognize:
recognize
,
// recognize:
null
,
recognizePriority
:
-
1
};
...
...
src/protocal/mindmanager.js
View file @
721273a5
...
...
@@ -75,7 +75,7 @@ KityMinder.registerProtocal( 'mindmanager', function () {
}
function
onerror
(){
alert
(
'文件过程解压出错,请检查该文件是否损坏
'
);
km
.
fire
(
'unziperror
'
);
}
function
getEntries
(
file
,
onend
)
{
...
...
@@ -99,12 +99,16 @@ KityMinder.registerProtocal( 'mindmanager', function () {
if
(
entry
.
filename
==
'Document.xml'
)
{
hasMainDoc
=
true
;
entry
.
getData
(
new
zip
.
TextWriter
(),
function
(
text
)
{
var
km
=
xml2km
(
$
.
parseXML
(
text
)
);
callback
&&
callback
(
km
);
try
{
var
km
=
xml2km
(
$
.
parseXML
(
text
)
);
callback
&&
callback
(
km
);
}
catch
(
e
){
km
.
fire
(
'parseerror'
);
}
}
);
}
}
);
!
hasMainDoc
&&
alert
(
'找不到文件主文档,请检查文件是否是合法mindmanager格式文件
'
);
!
hasMainDoc
&&
km
.
fire
(
'parseerror
'
);
}
);
}
};
...
...
src/protocal/xmind.js
View file @
721273a5
...
...
@@ -29,6 +29,13 @@ KityMinder.registerProtocal( 'xmind', function () {
,
'task-7oct'
:
null
};
function
getAttachedNode
(
arr
){
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
].
type
==
"attached"
)
return
arr
[
i
]
}
}
function
processTopic
(
topic
,
obj
){
//处理文本
...
...
@@ -54,8 +61,9 @@ KityMinder.registerProtocal( 'xmind', function () {
}
//处理子节点
if
(
topic
.
children
&&
topic
.
children
.
topics
&&
topic
.
children
.
topics
.
topic
){
var
tmp
=
topic
.
children
.
topics
.
topic
;
var
topics
;
if
(
topic
.
children
&&
(
topics
=
topic
.
children
.
topics
)
&&
(
topics
.
topic
||
(
utils
.
isArray
(
topics
)
&&
topics
.
length
>
0
)
)
){
var
tmp
=
topics
.
topic
||
(
getAttachedNode
(
topics
)).
topic
;
if
(
tmp
.
length
&&
tmp
.
length
>
0
){
//多个子节点
obj
.
children
=
[];
...
...
@@ -81,7 +89,7 @@ KityMinder.registerProtocal( 'xmind', function () {
}
function
onerror
(){
alert
(
'文件过程解压出错,请检查该文件是否损坏
'
);
km
.
fire
(
'unziperror
'
);
}
function
getEntries
(
file
,
onend
)
{
...
...
@@ -105,13 +113,17 @@ KityMinder.registerProtocal( 'xmind', function () {
if
(
entry
.
filename
==
'content.xml'
){
hasMainDoc
=
true
;
entry
.
getData
(
new
zip
.
TextWriter
(),
function
(
text
)
{
var
km
=
xml2km
(
$
.
parseXML
(
text
));
callback
&&
callback
(
km
);
try
{
var
km
=
xml2km
(
$
.
parseXML
(
text
));
callback
&&
callback
(
km
);
}
catch
(
e
){
km
.
fire
(
'parseerror'
);
}
});
}
});
!
hasMainDoc
&&
alert
(
'找不到文件主文档,请检查文件是否是合法xmind格式文件
'
);
!
hasMainDoc
&&
km
.
fire
(
'parseerror
'
);
});
}
};
...
...
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