jsmind 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +45 -32
- package/docs/en/1.usage.md +4 -3
- package/docs/en/2.options.md +6 -1
- package/docs/en/3.operation.md +18 -17
- package/docs/en/4.contribution.md +6 -5
- package/docs/en/5.development.md +18 -0
- package/docs/en/index.md +1 -0
- package/docs/zh/1.usage.md +4 -3
- package/docs/zh/2.options.md +7 -1
- package/docs/zh/3.operation.md +23 -17
- package/docs/zh/4.contribution.md +13 -6
- package/docs/zh/5.development.md +78 -0
- package/docs/zh/index.md +1 -0
- package/es6/jsmind.draggable-node.js +9 -0
- package/es6/jsmind.draggable-node.js.map +1 -0
- package/es6/jsmind.js +9 -0
- package/es6/jsmind.js.map +1 -0
- package/es6/jsmind.screenshot.js +9 -0
- package/es6/jsmind.screenshot.js.map +1 -0
- package/js/{jsmind.draggable.js → jsmind.draggable-node.js} +5 -3
- package/js/jsmind.js +129 -148
- package/js/jsmind.screenshot.js +3 -3
- package/package.json +51 -31
- package/style/jsmind.css +357 -115
- package/example/1_basic.html +0 -62
- package/example/2_features.html +0 -528
- package/example/3_mathjax.html +0 -104
- package/example/ant.png +0 -0
- package/example/data_example.json +0 -48
- package/example/demo.html +0 -102
- package/features/jsmind.shell.js +0 -116
- package/screenshots/jsmind.png +0 -0
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2014-
|
|
1
|
+
Copyright (c) 2014-2022, ZHANG ZHIGANG <hizzgdev@163.com>
|
|
2
2
|
All rights reserved.
|
|
3
3
|
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
@@ -11,7 +11,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
版权所有 (c) 2014-
|
|
14
|
+
版权所有 (c) 2014-2022, 张志刚 <hizzgdev@163.com>
|
|
15
15
|
保留一切权利。
|
|
16
16
|
|
|
17
17
|
在满足下列条件的前提下,授予使用者使用及再发布本软件的源代码或二进制形式的权利,无论是否修改皆然:
|
package/README.md
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
jsMind
|
|
2
|
-
======
|
|
1
|
+
# jsMind
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+

