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
4f2c9226
Commit
4f2c9226
authored
Feb 12, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
873f9122
01df8e56
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
8 deletions
+108
-8
.jshintrc
.jshintrc
+3
-1
Import Export.md
doc/Import Export.md
+95
-0
node.js
src/core/node.js
+7
-6
font.js
src/module/font.js
+3
-1
No files found.
.jshintrc
View file @
4f2c9226
...
@@ -12,11 +12,13 @@
...
@@ -12,11 +12,13 @@
"console",
"console",
"kity",
"kity",
"KityMinder",
"KityMinder",
"KM",
"Minder",
"Minder",
"MinderNode",
"MinderNode",
"MinderEvent",
"MinderEvent",
"Command",
"Command",
"KITYMINDER_CONFIG",
"KITYMINDER_CONFIG",
"Utils"
"Utils",
"utils"
]
]
}
}
\ No newline at end of file
doc/Import Export.md
0 → 100644
View file @
4f2c9226
# 导入导出功能设计
## 名词
*
本地格式
指一种公开的脑图编码格式,如 XMind、FreeMind、MinderManager、PDF等。下文代码中,local 表示本地格式字符串或二进制流(Blob)。
*
Json格式
指 KityMinder 自身使用的 JS 内存对象,是带数据的树结构。数据结构如下:
```
js
// A <MinderNode> is:
{
"data"
:
{...},
"children"
:
[
<
MinderNode
>
,
<
MinderNode
>
,
...]
}
```
下文代码中,json 表示 json 格式字符串。
*
编码
把 Json 格式转换为一种本地格式的过程
*
解码
把一种本地格式解析回 Json 格式的过程
*
协议
协议包含名称(作为标识)、编码方法(encode)、解码方法(decode)、识别判断(recognize)。解码方法是可选项,因为对于某些协议可以只支持导出而不需支持导入(如 PDF )。识别判断也是可选的,识别判断用于快速判断一个字符串或 Blob 是否改协议的本地数据,这个方法用于自动识别未知格式的协议。如果不提供这个方法,那么将不能把未知格式识别为该协议的格式,所以建议提供。
## 协议注册
使用
`KityMinder`
上的静态方法
`registerProtocal()`
来注册协议。
```
js
KityMinder
.
registerProtocal
(
"xmind"
,
function
()
{
return
{
encode
:
function
(
json
)
{
// return local;
},
decode
:
function
(
local
)
{
// return json;
},
recognize
:
function
(
local
)
{
// return bool;
}
}
});
```
## 协议使用
使用
`KityMinder`
上的静态方法
`findProtocal()`
来获取协议。
```
js
var
pXMind
=
KityMinder
.
findProtocal
(
"xmind"
);
if
(
pXMind
&&
pXMind
.
encode
)
{
local
=
pXMind
.
encode
(
json
);
}
```
## 协议枚举
使用
`KityMinder`
上的静态方法
`getSupportedProtocals()`
来获取支持的协议列表。
```
js
var
supported
=
KityMinder
.
getSupportedProtocals
();
// supported == [ 'xmind', 'txt', 'pdf', ... ]
```
## 导入导出接口
导入导出接口名称与原来架构的保持一致,只是参数有所调整。
### 导入
```
js
minder
.
importData
(
local
[,
protocalName
]
);
```
导入数据需要提供读取到的本地数据,如果指明协议,则直接用指明的协议来解析;否则尝试去识别本地数据的协议格式。
### 导出
```
js
var
exported
=
minder
.
exportData
(
[
protocalName
]
);
```
使用指定的协议来导出数据,如果不指定,则导出成 Json 格式。
src/core/node.js
View file @
4f2c9226
...
@@ -234,15 +234,15 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -234,15 +234,15 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if
(
parent
)
{
if
(
parent
)
{
parent
.
children
.
push
(
_tmp
);
parent
.
children
.
push
(
_tmp
);
}
}
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];
)
{
for
(
var
i
=
0
,
ci
;
(
ci
=
isClonedNode
.
children
[
i
++
]
);
)
{
cloneNode
(
_tmp
,
ci
);
cloneNode
(
_tmp
,
ci
);
}
}
return
_tmp
;
return
_tmp
;
}
}
return
function
()
{
return
function
()
{
return
cloneNode
(
null
,
this
);
return
cloneNode
(
null
,
this
);
};
}
}(),
}(),
equals
:
function
(
node
)
{
equals
:
function
(
node
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
...
@@ -252,7 +252,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -252,7 +252,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
false
;
return
false
;
}
}
for
(
var
i
=
0
,
ci
;
ci
=
this
.
children
[
i
++
];
)
{
for
(
var
i
=
0
,
ci
;
(
ci
=
this
.
children
[
i
++
]
);
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
return
false
;
return
false
;
}
}
...
@@ -261,9 +262,9 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -261,9 +262,9 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
},
getTextShape
:
function
()
{
getTextShape
:
function
()
{
return
this
.
getContRc
().
getShapesByType
(
'text'
)[
0
]
return
this
.
getContRc
().
getShapesByType
(
'text'
)[
0
]
;
},
},
isSelected
:
function
()
{
isSelected
:
function
()
{
return
this
.
getData
(
'highlight'
)
===
true
return
this
.
getData
(
'highlight'
)
===
true
;
}
}
}
);
}
);
\ No newline at end of file
src/module/font.js
View file @
4f2c9226
...
@@ -87,9 +87,11 @@ KityMinder.registerModule( "fontmodule", function () {
...
@@ -87,9 +87,11 @@ KityMinder.registerModule( "fontmodule", function () {
e
.
node
.
getTextShape
().
setAttr
(
'font-family'
,
val
);
e
.
node
.
getTextShape
().
setAttr
(
'font-family'
,
val
);
}
}
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
console
.
log
(
val
);
e
.
node
.
getTextShape
().
fill
(
val
);
e
.
node
.
getTextShape
().
fill
(
val
);
}
}
if
(
val
=
e
.
node
.
getData
(
'fontsize'
)
)
{
e
.
node
.
getTextShape
().
setSize
(
val
);
}
}
}
}
}
};
};
...
...
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