GithubHelp home page GithubHelp logo

xmindltd / xmind-sdk-js Goto Github PK

View Code? Open in Web Editor NEW
422.0 16.0 58.0 1.35 MB

This is a lightweight official software development kit to help people who wants to build the mapping file without the UI client and It's also supported to run in Browser or Node.js.

Home Page: https://xmind.app

License: MIT License

JavaScript 26.24% TypeScript 70.19% Shell 0.15% HTML 3.43%
xmind mindmap mindmapping sdk xmind-sdk xmind-sdk-js xmind-sdk-ts

xmind-sdk-js's Introduction

📦 📦 📦

CodeQL Build status Codacy Badge npm GitHub npm (scoped)

This project is a lightweight official software development kit for JavaScript/Typescript which is available for browsers and Node.js.

This library implements various functions which are similar to our UI applications, and You might know the basic concepts of this library if you've used the application before.

In order to use it conveniently, an essential concept you should know is that everything is a component and each one of them has a unique component ID. You can add a child node under the components, however, the Markers and Notes can only be attached to the components.

Eventually, Our UI apps could be used to open the *.xmind file generated by this tool.

Recommendations

  • Xmind AI - It's a lightweight online Mind-Map tool comes with AI features which helps you to build everything you wanted.
  • Xmind-generator — If you are looking for a tool specifically designed for Mind-Map generation, Xmind Generator is an official package that prioritizes this functionality, featuring a modern and lightweight API.

Supported Platforms

  • Linux
  • Win32
  • Browser (Not Fully Supported)

Usage and Getting Started

Node.js

$ npm i --save xmind

NOTICE: The xmind-sdk is renamed to xmind from the version: 2.0.0

Please, use npm i --save xmind to replace with it if you were using the xmind-sdk.

const { Workbook, Topic, Marker } = require('xmind');

Browser or Vue.js

import { Workbook, Topic, Marker } from 'xmind';
// HTML
// Latest version
<script src="https://cdn.jsdelivr.net/npm/xmind/dist/xmind.min.js"></script>
// Specify version
<!-- script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/xmind.min.js"></script -->

<script>
  const { Workbook, Topic, Marker } = window;
</script>

More Examples

See example directory.

const { Workbook, Topic, Marker, Zipper } = require('xmind');

const [ workbook, marker ] = [new Workbook(), new Marker()];

const topic = new Topic({sheet: workbook.createSheet('sheet title', 'Central Topic')});
const zipper = new Zipper({path: '/tmp', workbook, filename: 'MyFirstMap'});

// topic.on() default: `central topic`
topic.add({title: 'main topic 1'});

topic
  .on(topic.cid(/*In default, the componentId is last element*/))
  
  // add subtopics under `main topic 1`
  .add({title: 'subtopic 1'})
  .add({title: 'subtopic 2'})
   
   // attach text note to `main topic 1`
  .note('This is a note attached on main topic 1')
  
  // attach a marker flag to `subtopic 1`
  .on(topic.cid('subtopic 1'))
  .marker(marker.week('fri'))
   
   // add a component of the summary that contains two sub topics
  .summary({title: 'subtopic summary', edge: topic.cid('subtopic 2')})
  
zipper.save().then(status => status && console.log('Saved /tmp/MyFirstMap.xmind'));

Workbook

The workbook is a temporary storage where all the data are written.

Methods

.createSheet(sheetTitle, topicTitle?) => Sheet

Once the workbook is created, then there's a way to build a sheet containing a root topic. In addition, you can customize their titles by parameters.

Name Type Default Required
sheetTitle String - Y
topicTitle String Central Topic N

.createSheets(options: Object[]) => Object[]

You can use this method to create sheets in bulk.

Name Type Default Required
sheetTitle String - Y
topicTitle String Central Topic N

It returns an object of sheet identifier(Click here to check how it uses).

const sheets = workbook.createSheets([
  {s: 'SheetTitle1', t: 'RootTopicTitle1'},
  {s: 'SheetTitle2', t: 'RootTopicTitle2'}
]);
console.info(sheets);
// [
//   { id: string, title: string },
//   { id: string, title: string }
//   ...
// ]

.getSheets() => Object[]

It allows you to get back the identifier of the sheet anytime and anywhere.

.getSheet(id: string) => Sheet

You can get an instance of the sheet with an existed sheet ID.

.theme(sheetTitle, themeName) => Boolean

The UI client has many theme styles and this library also offers some of them, such as robust / snowbrush / business.