|
|
5
4
|
|
|
6
|
-
jsMind
|
|
5
|
+
jsMind 是一个显示/编辑思维导图的纯 javascript 类库,其基于 html5 canvas (和 svg) 进行设计。jsMind 以 BSD 协议开源,在此基础上你可以在你的项目上任意使用。你可以在此浏览[适用于 jsMind 的 BSD 许可协议(中英文版本)][3]。
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
jsMind is a pure javascript library for mindmap, it base on html5 canvas and svg. jsMind was released under BSD license, you can embed it in any project, if only you observe the license. You can read [the BSD license agreement for jsMind in English and Chinese version][3] here.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* App : <http://jsmind.sinaapp.com>
|
|
13
|
-
* Home : <http://hizzgdev.github.io/jsmind/developer.html>
|
|
14
|
-
* Demo :
|
|
15
|
-
* <http://hizzgdev.github.io/jsmind/example/1_basic.html>
|
|
16
|
-
* <http://hizzgdev.github.io/jsmind/example/2_features.html>
|
|
17
|
-
* <http://hizzgdev.github.io/jsmind/example/3_mathjax.html>
|
|
18
|
-
* Documents :
|
|
19
|
-
* [简体中文][1]
|
|
20
|
-
* [English(draft)][2]
|
|
21
|
-
* Wiki :
|
|
22
|
-
* [邮件列表 Mailing List](../../wiki/MailingList)
|
|
23
|
-
* [热点问题 Hot Topics](../../wiki/HotTopics)
|
|
24
|
-
* Donate :
|
|
25
|
-
* [资助本项目的开发][4]
|
|
26
|
-
|
|
27
|
-
Get Started:
|
|
9
|
+
## Get Started
|
|
28
10
|
|
|
29
11
|
```html
|
|
30
12
|
<html>
|
|
@@ -32,8 +14,8 @@ Get Started:
|
|
|
32
14
|
<link type="text/css" rel="stylesheet" href="style/jsmind.css" />
|
|
33
15
|
<script type="text/javascript" src="js/jsmind.js"></script>
|
|
34
16
|
<!--
|
|
35
|
-
enable
|
|
36
|
-
<script type="text/javascript" src="js/jsmind.draggable.js"></script>
|
|
17
|
+
enable draggable node feature
|
|
18
|
+
<script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
|
|
37
19
|
-->
|
|
38
20
|
</head>
|
|
39
21
|
<body>
|
|
@@ -45,9 +27,9 @@ Get Started:
|
|
|
45
27
|
// see Documents for more information
|
|
46
28
|
};
|
|
47
29
|
var options = {
|
|
48
|
-
container:'jsmind_container',
|
|
49
|
-
theme:'orange',
|
|
50
|
-
editable:true
|
|
30
|
+
container: 'jsmind_container',
|
|
31
|
+
theme: 'orange',
|
|
32
|
+
editable: true,
|
|
51
33
|
};
|
|
52
34
|
var jm = new jsMind(options);
|
|
53
35
|
jm.show(mind);
|
|
@@ -56,7 +38,38 @@ Get Started:
|
|
|
56
38
|
</html>
|
|
57
39
|
```
|
|
58
40
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
## Links
|
|
42
|
+
|
|
43
|
+
- App : <http://jsmind.sinaapp.com>
|
|
44
|
+
- Home : <http://hizzgdev.github.io/jsmind/developer.html>
|
|
45
|
+
- npm : <https://www.npmjs.com/package/jsmind>
|
|
46
|
+
- Demo :
|
|
47
|
+
- <http://hizzgdev.github.io/jsmind/example/1_basic.html>
|
|
48
|
+
- <http://hizzgdev.github.io/jsmind/example/2_features.html>
|
|
49
|
+
- <http://hizzgdev.github.io/jsmind/example/3_mathjax.html>
|
|
50
|
+
- Documents :
|
|
51
|
+
- [简体中文][1]
|
|
52
|
+
- [English][2]
|
|
53
|
+
- Wiki :
|
|
54
|
+
- [邮件列表 Mailing List](../../wiki/MailingList)
|
|
55
|
+
- [热点问题 Hot Topics](../../wiki/HotTopics)
|
|
56
|
+
- Donate :
|
|
57
|
+
- [Become a sponsor][4]
|
|
58
|
+
- [资助本项目的开发][5]
|
|
59
|
+
|
|
60
|
+
## ES6 Pilot Version
|
|
61
|
+
|
|
62
|
+
- 目前处于测试阶段,欢迎试用找 bug, ES6 代码位于 `/src`, 可运行于浏览器的 js 文件位于 `/es6`
|
|
63
|
+
- Currently it's in the testing stage, You are welcome to serve as a guinea pig, the ES6 code is located in `/src`, and the js files that can run in browsers are located in `/es6`
|
|
64
|
+
- Demo <http://hizzgdev.github.io/jsmind/example/2_features_es6.html>
|
|
65
|
+
|
|
66
|
+
## Maintainer
|
|
67
|
+
|
|
68
|
+
- [张志刚 | Zhigang Zhang](https://hizzgdev.github.io)
|
|
69
|
+
- hizzgdev@163.com
|
|
70
|
+
|
|
71
|
+
[1]: docs/zh/index.md
|
|
72
|
+
[2]: docs/en/index.md
|
|
73
|
+
[3]: LICENSE
|
|
74
|
+
[4]: https://github.com/sponsors/hizzgdev
|
|
75
|
+
[5]: http://hizzgdev.github.io/sponsor.html
|
package/docs/en/1.usage.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[Contents](index.md)
|
|
2
2
|
|
|
3
|
-
1.
|
|
3
|
+
1. [Usage *](1.usage.md)
|
|
4
4
|
2. [Options](2.options.md)
|
|
5
5
|
3. [Operation](3.operation.md)
|
|
6
6
|
4. [Contribution](4.contribution.md)
|
|
7
|
+
5. [Attached: Development Guide](5.development.md)
|
|
7
8
|
|
|
8
9
|
1.1. Basic Framework
|
|
9
10
|
===
|
|
@@ -15,10 +16,10 @@ At first, 2 files (jsmind.css and jsmind.js) are required.
|
|
|
15
16
|
<script type="text/javascript" src="js/jsmind.js"></script>
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
add script jsmind.draggable.js for enabling
|
|
19
|
+
add script jsmind.draggable-node.js for enabling draggable node feature.
|
|
19
20
|
|
|
20
21
|
```html
|
|
21
|
-
<script type="text/javascript" src="js/jsmind.draggable.js"></script>
|
|
22
|
+
<script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
The second, a div element should be in your HTML as container
|
package/docs/en/2.options.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[Contents](index.md)
|
|
2
2
|
|
|
3
3
|
1. [Usage](1.usage.md)
|
|
4
|
-
2.
|
|
4
|
+
2. [Options *](2.options.md)
|
|
5
5
|
3. [Operation](3.operation.md)
|
|
6
6
|
4. [Contribution](4.contribution.md)
|
|
7
|
+
5. [Attached: Development Guide](5.development.md)
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
2.1. Introduction
|
|
@@ -99,6 +100,10 @@ These options are described in more detail below.
|
|
|
99
100
|
|
|
100
101
|
> Note that in freemind, the style of the node is controlled using the HTML language, and it is recommended to set this parameter to true if you are using data in freemind format.
|
|
101
102
|
|
|
103
|
+
**log_level** : (string) log level
|
|
104
|
+
|
|
105
|
+
> There are 5 levels: `debug`/`info`/`warn`/`error`/`disable`, default level is `info`. if it set to `disable`, all the logs will be closed.
|
|
106
|
+
|
|
102
107
|
2.3 Layout Options
|
|
103
108
|
===
|
|
104
109
|
|
package/docs/en/3.operation.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
1. [Usage](1.usage.md)
|
|
4
4
|
2. [Options](2.options.md)
|
|
5
|
-
3.
|
|
5
|
+
3. [Operation *](3.operation.md)
|
|
6
6
|
4. [Contribution](4.contribution.md)
|
|
7
|
+
5. [Attached: Development Guide](5.development.md)
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
jsMind object
|
|
@@ -36,11 +37,11 @@ Use the `jm.show(mind)` method to display a mindmap, see [1.1. Basic framework](
|
|
|
36
37
|
|
|
37
38
|
**Get root** : Use `jm.get_root()` to get the root of the current mindmap.
|
|
38
39
|
|
|
39
|
-
**Find node by id** : Use the `jm.get_node(
|
|
40
|
+
**Find node by id** : Use the `jm.get_node(node_id)` method to find the node specified in the current mind map by id, and return `null` if it is not found.
|
|
40
41
|
|
|
41
42
|
**Get selected node** : Use `jm.get_selected_node()` to get the currently selected node and return `null` if there is no selected node.
|
|
42
43
|
|
|
43
|
-
**Find adjacent nodes** : Use `jm.find_node_before(node|
|
|
44
|
+
**Find adjacent nodes** : Use `jm.find_node_before(node|node_id)` and `find_node_after(node|node_id)` to get the previous or next node of the specified node, and return `null` if there is no previous or next one.
|
|
44
45
|
|
|
45
46
|
**Fetch parent** : Use `node.parent` to get the parent node, the parent of the root node is `null`.
|
|
46
47
|
|
|
@@ -68,25 +69,25 @@ node {
|
|
|
68
69
|
3.3 Operation on Nodes
|
|
69
70
|
===
|
|
70
71
|
|
|
71
|
-
**Select node** : Use the `jm.select_node(node) method to select the specified node.
|
|
72
|
+
**Select node** : Use the `jm.select_node(node)` method to select the specified node.
|
|
72
73
|
|
|
73
|
-
**Collapse child nodes** : Use the `jm.collapse_node(node|
|
|
74
|
+
**Collapse child nodes** : Use the `jm.collapse_node(node|node_id)` method to collapse the child nodes of the node.
|
|
74
75
|
|
|
75
|
-
**Expand Child Node** : Use the `jm.expand_node(node|
|
|
76
|
+
**Expand Child Node** : Use the `jm.expand_node(node|node_id)` method to expand the child node of this node.
|
|
76
77
|
|
|
77
|
-
**Collapse or expand child nodes** : Use the `jm.toggle_node(node|
|
|
78
|
+
**Collapse or expand child nodes** : Use the `jm.toggle_node(node|node_id)` method to automatically expand or collapse child nodes.
|
|
78
79
|
|
|
79
80
|
**Expand all child nodes** : All child nodes can be expanded using the `jm.expand_all()` method.
|
|
80
81
|
|
|
81
82
|
**Expand to level** : Use the `jm.expand_to_depth(depth)` method to expand to a specified level.
|
|
82
83
|
|
|
83
|
-
**Move Node** : Use the `jm.move_node(node|
|
|
84
|
+
**Move Node** : Use the `jm.move_node(node|node_id,before_id)` method to move the node to before_id node, and set before_id to `_first_` or `_last_` to move the node to first or last of the adjacent node.
|
|
84
85
|
|
|
85
86
|
**Enable editing** : Use the `jm.enable_edit()` method to enable editing of the current mindmap.
|
|
86
87
|
|
|
87
88
|
**Disable_edit** : Use the `jm.disable_edit()` method to disable editing of the current mindmap.
|
|
88
89
|
|
|
89
|
-
**Edit Node** : The node can be adjusted to edit using the `jm.begin_edit(node|
|
|
90
|
+
**Edit Node** : The node can be adjusted to edit using the `jm.begin_edit(node|node_id)` method.
|
|
90
91
|
|
|
91
92
|
**Stop editing** : The node can be adjusted to read-only using the `jm.end_edit()` method.
|
|
92
93
|
|
|
@@ -94,15 +95,15 @@ node {
|
|
|
94
95
|
3.4. Editing Nodes
|
|
95
96
|
===
|
|
96
97
|
|
|
97
|
-
**Add Node** : A node can be added using the `jm.add_node(parent_node,
|
|
98
|
+
**Add Node** : A node can be added using the `jm.add_node(parent_node, node_id, topic, data)` method.
|
|
98
99
|
|
|
99
|
-
**Insert node before specified location** : The `jm.insert_node_before(node_before,
|
|
100
|
+
**Insert node before specified location** : The `jm.insert_node_before(node_before, node_id, topic, data)` method can be used to insert a node before a node_before node.
|
|
100
101
|
|
|
101
|
-
**Insert node after specified location** : Node can be inserted after node_after using `jm.insert_node_after(node_after,
|
|
102
|
+
**Insert node after specified location** : Node can be inserted after node_after using `jm.insert_node_after(node_after, node_id, topic, data)` method.
|
|
102
103
|
|
|
103
|
-
**Delete Node** : Use the `jm.remove_node(node|
|
|
104
|
+
**Delete Node** : Use the `jm.remove_node(node|node_id)` method to delete a specified node and all its children.
|
|
104
105
|
|
|
105
|
-
**Update node** : Use the `jm.update_node(
|
|
106
|
+
**Update node** : Use the `jm.update_node(node_id, topic)` method to update the topic of the specified node.
|
|
106
107
|
|
|
107
108
|
|
|
108
109
|
3.5 Setting Style
|
|
@@ -110,11 +111,11 @@ node {
|
|
|
110
111
|
|
|
111
112
|
**Set the theme** : Use the `jm.set_theme(theme)` method to set the theme of the mind map.
|
|
112
113
|
|
|
113
|
-
**Set background / foreground color** : Use the `jm.set_node_color(
|
|
114
|
+
**Set background / foreground color** : Use the `jm.set_node_color(node_id, bg_color, fg_color)` method to set the background and foreground color of the specified node.
|
|
114
115
|
|
|
115
|
-
**Set Font** : Use the `jm.set_node_font_style(
|
|
116
|
+
**Set Font** : Use the `jm.set_node_font_style(node_id, size, weight, style)` method to set the font of the specified node.
|
|
116
117
|
|
|
117
|
-
**Set background image** : Use the `jm.set_node_background_image(
|
|
118
|
+
**Set background image** : Use the `jm.set_node_background_image(node_id, image, width, height)` method to set the background image of the specified node.
|
|
118
119
|
|
|
119
120
|
3.6 Access to Data
|
|
120
121
|
===
|
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
1. [Usage](1.usage.md)
|
|
4
4
|
2. [Options](2.options.md)
|
|
5
5
|
3. [Operation](3.operation.md)
|
|
6
|
-
4.
|
|
6
|
+
4. [Contribution *](4.contribution.md)
|
|
7
|
+
5. [Attached: Development Guide](5.development.md)
|
|
7
8
|
|
|
8
9
|
4.1. contribution code
|
|
9
10
|
===
|
|
10
11
|
|
|
11
|
-
jsMind
|
|
12
|
+
jsMind still has a lot of room for improvement and optimization. You are welcome to contribute code to jsMind.
|
|
12
13
|
|
|
13
14
|
The most convenient way to contribute code is to submit a pull-request to the jsMind project, which can be done in the github help documentation.
|
|
14
15
|
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* [Creating a pull request from a fork](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork)
|
|
17
|
+
* [Working with forks] (https://help.github.com/en/articles/working-with-forks)
|
|
17
18
|
|
|
18
19
|
Before submitting a pull-request, be sure to test it well and make a detailed note when submitting the pull-request, including feature descriptions, code change notes.
|
|
19
20
|
|
|
20
|
-
4.2
|
|
21
|
+
4.2 ask questions or contribute ideas
|
|
21
22
|
===
|
|
22
23
|
|
|
23
24
|
Or you can bring up a problem or need you've encountered via an issue for discussion, and hopefully a friend who has the ability and energy to join in and solve the problem together.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[Contents](index.md)
|
|
2
|
+
|
|
3
|
+
1. [Usage](1.usage.md)
|
|
4
|
+
2. [Options](2.options.md)
|
|
5
|
+
3. [Operation](3.operation.md)
|
|
6
|
+
4. [Contribution](4.contribution.md)
|
|
7
|
+
5. [Attached: Development Guide *](5.development.md)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
WIP
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
copyright notice
|
|
14
|
+
===
|
|
15
|
+
|
|
16
|
+
Reproduction and deduction are prohibited.
|
|
17
|
+
|
|
18
|
+
The jsMind project is still being updated and the corresponding documentation is updated at the same time as the version is updated. In order to avoid confusion to the user, it is forbidden to reprint this document without written permission and to make changes of any kind to this document.
|
package/docs/en/index.md
CHANGED
package/docs/zh/1.usage.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[目录](index.md)
|
|
2
2
|
|
|
3
|
-
1.
|
|
3
|
+
1. [基本用法 *](1.usage.md)
|
|
4
4
|
2. [选项](2.options.md)
|
|
5
5
|
3. [界面操控](3.operation.md)
|
|
6
6
|
4. [参与贡献](4.contribution.md)
|
|
7
|
+
5. [附:贡献代码指南](5.development.md)
|
|
7
8
|
|
|
8
9
|
1.1. 基本框架
|
|
9
10
|
===
|
|
@@ -15,10 +16,10 @@
|
|
|
15
16
|
<script type="text/javascript" src="js/jsmind.js"></script>
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
如果希望能够通过鼠标拖拽的方式移动节点,需要额外引用 jsmind.draggable.js 文件
|
|
19
|
+
如果希望能够通过鼠标拖拽的方式移动节点,需要额外引用 jsmind.draggable-node.js 文件
|
|
19
20
|
|
|
20
21
|
```html
|
|
21
|
-
<script type="text/javascript" src="js/jsmind.draggable.js"></script>
|
|
22
|
+
<script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
其次,要为 jsMind 准备一个容器,jsMind 将在这个容器里显示思维导图。可自行定义容器的id、大小及样式。
|
package/docs/zh/2.options.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[目录](index.md)
|
|
2
2
|
|
|
3
3
|
1. [基本用法](1.usage.md)
|
|
4
|
-
2.
|
|
4
|
+
2. [选项 *](2.options.md)
|
|
5
5
|
3. [界面操控](3.operation.md)
|
|
6
6
|
4. [参与贡献](4.contribution.md)
|
|
7
|
+
5. [附:贡献代码指南](5.development.md)
|
|
7
8
|
|
|
8
9
|
2.1. 综述
|
|
9
10
|
===
|
|
@@ -28,6 +29,7 @@ options = {
|
|
|
28
29
|
theme : null, // 主题
|
|
29
30
|
mode :'full', // 显示模式
|
|
30
31
|
support_html : true, // 是否支持节点里的HTML元素
|
|
32
|
+
log_level: 'info', // 日志级别
|
|
31
33
|
view:{
|
|
32
34
|
engine: 'canvas', // 思维导图各节点之间线条的绘制引擎
|
|
33
35
|
hmargin:100, // 思维导图距容器外框的最小水平距离
|
|
@@ -96,6 +98,10 @@ options = {
|
|
|
96
98
|
|
|
97
99
|
> 需要注意的是,在 freemind 中,节点的样式是使用 html 语言进行控制的,如果你使用 freemind 格式的数据时,建议将此参数设置为 true。
|
|
98
100
|
|
|
101
|
+
**log_level** : (string) log 级别
|
|
102
|
+
|
|
103
|
+
> log 级别一共有五种: `debug`/`info`/`warn`/`error`/`disable`,默认设置为 `info`,如果需要关闭所有日志,请设置为 `disable`。
|
|
104
|
+
|
|
99
105
|
2.3. 排版选项
|
|
100
106
|
===
|
|
101
107
|
|
package/docs/zh/3.operation.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
1. [基本用法](1.usage.md)
|
|
4
4
|
2. [选项](2.options.md)
|
|
5
|
-
3.
|
|
5
|
+
3. [界面操控 *](3.operation.md)
|
|
6
6
|
4. [参与贡献](4.contribution.md)
|
|
7
|
+
5. [附:贡献代码指南](5.development.md)
|
|
7
8
|
|
|
8
9
|
jsMind 对象
|
|
9
10
|
===
|
|
@@ -35,11 +36,11 @@ var jm = jsMind.current;
|
|
|
35
36
|
|
|
36
37
|
**获取根节点** : 使用 `jm.get_root()` 即可获取当前思维导图的根节点。
|
|
37
38
|
|
|
38
|
-
**根据 id 查找节点** : 使用 `jm.get_node(
|
|
39
|
+
**根据 id 查找节点** : 使用 `jm.get_node(node_id)` 方法即可根据 id 查找当前思维导图中指定的节点,如果查找不到则返回 `null`。
|
|
39
40
|
|
|
40
41
|
**获取选中的节点** : 使用 `jm.get_selected_node()` 方法即可获取当前选中的节点,如果没有选中的节点则返回 `null`。
|
|
41
42
|
|
|
42
|
-
**查找相邻的节点** : 使用 `jm.find_node_before(node|
|
|
43
|
+
**查找相邻的节点** : 使用 `jm.find_node_before(node|node_id)` 和 `find_node_after(node|node_id)` 即可获取指定的节点的上一个或下一个节点,如果没有上一个或下一个,则返回 `null`。
|
|
43
44
|
|
|
44
45
|
**获取父节点** : 使用 `node.parent` 即可获取父节点,根节点的父节点为 `null`。
|
|
45
46
|
|
|
@@ -67,51 +68,51 @@ node {
|
|
|
67
68
|
3.3. 操作节点
|
|
68
69
|
===
|
|
69
70
|
|
|
70
|
-
**选中节点** : 使用 `jm.select_node(node) 方法选中指定的节点。
|
|
71
|
+
**选中节点** : 使用 `jm.select_node(node)` 方法选中指定的节点。
|
|
71
72
|
|
|
72
|
-
**收起子节点** : 使用 `jm.collapse_node(node|
|
|
73
|
+
**收起子节点** : 使用 `jm.collapse_node(node|node_id)` 方法可收起该节点的子节点。
|
|
73
74
|
|
|
74
|
-
**展开子节点** : 使用 `jm.expand_node(node|
|
|
75
|
+
**展开子节点** : 使用 `jm.expand_node(node|node_id)` 方法可展开该节点的子节点。
|
|
75
76
|
|
|
76
|
-
**收起或展开子节点** : 使用 `jm.toggle_node(node|
|
|
77
|
+
**收起或展开子节点** : 使用 `jm.toggle_node(node|node_id)` 方法可自动展开或收起子节点。
|
|
77
78
|
|
|
78
79
|
**展开全部子节点** : 使用 `jm.expand_all()` 方法可展开全部子节点。
|
|
79
80
|
|
|
80
81
|
**展开至层级** : 使用 `jm.expand_to_depth(depth)` 方法可展开到指定层级。
|
|
81
82
|
|
|
82
|
-
**移动节点** : 使用 `jm.move_node(node|
|
|
83
|
+
**移动节点** : 使用 `jm.move_node(node|node_id,before_id)` 方法可将该节点移动到 before_id 节点之前,可将 before_id 设为 `_first_`或`_last_`可将该节点移动到相邻节点的最前或最后。
|
|
83
84
|
|
|
84
85
|
**启用编辑** : 使用 `jm.enable_edit()` 方法可启用对当前思维导图的编辑功能。
|
|
85
86
|
|
|
86
87
|
**禁止编辑** : 使用 `jm.disable_edit()` 方法可禁止对当前思维导图进行编辑。
|
|
87
88
|
|
|
88
|
-
**编辑节点** : 使用 `jm.begin_edit(node|
|
|
89
|
+
**编辑节点** : 使用 `jm.begin_edit(node|node_id)` 方法可以将该节点调整为编辑状态。
|
|
89
90
|
|
|
90
91
|
**停止编辑** : 使用 `jm.end_edit()` 方法可以将该节点调整为只读状态。
|
|
91
92
|
|
|
92
93
|
3.4. 编辑节点
|
|
93
94
|
===
|
|
94
95
|
|
|
95
|
-
**添加节点** : 使用 `jm.add_node(parent_node,
|
|
96
|
+
**添加节点** : 使用 `jm.add_node(parent_node, node_id, topic, data)` 方法可添加一个节点。
|
|
96
97
|
|
|
97
|
-
**在指定位置前插入节点** : 使用 `jm.insert_node_before(node_before,
|
|
98
|
+
**在指定位置前插入节点** : 使用 `jm.insert_node_before(node_before, node_id, topic, data)` 方法可在 node_before 节点前插入节点。
|
|
98
99
|
|
|
99
|
-
**在指定位置后插入节点** : 使用 `jm.insert_node_after(node_after,
|
|
100
|
+
**在指定位置后插入节点** : 使用 `jm.insert_node_after(node_after, node_id, topic, data)` 方法可在 node_after 节点后插入节点。
|
|
100
101
|
|
|
101
|
-
**删除节点** : 使用 `jm.remove_node(node|
|
|
102
|
+
**删除节点** : 使用 `jm.remove_node(node|node_id)` 方法可删除指定的节点及其所有的子节点。
|
|
102
103
|
|
|
103
|
-
**更新节点** : 使用 `jm.update_node(
|
|
104
|
+
**更新节点** : 使用 `jm.update_node(node_id, topic)` 方法可更新指定节点的 topic,其它属性由于不在界面上显示,可以直接修改对应 node 的属性。
|
|
104
105
|
|
|
105
106
|
3.5. 设置样式
|
|
106
107
|
===
|
|
107
108
|
|
|
108
109
|
**设置主题** : 使用 `jm.set_theme(theme)` 方法可设置当前思维导图的主题。
|
|
109
110
|
|
|
110
|
-
**设置背景色/前景色** : 使用 `jm.set_node_color(
|
|
111
|
+
**设置背景色/前景色** : 使用 `jm.set_node_color(node_id, bg_color, fg_color)` 方法可设置指定节点的背景色与前景色。
|
|
111
112
|
|
|
112
|
-
**设置字体** : 使用 `jm.set_node_font_style(
|
|
113
|
+
**设置字体** : 使用 `jm.set_node_font_style(node_id, size, weight, style)` 方法可设置指定节点的字体。
|
|
113
114
|
|
|
114
|
-
**设置背景图片** : 使用 `jm.set_node_background_image(
|
|
115
|
+
**设置背景图片** : 使用 `jm.set_node_background_image(node_id, image, width, height)` 方法可设置指定节点的背景图片。
|
|
115
116
|
|
|
116
117
|
3.6. 获取数据
|
|
117
118
|
===
|
|
@@ -127,6 +128,11 @@ node {
|
|
|
127
128
|
|
|
128
129
|
**判断节点是否可见** : 使用 `jm.is_node_visible(node)` 方法可以判断此节点是否显示。
|
|
129
130
|
|
|
131
|
+
3.8. 兼容性说明
|
|
132
|
+
===
|
|
133
|
+
|
|
134
|
+
请尽量只使用此文档中介绍的这些 API, 在后续的版本迭代中,这些 API 将会得到最大程度的兼容性支持。此文档以外的方法有可能会随时修改和删除。
|
|
135
|
+
|
|
130
136
|
版权声明
|
|
131
137
|
===
|
|
132
138
|
|
|
@@ -3,28 +3,35 @@
|
|
|
3
3
|
1. [基本用法](1.usage.md)
|
|
4
4
|
2. [选项](2.options.md)
|
|
5
5
|
3. [界面操控](3.operation.md)
|
|
6
|
-
4.
|
|
6
|
+
4. [参与贡献 *](4.contribution.md)
|
|
7
|
+
5. [附:贡献代码指南](5.development.md)
|
|
7
8
|
|
|
8
9
|
4.1. 贡献代码
|
|
9
10
|
===
|
|
10
11
|
|
|
11
|
-
jsMind
|
|
12
|
+
jsMind 还有很多可以完善及优化的地方,欢迎任何人给 jsMind 贡献代码。
|
|
12
13
|
|
|
13
14
|
贡献代码最方便的方式是给 jsMind 项目提交 pull-request,具体做法可参考 github 的帮助文档:
|
|
14
15
|
|
|
15
16
|
* [Creating a pull request from a fork](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork)
|
|
16
17
|
* [Working with forks](https://help.github.com/en/articles/working-with-forks)
|
|
17
18
|
|
|
19
|
+
另外我们准备了 jsMind 的[开发指南](5.development.md),有需要的话可以阅读了解。
|
|
20
|
+
|
|
18
21
|
在提交 pull-request 前,请务必做好测试,并在提交 pull-request 时做出详细的说明,包括功能特性介绍、代码变更说明。
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
|
|
24
|
+
4.2. 提出问题或贡献想法
|
|
21
25
|
===
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
或者您可以将您遇到的问题或想法通过 issue 的方式提出来供大家讨论,希望有能力和精力的朋友共同参与,一起解决问题。
|
|
24
28
|
|
|
25
|
-
对于共性的需求,建议实现后回馈到开源项目中,对于非共性的需求,可fork出独立仓库进行定制开发。
|
|
29
|
+
对于共性的需求,建议实现后回馈到开源项目中,对于非共性的需求,可 fork 出独立仓库进行定制开发。
|
|
30
|
+
|
|
31
|
+
4.3. 需要定制开发
|
|
32
|
+
===
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
jsMind 以 BSD 协议开源,并不限制商业使用。如果需要定制开发,请单独联系作者或您依赖的其他开发者。
|
|
28
35
|
|
|
29
36
|
版权声明
|
|
30
37
|
===
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[目录](index.md)
|
|
2
|
+
|
|
3
|
+
1. [基本用法](1.usage.md)
|
|
4
|
+
2. [选项](2.options.md)
|
|
5
|
+
3. [界面操控](3.operation.md)
|
|
6
|
+
4. [参与贡献](4.contribution.md)
|
|
7
|
+
5. [附:贡献代码指南 *](5.development.md)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
> 首先向您表示感谢,开源社区因为有您而生机勃勃,jsMind也因您而有了更大的价值。
|
|
11
|
+
|
|
12
|
+
5.1. 基本流程
|
|
13
|
+
===
|
|
14
|
+
|
|
15
|
+
向 jsMind 贡献代码的基本流程是:
|
|
16
|
+
|
|
17
|
+
1. fork jsmind
|
|
18
|
+
2. 开发新功能或改进当前版本
|
|
19
|
+
3. 测试您的代码
|
|
20
|
+
4. 给 jsmind 提交 pull-request
|
|
21
|
+
5. 等待审查,审查期间可能会请你对您的代码进行修改
|
|
22
|
+
6. 合并你的 pull-request 到 jsMind 项目中
|
|
23
|
+
|
|
24
|
+
5.2. 开发前的准备
|
|
25
|
+
===
|
|
26
|
+
|
|
27
|
+
**Pull-Request 及 Fork** : 阅读 github 文档 [中文](https://docs.github.com/cn/pull-requests), [英文](https://docs.github.com/cn/pull-requests), 了解如何通过 fork 及 pull-request 提交你的代码。
|
|
28
|
+
|
|
29
|
+
**Node.js** : 使用 jsMind 时是不需要在 Node.js 环境下的,但是在开发时,需要在 Node.js 环境下执行单元测试、代码格式化检查、及打包和压缩。对 Node.js 的版本没有强烈的要求,但是 CI 环境里使用的是 18.x 的版本,如果您提交 pull-request 后发现没有通过 CI 检测,请将你的 node 修改为 18.x 的版本。
|
|
30
|
+
|
|
31
|
+
**Visual Studio Code** : 如果您使用的 IDE 是 VS Code, 建议您安装这个插件: `esbenp.prettier-vscode` 。这样的话在本项目里,你的 VS Code 将能自动按 jsMind 的配置对代码进行格式化
|
|
32
|
+
|
|
33
|
+
5.3. 开发
|
|
34
|
+
===
|
|
35
|
+
|
|
36
|
+
jsMind 使用 ES6 编写,代码在 `/src` 目录里,一般情况下只需要在此目录里开发即可。
|
|
37
|
+
|
|
38
|
+
开发过程中请记得随时格式化代码。在命令行中执行以下代码即可对代码进行格式化:
|
|
39
|
+
```
|
|
40
|
+
npm run format
|
|
41
|
+
```
|
|
42
|
+
5.4. 单元测试
|
|
43
|
+
===
|
|
44
|
+
|
|
45
|
+
单元测试的代码位于 `/tests/unit` 目录,请为新代码的代码补充单元测试,并确保所有的单元测试都能通过。
|
|
46
|
+
|
|
47
|
+
在命令行中执行以下命令即可运行单元测试。
|
|
48
|
+
```
|
|
49
|
+
npm run test-es6
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
5.5. 打包及压缩
|
|
53
|
+
===
|
|
54
|
+
|
|
55
|
+
在命令行中执行以下命令将代码打包为便于在浏览器中执行的js文件:
|
|
56
|
+
```
|
|
57
|
+
npm run build
|
|
58
|
+
```
|
|
59
|
+
生成的代码位于 `/es6` 目录。
|
|
60
|
+
|
|
61
|
+
5.5. 本地预览及调试
|
|
62
|
+
===
|
|
63
|
+
在命令行中执行以下命令可以在本机启动一个简易的 http server
|
|
64
|
+
```
|
|
65
|
+
npm run server
|
|
66
|
+
```
|
|
67
|
+
执行后一会提示 http server 的访问地址,一般情况下应该是 http://127.0.0.1:8080 。这时访问 http://127.0.0.1:8080/example/2_features_es6.html 即可在本地进行调试。
|
|
68
|
+
|
|
69
|
+
无论开发的是否是新的feature, 都建议把页面上所有的用例全部测试一遍。
|
|
70
|
+
|
|
71
|
+
需要提醒的是,调试过程中如果修改了 js 文件,请重新执行打包命令 `npm run build` 并刷新页面才能查看到新的效果。
|
|
72
|
+
|
|
73
|
+
版权声明
|
|
74
|
+
===
|
|
75
|
+
|
|
76
|
+
禁止转载、禁止演绎。
|
|
77
|
+
|
|
78
|
+
jsMind 项目仍在不断升级变化,版本更新时会同时更新对应的文档。为避免给使用者带来困惑,在没有得到书面许可前,禁止转载本文档,同时禁止对本文档进行任何形式的更改。
|
package/docs/zh/index.md
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license BSD-3-Clause
|
|
3
|
+
* @copyright 2014-2022 hizzgdev@163.com
|
|
4
|
+
*
|
|
5
|
+
* Project Home:
|
|
6
|
+
* https://github.com/hizzgdev/jsmind/
|
|
7
|
+
*/
|
|
8
|
+
!function(){"use strict";if(!jsMind)throw new Error("jsMind is not defined");const t=jsMind,e=t.$,i="getSelection"in e.w?function(){e.w.getSelection().removeAllRanges()}:function(){e.d.selection.empty()},s=5,a=500,o=80;class h{constructor(t){this.jm=t,this.e_canvas=null,this.canvas_ctx=null,this.shadow=null,this.shadow_w=0,this.shadow_h=0,this.active_node=null,this.target_node=null,this.target_direct=null,this.client_w=0,this.client_h=0,this.offset_x=0,this.offset_y=0,this.hlookup_delay=0,this.hlookup_timer=0,this.capture=!1,this.moved=!1,this.canvas_draggable=this.jm.get_view_draggable()}init(){this._create_canvas(),this._create_shadow(),this._event_bind()}resize(){this.jm.view.e_nodes.appendChild(this.shadow),this.e_canvas.width=this.jm.view.size.w,this.e_canvas.height=this.jm.view.size.h}_create_canvas(){var t=e.c("canvas");this.jm.view.e_panel.appendChild(t);var i=t.getContext("2d");this.e_canvas=t,this.canvas_ctx=i}_create_shadow(){var t=e.c("jmnode");t.style.visibility="hidden",t.style.zIndex="3",t.style.cursor="move",t.style.opacity="0.7",this.shadow=t}reset_shadow(t){var e=this.shadow.style;this.shadow.innerHTML=t.innerHTML,e.left=t.style.left,e.top=t.style.top,e.width=t.style.width,e.height=t.style.height,e.backgroundImage=t.style.backgroundImage,e.backgroundSize=t.style.backgroundSize,e.transform=t.style.transform,this.shadow_w=this.shadow.clientWidth,this.shadow_h=this.shadow.clientHeight}show_shadow(){this.moved||(this.shadow.style.visibility="visible")}hide_shadow(){this.shadow.style.visibility="hidden"}_magnet_shadow(t){t&&(this.canvas_ctx.lineWidth=s,this.canvas_ctx.strokeStyle="rgba(0,0,0,0.3)",this.canvas_ctx.lineCap="round",this._clear_lines(),this._canvas_lineto(t.sp.x,t.sp.y,t.np.x,t.np.y))}_clear_lines(){this.canvas_ctx.clearRect(0,0,this.jm.view.size.w,this.jm.view.size.h)}_canvas_lineto(t,e,i,s){this.canvas_ctx.beginPath(),this.canvas_ctx.moveTo(t,e),this.canvas_ctx.lineTo(i,s),this.canvas_ctx.stroke()}_lookup_close_node(){var t,e,i=this.jm.get_root(),a=i.get_location(),o=i.get_size(),h=a.x+o.w/2,n=this.shadow_w,l=this.shadow_h,d=this.shadow.offsetLeft,r=this.shadow.offsetTop,_=d+n/2>=h?jsMind.direction.right:jsMind.direction.left,c=this.jm.mind.nodes,v=null,u=this.jm.layout,w=Number.MAX_VALUE,g=0,m=null,f=null,p=null;for(var y in c){var j,b;if((v=c[y]).isroot||v.direction==_){if(v.id==this.active_node.id)continue;if(!u.is_visible(v))continue;if(t=v.get_size(),e=v.get_location(),_==jsMind.direction.right){if(d-e.x-t.w<=0)continue;g=Math.abs(d-e.x-t.w)+Math.abs(r+l/2-e.y-t.h/2),j={x:e.x+t.w-s,y:e.y+t.h/2},b={x:d+s,y:r+l/2}}else{if(e.x-d-n<=0)continue;g=Math.abs(d+n-e.x)+Math.abs(r+l/2-e.y-t.h/2),j={x:e.x+s,y:e.y+t.h/2},b={x:d+n-s,y:r+l/2}}g<w&&(m=v,f=j,p=b,w=g)}}var x=null;return m&&(x={node:m,direction:_,sp:p,np:f}),x}lookup_close_node(){var t=this._lookup_close_node();t&&(this._magnet_shadow(t),this.target_node=t.node,this.target_direct=t.direction)}_event_bind(){var t=this,i=this.jm.view.container;e.on(i,"mousedown",(function(e){var i=e||event;t.dragstart.call(t,i)})),e.on(i,"mousemove",(function(e){var i=e||event;t.drag.call(t,i)})),e.on(i,"mouseup",(function(e){var i=e||event;t.dragend.call(t,i)})),e.on(i,"touchstart",(function(e){var i=e||event;t.dragstart.call(t,i)})),e.on(i,"touchmove",(function(e){var i=e||event;t.drag.call(t,i)})),e.on(i,"touchend",(function(e){var i=e||event;t.dragend.call(t,i)}))}dragstart(t){if(this.jm.get_editable()&&!this.capture){this.active_node=null,this.view_draggable=this.jm.get_view_draggable();var i=this.jm.view,s=t.target||event.srcElement;if("jmnode"==s.tagName.toLowerCase()){this.view_draggable&&this.jm.disable_view_draggable();var h=i.get_binded_nodeid(s);if(h){var n=this.jm.get_node(h);if(!n.isroot){this.reset_shadow(s),this.active_node=n,this.offset_x=(t.clientX||t.touches[0].clientX)/i.actualZoom-s.offsetLeft,this.offset_y=(t.clientY||t.touches[0].clientY)/i.actualZoom-s.offsetTop,this.client_hw=Math.floor(s.clientWidth/2),this.client_hh=Math.floor(s.clientHeight/2),0!=this.hlookup_delay&&e.w.clearTimeout(this.hlookup_delay),0!=this.hlookup_timer&&e.w.clearInterval(this.hlookup_timer);var l=this;this.hlookup_delay=e.w.setTimeout((function(){l.hlookup_delay=0,l.hlookup_timer=e.w.setInterval((function(){l.lookup_close_node.call(l)}),o)}),a),this.capture=!0}}}}}drag(t){if(this.jm.get_editable()&&this.capture){t.preventDefault(),this.show_shadow(),this.moved=!0,i();var e=this.jm.view,s=(t.clientX||t.touches[0].clientX)/e.actualZoom-this.offset_x,a=(t.clientY||t.touches[0].clientY)/e.actualZoom-this.offset_y;this.shadow.style.left=s+"px",this.shadow.style.top=a+"px",i()}}dragend(t){if(this.jm.get_editable()){if(this.view_draggable&&this.jm.enable_view_draggable(),this.capture){if(0!=this.hlookup_delay&&(e.w.clearTimeout(this.hlookup_delay),this.hlookup_delay=0,this._clear_lines()),0!=this.hlookup_timer&&(e.w.clearInterval(this.hlookup_timer),this.hlookup_timer=0,this._clear_lines()),this.moved){var i=this.active_node,s=this.target_node,a=this.target_direct;this.move_node(i,s,a)}this.hide_shadow()}this.moved=!1,this.capture=!1}}move_node(t,e,i){var s=this.shadow.offsetTop;if(e&&t&&!jsMind.node.inherited(t,e)){for(var a=e.children,o=a.length,h=null,n=Number.MAX_VALUE,l=null,d="_last_";o--;)if((h=a[o]).direction==i&&h.id!=t.id){var r=h.get_location().y-s;r>0&&r<n&&(n=r,l=h,d="_first_")}l&&(d=l.id),this.jm.move_node(t.id,d,e.id,i)}this.active_node=null,this.target_node=null,this.target_direct=null}jm_event_handle(t,e){t===jsMind.event_type.resize&&this.resize()}}var n=new t.plugin("draggable_node",(function(t){var e=new h(t);e.init(),t.add_event_listener((function(t,i){e.jm_event_handle.call(e,t,i)}))}));jsMind.register_plugin(n)}();
|
|
9
|
+
//# sourceMappingURL=jsmind.draggable-node.js.map
|