mind-elixir 3.1.3 → 3.2.0

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.
@@ -1,2 +1,2 @@
1
1
  var example=function(){"use strict";return{direction:2,nodeData:{id:"me-root",topic:"Mind Elixir",root:!0,tags:["Mind Map Core"],children:[{topic:"logo2",id:"56dae51a90d350a8",direction:0,expanded:!0,children:[{id:"use-image",topic:"mind-elixir",image:{url:"https://raw.githubusercontent.com/ssshooter/mind-elixir-core/master/images/logo2.png",height:90,width:90}}]},{topic:"What is Mind Elixir",id:"bd4313fbac40284b",direction:0,expanded:!0,children:[{topic:"A mind map core",id:"beeb823afd6d2114"},{topic:"Free",id:"c1f068377de9f3a0"},{topic:"Open-Source",id:"c1f06d38a09f23ca"},{topic:"Use without JavaScript framework",id:"c1f06e4cbcf16463",expanded:!0,children:[]},{topic:"Use in your own project",id:"c1f1f11a7fbf7550",children:[{topic:"import MindElixir from 'mind-elixir'",id:"c1f1e245b0a89f9b"},{topic:"new MindElixir({...}).init(data)",id:"c1f1ebc7072c8928"}]},{topic:"Easy to use",id:"c1f0723c07b408d7",expanded:!0,children:[{topic:"Use it like other mind map application",id:"c1f09612fd89920d"}]}]},{topic:"Basics",id:"bd1b66c4b56754d9",direction:0,expanded:!0,children:[{topic:"tab - Create a child node",id:"bd1b6892bcab126a"},{topic:"enter - Create a sibling node",id:"bd1b6b632a434b27"},{topic:"del - Remove a node",id:"bd1b983085187c0a"}]},{topic:"Focus mode",id:"bd1b9b94a9a7a913",direction:1,expanded:!0,children:[{topic:"Right click and select Focus Mode",id:"bd1bb2ac4bbab458"},{topic:"Right click and select Cancel Focus Mode",id:"bd1bb4b14d6697c3"}]},{topic:"Left menu",id:"bd1b9d1816ede134",direction:0,expanded:!0,children:[{topic:"Node distribution",id:"bd1ba11e620c3c1a",expanded:!0,children:[{topic:"Left",id:"bd1c1cb51e6745d3"},{topic:"Right",id:"bd1c1e12fd603ff6"},{topic:"Both l & r",id:"bd1c1f03def5c97b"}]}]},{topic:"Bottom menu",id:"bd1ba66996df4ba4",direction:1,expanded:!0,children:[{topic:"Full screen",id:"bd1ba81d9bc95a7e"},{topic:"Return to Center",id:"bd1babdd5c18a7a2"},{topic:"Zoom in",id:"bd1bae68e0ab186e"},{topic:"Zoom out",id:"bd1bb06377439977"}]},{topic:"Link",id:"bd1beff607711025",direction:0,expanded:!0,children:[{topic:"Right click and select Link",id:"bd1bf320da90046a"},{topic:"Click the target you want to link",id:"bd1bf6f94ff2e642"},{topic:"Modify link with control points",id:"bd1c0c4a487bd036"}]},{topic:"Node style",id:"bd1c217f9d0b20bd",direction:0,expanded:!0,children:[{topic:"Font Size",id:"bd1c24420cd2c2f5",style:{fontSize:"32",color:"#3298db"}},{topic:"Font Color",id:"bd1c2a59b9a2739c",style:{color:"#c0392c"}},{topic:"Background Color",id:"bd1c2de33f057eb4",style:{color:"#bdc3c7",background:"#2c3e50"}},{topic:"Add tags",id:"bd1cff58364436d0",tags:["Completed"]},{topic:"Add icons",id:"bd1d0317f7e8a61a",icons:["😂"],tags:["www"]},{topic:"Bolder",id:"bd41fd4ca32322a4",style:{fontWeight:"bold"}},{topic:"Hyper link",id:"bd41fd4ca32322a5",hyperLink:"https://github.com/ssshooter/mind-elixir-core"}]},{topic:"Draggable",id:"bd1f03fee1f63bc6",direction:1,expanded:!0,children:[{topic:`Drag a node to another node
2
- and the former one will become a child node of latter one`,id:"bd1f07c598e729dc"}]},{topic:"TODO",id:"bd1facea32a1967c",direction:1,expanded:!0,children:[{topic:"Add image",id:"bd1fb1ec53010749"},{topic:"Free node (position)",id:"bd42d3e3bee992b9"},{topic:"Style adjustment",id:"beeb7f3db6ad6496"}]},{topic:"Export data",id:"beeb7586973430db",direction:1,expanded:!0,children:[{topic:"JSON",id:"beeb784cc189375f"},{topic:"HTML",id:"beeb7a6bec2d68f5"}]},{topic:"Caution",id:"bd42dad21aaf6bae",direction:0,style:{background:"#f1c40e"},expanded:!0,children:[{topic:"Only save manually",id:"bd42e1d0163ebf04",expanded:!0,children:[{topic:"Save button in the top-right corner",id:"bd42e619051878b3",expanded:!0,children:[]},{topic:"ctrl + S",id:"bd42e97d7ac35e99"}]}]}],expanded:!0},linkData:{},summaries:[{id:"a5e68e6a2ce1b648",parent:"bd42e1d0163ebf04",start:0,end:1,text:"summary"},{id:"a5e6978f1bc69f4a",parent:"bd4313fbac40284b",start:3,end:5,text:"summary"}]}}();
2
+ and the former one will become a child node of latter one`,id:"bd1f07c598e729dc"}]},{topic:"TODO",id:"bd1facea32a1967c",direction:1,expanded:!0,children:[{topic:"Add image",id:"bd1fb1ec53010749"},{topic:"Free node (position)",id:"bd42d3e3bee992b9"},{topic:"Style adjustment",id:"beeb7f3db6ad6496"}]},{topic:"Export data",id:"beeb7586973430db",direction:1,expanded:!0,children:[{topic:"JSON",id:"beeb784cc189375f"},{topic:"HTML",id:"beeb7a6bec2d68f5"}]},{topic:"Caution",id:"bd42dad21aaf6bae",direction:0,style:{background:"#f1c40e"},expanded:!0,children:[{topic:"Only save manually",id:"bd42e1d0163ebf04",expanded:!0,children:[{topic:"Save button in the top-right corner",id:"bd42e619051878b3",expanded:!0,children:[]},{topic:"ctrl + S",id:"bd42e97d7ac35e99"}]}]}],expanded:!0},linkData:{ac5fb1df7345e9c4:{id:"ac5fb1df7345e9c4",label:"Render",from:"beeb784cc189375f",to:"beeb7a6bec2d68f5",delta1:{x:142.8828125,y:-57},delta2:{x:146.1171875,y:45}}},summaries:[{id:"a5e68e6a2ce1b648",parent:"bd42e1d0163ebf04",start:0,end:1,text:"summary"},{id:"a5e6978f1bc69f4a",parent:"bd4313fbac40284b",start:3,end:5,text:"summary"}]}}();
package/dist/example.js CHANGED
@@ -221,7 +221,7 @@ and the former one will become a child node of latter one`,
221
221
  expanded: !0,
