1.0.2 • Published 3 years ago

xmindparser v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

xmindparser

一个简单的javascript模块,用于Xmind 双向格式转换

安装

使用(npm)源安装,npm install xmindparser

可用脚本

npm run test

运行测试程序.\ See the section about running tests for more information.

快速开始

xmind转json

const xmindparser = require('xmindparser');
let parser = new xmindparser()
//xmind转脑图 json 支持二进制文件或url和本地目录
const fileOrPath = 'test.xmind' 
parser.xmindToJSON(fileOrPath).then(json => {
    console.log(json)
})

json转xmind

const xmindparser = require('xmindparser');
let parser = new xmindparser()
const json = {
   "template": "default",
   "theme": "fresh-blue",
   "root": {
       "data": {"text": "中心主题", "note": "", "imageSize": {}},
       "children": [{
           "children": [{"children": [], "data": {"text": "新建节点", "note": "", "imageSize": {}}}],
           "data": {"text": "新建节点", "note": "", "imageSize": {}}
       }, {
           "children": [{"children": [], "data": {"text": "新建节点", "note": "", "imageSize": {}}}],
           "data": {"text": "新建节点", "note": "", "imageSize": {}}
       }, {"children": [], "data": {"text": "新建节点", "note": "", "imageSize": {}}}, {
           "children": [],
           "data": {"text": "新建节点", "note": "", "imageSize": {}}
       }, {"children": [], "data": {"text": "新建节点", "note": "", "imageSize": {}}}, {
           "children": [],
           "data": {"text": "新建节点", "note": "", "imageSize": {}}
       }]
   }
}

//脑图 json转xmind 浏览器返回blob node返回pathurl
const fileOrPath = 'test.xmind' 
parser.JSONToXmind(json,outputPath).then(data => {
    console.log(data)
})

Methods

.xmindToJSON(params)

NameTypeDefaultRequired
params(path,url,buffer,blob)-Y

.JSONToXmind(json,outputPath)

NameTypeDefaultRequired
json(object)-Y
outputPathstringpath.join(__dirname, '../')node:Y