mind-elixir 2.0.2 → 2.0.3
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.js +1 -1
- package/dist/MindElixirLite.js +1 -1
- package/dist/example1.js +1 -1
- package/dist/types/const.d.ts +18 -0
- package/dist/types/customLink.d.ts +6 -0
- package/dist/types/dev.d.ts +1 -0
- package/dist/types/exampleData/1.cn.d.ts +126 -0
- package/dist/types/exampleData/1.d.ts +3 -0
- package/dist/types/exampleData/2.d.ts +3 -0
- package/dist/types/exampleData/3.d.ts +3 -0
- package/dist/types/i18n.d.ts +2 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/index.lite.d.ts +13 -0
- package/dist/types/interact.d.ts +140 -0
- package/dist/types/linkDiv.d.ts +14 -0
- package/dist/types/mouse.d.ts +2 -0
- package/dist/types/nodeOperation.d.ts +159 -0
- package/dist/types/plugin/contextMenu.d.ts +3 -0
- package/dist/types/plugin/keypress.d.ts +2 -0
- package/dist/types/plugin/mobileMenu.d.ts +3 -0
- package/dist/types/plugin/nodeDraggable.d.ts +2 -0
- package/dist/types/plugin/operationHistory.d.ts +2 -0
- package/dist/types/plugin/toolBar.d.ts +3 -0
- package/dist/types/types/dom.d.ts +41 -0
- package/dist/types/types/function.d.ts +45 -0
- package/dist/types/types/global.d.ts +7 -0
- package/dist/types/types/index.d.ts +219 -0
- package/dist/types/types/interact.d.ts +14 -0
- package/dist/types/types/linkDiv.d.ts +18 -0
- package/dist/types/utils/LinkDragMoveHelper.d.ts +5 -0
- package/dist/types/utils/dom.d.ts +12 -0
- package/dist/types/utils/dragMoveHelper.d.ts +9 -0
- package/dist/types/utils/index.d.ts +36 -0
- package/dist/types/utils/layout.d.ts +12 -0
- package/dist/types/utils/pubsub.d.ts +10 -0
- package/dist/types/utils/svg.d.ts +6 -0
- package/package.json +88 -75
- package/readme.cn.md +1 -1
- package/readme.md +19 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { SelectNodeFunc, CommonSelectFunc, SiblingSelectFunc, GetDataStringFunc, GetDataFunc, ExpandNode, RefreshFunc } from './types/function';
|
|
2
|
+
import type { EnableEdit, DisableEdit, Scale, ToCenter, Install, FocusNode, CancelFocus, InitLeft, InitRight, InitSide, SetLocale } from './types/interact';
|
|
3
|
+
/**
|
|
4
|
+
* @function
|
|
5
|
+
* @instance
|
|
6
|
+
* @name selectNode
|
|
7
|
+
* @memberof MapInteraction
|
|
8
|
+
* @description Select a node and add solid border to it.
|
|
9
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
10
|
+
*/
|
|
11
|
+
export declare const selectNode: SelectNodeFunc;
|
|
12
|
+
export declare const unselectNode: CommonSelectFunc;
|
|
13
|
+
export declare const selectNextSibling: SiblingSelectFunc;
|
|
14
|
+
export declare const selectPrevSibling: SiblingSelectFunc;
|
|
15
|
+
export declare const selectFirstChild: CommonSelectFunc;
|
|
16
|
+
export declare const selectParent: CommonSelectFunc;
|
|
17
|
+
/**
|
|
18
|
+
* @function
|
|
19
|
+
* @instance
|
|
20
|
+
* @name getDataString
|
|
21
|
+
* @description Get all node data as string.
|
|
22
|
+
* @memberof MapInteraction
|
|
23
|
+
* @return {string}
|
|
24
|
+
*/
|
|
25
|
+
export declare const getDataString: GetDataStringFunc;
|
|
26
|
+
/**
|
|
27
|
+
* @function
|
|
28
|
+
* @instance
|
|
29
|
+
* @name getData
|
|
30
|
+
* @description Get all node data as object.
|
|
31
|
+
* @memberof MapInteraction
|
|
32
|
+
* @return {Object}
|
|
33
|
+
*/
|
|
34
|
+
export declare const getData: GetDataFunc;
|
|
35
|
+
/**
|
|
36
|
+
* @function
|
|
37
|
+
* @instance
|
|
38
|
+
* @name getDataMd
|
|
39
|
+
* @description Get all node data as markdown.
|
|
40
|
+
* @memberof MapInteraction
|
|
41
|
+
* @return {String}
|
|
42
|
+
*/
|
|
43
|
+
export declare const getDataMd: GetDataStringFunc;
|
|
44
|
+
/**
|
|
45
|
+
* @function
|
|
46
|
+
* @instance
|
|
47
|
+
* @name enableEdit
|
|
48
|
+
* @memberof MapInteraction
|
|
49
|
+
*/
|
|
50
|
+
export declare const enableEdit: EnableEdit;
|
|
51
|
+
/**
|
|
52
|
+
* @function
|
|
53
|
+
* @instance
|
|
54
|
+
* @name disableEdit
|
|
55
|
+
* @memberof MapInteraction
|
|
56
|
+
*/
|
|
57
|
+
export declare const disableEdit: DisableEdit;
|
|
58
|
+
/**
|
|
59
|
+
* @function
|
|
60
|
+
* @instance
|
|
61
|
+
* @name scale
|
|
62
|
+
* @description Change the scale of the mind map.
|
|
63
|
+
* @memberof MapInteraction
|
|
64
|
+
* @param {number}
|
|
65
|
+
*/
|
|
66
|
+
export declare const scale: Scale;
|
|
67
|
+
/**
|
|
68
|
+
* @function
|
|
69
|
+
* @instance
|
|
70
|
+
* @name toCenter
|
|
71
|
+
* @description Reset position of the map to center.
|
|
72
|
+
* @memberof MapInteraction
|
|
73
|
+
*/
|
|
74
|
+
export declare const toCenter: ToCenter;
|
|
75
|
+
/**
|
|
76
|
+
* @function
|
|
77
|
+
* @instance
|
|
78
|
+
* @name install
|
|
79
|
+
* @description Install plugin.
|
|
80
|
+
* @memberof MapInteraction
|
|
81
|
+
*/
|
|
82
|
+
export declare const install: Install;
|
|
83
|
+
/**
|
|
84
|
+
* @function
|
|
85
|
+
* @instance
|
|
86
|
+
* @name focusNode
|
|
87
|
+
* @description Enter focus mode, set the target element as root.
|
|
88
|
+
* @memberof MapInteraction
|
|
89
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
90
|
+
*/
|
|
91
|
+
export declare const focusNode: FocusNode;
|
|
92
|
+
/**
|
|
93
|
+
* @function
|
|
94
|
+
* @instance
|
|
95
|
+
* @name cancelFocus
|
|
96
|
+
* @description Exit focus mode.
|
|
97
|
+
* @memberof MapInteraction
|
|
98
|
+
*/
|
|
99
|
+
export declare const cancelFocus: CancelFocus;
|
|
100
|
+
/**
|
|
101
|
+
* @function
|
|
102
|
+
* @instance
|
|
103
|
+
* @name initLeft
|
|
104
|
+
* @description Child nodes will distribute on the left side of the root node.
|
|
105
|
+
* @memberof MapInteraction
|
|
106
|
+
*/
|
|
107
|
+
export declare const initLeft: InitLeft;
|
|
108
|
+
/**
|
|
109
|
+
* @function
|
|
110
|
+
* @instance
|
|
111
|
+
* @name initRight
|
|
112
|
+
* @description Child nodes will distribute on the right side of the root node.
|
|
113
|
+
* @memberof MapInteraction
|
|
114
|
+
*/
|
|
115
|
+
export declare const initRight: InitRight;
|
|
116
|
+
/**
|
|
117
|
+
* @function
|
|
118
|
+
* @instance
|
|
119
|
+
* @name initSide
|
|
120
|
+
* @description Child nodes will distribute on both left and right side of the root node.
|
|
121
|
+
* @memberof MapInteraction
|
|
122
|
+
*/
|
|
123
|
+
export declare const initSide: InitSide;
|
|
124
|
+
/**
|
|
125
|
+
* @function
|
|
126
|
+
* @instance
|
|
127
|
+
* @name setLocale
|
|
128
|
+
* @memberof MapInteraction
|
|
129
|
+
*/
|
|
130
|
+
export declare const setLocale: SetLocale;
|
|
131
|
+
export declare const expandNode: ExpandNode;
|
|
132
|
+
/**
|
|
133
|
+
* @function
|
|
134
|
+
* @instance
|
|
135
|
+
* @name refresh
|
|
136
|
+
* @description Refresh mind map, you can use it after modified `this.nodeData`
|
|
137
|
+
* @memberof MapInteraction
|
|
138
|
+
* @param {TargetElement} data mind elixir data
|
|
139
|
+
*/
|
|
140
|
+
export declare const refresh: RefreshFunc;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LinkDiv } from './types/function';
|
|
2
|
+
/**
|
|
3
|
+
* Link nodes with svg,
|
|
4
|
+
* only link specific node if `mainNode` is present
|
|
5
|
+
*
|
|
6
|
+
* procedure:
|
|
7
|
+
* 1. calculate position of main nodes
|
|
8
|
+
* 2. layout main node, generate main link
|
|
9
|
+
* 3. generate links inside main node
|
|
10
|
+
* 4. generate custom link
|
|
11
|
+
* @param mainNode process the specific main node only
|
|
12
|
+
*/
|
|
13
|
+
declare const linkDiv: LinkDiv;
|
|
14
|
+
export default linkDiv;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { ReshapeNode, InsertNodeCommon, AddChildFunction, TNodeCopy, MoveNodeCommon, RemoveNode, MoveNodeToCommon, SetNodeTopic } from './types/function';
|
|
2
|
+
/**
|
|
3
|
+
* @exports NodeOperation
|
|
4
|
+
* @namespace NodeOperation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @function
|
|
8
|
+
* @instance
|
|
9
|
+
* @name reshapeNode
|
|
10
|
+
* @memberof NodeOperation
|
|
11
|
+
* @description Re-shape a node.
|
|
12
|
+
* @param {TargetElement} el - Target element return by E('...')
|
|
13
|
+
* @param {patchData} node - Data should be patched to the original data
|
|
14
|
+
* @example
|
|
15
|
+
* reshapeNode(E('bd4313fbac40284b'),{tags:['A', 'B'], style:{color:'#000'}})
|
|
16
|
+
*/
|
|
17
|
+
export declare const reshapeNode: ReshapeNode;
|
|
18
|
+
/**
|
|
19
|
+
* @function
|
|
20
|
+
* @instance
|
|
21
|
+
* @name insertSibling
|
|
22
|
+
* @memberof NodeOperation
|
|
23
|
+
* @description Create a sibling node.
|
|
24
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
25
|
+
* @param {node} node - New node information.
|
|
26
|
+
* @example
|
|
27
|
+
* insertSibling(E('bd4313fbac40284b'))
|
|
28
|
+
*/
|
|
29
|
+
export declare const insertSibling: InsertNodeCommon;
|
|
30
|
+
/**
|
|
31
|
+
* @function
|
|
32
|
+
* @instance
|
|
33
|
+
* @name insertBefore
|
|
34
|
+
* @memberof NodeOperation
|
|
35
|
+
* @description Create a sibling node before the selected node.
|
|
36
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
37
|
+
* @param {node} node - New node information.
|
|
38
|
+
* @example
|
|
39
|
+
* insertBefore(E('bd4313fbac40284b'))
|
|
40
|
+
*/
|
|
41
|
+
export declare const insertBefore: InsertNodeCommon;
|
|
42
|
+
/**
|
|
43
|
+
* @function
|
|
44
|
+
* @instance
|
|
45
|
+
* @name insertParent
|
|
46
|
+
* @memberof NodeOperation
|
|
47
|
+
* @description Create a parent node of the selected node.
|
|
48
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
49
|
+
* @param {node} node - New node information.
|
|
50
|
+
* @example
|
|
51
|
+
* insertParent(E('bd4313fbac40284b'))
|
|
52
|
+
*/
|
|
53
|
+
export declare const insertParent: InsertNodeCommon;
|
|
54
|
+
export declare const addChildFunction: AddChildFunction;
|
|
55
|
+
/**
|
|
56
|
+
* @function
|
|
57
|
+
* @instance
|
|
58
|
+
* @name addChild
|
|
59
|
+
* @memberof NodeOperation
|
|
60
|
+
* @description Create a child node.
|
|
61
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
62
|
+
* @param {node} node - New node information.
|
|
63
|
+
* @example
|
|
64
|
+
* addChild(E('bd4313fbac40284b'))
|
|
65
|
+
*/
|
|
66
|
+
export declare const addChild: InsertNodeCommon;
|
|
67
|
+
/**
|
|
68
|
+
* @function
|
|
69
|
+
* @instance
|
|
70
|
+
* @name copyNode
|
|
71
|
+
* @memberof NodeOperation
|
|
72
|
+
* @description Copy node to another node.
|
|
73
|
+
* @param {TargetElement} node - Target element return by E('...'), default value: currentTarget.
|
|
74
|
+
* @param {TargetElement} to - The target(as parent node) you want to copy to.
|
|
75
|
+
* @example
|
|
76
|
+
* copyNode(E('bd4313fbac402842'),E('bd4313fbac402839'))
|
|
77
|
+
*/
|
|
78
|
+
export declare const copyNode: TNodeCopy;
|
|
79
|
+
/**
|
|
80
|
+
* @function
|
|
81
|
+
* @instance
|
|
82
|
+
* @name moveUpNode
|
|
83
|
+
* @memberof NodeOperation
|
|
84
|
+
* @description Move the target node up.
|
|
85
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
86
|
+
* @example
|
|
87
|
+
* moveUpNode(E('bd4313fbac40284b'))
|
|
88
|
+
*/
|
|
89
|
+
export declare const moveUpNode: MoveNodeCommon;
|
|
90
|
+
/**
|
|
91
|
+
* @function
|
|
92
|
+
* @instance
|
|
93
|
+
* @name moveDownNode
|
|
94
|
+
* @memberof NodeOperation
|
|
95
|
+
* @description Move the target node down.
|
|
96
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
97
|
+
* @example
|
|
98
|
+
* moveDownNode(E('bd4313fbac40284b'))
|
|
99
|
+
*/
|
|
100
|
+
export declare const moveDownNode: MoveNodeCommon;
|
|
101
|
+
/**
|
|
102
|
+
* @function
|
|
103
|
+
* @instance
|
|
104
|
+
* @name removeNode
|
|
105
|
+
* @memberof NodeOperation
|
|
106
|
+
* @description Remove the target node.
|
|
107
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
108
|
+
* @example
|
|
109
|
+
* removeNode(E('bd4313fbac40284b'))
|
|
110
|
+
*/
|
|
111
|
+
export declare const removeNode: RemoveNode;
|
|
112
|
+
/**
|
|
113
|
+
* @function
|
|
114
|
+
* @instance
|
|
115
|
+
* @name moveNode
|
|
116
|
+
* @memberof NodeOperation
|
|
117
|
+
* @description Move a node to another node (as child node).
|
|
118
|
+
* @param {TargetElement} from - The target you want to move.
|
|
119
|
+
* @param {TargetElement} to - The target(as parent node) you want to move to.
|
|
120
|
+
* @example
|
|
121
|
+
* moveNode(E('bd4313fbac402842'),E('bd4313fbac402839'))
|
|
122
|
+
*/
|
|
123
|
+
export declare const moveNode: MoveNodeToCommon;
|
|
124
|
+
/**
|
|
125
|
+
* @function
|
|
126
|
+
* @instance
|
|
127
|
+
* @name moveNodeBefore
|
|
128
|
+
* @memberof NodeOperation
|
|
129
|
+
* @description Move a node and become previous node of another node.
|
|
130
|
+
* @param {TargetElement} from
|
|
131
|
+
* @param {TargetElement} to
|
|
132
|
+
* @example
|
|
133
|
+
* moveNodeBefore(E('bd4313fbac402842'),E('bd4313fbac402839'))
|
|
134
|
+
*/
|
|
135
|
+
export declare const moveNodeBefore: MoveNodeToCommon;
|
|
136
|
+
/**
|
|
137
|
+
* @function
|
|
138
|
+
* @instance
|
|
139
|
+
* @name moveNodeAfter
|
|
140
|
+
* @memberof NodeOperation
|
|
141
|
+
* @description Move a node and become next node of another node.
|
|
142
|
+
* @param {TargetElement} from
|
|
143
|
+
* @param {TargetElement} to
|
|
144
|
+
* @example
|
|
145
|
+
* moveNodeAfter(E('bd4313fbac402842'),E('bd4313fbac402839'))
|
|
146
|
+
*/
|
|
147
|
+
export declare const moveNodeAfter: MoveNodeToCommon;
|
|
148
|
+
/**
|
|
149
|
+
* @function
|
|
150
|
+
* @instance
|
|
151
|
+
* @name beginEdit
|
|
152
|
+
* @memberof NodeOperation
|
|
153
|
+
* @description Begin to edit the target node.
|
|
154
|
+
* @param {TargetElement} el - Target element return by E('...'), default value: currentTarget.
|
|
155
|
+
* @example
|
|
156
|
+
* beginEdit(E('bd4313fbac40284b'))
|
|
157
|
+
*/
|
|
158
|
+
export declare const beginEdit: InsertNodeCommon;
|
|
159
|
+
export declare const setNodeTopic: SetNodeTopic;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NodeObj, LinkItem } from './index';
|
|
2
|
+
export interface Wrapper extends HTMLElement {
|
|
3
|
+
firstChild: Parent;
|
|
4
|
+
parentNode: Children;
|
|
5
|
+
parentElement: Children;
|
|
6
|
+
offsetParent: Wrapper;
|
|
7
|
+
previousSibling: Wrapper | null;
|
|
8
|
+
nextSibling: Wrapper | null;
|
|
9
|
+
}
|
|
10
|
+
export interface Parent extends HTMLElement {
|
|
11
|
+
firstChild: Topic;
|
|
12
|
+
parentNode: Wrapper;
|
|
13
|
+
parentElement: Wrapper;
|
|
14
|
+
nextSibling: Children;
|
|
15
|
+
offsetParent: Wrapper;
|
|
16
|
+
}
|
|
17
|
+
export declare type Root = Parent;
|
|
18
|
+
export interface Children extends HTMLElement {
|
|
19
|
+
parentNode: Wrapper;
|
|
20
|
+
parentElement: Wrapper;
|
|
21
|
+
firstChild: Wrapper;
|
|
22
|
+
previousSibling: Parent;
|
|
23
|
+
}
|
|
24
|
+
export interface Topic extends HTMLElement {
|
|
25
|
+
nodeObj: NodeObj;
|
|
26
|
+
linkContainer: HTMLElement | null;
|
|
27
|
+
parentNode: Parent;
|
|
28
|
+
parentElement: Parent;
|
|
29
|
+
offsetParent: Parent;
|
|
30
|
+
}
|
|
31
|
+
export interface Expander extends HTMLElement {
|
|
32
|
+
expanded?: boolean;
|
|
33
|
+
parentNode: Parent;
|
|
34
|
+
parentElement: Parent;
|
|
35
|
+
previousSibling: Topic;
|
|
36
|
+
}
|
|
37
|
+
export declare type CustomLine = SVGPathElement;
|
|
38
|
+
export declare type CustomArrow = SVGPathElement;
|
|
39
|
+
export interface CustomSvg extends SVGGElement {
|
|
40
|
+
linkObj?: LinkItem;
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Topic, Wrapper, Parent, Children, CustomSvg } from './dom';
|
|
2
|
+
import type { MindElixirInstance, MindElixirData, NodeObj, LinkItem } from './index';
|
|
3
|
+
export declare type Init = (this: MindElixirInstance, data: MindElixirData) => void;
|
|
4
|
+
export declare type CreateInputDiv = (this: MindElixirInstance, el: Topic) => void;
|
|
5
|
+
export declare type CreateWrapper = (this: MindElixirInstance, nodeObj: NodeObj, omitChildren?: boolean) => {
|
|
6
|
+
grp: Wrapper;
|
|
7
|
+
top: Parent;
|
|
8
|
+
};
|
|
9
|
+
export declare type CreateChildren = (this: MindElixirInstance, wrappers: Wrapper[]) => Children;
|
|
10
|
+
export declare type CreateParent = (this: MindElixirInstance, nodeObj: NodeObj) => Parent;
|
|
11
|
+
export declare type CreateTopic = (this: MindElixirInstance, nodeObj: NodeObj) => Topic;
|
|
12
|
+
export declare type InsertNodeCommon = (this: MindElixirInstance, el?: Topic, node?: NodeObj) => void;
|
|
13
|
+
export declare type RemoveNode = (this: MindElixirInstance, el?: Topic) => void;
|
|
14
|
+
export declare type MoveNodeCommon = (this: MindElixirInstance, target?: Topic) => void;
|
|
15
|
+
export declare type MoveNodeToCommon = (this: MindElixirInstance, from: Topic, to: Topic) => void;
|
|
16
|
+
export declare type TNodeCopy = (this: MindElixirInstance, node: Topic, to: Topic) => void;
|
|
17
|
+
export declare type AddChildFunction = (this: MindElixirInstance, nodeEle: Topic, node?: NodeObj) => {
|
|
18
|
+
newTop: Parent;
|
|
19
|
+
newNodeObj: NodeObj;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare type ReshapeNode = (this: MindElixirInstance, tpc: Topic, patchData: NodeObj) => void;
|
|
22
|
+
export declare type Layout = (this: MindElixirInstance) => void;
|
|
23
|
+
export declare type LayoutChildren = (this: MindElixirInstance, data: NodeObj[], container?: Children, direction?: number) => Children;
|
|
24
|
+
export declare type LinkDiv = (this: MindElixirInstance, mainNode?: Wrapper) => void;
|
|
25
|
+
export declare type TraverseChildrenFunc = (children: HTMLCollection, parent: Parent, isFirst?: boolean) => string;
|
|
26
|
+
export declare type JudgeDirection = (this: MindElixirInstance, mainNode: Wrapper, obj: NodeObj) => void;
|
|
27
|
+
export declare type CreateLink = (this: MindElixirInstance, from: Topic, to: Topic, isInitPaint?: boolean, linkObj?: LinkItem) => void;
|
|
28
|
+
export declare type RemoveLink = (this: MindElixirInstance, link?: CustomSvg) => void;
|
|
29
|
+
export declare type SelectLink = (this: MindElixirInstance, link: CustomSvg) => void;
|
|
30
|
+
export declare type LinkControllerData = {
|
|
31
|
+
cx: number;
|
|
32
|
+
cy: number;
|
|
33
|
+
w: any;
|
|
34
|
+
h: any;
|
|
35
|
+
};
|
|
36
|
+
export declare type ShowLinkController = (this: MindElixirInstance, p2x: number, p2y: number, p3x: number, p3y: number, linkItem: LinkItem, fromData: LinkControllerData, toData: LinkControllerData) => void;
|
|
37
|
+
export declare type HideLinkController = (this: MindElixirInstance) => void;
|
|
38
|
+
export declare type ExpandNode = (this: MindElixirInstance, el: Topic, isExpand?: boolean) => void;
|
|
39
|
+
export declare type SelectNodeFunc = (this: MindElixirInstance, targetElement: Topic, isNewNode?: boolean, e?: MouseEvent) => void;
|
|
40
|
+
export declare type CommonSelectFunc = (this: MindElixirInstance) => void;
|
|
41
|
+
export declare type SiblingSelectFunc = (this: MindElixirInstance) => boolean;
|
|
42
|
+
export declare type GetDataStringFunc = (this: MindElixirInstance) => string;
|
|
43
|
+
export declare type GetDataFunc = (this: MindElixirInstance) => MindElixirData;
|
|
44
|
+
export declare type RefreshFunc = (this: MindElixirInstance, data?: MindElixirData) => void;
|
|
45
|
+
export declare type SetNodeTopic = (this: MindElixirInstance, el: Topic, topic: string) => void;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type Bus from '../utils/pubsub';
|
|
2
|
+
import type { Topic, CustomSvg, Children } from './dom';
|
|
3
|
+
import type { Init, CreateWrapper, CreateParent, CreateChildren, CreateTopic, LinkDiv, JudgeDirection, InsertNodeCommon, CreateInputDiv, LayoutChildren, MoveNodeToCommon, MoveNodeCommon, RemoveNode, TNodeCopy, SetNodeTopic, SelectNodeFunc, CommonSelectFunc, SiblingSelectFunc, GetDataStringFunc, GetDataFunc, ExpandNode, RefreshFunc, Layout, RemoveLink, SelectLink, HideLinkController, CreateLink, ShowLinkController } from './function';
|
|
4
|
+
import type { Scale, ToCenter, FocusNode, CancelFocus, InitLeft, InitRight, InitSide, SetLocale, EnableEdit, DisableEdit } from './interact';
|
|
5
|
+
export declare enum OperationType {
|
|
6
|
+
moveNode = "moveNode",
|
|
7
|
+
moveNodeAfter = "moveNodeAfter",
|
|
8
|
+
moveNodeBefore = "moveNodeBefore",
|
|
9
|
+
removeNode = "removeNode",
|
|
10
|
+
addChild = "addChild",
|
|
11
|
+
copyNode = "copyNode",
|
|
12
|
+
reshapeNode = "reshapeNode",
|
|
13
|
+
insertSibling = "insertSibling",
|
|
14
|
+
insertBefore = "insertBefore",
|
|
15
|
+
insertParent = "insertParent",
|
|
16
|
+
moveUpNode = "moveUpNode",
|
|
17
|
+
moveDownNode = "moveDownNode",
|
|
18
|
+
beginEdit = "beginEdit",
|
|
19
|
+
finishEdit = "finishEdit"
|
|
20
|
+
}
|
|
21
|
+
export declare type Operation = {
|
|
22
|
+
name: OperationType;
|
|
23
|
+
obj: any;
|
|
24
|
+
origin: any;
|
|
25
|
+
originSiblingId: string;
|
|
26
|
+
originParentId: string;
|
|
27
|
+
};
|
|
28
|
+
export interface Theme {
|
|
29
|
+
name: string;
|
|
30
|
+
palette: string[];
|
|
31
|
+
cssVar: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
export interface LinkDragMoveHelperInstance {
|
|
34
|
+
dom: HTMLElement;
|
|
35
|
+
mousedown: boolean;
|
|
36
|
+
lastX: number;
|
|
37
|
+
lastY: number;
|
|
38
|
+
init: (map: HTMLElement, cb: (deltaX: number, deltaY: number) => void) => void;
|
|
39
|
+
destory: (map: HTMLElement) => void;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
handleMouseMove: (e: MouseEvent) => void;
|
|
42
|
+
handleMouseDown: (e: MouseEvent) => void;
|
|
43
|
+
handleClear: (e: MouseEvent) => void;
|
|
44
|
+
cb: ((deltaX: number, deltaY: number) => void) | null;
|
|
45
|
+
}
|
|
46
|
+
export interface MindElixirInstance {
|
|
47
|
+
isFocusMode: boolean;
|
|
48
|
+
nodeDataBackup: NodeObj;
|
|
49
|
+
mindElixirBox: HTMLElement;
|
|
50
|
+
nodeData: NodeObj;
|
|
51
|
+
linkData: LinkObj;
|
|
52
|
+
currentNode: Topic | null;
|
|
53
|
+
waitCopy: Topic | null;
|
|
54
|
+
currentLink: CustomSvg | null;
|
|
55
|
+
inputDiv: HTMLElement | null;
|
|
56
|
+
scaleVal: number;
|
|
57
|
+
tempDirection: number | null;
|
|
58
|
+
bus: ReturnType<typeof Bus.create>;
|
|
59
|
+
history: Operation[];
|
|
60
|
+
isUndo: boolean;
|
|
61
|
+
undo: () => void;
|
|
62
|
+
theme: Theme;
|
|
63
|
+
direction: number;
|
|
64
|
+
locale: string;
|
|
65
|
+
draggable: boolean;
|
|
66
|
+
editable: boolean;
|
|
67
|
+
contextMenu: boolean;
|
|
68
|
+
contextMenuOption: object;
|
|
69
|
+
toolBar: boolean;
|
|
70
|
+
keypress: boolean;
|
|
71
|
+
before: Before;
|
|
72
|
+
newTopicName: string;
|
|
73
|
+
allowUndo: boolean;
|
|
74
|
+
overflowHidden: boolean;
|
|
75
|
+
mainLinkStyle: number;
|
|
76
|
+
mainNodeHorizontalGap: number;
|
|
77
|
+
mainNodeVerticalGap: number;
|
|
78
|
+
subLinkStyle: number;
|
|
79
|
+
mobileMenu: boolean;
|
|
80
|
+
container: HTMLElement;
|
|
81
|
+
map: HTMLElement;
|
|
82
|
+
root: HTMLElement;
|
|
83
|
+
mainNodes: Children;
|
|
84
|
+
lines: SVGElement;
|
|
85
|
+
linkController: SVGElement;
|
|
86
|
+
P2: HTMLElement;
|
|
87
|
+
P3: HTMLElement;
|
|
88
|
+
line1: SVGElement;
|
|
89
|
+
line2: SVGElement;
|
|
90
|
+
linkSvgGroup: SVGElement;
|
|
91
|
+
mapHeight: number;
|
|
92
|
+
init: Init;
|
|
93
|
+
generateNewObj: GenerateNewObj;
|
|
94
|
+
createWrapper: CreateWrapper;
|
|
95
|
+
createParent: CreateParent;
|
|
96
|
+
createChildren: CreateChildren;
|
|
97
|
+
createTopic: CreateTopic;
|
|
98
|
+
linkDiv: LinkDiv;
|
|
99
|
+
judgeDirection: JudgeDirection;
|
|
100
|
+
addChild: InsertNodeCommon;
|
|
101
|
+
createInputDiv: CreateInputDiv;
|
|
102
|
+
layoutChildren: LayoutChildren;
|
|
103
|
+
moveNode: MoveNodeToCommon;
|
|
104
|
+
moveUpNode: MoveNodeCommon;
|
|
105
|
+
moveDownNode: MoveNodeCommon;
|
|
106
|
+
moveNodeBefore: MoveNodeToCommon;
|
|
107
|
+
moveNodeAfter: MoveNodeToCommon;
|
|
108
|
+
removeNode: RemoveNode;
|
|
109
|
+
copyNode: TNodeCopy;
|
|
110
|
+
setNodeTopic: SetNodeTopic;
|
|
111
|
+
insertParent: InsertNodeCommon;
|
|
112
|
+
insertSibling: InsertNodeCommon;
|
|
113
|
+
insertBefore: InsertNodeCommon;
|
|
114
|
+
selectNode: SelectNodeFunc;
|
|
115
|
+
unselectNode: CommonSelectFunc;
|
|
116
|
+
selectNextSibling: SiblingSelectFunc;
|
|
117
|
+
selectPrevSibling: SiblingSelectFunc;
|
|
118
|
+
selectFirstChild: CommonSelectFunc;
|
|
119
|
+
selectParent: CommonSelectFunc;
|
|
120
|
+
getDataString: GetDataStringFunc;
|
|
121
|
+
getData: GetDataFunc;
|
|
122
|
+
getDataMd: GetDataStringFunc;
|
|
123
|
+
scale: Scale;
|
|
124
|
+
toCenter: ToCenter;
|
|
125
|
+
focusNode: FocusNode;
|
|
126
|
+
cancelFocus: CancelFocus;
|
|
127
|
+
initLeft: InitLeft;
|
|
128
|
+
initRight: InitRight;
|
|
129
|
+
initSide: InitSide;
|
|
130
|
+
setLocale: SetLocale;
|
|
131
|
+
enableEdit: EnableEdit;
|
|
132
|
+
disableEdit: DisableEdit;
|
|
133
|
+
expandNode: ExpandNode;
|
|
134
|
+
refresh: RefreshFunc;
|
|
135
|
+
layout: Layout;
|
|
136
|
+
beginEdit: InsertNodeCommon;
|
|
137
|
+
fillParent: FillParent;
|
|
138
|
+
getObjById: GetObjById;
|
|
139
|
+
removeLink: RemoveLink;
|
|
140
|
+
selectLink: SelectLink;
|
|
141
|
+
hideLinkController: HideLinkController;
|
|
142
|
+
createLink: CreateLink;
|
|
143
|
+
showLinkController: ShowLinkController;
|
|
144
|
+
helper1: LinkDragMoveHelperInstance;
|
|
145
|
+
helper2: LinkDragMoveHelperInstance;
|
|
146
|
+
}
|
|
147
|
+
export declare type Before = Record<string, (...args: any[]) => Promise<boolean> | boolean>;
|
|
148
|
+
export declare type GenerateNewObj = (this: MindElixirInstance) => NodeObjExport;
|
|
149
|
+
export declare type GetObjById = (id: string, data: NodeObj) => NodeObj | null;
|
|
150
|
+
export declare type FillParent = (data: NodeObj, parent?: NodeObj) => void;
|
|
151
|
+
export interface Options {
|
|
152
|
+
el: string | HTMLElement;
|
|
153
|
+
direction?: number;
|
|
154
|
+
locale?: string;
|
|
155
|
+
draggable?: boolean;
|
|
156
|
+
editable?: boolean;
|
|
157
|
+
contextMenu?: boolean;
|
|
158
|
+
contextMenuOption?: any;
|
|
159
|
+
toolBar?: boolean;
|
|
160
|
+
keypress?: boolean;
|
|
161
|
+
before?: Before;
|
|
162
|
+
newTopicName?: string;
|
|
163
|
+
allowUndo?: boolean;
|
|
164
|
+
overflowHidden?: boolean;
|
|
165
|
+
mainLinkStyle?: number;
|
|
166
|
+
mainNodeHorizontalGap?: number;
|
|
167
|
+
mainNodeVerticalGap?: number;
|
|
168
|
+
subLinkStyle?: number;
|
|
169
|
+
mobileMenu?: boolean;
|
|
170
|
+
theme?: Theme;
|
|
171
|
+
nodeMenu?: boolean;
|
|
172
|
+
}
|
|
173
|
+
export declare type Uid = string;
|
|
174
|
+
export interface NodeObj {
|
|
175
|
+
topic: string;
|
|
176
|
+
id: Uid;
|
|
177
|
+
style?: {
|
|
178
|
+
fontSize?: string;
|
|
179
|
+
color?: string;
|
|
180
|
+
background?: string;
|
|
181
|
+
fontWeight?: string;
|
|
182
|
+
};
|
|
183
|
+
children?: NodeObj[];
|
|
184
|
+
tags?: string[];
|
|
185
|
+
icons?: string[];
|
|
186
|
+
hyperLink?: string;
|
|
187
|
+
expanded?: boolean;
|
|
188
|
+
direction?: number;
|
|
189
|
+
root?: boolean;
|
|
190
|
+
image?: {
|
|
191
|
+
url: string;
|
|
192
|
+
width: number;
|
|
193
|
+
height: number;
|
|
194
|
+
};
|
|
195
|
+
branchColor?: string;
|
|
196
|
+
parent?: NodeObj;
|
|
197
|
+
}
|
|
198
|
+
export declare type NodeObjExport = Omit<NodeObj, 'parent'>;
|
|
199
|
+
export declare type LinkItem = {
|
|
200
|
+
id: string;
|
|
201
|
+
label: string;
|
|
202
|
+
from: Uid;
|
|
203
|
+
to: Uid;
|
|
204
|
+
delta1: {
|
|
205
|
+
x: number;
|
|
206
|
+
y: number;
|
|
207
|
+
};
|
|
208
|
+
delta2: {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
export declare type LinkObj = Record<string, LinkItem>;
|
|
214
|
+
export interface MindElixirData {
|
|
215
|
+
nodeData: NodeObj;
|
|
216
|
+
linkData?: LinkObj;
|
|
217
|
+
direction?: number;
|
|
218
|
+
theme?: Theme;
|
|
219
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Topic } from './dom';
|
|
2
|
+
import type { MindElixirInstance } from './index';
|
|
3
|
+
export declare type CancelFocus = (this: MindElixirInstance) => void;
|
|
4
|
+
export declare type InitLeft = (this: MindElixirInstance) => void;
|
|
5
|
+
export declare type InitRight = (this: MindElixirInstance) => void;
|
|
6
|
+
export declare type InitSide = (this: MindElixirInstance) => void;
|
|
7
|
+
export declare type SetLocale = (this: MindElixirInstance, locale: string) => void;
|
|
8
|
+
export declare type FocusNode = (this: MindElixirInstance, el: Topic) => void;
|
|
9
|
+
export declare type EnableEdit = (this: MindElixirInstance) => void;
|
|
10
|
+
export declare type DisableEdit = (this: MindElixirInstance) => void;
|
|
11
|
+
export declare type Scale = (this: MindElixirInstance, val: number) => void;
|
|
12
|
+
export declare type ToCenter = (this: MindElixirInstance) => void;
|
|
13
|
+
export declare type MindElixirPlugin = (instance: MindElixirInstance) => void;
|
|
14
|
+
export declare type Install = (this: MindElixirInstance, plugin: MindElixirPlugin) => void;
|