mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Doc: update
This commit is contained in:
parent
7c6b67e8fb
commit
3243e366b0
@ -306,4 +306,8 @@ const mindMap = new MindMap({
|
||||
<img src="./web/src/assets/avatar/default.png" style="width: 50px;height: 50px;" />
|
||||
<span>SR</span>
|
||||
</span>
|
||||
<span>
|
||||
<img src="./web/src/assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;" />
|
||||
<span>逆水行舟</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-mind-map",
|
||||
"version": "0.9.8",
|
||||
"version": "0.9.9",
|
||||
"description": "一个简单的web在线思维导图",
|
||||
"authors": [
|
||||
{
|
||||
|
||||
@ -92,13 +92,13 @@ function createIconNode() {
|
||||
}
|
||||
node.size(iconSize, iconSize)
|
||||
node.on('click', e => {
|
||||
this.mindMap.emit('node_icon_click', this, item, e)
|
||||
this.mindMap.emit('node_icon_click', this, item, e, node)
|
||||
})
|
||||
node.on('mouseenter', e => {
|
||||
this.mindMap.emit('node_icon_mouseenter', this, item, e)
|
||||
this.mindMap.emit('node_icon_mouseenter', this, item, e, node)
|
||||
})
|
||||
node.on('mouseleave', e => {
|
||||
this.mindMap.emit('node_icon_mouseleave', this, item, e)
|
||||
this.mindMap.emit('node_icon_mouseleave', this, item, e, node)
|
||||
})
|
||||
return {
|
||||
node,
|
||||
|
||||
BIN
web/src/assets/avatar/逆水行舟.jpg
Normal file
BIN
web/src/assets/avatar/逆水行舟.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
@ -11,7 +11,7 @@ let langList = [
|
||||
}
|
||||
]
|
||||
let StartList = ['introduction', 'start', 'deploy', 'client', 'translate', 'changelog']
|
||||
let CourseList = new Array(25).fill(0).map((_, index) => {
|
||||
let CourseList = new Array(26).fill(0).map((_, index) => {
|
||||
return 'course' + (index + 1)
|
||||
})
|
||||
let APIList = [
|
||||
@ -38,6 +38,7 @@ let APIList = [
|
||||
'scrollbar',
|
||||
'formula',
|
||||
'cooperate',
|
||||
'rainbowLines',
|
||||
'handDrawnLikeStyle',
|
||||
'xmind',
|
||||
'markdown',
|
||||
|
||||
@ -1,5 +1,35 @@
|
||||
# Changelog
|
||||
|
||||
## 0.9.9
|
||||
|
||||
New:
|
||||
|
||||
> 1.Support inserting child nodes with the insert key;
|
||||
>
|
||||
> 2.Add the beforeShortcutRun instantiation option to intercept shortcut key operations;
|
||||
>
|
||||
> 3.The method of incrementally updating canvas data by adding root instances, updateData;
|
||||
>
|
||||
> 4.Add a rainbow line plugin;
|
||||
>
|
||||
> 5.Add mouse in and out events to icons in nodes;
|
||||
>
|
||||
> 6.Add the getAncestorNodes method to the node instance to obtain the list of ancestor nodes;
|
||||
>
|
||||
> 7.Adding mouse events to personnel avatars during collaborative editing;
|
||||
|
||||
Demo:
|
||||
|
||||
> 1.Support configuration of rainbow lines;
|
||||
|
||||
Client:
|
||||
|
||||
> 1.Double click the file to open the application without opening the workbench page;
|
||||
>
|
||||
> 2.Fix the issue of multiple editing windows opening when repeatedly opening the same file;
|
||||
>
|
||||
> 3.Prompt for modifying and deleting files being edited;
|
||||
|
||||
## 0.9.8
|
||||
|
||||
Fix:
|
||||
|
||||
@ -1,6 +1,27 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Changelog</h1>
|
||||
<h2>0.9.9</h2>
|
||||
<p>New:</p>
|
||||
<blockquote>
|
||||
<p>1.Support inserting child nodes with the insert key;</p>
|
||||
<p>2.Add the beforeShortcutRun instantiation option to intercept shortcut key operations;</p>
|
||||
<p>3.The method of incrementally updating canvas data by adding root instances, updateData;</p>
|
||||
<p>4.Add a rainbow line plugin;</p>
|
||||
<p>5.Add mouse in and out events to icons in nodes;</p>
|
||||
<p>6.Add the getAncestorNodes method to the node instance to obtain the list of ancestor nodes;</p>
|
||||
<p>7.Adding mouse events to personnel avatars during collaborative editing;</p>
|
||||
</blockquote>
|
||||
<p>Demo:</p>
|
||||
<blockquote>
|
||||
<p>1.Support configuration of rainbow lines;</p>
|
||||
</blockquote>
|
||||
<p>Client:</p>
|
||||
<blockquote>
|
||||
<p>1.Double click the file to open the application without opening the workbench page;</p>
|
||||
<p>2.Fix the issue of multiple editing windows opening when repeatedly opening the same file;</p>
|
||||
<p>3.Prompt for modifying and deleting files being edited;</p>
|
||||
</blockquote>
|
||||
<h2>0.9.8</h2>
|
||||
<p>Fix:</p>
|
||||
<blockquote>
|
||||
|
||||
@ -114,6 +114,8 @@ const mindMap = new MindMap({
|
||||
| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | Is it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for | |
|
||||
| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | During collaborative editing, the same node cannot be selected by multiple people at the same time | |
|
||||
| beforeCooperateUpdate(v0.9.8+) | Function、null | null | During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 } | |
|
||||
| beforeShortcutRun(v0.9.9+) | Function、null | null | The lifecycle function before the shortcut operation is about to be executed, returning true can prevent the operation from executing. The function takes two parameters: key(Shortcut key)、activeNodeList(List of currently activated nodes) |
|
||||
| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 } |
|
||||
|
||||
### Data structure
|
||||
|
||||
@ -314,6 +316,12 @@ Current Theme Configuration.
|
||||
|
||||
## Instance methods
|
||||
|
||||
### updateData(data)
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
Update canvas data. If the new data is formed by adding, deleting, modifying, and querying based on the current canvas node data, this method can be used to update the canvas data. The performance will be better, and not all nodes will be recreated, but rather reused as much as possible.
|
||||
|
||||
### clearDraw()
|
||||
|
||||
> v0.8.0+
|
||||
@ -419,7 +427,9 @@ Listen to an event. Event list:
|
||||
| associative_line_click(v0.4.5+) | Triggered when an associated line is clicked | path(Connector node)、clickPath(Invisible click line node)、node(Start node)、toNode(Target node) |
|
||||
| svg_mouseenter(v0.5.1+) | Triggered when the mouse moves into the SVG canvas | e(event object) |
|
||||
| svg_mouseleave(v0.5.1+) | Triggered when the mouse moves out of the SVG canvas | e(event object) |
|
||||
| node_icon_click(v0.6.10+) | Triggered when clicking on an icon within a node | this(node instance)、item(Click on the icon name)、e(event object) |
|
||||
| node_icon_click(v0.6.10+) | Triggered when clicking on an icon within a node | this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node, v0.9.9+) |
|
||||
| node_icon_mouseenter(v0.9.9+) | Triggered when the mouse moves into an icon within a node | this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node) |
|
||||
| node_icon_mouseleave(v0.9.9+) | Triggered when the mouse moves out of the icon within the node | this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node) |
|
||||
| view_theme_change(v0.6.12+) | Triggered after calling the setTheme method to set the theme | theme(theme name) |
|
||||
| set_data(v0.7.3+) | Triggered when the setData method is called to dynamically set mind map data | data(New Mind Map Data) |
|
||||
| resize(v0.8.0+) | Triggered after the container size changes, actually when the 'resize' method of the mind map instance is called | |
|
||||
@ -428,6 +438,9 @@ Listen to an event. Event list:
|
||||
| body_click | Click event of document.body | e(event object) |
|
||||
| data_change_detail(v0.9.3+) | The detailed changes in rendering tree data will return an array, with each item representing an update point and each item being an object, There is a 'type' attribute that represents the type of detail, Including 'create' (create node), 'update' (update node), 'delete' (delete node), There is a 'data' attribute that represents the current updated node data. If it is of the 'update' type, there will also be an 'oldData' attribute that saves the data of the node before the update | arr(Detail data) |
|
||||
| layout_change(v0.9.4+) | Triggered when modifying the structure, i.e. when the mindMap.setLayout() method is called | layout(New layout) |
|
||||
| node_cooperate_avatar_click(v0.9.9+) | Triggered when the mouse clicks on a person's avatar during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
|
||||
| node_cooperate_avatar_mouseenter(v0.9.9+) | Triggered when the mouse moves over a person's avatar during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
|
||||
| node_cooperate_avatar_mouseleave(v0.9.9+) | Triggered when removing personnel avatars with the mouse during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
|
||||
|
||||
### emit(event, ...args)
|
||||
|
||||
|
||||
@ -658,6 +658,20 @@
|
||||
<td>During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 }</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>beforeShortcutRun(v0.9.9+)</td>
|
||||
<td>Function、null</td>
|
||||
<td>null</td>
|
||||
<td>The lifecycle function before the shortcut operation is about to be executed, returning true can prevent the operation from executing. The function takes two parameters: key(Shortcut key)、activeNodeList(List of currently activated nodes)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>rainbowLinesConfig(v0.9.9+)</td>
|
||||
<td>Object</td>
|
||||
<td>{ open: false, colorsList: [] }</td>
|
||||
<td>Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 }</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Data structure</h3>
|
||||
@ -872,6 +886,11 @@ mindMap.setTheme(<span class="hljs-string">'Theme name'</span>)
|
||||
<h3>themeConfig</h3>
|
||||
<p>Current Theme Configuration.</p>
|
||||
<h2>Instance methods</h2>
|
||||
<h3>updateData(data)</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>Update canvas data. If the new data is formed by adding, deleting, modifying, and querying based on the current canvas node data, this method can be used to update the canvas data. The performance will be better, and not all nodes will be recreated, but rather reused as much as possible.</p>
|
||||
<h3>clearDraw()</h3>
|
||||
<blockquote>
|
||||
<p>v0.8.0+</p>
|
||||
@ -1119,7 +1138,17 @@ poor performance and should be used sparingly.</p>
|
||||
<tr>
|
||||
<td>node_icon_click(v0.6.10+)</td>
|
||||
<td>Triggered when clicking on an icon within a node</td>
|
||||
<td>this(node instance)、item(Click on the icon name)、e(event object)</td>
|
||||
<td>this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node, v0.9.9+)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_icon_mouseenter(v0.9.9+)</td>
|
||||
<td>Triggered when the mouse moves into an icon within a node</td>
|
||||
<td>this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_icon_mouseleave(v0.9.9+)</td>
|
||||
<td>Triggered when the mouse moves out of the icon within the node</td>
|
||||
<td>this(node instance)、item(Click on the icon name)、e(event object)、node(Icon node)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>view_theme_change(v0.6.12+)</td>
|
||||
@ -1161,6 +1190,21 @@ poor performance and should be used sparingly.</p>
|
||||
<td>Triggered when modifying the structure, i.e. when the mindMap.setLayout() method is called</td>
|
||||
<td>layout(New layout)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_click(v0.9.9+)</td>
|
||||
<td>Triggered when the mouse clicks on a person's avatar during collaborative editing</td>
|
||||
<td>userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_mouseenter(v0.9.9+)</td>
|
||||
<td>Triggered when the mouse moves over a person's avatar during collaborative editing</td>
|
||||
<td>userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_mouseleave(v0.9.9+)</td>
|
||||
<td>Triggered when removing personnel avatars with the mouse during collaborative editing</td>
|
||||
<td>userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>emit(event, ...args)</h3>
|
||||
|
||||
@ -339,4 +339,8 @@ Open source is not easy. If this project is helpful to you, you can invite the a
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>SR</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>逆水行舟</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -293,6 +293,10 @@ full screen, support mini map</li>
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>SR</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>逆水行舟</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -56,6 +56,12 @@ Whether the node is currently being dragged
|
||||
|
||||
## Methods
|
||||
|
||||
### getAncestorNodes()
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
Obtain a list of ancestor node instances.
|
||||
|
||||
### highlight()
|
||||
|
||||
> v0.9.8+
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
</blockquote>
|
||||
<p>Whether the node is currently being dragged</p>
|
||||
<h2>Methods</h2>
|
||||
<h3>getAncestorNodes()</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>Obtain a list of ancestor node instances.</p>
|
||||
<h3>highlight()</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.8+</p>
|
||||
|
||||
56
web/src/pages/Doc/en/rainbowLines/index.md
Normal file
56
web/src/pages/Doc/en/rainbowLines/index.md
Normal file
@ -0,0 +1,56 @@
|
||||
# RainbowLines plugin
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
This plugin is used to implement rainbow lines.
|
||||
|
||||
Enabling rainbow lines and custom colors can be set through the instantiation option 'rainbowLinesConfig'.
|
||||
|
||||
The default color list is as follows:
|
||||
|
||||
```
|
||||
[
|
||||
'rgb(255, 213, 73)',
|
||||
'rgb(255, 136, 126)',
|
||||
'rgb(107, 225, 141)',
|
||||
'rgb(151, 171, 255)',
|
||||
'rgb(129, 220, 242)',
|
||||
'rgb(255, 163, 125)',
|
||||
'rgb(152, 132, 234)'
|
||||
]
|
||||
```
|
||||
|
||||
## Register
|
||||
|
||||
```js
|
||||
import MindMap from 'simple-mind-map'
|
||||
import RainbowLines from 'simple-mind-map/src/plugins/RainbowLines.js'
|
||||
MindMap.usePlugin(RainbowLines)
|
||||
```
|
||||
|
||||
After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.rainbowLines`.
|
||||
|
||||
## Method
|
||||
|
||||
### updateRainLinesConfig(config = {})
|
||||
|
||||
If you want to modify the rainbow lines after setting them through the instantiation option 'rainbowLinesConfig', you can use this method, option `config` is same with `rainbowLinesConfig`。
|
||||
|
||||
```js
|
||||
{
|
||||
open: false,// Is turn on rainbow lines
|
||||
colorsList: []// Customize the color list for rainbow lines. If not set, the default color list will be used
|
||||
}
|
||||
```
|
||||
|
||||
### getColorsList()
|
||||
|
||||
Get a list of currently used rainbow line colors.
|
||||
|
||||
### getNodeColor(node)
|
||||
|
||||
Retrieve the rainbow line color corresponding to the specified node instance.
|
||||
|
||||
### getSecondLayerAncestor(node)
|
||||
|
||||
Retrieve the second level ancestor node instance of a node instance.
|
||||
52
web/src/pages/Doc/en/rainbowLines/index.vue
Normal file
52
web/src/pages/Doc/en/rainbowLines/index.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>RainbowLines plugin</h1>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>This plugin is used to implement rainbow lines.</p>
|
||||
<p>Enabling rainbow lines and custom colors can be set through the instantiation option 'rainbowLinesConfig'.</p>
|
||||
<p>The default color list is as follows:</p>
|
||||
<pre class="hljs"><code>[
|
||||
'rgb(255, 213, 73)',
|
||||
'rgb(255, 136, 126)',
|
||||
'rgb(107, 225, 141)',
|
||||
'rgb(151, 171, 255)',
|
||||
'rgb(129, 220, 242)',
|
||||
'rgb(255, 163, 125)',
|
||||
'rgb(152, 132, 234)'
|
||||
]
|
||||
</code></pre>
|
||||
<h2>Register</h2>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">'simple-mind-map'</span>
|
||||
<span class="hljs-keyword">import</span> RainbowLines <span class="hljs-keyword">from</span> <span class="hljs-string">'simple-mind-map/src/plugins/RainbowLines.js'</span>
|
||||
MindMap.usePlugin(RainbowLines)
|
||||
</code></pre>
|
||||
<p>After registration and instantiation of <code>MindMap</code>, the instance can be obtained through <code>mindMap.rainbowLines</code>.</p>
|
||||
<h2>Method</h2>
|
||||
<h3>updateRainLinesConfig(config = {})</h3>
|
||||
<p>If you want to modify the rainbow lines after setting them through the instantiation option 'rainbowLinesConfig', you can use this method, option <code>config</code> is same with <code>rainbowLinesConfig</code>。</p>
|
||||
<pre class="hljs"><code>{
|
||||
<span class="hljs-attr">open</span>: <span class="hljs-literal">false</span>,<span class="hljs-comment">// Is turn on rainbow lines</span>
|
||||
<span class="hljs-attr">colorsList</span>: []<span class="hljs-comment">// Customize the color list for rainbow lines. If not set, the default color list will be used</span>
|
||||
}
|
||||
</code></pre>
|
||||
<h3>getColorsList()</h3>
|
||||
<p>Get a list of currently used rainbow line colors.</p>
|
||||
<h3>getNodeColor(node)</h3>
|
||||
<p>Retrieve the rainbow line color corresponding to the specified node instance.</p>
|
||||
<h3>getSecondLayerAncestor(node)</h3>
|
||||
<p>Retrieve the second level ancestor node instance of a node instance.</p>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@ -32,6 +32,7 @@ export default [
|
||||
{ path: 'course23', title: '如何渲染滚动条' },
|
||||
{ path: 'course24', title: '如何开发一个插件' },
|
||||
{ path: 'course25', title: '关于概要' },
|
||||
{ path: 'course26', title: '如何实现AI生成节点内容' },
|
||||
{ path: 'doExport', title: 'Export 插件' },
|
||||
{ path: 'drag', title: 'Drag插件' },
|
||||
{ path: 'introduction', title: '简介' },
|
||||
@ -60,6 +61,7 @@ export default [
|
||||
{ path: 'scrollbar', title: 'Scrollbar插件' },
|
||||
{ path: 'formula', title: 'Formula插件' },
|
||||
{ path: 'cooperate', title: 'Cooperate插件' },
|
||||
{ path: 'rainbowLines', title: 'RainbowLines插件' },
|
||||
{ path: 'handDrawnLikeStyle', title: 'HandDrawnLikeStyle收费插件' },
|
||||
{ path: 'help1', title: '概要/关联线' },
|
||||
{ path: 'help2', title: '客户端' },
|
||||
@ -102,6 +104,7 @@ export default [
|
||||
{ path: 'scrollbar', title: 'Scrollbar plugin' },
|
||||
{ path: 'formula', title: 'Formula plugin' },
|
||||
{ path: 'cooperate', title: 'Cooperate plugin' },
|
||||
{ path: 'rainbowLines', title: 'RainbowLines plugin' },
|
||||
{ path: 'handDrawnLikeStyle', title: 'HandDrawnLikeStyle chargeable plugin' },
|
||||
{ path: 'client', title: 'Client' }
|
||||
]
|
||||
|
||||
@ -1,5 +1,35 @@
|
||||
# Changelog
|
||||
|
||||
## 0.9.9
|
||||
|
||||
新增:
|
||||
|
||||
> 1.支持insert键插入下级节点;
|
||||
>
|
||||
> 2.增加beforeShortcutRun实例化选项用于拦截快捷键操作;
|
||||
>
|
||||
> 3.根实例增加增量更新画布数据的方法updateData;
|
||||
>
|
||||
> 4.新增彩虹线条插件;
|
||||
>
|
||||
> 5.节点中的图标添加鼠标移入和移出事件;
|
||||
>
|
||||
> 6.节点实例新增getAncestorNodes方法用于获取祖先节点列表;
|
||||
>
|
||||
> 7.协同编辑时的人员头像增加鼠标事件;
|
||||
|
||||
Demo:
|
||||
|
||||
> 1.支持配置彩虹线条;
|
||||
|
||||
客户端:
|
||||
|
||||
> 1.双击文件打开应用时不打开工作台页面;
|
||||
>
|
||||
> 2.修复重复打开同一个文件会打开多个编辑窗口的问题;
|
||||
>
|
||||
> 3.修改删除正在编辑的文件的提示;
|
||||
|
||||
## 0.9.8
|
||||
|
||||
修复:
|
||||
|
||||
@ -1,6 +1,27 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Changelog</h1>
|
||||
<h2>0.9.9</h2>
|
||||
<p>新增:</p>
|
||||
<blockquote>
|
||||
<p>1.支持insert键插入下级节点;</p>
|
||||
<p>2.增加beforeShortcutRun实例化选项用于拦截快捷键操作;</p>
|
||||
<p>3.根实例增加增量更新画布数据的方法updateData;</p>
|
||||
<p>4.新增彩虹线条插件;</p>
|
||||
<p>5.节点中的图标添加鼠标移入和移出事件;</p>
|
||||
<p>6.节点实例新增getAncestorNodes方法用于获取祖先节点列表;</p>
|
||||
<p>7.协同编辑时的人员头像增加鼠标事件;</p>
|
||||
</blockquote>
|
||||
<p>Demo:</p>
|
||||
<blockquote>
|
||||
<p>1.支持配置彩虹线条;</p>
|
||||
</blockquote>
|
||||
<p>客户端:</p>
|
||||
<blockquote>
|
||||
<p>1.双击文件打开应用时不打开工作台页面;</p>
|
||||
<p>2.修复重复打开同一个文件会打开多个编辑窗口的问题;</p>
|
||||
<p>3.修改删除正在编辑的文件的提示;</p>
|
||||
</blockquote>
|
||||
<h2>0.9.8</h2>
|
||||
<p>修复:</p>
|
||||
<blockquote>
|
||||
|
||||
@ -113,6 +113,9 @@ const mindMap = new MindMap({
|
||||
| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 |
|
||||
| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | 协同编辑时,同一个节点不能同时被多人选中 |
|
||||
| beforeCooperateUpdate(v0.9.8+) | Function、null | null | 协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 } |
|
||||
| beforeShortcutRun(v0.9.9+) | Function、null | null | 快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行。函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表) |
|
||||
| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | 彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 } |
|
||||
|
||||
|
||||
### 数据结构
|
||||
|
||||
@ -313,6 +316,12 @@ mindMap.setTheme('主题名称')
|
||||
|
||||
## 实例方法
|
||||
|
||||
### updateData(data)
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
更新画布数据,如果新的数据是在当前画布节点数据基础上增删改查后形成的,那么可以使用该方法来更新画布数据。性能会更好,不会重新创建所有节点,而是会尽可能的复用。
|
||||
|
||||
### clearDraw()
|
||||
|
||||
> v0.8.0+
|
||||
@ -415,7 +424,9 @@ mindMap.setTheme('主题名称')
|
||||
| associative_line_click(v0.4.5+) | 点击某条关联线时触发 | path(连接线节点)、clickPath(不可见的点击线节点)、node(起始节点)、toNode(目标节点) |
|
||||
| svg_mouseenter(v0.5.1+) | 鼠标移入svg画布时触发 | e(事件对象) |
|
||||
| svg_mouseleave(v0.5.1+) | 鼠标移出svg画布时触发 | e(事件对象) |
|
||||
| node_icon_click(v0.6.10+) | 点击节点内的图标时触发 | this(节点实例)、item(点击的图标名称)、e(事件对象) |
|
||||
| node_icon_click(v0.6.10+) | 点击节点内的图标时触发 | this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点,v0.9.9+) |
|
||||
| node_icon_mouseenter(v0.9.9+) | 鼠标移入节点内的图标时触发 | this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点) |
|
||||
| node_icon_mouseleave(v0.9.9+) | 鼠标移出节点内的图标时触发 | this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点) |
|
||||
| view_theme_change(v0.6.12+) | 调用了setTheme方法设置主题后触发 | theme(设置的新主题名称) |
|
||||
| set_data(v0.7.3+) | 调用了setData方法动态设置思维导图数据时触发 | data(新的思维导图数据) |
|
||||
| resize(v0.8.0+) | 容器尺寸改变后触发,实际上是当思维导图实例的`resize`方法被调用后触发 | |
|
||||
@ -424,6 +435,9 @@ mindMap.setTheme('主题名称')
|
||||
| body_click | document.body的点击事件 | e(事件对象) |
|
||||
| data_change_detail(v0.9.3+) | 渲染树数据变化的明细,会返回一个数组,每一项代表一个更新点,每一项都是一个对象,存在一个`type`属性,代表明细的类型,包含`create`(创建节点)、`update`(更新节点)、`delete`(删除节点),存在一个`data`属性,代表当前更新的节点数据,如果是`update`类型,还会存在一个`oldData`属性,保存了更新前该节点的数据 | arr(明细数据) |
|
||||
| layout_change(v0.9.4+) | 修改结构时触发,即调用了mindMap.setLayout()方法时触发 | layout(新的结构) |
|
||||
| node_cooperate_avatar_click(v0.9.9+) | 协同编辑时,鼠标点击人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
|
||||
| node_cooperate_avatar_mouseenter(v0.9.9+) | 协同编辑时,鼠标移入人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
|
||||
| node_cooperate_avatar_mouseleave(v0.9.9+) | 协同编辑时,鼠标移除人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
|
||||
|
||||
### emit(event, ...args)
|
||||
|
||||
|
||||
@ -561,6 +561,18 @@
|
||||
<td>null</td>
|
||||
<td>协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 }</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>beforeShortcutRun(v0.9.9+)</td>
|
||||
<td>Function、null</td>
|
||||
<td>null</td>
|
||||
<td>快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行。函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>rainbowLinesConfig(v0.9.9+)</td>
|
||||
<td>Object</td>
|
||||
<td>{ open: false, colorsList: [] }</td>
|
||||
<td>彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 }</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>数据结构</h3>
|
||||
@ -775,6 +787,11 @@ mindMap.setTheme(<span class="hljs-string">'主题名称'</span>)
|
||||
<h3>themeConfig</h3>
|
||||
<p>当前主题配置。</p>
|
||||
<h2>实例方法</h2>
|
||||
<h3>updateData(data)</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>更新画布数据,如果新的数据是在当前画布节点数据基础上增删改查后形成的,那么可以使用该方法来更新画布数据。性能会更好,不会重新创建所有节点,而是会尽可能的复用。</p>
|
||||
<h3>clearDraw()</h3>
|
||||
<blockquote>
|
||||
<p>v0.8.0+</p>
|
||||
@ -1015,7 +1032,17 @@ mindMap.setTheme(<span class="hljs-string">'主题名称'</span>)
|
||||
<tr>
|
||||
<td>node_icon_click(v0.6.10+)</td>
|
||||
<td>点击节点内的图标时触发</td>
|
||||
<td>this(节点实例)、item(点击的图标名称)、e(事件对象)</td>
|
||||
<td>this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点,v0.9.9+)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_icon_mouseenter(v0.9.9+)</td>
|
||||
<td>鼠标移入节点内的图标时触发</td>
|
||||
<td>this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_icon_mouseleave(v0.9.9+)</td>
|
||||
<td>鼠标移出节点内的图标时触发</td>
|
||||
<td>this(节点实例)、item(点击的图标名称)、e(事件对象)、node(图标节点)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>view_theme_change(v0.6.12+)</td>
|
||||
@ -1057,6 +1084,21 @@ mindMap.setTheme(<span class="hljs-string">'主题名称'</span>)
|
||||
<td>修改结构时触发,即调用了mindMap.setLayout()方法时触发</td>
|
||||
<td>layout(新的结构)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_click(v0.9.9+)</td>
|
||||
<td>协同编辑时,鼠标点击人员头像时触发</td>
|
||||
<td>userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_mouseenter(v0.9.9+)</td>
|
||||
<td>协同编辑时,鼠标移入人员头像时触发</td>
|
||||
<td>userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>node_cooperate_avatar_mouseleave(v0.9.9+)</td>
|
||||
<td>协同编辑时,鼠标移除人员头像时触发</td>
|
||||
<td>userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>emit(event, ...args)</h3>
|
||||
|
||||
255
web/src/pages/Doc/zh/course26/index.md
Normal file
255
web/src/pages/Doc/zh/course26/index.md
Normal file
@ -0,0 +1,255 @@
|
||||
# 如何实现AI生成节点内容
|
||||
|
||||
目前AI能力非常流行,每个应用都给自己加上了AI的能力提高竞争力,那么在使用了`simple-mind-map`的情况下如何添加AI的能力呢,本教程会详细的教你如何实现。
|
||||
|
||||
首先要说明的是本教程并不会真的实现一个可用的AI能力,只是在假设你要实现该功能的前提下来教你如何调用对应的API来实现你想要的效果。
|
||||
|
||||
其次AI返回的数据结构不尽相同,你都需要自行转换成`simple-mind-map`的结构类型。
|
||||
|
||||
## 自动生成整个思维导图
|
||||
|
||||
### 一次生成
|
||||
|
||||
通过AI生成整个思维导图并且一次直接生成,这个其实就是普通的回显功能,那么你可以在实例化时通过`data`传入生成的数据:
|
||||
|
||||
```js
|
||||
const mindMap = new MindMap({
|
||||
el,
|
||||
data: {
|
||||
data: {
|
||||
text: '我是自动生成的节点'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: {
|
||||
text: '子节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
也可以在实例化之后使用`setData`方法设置:
|
||||
|
||||
```js
|
||||
mindMap.setData({
|
||||
data: {
|
||||
text: '我是自动生成的节点'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: {
|
||||
text: '子节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
### 依次生成节点
|
||||
|
||||
如果你想像ChatGPT一样依次生成节点,那么推荐使用`updateData`方法增量更新节点数据,而不是手动获取到之前插入的节点实例,再调用命令来插入下级节点,这样会复杂很多,当然,如果你能轻松的知道当前创建到哪里了,并且下一个节点在哪个节点下创建,可以忽略。
|
||||
|
||||
> updateData方法是v0.9.9+的方法,之前的版本可以使用下面的方法:
|
||||
|
||||
```js
|
||||
const updateData = (data) => {
|
||||
mindMap.renderer.setData(data)
|
||||
mindMap.render()
|
||||
mindMap.command.addHistory()
|
||||
}
|
||||
```
|
||||
|
||||
增量更新的前提是之前生成的节点都存在`uid`,并且不会变化,这样调用`updateData`方法渲染时会根据`uid`来复用之前的节点,只创建新的节点,达到依次生成的目的。
|
||||
|
||||
比如第一次返回的数据:
|
||||
|
||||
```js
|
||||
const data = {
|
||||
data: {
|
||||
text: '根节点',
|
||||
uid: '1'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
|
||||
mindMap.setData(data)
|
||||
```
|
||||
|
||||
第二次返回的数据:
|
||||
|
||||
```js
|
||||
const data = {
|
||||
data: {
|
||||
text: '根节点',
|
||||
uid: '1'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: {
|
||||
text: '二级节点',
|
||||
uid: '2'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
mindMap.updateData(data)
|
||||
```
|
||||
|
||||
以此类推,这样虽然是整个数据更新,但是因为复用的原因画布呈现的是依次生成新节点的效果。
|
||||
|
||||
当生成的节点多了会有个问题,就是新生成的节点在画布外看不见了,所以我们要将新生成的节点移动到画布中心,首先可以监听`data_change_detail`事件来获取到详细的更新数据,找出其中新创建的节点数据,然后使用`findNodeByUid`方法找出对应的节点实例,最后调用`moveNodeToCenter`方法将该节点移动到画布中心即可。
|
||||
|
||||
```js
|
||||
mindMap.on('data_change_detail', (list) => {
|
||||
// 找出新创建节点中的最后一个
|
||||
const lastCreate = list.filter((item) => {
|
||||
return item.action === 'create'
|
||||
})[0]
|
||||
if (lastCreate) {
|
||||
const uid = lastCreate.data.data.uid
|
||||
const node = mindMap.renderer.findNodeByUid(uid)
|
||||
if (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
当节点数据多了,可能`data_change_detail`事件触发时节点树还没渲染完毕,导致获取不到节点,解决这个问题可以通过监听`node_tree_render_end`事件:
|
||||
|
||||
```js
|
||||
let waitUid = ''
|
||||
mindMap.on('data_change_detail', (list) => {
|
||||
// ...
|
||||
if (lastCreate) {
|
||||
// ...
|
||||
if (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
} else {
|
||||
waitUid = uid
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mindMap.on('node_tree_render_end', () =>{
|
||||
if (waitUid) {
|
||||
waitUid = ''
|
||||
const node = mindMap.renderer.findNodeByUid(waitUid)
|
||||
if (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
当在`data_change_detail`事件中没有获取到节点实例就将该`uid`保存起来,然后在`node_tree_render_end`事件里判断是否有保存的`uid`,是的话就获取该节点实例并移动到画布中心。
|
||||
|
||||
最后,当自动生成节点中最好禁止用户操作,否则可能会产生异常。
|
||||
|
||||
### 完整示例
|
||||
|
||||
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rHDcQ/ypiS9m95rx3bvN0vTOJnUILdVtC+uQNZr2ru1OqlZZdrc+HOQih0DT0IYUWSkto+9QSWvKSByct+TT2XT5GR7uS9t/ZxNBAoTHYXmlmfvObGWkkHVvX49g9zLA1sIZpkJBYoBSLLN7yGIlingh0jBI87iLOdnnGBA67KJ36lPLZTTxGCzROeIRsQLCNxS5h4a4fFyLPSmGa4o0IZjciP/YsjyHkMYoFknNSc4RYRqnHPBZwlgpwFuCdBPsCX6cUpE4HjbbQsTRUJi6wvOEL38knEQrhe1BoyB+Bj8QA2cv73y5/ePLyq8dnD35ffffz8v7D1Y9fvnxwb3XvGdCViotu8T+YEhommA3QnsYwYC30ioezPx/W8KqYDdzberaUX87Fu5fxUXzk40XHYzAuk4u355+y8xJcKEk6HxP4GOmEGGotpjrZvzxTqahwy0gIok3DvOTdZq1lr9FTqV7L9JrkG2enz79ZPf+t7a/0Wa1LvTLra2Oqo+rzv4q8ovMvEnnvTQkujrxu2nB2Docqj5Ovz+VRcrla49Lmc341ahWpVOW/vWTkv/xbnmVwLuEjaJf9sokmGav3VoTIGDmF5tbINFmXYjYR0w6ctCJLoFHnHHKIIEsAQivu5abKfQk1GoHbTpmJ5hkJIHAEFDJJdeYT8TkJAdg2SdA2nDm2dLcfTH02wfshFj6hdhc5FAhUQylJUj8VxWkCkFLNHRMqcOI4ROCoaYNUmEgKXT8QhEOaIAQ7yDGqp1xnr18pgIy49FUJuKQCtZUcjJIrYyn+gKitz3goSevooeYhTnACAbDwE5BtzyFRDpiaBGoi0rJBocyiwYn4IZY4t/gOhttTUpjVVh7CNMVNoLJEDdqVXWI+5QHfrqL0tC8SjPcLNvvwV9ZR1qPiTcaivDXCWbdMLps5jfzasndBOpqZ7fWMhyyGJYFbm6NFoL2DPFFXclrzAY8in4WuH4Yfwl7gyVzrKIYAeotEmGfCqfUGyIzczleu6CH0D2PaRZv9fj8f5TBKlt/rzN28ile5W+OZvpPr6zKmAxTyIIsgre4Eiw8olp/b849Cx1aWO5zB1mc4sTuqOTYarmfJCc9q9GDPkj1YTsNVP7/s1xusZ+n2KnWalz/CiLjJuZBl/4ynRHYH0LIpHgtYvXaQLwT7dq6+6LwPKYA0DHvF4wWeLTCAvhJTqC+MEBqG5BAF0BHSkWep0G7giHtWLlYKJCylJnBQGfZAWlXUSIJzeuBLFR3X8CATAlrZtYCS4AtQqb1iQPH05O7yj1+Ld8jy+6enJ4+Xdx+t/np69uTvs59eDHuF/UV4jYu7xHzx6NUxy2D017BXyRUMUzGnRdquqcecZ7m94gWnlpCL08gN0tSzIPfyIYeQW0mrXgszEorpQC7at3M9hGJTzQSDR3KIc0G+muXvW830a6jS0D9IOc1EYSjPsjGc9X01EjwuB233U0wmU1C/2u/HR9rzer/vaM+Rn0wI+NWoMexpwiZ6wlB31Wp4RcabmoEibcYACCs5r4HVtYoKyDezeyflDJ7oObynBFABs/M8C17gxZZze/DpQnsQ0GNksTYOEj5LoZndAQu1y9a8ygvbdqmlleK2sBb/AOBR7ZA=" />
|
||||
|
||||
## 在某个节点下自动生成新节点
|
||||
|
||||
在某个节点下自动生成新节点,如果也要依次生成,那么可以使用前面的增量更新数据的方式。如果一次生成,那么可以简单的调用插入新节点的命令即可。
|
||||
|
||||
### 一次生成下级节点
|
||||
|
||||
```js
|
||||
// 插入一个子节点
|
||||
mindMap.execCommand('INSERT_CHILD_NODE',
|
||||
false,
|
||||
node,
|
||||
{
|
||||
data: {
|
||||
text: '三级节点'
|
||||
},
|
||||
children: []
|
||||
},
|
||||
[
|
||||
{
|
||||
data: {
|
||||
text: '三级节点的子节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
// 插入多个子节点
|
||||
mindMap.execCommand('INSERT_MULTI_CHILD_NODE', node, [
|
||||
{
|
||||
data: {
|
||||
text: '三级节点'
|
||||
},
|
||||
children: []
|
||||
},
|
||||
{
|
||||
data: {
|
||||
text: '三级节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
])
|
||||
```
|
||||
|
||||
### 一次生成兄弟节点
|
||||
|
||||
```js
|
||||
// 插入一个兄弟节点
|
||||
mindMap.execCommand('INSERT_NODE',
|
||||
false,
|
||||
node,
|
||||
{
|
||||
data: {
|
||||
text: '二级节点'
|
||||
},
|
||||
children: []
|
||||
},
|
||||
[
|
||||
{
|
||||
data: {
|
||||
text: '二级节点的子节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
// 插入多个兄弟节点
|
||||
mindMap.execCommand('INSERT_MULTI_NODE', node, [
|
||||
{
|
||||
data: {
|
||||
text: '二级节点'
|
||||
},
|
||||
children: []
|
||||
},
|
||||
{
|
||||
data: {
|
||||
text: '二级节点'
|
||||
},
|
||||
children: []
|
||||
}
|
||||
])
|
||||
```
|
||||
|
||||
这样新创建的节点默认会被激活但不进入编辑,如果你连激活都不想要的话,那么可以通过将实例化选项`createNewNodeBehavior`设置为`notActive`。
|
||||
|
||||
当自动生成结束后你又想恢复创建新节点时自动进入编辑状态,那么可以通过`updateConfig`方法修改`createNewNodeBehavior`:
|
||||
|
||||
```js
|
||||
mindMap.updateConfig({
|
||||
createNewNodeBehavior: 'default'
|
||||
})
|
||||
```
|
||||
|
||||
### 完整示例
|
||||
|
||||
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rG0cQ/yrLliK5yCcl9EmVQ2LZUEPkFDd5yppwvhtJm97tHnd7lo0RlJDSNu1DoH0KFLdQaAntu/Pn40hWPkZmb3dPfw35Q/ySHBzszs78Zm5+M7t7J/RGkniHOdAmbWVByhNFMlB5co0JHicyVeSEpNCtESk6MhcKwhrJ+n4UycEedMmQdFMZkwoiVEqLDhdhx0/MEqMZiiNYj1G6HvsJo0wQwkQEimiZ1twgIo8iJpgIpMgUOgugnYKv4JaAdp9HYQoCtaprZOMaOdEARlHIEFBucTzUCiGF1OuiYBfXNo/v8LB6dU1bOCU4gqAt49gXYbWys/vt9t7te+2vd25u3du9tbVdqWFsBJ+uH2VQM2Ptxg4L5+YJfeU3ZwX6UXCkmqQyOvt58vyfV48eTB48w8y41aFF0U9gv6tJ7u4bqVu9O1VaQF/p8gK3kycPx/8/XgphMYzVoRRaZogSzB9Oltnp5JHil8FP587N2zvzLBWcuFRdBisf1AcT+xclGVtgM5WqD+mHzPCn2n+X2r8EYkzpfxxFjzmaT6VLTJ6gd2hL0eW9qg0hKGjYhUGRTej7h1ymGEsIXR+5wTCGDr08vKrL2PrwgYE7tBw4RE0SyiCPQSivB2o7Aj3cPN5BZqwlhqN8LiCtrNnvXEgRo1rA6FzWGNU500JGz/98ZnLG6EymGM15qBWuONk0j4y6PGqFi5plpeNF56Pnv5aczfmfi+HqrHy+dxZiWe6eon9m7bjgak9KpRn7RmZccanroRJBV2F1VwJMMaZz36pfxLCQ6kag+KG+cyD42leG6lbd3GDw7oITBXjtQHOcEdIK+SEJIj/LNhi19G1BLBktlq0CD6erJbmo0qrj6qyiQ1JSRge+VnEf3DrIlZKCXA8iHnyHKiuvMmgwOvv+/L+/Jr+fnv/0GMejs6ejs19KPlp1g/MmuHOH8ALy+O8n74E8PXlWBjz+4eH45ek7Brwa2MT7dsC4aSDKqx+fjh/9a1AmL347/+N0wXJKohu16jM1gtNMHUemXK7bmyyjXt1cX+324EEWe0GWMYo1p2+xhHgz5eTabcBD1cf+bTQ+L/QIScpqTwE9Yu0WC0Wj6PezxbJzUFND/yCTUa6MISG6Z5qkYWdKJtPJsvs+8F4f1b9sNJIj53m13y+c59hPexz9OtTED0Muek5Qhu7ZLnjDiK+4CGzQ5RwBsYMLDmiNGgb0D4N3P5MC/08KeGYXkIFyc2MUfz/MnubVceiluNfzGDRZ6wepHGR47N5HC7utrPglMbbLVGsrG9uQDl8Db1FoOA==" />
|
||||
223
web/src/pages/Doc/zh/course26/index.vue
Normal file
223
web/src/pages/Doc/zh/course26/index.vue
Normal file
@ -0,0 +1,223 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>如何实现AI生成节点内容</h1>
|
||||
<p>目前AI能力非常流行,每个应用都给自己加上了AI的能力提高竞争力,那么在使用了<code>simple-mind-map</code>的情况下如何添加AI的能力呢,本教程会详细的教你如何实现。</p>
|
||||
<p>首先要说明的是本教程并不会真的实现一个可用的AI能力,只是在假设你要实现该功能的前提下来教你如何调用对应的API来实现你想要的效果。</p>
|
||||
<p>其次AI返回的数据结构不尽相同,你都需要自行转换成<code>simple-mind-map</code>的结构类型。</p>
|
||||
<h2>自动生成整个思维导图</h2>
|
||||
<h3>一次生成</h3>
|
||||
<p>通过AI生成整个思维导图并且一次直接生成,这个其实就是普通的回显功能,那么你可以在实例化时通过<code>data</code>传入生成的数据:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">const</span> mindMap = <span class="hljs-keyword">new</span> MindMap({
|
||||
el,
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'我是自动生成的节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: [
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'子节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
</code></pre>
|
||||
<p>也可以在实例化之后使用<code>setData</code>方法设置:</p>
|
||||
<pre class="hljs"><code>mindMap.setData({
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'我是自动生成的节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: [
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'子节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
]
|
||||
})
|
||||
</code></pre>
|
||||
<h3>依次生成节点</h3>
|
||||
<p>如果你想像ChatGPT一样依次生成节点,那么推荐使用<code>updateData</code>方法增量更新节点数据,而不是手动获取到之前插入的节点实例,再调用命令来插入下级节点,这样会复杂很多,当然,如果你能轻松的知道当前创建到哪里了,并且下一个节点在哪个节点下创建,可以忽略。</p>
|
||||
<blockquote>
|
||||
<p>updateData方法是v0.9.9+的方法,之前的版本可以使用下面的方法:</p>
|
||||
</blockquote>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">const</span> updateData = <span class="hljs-function">(<span class="hljs-params">data</span>) =></span> {
|
||||
mindMap.renderer.setData(data)
|
||||
mindMap.render()
|
||||
mindMap.command.addHistory()
|
||||
}
|
||||
</code></pre>
|
||||
<p>增量更新的前提是之前生成的节点都存在<code>uid</code>,并且不会变化,这样调用<code>updateData</code>方法渲染时会根据<code>uid</code>来复用之前的节点,只创建新的节点,达到依次生成的目的。</p>
|
||||
<p>比如第一次返回的数据:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">const</span> data = {
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'根节点'</span>,
|
||||
<span class="hljs-attr">uid</span>: <span class="hljs-string">'1'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
|
||||
mindMap.setData(data)
|
||||
</code></pre>
|
||||
<p>第二次返回的数据:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">const</span> data = {
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'根节点'</span>,
|
||||
<span class="hljs-attr">uid</span>: <span class="hljs-string">'1'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: [
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'二级节点'</span>,
|
||||
<span class="hljs-attr">uid</span>: <span class="hljs-string">'2'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
mindMap.updateData(data)
|
||||
</code></pre>
|
||||
<p>以此类推,这样虽然是整个数据更新,但是因为复用的原因画布呈现的是依次生成新节点的效果。</p>
|
||||
<p>当生成的节点多了会有个问题,就是新生成的节点在画布外看不见了,所以我们要将新生成的节点移动到画布中心,首先可以监听<code>data_change_detail</code>事件来获取到详细的更新数据,找出其中新创建的节点数据,然后使用<code>findNodeByUid</code>方法找出对应的节点实例,最后调用<code>moveNodeToCenter</code>方法将该节点移动到画布中心即可。</p>
|
||||
<pre class="hljs"><code>mindMap.on(<span class="hljs-string">'data_change_detail'</span>, <span class="hljs-function">(<span class="hljs-params">list</span>) =></span> {
|
||||
<span class="hljs-comment">// 找出新创建节点中的最后一个</span>
|
||||
<span class="hljs-keyword">const</span> lastCreate = list.filter(<span class="hljs-function">(<span class="hljs-params">item</span>) =></span> {
|
||||
<span class="hljs-keyword">return</span> item.action === <span class="hljs-string">'create'</span>
|
||||
})[<span class="hljs-number">0</span>]
|
||||
<span class="hljs-keyword">if</span> (lastCreate) {
|
||||
<span class="hljs-keyword">const</span> uid = lastCreate.data.data.uid
|
||||
<span class="hljs-keyword">const</span> node = mindMap.renderer.findNodeByUid(uid)
|
||||
<span class="hljs-keyword">if</span> (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
</code></pre>
|
||||
<p>当节点数据多了,可能<code>data_change_detail</code>事件触发时节点树还没渲染完毕,导致获取不到节点,解决这个问题可以通过监听<code>node_tree_render_end</code>事件:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">let</span> waitUid = <span class="hljs-string">''</span>
|
||||
mindMap.on(<span class="hljs-string">'data_change_detail'</span>, <span class="hljs-function">(<span class="hljs-params">list</span>) =></span> {
|
||||
<span class="hljs-comment">// ...</span>
|
||||
<span class="hljs-keyword">if</span> (lastCreate) {
|
||||
<span class="hljs-comment">// ...</span>
|
||||
<span class="hljs-keyword">if</span> (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
waitUid = uid
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mindMap.on(<span class="hljs-string">'node_tree_render_end'</span>, <span class="hljs-function">() =></span>{
|
||||
<span class="hljs-keyword">if</span> (waitUid) {
|
||||
waitUid = <span class="hljs-string">''</span>
|
||||
<span class="hljs-keyword">const</span> node = mindMap.renderer.findNodeByUid(waitUid)
|
||||
<span class="hljs-keyword">if</span> (node) {
|
||||
mindMap.renderer.moveNodeToCenter(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
</code></pre>
|
||||
<p>当在<code>data_change_detail</code>事件中没有获取到节点实例就将该<code>uid</code>保存起来,然后在<code>node_tree_render_end</code>事件里判断是否有保存的<code>uid</code>,是的话就获取该节点实例并移动到画布中心。</p>
|
||||
<p>最后,当自动生成节点中最好禁止用户操作,否则可能会产生异常。</p>
|
||||
<h3>完整示例</h3>
|
||||
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rHDcQ/ypiS9m95rx3bvN0vTOJnUILdVtC+uQNZr2ru1OqlZZdrc+HOQih0DT0IYUWSkto+9QSWvKSByct+TT2XT5GR7uS9t/ZxNBAoTHYXmlmfvObGWkkHVvX49g9zLA1sIZpkJBYoBSLLN7yGIlingh0jBI87iLOdnnGBA67KJ36lPLZTTxGCzROeIRsQLCNxS5h4a4fFyLPSmGa4o0IZjciP/YsjyHkMYoFknNSc4RYRqnHPBZwlgpwFuCdBPsCX6cUpE4HjbbQsTRUJi6wvOEL38knEQrhe1BoyB+Bj8QA2cv73y5/ePLyq8dnD35ffffz8v7D1Y9fvnxwb3XvGdCViotu8T+YEhommA3QnsYwYC30ioezPx/W8KqYDdzberaUX87Fu5fxUXzk40XHYzAuk4u355+y8xJcKEk6HxP4GOmEGGotpjrZvzxTqahwy0gIok3DvOTdZq1lr9FTqV7L9JrkG2enz79ZPf+t7a/0Wa1LvTLra2Oqo+rzv4q8ovMvEnnvTQkujrxu2nB2Docqj5Ovz+VRcrla49Lmc341ahWpVOW/vWTkv/xbnmVwLuEjaJf9sokmGav3VoTIGDmF5tbINFmXYjYR0w6ctCJLoFHnHHKIIEsAQivu5abKfQk1GoHbTpmJ5hkJIHAEFDJJdeYT8TkJAdg2SdA2nDm2dLcfTH02wfshFj6hdhc5FAhUQylJUj8VxWkCkFLNHRMqcOI4ROCoaYNUmEgKXT8QhEOaIAQ7yDGqp1xnr18pgIy49FUJuKQCtZUcjJIrYyn+gKitz3goSevooeYhTnACAbDwE5BtzyFRDpiaBGoi0rJBocyiwYn4IZY4t/gOhttTUpjVVh7CNMVNoLJEDdqVXWI+5QHfrqL0tC8SjPcLNvvwV9ZR1qPiTcaivDXCWbdMLps5jfzasndBOpqZ7fWMhyyGJYFbm6NFoL2DPFFXclrzAY8in4WuH4Yfwl7gyVzrKIYAeotEmGfCqfUGyIzczleu6CH0D2PaRZv9fj8f5TBKlt/rzN28ile5W+OZvpPr6zKmAxTyIIsgre4Eiw8olp/b849Cx1aWO5zB1mc4sTuqOTYarmfJCc9q9GDPkj1YTsNVP7/s1xusZ+n2KnWalz/CiLjJuZBl/4ynRHYH0LIpHgtYvXaQLwT7dq6+6LwPKYA0DHvF4wWeLTCAvhJTqC+MEBqG5BAF0BHSkWep0G7giHtWLlYKJCylJnBQGfZAWlXUSIJzeuBLFR3X8CATAlrZtYCS4AtQqb1iQPH05O7yj1+Ld8jy+6enJ4+Xdx+t/np69uTvs59eDHuF/UV4jYu7xHzx6NUxy2D017BXyRUMUzGnRdquqcecZ7m94gWnlpCL08gN0tSzIPfyIYeQW0mrXgszEorpQC7at3M9hGJTzQSDR3KIc0G+muXvW830a6jS0D9IOc1EYSjPsjGc9X01EjwuB233U0wmU1C/2u/HR9rzer/vaM+Rn0wI+NWoMexpwiZ6wlB31Wp4RcabmoEibcYACCs5r4HVtYoKyDezeyflDJ7oObynBFABs/M8C17gxZZze/DpQnsQ0GNksTYOEj5LoZndAQu1y9a8ygvbdqmlleK2sBb/AOBR7ZA=" />
|
||||
<h2>在某个节点下自动生成新节点</h2>
|
||||
<p>在某个节点下自动生成新节点,如果也要依次生成,那么可以使用前面的增量更新数据的方式。如果一次生成,那么可以简单的调用插入新节点的命令即可。</p>
|
||||
<h3>一次生成下级节点</h3>
|
||||
<pre class="hljs"><code><span class="hljs-comment">// 插入一个子节点</span>
|
||||
mindMap.execCommand(<span class="hljs-string">'INSERT_CHILD_NODE'</span>,
|
||||
<span class="hljs-literal">false</span>,
|
||||
node,
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'三级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
},
|
||||
[
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'三级节点的子节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
<span class="hljs-comment">// 插入多个子节点</span>
|
||||
mindMap.execCommand(<span class="hljs-string">'INSERT_MULTI_CHILD_NODE'</span>, node, [
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'三级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
},
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'三级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
])
|
||||
</code></pre>
|
||||
<h3>一次生成兄弟节点</h3>
|
||||
<pre class="hljs"><code><span class="hljs-comment">// 插入一个兄弟节点</span>
|
||||
mindMap.execCommand(<span class="hljs-string">'INSERT_NODE'</span>,
|
||||
<span class="hljs-literal">false</span>,
|
||||
node,
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'二级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
},
|
||||
[
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'二级节点的子节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
<span class="hljs-comment">// 插入多个兄弟节点</span>
|
||||
mindMap.execCommand(<span class="hljs-string">'INSERT_MULTI_NODE'</span>, node, [
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'二级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
},
|
||||
{
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'二级节点'</span>
|
||||
},
|
||||
<span class="hljs-attr">children</span>: []
|
||||
}
|
||||
])
|
||||
</code></pre>
|
||||
<p>这样新创建的节点默认会被激活但不进入编辑,如果你连激活都不想要的话,那么可以通过将实例化选项<code>createNewNodeBehavior</code>设置为<code>notActive</code>。</p>
|
||||
<p>当自动生成结束后你又想恢复创建新节点时自动进入编辑状态,那么可以通过<code>updateConfig</code>方法修改<code>createNewNodeBehavior</code>:</p>
|
||||
<pre class="hljs"><code>mindMap.updateConfig({
|
||||
<span class="hljs-attr">createNewNodeBehavior</span>: <span class="hljs-string">'default'</span>
|
||||
})
|
||||
</code></pre>
|
||||
<h3>完整示例</h3>
|
||||
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rG0cQ/yrLliK5yCcl9EmVQ2LZUEPkFDd5yppwvhtJm97tHnd7lo0RlJDSNu1DoH0KFLdQaAntu/Pn40hWPkZmb3dPfw35Q/ySHBzszs78Zm5+M7t7J/RGkniHOdAmbWVByhNFMlB5co0JHicyVeSEpNCtESk6MhcKwhrJ+n4UycEedMmQdFMZkwoiVEqLDhdhx0/MEqMZiiNYj1G6HvsJo0wQwkQEimiZ1twgIo8iJpgIpMgUOgugnYKv4JaAdp9HYQoCtaprZOMaOdEARlHIEFBucTzUCiGF1OuiYBfXNo/v8LB6dU1bOCU4gqAt49gXYbWys/vt9t7te+2vd25u3du9tbVdqWFsBJ+uH2VQM2Ptxg4L5+YJfeU3ZwX6UXCkmqQyOvt58vyfV48eTB48w8y41aFF0U9gv6tJ7u4bqVu9O1VaQF/p8gK3kycPx/8/XgphMYzVoRRaZogSzB9Oltnp5JHil8FP587N2zvzLBWcuFRdBisf1AcT+xclGVtgM5WqD+mHzPCn2n+X2r8EYkzpfxxFjzmaT6VLTJ6gd2hL0eW9qg0hKGjYhUGRTej7h1ymGEsIXR+5wTCGDr08vKrL2PrwgYE7tBw4RE0SyiCPQSivB2o7Aj3cPN5BZqwlhqN8LiCtrNnvXEgRo1rA6FzWGNU500JGz/98ZnLG6EymGM15qBWuONk0j4y6PGqFi5plpeNF56Pnv5aczfmfi+HqrHy+dxZiWe6eon9m7bjgak9KpRn7RmZccanroRJBV2F1VwJMMaZz36pfxLCQ6kag+KG+cyD42leG6lbd3GDw7oITBXjtQHOcEdIK+SEJIj/LNhi19G1BLBktlq0CD6erJbmo0qrj6qyiQ1JSRge+VnEf3DrIlZKCXA8iHnyHKiuvMmgwOvv+/L+/Jr+fnv/0GMejs6ejs19KPlp1g/MmuHOH8ALy+O8n74E8PXlWBjz+4eH45ek7Brwa2MT7dsC4aSDKqx+fjh/9a1AmL347/+N0wXJKohu16jM1gtNMHUemXK7bmyyjXt1cX+324EEWe0GWMYo1p2+xhHgz5eTabcBD1cf+bTQ+L/QIScpqTwE9Yu0WC0Wj6PezxbJzUFND/yCTUa6MISG6Z5qkYWdKJtPJsvs+8F4f1b9sNJIj53m13y+c59hPexz9OtTED0Muek5Qhu7ZLnjDiK+4CGzQ5RwBsYMLDmiNGgb0D4N3P5MC/08KeGYXkIFyc2MUfz/MnubVceiluNfzGDRZ6wepHGR47N5HC7utrPglMbbLVGsrG9uQDl8Db1FoOA==" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@ -332,4 +332,8 @@
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>SR</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>逆水行舟</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -287,6 +287,10 @@
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>SR</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>逆水行舟</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -56,6 +56,12 @@
|
||||
|
||||
## 方法
|
||||
|
||||
### getAncestorNodes()
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
获取祖先节点实例列表。
|
||||
|
||||
### highlight()
|
||||
|
||||
> v0.9.8+
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
</blockquote>
|
||||
<p>节点是否正在拖拽中</p>
|
||||
<h2>方法</h2>
|
||||
<h3>getAncestorNodes()</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>获取祖先节点实例列表。</p>
|
||||
<h3>highlight()</h3>
|
||||
<blockquote>
|
||||
<p>v0.9.8+</p>
|
||||
|
||||
56
web/src/pages/Doc/zh/rainbowLines/index.md
Normal file
56
web/src/pages/Doc/zh/rainbowLines/index.md
Normal file
@ -0,0 +1,56 @@
|
||||
# RainbowLines插件
|
||||
|
||||
> v0.9.9+
|
||||
|
||||
该插件用于实现彩虹线条。
|
||||
|
||||
开启彩虹线条及自定义颜色可以通过实例化选项`rainbowLinesConfig`设置。
|
||||
|
||||
默认的颜色列表如下:
|
||||
|
||||
```
|
||||
[
|
||||
'rgb(255, 213, 73)',
|
||||
'rgb(255, 136, 126)',
|
||||
'rgb(107, 225, 141)',
|
||||
'rgb(151, 171, 255)',
|
||||
'rgb(129, 220, 242)',
|
||||
'rgb(255, 163, 125)',
|
||||
'rgb(152, 132, 234)'
|
||||
]
|
||||
```
|
||||
|
||||
## 注册
|
||||
|
||||
```js
|
||||
import MindMap from 'simple-mind-map'
|
||||
import RainbowLines from 'simple-mind-map/src/plugins/RainbowLines.js'
|
||||
MindMap.usePlugin(RainbowLines)
|
||||
```
|
||||
|
||||
注册完且实例化`MindMap`后可通过`mindMap.rainbowLines`获取到该实例。
|
||||
|
||||
## 方法
|
||||
|
||||
### updateRainLinesConfig(config = {})
|
||||
|
||||
如果你在通过实例化选项`rainbowLinesConfig`设置了彩虹线条后想修改,那么可以使用该方法,参数`config`同`rainbowLinesConfig`。
|
||||
|
||||
```js
|
||||
{
|
||||
open: false,// 是否开启彩虹线条
|
||||
colorsList: []// 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表
|
||||
}
|
||||
```
|
||||
|
||||
### getColorsList()
|
||||
|
||||
获取当前使用的彩虹线条颜色列表。
|
||||
|
||||
### getNodeColor(node)
|
||||
|
||||
获取指定的节点实例对应的彩虹线条颜色。
|
||||
|
||||
### getSecondLayerAncestor(node)
|
||||
|
||||
获取一个节点实例的第二层级的祖先节点实例。
|
||||
52
web/src/pages/Doc/zh/rainbowLines/index.vue
Normal file
52
web/src/pages/Doc/zh/rainbowLines/index.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>RainbowLines插件</h1>
|
||||
<blockquote>
|
||||
<p>v0.9.9+</p>
|
||||
</blockquote>
|
||||
<p>该插件用于实现彩虹线条。</p>
|
||||
<p>开启彩虹线条及自定义颜色可以通过实例化选项<code>rainbowLinesConfig</code>设置。</p>
|
||||
<p>默认的颜色列表如下:</p>
|
||||
<pre class="hljs"><code>[
|
||||
'rgb(255, 213, 73)',
|
||||
'rgb(255, 136, 126)',
|
||||
'rgb(107, 225, 141)',
|
||||
'rgb(151, 171, 255)',
|
||||
'rgb(129, 220, 242)',
|
||||
'rgb(255, 163, 125)',
|
||||
'rgb(152, 132, 234)'
|
||||
]
|
||||
</code></pre>
|
||||
<h2>注册</h2>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">'simple-mind-map'</span>
|
||||
<span class="hljs-keyword">import</span> RainbowLines <span class="hljs-keyword">from</span> <span class="hljs-string">'simple-mind-map/src/plugins/RainbowLines.js'</span>
|
||||
MindMap.usePlugin(RainbowLines)
|
||||
</code></pre>
|
||||
<p>注册完且实例化<code>MindMap</code>后可通过<code>mindMap.rainbowLines</code>获取到该实例。</p>
|
||||
<h2>方法</h2>
|
||||
<h3>updateRainLinesConfig(config = {})</h3>
|
||||
<p>如果你在通过实例化选项<code>rainbowLinesConfig</code>设置了彩虹线条后想修改,那么可以使用该方法,参数<code>config</code>同<code>rainbowLinesConfig</code>。</p>
|
||||
<pre class="hljs"><code>{
|
||||
<span class="hljs-attr">open</span>: <span class="hljs-literal">false</span>,<span class="hljs-comment">// 是否开启彩虹线条</span>
|
||||
<span class="hljs-attr">colorsList</span>: []<span class="hljs-comment">// 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表</span>
|
||||
}
|
||||
</code></pre>
|
||||
<h3>getColorsList()</h3>
|
||||
<p>获取当前使用的彩虹线条颜色列表。</p>
|
||||
<h3>getNodeColor(node)</h3>
|
||||
<p>获取指定的节点实例对应的彩虹线条颜色。</p>
|
||||
<h3>getSecondLayerAncestor(node)</h3>
|
||||
<p>获取一个节点实例的第二层级的祖先节点实例。</p>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user