将xmind解析方法从MindMap类上移除,改为按需引入方式使用

This commit is contained in:
wanglin2
2023-01-17 11:19:59 +08:00
parent 660906e4c5
commit 92ee241ed8
13 changed files with 163 additions and 139 deletions

View File

@@ -14,7 +14,6 @@ import MiniMap from './src/MiniMap'
import Watermark from './src/Watermark'
import { layoutValueList } from './src/utils/constant'
import { SVG } from '@svgdotjs/svg.js'
import xmind from './src/parse/xmind'
import { simpleDeepClone } from './src/utils'
import KeyboardNavigation from './src/KeyboardNavigation'
import defaultTheme from './src/themes/default'
@@ -357,8 +356,6 @@ class MindMap {
}
}
MindMap.xmind = xmind
// 定义新主题
MindMap.defineTheme = (name, config = {}) => {
if (theme[name]) {

View File

@@ -22,7 +22,7 @@
"format": "prettier --write ."
},
"module": "index.js",
"main": "./dist/simpleMindMap.umd.min.js",
"__main": "./dist/simpleMindMap.umd.min.js",
"dependencies": {
"@svgdotjs/svg.js": "^3.0.16",
"canvg": "^3.0.7",

View File

@@ -24,6 +24,7 @@ let APIList = [
'command',
'select',
'batchExecution',
'xmind',
'utils'
]

View File

@@ -20,50 +20,6 @@ const mindMap = new MindMap({
});
```
## Xmind Parsing Method
> v0.2.7+
You can get the `Xmind` parsing method as follows:
```js
import MindMap from "simple-mind-map";
console.log(MindMap.xmind);
```
The `MindMap.xmind` object has two methods attached:
### parseXmindFile(file)
Parsing the `.xmind` file and returning the parsed data. Note that this is
complete data, including the node tree, theme, and structure. You can use
`mindMap.setFullData(data)` to render the returned data to the canvas.
`file`: `File` object
### transformXmind(content)
Convert `xmind` data. The `.xmind` file is essentially a `zip` file that can be
decompressed by changing the suffix to zip. Inside, there is a `content.json`
file. If you have parsed this file yourself, you can pass the contents of this
file to this method for conversion. The converted data is the complete data,
including the node tree, theme, structure, etc. You can use
`mindMap.setFullData(data)` to render the returned data to the canvas.
`content`: the contents of the `content.json` file within the `.xmind` zip
package
### transformOldXmind(content)
> v0.2.8+
For data parsing of the `xmind8` version, because the `.xmind` file in this
version does not have a `content.json`, it corresponds to `content.xml`.
`content`: the contents of the `content.xml` file within the `.xmind` zip
package
## Instantiation options
| Field Name | Type | Default Value | Description | Required |

View File

@@ -16,38 +16,6 @@
}
});
</code></pre>
<h2>Xmind Parsing Method</h2>
<blockquote>
<p>v0.2.7+</p>
</blockquote>
<p>You can get the <code>Xmind</code> parsing method as follows:</p>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;simple-mind-map&quot;</span>;
<span class="hljs-built_in">console</span>.log(MindMap.xmind);
</code></pre>
<p>The <code>MindMap.xmind</code> object has two methods attached:</p>
<h3>parseXmindFile(file)</h3>
<p>Parsing the <code>.xmind</code> file and returning the parsed data. Note that this is
complete data, including the node tree, theme, and structure. You can use
<code>mindMap.setFullData(data)</code> to render the returned data to the canvas.</p>
<p><code>file</code>: <code>File</code> object</p>
<h3>transformXmind(content)</h3>
<p>Convert <code>xmind</code> data. The <code>.xmind</code> file is essentially a <code>zip</code> file that can be
decompressed by changing the suffix to zip. Inside, there is a <code>content.json</code>
file. If you have parsed this file yourself, you can pass the contents of this
file to this method for conversion. The converted data is the complete data,
including the node tree, theme, structure, etc. You can use
<code>mindMap.setFullData(data)</code> to render the returned data to the canvas.</p>
<p><code>content</code>: the contents of the <code>content.json</code> file within the <code>.xmind</code> zip
package</p>
<h3>transformOldXmind(content)</h3>
<blockquote>
<p>v0.2.8+</p>
</blockquote>
<p>For data parsing of the <code>xmind8</code> version, because the <code>.xmind</code> file in this
version does not have a <code>content.json</code>, it corresponds to <code>content.xml</code>.</p>
<p><code>content</code>: the contents of the <code>content.xml</code> file within the <code>.xmind</code> zip
package</p>
<h2>Instantiation options</h2>
<table>
<thead>

View File

@@ -0,0 +1,43 @@
# XMind parse
> v0.2.7+
Provides methods for importing `XMind` files.
## Import
```js
import xmind from 'simple-mind-map/src/parse/xmind.js'
```
## Methods
### xmind.parseXmindFile(file)
Parsing the `.xmind` file and returning the parsed data. Note that this is
complete data, including the node tree, theme, and structure. You can use
`mindMap.setFullData(data)` to render the returned data to the canvas.
`file`: `File` object
### xmind.transformXmind(content)
Convert `xmind` data. The `.xmind` file is essentially a `zip` file that can be
decompressed by changing the suffix to zip. Inside, there is a `content.json`
file. If you have parsed this file yourself, you can pass the contents of this
file to this method for conversion. The converted data is the complete data,
including the node tree, theme, structure, etc. You can use
`mindMap.setFullData(data)` to render the returned data to the canvas.
`content`: the contents of the `content.json` file within the `.xmind` zip
package
### xmind.transformOldXmind(content)
> v0.2.8+
For data parsing of the `xmind8` version, because the `.xmind` file in this
version does not have a `content.json`, it corresponds to `content.xml`.
`content`: the contents of the `content.xml` file within the `.xmind` zip
package

View File

@@ -0,0 +1,46 @@
<template>
<div>
<h1>XMind parse</h1>
<blockquote>
<p>v0.2.7+</p>
</blockquote>
<p>Provides methods for importing <code>XMind</code> files.</p>
<h2>Import</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> xmind <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/parse/xmind.js&#x27;</span>
</code></pre>
<h2>Methods</h2>
<h3>xmind.parseXmindFile(file)</h3>
<p>Parsing the <code>.xmind</code> file and returning the parsed data. Note that this is
complete data, including the node tree, theme, and structure. You can use
<code>mindMap.setFullData(data)</code> to render the returned data to the canvas.</p>
<p><code>file</code>: <code>File</code> object</p>
<h3>xmind.transformXmind(content)</h3>
<p>Convert <code>xmind</code> data. The <code>.xmind</code> file is essentially a <code>zip</code> file that can be
decompressed by changing the suffix to zip. Inside, there is a <code>content.json</code>
file. If you have parsed this file yourself, you can pass the contents of this
file to this method for conversion. The converted data is the complete data,
including the node tree, theme, structure, etc. You can use
<code>mindMap.setFullData(data)</code> to render the returned data to the canvas.</p>
<p><code>content</code>: the contents of the <code>content.json</code> file within the <code>.xmind</code> zip
package</p>
<h3>xmind.transformOldXmind(content)</h3>
<blockquote>
<p>v0.2.8+</p>
</blockquote>
<p>For data parsing of the <code>xmind8</code> version, because the <code>.xmind</code> file in this
version does not have a <code>content.json</code>, it corresponds to <code>content.xml</code>.</p>
<p><code>content</code>: the contents of the <code>content.xml</code> file within the <code>.xmind</code> zip
package</p>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>

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":"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实例"}]},{"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"}]}]
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"}]}]

View File

@@ -20,40 +20,6 @@ const mindMap = new MindMap({
});
```
## Xmind解析方法
> v0.2.7+
可以通过如下方法获取解析`Xmind`文件的方法:
```js
import MindMap from "simple-mind-map";
console.log(MindMap.xmind)
```
`MindMap.xmind`对象上挂载了两个方法:
### parseXmindFile(file)
解析`.xmind`文件,返回解析后的数据,注意是完整的数据,包含节点树、主题、结构等,可以使用`mindMap.setFullData(data)`来将返回的数据渲染到画布上
`file``File`对象
### transformXmind(content)
转换`xmind`数据,`.xmind`文件本质上是一个压缩包,改成`zip`后缀可以解压缩,里面存在一个`content.json`文件,如果你自己解析出了这个文件,那么可以把这个文件内容传递给这个方法进行转换,转换后的数据,注意是完整的数据,包含节点树、主题、结构等,可以使用`mindMap.setFullData(data)`来将返回的数据渲染到画布上
`content``.xmind`压缩包内的`content.json`文件内容
### transformOldXmind(content)
> v0.2.8+
针对`xmind8`版本的数据解析,因为该版本的`.xmind`文件内没有`content.json`,对应的是`content.xml`
`content``.xmind`压缩包内的`content.xml`文件内容
## 实例化选项
| 字段名称 | 类型 | 默认值 | 描述 | 是否必填 |

View File

@@ -16,28 +16,6 @@
}
});
</code></pre>
<h2>Xmind解析方法</h2>
<blockquote>
<p>v0.2.7+</p>
</blockquote>
<p>可以通过如下方法获取解析<code>Xmind</code>文件的方法</p>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;simple-mind-map&quot;</span>;
<span class="hljs-built_in">console</span>.log(MindMap.xmind)
</code></pre>
<p><code>MindMap.xmind</code>对象上挂载了两个方法</p>
<h3>parseXmindFile(file)</h3>
<p>解析<code>.xmind</code>文件返回解析后的数据注意是完整的数据包含节点树主题结构等可以使用<code>mindMap.setFullData(data)</code>来将返回的数据渲染到画布上</p>
<p><code>file</code><code>File</code>对象</p>
<h3>transformXmind(content)</h3>
<p>转换<code>xmind</code>数据<code>.xmind</code>文件本质上是一个压缩包改成<code>zip</code>后缀可以解压缩里面存在一个<code>content.json</code>文件如果你自己解析出了这个文件那么可以把这个文件内容传递给这个方法进行转换转换后的数据注意是完整的数据包含节点树主题结构等可以使用<code>mindMap.setFullData(data)</code>来将返回的数据渲染到画布上</p>
<p><code>content</code><code>.xmind</code>压缩包内的<code>content.json</code>文件内容</p>
<h3>transformOldXmind(content)</h3>
<blockquote>
<p>v0.2.8+</p>
</blockquote>
<p>针对<code>xmind8</code>版本的数据解析因为该版本的<code>.xmind</code>文件内没有<code>content.json</code>对应的是<code>content.xml</code></p>
<p><code>content</code><code>.xmind</code>压缩包内的<code>content.xml</code>文件内容</p>
<h2>实例化选项</h2>
<table>
<thead>

