├── .eslintrc.json
├── .githooks
└── pre-commit
│ └── filter.sh
├── .github
└── workflows
│ └── codeql.yml
├── .gitignore
├── .nycrc.json
├── .travis.yml
├── LICENSE
├── README.md
├── appveyor.yml
├── docs
├── edge.graphic.txt
├── en.md
└── icons.md
├── example
├── example.browser.html
├── example.destroy.js
├── example.easy.js
├── example.fully.js
├── example.image.browser.html
├── example.image.js
├── example.jsx
├── example.marker.js
└── example.summary.js
├── package-lock.json
├── package.json
├── rollup.config.ts
├── scripts
├── browserify.js
├── icons.js
└── marker.js
├── src
├── abstracts
│ ├── marker.abstract.ts
│ ├── note.abstract.ts
│ ├── summary.abstract.ts
│ ├── topic.abstract.ts
│ └── workbook.abstract.ts
├── browser.ts
├── common
│ ├── constants
│ │ ├── index.ts
│ │ └── marker.ts
│ ├── model.ts
│ ├── templates
│ │ └── content.xml
│ └── themes
│ │ ├── business.json
│ │ ├── robust.json
│ │ └── snowbrush.json
├── core
│ ├── base.ts
│ ├── marker.ts
│ ├── note.ts
│ ├── summary.ts
│ ├── theme.ts
│ ├── topic.ts
│ └── workbook.ts
├── index.ts
└── utils
│ ├── common.ts
│ ├── dumper.ts
│ └── zipper.ts
├── test
├── browser
│ └── index.html
├── fixtures
│ ├── 19442.png
│ ├── logo.png
│ └── utils.ts
├── functional
│ └── index.test.ts
├── mocha.opts
└── units
│ ├── common.test.ts
│ ├── dumper.test.ts
│ ├── marker.test.ts
│ ├── theme.test.ts
│ ├── topic.test.ts
│ ├── workbook.test.ts
│ └── zip.test.ts
├── tsconfig.json
└── tslint.json
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "@typescript-eslint/parser",
3 | "parserOptions": {
4 | "ecmaVersion": 6,
5 | "sourceType": "module",
6 | "ecmaFeatures": {
7 | "jsx": false,
8 | "modules": true
9 | },
10 | "useJSXTextNode": true,
11 | "project": "./tsconfig.json",
12 | "tsconfigRootDir": ".",
13 | "extraFileExtensions": [".ts"]
14 | },
15 | "plugins": [
16 | "@typescript-eslint/tslint"
17 | ],
18 | "rules": {
19 | "@typescript-eslint/tslint/config": ["error", {
20 | "lintFile": "./tslint.json",
21 | "rulesDirectory": []
22 | }]
23 | }
24 | }
--------------------------------------------------------------------------------
/.githooks/pre-commit/filter.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | EMAIL=$(git config user.email)
5 |
6 | npm run lint
7 |
8 | if [[ $? != 0 ]]; then
9 | echo "lint error."
10 | exit 1;
11 | fi
12 |
13 | if [[ ${EMAIL} == *"xmind"* ]]; then
14 | echo "Do not use *@xmind.net email to commit codes.";
15 | exit 1;
16 | else
17 | exit 0
18 | fi
19 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ "master" ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ "master" ]
20 | schedule:
21 | - cron: '15 23 * * 4'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'javascript' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38 |
39 | steps:
40 | - name: Checkout repository
41 | uses: actions/checkout@v3
42 |
43 | # Initializes the CodeQL tools for scanning.
44 | - name: Initialize CodeQL
45 | uses: github/codeql-action/init@v2
46 | with:
47 | languages: ${{ matrix.language }}
48 | # If you wish to specify custom queries, you can do so here or in a config file.
49 | # By default, queries listed here will override any specified in a config file.
50 | # Prefix the list here with "+" to use these queries and those in the config file.
51 |
52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53 | # queries: security-extended,security-and-quality
54 |
55 |
56 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
57 | # If this step fails, then you should remove it and run the build manually (see below)
58 | - name: Autobuild
59 | uses: github/codeql-action/autobuild@v2
60 |
61 | # ℹ️ Command-line programs to run using the OS shell.
62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63 |
64 | # If the Autobuild fails above, remove it and uncomment the following three lines.
65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66 |
67 | # - run: |
68 | # echo "Run, Build Application using script"
69 | # ./location_of_script_within_repo/buildscript.sh
70 |
71 | - name: Perform CodeQL Analysis
72 | uses: github/codeql-action/analyze@v2
73 | with:
74 | category: "/language:${{matrix.language}}"
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | dist
3 |
4 | # Mac os
5 | .DS_Store
6 |
7 | # webstorm
8 | .idea
9 |
10 | docs/typedocs
11 |
12 | # vscode
13 | .vscode
14 |
15 | ### Node template
16 | # Logs
17 | logs
18 | *.log
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 |
23 | # Runtime data
24 | pids
25 | *.pid
26 | *.seed
27 | *.pid.lock
28 |
29 | # Directory for instrumented libs generated by jscoverage/JSCover
30 | lib-cov
31 |
32 | # Coverage directory used by tools like istanbul
33 | coverage
34 |
35 | # nyc test coverage
36 | .nyc_output
37 |
38 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
39 | .grunt
40 |
41 | # Bower dependency directory (https://bower.io/)
42 | bower_components
43 |
44 | # node-waf configuration
45 | .lock-wscript
46 |
47 | # Compiled binary addons (https://nodejs.org/api/addons.html)
48 | build/Release
49 |
50 | # Dependency directories
51 | node_modules/
52 | jspm_packages/
53 |
54 | # TypeScript v1 declaration files
55 | typings/
56 |
57 | # Optional npm cache directory
58 | .npm
59 |
60 | # Optional eslint cache
61 | .eslintcache
62 |
63 | # Optional REPL history
64 | .node_repl_history
65 |
66 | # Output of 'npm pack'
67 | *.tgz
68 |
69 | # Yarn Integrity file
70 | .yarn-integrity
71 |
72 | # dotenv environment variables file
73 | .env
74 |
75 | # next.js build output
76 | .next
77 |
78 | .idea/encodings.xml
79 | .idea/misc.xml
80 | .idea/modules.xml
81 | .idea/workspace.xml
82 | .idea/xmind-sdk.iml
83 |
--------------------------------------------------------------------------------
/.nycrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@istanbuljs/nyc-config-typescript",
3 | "all": true,
4 | "check-coverage": false,
5 | "exclude": [
6 | "src/abstracts",
7 | "src/common",
8 | "src/index.ts",
9 | "src/browser.ts",
10 | "test/",
11 | "example/",
12 | "dist/",
13 | "scripts/",
14 | "**/*.d.ts",
15 | "docs",
16 | "coverage",
17 | "rollup.config.ts"
18 | ],
19 | "extension": [".ts"],
20 | "reporter": ["html", "text", "lcov"],
21 | "require": ["ts-node/register"]
22 | }
23 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "8"
5 | - "10"
6 | - "12"
7 |
8 | install:
9 | - npm i
10 | - npm i ts-node # --require ts-node/register
11 |
12 | before_script:
13 | - npm run lint
14 | - npm run build
15 |
16 | script:
17 | - npm run test
18 | - npm run cov
19 | - npm run clean
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 - 2023 Xmind Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 📦 📦 📦 
2 |
3 | [](https://github.com/xmindltd/xmind-sdk-js/actions/workflows/codeql.yml)
4 | [](https://ci.appveyor.com/project/danielsss/xmind-sdk-js/branch/master)
5 | [](https://www.codacy.com/gh/xmindltd/xmind-sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xmindltd/xmind-sdk-js&utm_campaign=Badge_Grade)
6 | 
7 | 
8 | [](https://xmind.app)
9 |
10 | This project is a lightweight official software development kit for JavaScript/Typescript which is available for browsers and Node.js.
11 |
12 | 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.
13 |
14 | 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.
15 |
16 | Eventually, Our UI apps could be used to open the `*.xmind` file generated by this tool.
17 |
18 |
19 | ## Recommendations
20 |
21 | * [Xmind AI](https://xmind.works) - It's a lightweight online `Mind-Map` tool comes with AI features which helps you to build everything you wanted.
22 | * [Xmind-generator](https://github.com/xmindltd/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.
23 |
24 |
25 | ## Supported Platforms
26 |
27 | * Linux
28 | * Win32
29 | * Browser (Not Fully Supported)
30 |
31 | ## Usage and Getting Started
32 |
33 | ### Node.js
34 |
35 | ```shell
36 | $ npm i --save xmind
37 | ```
38 |
39 | > NOTICE: The `xmind-sdk` is renamed to `xmind` from the version: 2.0.0
40 | >
41 | > Please, use `npm i --save xmind` to replace with it if you were using the `xmind-sdk`.
42 |
43 |
44 | ```js
45 | const { Workbook, Topic, Marker } = require('xmind');
46 | ```
47 |
48 | ### Browser or Vue.js
49 |
50 | ```jsx harmony
51 | import { Workbook, Topic, Marker } from 'xmind';
52 | ```
53 |
54 | ```html
55 | // HTML
56 | // Latest version
57 |
58 | // Specify version
59 |
60 |
61 |
64 | ```
65 |
66 |
67 | ### More Examples
68 |
69 |
70 | See [example directory](./example).
71 |
72 | ```js
73 | const { Workbook, Topic, Marker, Zipper } = require('xmind');
74 |
75 | const [ workbook, marker ] = [new Workbook(), new Marker()];
76 |
77 | const topic = new Topic({sheet: workbook.createSheet('sheet title', 'Central Topic')});
78 | const zipper = new Zipper({path: '/tmp', workbook, filename: 'MyFirstMap'});
79 |
80 | // topic.on() default: `central topic`
81 | topic.add({title: 'main topic 1'});
82 |
83 | topic
84 | .on(topic.cid(/*In default, the componentId is last element*/))
85 |
86 | // add subtopics under `main topic 1`
87 | .add({title: 'subtopic 1'})
88 | .add({title: 'subtopic 2'})
89 |
90 | // attach text note to `main topic 1`
91 | .note('This is a note attached on main topic 1')
92 |
93 | // attach a marker flag to `subtopic 1`
94 | .on(topic.cid('subtopic 1'))
95 | .marker(marker.week('fri'))
96 |
97 | // add a component of the summary that contains two sub topics
98 | .summary({title: 'subtopic summary', edge: topic.cid('subtopic 2')})
99 |
100 | zipper.save().then(status => status && console.log('Saved /tmp/MyFirstMap.xmind'));
101 | ```
102 |
103 |
104 | ## Workbook
105 |
106 | The workbook is a temporary storage where all the data are written.
107 |
108 | ### Methods
109 |
110 | #### .createSheet(sheetTitle, topicTitle?) => `Sheet`
111 |
112 | Once the workbook is created, then there's a way to build a sheet containing a `root topic`.
113 | In addition, you can customize their titles by parameters.
114 |
115 |
116 | | Name | Type | Default | Required |
117 | |:---- |:----:|:-------:|:--------:|
118 | | sheetTitle | String | `-` | Y |
119 | | topicTitle | String | `Central Topic` | N |
120 |
121 | #### .createSheets(options: Object[]) => `Object[]`
122 |
123 | You can use this method to create sheets in bulk.
124 |
125 |
126 | | Name | Type | Default | Required |
127 | |:---- |:----:|:-------:|:--------:|
128 | | sheetTitle | String | `-` | Y |
129 | | topicTitle | String | `Central Topic` | N |
130 |
131 | It returns an object of sheet identifier([Click here to check how it uses](./example/example.fully.js)).
132 |
133 | ```typescript
134 | const sheets = workbook.createSheets([
135 | {s: 'SheetTitle1', t: 'RootTopicTitle1'},
136 | {s: 'SheetTitle2', t: 'RootTopicTitle2'}
137 | ]);
138 | console.info(sheets);
139 | // [
140 | // { id: string, title: string },
141 | // { id: string, title: string }
142 | // ...
143 | // ]
144 | ```
145 |
146 | #### .getSheets() => `Object[]`
147 |
148 | It allows you to get back the identifier of the sheet anytime and anywhere.
149 |
150 | #### .getSheet(id: string) => `Sheet`
151 |
152 | You can get an instance of the sheet with an existed sheet ID.
153 |
154 | #### .theme(sheetTitle, themeName) => Boolean
155 |
156 | The `UI client` has many theme styles and this library also offers some of them, such as `robust / snowbrush / business`.
157 |
158 | | Name | Type | Default | Required |
159 | |:---- |:----:|:-------:|:--------:|
160 | | sheetTitle | String | null | Y |
161 | | themeName | String | null | Y |
162 |
163 | #### .toJSON()
164 |
165 | Get component's data from the workbook in the form of `JSON`.
166 |
167 | #### .toString()
168 |
169 | Get component's data from the workbook in the form of `STRING`.
170 |
171 | #### .validate() => `{status: Boolean, errors: Array