mind-elixir 5.0.0-beta.9 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,11 +20,6 @@ type NodeOperation = {
20
20
  name: 'moveNodeAfter' | 'moveNodeBefore' | 'moveNodeIn';
21
21
  objs: NodeObj[];
22
22
  toObj: NodeObj;
23
- } | {
24
- name: 'removeNode';
25
- obj: NodeObj;
26
- originIndex?: number;
27
- originParentId?: string;
28
23
  };
29
24
  type MultipleNodeOperation = {
30
25
  name: 'removeNodes';
@@ -64,8 +59,7 @@ export type EventMap = {
64
59
  selectNode: (nodeObj: NodeObj, e?: MouseEvent) => void;
65
60
  selectNewNode: (nodeObj: NodeObj) => void;
66
61
  selectNodes: (nodeObj: NodeObj[]) => void;
67
- unselectNode: () => void;
68
- unselectNodes: () => void;
62
+ unselectNodes: (nodeObj: NodeObj[]) => void;
69
63
  expandNode: (nodeObj: NodeObj) => void;
70
64
  linkDiv: () => void;
71
65
  scale: (scale: number) => void;
@@ -77,12 +71,12 @@ export type EventMap = {
77
71
  * please use throttling to prevent performance degradation
78
72
  */
79
73
  updateArrowDelta: (arrow: Arrow) => void;
74
+ showContextMenu: (e: MouseEvent) => void;
80
75
  };
81
76
  export declare function createBus<T extends Record<string, (...args: any[]) => void> = EventMap>(): {
82
77
  handlers: Record<keyof T, ((...arg: any[]) => void)[]>;
83
- showHandler: () => void;
84
78
  addListener: <K extends keyof T>(type: K, handler: T[K]) => void;
85
- fire: <K_1 extends keyof T>(type: K_1, ...payload: Parameters<T[K_1]>) => void;
86
- removeListener: <K_2 extends keyof T>(type: K_2, handler: T[K_2]) => void;
79
+ fire: <K extends keyof T>(type: K, ...payload: Parameters<T[K]>) => void;
80
+ removeListener: <K extends keyof T>(type: K, handler: T[K]) => void;
87
81
  };
88
82
  export {};
@@ -2,8 +2,16 @@ import type { Arrow } from '../arrow';
2
2
  import type { Summary } from '../summary';
3
3
  import type { MindElixirInstance } from '../types';
4
4
  import type { CustomSvg } from '../types/dom';
5
+ export declare const svgNS = "http://www.w3.org/2000/svg";
5
6
  export declare const createPath: (d: string, color: string, width: string) => SVGPathElement;
6
7
  export declare const createLinkSvg: (klass: string) => SVGSVGElement;
7
8
  export declare const createLine: () => SVGLineElement;
8
- export declare const createSvgGroup: (d: string, arrowd1: string, arrowd2: string) => CustomSvg;
9
+ export declare const createSvgGroup: (d: string, arrowd1: string, arrowd2: string, style?: {
10
+ stroke?: string;
11
+ strokeWidth?: string | number;
12
+ strokeDasharray?: string;
13
+ strokeLinecap?: "butt" | "round" | "square";
14
+ opacity?: string | number;
15
+ labelColor?: string;
16
+ }) => CustomSvg;
9
17
  export declare const editSvgText: (mei: MindElixirInstance, textEl: SVGTextElement, node: Summary | Arrow) => void;
@@ -1,4 +1,3 @@
1
1
  import type { MindElixirInstance } from '../types/index';
2
2
  import type { Theme } from '../types/index';
3
- declare const changeTheme: (this: MindElixirInstance, theme: Theme, shouldRefresh?: boolean) => void;
4
- export default changeTheme;
3
+ export declare const changeTheme: (this: MindElixirInstance, theme: Theme, shouldRefresh?: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mind-elixir",
3
- "version": "5.0.0-beta.9",
3
+ "version": "5.0.1",
4
4
  "type": "module",
5
5
  "description": "Mind elixir is a free open source mind map core.",
6
6
  "keywords": [
@@ -36,8 +36,14 @@
36
36
  "import": "./dist/example.js",
37
37
  "require": "./dist/example.js"
38
38
  },
39
+ "./LayoutSsr": {
40
+ "types": "./dist/types/utils/LayoutSsr.d.ts",
41
+ "import": "./dist/LayoutSsr.js",
42
+ "require": "./dist/LayoutSsr.js"
43
+ },
39
44
  "./readme.md": "./readme.md",
40
- "./package.json": "./package.json"
45
+ "./package.json": "./package.json",
46
+ "./style": "./dist/style.css"
41
47
  },
42
48
  "typesVersions": {
43
49
  "*": {
@@ -77,7 +83,8 @@
77
83
  "@types/node": "^20.14.2",
78
84
  "@typescript-eslint/eslint-plugin": "^5.62.0",
79
85
  "@typescript-eslint/parser": "^5.62.0",
80
- "@viselect/vanilla": "3.5.1",
86
+ "@viselect/vanilla": "3.9.0",
87
+ "@zumer/snapdom": "^1.3.0",
81
88
  "eslint": "^8.57.0",
82
89
  "eslint-config-prettier": "^8.10.0",
83
90
  "eslint-plugin-prettier": "^4.2.1",
@@ -86,7 +93,6 @@
86
93
  "lint-staged": "^13.3.0",
87
94
  "prettier": "2.8.4",
88
95
  "typescript": "^5.4.5",
89
- "vite": "^4.5.3",
90
- "vite-plugin-css-injected-by-js": "^3.5.1"
96
+ "vite": "^4.5.3"
91
97
  }
92
98
  }
package/readme.md CHANGED
@@ -34,19 +34,34 @@
34
34
 
35
35
  Mind elixir is a open source JavaScript mind map core. You can use it with any frontend framework you like.
36
36
 
37
- Features:
38
-
39
- - Lightweight
40
- - High performance
41
- - Framework agnostic
42
- - Pluginable
43
- - Build-in drag and drop / node edit plugin
44
- - Export as SVG / PNG / Html
45
- - Summarize nodes
46
- - Bulk operations supported
47
- - Undo / Redo
48
- - Efficient shortcuts
49
- - Easily Styling your node with CSS variables
37
+ ## Features
38
+
39
+ ### 🎨 **User Experience**
40
+
41
+ - **Fluent UX** - Smooth and intuitive interactions
42
+ - **Well designed** - Clean and modern interface
43
+ - **Mobile friendly** - Touch events for mobile devices
44
+ - **Efficient shortcuts** - Keyboard shortcuts for power users
45
+
46
+ ### **Performance & Architecture**
47
+
48
+ - **Lightweight** - Minimal bundle size
49
+ - **High performance** - Optimized for large mind maps
50
+ - **Framework agnostic** - Works with any frontend framework
51
+ - **Pluginable** - Extensible architecture
52
+
53
+ ### 🛠️ **Core Features**
54
+
55
+ - **Interactive editing** - Built-in drag and drop / node edit capabilities
56
+ - **Bulk operations** - Multi-node selection and operations
57
+ - **Undo / Redo** - Complete operation history
58
+ - **Node connections & summarization** - Custom node linking and content summarization
59
+
60
+ ### 📤 **Export & Customization**
61
+
62
+ - **Multiple export formats** - SVG / PNG / HTML export
63
+ - **Easy styling** - Customize mindmap with CSS variables
64
+ - **Theme support** - Built-in themes and custom styling
50
65
 
51
66
  <details>
52
67
  <summary>Table of Contents</summary>
@@ -64,29 +79,27 @@ Features:
64
79
  - [Data Export And Import](#data-export-and-import)
65
80
  - [Operation Guards](#operation-guards)
66
81
  - [Export as a Image](#export-as-a-image)
67
- - [Solution 1](#solution-1)
68
- - [Solution 2](#solution-2)
69
82
  - [Theme](#theme)
70
83
  - [Shortcuts](#shortcuts)
71
84
  - [Ecosystem](#ecosystem)
72
85
  - [Development](#development)
73
86
  - [Thanks](#thanks)
74
87
  - [Contributors](#contributors)
88
+ - [v5 Breaking Changes](#v5-breaking-changes)
75
89
 
76
90
  </details>
77
91
 
78
92
  ## Try now
79
93
 
80
- ![mindelixir](https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/screenshot2.png)
94
+ ![mindelixir](https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/screenshot5.jpg)
81
95
 
82
96
  https://mind-elixir.com/
83
97
 
84
98
  ### Playground
85
99
 
86
- - Vanilla JS - https://codepen.io/ssshooter/pen/OJrJowN
87
- - React - https://codesandbox.io/s/mind-elixir-3-x-react-18-x-vy9fcq
88
- - Vue3 - https://codesandbox.io/s/mind-elixir-3-x-vue3-lth484
89
- - Vue2 - https://codesandbox.io/s/mind-elixir-3-x-vue-2-x-5kdfjp
100
+ - Vanilla JS - https://codepen.io/ssshooter/pen/vEOqWjE
101
+ - React - https://codesandbox.io/p/devbox/mind-elixir-3-x-react-18-x-forked-f3mtcd
102
+ - Vue3 - https://codesandbox.io/p/sandbox/mind-elixir-3-x-vue3-lth484
90
103
 
91
104
  ## Documentation
92
105
 
@@ -103,7 +116,8 @@ npm i mind-elixir -S
103
116
  ```
104
117
 
105
118
  ```javascript
106
- import MindElixir from 'mind-elixir'
119
+ import MindElixir from 'mind-elixir';
120
+ import "mind-elixir/style";
107
121
  ```
108
122
 
109
123
  #### Script tag
@@ -112,6 +126,12 @@ import MindElixir from 'mind-elixir'
112
126
  <script type="module" src="https://cdn.jsdelivr.net/npm/mind-elixir/dist/MindElixir.js"></script>
113
127
  ```
114
128
 
129
+ And in your CSS file:
130
+
131
+ ```css
132
+ @import "https://cdn.jsdelivr.net/npm/mind-elixir/dist/style.css";
133
+ ```
134
+
115
135
  ### Init
116
136
 
117
137
  ```html
@@ -124,10 +144,9 @@ import MindElixir from 'mind-elixir'
124
144
  </style>
125
145
  ```
126
146
 
127
- **Breaking Change** since 1.0.0, `data` should be passed to `init()`, not `options`.
128
-
129
147
  ```javascript
130
148
  import MindElixir from 'mind-elixir'
149
+ import "mind-elixir/style";
131
150
  import example from 'mind-elixir/dist/example1'
132
151
 
133
152
  let options = {
@@ -155,11 +174,7 @@ let options = {
155
174
  ],
156
175
  },
157
176
  before: {
158
- insertSibling(el, obj) {
159
- return true
160
- },
161
- async addChild(el, obj) {
162
- await sleep()
177
+ insertSibling(type, obj) {
163
178
  return true
164
179
  },
165
180
  },
@@ -256,18 +271,8 @@ mind.refresh(data)
256
271
  let mind = new MindElixir({
257
272
  // ...
258
273
  before: {
259
- insertSibling(el, obj) {
260
- console.log(el, obj)
261
- if (this.currentNode.nodeObj.parent.root) {
262
- return false
263
- }
264
- return true
265
- },
266
274
  async addChild(el, obj) {
267
- await sleep()
268
- if (this.currentNode.nodeObj.parent.root) {
269
- return false
270
- }
275
+ await saveDataToDb()
271
276
  return true
272
277
  },
273
278
  },
@@ -276,26 +281,6 @@ let mind = new MindElixir({
276
281
 
277
282
  ## Export as a Image
278
283
 
279
- ### Solution 1
280
-
281
- ```typescript
282
- const mind = {
283
- /** mind elixir instance */
284
- }
285
- const downloadPng = async () => {
286
- const blob = await mind.exportPng() // Get a Blob!
287
- if (!blob) return
288
- const url = URL.createObjectURL(blob)
289
- const a = document.createElement('a')
290
- a.href = url
291
- a.download = 'filename.png'
292
- a.click()
293
- URL.revokeObjectURL(url)
294
- }
295
- ```
296
-
297
- ### Solution 2
298
-
299
284
  Install `@ssshooter/modern-screenshot`, then:
300
285
 
301
286
  ```typescript
@@ -303,14 +288,6 @@ import { domToPng } from '@ssshooter/modern-screenshot'
303
288
 
304
289
  const download = async () => {
305
290
  const dataUrl = await domToPng(mind.nodes, {
306
- onCloneNode: node => {
307
- const n = node as HTMLDivElement
308
- n.style.position = ''
309
- n.style.top = ''
310
- n.style.left = ''
311
- n.style.bottom = ''
312
- n.style.right = ''
313
- },
314
291
  padding: 300,
315
292
  quality: 1,
316
293
  })
@@ -426,5 +403,19 @@ pnpm doc:md
426
403
  Thanks for your contributions to Mind Elixir! Your support and dedication make this project better.
427
404
 
428
405
  <a href="https://github.com/SSShooter/mind-elixir-core/graphs/contributors">
429
- <img src="https://contrib.rocks/image?repo=SSShooter/mind-elixir-core&columns=6" />
406
+ <img src="https://contrib.rocks/image?repo=SSShooter/mind-elixir-core" />
430
407
  </a>
408
+
409
+ ## v5 Breaking Changes
410
+
411
+ - Move scroll-based movement to transition-based movement
412
+ - `Summary.text` -> `Summary.label`
413
+ - Remove `getDataMd()`
414
+ - MindElixir.dragMoveHelper -> instance.dragMoveHelper
415
+ - Remove `unselectNode()`
416
+ - Remove `removeNode()`
417
+ - `node.style.fontSize`: use string instead of number which means you should add `px` to the end
418
+ - Use `instance.findEl` instead of `MindElixir.E` to get a node element
419
+ - CSS file is separated from JS file, you need to import it manually
420
+ - If using a bundler with CSS support: `import "mind-elixir/style";`
421
+ - If using a CDN you can add to your CSS file: `@import "https://cdn.jsdelivr.net/npm/mind-elixir@^5.0.0/dist/style.css";`