jsmind 0.5.1 → 0.5.3

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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2022, ZHANG ZHIGANG <hizzgdev@163.com>
1
+ Copyright (c) 2014-2023, 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-2022, 张志刚 <hizzgdev@163.com>
14
+ 版权所有 (c) 2014-2023, 张志刚 <hizzgdev@163.com>
15
15
  保留一切权利。
16
16
 
17
17
  在满足下列条件的前提下,授予使用者使用及再发布本软件的源代码或二进制形式的权利,无论是否修改皆然:
package/README.md CHANGED
@@ -3,20 +3,32 @@
3
3
  [![npm version](https://badge.fury.io/js/jsmind.svg)](https://www.npmjs.com/package/jsmind)
4
4
  ![build-test](https://github.com/hizzgdev/jsmind/actions/workflows/node.js.yml/badge.svg)
5
5
 
6
- jsMind 是一个显示/编辑思维导图的纯 javascript 类库,其基于 html5 canvas (和 svg) 进行设计。jsMind 以 BSD 协议开源,在此基础上你可以在你的项目上任意使用。你可以在此浏览[适用于 jsMind 的许可协议][3]。
6
+ jsMind 是一个显示/编辑思维导图的纯 javascript 类库,其基于 html5 canvas (和 svg) 进行设计。jsMind 以 [BSD 协议开源](LICENSE),在此基础上你可以在你的项目上任意使用。
7
7
 
8
- jsMind is mind map library built by javascript, it base on html5 canvas and svg. jsMind is released under the BSD license, you can embed it in any project as long as you abide by the license. You can read [the license agreement for jsMind][3] here.
8
+ jsMind is mind map library built by javascript, it base on html5 canvas and svg. jsMind is released under [the BSD license](LICENSE), you can embed it in any project as long as you abide by the license.
9
+
10
+ ## Project Home
11
+
12
+ - [jsMind on Github](https://github.com/hizzgdev/jsmind)
13
+ - [国内镜像 - Gitee](https://gitee.com/hizzgdev/jsmind)
9
14
 
10
15
  ## Get Started
11
16
 
12
17
  ```html
13
18
  <html>
14
19
  <head>
15
- <link type="text/css" rel="stylesheet" href="style/jsmind.css" />
16
- <script type="text/javascript" src="js/jsmind.js"></script>
20
+ <link
21
+ type="text/css"
22
+ rel="stylesheet"
23
+ href="https://cdn.jsdelivr.net/npm/jsmind@0.5/style/jsmind.css"
24
+ />
25
+ <script
26
+ type="text/javascript"
27
+ src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.js"
28
+ ></script>
17
29
  <!--
18
30
  enable draggable node feature
19
- <script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
31
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.draggable-node.js"></script>
20
32
  -->
21
33
  </head>
22
34
  <body>
@@ -41,39 +53,35 @@ jsMind is mind map library built by javascript, it base on html5 canvas and svg.
41
53
 
42
54
  ## Links
43
55
 
44
- - Project Home :
45
- - on Github: <https://github.com/hizzgdev/jsmind>
46
- - on npm : <https://www.npmjs.com/package/jsmind>
56
+ - Resources:
57
+ - [NPM - jsmind](https://www.npmjs.com/package/jsmind)
58
+ - [CDN - jsDeliver](https://www.jsdelivr.com/package/npm/jsmind)
59
+ - [文档 - Documents](https://hizzgdev.github.io/jsmind/docs)
47
60
  - Apps :
48
61
  - <https://jsmind.online>
49
62
  - <https://jsmind.sinaapp.com>
50
63
  - Demo :
51
- - <http://hizzgdev.github.io/jsmind/example/1_basic.html>
52
- - <http://hizzgdev.github.io/jsmind/example/2_features.html>
53
- - ~~<http://hizzgdev.github.io/jsmind/example/3_mathjax.html>~~
54
- - Document :
55
- - [简体中文][1]
56
- - [English][2]
57
- - Wiki :
58
- - [邮件列表 Mailing List](../../wiki/MailingList)
59
- - [热点问题 Hot Topics](../../wiki/HotTopics)
60
- - Donate :
61
- - [Become a sponsor][4]
62
- - [资助本项目的开发][5]
64
+ - [显示一个脑图 Render a mindmap](https://hizzgdev.github.io/jsmind/example/1_basic.html)
65
+ - [试用所有功能 Features simple](https://hizzgdev.github.io/jsmind/example/2_features.html)
66
+ - [ES6 Version](https://hizzgdev.github.io/jsmind/example/2_features_es6.html)
63
67
 
64
68
  ## ES6 Pilot Version
65
69
 
66
- - 目前处于测试阶段,欢迎试用找 bug, ES6 代码位于 `/src`, 可运行于浏览器的 js 文件位于 `/es6`
67
- - Currently it's in the testing stage, welcome to trial and dig bugs, the ES6 code is located in `/src`, and the js files that can run in browsers are located in `/es6`
68
- - Demo: <http://hizzgdev.github.io/jsmind/example/2_features_es6.html>
70
+ - Launch Plan
71
+ - 将于 2023 年上半年正式启用
72
+ - Will be launched in 2023 H1
73
+ - NPM Pilot Version: `0.5.1`
74
+ - Code Location
75
+ - 源码位于 `/src`, 可运行于浏览器的 js 文件将生成于 `/es6`
76
+ - The source code is located in `/src`, and the js files that can run in browsers will be generated into `/es6`
77
+ - Demo: <https://hizzgdev.github.io/jsmind/example/2_features_es6.html>
69
78
 
70
- ## Maintainer
79
+ ## Donate
71
80
 
72
- - [张志刚 | Zhigang Zhang](https://hizzgdev.github.io)
73
- - hizzgdev@163.com
81
+ - [致谢 - Acknowledgement](https://hizzgdev.github.io/acknowledgement.html)
82
+ - [资助本项目](https://hizzgdev.github.io/sponsor.html)
83
+ - [Become a sponsor](https://github.com/sponsors/hizzgdev)
84
+
85
+ ## Maintainer
74
86
 
75
- [1]: docs/zh/index.md
76
- [2]: docs/en/index.md
77
- [3]: LICENSE
78
- [4]: https://github.com/sponsors/hizzgdev
79
- [5]: http://hizzgdev.github.io/sponsor.html
87
+ - [张志刚 - Zhigang Zhang](https://hizzgdev.github.io)
@@ -1,4 +1,4 @@
1
- [Contents](index.md)
1
+ [Table of Contents](index.md)
2
2
 
3
3
  1. [Usage *](1.usage.md)
4
4
  2. [Options](2.options.md)
@@ -9,17 +9,18 @@
9
9
  1.1. Basic Framework
10
10
  ===
11
11
 
12
- At first, 2 files (jsmind.css and jsmind.js) are required.
12
+ At first, 2 files (jsmind.css and jsmind.js) are required. Here we link to the resources on the CDN. It is recommended to use the latest version.
13
13
 
14
14
  ```html
15
- <link type="text/css" rel="stylesheet" href="style/jsmind.css" />
16
- <script type="text/javascript" src="js/jsmind.js"></script>
15
+ <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsmind@0.5/style/jsmind.css" />
16
+
17
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.js"></script>
17
18
  ```
18
19
 
19
- add script jsmind.draggable-node.js for enabling draggable node feature.
20
+ Add script jsmind.draggable-node.js for enabling draggable node feature.
20
21
 
21
22
  ```html
22
- <script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
23
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.draggable-node.js"></script>
23
24
  ```
24
25
 
25
26
  The second, a div element should be in your HTML as container
@@ -30,7 +31,7 @@ The second, a div element should be in your HTML as container
30
31
 
31
32
  The last, show an empty mindmap:
32
33
 
33
- ```javascript
34
+ ```html
34
35
  <script type="text/javascript">
35
36
  var options = { // for more detail at next chapter
36
37
  container:'jsmind_container', // [required] id of container
@@ -44,7 +45,7 @@ The last, show an empty mindmap:
44
45
 
45
46
  Or, show a mindmap with some topics:
46
47
 
47
- ```javascript
48
+ ```html
48
49
  <script type="text/javascript">
49
50
  var mind = { /* jsMind data, for more detail at next section */ };
50
51
  var options = {
@@ -1,4 +1,4 @@
1
- [Contents](index.md)
1
+ [Table of Contents](index.md)
2
2
 
3
3
  1. [Usage](1.usage.md)
4
4
  2. [Options *](2.options.md)
@@ -37,7 +37,8 @@ options = {
37
37
  line_width:2, // thickness of the mindmap line
38
38
  line_color:'#555', // Thought mindmap line color
39
39
  draggable: false, // Drag the mind map with your mouse, when it's larger that the container
40
- hide_scrollbars_when_draggable: false // Hide container scrollbars, when mind map is larger than container and draggable option is true.
40
+ hide_scrollbars_when_draggable: false, // Hide container scrollbars, when mind map is larger than container and draggable option is true.
41
+ node_overflow: 'hidden' // Text overflow style in node
41
42
  },
42
43
  layout:{
43
44
  hspace:30, // horizontal spacing between nodes
@@ -89,15 +90,10 @@ These options are described in more detail below.
89
90
 
90
91
  **mode** : (string) layout mode
91
92
 
92
- > When adding a first-level child node to the mind map, jsMind will decide which side to place the node based on this option. 2 layout modes are currently supported::
93
+ > When adding a first-level child node to the mind map, jsMind will decide which side to place the node based on this option. 2 layout modes are currently supported:
93
94
 
94
- > * full - child nodes are dynamically distributed on both sides of the root node [default]
95
- > * side - child nodes are distributed only to the right of the root node
96
-
97
- > 当往脑图里添加一级子节点时,jsMind 将根据此参数决定把节点放置在哪一侧。目前支持两种布局模式:
98
-
99
- > * full - 子节点动态分布在根节点两侧 [默认值]
100
- > * side - 子节点只分布在根节点右侧
95
+ > * `full` - child nodes are dynamically distributed on both sides of the root node [default]
96
+ > * `side` - child nodes are distributed only to the right of the root node
101
97
 
102
98
  > Note that this option only takes effect when adding nodes (`jsMind.add_node(...)`)
103
99
 
@@ -118,8 +114,8 @@ These options are described in more detail below.
118
114
 
119
115
  > jsMind now supports two line drawing engines:
120
116
 
121
- > * CANVAS - Draw the lines on the canvas [default]
122
- > * SVG - Using SVG to draw lines, when there are a lot of nodes and a huge area in the mind map, using this mode can bring significant performance improvements
117
+ > * `canvas` - Draw the lines on the canvas [default]
118
+ > * `svg` - Using SVG to draw lines, when there are a lot of nodes and a huge area in the mind map, using this mode can bring significant performance improvements
123
119
 
124
120
  **view.hmargin** : (number) Minimum horizontal distance (in pixels) of the mindmap from the container frame
125
121
  **view.vmargin** : (number) Minimum vertical distance (in pixels) of the mindmap from the outer container frame
@@ -141,6 +137,13 @@ These options are described in more detail below.
141
137
  > The default value of this parameter is false, as it keep the default behavior with vertical and horizontal scrollbars on the container when mind map is bigger than the container.
142
138
  > Otherwise, if true, there is no more scrollbars, and instead you can drag the mind map with your mouse, while button is down. It should be noted that in this case, the user will not be able to explore the mind map by rolling the mouse wheel.
143
139
 
140
+ **view.node_overflow** : (string) Text overflow style in node (since 0.5.3)
141
+
142
+ > 2 styles are currently supported when the node text is too long
143
+
144
+ > * `hidden` - Hide part of them to maintain the overall readability of the mind map [default]
145
+ > * `wrap` - Wrap the text to display the entire content
146
+
144
147
  **layout.hspace** : horizontal distance (pixels) between (number) nodes
145
148
  **layout.vspace** : vertical spacing (pixels) between (number) nodes
146
149
 
@@ -1,4 +1,4 @@
1
- [Contents](index.md)
1
+ [Table of Contents](index.md)
2
2
 
3
3
  1. [Usage](1.usage.md)
4
4
  2. [Options](2.options.md)
@@ -27,6 +27,25 @@ Method 2.
27
27
  var jm = jsMind.current;
28
28
  ```
29
29
 
30
+ Node object
31
+ ===
32
+
33
+ A mindmap diagram is composed of multiple nodes and connections between nodes, a mindmap diagram has a root node, the root node can have multiple child nodes on the periphery, and the child node can have multiple child nodes. Each node contains more than one of the following attributes.
34
+
35
+ ```javascript
36
+ node {
37
+ id, // : string node id
38
+ index, // : integer node number
39
+ topic, // : string node topic
40
+ isroot, // : boolean indicates whether this node is root or not
41
+ parent, // : node The parent of this node, the parent program of the root node is null, but please do not judge whether this node is the root node based on this property.
42
+ direction, // : enum(left,center,right) The distribution position of the node
43
+ children, // : array of node The combination of children of the node
44
+ expanded, // : boolean Is the next level of the node expanded or not
45
+ data, // : object{string: object} Other additional data for this node
46
+ }
47
+ ```
48
+
30
49
  3.1 Displaying a mindmap
31
50
  ===
32
51
 
@@ -47,25 +66,6 @@ Use the `jm.show(mind)` method to display a mindmap, see [1.1. Basic framework](
47
66
 
48
67
  **Fetching a collection of child nodes** : A collection of child nodes can be obtained using `node.children`.
49
68
 
50
- Tips
51
- ---
52
-
53
- A mindmap diagram is composed of multiple nodes and connections between nodes, a mindmap diagram has a root node, the root node can have multiple child nodes on the periphery, and the child node can have multiple child nodes. Each node contains more than one of the following attributes.
54
-
55
- ```javascript
56
- node {
57
- id, // : string node id
58
- index, // : integer node number
59
- topic, // : string node topic
60
- isroot, // : boolean indicates whether this node is root or not
61
- parent, // : node The parent of this node, the parent program of the root node is null, but please do not judge whether this node is the root node based on this property.
62
- direction, // : enum(left,center,right) The distribution position of the node
63
- children, // : array of node The combination of children of the node
64
- expanded, // : boolean Is the next level of the node expanded or not
65
- data, // : object{string,object} Other additional data for this node
66
- }
67
- ```
68
-
69
69
  3.3 Operation on Nodes
70
70
  ===
71
71
 
@@ -95,11 +95,11 @@ node {
95
95
  3.4. Editing Nodes
96
96
  ===
97
97
 
98
- **Add Node** : A node can be added using the `jm.add_node(parent_node, node_id, topic, data)` method.
98
+ **Add Node** : Use the `jm.add_node(parent_node, node_id, topic, data, direction)` method to add a sub node to the `parent_node`. `data` and `direction` are optional.
99
99
 
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
+ **Insert node before specified location** : Use the `jm.insert_node_before(node_before, node_id, topic, data, direction)` method to insert a node before the `node_before` node. `data` and `direction` are optional.
101
101
 
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
+ **Insert node after specified location** : Use the `jm.insert_node_after(node_after, node_id, topic, data, direction)` method to insert a node after the `node_after` node. `data` and `direction` are optional.
103
103
 
104
104
  **Delete Node** : Use the `jm.remove_node(node|node_id)` method to delete a specified node and all its children.
105
105
 
@@ -122,7 +122,7 @@ node {
122
122
 
123
123
  **Get metadata** : Use the `jm.get_meta()` method to get metadata for the current mindmap.
124
124
 
125
- **Get Data** : The `jm.get_data(data_format)` method is used to get the data text in the specified format of the current mindmap.
125
+ **Get Data** : Use the `jm.get_data(data_format)` method to get the data text in the specified format of the current mindmap.
126
126
 
127
127
  3.7 Other Operations
128
128
  ===
@@ -1,4 +1,4 @@
1
- [Contents](index.md)
1
+ [Table of Contents](index.md)
2
2
 
3
3
  1. [Usage](1.usage.md)
4
4
  2. [Options](2.options.md)
@@ -14,7 +14,7 @@ jsMind still has a lot of room for improvement and optimization. You are welcome
14
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.
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
+ * [Working with forks](https://help.github.com/en/articles/working-with-forks)
18
18
 
19
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.
20
20
 
@@ -1,4 +1,4 @@
1
- [Contents](index.md)
1
+ [Table of Contents](index.md)
2
2
 
3
3
  1. [Usage](1.usage.md)
4
4
  2. [Options](2.options.md)
package/docs/en/index.md CHANGED
@@ -1,4 +1,4 @@
1
- Contents.
1
+ Table of Contents
2
2
  ======
3
3
 
4
4
  * [1. Usage](1.usage.md)
package/docs/index.md ADDED
@@ -0,0 +1,17 @@
1
+ ## 中文
2
+
3
+ * [目录](zh/index.md)
4
+ * [1. 基本用法](zh/1.usage.md)
5
+ * [2. 选项](zh/2.options.md)
6
+ * [3. 界面操控](zh/3.operation.md)
7
+ * [4. 参与贡献](zh/4.contribution.md)
8
+ * [附:贡献代码指南](zh/5.development.md)
9
+
10
+ ## English
11
+
12
+ * [Table of Contents](en/index.md)
13
+ * [1. Usage](en/1.usage.md)
14
+ * [2. Options](en/2.options.md)
15
+ * [3. API / Operation](en/3.operation.md)
16
+ * [4. Contribution](en/4.contribution.md)
17
+ * [Attached: Development Guide](en/5.development.md)
@@ -9,17 +9,18 @@
9
9
  1.1. 基本框架
10
10
  ===
11
11
 
12
- 首先,需要在页面上引用 jsmind.js 和 jsmind.css 两个文件。
12
+ 首先,需要在页面上引用 jsmind.js 和 jsmind.css 两个文件,这里我们引用的是 CDN 上的资源,请注意使用最新的版本。
13
13
 
14
14
  ```html
15
- <link type="text/css" rel="stylesheet" href="style/jsmind.css" />
16
- <script type="text/javascript" src="js/jsmind.js"></script>
15
+ <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsmind@0.5/style/jsmind.css" />
16
+
17
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.js"></script>
17
18
  ```
18
19
 
19
20
  如果希望能够通过鼠标拖拽的方式移动节点,需要额外引用 jsmind.draggable-node.js 文件
20
21
 
21
22
  ```html
22
- <script type="text/javascript" src="js/jsmind.draggable-node.js"></script>
23
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsmind@0.5/es6/jsmind.draggable-node.js"></script>
23
24
  ```
24
25
 
25
26
  其次,要为 jsMind 准备一个容器,jsMind 将在这个容器里显示思维导图。可自行定义容器的id、大小及样式。
@@ -30,7 +31,7 @@
30
31
 
31
32
  最后,添加下面一段代码即可显示一个空白的思维导图:
32
33
 
33
- ```javascript
34
+ ```html
34
35
  <script type="text/javascript">
35
36
  var options = { // options 将在下一章中详细介绍
36
37
  container:'jsmind_container', // [必选] 容器的ID,或者为容器的对象
@@ -44,7 +45,7 @@
44
45
 
45
46
  或者,使用下面的代码显示一个包含既定内容的思维导图:
46
47
 
47
- ```javascript
48
+ ```html
48
49
  <script type="text/javascript">
49
50
  var mind = { /* jsMind 数据,详见下一节的说明 */ };
50
51
  var options = {
@@ -37,7 +37,8 @@ options = {
37
37
  line_width:2, // 思维导图线条的粗细
38
38
  line_color:'#555', // 思维导图线条的颜色
39
39
  draggable: false, // 当容器不能完全容纳思维导图时,是否允许拖动画布代替鼠标滚动
40
- hide_scrollbars_when_draggable: false // 当设置 draggable = true 时,是否隐藏滚动条
40
+ hide_scrollbars_when_draggable: false, // 当设置 draggable = true 时,是否隐藏滚动条
41
+ node_overflow: 'hidden' // 节点文本过长时的样式
41
42
  },
42
43
  layout:{
43
44
  hspace:30, // 节点之间的水平间距
@@ -89,8 +90,8 @@ options = {
89
90
 
90
91
  > 当往脑图里添加一级子节点时,jsMind 将根据此参数决定把节点放置在哪一侧。目前支持两种布局模式:
91
92
 
92
- > * full - 子节点动态分布在根节点两侧 [默认值]
93
- > * side - 子节点只分布在根节点右侧
93
+ > * `full` - 子节点动态分布在根节点两侧 [默认值]
94
+ > * `side` - 子节点只分布在根节点右侧
94
95
 
95
96
  > 需要注意的是,此参数只在添加节点时(`jsMind.add_node(...)`)生效。
96
97
 
@@ -111,8 +112,8 @@ options = {
111
112
 
112
113
  > jsMind 现支持两种线条的绘制引擎:
113
114
 
114
- > * canvas - 把线条绘制在 canvas 上 [默认值]
115
- > * svg - 使用 svg 绘制线条,当思维导图的节点很多,面积巨大的时候,使用该模式能带来显著的性能提升
115
+ > * `canvas` - 把线条绘制在 canvas 上 [默认值]
116
+ > * `svg` - 使用 svg 绘制线条,当思维导图的节点很多,面积巨大的时候,使用该模式能带来显著的性能提升
116
117
 
117
118
  **view.hmargin** : (number) 思维导图距容器外框的最小水平距离(像素)
118
119
  **view.vmargin** : (number) 思维导图距容器外框的最小垂直距离(像素)
@@ -133,6 +134,13 @@ options = {
133
134
  > 此参数仅当 `view.draggable` 为 true 时生效,其用于设置是否隐藏水平和垂直容器内的滚动条。
134
135
  > 此参数的默认值为 `false` (显示滚动条),当设置为 `true` 时,容器内的滚动条将会被隐藏,用户无法通过滚动鼠标滚轮的方式查看思维导图的不同部分。
135
136
 
137
+ **view.node_overflow** : (string) 节点文本过长时的样式 (0.5.3 及以上版本支持)
138
+
139
+ > 节点文本过长时,jsMind 支持两种样式:
140
+
141
+ > * `hidden` - 隐藏部分文本以保持脑图的整体易读性 [默认值]
142
+ > * `wrap` - 对文本进行换行,以展示全部文本内容
143
+
136
144
  **layout.hspace** : (number) 节点之间的水平间距(像素)
137
145
  **layout.vspace** : (number) 节点之间的垂直间距(像素)
138
146
 
@@ -26,6 +26,25 @@ var jm = new jsMind(options);
26
26
  var jm = jsMind.current;
27
27
  ```
28
28
 
29
+ 节点对象
30
+ ===
31
+
32
+ 思维导图是由多个节点和节点之间的连线组成的,一个思维导图有一个根节点,根节点外围可以有多个子节点,子节点还可以有多个子节点。每个节点包含以下的多个属性:
33
+
34
+ ```javascript
35
+ node {
36
+ id, // : string 节点id
37
+ index, // : integer 节点序号
38
+ topic, // : string 节点主题
39
+ isroot, // : boolean 指示该节点是否为根节点
40
+ parent, // : node 该节点的父节点,根节点的父节目为 null ,但请不要根据此属性判断该节点是否为根节点
41
+ direction, // : enum(left,center,right) 该节点的分布位置
42
+ children, // : array of node 该节点的子节点组合
43
+ expanded, // : boolean 该节点的下级节点是否展开
44
+ data, // : object{string: object} 该节点的其它附加数据
45
+ }
46
+ ```
47
+
29
48
  3.1. 显示思维导图
30
49
  ===
31
50
 
@@ -46,25 +65,6 @@ var jm = jsMind.current;
46
65
 
47
66
  **获取子节点集合** : 使用 `node.children` 即可获取子节点的集合。
48
67
 
49
- Tips
50
- ---
51
-
52
- 思维导图是由多个节点和节点之间的连线组成的,一个思维导图有一个根节点,根节点外围可以有多个子节点,子节点还可以有多个子节点。每个节点包含以下的多个属性:
53
-
54
- ```javascript
55
- node {
56
- id, // : string 节点id
57
- index, // : integer 节点序号
58
- topic, // : string 节点主题
59
- isroot, // : boolean 指示该节点是否为根节点
60
- parent, // : node 该节点的父节点,根节点的父节目为 null ,但请不要根据此属性判断该节点是否为根节点
61
- direction, // : enum(left,center,right) 该节点的分布位置
62
- children, // : array of node 该节点的子节点组合
63
- expanded, // : boolean 该节点的下级节点是否展开
64
- data, // : object{string,object} 该节点的其它附加数据
65
- }
66
- ```
67
-
68
68
  3.3. 操作节点
69
69
  ===
70
70
 
@@ -93,11 +93,11 @@ node {
93
93
  3.4. 编辑节点
94
94
  ===
95
95
 
96
- **添加节点** : 使用 `jm.add_node(parent_node, node_id, topic, data)` 方法可添加一个节点。
96
+ **添加节点** : 使用 `jm.add_node(parent_node, node_id, topic, data, direction)` 方法可为`parent_node`添加一个子节点。`data` 和 `direction` 为可选参数。
97
97
 
98
- **在指定位置前插入节点** : 使用 `jm.insert_node_before(node_before, node_id, topic, data)` 方法可在 node_before 节点前插入节点。
98
+ **在指定位置前插入节点** : 使用 `jm.insert_node_before(node_before, node_id, topic, data, direction)` 方法可在 `node_before` 节点前插入节点。`data` 和 `direction` 为可选参数。
99
99
 
100
- **在指定位置后插入节点** : 使用 `jm.insert_node_after(node_after, node_id, topic, data)` 方法可在 node_after 节点后插入节点。
100
+ **在指定位置后插入节点** : 使用 `jm.insert_node_after(node_after, node_id, topic, data, direction)` 方法可在 `node_after` 节点后插入节点。`data` 和 `direction` 为可选参数。
101
101
 
102
102
  **删除节点** : 使用 `jm.remove_node(node|node_id)` 方法可删除指定的节点及其所有的子节点。
103
103
 
@@ -26,19 +26,20 @@
26
26
 
27
27
  **Pull-Request 及 Fork** : 阅读 github 文档 [中文](https://docs.github.com/cn/pull-requests), [英文](https://docs.github.com/cn/pull-requests), 了解如何通过 fork 及 pull-request 提交你的代码。
28
28
 
29
- **Node.js** : 使用 jsMind 时是不需要在 Node.js 环境下的,但是在开发时,需要在 Node.js 环境下执行单元测试、代码格式化检查、及打包和压缩。对 Node.js 的版本没有强烈的要求,但是 CI 环境里使用的是 18.x 的版本,如果您提交 pull-request 后发现没有通过 CI 检测,请将你的 node 修改为 18.x 的版本。
29
+ **Node.js** : 项目中使用 jsMind 并不依赖 Node.js 环境,但是在开发时,我们需要在 Node.js 环境下执行单元测试、代码格式化检查、及打包和压缩。jsMind 的 CI 环境里使用的 Node 版本是 18.x。
30
30
 
31
- **Visual Studio Code** : 如果您使用的 IDE 是 VS Code, 建议您安装这个插件: `esbenp.prettier-vscode` 。这样的话在本项目里,你的 VS Code 将能自动按 jsMind 的配置对代码进行格式化
31
+ **Visual Studio Code** : 如果您使用的 IDE 是 VS Code, 建议您安装这个插件: `esbenp.prettier-vscode` 。这样你的 VS Code 将能自动按 jsMind 的配置对代码进行格式化
32
32
 
33
33
  5.3. 开发
34
34
  ===
35
35
 
36
- jsMind 使用 ES6 编写,代码在 `/src` 目录里,一般情况下只需要在此目录里开发即可。
36
+ jsMind 使用 ES6 编写,代码在 `/src` 目录里,一般情况下只需要改动此目录里的代码。
37
37
 
38
38
  开发过程中请记得随时格式化代码。在命令行中执行以下代码即可对代码进行格式化:
39
39
  ```
40
40
  npm run format
41
41
  ```
42
+
42
43
  5.4. 单元测试
43
44
  ===
44
45
 
@@ -64,9 +65,9 @@ npm run build
64
65
  ```
65
66
  npm run server
66
67
  ```
67
- 执行后一会提示 http server 的访问地址,一般情况下应该是 http://127.0.0.1:8080 。这时访问 http://127.0.0.1:8080/example/2_features_es6.html 即可在本地进行调试。
68
+ 执行后会提示 http server 的访问地址,一般情况下应该是 http://127.0.0.1:8080 。这时访问 http://127.0.0.1:8080/example/2_features_es6.html 即可在本地进行调试。
68
69
 
69
- 无论开发的是否是新的feature, 都建议把页面上所有的用例全部测试一遍。
70
+ 无论开发新功能还是修复bug, 都建议把页面上所有的用例全部测试一遍。
70
71
 
71
72
  需要提醒的是,调试过程中如果修改了 js 文件,请重新执行打包命令 `npm run build` 并刷新页面才能查看到新的效果。
72
73
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license BSD-3-Clause
3
- * @copyright 2014-2022 hizzgdev@163.com
3
+ * @copyright 2014-2023 hizzgdev@163.com
4
4
  *
5
5
  * Project Home:
6
6
  * https://github.com/hizzgdev/jsmind/