Name Type Default Required
sheetTitle String null Y
themeName String null Y

.toJSON()

Get component's data from the workbook in the form of JSON.

.toString()

Get component's data from the workbook in the form of STRING.

.validate() => {status: Boolean, errors: Array<object> | null}

This is the way to prove that all data are available and complete.

The status indicates the result of validation which is true if it's correct, otherwise false returns.

Topic

The Topic is an important constructor function that implements most of the methods. And you're going to depend on it during most operations.

Topic Options

  • options.sheet <= workbook.createSheet(...)

You may wonder why we need to offer the options.sheet manually? The reason is that Topic is implemented independently and most of the methods depend on the instance of the sheet.

In the UI client, you also need to draw the mind map on the sheet.

usage:

const {Topic, Workbook} = require('xmind');
const wb = new Workbook();

new Topic({sheet: wb.createSheet('Sheet-1', 'topic-1')});

Methods

.on(componentId?) => Topic

Set the component to be parent node. If there isn't component ID, the Central Topic will become as parent node.

.cid(title?, options?: { customId?: string, parentId?: string }) => String

Use this method to get componentId.

You should use customId or parentId for getting the componentId if there are some duplicated topic titles.

If you don't specify the title in the period of calling .cid(), the last componentId that you've added would be returned.

.cids() => {$cid: $title}

It will return all the key/values in once.

.add(options) => Topic

Add a topic component under parent node.

Name Type Default Required
options.title String null Y
options.parentId String The previous topic that you've operated on N
options.customId String It would be useful if you have the same topic title N

.note(text, del?) => Topic

Attach a text to parent node.

Name Type Default Required Description
text String null Y text message
del Boolean false N detach the note from current parent node if the del is true

.addLabel(text) => Topic

Add label text to the component, also you can add label to the same component many times.

Name Type Default Required Description
text String null Y label text string

.removeLabels(componentId?) => Topic

Remove all the labels from the component.

If you don't give the componentId, then remove labels from the currently component.

Name Type Default Required Description
componentId String null N -

.marker(object) => Topic

Attach a marker flag to the parent node. Moreover, you can detach a marker flag from the parent node by setting object.del as true. Default: false

Example:

const {Marker} = require('xmind');
const marker = new Marker();
// add
topic.marker(marker.smiley('cry'));
// del
topic.marker(Object.assign({}, marker.smiley('cry'), {del: true}));

Use Marker Object to generate the object

.image() => key

You can use .image() to get image key back.

However, you need to write image into manifest by zip.updateManifestMetadata() or dumper.updateManifestMetadata().

See image example See image in browser example

.summary(options) => Topic

Attach a summary component to parent node including all children. In the meantime, the edge can be used to set the scope of summary component.

Important

The summary doesn't allow to be added under Central Topic

The edge must parallel to parent node

Name Type Default Required
options.title String null Y
options.edge String null N

About edge

.destroy(componentId) => Topic

Destroy a component from the map tree.

Important

All children would be destroyed along with it

Marker flags

We provide an instance of Marker that includes all the markers. Such as:

.priority(name: string)
.smiley(name: string)
.task(name: string)
.flag(name: string)
.star(name: string)
.people(name: string)
.arrow(name: string)
.symbol(name: string)
.month(name: string)
.week(name: string)
.half(name: string)
.other(name: string)

The name of marker is available !here

You can also use the Marker.groups and Marker.names to find out available names of Marker.

Static methods

Marker.groups() => Array<groupName>

List available group names.

Marker.names(groupName) => Array<name>

  • Get the flag names by groupName.

Zipper

The module of Zipper only works under backend.

!See Dumper in browser environment

Zipper Options

Name Type Default Required Description
options.path String - Y The path is where to save the .xmind file
options.workbook Workbook - Y The instance of Workbook
options.filename String default N default.xmind

.updateManifestMetadata(key, content) => Zipper

Update manifest for image insertion.

Name Type Default Required Description
key String null Y The key only can get by topic.image()
content Buffer null Y The buffer data of image

.removeManifestMetadata(key) => Zipper

Remove a pair of key / value from manifest.

.save() => Promise<boolean>

Save components to the logic disk in the form of zip.

Dumper

The module of Dumper only works under browser.

Dumper methods

.dumping() => Array<{filename: string, value: string}>

Return an array of objects composed of file content. In order to open it in the official software, you need to compress these files in the form of zip with the suffix .xmind.

Important

Don't include top level folders, otherwise the software can't extract files

.updateManifestMetadata(key, content, creator) => Promise<void>

