mind-elixir 3.2.6 → 3.3.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.
- package/dist/MindElixir.iife.js +8 -8
- package/dist/MindElixir.js +939 -872
- package/dist/MindElixirLite.iife.js +8 -8
- package/dist/MindElixirLite.js +895 -869
- package/dist/types/index.d.ts +2 -1
- package/dist/types/methods.d.ts +1 -0
- package/dist/types/nodeOperation.d.ts +1 -0
- package/dist/types/types/index.d.ts +6 -2
- package/dist/types/utils/LinkDragMoveHelper.d.ts +2 -4
- package/dist/types/utils/domManipulation.d.ts +8 -0
- package/dist/types/utils/dragMoveHelper.d.ts +0 -2
- package/dist/types/utils/index.d.ts +3 -9
- package/dist/types/utils/objectManipulation.d.ts +10 -0
- package/dist/types/utils/pubsub.d.ts +31 -6
- package/package.json +1 -1
- package/readme.md +2 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { findEle } from './utils/dom';
|
|
|
5
5
|
export * from './types/index';
|
|
6
6
|
export * from './types/dom';
|
|
7
7
|
import type { MindElixirData, MindElixirInstance, MindElixirMethods, Options } from './types/index';
|
|
8
|
-
declare function MindElixir(this: MindElixirInstance, { el, direction, locale, draggable, editable, contextMenu, contextMenuOption, toolBar, keypress, before, newTopicName, allowUndo, mainLinkStyle, subLinkStyle, overflowHidden, mobileMenu, theme, }: Options): void;
|
|
8
|
+
declare function MindElixir(this: MindElixirInstance, { el, direction, locale, draggable, editable, contextMenu, contextMenuOption, toolBar, keypress, mouseSelectionButton, before, newTopicName, allowUndo, mainLinkStyle, subLinkStyle, overflowHidden, mobileMenu, theme, }: Options): void;
|
|
9
9
|
declare namespace MindElixir {
|
|
10
10
|
export var prototype: {
|
|
11
11
|
init(this: MindElixirInstance, data: MindElixirData): Error | undefined;
|
|
@@ -36,6 +36,7 @@ declare namespace MindElixir {
|
|
|
36
36
|
moveUpNode: (this: MindElixirInstance, el?: import("./types/dom").Topic | undefined) => Promise<void>;
|
|
37
37
|
moveDownNode: (this: MindElixirInstance, el?: import("./types/dom").Topic | undefined) => Promise<void>;
|
|
38
38
|
removeNode: (this: MindElixirInstance, el?: import("./types/dom").Topic | undefined) => Promise<void>;
|
|
39
|
+
removeNodes: (this: MindElixirInstance, tpcs: import("./types/dom").Topic[]) => Promise<void>;
|
|
39
40
|
moveNode: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic) => Promise<void>;
|
|
40
41
|
moveNodeBefore: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic) => Promise<void>;
|
|
41
42
|
moveNodeAfter: (this: MindElixirInstance, from: import("./types/dom").Topic, to: import("./types/dom").Topic) => Promise<void>;
|
package/dist/types/methods.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ declare const methods: {
|
|
|
39
39
|
moveUpNode: (this: MindElixirInstance, el?: import("./index").Topic | undefined) => Promise<void>;
|
|
40
40
|
moveDownNode: (this: MindElixirInstance, el?: import("./index").Topic | undefined) => Promise<void>;
|
|
41
41
|
removeNode: (this: MindElixirInstance, el?: import("./index").Topic | undefined) => Promise<void>;
|
|
42
|
+
removeNodes: (this: MindElixirInstance, tpcs: import("./index").Topic[]) => Promise<void>;
|
|
42
43
|
moveNode: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic) => Promise<void>;
|
|
43
44
|
moveNodeBefore: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic) => Promise<void>;
|
|
44
45
|
moveNodeAfter: (this: MindElixirInstance, from: import("./index").Topic, to: import("./index").Topic) => Promise<void>;
|
|
@@ -105,6 +105,7 @@ export declare const moveDownNode: (this: MindElixirInstance, el?: Topic) => voi
|
|
|
105
105
|
* removeNode(E('bd4313fbac40284b'))
|
|
106
106
|
*/
|
|
107
107
|
export declare const removeNode: (this: MindElixirInstance, el?: Topic) => void;
|
|
108
|
+
export declare const removeNodes: (this: MindElixirInstance, tpcs: Topic[]) => void;
|
|
108
109
|
/**
|
|
109
110
|
* @function
|
|
110
111
|
* @instance
|
|
@@ -5,6 +5,7 @@ import type { MindElixirMethods, OperationMap, Operations } from '../methods';
|
|
|
5
5
|
import type { LinkDragMoveHelperInstance } from '../utils/LinkDragMoveHelper';
|
|
6
6
|
import type { LinkItem } from '../customLink';
|
|
7
7
|
import type { Summary, SummarySvgGroup } from '../summary';
|
|
8
|
+
import type SelectionArea from '@viselect/vanilla';
|
|
8
9
|
export * from '../methods';
|
|
9
10
|
type Before = Partial<{
|
|
10
11
|
[K in Operations]: (...args: Parameters<OperationMap[K]>) => Promise<boolean> | boolean;
|
|
@@ -57,6 +58,7 @@ export interface MindElixirInstance extends MindElixirMethods {
|
|
|
57
58
|
contextMenuOption: object;
|
|
58
59
|
toolBar: boolean;
|
|
59
60
|
keypress: boolean;
|
|
61
|
+
mouseSelectionButton: 0 | 2;
|
|
60
62
|
before: Before;
|
|
61
63
|
newTopicName: string;
|
|
62
64
|
allowUndo: boolean;
|
|
@@ -79,15 +81,16 @@ export interface MindElixirInstance extends MindElixirMethods {
|
|
|
79
81
|
/**
|
|
80
82
|
* @internal
|
|
81
83
|
*/
|
|
82
|
-
helper1
|
|
84
|
+
helper1?: LinkDragMoveHelperInstance;
|
|
83
85
|
/**
|
|
84
86
|
* @internal
|
|
85
87
|
*/
|
|
86
|
-
helper2
|
|
88
|
+
helper2?: LinkDragMoveHelperInstance;
|
|
87
89
|
bus: ReturnType<typeof Bus.create<EventMap>>;
|
|
88
90
|
history: Operation[];
|
|
89
91
|
undo: () => void;
|
|
90
92
|
redo: () => void;
|
|
93
|
+
selection: SelectionArea;
|
|
91
94
|
}
|
|
92
95
|
/**
|
|
93
96
|
* The MindElixir options
|
|
@@ -104,6 +107,7 @@ export interface Options {
|
|
|
104
107
|
contextMenuOption?: any;
|
|
105
108
|
toolBar?: boolean;
|
|
106
109
|
keypress?: boolean;
|
|
110
|
+
mouseSelectionButton?: 0 | 2;
|
|
107
111
|
before?: Before;
|
|
108
112
|
newTopicName?: string;
|
|
109
113
|
allowUndo?: boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
declare const create: (dom: HTMLElement) => {
|
|
2
2
|
dom: HTMLElement;
|
|
3
|
+
moved: boolean;
|
|
3
4
|
mousedown: boolean;
|
|
4
|
-
lastX: number;
|
|
5
|
-
lastY: number;
|
|
6
5
|
handleMouseMove(e: MouseEvent): void;
|
|
7
6
|
handleMouseDown(e: MouseEvent): void;
|
|
8
7
|
handleClear(e: MouseEvent): void;
|
|
@@ -14,9 +13,8 @@ declare const create: (dom: HTMLElement) => {
|
|
|
14
13
|
declare const LinkDragMoveHelper: {
|
|
15
14
|
create: (dom: HTMLElement) => {
|
|
16
15
|
dom: HTMLElement;
|
|
16
|
+
moved: boolean;
|
|
17
17
|
mousedown: boolean;
|
|
18
|
-
lastX: number;
|
|
19
|
-
lastY: number;
|
|
20
18
|
handleMouseMove(e: MouseEvent): void;
|
|
21
19
|
handleMouseDown(e: MouseEvent): void;
|
|
22
20
|
handleClear(e: MouseEvent): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MindElixirInstance, NodeObj } from '../types';
|
|
2
|
+
import type { Topic } from '../types/dom';
|
|
3
|
+
export declare const judgeDirection: (direction: number, obj: NodeObj) => 0 | 1 | undefined;
|
|
4
|
+
export declare const addChildDom: (this: MindElixirInstance, tpc: Topic, node?: NodeObj) => {
|
|
5
|
+
newTop: import("../types/dom").Parent;
|
|
6
|
+
newNodeObj: import("../types").NodeObjExport;
|
|
7
|
+
} | null;
|
|
8
|
+
export declare const removeNodeDom: (tpc: Topic, siblingLength: number) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Topic } from '../types/dom';
|
|
1
2
|
import type { NodeObj, MindElixirInstance, NodeObjExport } from '../types/index';
|
|
2
3
|
export declare function encodeHTML(s: string): string;
|
|
3
4
|
export declare const isMobile: () => boolean;
|
|
@@ -17,15 +18,6 @@ export declare function getArrowPoints(p3x: number, p3y: number, p4x: number, p4
|
|
|
17
18
|
export declare function generateUUID(): string;
|
|
18
19
|
export declare const generateNewObj: (this: MindElixirInstance) => NodeObjExport;
|
|
19
20
|
export declare function checkMoveValid(from: NodeObj, to: NodeObj): boolean;
|
|
20
|
-
export declare function moveUpObj(obj: NodeObj): void;
|
|
21
|
-
export declare function moveDownObj(obj: NodeObj): void;
|
|
22
|
-
export declare function removeNodeObj(obj: NodeObj): number;
|
|
23
|
-
export declare function insertNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
24
|
-
export declare function insertBeforeNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
25
|
-
export declare function insertParentNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
26
|
-
export declare function moveNodeObj(from: NodeObj, to: NodeObj): void;
|
|
27
|
-
export declare function moveNodeBeforeObj(from: NodeObj, to: NodeObj): void;
|
|
28
|
-
export declare function moveNodeAfterObj(from: NodeObj, to: NodeObj): void;
|
|
29
21
|
export declare function deepClone(obj: NodeObj): any;
|
|
30
22
|
export declare const getOffsetLT: (parent: HTMLElement, child: HTMLElement) => {
|
|
31
23
|
offsetLeft: number;
|
|
@@ -34,3 +26,5 @@ export declare const getOffsetLT: (parent: HTMLElement, child: HTMLElement) => {
|
|
|
34
26
|
export declare const setAttributes: (el: HTMLElement | SVGElement, attrs: {
|
|
35
27
|
[key: string]: string;
|
|
36
28
|
}) => void;
|
|
29
|
+
export declare const isTopic: (target?: HTMLElement) => target is Topic;
|
|
30
|
+
export declare const unionTopics: (nodes: Topic[]) => Topic[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NodeObj } from '../types';
|
|
2
|
+
export declare function moveUpObj(obj: NodeObj): void;
|
|
3
|
+
export declare function moveDownObj(obj: NodeObj): void;
|
|
4
|
+
export declare function removeNodeObj(obj: NodeObj): number;
|
|
5
|
+
export declare function insertNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
6
|
+
export declare function insertBeforeNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
7
|
+
export declare function insertParentNodeObj(obj: NodeObj, newObj: NodeObj): void;
|
|
8
|
+
export declare function moveNodeObj(from: NodeObj, to: NodeObj): void;
|
|
9
|
+
export declare function moveNodeBeforeObj(from: NodeObj, to: NodeObj): void;
|
|
10
|
+
export declare function moveNodeAfterObj(from: NodeObj, to: NodeObj): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { LinkItem } from '../customLink';
|
|
1
2
|
import type { Summary } from '../summary';
|
|
2
3
|
import type { NodeObj } from '../types/index';
|
|
3
|
-
|
|
4
|
-
export type Operation = {
|
|
4
|
+
type NodeOperation = {
|
|
5
5
|
name: 'moveNode' | 'moveDownNode' | 'moveUpNode' | 'copyNode' | 'addChild' | 'insertParent' | 'insertBefore' | 'insertSibling' | 'beginEdit';
|
|
6
6
|
obj: NodeObj;
|
|
7
7
|
} | {
|
|
@@ -12,10 +12,6 @@ export type Operation = {
|
|
|
12
12
|
name: 'finishEdit';
|
|
13
13
|
obj: NodeObj;
|
|
14
14
|
origin: string;
|
|
15
|
-
} | {
|
|
16
|
-
name: 'finishEditSummary';
|
|
17
|
-
obj: Summary;
|
|
18
|
-
origin: string;
|
|
19
15
|
} | {
|
|
20
16
|
name: 'moveNodeAfter' | 'moveNodeBefore' | 'moveNode';
|
|
21
17
|
obj: NodeObj;
|
|
@@ -26,7 +22,36 @@ export type Operation = {
|
|
|
26
22
|
obj: NodeObj;
|
|
27
23
|
originIndex?: number;
|
|
28
24
|
originParentId?: string;
|
|
25
|
+
} | {
|
|
26
|
+
name: 'removeNodes';
|
|
27
|
+
objs: NodeObj[];
|
|
28
|
+
};
|
|
29
|
+
export type SummaryOperation = {
|
|
30
|
+
name: 'createSummary';
|
|
31
|
+
obj: Summary;
|
|
32
|
+
} | {
|
|
33
|
+
name: 'removeSummary';
|
|
34
|
+
obj: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
name: 'finishEditSummary';
|
|
39
|
+
obj: Summary;
|
|
40
|
+
};
|
|
41
|
+
export type CustomLinkOperation = {
|
|
42
|
+
name: 'createCustomLink';
|
|
43
|
+
obj: LinkItem;
|
|
44
|
+
} | {
|
|
45
|
+
name: 'removeCustomLink';
|
|
46
|
+
obj: {
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
name: 'finishEditCustomLinkLabel';
|
|
51
|
+
obj: LinkItem;
|
|
29
52
|
};
|
|
53
|
+
export type Operation = NodeOperation | SummaryOperation | CustomLinkOperation;
|
|
54
|
+
export type OperationType = Operation['name'];
|
|
30
55
|
export type EventMap = {
|
|
31
56
|
operation: (info: Operation) => void;
|
|
32
57
|
selectNode: (nodeObj: NodeObj, e?: MouseEvent) => void;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -124,6 +124,7 @@ let options = {
|
|
|
124
124
|
locale: 'en', // [zh_CN,zh_TW,en,ja,pt,ru] waiting for PRs
|
|
125
125
|
overflowHidden: false, // default false
|
|
126
126
|
mainLinkStyle: 2, // [1,2] default 1
|
|
127
|
+
mouseSelectionButton: 0, // 0 for left button, 2 for right button, default 0
|
|
127
128
|
contextMenuOption: {
|
|
128
129
|
focus: true,
|
|
129
130
|
link: true,
|
|
@@ -351,7 +352,7 @@ Be aware that Mind Elixir will not observe the change of `prefers-color-scheme`.
|
|
|
351
352
|
|
|
352
353
|
```
|
|
353
354
|
pnpm i
|
|
354
|
-
|
|
355
|
+
pnpm dev
|
|
355
356
|
```
|
|
356
357
|
|
|
357
358
|
Test generated files with `dev.dist.ts`:
|