Giter Site home page Giter Site logo

xmindltd / xmind-sdk-js Goto Github PK

View Code? Open in Web Editor NEW
437.0 16.0 60.0 1.18 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 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

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"
},

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文件解析,要怎么读?

x

it was mistake you change my issue title

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 是常见场景吧)

[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、怀疑杀毒软件将文件误删,但未见提示和记录(待定)

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 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": []
          }
        ]
      }
    ]
  }
]

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.

怎么导出图像呢?

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

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

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

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.

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.

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 为什么不更新呢?什么时候更新呢?

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 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.

节点过多时,报错 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)

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.