Update manifest for image insertion.

Name Type Default Required Description
key string null Y The key only can get by topic.image()
content File | Blob | ArrayBuffer null Y The data of image
creator FileCreator Y To specify how to save the file

where FileCreator is

interface FileCreator {
  /**
   * Hint that should create a folder-like structure, enter the folder if exists
   * @param name - Folder name
   */
  folder(name: string): Promise<void>
  
  /**
   * Hint that should create a file-like object with `content`, update the file if exists
   * @param name Filename
   */
  file(name: string, content: File | Blob | ArrayBuffer): Promise<void>
}

Contributing

Thank you for being interested in the SDK.

If you have any problems or suggestions, please let's know. 🙂

We also welcome you to submit a pull request for any big or small issues.

License

See the MIT License.

xmind-sdk-js's People

Contributors

danielsss avatar dependabot[bot] avatar edmanchen avatar tomtiao avatar zhangzhonghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xmind-sdk-js's Issues

节点过多时,报错 Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded
at D:\project\test\xmind\node_modules\tree-model\index.js:269:63
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:214:26)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)
at Node.depthFirstPreOrder (D:\project\test\xmind\node_modules\tree-model\index.js:219:38)

How to generate a horizontal tree?

I was trying to use the browser version of the SDK to generate a org-chart. But it seems no such configurations to make the tree horizontal. Please help. Thanks.

I have XMind to SQL

I just found this project. I see a note in the README that in the future there may be an official API into .xmind file/archives. I would welcome that API. (EDIT: My mistake: I mis-read the text in the readme.)

I would publish this somewhere else but I don't know where info like this might be visible to XMind users.

I recently wrote an app that extracts content.json from a .xmind file, and generates related SQL tables from maps that define database schema. This is a private, personal, non-commercial project by a self-employed developer. It is written in JavaScript over NodeJS, and is currently dedicated to MySQL. It will be enhanced with TypeScript and at some point should support other databases.

SQL is not a featured export option even for XMind Pro. I was thinking that when this is ready for general use I might purchase a Pro license, to be compliant with terms and to benefit from extended features. Then I am considering offer SaaS to process documents into schema. After that, the code might be FOSS'd.

Now that I'm familiar with the .xmind schema, and at some point I might look into this xmind-sdk-js to do the reverse, generating maps from SQL. There are tons of applications for that.

If XMind Ltd or anyone else is interested in this, please let me know. This is not yet ready for use by anyone else, but as I learn more about use cases from this audience, I'll add more features to prepare for whatever comes from this later.

Thanks for your time.

请问python的sdk为什么不继续更新了呢?

最近在使用python xmind sdk 的时候发现,无法大开xmind2022的文件,出现的结果如下:
Warning 警告 Attention Warnung 경고This file can not be opened normally, please do not modify and save, otherwise the contents will be permanently lost!该文件无法正常打开,请勿修改并保存,否则文件内容将会永 久性丢失!該文件無法正常打開,請勿修改並保存,否則文件內容 AttentionWarnung경고This file can not be opened normally, please do not modify and save, otherwise the contents will be permanently lost!该文件无法正常打开,请勿修改并保存,否则文件内容将会永 久性丢失!該文件無法正常打開,請勿修改並保存,否則文件內容 將會永久性丟失!この文書は正常に開かないので、修正して保存 しないようにしてください。そうでないと、書類の内容が永久に 失われます。!Datei kann nicht richtig geöffnet werden. Bitte ändern Sie diese Datei nicht und speichern Sie sie, sonst wird die Datei endgültig gelöscht werden.Ce fichier ne peut pas ouvert normalement, veuillez le rédiger et sauvegarder, sinon le fichier sera perdu en permanence. 파일을 정상 적으로 열 수 없으며, 수정 및 저장하지 마십시오. 그렇지 않으면 파일의 내용이 영구적으로 손실됩니다!
请问是否是python sdk 的版本问题,导致不能大开xmind2020的文件,如果是,python sdk 为什么不更新呢?什么时候更新呢?

import existing mindmap?

Is it possible to export an existing xmind mindmap into a format where I can work with it in the sdk?

Too early to support loading existing files

This project was started from scratch, and currently still lacks a bunch of required models/components, such as attachment management. Supporting loading existing files at this point will be buggy and hard to maintain. For example, when loading a .xmind file containing topic images and just saving it back, the image will be lost.