222
222
  children: [
223
223
  {
224
- topic: "Save button in the top-right corner",
224
+ topic: "Save button in the top-right corner",
225
225
  id: "bd42e619051878b3",
226
226
  expanded: !0,
227
227
  children: []
@@ -234,7 +234,22 @@ and the former one will become a child node of latter one`,
234
234
  ],
235
235
  expanded: !0
236
236
  },
237
- linkData: {},
237
+ linkData: {
238
+ ac5fb1df7345e9c4: {
239
+ id: "ac5fb1df7345e9c4",
240
+ label: "Render",
241
+ from: "beeb784cc189375f",
242
+ to: "beeb7a6bec2d68f5",
243
+ delta1: {
244
+ x: 142.8828125,
245
+ y: -57
246
+ },
247
+ delta2: {
248
+ x: 146.1171875,
249
+ y: 45
250
+ }
251
+ }
252
+ },
238
253
  summaries: [
239
254
  {
240
255
  id: "a5e68e6a2ce1b648",
@@ -14,14 +14,19 @@ export type LinkItem = {
14
14
  y: number;
15
15
  };
16
16
  };
17
- export type LinkControllerData = {
17
+ export type DivData = {
18
18
  cx: number;
19
19
  cy: number;
20
20
  w: number;
21
21
  h: number;
22
+ ctrlX: number;
23
+ ctrlY: number;
22
24
  };
23
- export declare const createLink: (this: MindElixirInstance, from: Topic, to: Topic, isInitPaint?: boolean, obj?: LinkItem) => void;
25
+ export declare const drawCustomLink: (this: MindElixirInstance, from: Topic, to: Topic, obj: LinkItem, isInitPaint?: boolean) => void;
26
+ export declare const createLink: (this: MindElixirInstance, from: Topic, to: Topic) => void;
24
27
  export declare const removeLink: (this: MindElixirInstance, linkSvg?: CustomSvg) => void;
25
28
  export declare const selectLink: (this: MindElixirInstance, link: CustomSvg) => void;
26
29
  export declare const hideLinkController: (this: MindElixirInstance) => void;
27
- export declare const showLinkController: (this: MindElixirInstance, p2x: number, p2y: number, p3x: number, p3y: number, linkItem: LinkItem, fromData: LinkControllerData, toData: LinkControllerData) => void;
30
+ export declare const showLinkController: (this: MindElixirInstance, linkItem: LinkItem, fromData: DivData, toData: DivData) => void;
31
+ export declare function renderCustomLink(this: MindElixirInstance): void;
32
+ export declare function editCutsomLinkLabel(this: MindElixirInstance, el: CustomSvg): void;
@@ -9,17 +9,22 @@ declare function MindElixir(this: MindElixirInstance, { el, direction, locale, d
9
9
  declare namespace MindElixir {
10
10
  export var prototype: {
11
11
  init(this: MindElixirInstance, data: MindElixirData): Error | undefined;
12
+ exportSvg: (this: MindElixirInstance) => Blob;
13
+ exportPng: (this: MindElixirInstance) => Promise<Blob | null>;
12
14
  createSummary: (this: MindElixirInstance) => void;
13
15
  removeSummary: (this: MindElixirInstance, id: string) => void;
14
16
  selectSummary: (this: MindElixirInstance, el: import("./summary").SummarySvgGroup) => void;
15
17
  unselectSummary: (this: MindElixirInstance) => void;
16
18
  renderSummary: (this: MindElixirInstance) => void;
17
19
  editSummary: (this: MindElixirInstance, el: import("./summary").SummarySvgGroup) => void;
18
- createLink: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic, isInitPaint?: boolean | undefined, obj?: import("./customLink").LinkItem | undefined) => void;
20
+ renderCustomLink(this: MindElixirInstance): void;
21
+ editCutsomLinkLabel(this: MindElixirInstance, el: import("./types/dom").CustomSvg): void;
22
+ drawCustomLink: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic, obj: import("./customLink").LinkItem, isInitPaint?: boolean | undefined) => void;
23
+ createLink: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic) => void;
19
24
  removeLink: (this: MindElixirInstance, linkSvg?: import("./types/dom").CustomSvg | undefined) => void;
20
25
  selectLink: (this: MindElixirInstance, link: import("./types/dom").CustomSvg) => void;
21
26
  hideLinkController: (this: MindElixirInstance) => void;
22
- showLinkController: (this: MindElixirInstance, p2x: number, p2y: number, p3x: number, p3y: number, linkItem: import("./customLink").LinkItem, fromData: import("./customLink").LinkControllerData, toData: import("./customLink").LinkControllerData) => void;
27
+ showLinkController: (this: MindElixirInstance, linkItem: import("./customLink").LinkItem, fromData: import("./customLink").DivData, toData: import("./customLink").DivData) => void;
23
28
  reshapeNode: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
24
29
  insertSibling: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
25
30
  insertBefore: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
@@ -9,17 +9,22 @@ export type MindElixirMethods = typeof methods;
9
9
  */
10
10
  declare const methods: {
11
11
  init(this: MindElixirInstance, data: MindElixirData): Error | undefined;
12
+ exportSvg: (this: MindElixirInstance) => Blob;
13
+ exportPng: (this: MindElixirInstance) => Promise<Blob | null>;
12
14
  createSummary: (this: MindElixirInstance) => void;
13
15
  removeSummary: (this: MindElixirInstance, id: string) => void;
14
16
  selectSummary: (this: MindElixirInstance, el: summaryOperation.SummarySvgGroup) => void;
15
17
  unselectSummary: (this: MindElixirInstance) => void;
16
18
  renderSummary: (this: MindElixirInstance) => void;
17
19
  editSummary: (this: MindElixirInstance, el: summaryOperation.SummarySvgGroup) => void;
18
- createLink: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic, isInitPaint?: boolean | undefined, obj?: customLink.LinkItem | undefined) => void;
20
+ renderCustomLink(this: MindElixirInstance): void;
21
+ editCutsomLinkLabel(this: MindElixirInstance, el: import("./index").CustomSvg): void;
22
+ drawCustomLink: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic, obj: customLink.LinkItem, isInitPaint?: boolean | undefined) => void;
23
+ createLink: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic) => void;
19
24
  removeLink: (this: MindElixirInstance, linkSvg?: import("./index").CustomSvg | undefined) => void;
20
25
  selectLink: (this: MindElixirInstance, link: import("./index").CustomSvg) => void;
21
26
  hideLinkController: (this: MindElixirInstance) => void;
22
- showLinkController: (this: MindElixirInstance, p2x: number, p2y: number, p3x: number, p3y: number, linkItem: customLink.LinkItem, fromData: customLink.LinkControllerData, toData: customLink.LinkControllerData) => void;
27
+ showLinkController: (this: MindElixirInstance, linkItem: customLink.LinkItem, fromData: customLink.DivData, toData: customLink.DivData) => void;
23
28
  reshapeNode: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
24
29
  insertSibling: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
25
30
  insertBefore: (this: MindElixirInstance, ...args: unknown[]) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { MindElixirInstance } from '../types';
2
+ export declare const exportSvg: (this: MindElixirInstance) => Blob;
3
+ export declare const exportPng: (this: MindElixirInstance) => Promise<Blob | null>;
@@ -44,6 +44,6 @@ export interface Expander extends HTMLElement {
44
44
  export type CustomLine = SVGPathElement;
45
45
  export type CustomArrow = SVGPathElement;
46
46
  export interface CustomSvg extends SVGGElement {
47
- linkObj?: LinkItem;
48
- children: HTMLCollection & [CustomLine, CustomArrow];
47
+ linkObj: LinkItem;
48
+ children: HTMLCollection & [CustomLine, CustomArrow, SVGTextElement];
49
49
  }
@@ -1,4 +1,3 @@
1
- import type { LinkControllerData } from '../customLink';
2
1
  import type { NodeObj, MindElixirInstance, NodeObjExport } from '../types/index';
3
2
  export declare function encodeHTML(s: string): string;
4
3
  export declare const isMobile: () => boolean;
@@ -15,14 +14,6 @@ export declare function getArrowPoints(p3x: number, p3y: number, p4x: number, p4
15
14
  x2: number;
16
15
  y2: number;
17
16
  };
18
- export declare function calcP1(fromData: LinkControllerData, p2x: number, p2y: number): {
19
- x: number;
20
- y: number;
21
- };
22
- export declare function calcP4(toData: LinkControllerData, p3x: number, p3y: number): {
23
- x: number;
24
- y: number;
25
- };
26
17
  export declare function generateUUID(): string;
27
18
  export declare const generateNewObj: (this: MindElixirInstance) => NodeObjExport;
28
19
  export declare function checkMoveValid(from: NodeObj, to: NodeObj): boolean;
@@ -1,6 +1,8 @@
1
+ import type { MindElixirInstance } from '../types';
1
2
  import type { CustomSvg } from '../types/dom';
2
3
  export declare const createMainPath: (d: string, color: string) => SVGPathElement;
3
4
  export declare const createLinkSvg: (klass: string) => SVGSVGElement;
4
- export declare const createLine: (x1: number, y1: number, x2: number, y2: number) => SVGLineElement;
5
+ export declare const createLine: () => SVGLineElement;
5
6
  export declare const createPath: (d: string, color: string) => SVGPathElement;
6
7
  export declare const createSvgGroup: (d: string, arrowd: string) => CustomSvg;
8
+ export declare const editSvgText: (mei: MindElixirInstance, textEl: SVGTextElement, onblur: (div: HTMLDivElement) => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mind-elixir",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "description": "Mind elixir is a free open source mind map core.",
6
6
  "keywords": [
@@ -76,7 +76,6 @@
76
76
  "eslint-plugin-prettier": "^4.2.1",
77
77
  "husky": "^8.0.3",
78
78
  "less": "^4.1.3",
79
- "less-loader": "^10.2.0",
80
79
  "lint-staged": "^13.2.3",
81
80
  "prettier": "2.8.4",
82
81
  "typescript": "^5.1.6",
package/readme.md CHANGED
@@ -31,10 +31,12 @@ Mind elixir is a free open source mind map core.
31
31
  - High performance
32
32
  - Framework agnostic
33
33
  - Pluginable
34
+ - Export as SVG or PNG
34
35
  - Build-in drag and drop / node edit plugin
35
36
  - Summarize nodes
36
- - Undo / Redo
37
37
  - Styling your node with CSS
38
+ - Undo / Redo
39
+ - Efficient shortcuts
38
40
 
39
41
  <details>
40
42
  <summary>Table of Contents</summary>
@@ -50,8 +52,10 @@ Mind elixir is a free open source mind map core.
50
52
  - [Event Handling](#event-handling)
51
53
  - [Data Export And Import](#data-export-and-import)
52
54
  - [Operation Guards](#operation-guards)
53
- - [Methods](#methods)
55
+ - [Export as a Image](#export-as-a-image)
56
+ - [APIs](#apis)
54
57
  - [Theme](#theme)
58
+ - [Shortcuts](#shortcuts)
55
59
  - [Not only core](#not-only-core)
56
60
  - [Development](#development)
57
61
  - [Thanks](#thanks)
@@ -252,7 +256,27 @@ let mind = new MindElixir({
252
256
  })
253
257
  ```
254
258
 
255
- ## Methods
259
+ ## Export as a Image
260
+
261
+ ```typescript
262
+ import { exportPng } from './plugin/exportImage'
263
+
264
+ const mind = {
265
+ /** mind elixir instance */
266
+ }
267
+ const downloadPng = async () => {
268
+ const blob = await mind.exportPng() // Get a Blob!
269
+ if (!blob) return
270
+ const url = URL.createObjectURL(blob)
271
+ const a = document.createElement('a')
272
+ a.href = url
273
+ a.download = 'filename.png'
274
+ a.click()
275
+ URL.revokeObjectURL(url)
276
+ }
277
+ ```
278
+
279
+ ## APIs
256
280
 
257
281
  https://github.com/ssshooter/mind-elixir-core/blob/master/api/mind-elixir.api.md
258
282
 
@@ -295,6 +319,28 @@ mind.changeTheme({
295
319
 
296
320
  Be aware that Mind Elixir will not observe the change of `prefers-color-scheme`. Please change the theme **manually** when the scheme changes.
297
321
 
322
+ ## Shortcuts
323
+
324
+ | Shortcut | Function |
325
+ | ------------------ | -------------------------------- |
326
+ | Enter | Insert Sibling Node |
327
+ | Tab | Insert Child Node |
328
+ | F1 | Center the Map |
329
+ | F2 | Begin Editing the Current Node |
330
+ | Up Arrow | Select the Previous Sibling Node |
331
+ | Down Arrow | Select the Next Sibling Node |
332
+ | Left/Right Arrow | Select Parent or First Child |
333
+ | PageUp | Move Up Node |
334
+ | PageDown | Move Down Node |
335
+ | Ctrl + Up Arrow | Change Layout Pattern to Side |
336
+ | Ctrl + Left Arrow | Change Layout Pattern to Left |
337
+ | Ctrl + Right Arrow | Change Layout Pattern to Right |
338
+ | Ctrl + C | Copy the Current Node |
339
+ | Ctrl + V | Paste the Copied Node |
340
+ | Ctrl + "+" | Zoom In Mind Map |
341
+ | Ctrl + "-" | Zoom Out Mind Map |
342
+ | Ctrl + 0 | Reset Zoom Level |
343
+
298
344
  ## Not only core
299
345
 
300
346
  - [@mind-elixir/node-menu](https://github.com/ssshooter/node-menu)