提取导出类作为插件

This commit is contained in:
wanglin2 2023-01-17 15:21:02 +08:00
parent bd655839cb
commit 97bcc22abd
13 changed files with 61 additions and 23 deletions

View File

@ -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()

View File

@ -215,4 +215,6 @@ class Export {
}
}
Export.instanceName = 'doExport'
export default Export

View File

@ -167,4 +167,6 @@ class Select {
}
}
Select.instanceName = 'select'
export default Select

View File

@ -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+),

View File

@ -612,6 +612,9 @@ redo. All commands are as follows:</p>
includes the node tree, if <code>true</code> is passed, it will also include theme, layout,
view, etc. data</p>
<h3>export(type, isDownload, fileName)</h3>
<blockquote>
<p>You need to register the <code>Export</code> plugin first</p>
</blockquote>
<p>Export</p>
<p><code>type</code>: the type to be exported, optional values: png, svg, json, pdf (v0.2.1+),
smm (essentially also json)</p>

View File

@ -1,7 +1,17 @@
# DoExport instance
# Export plugin
The `doExport` instance is responsible for exporting and can be obtained through
`mindMap.doExport`.
The `Export` plugin provides the export function.
## Register
```js
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`.
## Methods

View File

@ -1,8 +1,14 @@
<template>
<div>
<h1>DoExport instance</h1>
<p>The <code>doExport</code> instance is responsible for exporting and can be obtained through
<code>mindMap.doExport</code>.</p>
<h1>Export plugin</h1>
<p>The <code>Export</code> plugin provides the export function.</p>
<h2>Register</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map&#x27;</span>
<span class="hljs-keyword">import</span> Export <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/Export.js&#x27;</span>
MindMap.usePlugin(Export)
</code></pre>
<p>After registration and instantiation of <code>MindMap</code>, the instance can be obtained through <code>mindMap.doExport</code>.</p>
<h2>Methods</h2>
<h3>png()</h3>
<p>Exports as <code>png</code>, an async method that returns image data, <code>data:url</code> data which

View File

@ -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"}]}]

View File

@ -293,6 +293,8 @@ mindMap.updateConfig({
### export(type, isDownload, fileName)
> 需要先注册`Export`插件
导出
`type`要导出的类型可选值png、svg、json、pdfv0.2.1+、smm本质也是json

View File

@ -604,6 +604,9 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<p>获取思维导图数据</p>
<p><code>withConfig</code><code>Boolean</code>默认为<code>false</code>即获取的数据只包括节点树如果传<code>true</code>则会包含主题布局视图等数据</p>
<h3>export(type, isDownload, fileName)</h3>
<blockquote>
<p>需要先注册<code>Export</code>插件</p>
</blockquote>
<p>导出</p>
<p><code>type</code>要导出的类型可选值pngsvgjsonpdfv0.2.1+smm本质也是json</p>
<p><code>isDownload</code>是否需要直接触发下载布尔值默认为<code>false</code></p>

View File

@ -1,6 +1,17 @@
# DoExport实例
# Export 插件
`doExport`实例负责导出,可通过`mindMap.doExport`获取到该实例
`Export`插件提供导出的功能。
## 注册
```js
import MindMap from 'simple-mind-map'
import Export from 'simple-mind-map/src/Export.js'
MindMap.usePlugin(Export)
```
注册完且实例化`MindMap`后可通过`mindMap.doExport`获取到该实例。
## 方法

View File

@ -1,7 +1,14 @@
<template>
<div>
<h1>DoExport实例</h1>
<p><code>doExport</code>实例负责导出可通过<code>mindMap.doExport</code>获取到该实例</p>
<h1>Export 插件</h1>
<p><code>Export</code>插件提供导出的功能</p>
<h2>注册</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map&#x27;</span>
<span class="hljs-keyword">import</span> Export <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/Export.js&#x27;</span>
MindMap.usePlugin(Export)
</code></pre>
<p>注册完且实例化<code>MindMap</code>后可通过<code>mindMap.doExport</code>获取到该实例</p>
<h2>方法</h2>
<h3>png()</h3>
<p>导出为<code>png</code>异步方法返回图片数据<code>data:url</code>数据可以自行下载或显示</p>

View File

@ -25,6 +25,7 @@ import MindMap from 'simple-mind-map'
import MiniMap from 'simple-mind-map/src/MiniMap.js'
import Watermark from 'simple-mind-map/src/Watermark.js'
import KeyboardNavigation from 'simple-mind-map/src/KeyboardNavigation.js'
import Export from 'simple-mind-map/src/Export.js'
import Drag from 'simple-mind-map/src/Drag.js'
import Outline from './Outline'
import Style from './Style'
@ -49,6 +50,7 @@ MindMap
.usePlugin(Watermark)
.usePlugin(Drag)
.usePlugin(KeyboardNavigation)
.usePlugin(Export)
//
customThemeList.forEach((item) => {