So I would recommend reverting this feature and keeping steady on building up the model layer, until we finally support all required models and components, and implement this feature then. At the present time, I would rather make this project only support creating new .xmind files, than see it becoming a buggy one that no one like to use.

In the meantime, we still welcome suggestions and ideas about loading existing files. We would like to know further about what you want this feature for. This will help us evaluate how to design the API as well as the inner infrastructure.

FYI, for those who want to load and display/render existing .xmind files, there is another project "xmind-viewer" specifically made for this purpose.

x

it was mistake you change my issue title

documentation: boundaries, styles?

Hi,

Thanks for this project.
I've been reading the documentation and trying the XMind-sdk-js. I can't find a way to add boundaries, styles, or change summary curly braces from curly to round.

Could you provide an example? Is the SDK on par with the UI ?

Thanks in advance.

怎么导出图像呢?

我想要自动创建 XMind 文件并导出为图像,自动插入到我这边的工作流程里面,请问需要怎么做?如果不能在 SDK 里面完成,我的 XMind 已经开了会员了,请问有命令行什么的自动导出为图像吗?

[BUG]broswer使用插件时报错 Cannot find module './robust-fdb2b57a.json'

出现背景:昨天使用 npm install 安装xmind,照示例简单使用一切正常,次日启动项目开发调试,编译阶段就报该错误。
报错如下:
image

Node版本:
image

出现问题代码:
依赖,xmind版本 v2.2.29
image
使用
image
代码在函数内,初始化未调用,在编译阶段红色的代码就已经报错了,注释或去掉代码后运行正常

尝试解决:
1、删除xmind依赖重新安装(未解决)
2、清除项目node_modules和lock,重新install(未解决)
3、怀疑杀毒软件将文件误删,但未见提示和记录(待定)

Import Error: Workbook is not a constructor

hey, i want to know hot to use it in my project
I follow the steps:
npm i xmind
import { Workbook, Topic, Marker, Zipper } from 'xmind';
but it reported an error " xmind__WEBPACK_IMPORTED_MODULE_0__.Workbook is not a constructor "

Hope to get a reply thanks

Broken sourcemap

WARNING in ./node_modules/xmind/dist/core/topic.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/xxx/xxx/node_modules/xmind/src/core/topic.ts' file: Error: ENOENT: no such file or directory, open '/home/xxx/xxx/node_modules/xmind/src/core/topic.ts'
 @ ./node_modules/xmind/dist/browser.js 17:16-39
  • Cannot use debugger to step in functions of the library in browser DevTools, unless turn off Enable JavaScript source maps in the DevTools settings.

This can be fixed by

  1. publish the package with the typescript code
  2. or use inlineSources options in tsconfig to include the code in the sourcemap file
  3. or don't emit the sourcemap at all

Options 1 and 2 will both increase the published size of the package.

  • Rollup warns "Broken sourcemap" when bundling

To reproduce, run command npm run rollup. It seems that rollup-plugin-minification doesn't return the transformed sourcemap after the minification. Since the plugin is no longer maintained, consider migrating to @rollup/plugin-terser.

(!) Broken sourcemap
https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect
Plugins that transform code (such as "minification") should generate accompanying sourcemaps.

I will open a draft pr first and push fixes based on your feedback.

#88

destroy error

this is destroy example:


'use strict';

const { Workbook, Topic, Zipper, Marker } = require('xmind');

const workbook = new Workbook();
const topic = new Topic({sheet: workbook.createSheet('sheet-1', 'central topic')});

const marker = new Marker();
const zip = new Zipper({path: '/tmp', workbook});

const mainTopic1 = topic.add({title: 'main topic 1'}).cid();
const mainTopic2 = topic.add({title: 'main topic 2'}).cid();
const mainTopic3 = topic.add({title: 'repeated'}).cid();
const mainTopic4 = topic.add({title: 'repeated'}).cid();


topic
  .on(mainTopic1)
  .add({title: 'subtopic 1'})
  .add({title: 'subtopic 2'});

const subtopic1 = topic.on(mainTopic3).add({title: 'subtopic 1'}).cid();
topic.on(subtopic1)
  .note('this is a note text')
  .marker(marker.smiley('cry'))
  // destroy marker from current component
  .marker(Object.assign({}, marker.smiley('cry'), {del: true}));
  
const summaryId = topic.summary({title: 'Summary'}).cid();

// The destroyed operation does not depends on the parent node
topic
  .destroy(topic.cid('subtopic 2'))
  .destroy(mainTopic4)
  .destroy(summaryId)
  .destroy(mainTopic2);