View File

@@ -0,0 +1,33 @@
# XMind解析
> v0.2.7+
提供导入`XMind`文件的方法。
## 引入
```js
import xmind from 'simple-mind-map/src/parse/xmind.js'
```
## 方法
### xmind.parseXmindFile(file)
解析`.xmind`文件,返回解析后的数据,注意是完整的数据,包含节点树、主题、结构等,可以使用`mindMap.setFullData(data)`来将返回的数据渲染到画布上
`file``File`对象
### xmind.transformXmind(content)
转换`xmind`数据,`.xmind`文件本质上是一个压缩包,改成`zip`后缀可以解压缩,里面存在一个`content.json`文件,如果你自己解析出了这个文件,那么可以把这个文件内容传递给这个方法进行转换,转换后的数据,注意是完整的数据,包含节点树、主题、结构等,可以使用`mindMap.setFullData(data)`来将返回的数据渲染到画布上
`content``.xmind`压缩包内的`content.json`文件内容
### xmind.transformOldXmind(content)
> v0.2.8+
针对`xmind8`版本的数据解析,因为该版本的`.xmind`文件内没有`content.json`,对应的是`content.xml`
`content``.xmind`压缩包内的`content.xml`文件内容

View File

@@ -0,0 +1,36 @@
<template>
<div>
<h1>XMind解析</h1>
<blockquote>
<p>v0.2.7+</p>
</blockquote>
<p>提供导入<code>XMind</code>文件的方法</p>
<h2>引入</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> xmind <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/parse/xmind.js&#x27;</span>
</code></pre>
<h2>方法</h2>
<h3>xmind.parseXmindFile(file)</h3>
<p>解析<code>.xmind</code>文件返回解析后的数据注意是完整的数据包含节点树主题结构等可以使用<code>mindMap.setFullData(data)</code>来将返回的数据渲染到画布上</p>
<p><code>file</code><code>File</code>对象</p>
<h3>xmind.transformXmind(content)</h3>
<p>转换<code>xmind</code>数据<code>.xmind</code>文件本质上是一个压缩包改成<code>zip</code>后缀可以解压缩里面存在一个<code>content.json</code>文件如果你自己解析出了这个文件那么可以把这个文件内容传递给这个方法进行转换转换后的数据注意是完整的数据包含节点树主题结构等可以使用<code>mindMap.setFullData(data)</code>来将返回的数据渲染到画布上</p>
<p><code>content</code><code>.xmind</code>压缩包内的<code>content.json</code>文件内容</p>
<h3>xmind.transformOldXmind(content)</h3>
<blockquote>
<p>v0.2.8+</p>
</blockquote>
<p>针对<code>xmind8</code>版本的数据解析因为该版本的<code>.xmind</code>文件内没有<code>content.json</code>对应的是<code>content.xml</code></p>
<p><code>content</code><code>.xmind</code>压缩包内的<code>content.xml</code>文件内容</p>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>

View File

@@ -32,7 +32,7 @@
</template>
<script>
import MindMap from 'simple-mind-map'
import xmind from 'simple-mind-map/src/parse/xmind.js'
import { fileToBuffer } from '@/utils'
import { read, utils } from 'xlsx'
@@ -146,7 +146,7 @@ export default {
*/
async handleXmind(file) {
try {
let data = await MindMap.xmind.parseXmindFile(file.raw)
let data = await xmind.parseXmindFile(file.raw)
this.$bus.$emit('setData', data)
this.$message.success('导入成功')
} catch (error) {