From eb01646747cfcd64d7184e3c9be8d314ae3d2335 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 17 Jan 2023 14:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E6=B0=B4=E5=8D=B0=E7=B1=BB?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 6 ------ simple-mind-map/src/Watermark.js | 6 +++++- web/src/pages/Doc/en/constructor/index.md | 4 +++- web/src/pages/Doc/en/constructor/index.vue | 3 ++- web/src/pages/Doc/en/introduction/index.md | 2 +- web/src/pages/Doc/en/introduction/index.vue | 2 +- web/src/pages/Doc/en/miniMap/index.md | 13 +++++++++++-- web/src/pages/Doc/en/miniMap/index.vue | 10 ++++++++-- web/src/pages/Doc/en/watermark/index.md | 16 +++++++++++++--- web/src/pages/Doc/en/watermark/index.vue | 12 +++++++++--- web/src/pages/Doc/routerList.js | 2 +- web/src/pages/Doc/zh/constructor/index.md | 4 +++- web/src/pages/Doc/zh/constructor/index.vue | 3 ++- web/src/pages/Doc/zh/introduction/index.md | 2 +- web/src/pages/Doc/zh/introduction/index.vue | 2 +- web/src/pages/Doc/zh/miniMap/index.md | 13 +++++++++++-- web/src/pages/Doc/zh/miniMap/index.vue | 10 ++++++++-- web/src/pages/Doc/zh/watermark/index.md | 15 +++++++++++++-- web/src/pages/Doc/zh/watermark/index.vue | 11 +++++++++-- web/src/pages/Edit/components/Edit.vue | 5 ++++- 20 files changed, 106 insertions(+), 35 deletions(-) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 9f45265e..83420a66 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -10,7 +10,6 @@ import BatchExecution from './src/BatchExecution' import Export from './src/Export' import Select from './src/Select' import Drag from './src/Drag' -import Watermark from './src/Watermark' import { layoutValueList } from './src/utils/constant' import { SVG } from '@svgdotjs/svg.js' import { simpleDeepClone } from './src/utils' @@ -138,11 +137,6 @@ class MindMap { mindMap: this }) - // 水印类 - this.watermark = new Watermark({ - mindMap: this - }) - // 批量执行类 this.batchExecution = new BatchExecution() diff --git a/simple-mind-map/src/Watermark.js b/simple-mind-map/src/Watermark.js index 2d740fb2..0a1985a4 100644 --- a/simple-mind-map/src/Watermark.js +++ b/simple-mind-map/src/Watermark.js @@ -3,7 +3,7 @@ import { degToRad, camelCaseToHyphen } from './utils' import merge from 'deepmerge' // 水印类 -export default class Watermark { +class Watermark { constructor(opt = {}) { this.mindMap = opt.mindMap this.lineSpacing = 0 // 水印行间距 @@ -109,3 +109,7 @@ export default class Watermark { this.draw() } } + +Watermark.instanceName = 'watermark' + +export default Watermark \ No newline at end of file diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 3c159c70..71d31470 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -85,7 +85,9 @@ For all configurations of theme, please refer to [Default Topic](https://github. > v0.3.0+ -If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. +If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. Can be called in chain. + +Note: The plugin needs to be registered before instantiating `MindMap`. ## Static props diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index adfeacee..1a0fa82a 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -211,7 +211,8 @@ mindMap.setTheme('Theme name')
-v0.3.0+
If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method.
+If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. Can be called in chain.
+Note: The plugin needs to be registered before instantiating MindMap.
diff --git a/web/src/pages/Doc/en/introduction/index.md b/web/src/pages/Doc/en/introduction/index.md index 859b96f8..f65f745d 100644 --- a/web/src/pages/Doc/en/introduction/index.md +++ b/web/src/pages/Doc/en/introduction/index.md @@ -16,7 +16,7 @@ - [x] Supports free dragging and dragging to adjust nodes - [x] Supports various node shapes - [x] Supports export to json, png, svg, pdf, and import from json, xmind -- [x] Supports mini map +- [x] Supports mini map、support watermark ## Table of Contents diff --git a/web/src/pages/Doc/en/introduction/index.vue b/web/src/pages/Doc/en/introduction/index.vue index 5c3fd50d..3b677ebc 100644 --- a/web/src/pages/Doc/en/introduction/index.vue +++ b/web/src/pages/Doc/en/introduction/index.vue @@ -16,7 +16,7 @@ summaries - +Table of Contents
1.
diff --git a/web/src/pages/Doc/en/miniMap/index.md b/web/src/pages/Doc/en/miniMap/index.md index 0492c671..0e82ce40 100644 --- a/web/src/pages/Doc/en/miniMap/index.md +++ b/web/src/pages/Doc/en/miniMap/index.md @@ -1,4 +1,4 @@ -# MiniMap instance +# MiniMap plugin > v0.2.11+ @@ -8,7 +8,16 @@ When zoomed, moved, or there are too many elements, the canvas may only display part of the mind map content. The viewport frame can be used to view the current viewport location, and can be quickly positioned by dragging on the small map. -The `mindMap.miniMap` instance can be obtained through this. +## Register + +```js +import MindMap from 'simple-mind-map' +import MiniMap from 'simple-mind-map/src/MiniMap.js' + +MindMap.usePlugin(MiniMap) +``` + +After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.miniMap`. ## Methods diff --git a/web/src/pages/Doc/en/miniMap/index.vue b/web/src/pages/Doc/en/miniMap/index.vue index 1f231a4f..d8be49ff 100644 --- a/web/src/pages/Doc/en/miniMap/index.vue +++ b/web/src/pages/Doc/en/miniMap/index.vue @@ -1,6 +1,6 @@simple-mind-map-MiniMap instance
+MiniMap plugin
@@ -9,7 +9,13 @@ parts, one is the current canvas content, and the other is the viewport frame. When zoomed, moved, or there are too many elements, the canvas may only display part of the mind map content. The viewport frame can be used to view the current viewport location, and can be quickly positioned by dragging on the small map. -v0.2.11+
The
+mindMap.miniMapinstance can be obtained through this.Register
++import MindMap from 'simple-mind-map' +import MiniMap from 'simple-mind-map/src/MiniMap.js' + +MindMap.usePlugin(MiniMap) +After registration and instantiation of
MindMap, the instance can be obtained throughmindMap.miniMap.Methods
calculationMiniMap(boxWidth, boxHeight)
"Calculate the rendering data for the small map, this function will call the diff --git a/web/src/pages/Doc/en/watermark/index.md b/web/src/pages/Doc/en/watermark/index.md index 9407fcd3..69b49a70 100644 --- a/web/src/pages/Doc/en/watermark/index.md +++ b/web/src/pages/Doc/en/watermark/index.md @@ -1,9 +1,19 @@ -# Watermark instance +# Watermark plugin > 0.2.24+ -`Watermark` instance is responsible for displaying the watermark, and can be obtained -through `mindMap.watermark`. +`Watermark` instance is responsible for displaying the watermark. + +## Register + +```js +import MindMap from 'simple-mind-map' +import Watermark from 'simple-mind-map/src/Watermark.js' + +MindMap.usePlugin(Watermark) +``` + +After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.watermark`. ## Methods diff --git a/web/src/pages/Doc/en/watermark/index.vue b/web/src/pages/Doc/en/watermark/index.vue index cd341b2a..542d2a24 100644 --- a/web/src/pages/Doc/en/watermark/index.vue +++ b/web/src/pages/Doc/en/watermark/index.vue @@ -1,11 +1,17 @@
-Watermark instance
+Watermark plugin
-0.2.24+
+
Watermarkinstance is responsible for displaying the watermark, and can be obtained -throughmindMap.watermark.+
Watermarkinstance is responsible for displaying the watermark.Register
++import MindMap from 'simple-mind-map' +import Watermark from 'simple-mind-map/src/Watermark.js' + +MindMap.usePlugin(Watermark) +After registration and instantiation of
MindMap, the instance can be obtained throughmindMap.watermark.Methods
draw()
Redraw the watermark.
diff --git a/web/src/pages/Doc/routerList.js b/web/src/pages/Doc/routerList.js index ddeba8b1..bab0303a 100644 --- a/web/src/pages/Doc/routerList.js +++ b/web/src/pages/Doc/routerList.js @@ -1,3 +1,3 @@ - export default [{"lang":"zh","children":[{"path":"batchExecution","title":"BatchExecution实例"},{"path":"changelog","title":"Changelog"},{"path":"command","title":"Command实例"},{"path":"constructor","title":"构造函数"},{"path":"doExport","title":"DoExport实例"},{"path":"introduction","title":"简介"},{"path":"keyboardNavigation","title":"KeyboardNavigation实例"},{"path":"keyCommand","title":"KeyCommand实例"},{"path":"miniMap","title":"MiniMap实例"},{"path":"node","title":"Node实例"},{"path":"render","title":"Render实例"},{"path":"select","title":"Select实例"},{"path":"start","title":"开始"},{"path":"translate","title":"参与翻译"},{"path":"utils","title":"内置工具方法"},{"path":"view","title":"View实例"},{"path":"watermark","title":"Watermark实例"},{"path":"xmind","title":"XMind解析"}]},{"lang":"en","children":[{"path":"batchExecution","title":"batchExecution instance"},{"path":"changelog","title":"Changelog"},{"path":"command","title":"command instance"},{"path":"constructor","title":"Constructor"},{"path":"doExport","title":"DoExport instance"},{"path":"introduction","title":"Introduction"},{"path":"keyboardNavigation","title":"KeyboardNavigation instance"},{"path":"keyCommand","title":"KeyCommand instance"},{"path":"miniMap","title":"MiniMap instance"},{"path":"node","title":"Node instance"},{"path":"render","title":"Render instance"},{"path":"select","title":"Select instance"},{"path":"start","title":"Start"},{"path":"translate","title":"Participate in translation"},{"path":"utils","title":"Utility Methods"},{"path":"view","title":"View instance"},{"path":"watermark","title":"Watermark instance"},{"path":"xmind","title":"XMind parse"}]}] + export default [{"lang":"zh","children":[{"path":"batchExecution","title":"BatchExecution实例"},{"path":"changelog","title":"Changelog"},{"path":"command","title":"Command实例"},{"path":"constructor","title":"构造函数"},{"path":"doExport","title":"DoExport实例"},{"path":"introduction","title":"简介"},{"path":"keyboardNavigation","title":"KeyboardNavigation实例"},{"path":"keyCommand","title":"KeyCommand实例"},{"path":"miniMap","title":"MiniMap插件"},{"path":"node","title":"Node实例"},{"path":"render","title":"Render实例"},{"path":"select","title":"Select实例"},{"path":"start","title":"开始"},{"path":"translate","title":"参与翻译"},{"path":"utils","title":"内置工具方法"},{"path":"view","title":"View实例"},{"path":"watermark","title":"Watermark插件"},{"path":"xmind","title":"XMind解析"}]},{"lang":"en","children":[{"path":"batchExecution","title":"batchExecution instance"},{"path":"changelog","title":"Changelog"},{"path":"command","title":"command instance"},{"path":"constructor","title":"Constructor"},{"path":"doExport","title":"DoExport instance"},{"path":"introduction","title":"Introduction"},{"path":"keyboardNavigation","title":"KeyboardNavigation instance"},{"path":"keyCommand","title":"KeyCommand instance"},{"path":"miniMap","title":"MiniMap plugin"},{"path":"node","title":"Node instance"},{"path":"render","title":"Render instance"},{"path":"select","title":"Select instance"},{"path":"start","title":"Start"},{"path":"translate","title":"Participate in translation"},{"path":"utils","title":"Utility Methods"},{"path":"view","title":"View instance"},{"path":"watermark","title":"Watermark plugin"},{"path":"xmind","title":"XMind parse"}]}] \ No newline at end of file diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 9d3e0a71..8668d41b 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -87,7 +87,9 @@ mindMap.setTheme('主题名称') > v0.3.0+ -注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。 +注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。可链式调用。 + +注意:插件需要在实例化`MindMap`前注册。 ## 静态属性 diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index 9fcc1fed..2f211d83 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -211,7 +211,8 @@ mindMap.setTheme('主题名称')-v0.3.0+
注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。
+注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。可链式调用。
+注意:插件需要在实例化
MindMap前注册。静态属性
pluginList
diff --git a/web/src/pages/Doc/zh/introduction/index.md b/web/src/pages/Doc/zh/introduction/index.md index 0e612b0b..304c84b1 100644 --- a/web/src/pages/Doc/zh/introduction/index.md +++ b/web/src/pages/Doc/zh/introduction/index.md @@ -14,7 +14,7 @@ - [x] 支持节点自由拖拽、拖拽调整 - [x] 支持多种节点形状 - [x] 支持导出为`json`、`png`、`svg`、`pdf`,支持从`json`、`xmind`导入 -- [x] 支持小地图 +- [x] 支持小地图、支持水印 ## 目录介绍 diff --git a/web/src/pages/Doc/zh/introduction/index.vue b/web/src/pages/Doc/zh/introduction/index.vue index 045bf039..da07c2c0 100644 --- a/web/src/pages/Doc/zh/introduction/index.vue +++ b/web/src/pages/Doc/zh/introduction/index.vue @@ -14,7 +14,7 @@- + json、png、svg、json、xmind导入目录介绍
1.
diff --git a/web/src/pages/Doc/zh/miniMap/index.md b/web/src/pages/Doc/zh/miniMap/index.md index fbd9dd24..e6157724 100644 --- a/web/src/pages/Doc/zh/miniMap/index.md +++ b/web/src/pages/Doc/zh/miniMap/index.md @@ -1,10 +1,19 @@ -# MiniMap实例 +# MiniMap插件 > v0.2.11+ 用于帮助快速开发小地图功能,小地图由两部分组成,一个是当前的画布内容,一个是视口框,当缩放、移动、元素过多时画布上可能只显示了思维导图的部分内容,可以通过视口框来查看当前视口所在位置,以及可以通过在小地图上拖动来快速定位。 -可通过`mindMap.miniMap`获取到该实例。 +## 注册 + +```js +import MindMap from 'simple-mind-map' +import MiniMap from 'simple-mind-map/src/MiniMap.js' + +MindMap.usePlugin(MiniMap) +``` + +注册完且实例化`MindMap`后可通过`mindMap.miniMap`获取到该实例。 ## 方法 diff --git a/web/src/pages/Doc/zh/miniMap/index.vue b/web/src/pages/Doc/zh/miniMap/index.vue index 029b057c..6eaf8969 100644 --- a/web/src/pages/Doc/zh/miniMap/index.vue +++ b/web/src/pages/Doc/zh/miniMap/index.vue @@ -1,11 +1,17 @@simple-mind-map-MiniMap实例
+MiniMap插件
v0.2.11+
用于帮助快速开发小地图功能,小地图由两部分组成,一个是当前的画布内容,一个是视口框,当缩放、移动、元素过多时画布上可能只显示了思维导图的部分内容,可以通过视口框来查看当前视口所在位置,以及可以通过在小地图上拖动来快速定位。
-可通过
+mindMap.miniMap获取到该实例。注册
++import MindMap from 'simple-mind-map' +import MiniMap from 'simple-mind-map/src/MiniMap.js' + +MindMap.usePlugin(MiniMap) +注册完且实例化
MindMap后可通过mindMap.miniMap获取到该实例。方法
calculationMiniMap(boxWidth, boxHeight)
计算小地图的渲染数据,该函数内会调用
diff --git a/web/src/pages/Doc/zh/watermark/index.md b/web/src/pages/Doc/zh/watermark/index.md index fbd94bd0..8a58daa2 100644 --- a/web/src/pages/Doc/zh/watermark/index.md +++ b/web/src/pages/Doc/zh/watermark/index.md @@ -1,8 +1,19 @@ -# Watermark实例 +# Watermark插件 > 0.2.24+ -`Watermark`实例负责显示水印,可通过`mindMap.watermark`获取到该实例。 +`Watermark`插件负责显示水印。 + +## 注册 + +```js +import MindMap from 'simple-mind-map' +import Watermark from 'simple-mind-map/src/Watermark.js' + +MindMap.usePlugin(Watermark) +``` + +注册完且实例化`MindMap`后可通过`mindMap.watermark`获取到该实例。 ## 方法 diff --git a/web/src/pages/Doc/zh/watermark/index.vue b/web/src/pages/Doc/zh/watermark/index.vue index e78d26ea..e8972f74 100644 --- a/web/src/pages/Doc/zh/watermark/index.vue +++ b/web/src/pages/Doc/zh/watermark/index.vue @@ -1,10 +1,17 @@getMiniMap()方法,所以一般使用该函数即可。-Watermark实例
+Watermark插件
-0.2.24+
+
Watermark实例负责显示水印,可通过mindMap.watermark获取到该实例。+
Watermark插件负责显示水印。注册
++import MindMap from 'simple-mind-map' +import Watermark from 'simple-mind-map/src/Watermark.js' + +MindMap.usePlugin(Watermark) +注册完且实例化
MindMap后可通过mindMap.watermark获取到该实例。方法
draw()
重新绘制水印。
diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index 9a168d3b..5c524d8c 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -23,6 +23,7 @@