zip.save().then(status => status && console.log('Saved'));

the result shows in xmind2020 APP:
Screen Shot 2020-06-09 at PM15 19 11

ERROR is that program is to destroy maintopic2 but sdk destroy maintopic1.

How to create a workbook with multiple sheets ?

Hello,
I would like to create a workbook with multiple sheets.
To do so I called new Topic with workbook.createSheet multiple time with different name.
But when I save to a file using Zipper only the latest sheet is visible in Xmind.

Here is my code:

#!/usr/bin/env node
const { Workbook, Topic, Marker, Zipper } = require('xmind');

const [workbook, marker] = [new Workbook(), new Marker()];
const zipper = new Zipper({path: './', workbook, filename: 'MyFirstMap'});

data = require('./test.json')

function add_data(topic, parent_name, node) {
    console.log(parent_name, node)
    new_node = topic.on(topic.cid(parent_name)).add({"title": node.name}).cid()
    if (node.childs) {
        node.childs.forEach(child => add_data(topic, node.name, child))
    }
}

function add_sheet(element) {
    // console.log(element)
    const topic = new Topic({sheet: workbook.createSheet(element.name, element.name)});
    element.childs.forEach(child => add_data(topic, element.name, child))
}

data.forEach(child => add_sheet(child))

zipper.save().then(status => status && console.log('Saved MyFirstMap.xmind'));

Example of test.json

[
  {
    "name": "All",
    "childs": [
      {
        "name": "N/A",
        "childs": [
          {
            "name": "Test-123",
            "childs": []
          }
        ]
      }
    ]
  },
  {
    "name": "Other",
    "childs": [
      {
        "name": "Plop",
        "childs": [
          {
            "name": "Test-456",
            "childs": []
          }
        ]
      }
    ]
  }
]

Need help In Reconstructing MindMap

It's less of an Issue but I do need help here.

I tried to make some kind of translator in this by making the Xmin into a JSON which then after I translate, I will reconstruct.

But I have encountered a problem where while some of the topics are connected porperly, there are others that are connected to something unrelated.
This is the JSON I have.

{
  "title": "Mind Map",
  "topic": {
    "title": "Indonesia",
    "topics": [
      {
        "title": "Eat well",
        "topics": [
          {
            "title": "I'm hungry"
          },
          {
            "title": "seems delicious"
          }
        ]
      },
      {
        "title": "minum manis",
        "topics": [
          {
            "title": "What's up"
          },
          {
            "title": "Good Morning"
          }
        ]
      },
      {
        "title": "mantap"
      },
      {
        "title": "I'm happy"
      }
    ]
  },
  "structure": "org.xmind.ui.map.clockwise"
}

and the code I made it with

const {Workbook, Topic, Marker, Zipper} = require('xmind');

function findParent(data, title, parent = null) {
    if (data.title === title) {
        return parent;
    }
    if (data.topics) {
        for (let topic of data.topics) {
            let result = findParent(topic, title, data.title);
            if (result) {
                return result;
            }
        }
    }
    if (data.topic) {
        return findParent(data.topic, title, data.title);
    }
    return null;
}

function main(){
    // Create a new Workbook instance
    const workbook = new Workbook();
    // Create a Topic for the central topic "Indonesia"
    const translated_JSON = require('./translated_data.json');
    const rootTopic = translated_JSON.topic;
    const rootTopicData = new Topic({sheet: workbook.createSheet(translated_JSON.title, rootTopic.title)});
    const currentDir = __dirname;
    const zipper = new Zipper({path: currentDir, workbook, filename: rootTopic.title});
    
    // Add subtopics recursively
    addSubtopics(rootTopic.topics);
    // Save the mind map
    zipper.save().then(status => {
        if (status) {
            console.log(`Saved ${__dirname}/${rootTopic.title}.xmind`);
        } else {
            console.error('Failed to save the mind map.');
        }
    });


    function addSubtopics(topics){
        if (topics.length === 0) return;
        topicNull = []
        console.log(topics)
        topics.forEach(topicData => {
                    if (rootTopicData.cid(findParent(translated_JSON, topicData.title)) == null){
                        console.log(topicData.title, "no parent")
                        rootTopicData.add({ title: topicData.title }).on(rootTopicData.cid("Central Topic"));
                        
                    }
                    else{
                        console.log(topicData.title,rootTopicData.cid(findParent(translated_JSON, topicData.title)) )
                        rootTopicData.add({ title: topicData.title }).on(rootTopicData.cid(findParent(translated_JSON, topicData.title)));
                    }
                    
                                        // Recursively add subtopics
                    if (topicData.topics && topicData.topics.length > 0) {
                        addSubtopics(topicData.topics);
                    }
                });
                
    }
}

