From 97bcc22abdbf4a84e059141d654c1e2ada114fe3 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 17 Jan 2023 15:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=AF=BC=E5=87=BA=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 | 12 ------------ simple-mind-map/src/Export.js | 2 ++ simple-mind-map/src/Select.js | 2 ++ web/src/pages/Doc/en/constructor/index.md | 2 ++ web/src/pages/Doc/en/constructor/index.vue | 3 +++ web/src/pages/Doc/en/doExport/index.md | 16 +++++++++++++--- web/src/pages/Doc/en/doExport/index.vue | 12 +++++++++--- web/src/pages/Doc/routerList.js | 2 +- web/src/pages/Doc/zh/constructor/index.md | 2 ++ web/src/pages/Doc/zh/constructor/index.vue | 3 +++ web/src/pages/Doc/zh/doExport/index.md | 15 +++++++++++++-- web/src/pages/Doc/zh/doExport/index.vue | 11 +++++++++-- web/src/pages/Edit/components/Edit.vue | 2 ++ 13 files changed, 61 insertions(+), 23 deletions(-) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 8637e0d2..35b20891 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -7,8 +7,6 @@ import Style from './src/Style' import KeyCommand from './src/KeyCommand' import Command from './src/Command' import BatchExecution from './src/BatchExecution' -import Export from './src/Export' -import Select from './src/Select' import { layoutValueList } from './src/utils/constant' import { SVG } from '@svgdotjs/svg.js' import { simpleDeepClone } from './src/utils' @@ -115,16 +113,6 @@ class MindMap { draw: this.draw }) - // 导出类 - this.doExport = new Export({ - mindMap: this - }) - - // 选择类 - this.select = new Select({ - mindMap: this - }) - // 批量执行类 this.batchExecution = new BatchExecution() diff --git a/simple-mind-map/src/Export.js b/simple-mind-map/src/Export.js index 141965ee..df7be3e3 100644 --- a/simple-mind-map/src/Export.js +++ b/simple-mind-map/src/Export.js @@ -215,4 +215,6 @@ class Export { } } +Export.instanceName = 'doExport' + export default Export diff --git a/simple-mind-map/src/Select.js b/simple-mind-map/src/Select.js index 95949c20..98a53c0a 100644 --- a/simple-mind-map/src/Select.js +++ b/simple-mind-map/src/Select.js @@ -167,4 +167,6 @@ class Select { } } +Select.instanceName = 'select' + export default Select diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 71d31470..f9bca6b2 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -301,6 +301,8 @@ view, etc. data ### export(type, isDownload, fileName) +> You need to register the `Export` plugin first + Export `type`: the type to be exported, optional values: png, svg, json, pdf (v0.2.1+), diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index 1a0fa82a..00de7638 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -612,6 +612,9 @@ redo. All commands are as follows:
includes the node tree, iftrue is passed, it will also include theme, layout,
view, etc. data
+You need to register the
+Exportplugin first
Export
type: the type to be exported, optional values: png, svg, json, pdf (v0.2.1+),
smm (essentially also json)
The doExport instance is responsible for exporting and can be obtained through
-mindMap.doExport.
The Export plugin provides the export function.
import MindMap from 'simple-mind-map'
+import Export from 'simple-mind-map/src/Export.js'
+
+MindMap.usePlugin(Export)
+
+After registration and instantiation of MindMap, the instance can be obtained through mindMap.doExport.
Exports as png, an async method that returns image data, data:url data which
diff --git a/web/src/pages/Doc/routerList.js b/web/src/pages/Doc/routerList.js
index 2f744257..5c371d29 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":"drag","title":"Drag插件"},{"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":"drag","title":"Drag plugin"},{"path":"introduction","title":"Introduction"},{"path":"keyboardNavigation","title":"KeyboardNavigation plugin"},{"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"}]}]
+ export default [{"lang":"zh","children":[{"path":"batchExecution","title":"BatchExecution实例"},{"path":"changelog","title":"Changelog"},{"path":"command","title":"Command实例"},{"path":"constructor","title":"构造函数"},{"path":"doExport","title":"Export 插件"},{"path":"drag","title":"Drag插件"},{"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":"Export plugin"},{"path":"drag","title":"Drag plugin"},{"path":"introduction","title":"Introduction"},{"path":"keyboardNavigation","title":"KeyboardNavigation plugin"},{"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 8668d41b..b3efdbe3 100644
--- a/web/src/pages/Doc/zh/constructor/index.md
+++ b/web/src/pages/Doc/zh/constructor/index.md
@@ -293,6 +293,8 @@ mindMap.updateConfig({
### export(type, isDownload, fileName)
+> 需要先注册`Export`插件
+
导出
`type`:要导出的类型,可选值:png、svg、json、pdf(v0.2.1+)、smm(本质也是json)
diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue
index 2f211d83..3855070d 100644
--- a/web/src/pages/Doc/zh/constructor/index.vue
+++ b/web/src/pages/Doc/zh/constructor/index.vue
@@ -604,6 +604,9 @@ mindMap.setTheme('主题名称')
获取思维导图数据
withConfig:Boolean,默认为false,即获取的数据只包括节点树,如果传true则会包含主题、布局、视图等数据
+需要先注册
+Export插件
导出
type:要导出的类型,可选值:png、svg、json、pdf(v0.2.1+)、smm(本质也是json)
isDownload:是否需要直接触发下载,布尔值,默认为false
doExport实例负责导出,可通过mindMap.doExport获取到该实例
Export插件提供导出的功能。
import MindMap from 'simple-mind-map'
+import Export from 'simple-mind-map/src/Export.js'
+
+MindMap.usePlugin(Export)
+
+注册完且实例化MindMap后可通过mindMap.doExport获取到该实例。
导出为png,异步方法,返回图片数据,data:url数据,可以自行下载或显示