@billtaofbj/mindmap 1.0.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.
- package/LICENSE +21 -0
- package/dist/AutoMove-B6piuV1l.mjs +21 -0
- package/dist/Base-B8xfItDp.mjs +289 -0
- package/dist/Drag-BNJqZaaB.mjs +458 -0
- package/dist/Export-C11gtER2.mjs +307 -0
- package/dist/Formula-rim6V3Ro.mjs +29081 -0
- package/dist/KeyboardNavigation-BznWjRqo.mjs +106 -0
- package/dist/MindMapNode-CKCds6wa.mjs +1865 -0
- package/dist/MiniMap-BtFFvLbR.mjs +98 -0
- package/dist/NodeImgAdjust-CU_ka96q.mjs +138 -0
- package/dist/OuterFrame-D-P0EKq5.mjs +325 -0
- package/dist/Painter-D3byksYq.mjs +42 -0
- package/dist/RainbowLines-CGp8BmNt.mjs +52 -0
- package/dist/Scrollbar-5bObtsl_.mjs +117 -0
- package/dist/Search-1GRF2dmm.mjs +124 -0
- package/dist/Select-CY_n5-r2.mjs +99 -0
- package/dist/Watermark-B-zBgHXG.mjs +88 -0
- package/dist/api-D2rfJWe_.mjs +16 -0
- package/dist/btns-Cf5zZK5X.mjs +9 -0
- package/dist/index.cjs.js +1515 -0
- package/dist/index.es.js +2745 -0
- package/dist/mindmap.css +2 -0
- package/dist/simple-mind-map-DFGmd5vc.mjs +3188 -0
- package/dist/utils-DjW7eJ1w.mjs +4295 -0
- package/package.json +26 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { Dt as e, I as t, dt as n, i as r, k as i, ut as a } from "./utils-DjW7eJ1w.mjs";
|
|
2
|
+
import { t as o } from "./Base-B8xfItDp.mjs";
|
|
3
|
+
import { t as s } from "./AutoMove-B6piuV1l.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/Drag.js
|
|
5
|
+
var c = class extends o {
|
|
6
|
+
constructor({ mindMap: e }) {
|
|
7
|
+
super(e.renderer), this.mindMap = e, this.autoMove = new s(e), this.reset(), this.bindEvent();
|
|
8
|
+
}
|
|
9
|
+
reset() {
|
|
10
|
+
this.isDragging = !1, this.mousedownNode = null, this.beingDragNodeList = [], this.nodeList = [], this.overlapNode = null, this.prevNode = null, this.nextNode = null, this.drawTransform = null, this.clone = null, this.placeholder = null, this.placeholderWidth = 50, this.placeholderHeight = 10, this.placeHolderLine = null, this.placeHolderExtraLines = [], this.offsetX = 0, this.offsetY = 0, this.isMousedown = !1, this.mouseDownX = 0, this.mouseDownY = 0, this.mouseMoveX = 0, this.mouseMoveY = 0, this.checkDragOffset = 10, this.minOffset = 10;
|
|
11
|
+
}
|
|
12
|
+
bindEvent() {
|
|
13
|
+
this.onNodeMousedown = this.onNodeMousedown.bind(this), this.onMousemove = this.onMousemove.bind(this), this.onMouseup = this.onMouseup.bind(this), this.checkOverlapNode = n(this.checkOverlapNode, 300, this), this.mindMap.on("node_mousedown", this.onNodeMousedown), this.mindMap.on("mousemove", this.onMousemove), this.mindMap.on("node_mouseup", this.onMouseup), this.mindMap.on("mouseup", this.onMouseup);
|
|
14
|
+
}
|
|
15
|
+
unBindEvent() {
|
|
16
|
+
this.mindMap.off("node_mousedown", this.onNodeMousedown), this.mindMap.off("mousemove", this.onMousemove), this.mindMap.off("node_mouseup", this.onMouseup), this.mindMap.off("mouseup", this.onMouseup);
|
|
17
|
+
}
|
|
18
|
+
onNodeMousedown(e, t) {
|
|
19
|
+
if (this.mindMap.opt.readonly || t.which !== 1 || e.isGeneralization || e.isRoot) return;
|
|
20
|
+
this.isMousedown = !0, this.mousedownNode = e;
|
|
21
|
+
let { x: n, y: r } = this.mindMap.toPos(t.clientX, t.clientY);
|
|
22
|
+
this.mouseDownX = n, this.mouseDownY = r;
|
|
23
|
+
}
|
|
24
|
+
onMousemove(e) {
|
|
25
|
+
if (this.mindMap.opt.readonly || !this.isMousedown) return;
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
let { x: t, y: n } = this.mindMap.toPos(e.clientX, e.clientY);
|
|
28
|
+
this.mouseMoveX = t, this.mouseMoveY = n, !(!this.isDragging && Math.abs(t - this.mouseDownX) <= this.checkDragOffset && Math.abs(n - this.mouseDownY) <= this.checkDragOffset) && (this.mindMap.emit("node_dragging", this.mousedownNode), this.handleStartMove(), this.onMove(t, n, e));
|
|
29
|
+
}
|
|
30
|
+
async onMouseup(e) {
|
|
31
|
+
if (!this.isMousedown) return;
|
|
32
|
+
let { autoMoveWhenMouseInEdgeOnDrag: t, enableFreeDrag: n, beforeDragEnd: r } = this.mindMap.opt;
|
|
33
|
+
t && this.mindMap.select && this.autoMove.clearAutoMoveTimer(), this.isMousedown = !1, this.beingDragNodeList.forEach((e) => {
|
|
34
|
+
e.setOpacity(1), e.showChildren(), e.endDrag();
|
|
35
|
+
}), this.removeCloneNode();
|
|
36
|
+
let i = this.overlapNode ? this.overlapNode.getData("uid") : "", a = this.prevNode ? this.prevNode.getData("uid") : "", o = this.nextNode ? this.nextNode.getData("uid") : "";
|
|
37
|
+
if (this.isDragging && typeof r == "function" && await r({
|
|
38
|
+
overlapNodeUid: i,
|
|
39
|
+
prevNodeUid: a,
|
|
40
|
+
nextNodeUid: o,
|
|
41
|
+
beingDragNodeList: [...this.beingDragNodeList]
|
|
42
|
+
})) {
|
|
43
|
+
this.reset();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (this.overlapNode) this.removeNodeActive(this.overlapNode), this.mindMap.execCommand("MOVE_NODE_TO", this.beingDragNodeList, this.overlapNode);
|
|
47
|
+
else if (this.prevNode) this.removeNodeActive(this.prevNode), this.mindMap.execCommand("INSERT_AFTER", this.beingDragNodeList, this.prevNode);
|
|
48
|
+
else if (this.nextNode) this.removeNodeActive(this.nextNode), this.mindMap.execCommand("INSERT_BEFORE", this.beingDragNodeList, this.nextNode);
|
|
49
|
+
else if (this.clone && n && this.beingDragNodeList.length === 1) {
|
|
50
|
+
let { x: t, y: n } = this.mindMap.toPos(e.clientX - this.offsetX, e.clientY - this.offsetY), { scaleX: r, scaleY: i, translateX: a, translateY: o } = this.drawTransform;
|
|
51
|
+
t = (t - a) / r, n = (n - o) / i, this.mousedownNode.left = t, this.mousedownNode.top = n, this.mousedownNode.customLeft = t, this.mousedownNode.customTop = n, this.mindMap.execCommand("SET_NODE_CUSTOM_POSITION", this.mousedownNode, t, n), this.mindMap.render();
|
|
52
|
+
}
|
|
53
|
+
this.isDragging && this.mindMap.emit("node_dragend", {
|
|
54
|
+
overlapNodeUid: i,
|
|
55
|
+
prevNodeUid: a,
|
|
56
|
+
nextNodeUid: o
|
|
57
|
+
}), this.reset();
|
|
58
|
+
}
|
|
59
|
+
removeNodeActive(e) {
|
|
60
|
+
e.getData("isActive") && this.mindMap.execCommand("SET_NODE_ACTIVE", e, !1);
|
|
61
|
+
}
|
|
62
|
+
onMove(e, t, n) {
|
|
63
|
+
if (!this.isMousedown || !this.isDragging) return;
|
|
64
|
+
let { scaleX: r, scaleY: i, translateX: a, translateY: o } = this.drawTransform, s = e - this.offsetX, c = t - this.offsetY;
|
|
65
|
+
e = (s - a) / r, t = (c - o) / i;
|
|
66
|
+
let l = this.clone.transform();
|
|
67
|
+
this.clone.translate(e - l.translateX, t - l.translateY), this.checkOverlapNode(), this.drawTransform = this.mindMap.draw.transform(), this.autoMove.clearAutoMoveTimer(), this.autoMove.onMove(n.clientX, n.clientY);
|
|
68
|
+
}
|
|
69
|
+
async handleStartMove() {
|
|
70
|
+
if (!this.isDragging) {
|
|
71
|
+
let e = this.mousedownNode;
|
|
72
|
+
this.drawTransform = this.mindMap.draw.transform();
|
|
73
|
+
let { scaleX: n, scaleY: r, translateX: i, translateY: o } = this.drawTransform;
|
|
74
|
+
this.offsetX = this.mouseDownX - (e.left * n + i), this.offsetY = this.mouseDownY - (e.top * r + o), e.getData("isActive") ? this.beingDragNodeList = a(t(this.mindMap.renderer.activeNodeList.filter((e) => !e.isRoot && !e.isGeneralization))) : this.beingDragNodeList = [e];
|
|
75
|
+
let { beforeDragStart: s } = this.mindMap.opt;
|
|
76
|
+
if (typeof s == "function" && await s([...this.beingDragNodeList])) return;
|
|
77
|
+
this.nodeTreeToList(), this.createCloneNode(), this.mindMap.execCommand("CLEAR_ACTIVE_NODE"), this.isDragging = !0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
nodeTreeToList() {
|
|
81
|
+
let e = [];
|
|
82
|
+
r(this.mindMap.renderer.root, (t) => {
|
|
83
|
+
this.checkIsInBeingDragNodeList(t) || (e[t.layerIndex] || (e[t.layerIndex] = []), e[t.layerIndex].push(t));
|
|
84
|
+
}), this.nodeList = e.reduceRight((e, t) => [...e, ...t], []);
|
|
85
|
+
}
|
|
86
|
+
createCloneNode() {
|
|
87
|
+
if (!this.clone) {
|
|
88
|
+
let { dragMultiNodeRectConfig: e, dragPlaceholderRectFill: t, dragPlaceholderLineConfig: n, dragOpacityConfig: r, handleDragCloneNode: i } = this.mindMap.opt, { width: a, height: o, fill: s } = e, c = this.beingDragNodeList[0], l = c.style.merge("lineColor", !0);
|
|
89
|
+
if (this.beingDragNodeList.length > 1) this.clone = this.mindMap.otherDraw.rect().size(a, o).radius(o / 2).fill({ color: s || l }), this.offsetX = a / 2, this.offsetY = o / 2;
|
|
90
|
+
else {
|
|
91
|
+
this.clone = c.group.clone();
|
|
92
|
+
let e = this.clone.findOne(".smm-expand-btn");
|
|
93
|
+
e && e.remove(), this.mindMap.otherDraw.add(this.clone), typeof i == "function" && i(this.clone);
|
|
94
|
+
}
|
|
95
|
+
this.clone.opacity(r.cloneNodeOpacity), this.clone.css("z-index", 99999), this.placeholder = this.mindMap.otherDraw.rect().fill({ color: t || l }).radius(5), this.placeHolderLine = this.mindMap.otherDraw.path().stroke({
|
|
96
|
+
color: n.color || l,
|
|
97
|
+
width: n.width
|
|
98
|
+
}).fill({ color: "none" }), this.beingDragNodeList.forEach((e) => {
|
|
99
|
+
e.setOpacity(r.beingDragNodeOpacity), e.hideChildren(), e.startDrag();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
removeCloneNode() {
|
|
104
|
+
this.clone && (this.clone.remove(), this.placeholder.remove(), this.placeHolderLine.remove(), this.removeExtraLines());
|
|
105
|
+
}
|
|
106
|
+
removeExtraLines() {
|
|
107
|
+
this.placeHolderExtraLines.forEach((e) => {
|
|
108
|
+
e.remove();
|
|
109
|
+
}), this.placeHolderExtraLines = [];
|
|
110
|
+
}
|
|
111
|
+
checkOverlapNode() {
|
|
112
|
+
if (!this.drawTransform || !this.placeholder) return;
|
|
113
|
+
let { LOGICAL_STRUCTURE: t, LOGICAL_STRUCTURE_LEFT: n, MIND_MAP: r, ORGANIZATION_STRUCTURE: i, CATALOG_ORGANIZATION: a, TIMELINE: o, TIMELINE2: s, VERTICAL_TIMELINE: c, VERTICAL_TIMELINE2: l, VERTICAL_TIMELINE3: u, FISHBONE: d, FISHBONE2: f, RIGHT_FISHBONE: p, RIGHT_FISHBONE2: m } = e.LAYOUT;
|
|
114
|
+
this.overlapNode = null, this.prevNode = null, this.nextNode = null, this.placeholder.size(0, 0), this.placeHolderLine.hide(), this.removeExtraLines(), this.nodeList.forEach((e) => {
|
|
115
|
+
if (e.getData("isActive") && this.mindMap.execCommand("SET_NODE_ACTIVE", e, !1), !(this.overlapNode || this.prevNode && this.nextNode)) switch (this.mindMap.opt.layout) {
|
|
116
|
+
case t:
|
|
117
|
+
case n:
|
|
118
|
+
this.handleLogicalStructure(e);
|
|
119
|
+
break;
|
|
120
|
+
case r:
|
|
121
|
+
this.handleMindMap(e);
|
|
122
|
+
break;
|
|
123
|
+
case i:
|
|
124
|
+
this.handleOrganizationStructure(e);
|
|
125
|
+
break;
|
|
126
|
+
case a:
|
|
127
|
+
this.handleCatalogOrganization(e);
|
|
128
|
+
break;
|
|
129
|
+
case o:
|
|
130
|
+
this.handleTimeLine(e);
|
|
131
|
+
break;
|
|
132
|
+
case s:
|
|
133
|
+
this.handleTimeLine2(e);
|
|
134
|
+
break;
|
|
135
|
+
case c:
|
|
136
|
+
case l:
|
|
137
|
+
case u:
|
|
138
|
+
this.handleLogicalStructure(e);
|
|
139
|
+
break;
|
|
140
|
+
case d:
|
|
141
|
+
case f:
|
|
142
|
+
case p:
|
|
143
|
+
case m:
|
|
144
|
+
this.handleFishbone(e);
|
|
145
|
+
break;
|
|
146
|
+
default: this.handleLogicalStructure(e);
|
|
147
|
+
}
|
|
148
|
+
}), this.overlapNode && this.handleOverlapNode();
|
|
149
|
+
}
|
|
150
|
+
handleOverlapNode() {
|
|
151
|
+
let { LOGICAL_STRUCTURE: t, LOGICAL_STRUCTURE_LEFT: n, MIND_MAP: r, ORGANIZATION_STRUCTURE: i, CATALOG_ORGANIZATION: a, TIMELINE: o, TIMELINE2: s, VERTICAL_TIMELINE: c, VERTICAL_TIMELINE2: l, VERTICAL_TIMELINE3: u, FISHBONE: d, FISHBONE2: f, RIGHT_FISHBONE: p, RIGHT_FISHBONE2: m } = e.LAYOUT, { LEFT: h, TOP: g, RIGHT: _, BOTTOM: v } = e.LAYOUT_GROW_DIR, y = this.overlapNode.layerIndex, b = this.overlapNode.children, x = this.mindMap.renderer.layout.getMarginX(y + 1), S = this.mindMap.renderer.layout.getMarginY(y + 1), C = this.placeholderWidth / 2, w = this.placeholderHeight / 2, T = "", E = "", D = "", O = !1, k = !1;
|
|
152
|
+
if (b.length > 0) {
|
|
153
|
+
let e = b[b.length - 1], v = this.getNodeRect(e);
|
|
154
|
+
switch (T = this.getNewChildNodeDir(e), this.mindMap.opt.layout) {
|
|
155
|
+
case t:
|
|
156
|
+
case r:
|
|
157
|
+
E = T === h ? v.originRight - this.placeholderWidth : v.originLeft, D = v.originBottom + this.minOffset - w;
|
|
158
|
+
break;
|
|
159
|
+
case n:
|
|
160
|
+
E = v.originRight - this.placeholderWidth, D = v.originBottom + this.minOffset - w;
|
|
161
|
+
break;
|
|
162
|
+
case i:
|
|
163
|
+
O = !0, E = v.originRight + this.minOffset - w, D = v.originTop;
|
|
164
|
+
break;
|
|
165
|
+
case a:
|
|
166
|
+
y === 0 ? (O = !0, E = v.originRight + this.minOffset - w, D = v.originTop) : (E = v.originLeft, D = v.originBottom + this.minOffset - w);
|
|
167
|
+
break;
|
|
168
|
+
case o:
|
|
169
|
+
y === 0 ? (O = !0, E = v.originRight + this.minOffset - w, D = v.originTop + v.originHeight / 2 - C) : (E = v.originLeft, D = v.originBottom + this.minOffset - w);
|
|
170
|
+
break;
|
|
171
|
+
case s:
|
|
172
|
+
y === 0 ? (O = !0, E = v.originRight + this.minOffset - w, D = v.originTop + v.originHeight / 2 - C) : (E = v.originLeft, D = y === 1 && T === g ? v.originTop - this.placeholderHeight - this.minOffset + w : v.originBottom + this.minOffset - w);
|
|
173
|
+
break;
|
|
174
|
+
case c:
|
|
175
|
+
case l:
|
|
176
|
+
case u:
|
|
177
|
+
y === 0 ? (E = v.originLeft + v.originWidth / 2 - C, D = v.originBottom + this.minOffset - w) : (E = T === _ ? v.originLeft : v.originRight - this.placeholderWidth, D = v.originBottom + this.minOffset - w);
|
|
178
|
+
break;
|
|
179
|
+
case d:
|
|
180
|
+
case f:
|
|
181
|
+
case p:
|
|
182
|
+
case m:
|
|
183
|
+
y <= 1 ? (k = !0, this.mindMap.execCommand("SET_NODE_ACTIVE", this.overlapNode, !0)) : (E = v.originLeft, D = T === g ? v.originBottom + this.minOffset - w : v.originTop - this.placeholderHeight - this.minOffset + w);
|
|
184
|
+
break;
|
|
185
|
+
default:
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
let e = this.getNodeRect(this.overlapNode);
|
|
189
|
+
switch (T = this.getNewChildNodeDir(this.overlapNode), this.mindMap.opt.layout) {
|
|
190
|
+
case t:
|
|
191
|
+
case r:
|
|
192
|
+
E = T === _ ? e.originRight + x : e.originLeft - this.placeholderWidth - x, D = e.originTop + (e.originHeight - this.placeholderHeight) / 2;
|
|
193
|
+
break;
|
|
194
|
+
case n:
|
|
195
|
+
E = e.originLeft - this.placeholderWidth - x, D = e.originTop + (e.originHeight - this.placeholderHeight) / 2;
|
|
196
|
+
break;
|
|
197
|
+
case i:
|
|
198
|
+
O = !0, E = e.originLeft + (e.originWidth - this.placeholderHeight) / 2, D = e.originBottom + x;
|
|
199
|
+
break;
|
|
200
|
+
case a:
|
|
201
|
+
y === 0 && (O = !0), E = e.originLeft + e.originWidth * .5, D = e.originBottom + x;
|
|
202
|
+
break;
|
|
203
|
+
case o:
|
|
204
|
+
y === 0 && (O = !0), E = e.originLeft + e.originWidth * .5, D = e.originBottom + S;
|
|
205
|
+
break;
|
|
206
|
+
case s:
|
|
207
|
+
y === 0 && (O = !0), E = e.originLeft + e.originWidth * .5, D = y === 1 && T === g ? e.originTop - this.placeholderHeight - x : e.originBottom + x;
|
|
208
|
+
break;
|
|
209
|
+
case c:
|
|
210
|
+
case l:
|
|
211
|
+
case u:
|
|
212
|
+
y === 0 && (O = !0), E = T === _ ? e.originRight + x : e.originLeft - this.placeholderWidth - x, D = e.originTop + e.originHeight / 2 - w;
|
|
213
|
+
break;
|
|
214
|
+
case d:
|
|
215
|
+
case f:
|
|
216
|
+
case p:
|
|
217
|
+
case m:
|
|
218
|
+
y <= 1 ? (k = !0, this.mindMap.execCommand("SET_NODE_ACTIVE", this.overlapNode, !0)) : (E = e.originLeft + e.originWidth * .5, D = T === v ? e.originTop - this.placeholderHeight - this.minOffset + w : e.originBottom + this.minOffset - w);
|
|
219
|
+
break;
|
|
220
|
+
default:
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
k || this.setPlaceholderRect({
|
|
224
|
+
x: E,
|
|
225
|
+
y: D,
|
|
226
|
+
dir: T,
|
|
227
|
+
rotate: O
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
getNewChildNodeDir(t) {
|
|
231
|
+
let { LOGICAL_STRUCTURE: n, LOGICAL_STRUCTURE_LEFT: r, MIND_MAP: i, TIMELINE2: a, VERTICAL_TIMELINE: o, VERTICAL_TIMELINE2: s, VERTICAL_TIMELINE3: c, FISHBONE: l, FISHBONE2: u, RIGHT_FISHBONE: d, RIGHT_FISHBONE2: f } = e.LAYOUT;
|
|
232
|
+
switch (this.mindMap.opt.layout) {
|
|
233
|
+
case n: return e.LAYOUT_GROW_DIR.RIGHT;
|
|
234
|
+
case r: return e.LAYOUT_GROW_DIR.LEFT;
|
|
235
|
+
case i:
|
|
236
|
+
case a:
|
|
237
|
+
case o:
|
|
238
|
+
case s:
|
|
239
|
+
case c:
|
|
240
|
+
case l:
|
|
241
|
+
case u:
|
|
242
|
+
case d:
|
|
243
|
+
case f: return t.dir;
|
|
244
|
+
default: return "";
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
handleVerticalCheck(t, n, r = !1) {
|
|
248
|
+
let { layout: i } = this.mindMap.opt, { LAYOUT: a, LAYOUT_GROW_DIR: o } = e, { VERTICAL_TIMELINE: s, VERTICAL_TIMELINE2: c, VERTICAL_TIMELINE3: l, FISHBONE: u, FISHBONE2: d, RIGHT_FISHBONE: f, RIGHT_FISHBONE2: p } = a, { LEFT: m } = o, h = this.mouseMoveX, g = this.mouseMoveY, _ = this.getNodeRect(t), v = this.getNewChildNodeDir(t), y = t.layerIndex;
|
|
249
|
+
r && (n = n.reverse());
|
|
250
|
+
let b = _.originHeight / 4, { prevBrotherOffset: x, nextBrotherOffset: S } = this.getNodeDistanceToSiblingNode(n, t, _, "v");
|
|
251
|
+
if (_.left <= h && _.right >= h) {
|
|
252
|
+
if (!this.overlapNode && !this.prevNode && !this.nextNode && !t.isRoot) {
|
|
253
|
+
let e = S > 0 ? g > _.bottom && g <= _.bottom + S : g >= _.bottom - b && g <= _.bottom, n = x > 0 ? g < _.top && g >= _.top - x : g >= _.top && g <= _.top + b, { scaleY: a } = this.drawTransform, o = v === m ? _.originRight - this.placeholderWidth : _.originLeft, h = !1;
|
|
254
|
+
switch (i) {
|
|
255
|
+
case s:
|
|
256
|
+
case c:
|
|
257
|
+
case l:
|
|
258
|
+
y === 1 && (o = _.originLeft + _.originWidth / 2 - this.placeholderWidth / 2);
|
|
259
|
+
break;
|
|
260
|
+
case f:
|
|
261
|
+
case p:
|
|
262
|
+
o = _.originLeft + _.originWidth - this.placeholderWidth;
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
}
|
|
266
|
+
if (e) {
|
|
267
|
+
r ? this.nextNode = t : this.prevNode = t;
|
|
268
|
+
let e = _.originBottom + S / a - this.placeholderHeight / 2;
|
|
269
|
+
switch (i) {
|
|
270
|
+
case u:
|
|
271
|
+
case d:
|
|
272
|
+
case f:
|
|
273
|
+
case p:
|
|
274
|
+
y === 2 && (h = !0, e = _.originBottom + this.minOffset - this.placeholderHeight / 2);
|
|
275
|
+
break;
|
|
276
|
+
default:
|
|
277
|
+
}
|
|
278
|
+
this.setPlaceholderRect({
|
|
279
|
+
x: o,
|
|
280
|
+
y: e,
|
|
281
|
+
dir: v,
|
|
282
|
+
notRenderLine: h
|
|
283
|
+
});
|
|
284
|
+
} else if (n) {
|
|
285
|
+
r ? this.prevNode = t : this.nextNode = t;
|
|
286
|
+
let e = _.originTop - this.placeholderHeight - x / a + this.placeholderHeight / 2;
|
|
287
|
+
switch (i) {
|
|
288
|
+
case u:
|
|
289
|
+
case d:
|
|
290
|
+
case f:
|
|
291
|
+
case p:
|
|
292
|
+
y === 2 && (h = !0, e = _.originTop - this.placeholderHeight - this.minOffset + this.placeholderHeight / 2);
|
|
293
|
+
break;
|
|
294
|
+
default:
|
|
295
|
+
}
|
|
296
|
+
this.setPlaceholderRect({
|
|
297
|
+
x: o,
|
|
298
|
+
y: e,
|
|
299
|
+
dir: v,
|
|
300
|
+
notRenderLine: h
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
this.checkIsOverlap({
|
|
305
|
+
node: t,
|
|
306
|
+
dir: "v",
|
|
307
|
+
prevBrotherOffset: x,
|
|
308
|
+
nextBrotherOffset: S,
|
|
309
|
+
size: b,
|
|
310
|
+
pos: g,
|
|
311
|
+
nodeRect: _
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
handleHorizontalCheck(t, n) {
|
|
316
|
+
let { layout: r } = this.mindMap.opt, { LAYOUT: i } = e, { FISHBONE: a, FISHBONE2: o, RIGHT_FISHBONE: s, RIGHT_FISHBONE2: c, TIMELINE: l, TIMELINE2: u } = i, d = this.mouseMoveX, f = this.mouseMoveY, p = this.getNodeRect(t), m = p.originWidth / 4, { prevBrotherOffset: h, nextBrotherOffset: g } = this.getNodeDistanceToSiblingNode(n, t, p, "h");
|
|
317
|
+
if (p.top <= f && p.bottom >= f) {
|
|
318
|
+
if (!this.overlapNode && !this.prevNode && !this.nextNode && !t.isRoot) {
|
|
319
|
+
let e = g > 0 ? d < p.right + g && d >= p.right : d <= p.right && d >= p.right - m, n = h > 0 ? d > p.left - h && d <= p.left : d <= p.left + m && d >= p.left, { scaleX: i } = this.drawTransform, f = t.layerIndex, _ = p.originTop, v = !1;
|
|
320
|
+
switch (r) {
|
|
321
|
+
case l:
|
|
322
|
+
case u:
|
|
323
|
+
_ = p.originTop + p.originHeight / 2 - this.placeholderWidth / 2;
|
|
324
|
+
break;
|
|
325
|
+
case a:
|
|
326
|
+
case o:
|
|
327
|
+
case s:
|
|
328
|
+
case c:
|
|
329
|
+
f === 1 && (v = !0, _ = p.originTop + p.originHeight / 2 - this.placeholderWidth / 2);
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
}
|
|
333
|
+
e ? ([s, c].includes(r) ? this.nextNode = t : this.prevNode = t, this.setPlaceholderRect({
|
|
334
|
+
x: p.originRight + g / i - this.placeholderHeight / 2,
|
|
335
|
+
y: _,
|
|
336
|
+
rotate: !0,
|
|
337
|
+
notRenderLine: v
|
|
338
|
+
})) : n && ([s, c].includes(r) ? this.prevNode = t : this.nextNode = t, this.setPlaceholderRect({
|
|
339
|
+
x: p.originLeft - this.placeholderHeight - h / i + this.placeholderHeight / 2,
|
|
340
|
+
y: _,
|
|
341
|
+
rotate: !0,
|
|
342
|
+
notRenderLine: v
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
this.checkIsOverlap({
|
|
346
|
+
node: t,
|
|
347
|
+
dir: "h",
|
|
348
|
+
prevBrotherOffset: h,
|
|
349
|
+
nextBrotherOffset: g,
|
|
350
|
+
size: m,
|
|
351
|
+
pos: d,
|
|
352
|
+
nodeRect: p
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
getNodeDistanceToSiblingNode(t, n, r, a) {
|
|
357
|
+
let { TOP: o, LEFT: s, BOTTOM: c, RIGHT: l } = e.LAYOUT_GROW_DIR, { scaleX: u, scaleY: d } = this.drawTransform, f = a === "v" ? o : s, p = a === "v" ? c : l, m = a === "v" ? d : u, h = this.minOffset * m, g = i(n, t), _ = null, v = null;
|
|
358
|
+
g !== -1 && (g - 1 >= 0 && (_ = t[g - 1]), g + 1 <= t.length - 1 && (v = t[g + 1]));
|
|
359
|
+
let y = 0;
|
|
360
|
+
if (_) {
|
|
361
|
+
let e = this.getNodeRect(_);
|
|
362
|
+
y = r[f] - e[p], y = y >= h ? y / 2 : 0;
|
|
363
|
+
} else y = h;
|
|
364
|
+
let b = 0;
|
|
365
|
+
return v ? (b = this.getNodeRect(v)[f] - r[p], b = b >= h ? b / 2 : 0) : b = h, {
|
|
366
|
+
prevBrother: _,
|
|
367
|
+
prevBrotherOffset: y,
|
|
368
|
+
nextBrother: v,
|
|
369
|
+
nextBrotherOffset: b
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
setPlaceholderRect({ x: e, y: t, dir: n, rotate: r, notRenderLine: i }) {
|
|
373
|
+
let a = this.placeholderWidth, o = this.placeholderHeight;
|
|
374
|
+
if (r) {
|
|
375
|
+
let e = a;
|
|
376
|
+
a = o, o = e;
|
|
377
|
+
}
|
|
378
|
+
if (this.placeholder.size(a, o).move(e, t), i) return;
|
|
379
|
+
let { dragPlaceholderLineConfig: s } = this.mindMap.opt, c = null, l = null;
|
|
380
|
+
this.overlapNode ? (c = this.overlapNode, l = this.overlapNode) : (c = this.prevNode || this.nextNode, l = c.parent), l = l.fakeClone(), c = c.fakeClone();
|
|
381
|
+
let u = this.beingDragNodeList[0].fakeClone();
|
|
382
|
+
u.dir = n, u.left = e, u.top = t, u.width = a, u.height = o, l.children = [u], l._lines = [], this.placeHolderLine.show(), this.mindMap.renderer.layout.renderLine(l, [this.placeHolderLine], (...e) => {}, c.style.getStyle("lineStyle", !0)), this.placeHolderExtraLines = [...l._lines], this.placeHolderExtraLines.forEach((e) => {
|
|
383
|
+
this.mindMap.otherDraw.add(e), e.stroke({
|
|
384
|
+
color: s.color,
|
|
385
|
+
width: s.width
|
|
386
|
+
}).fill({ color: "none" });
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
checkIsOverlap({ node: t, dir: n, prevBrotherOffset: r, nextBrotherOffset: i, size: a, pos: o, nodeRect: s }) {
|
|
390
|
+
let { TOP: c, LEFT: l, BOTTOM: u, RIGHT: d } = e.LAYOUT_GROW_DIR, f = n === "v" ? c : l, p = n === "v" ? u : d;
|
|
391
|
+
!this.overlapNode && !this.prevNode && !this.nextNode && s[f] + (r > 0 ? 0 : a) <= o && s[p] - (i > 0 ? 0 : a) >= o && (this.overlapNode = t);
|
|
392
|
+
}
|
|
393
|
+
handleLogicalStructure(e) {
|
|
394
|
+
let t = this.commonGetNodeCheckList(e);
|
|
395
|
+
this.handleVerticalCheck(e, t);
|
|
396
|
+
}
|
|
397
|
+
handleMindMap(e) {
|
|
398
|
+
let t = e.parent ? e.parent.children.filter((t) => {
|
|
399
|
+
let n = !0;
|
|
400
|
+
return e.layerIndex === 1 && (n = t.dir === e.dir), n && !this.checkIsInBeingDragNodeList(t);
|
|
401
|
+
}) : [];
|
|
402
|
+
this.handleVerticalCheck(e, t);
|
|
403
|
+
}
|
|
404
|
+
handleOrganizationStructure(e) {
|
|
405
|
+
let t = this.commonGetNodeCheckList(e);
|
|
406
|
+
this.handleHorizontalCheck(e, t);
|
|
407
|
+
}
|
|
408
|
+
handleCatalogOrganization(e) {
|
|
409
|
+
let t = this.commonGetNodeCheckList(e);
|
|
410
|
+
e.layerIndex === 1 ? this.handleHorizontalCheck(e, t) : this.handleVerticalCheck(e, t);
|
|
411
|
+
}
|
|
412
|
+
handleTimeLine(e) {
|
|
413
|
+
let t = this.commonGetNodeCheckList(e);
|
|
414
|
+
e.layerIndex === 1 ? this.handleHorizontalCheck(e, t) : this.handleVerticalCheck(e, t);
|
|
415
|
+
}
|
|
416
|
+
handleTimeLine2(t) {
|
|
417
|
+
let n = this.commonGetNodeCheckList(t);
|
|
418
|
+
t.layerIndex === 1 ? this.handleHorizontalCheck(t, n) : t.dir === e.LAYOUT_GROW_DIR.TOP && t.layerIndex === 2 ? this.handleVerticalCheck(t, n, !0) : this.handleVerticalCheck(t, n);
|
|
419
|
+
}
|
|
420
|
+
handleFishbone(t) {
|
|
421
|
+
let n = t.parent ? t.parent.children.filter((e) => e.layerIndex > 1 && !this.checkIsInBeingDragNodeList(e)) : [];
|
|
422
|
+
if (t.layerIndex === 1) this.handleHorizontalCheck(t, n);
|
|
423
|
+
else {
|
|
424
|
+
let r = t.dir === e.LAYOUT_GROW_DIR.TOP && t.layerIndex === 2, i = t.dir === e.LAYOUT_GROW_DIR.BOTTOM && t.layerIndex >= 3;
|
|
425
|
+
r || i ? this.handleVerticalCheck(t, n, !0) : this.handleVerticalCheck(t, n);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
commonGetNodeCheckList(e) {
|
|
429
|
+
return e.parent ? [...e.parent.children].filter((e) => !this.checkIsInBeingDragNodeList(e)) : [];
|
|
430
|
+
}
|
|
431
|
+
getNodeRect(e) {
|
|
432
|
+
let { scaleX: t, scaleY: n, translateX: r, translateY: i } = this.drawTransform, { left: a, top: o, width: s, height: c } = e, l = s, u = c, d = a, f = o, p = o + c, m = a + s, h = (a + s) * t + r, g = (o + c) * n + i;
|
|
433
|
+
return a = a * t + r, o = o * n + i, {
|
|
434
|
+
left: a,
|
|
435
|
+
top: o,
|
|
436
|
+
right: h,
|
|
437
|
+
bottom: g,
|
|
438
|
+
originWidth: l,
|
|
439
|
+
originHeight: u,
|
|
440
|
+
originLeft: d,
|
|
441
|
+
originTop: f,
|
|
442
|
+
originBottom: p,
|
|
443
|
+
originRight: m
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
checkIsInBeingDragNodeList(e) {
|
|
447
|
+
return !!this.beingDragNodeList.find((t) => t.uid === e.uid || t.isAncestor(e));
|
|
448
|
+
}
|
|
449
|
+
beforePluginRemove() {
|
|
450
|
+
this.unBindEvent();
|
|
451
|
+
}
|
|
452
|
+
beforePluginDestroy() {
|
|
453
|
+
this.unBindEvent();
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
c.instanceName = "drag";
|
|
457
|
+
//#endregion
|
|
458
|
+
export { c as default };
|