main()

And it returns this
image

when it should be

image

It could be my algorithm thinking is wrong but also I don't really understand the SDK here. so any help would be appreciated :)

How to insert image in the by this SDK?

I havent found the example for image insert in the examples is image insert supported.
I really need it. If so, please give me a example of inserting image. Thx in advance.

Is there a way to load the xmind file ?

Here is the thing I need a program to auto add image after I done with the xmind file without image. I may add some key word on the node which will be inserted with image.

I check the example of the code seems no way to load a xmind file. So I ask if there is a way to make it ? Thank you in advance.

0.5.0升级到2.2.0

原先的 open: Workbook.open 方法没了,现在要读取xmind文件解析,要怎么读?

TpeError: Class extends value undefined is not a constructor or null

ts vue3 node v16.14.2 引入之后就报错:

import { Workbook } from 'xmind';
console.log("🚀 ~ file: index.vue:4 ~ Workbook:", Workbook)

报错‘TpeError: Class extends value undefined is not a constructor or null’ 依赖如下

"dependencies": {
"@iconify-json/carbon": "^1.1.16",
"@pureadmin/table": "^2.0.0",
"@pureadmin/utils": "^1.8.5",
"@soerenmartius/vue3-clipboard": "^0.1.2",
"@unocss/reset": "^0.50.6",
"@vitejs/plugin-legacy": "^4.0.2",
"@vitejs/plugin-vue": "^4.1.0",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vue-macros/volar": "^0.9.1",
"@vueuse/core": "^9.13.0",
"@vueuse/integrations": "^9.13.0",
"@vueuse/motion": "2.0.0-beta.12",
"autoprefixer": "^10.4.14",
"axios": "^1.3.4",
"dayjs": "^1.11.7",
"echarts": "^5.4.1",
"element-plus": "^2.3.1",
"lodash-es": "^4.17.21",
"nprogress": "^0.2.0",
"pinia": "^2.0.33",
"pinia-plugin-persistedstate": "^3.1.0",
"postcss": "^8.4.21",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-html": "^1.5.0",
"postcss-scss": "^4.0.6",
"qs": "^6.11.1",
"rollup-plugin-visualizer": "^5.9.0",
"sass": "^1.59.3",
"typescript": "^5.0.2",
"unocss": "^0.50.6",
"unplugin-auto-import": "^0.15.1",
"unplugin-vue-components": "^0.24.1",
"unplugin-vue-macros": "^1.10.2",
"vform3-builds": "^3.0.10",
"vite": "^4.2.1",
"vite-plugin-cdn-import": "^0.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-html": "^3.2.0",
"vite-plugin-imagemin": "^0.6.1",
"vite-plugin-mkcert": "^1.13.3",
"vite-plugin-style-import": "^2.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vue": "^3.2.47",
"vue-router": "^4.1.6",
"xmind": "^2.2.28"
},
"devDependencies": {
"@antfu/eslint-config": "^0.37.0",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"chalk": "^4.0.0",
"commitizen": "^4.3.0",
"cz-git": "^1.6.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.9.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"prettier": "^2.8.6",
"pretty-quick": "^3.1.3",
"stylelint": "^15.3.0",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-standard": "^31.0.0",
"stylelint-config-standard-scss": "^7.0.1",
"stylelint-order": "^6.0.3",
"taze": "^0.9.1",
"vue-tsc": "^1.2.0"
},

How to generate xmind with json or array

If I have data like

[
  {
    title: 'subtopic 1',
    submmary: 'summary'
  },
  {
    title: 'subtopic 2',
  },
  {
    title: 'subtopic 1'
  }
]
  1. How can I use xmind-sdk to generate xmind file with array or json?
    Now i am using the api like add and summary.Is there a simpler way to go directly convert xmind file?

  2. How can I find the second subtopic 1

Cannot locate the topic accurately if there is an identical topic existing at the same time.

为什么只能通过 title 去获取 component Id 呢?有重复的 title 的时候就获取不到想要获取的正确的 topic 了,例如我有两个子主题的 title 同时为 A ,然后我需要在第二个 A 下添加一个子 title ,我只能通过 topic.on(topic.cid('A')).add({title: 'child for A'}) 去添加,但是这样是添加到第一个 A 下。(存在相同主题 title 是常见场景吧)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.