Skip to content

Commit 3757979

Browse files
authored
It's a nice time to release v2.0.0 during golden week!
v2.0.0
2 parents 82519af + 76c7754 commit 3757979

37 files changed

+752
-1142
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
dist
2-
src/__tests__
3-
**/*.d.ts
2+
src/__tests__

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@
4545
"@typescript-eslint/parser": "^5.52.0",
4646
"babel-loader": "^8.0.6",
4747
"better-docs": "^2.3.2",
48-
"canvg": "^3.0.6",
4948
"css-loader": "^6.7.1",
5049
"docdash": "^1.1.1",
5150
"eslint": "^8.34.0",
5251
"eslint-config-prettier": "^8.6.0",
5352
"eslint-plugin-prettier": "^4.2.1",
54-
"file-loader": "^6.2.0",
5553
"html-webpack-plugin": "^5.3.2",
5654
"husky": "^8.0.3",
5755
"jest": "^27.5.1",

readme.cn.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
![mindelixir logo](https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo.png)
1+
<p align="center"><a href="mind-elixir.com" target="_blank" rel="noopener noreferrer"><img width="150" src="https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo2.png" alt="mindelixir logo2"></a></p>
22

3-
<p>
3+
<p align="center">
44
<a href="https://www.npmjs.com/package/mind-elixir">
55
<img src="https://img.shields.io/npm/v/mind-elixir" alt="version">
66
</a>
@@ -78,17 +78,17 @@ let options = {
7878
direction: MindElixir.LEFT,
7979
// create new map data
8080
data: MindElixir.new('new topic') or example,
81-
// the data return from `.getAllData()`
81+
// the data return from `.getData()`
8282
draggable: true, // default true
8383
contextMenu: true, // default true
8484
toolBar: true, // default true
8585
nodeMenu: true, // default true
8686
keypress: true, // default true
8787
locale: 'en', // [zh_CN,zh_TW,en,ja,pt] waiting for PRs
8888
overflowHidden: false, // default false
89-
primaryLinkStyle: 2, // [1,2] default 1
90-
primaryNodeVerticalGap: 15, // default 25
91-
primaryNodeHorizontalGap: 15, // default 65
89+
mainLinkStyle: 2, // [1,2] default 1
90+
mainNodeVerticalGap: 15, // default 25
91+
mainNodeHorizontalGap: 15, // default 65
9292
contextMenuOption: {
9393
focus: true,
9494
link: true,
@@ -165,9 +165,9 @@ mind.bus.addListener('expandNode', node => {
165165
### 数据导出
166166

167167
```javascript
168-
mind.getAllData() // javascript object, see src/example.js
169-
mind.getAllDataString() // stringify object
170-
mind.getAllDataMd() // markdown
168+
mind.getData() // javascript object, see src/example.js
169+
mind.getDataString() // stringify object
170+
mind.getDataMd() // markdown
171171
```
172172

173173
### 输出图片
@@ -207,7 +207,3 @@ let mind = new MindElixir({
207207
## 文档
208208

209209
https://doc.mind-elixir.com/
210-
211-
## 感谢
212-
213-
[canvg](https://github.com/canvg/canvg)

readme.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
![mindelixir logo](https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo.png)
1+
<p align="center"><a href="mind-elixir.com" target="_blank" rel="noopener noreferrer"><img width="150" src="https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo2.png" alt="mindelixir logo2"></a></p>
22

3-
<p>
3+
<p align="center">
44
<a href="https://www.npmjs.com/package/mind-elixir">
55
<img src="https://img.shields.io/npm/v/mind-elixir" alt="version">
66
</a>
@@ -20,11 +20,13 @@
2020

2121
Mind elixir is a free open source mind map core.
2222

23+
- Zero dependency
2324
- High performance
2425
- Lightweight
2526
- Framework agnostic
2627
- Pluginable
2728
- Build-in drag and drop / node edit plugin
29+
- Styling your node with CSS
2830

2931
<details>
3032
<summary>Table of Contents</summary>
@@ -46,6 +48,7 @@ Mind elixir is a free open source mind map core.
4648
- [Event Handling](#event-handling)
4749
- [Data Export And Import](#data-export-and-import)
4850
- [Operation Guards](#operation-guards)
51+
- [Theme](#theme)
4952
- [Not only core](#not-only-core)
5053

5154
</details>
@@ -66,11 +69,11 @@ https://mind-elixir.com/
6669

6770
https://codepen.io/ssshooter/pen/GVQRYK
6871

69-
#### Use with React
72+
#### Use with React
7073

7174
https://codesandbox.io/s/mind-elixir-react-9sisb
7275

73-
#### Use with Vue
76+
#### Use with Vue
7477

7578
https://codesandbox.io/s/mind-elixir-vue-nqjjl
7679

@@ -128,9 +131,9 @@ let options = {
128131
keypress: true, // default true
129132
locale: 'en', // [zh_CN,zh_TW,en,ja,pt,ru] waiting for PRs
130133
overflowHidden: false, // default false
131-
primaryLinkStyle: 2, // [1,2] default 1
132-
primaryNodeVerticalGap: 15, // default 25
133-
primaryNodeHorizontalGap: 15, // default 65
134+
mainLinkStyle: 2, // [1,2] default 1
135+
mainNodeVerticalGap: 15, // default 25
136+
mainNodeHorizontalGap: 15, // default 65
134137
contextMenuOption: {
135138
focus: true,
136139
link: true,
@@ -162,7 +165,7 @@ mind.install(plugin) // install your plugin
162165
// create new map data
163166
const data = MindElixir.new('new topic')
164167
// or `example`
165-
// or the data return from `.getAllData()`
168+
// or the data return from `.getData()`
166169
mind.init(data)
167170

168171
// get a node
@@ -173,7 +176,7 @@ E('node-id')
173176

174177
```javascript
175178
// whole node data structure up to now
176-
nodeData = {
179+
const nodeData = {
177180
topic: 'node topic',
178181
id: 'bd1c24420cd2c2f5',
179182
style: { fontSize: '32', color: '#3298db', background: '#ecf0f1' },
@@ -182,10 +185,10 @@ nodeData = {
182185
icons: ['😀'],
183186
hyperLink: 'https://github.com/ssshooter/mind-elixir-core',
184187
image: {
185-
url: 'https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo.png', // required
188+
url: 'https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo2.png', // required
186189
// you need to query the height and width of the image and calculate the appropriate value to display the image
187190
height: 90, // required
188-
width: 300, // required
191+
width: 90, // required
189192
},
190193
children: [
191194
{
@@ -227,9 +230,9 @@ mind.bus.addListener('expandNode', node => {
227230

228231
```javascript
229232
// data export
230-
const data = mind.getAllData() // javascript object, see src/example.js
231-
mind.getAllDataString() // stringify object
232-
mind.getAllDataMd() // markdown
233+
const data = mind.getData() // javascript object, see src/example.js
234+
mind.getDataString() // stringify object
235+
mind.getDataMd() // markdown
233236

234237
// data import
235238
// initiate
@@ -263,6 +266,28 @@ let mind = new MindElixir({
263266
})
264267
```
265268

269+
## Theme
270+
271+
```javascript
272+
const options = {
273+
// ...
274+
theme: {
275+
name: 'Dark',
276+
// main lines color palette
277+
palette: ['#848FA0', '#748BE9', '#D2F9FE', '#4145A5', '#789AFA', '#706CF4', '#EF987F', '#775DD5', '#FCEECF', '#DA7FBC'],
278+
// overwrite css variables
279+
cssVar: {
280+
'--main-color': '#ffffff',
281+
'--main-bgcolor': '#4c4f69',
282+
'--color': '#cccccc',
283+
'--bgcolor': '#252526',
284+
},
285+
// all variables see /src/index.less
286+
},
287+
// ...
288+
}
289+
```
290+
266291
## Not only core
267292

268293
- [@mind-elixir/export-xmind](https://github.com/ssshooter/export-xmind)

src/__tests__/nodeOperation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('nodeOperation', () => {
7272
await m.moveNode(from, to)
7373

7474
const domCheck =
75-
from.closest('children').previousElementSibling === to.parentNode
75+
from.closest('me-children').previousElementSibling === to.parentNode
7676

7777
from = from.nodeObj
7878
to = to.nodeObj
@@ -90,7 +90,7 @@ describe('nodeOperation', () => {
9090
await m.moveNodeBefore(from, to)
9191

9292
const domCheck =
93-
from.closest('grp') === to.closest('grp').previousElementSibling
93+
from.closest('me-wrapper') === to.closest('me-wrapper').previousElementSibling
9494

9595
from = from.nodeObj
9696
to = to.nodeObj
@@ -112,7 +112,7 @@ describe('nodeOperation', () => {
112112
await m.moveNodeAfter(from, to)
113113

114114
const domCheck =
115-
from.closest('grp').previousElementSibling === to.closest('grp')
115+
from.closest('me-wrapper').previousElementSibling === to.closest('me-wrapper')
116116

117117
from = from.nodeObj
118118
to = to.nodeObj
@@ -142,7 +142,7 @@ describe('nodeOperation', () => {
142142
expect(res[1]).toBeFalsy()
143143

144144
const delRoot = await page.evaluate(async() => {
145-
const el = E('root')
145+
const el = E('me-root')
146146
try {
147147
await m.removeNode(el)
148148
} catch (err) {

src/const.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ export const RIGHT = 1
33
export const SIDE = 2
44
export const DOWN = 3
55

6-
export const GAP = 20 // must sync with --gap in index.less
7-
export const PRIMARY_NODE_HORIZONTAL_GAP = 65
8-
export const PRIMARY_NODE_VERTICAL_GAP = 25
6+
export const GAP = 30 // must sync with --gap in index.less
7+
export const MAIN_NODE_HORIZONTAL_GAP = 65
8+
export const MAIN_NODE_VERTICAL_GAP = 25
99
export const TURNPOINT_R = 8
10+
export const THEME = {
11+
name: 'Latte',
12+
palette: ['#dd7878', '#ea76cb', '#8839ef', '#e64553', '#fe640b', '#df8e1d', '#40a02b', '#209fb5', '#1e66f5', '#7287fd'],
13+
cssVar: {
14+
'--main-color': '#444446',
15+
'--main-bgcolor': '#ffffff',
16+
'--color': '#777777',
17+
'--bgcolor': '#f6f6f6',
18+
},
19+
}

src/dev.dist.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ const mind = new MindElixir({
4242
return true
4343
},
4444
},
45-
// primaryLinkStyle: 2,
46-
primaryNodeVerticalGap: 15, // 25
47-
primaryNodeHorizontalGap: 15, // 65
45+
// mainLinkStyle: 2,
46+
mainNodeVerticalGap: 15, // 25
47+
mainNodeHorizontalGap: 15, // 65
4848
})
4949
mind.init(example)
5050
function sleep() {

src/dev.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ const options = {
5555
return true
5656
},
5757
},
58-
primaryLinkStyle: 1,
59-
primaryNodeVerticalGap: 25, // 25
60-
primaryNodeHorizontalGap: 65, // 65
58+
mainLinkStyle: 1,
59+
mainNodeVerticalGap: 25, // 25
60+
mainNodeHorizontalGap: 65, // 65
6161
}
6262

6363
const mind = new (MindElixir as any)(options)

src/exampleData/1.cn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
nodeData: {
3-
id: 'root',
3+
id: 'me-root',
44
topic: 'Mind Elixir',
55
root: true,
66
children: [

src/exampleData/1.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
export default {
22
direction: 0,
3+
theme: {
4+
name: 'Dark',
5+
palette: ['#848FA0', '#748BE9', '#D2F9FE', '#4145A5', '#789AFA', '#706CF4', '#EF987F', '#775DD5', '#FCEECF', '#DA7FBC'],
6+
cssVar: {
7+
'--main-color': '#ffffff',
8+
'--main-bgcolor': '#4c4f69',
9+
'--color': '#cccccc',
10+
'--bgcolor': '#252526',
11+
},
12+
},
313
nodeData: {
4-
id: 'root',
14+
id: 'me-root',
515
topic: 'Mind Elixir',
616
root: true,
717
children: [
818
{
9-
topic: 'logo',
19+
topic: 'logo2',
1020
id: '56dae51a90d350a8',
1121
direction: 0,
1222
expanded: true,
1323
children: [
1424
{
1525
topic: 'mind-elixir',
1626
image: {
17-
url: 'https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo.png',
27+
url: 'https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo2.png',
1828
height: 90,
19-
width: 300,
29+
width: 90,
2030
},
2131
},
2232
],
@@ -26,7 +36,7 @@ export default {
2636
id: 'bd4313fbac40284b',
2737
direction: 0,
2838
expanded: true,
29-
branchColor: '#e64553',
39+
// branchColor: '#e64553',
3040
children: [
3141
{ topic: 'A mind map core', id: 'beeb823afd6d2114' },
3242
{ topic: 'Free', id: 'c1f068377de9f3a0' },
@@ -170,14 +180,6 @@ export default {
170180
id: 'bd41fd4ca32322a5',
171181
hyperLink: 'https://github.com/ssshooter/mind-elixir-core',
172182
},
173-
// {
174-
// topic: 'Image URL',
175-
// id: 'bd41fd4ca32322a6',
176-
// image: {
177-
// url: 'https://cdn.jsdelivr.net/gh/ssshooter/mind-elixir-core/logo.png',
178-
// width: 200,
179-
// },
180-
// },
181183
],
182184
},
183185
{

0 commit comments

Comments
 (0)