@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.
@@ -0,0 +1,98 @@
1
+ import { G as e, L as t, q as n } from "./utils-DjW7eJ1w.mjs";
2
+ //#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/MiniMap.js
3
+ var r = class {
4
+ constructor(e) {
5
+ this.mindMap = e.mindMap, this.isMousedown = !1, this.mousedownPos = {
6
+ x: 0,
7
+ y: 0
8
+ }, this.startViewPos = {
9
+ x: 0,
10
+ y: 0
11
+ }, this.currentState = null;
12
+ }
13
+ calculationMiniMap(e, t) {
14
+ let { svg: n, rect: r, origWidth: i, origHeight: a, scaleX: o, scaleY: s } = this.mindMap.getSvgData({ ignoreWatermark: !0 }), c = this.mindMap.elRect;
15
+ r.x -= c.left, r.x2 -= c.left, r.y -= c.top, r.y2 -= c.top;
16
+ let l = e / t, u = 0, d = 0;
17
+ l > r.ratio ? (d = t, u = r.ratio * d) : (u = e, d = u / r.ratio);
18
+ let f = u / r.width, p = (e - u) / 2, m = (t - d) / 2, h = r.width * o, g = r.height * s, _ = (h - r.width) / 2, v = (g - r.height) / 2, y = r.x - _, b = r.x2 + _, x = r.y - v, S = r.y2 + v, C = {
19
+ left: 0,
20
+ top: 0,
21
+ right: 0,
22
+ bottom: 0
23
+ };
24
+ C.left = Math.max(0, -y / h * u) + p, C.right = Math.max(0, (b - i) / h * u) + p, C.top = Math.max(0, -x / g * d) + m, C.bottom = Math.max(0, (S - a) / g * d) + m, C.top > m + d && (C.top = m + d), C.left > p + u && (C.left = p + u), Object.keys(C).forEach((e) => {
25
+ C[e] = C[e] + "px";
26
+ }), this.removeNodeContent(n);
27
+ let w = n.svg();
28
+ return this.currentState = {
29
+ viewBoxStyle: { ...C },
30
+ miniMapBoxScale: f,
31
+ miniMapBoxLeft: p,
32
+ miniMapBoxTop: m
33
+ }, {
34
+ getImgUrl: async (e) => {
35
+ e(await this.mindMap.doExport.fixSvgStrAndToBlob(w));
36
+ },
37
+ svgHTML: w,
38
+ viewBoxStyle: C,
39
+ miniMapBoxScale: f,
40
+ miniMapBoxLeft: p,
41
+ miniMapBoxTop: m
42
+ };
43
+ }
44
+ removeNodeContent(r) {
45
+ if (r.hasClass("smm-node")) {
46
+ let i = r.findOne(".smm-node-shape"), a = i.attr("fill");
47
+ (n(a) || e(a)) && i.attr("fill", t(this.mindMap.themeConfig)), r.clear(), r.add(i);
48
+ return;
49
+ }
50
+ let i = r.children();
51
+ i && i.length > 0 && i.forEach((e) => {
52
+ this.removeNodeContent(e);
53
+ });
54
+ }
55
+ onMousedown(e) {
56
+ this.isMousedown = !0, this.mousedownPos = {
57
+ x: e.clientX,
58
+ y: e.clientY
59
+ };
60
+ let t = this.mindMap.view.getTransformData();
61
+ this.startViewPos = {
62
+ x: t.state.x,
63
+ y: t.state.y
64
+ };
65
+ }
66
+ onMousemove(e, t = 5) {
67
+ if (!this.isMousedown || this.isViewBoxMousedown) return;
68
+ let n = e.clientX - this.mousedownPos.x, r = e.clientY - this.mousedownPos.y;
69
+ this.mindMap.view.translateXTo(n * t + this.startViewPos.x), this.mindMap.view.translateYTo(r * t + this.startViewPos.y);
70
+ }
71
+ onMouseup() {
72
+ this.isMousedown = !1, this.isViewBoxMousedown = !1;
73
+ }
74
+ onViewBoxMousedown(e) {
75
+ this.isViewBoxMousedown = !0, this.mousedownPos = {
76
+ x: e.clientX,
77
+ y: e.clientY
78
+ };
79
+ let t = this.mindMap.view.getTransformData();
80
+ this.startViewPos = {
81
+ x: t.state.x,
82
+ y: t.state.y
83
+ };
84
+ }
85
+ onViewBoxMousemove(e) {
86
+ if (!this.isViewBoxMousedown || !this.currentState || this.isMousedown) return;
87
+ let t = e.clientX - this.mousedownPos.x, n = e.clientY - this.mousedownPos.y, { viewBoxStyle: r, miniMapBoxScale: i, miniMapBoxLeft: a, miniMapBoxTop: o } = this.currentState, s = Math.max(a, Number.parseFloat(r.left) + t), c = Math.max(a, Number.parseFloat(r.right) - t), l = Math.max(o, Number.parseFloat(r.top) + n), u = Math.max(o, Number.parseFloat(r.bottom) - n);
88
+ this.mindMap.emit("mini_map_view_box_position_change", {
89
+ left: s + "px",
90
+ right: c + "px",
91
+ top: l + "px",
92
+ bottom: u + "px"
93
+ }), this.mindMap.view.translateXTo(-t / i + this.startViewPos.x), this.mindMap.view.translateYTo(-n / i + this.startViewPos.y);
94
+ }
95
+ };
96
+ r.instanceName = "miniMap";
97
+ //#endregion
98
+ export { r as default };
@@ -0,0 +1,138 @@
1
+ import { ot as e } from "./utils-DjW7eJ1w.mjs";
2
+ import { t } from "./btns-Cf5zZK5X.mjs";
3
+ //#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/NodeImgAdjust.js
4
+ var n = class {
5
+ constructor({ mindMap: e }) {
6
+ this.mindMap = e, this.handleEl = null, this.isShowHandleEl = !1, this.node = null, this.img = null, this.rect = null, this.isMousedown = !1, this.mousedownDrawTransform = null, this.mousedownOffset = {
7
+ x: 0,
8
+ y: 0
9
+ }, this.currentImgWidth = 0, this.currentImgHeight = 0, this.isAdjusted = !1, this.bindEvent();
10
+ }
11
+ bindEvent() {
12
+ this.onNodeImgMouseleave = this.onNodeImgMouseleave.bind(this), this.onNodeImgMousemove = this.onNodeImgMousemove.bind(this), this.onMousemove = this.onMousemove.bind(this), this.onMouseup = this.onMouseup.bind(this), this.onRenderEnd = this.onRenderEnd.bind(this), this.onScale = this.onScale.bind(this), this.mindMap.on("node_img_mouseleave", this.onNodeImgMouseleave), this.mindMap.on("node_img_mousemove", this.onNodeImgMousemove), this.mindMap.on("mousemove", this.onMousemove), this.mindMap.on("mouseup", this.onMouseup), this.mindMap.on("node_mouseup", this.onMouseup), this.mindMap.on("node_tree_render_end", this.onRenderEnd), this.mindMap.on("scale", this.onScale);
13
+ }
14
+ unBindEvent() {
15
+ this.mindMap.off("node_img_mouseleave", this.onNodeImgMouseleave), this.mindMap.off("node_img_mousemove", this.onNodeImgMousemove), this.mindMap.off("mousemove", this.onMousemove), this.mindMap.off("mouseup", this.onMouseup), this.mindMap.off("node_mouseup", this.onMouseup), this.mindMap.off("node_tree_render_end", this.onRenderEnd), this.mindMap.off("scale", this.onScale);
16
+ }
17
+ onScale() {
18
+ this.node && this.img && this.isShowHandleEl && (this.rect = this.img.rbox(), this.setHandleElRect());
19
+ }
20
+ onNodeImgMousemove(e, t) {
21
+ this.isMousedown || this.isAdjusted || this.mindMap.opt.readonly || this.node && this.node.uid === e.uid && this.isShowHandleEl || (this.node = e, this.img = t, this.rect = this.img.rbox(), this.showHandleEl());
22
+ }
23
+ onNodeImgMouseleave() {
24
+ this.isMousedown || this.hideHandleEl();
25
+ }
26
+ hideNodeImage() {
27
+ this.img && this.img.hide();
28
+ }
29
+ showNodeImage() {
30
+ this.img && this.img.show();
31
+ }
32
+ showHandleEl() {
33
+ this.isShowHandleEl ||= (this.handleEl || this.createResizeBtnEl(), this.setHandleElRect(), this.handleEl.style.display = "block", !0);
34
+ }
35
+ hideHandleEl() {
36
+ this.isShowHandleEl && (this.isShowHandleEl = !1, this.handleEl.style.display = "none", this.handleEl.style.backgroundImage = "", this.handleEl.style.width = 0, this.handleEl.style.height = 0, this.handleEl.style.left = 0, this.handleEl.style.top = 0);
37
+ }
38
+ setHandleElRect() {
39
+ let { width: e, height: t, x: n, y: r } = this.rect;
40
+ this.handleEl.style.left = `${n}px`, this.handleEl.style.top = `${r}px`, this.currentImgWidth = e, this.currentImgHeight = t, this.updateHandleElSize();
41
+ }
42
+ updateHandleElSize() {
43
+ this.handleEl.style.width = `${this.currentImgWidth}px`, this.handleEl.style.height = `${this.currentImgHeight}px`;
44
+ }
45
+ createResizeBtnEl() {
46
+ let { imgResizeBtnSize: e, customResizeBtnInnerHTML: n, customDeleteBtnInnerHTML: r } = this.mindMap.opt;
47
+ this.handleEl = document.createElement("div"), this.handleEl.style.cssText = "\n pointer-events: none;\n position: fixed;\n display:none;\n background-size: cover;\n ", this.handleEl.className = "node-img-handle";
48
+ let i = document.createElement("div");
49
+ i.innerHTML = n || t.imgAdjust, i.style.cssText = `
50
+ position: absolute;
51
+ right: 0;
52
+ bottom: 0;
53
+ pointer-events: auto;
54
+ background-color: rgba(0, 0, 0, 0.3);
55
+ width: ${e}px;
56
+ height: ${e}px;
57
+ display: flex;
58
+ justify-content: center;
59
+ align-items: center;
60
+ cursor: nwse-resize;
61
+ `, i.className = "node-image-resize", i.addEventListener("mouseenter", () => {
62
+ this.showHandleEl();
63
+ }), i.addEventListener("mouseleave", () => {
64
+ this.isMousedown || this.hideHandleEl();
65
+ }), i.addEventListener("mousedown", (e) => {
66
+ e.stopPropagation(), e.preventDefault(), this.onMousedown(e);
67
+ }), i.addEventListener("mouseup", (e) => {
68
+ setTimeout(() => {
69
+ this.hideHandleEl(), this.isAdjusted = !1;
70
+ }, 0);
71
+ }), i.addEventListener("click", (e) => {
72
+ e.stopPropagation();
73
+ }), this.handleEl.appendChild(i);
74
+ let a = document.createElement("div");
75
+ this.handleEl.prepend(a), a.className = "node-image-remove", a.innerHTML = r || t.remove, a.style.cssText = `
76
+ position: absolute;
77
+ right: 0;top:0;color:#fff;
78
+ pointer-events: auto;
79
+ background-color: rgba(0, 0, 0, 0.3);
80
+ width: ${e}px;
81
+ height: ${e}px;
82
+ display: flex;
83
+ justify-content: center;
84
+ align-items: center;
85
+ cursor: pointer;
86
+ `, a.addEventListener("mouseenter", (e) => {
87
+ this.showHandleEl();
88
+ }), a.addEventListener("mouseleave", (e) => {
89
+ this.isMousedown || this.hideHandleEl();
90
+ }), a.addEventListener("click", async (e) => {
91
+ let t = !1;
92
+ typeof this.mindMap.opt.beforeDeleteNodeImg == "function" && (t = await this.mindMap.opt.beforeDeleteNodeImg(this.node)), t || (this.mindMap.execCommand("SET_NODE_IMAGE", this.node, { url: null }), this.mindMap.emit("delete_node_img_from_delete_btn", this.node));
93
+ }), (this.mindMap.opt.customInnerElsAppendTo || document.body).appendChild(this.handleEl);
94
+ }
95
+ onMousedown(e) {
96
+ this.mindMap.emit("node_img_adjust_btn_mousedown", this.node), this.isMousedown = !0, this.mousedownDrawTransform = this.mindMap.draw.transform(), this.hideNodeImage(), this.mousedownOffset.x = e.clientX - this.rect.x2, this.mousedownOffset.y = e.clientY - this.rect.y2, this.handleEl.style.backgroundImage = `url(${this.node.getData("image")})`;
97
+ }
98
+ onMousemove(t) {
99
+ if (!this.isMousedown) return;
100
+ t.preventDefault();
101
+ let { scaleX: n, scaleY: r } = this.mousedownDrawTransform, { width: i, height: a } = this.node.getData("imageSize"), { minImgResizeWidth: o, minImgResizeHeight: s, maxImgResizeWidthInheritTheme: c, maxImgResizeWidth: l, maxImgResizeHeight: u } = this.mindMap.opt, d = o / s, f = i / a;
102
+ d > f ? s = o / f : o = s * f;
103
+ let p, m;
104
+ c ? (p = this.mindMap.getThemeConfig("imgMaxWidth"), m = this.mindMap.getThemeConfig("imgMaxHeight")) : (p = l, m = u), p *= n, m *= r;
105
+ let h = Math.abs(t.clientX - this.rect.x - this.mousedownOffset.x), g = Math.abs(t.clientY - this.rect.y - this.mousedownOffset.y);
106
+ h < o && (h = o), g < s && (g = s), h > p && (h = p), g > m && (g = m);
107
+ let [_, v] = e(i, a, h, g);
108
+ this.currentImgWidth = _, this.currentImgHeight = v, this.updateHandleElSize();
109
+ }
110
+ onMouseup() {
111
+ if (!this.isMousedown) return;
112
+ this.showNodeImage(), this.hideHandleEl();
113
+ let { image: e, imageTitle: t } = this.node.getData(), { scaleX: n, scaleY: r } = this.mousedownDrawTransform, i = this.currentImgWidth / n, a = this.currentImgHeight / r;
114
+ (Math.abs(i - this.rect.width) > 1 || Math.abs(a - this.rect.height) > 1) && (this.mindMap.execCommand("SET_NODE_IMAGE", this.node, {
115
+ url: e,
116
+ title: t,
117
+ width: i,
118
+ height: a,
119
+ custom: !0
120
+ }), this.isAdjusted = !0), this.isMousedown = !1, this.mousedownDrawTransform = null, this.mousedownOffset.x = 0, this.mousedownOffset.y = 0;
121
+ }
122
+ onRenderEnd() {
123
+ if (!this.isAdjusted) {
124
+ this.hideHandleEl();
125
+ return;
126
+ }
127
+ this.isAdjusted = !1;
128
+ }
129
+ beforePluginRemove() {
130
+ this.unBindEvent();
131
+ }
132
+ beforePluginDestroy() {
133
+ this.unBindEvent();
134
+ }
135
+ };
136
+ n.instanceName = "nodeImgAdjust";
137
+ //#endregion
138
+ export { n as default };
@@ -0,0 +1,325 @@
1
+ import { A as e, C as t, Ct as n, I as r, P as i, S as a, Tt as o, _ as s, pt as c, st as l, yt as u } from "./utils-DjW7eJ1w.mjs";
2
+ //#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/outerFrame/outerFrameUtils.js
3
+ var d = (e) => {
4
+ e = r(e);
5
+ let t = {}, n = {};
6
+ e.forEach((e) => {
7
+ let r = e.parent;
8
+ if (r) {
9
+ let i = r.uid;
10
+ n[i] = r;
11
+ let a = {
12
+ node: e,
13
+ index: e.getIndexInBrothers()
14
+ };
15
+ t[i] ? t[i].find((e) => e.index === a.index) || t[i].push(a) : t[i] = [a];
16
+ }
17
+ });
18
+ let i = [];
19
+ return Object.keys(t).forEach((e) => {
20
+ let r = t[e], a = n[e];
21
+ if (r.length > 1) {
22
+ let e = r.map((e) => e.index).sort((e, t) => e - t), t = e[0], n = e[e.length - 1], o = -1, s = -1;
23
+ for (let r = t; r <= n; r++) e.includes(r) ? (o === -1 && (o = r), s = r) : (o !== -1 && s !== -1 && i.push({
24
+ node: a,
25
+ range: [o, s]
26
+ }), o = -1, s = -1);
27
+ o !== -1 && s !== -1 && i.push({
28
+ node: a,
29
+ range: [o, s]
30
+ });
31
+ } else i.push({
32
+ node: a,
33
+ range: [r[0].index, r[0].index]
34
+ });
35
+ }), i;
36
+ }, f = (e) => {
37
+ let t = e.children;
38
+ if (!t || t.length <= 0) return;
39
+ let n = [], r = {};
40
+ return t.forEach((e, t) => {
41
+ let i = e.getData("outerFrame");
42
+ if (!i) return;
43
+ let a = i.groupId;
44
+ a ? (r[a] || (r[a] = []), r[a].push({
45
+ node: e,
46
+ index: t
47
+ })) : n.push({
48
+ nodeList: [e],
49
+ range: [t, t]
50
+ });
51
+ }), Object.keys(r).forEach((e) => {
52
+ let t = r[e];
53
+ n.push({
54
+ nodeList: t.map((e) => e.node),
55
+ range: [t[0].index, t[t.length - 1].index]
56
+ });
57
+ }), n;
58
+ }, p = "outer-frame-text-edit-warp";
59
+ function m(e, t, n) {
60
+ let r = this.draw.group(), i = () => {
61
+ (!this.activeOuterFrame || this.activeOuterFrame.el !== e) && this.setActiveOuterFrame(e, t, n, r);
62
+ };
63
+ return r.click((e) => {
64
+ e.stopPropagation(), i();
65
+ }), r.on("dblclick", (e) => {
66
+ e.stopPropagation(), i(), this.showEditTextBox(r);
67
+ }), r;
68
+ }
69
+ function h(e) {
70
+ this.mindMap.emit("before_show_text_edit"), this.mindMap.keyCommand.addShortcut("Enter", () => {
71
+ this.hideEditTextBox();
72
+ }), this.textEditNode || (this.textEditNode = document.createElement("div"), this.textEditNode.className = p, this.textEditNode.style.cssText = "\n position: fixed;\n box-sizing: border-box;\n background-color: #fff;\n box-shadow: 0 0 20px rgba(0,0,0,.5);\n outline: none; \n word-break: break-all;\n ", this.textEditNode.setAttribute("contenteditable", !0), this.textEditNode.addEventListener("keyup", (e) => {
73
+ e.stopPropagation();
74
+ }), this.textEditNode.addEventListener("click", (e) => {
75
+ e.stopPropagation();
76
+ }), (this.mindMap.opt.customInnerElsAppendTo || document.body).appendChild(this.textEditNode));
77
+ let { node: t, range: n } = this.activeOuterFrame, r = this.getStyle(this.getNodeRangeFirstNode(t, n)), [i, o, s, c] = r.textFillPadding, { defaultOuterFrameText: u, nodeTextEditZIndex: d } = this.mindMap.opt, f = this.mindMap.view.scale, m = this.getText(this.getNodeRangeFirstNode(t, n)), h = (m || u).split(/\n/gim);
78
+ this.textEditNode.style.padding = `${i}px ${o}px ${s}px ${c}px`, this.textEditNode.style.fontFamily = r.fontFamily, this.textEditNode.style.fontSize = r.fontSize * f + "px", this.textEditNode.style.fontWeight = r.fontWeight, this.textEditNode.style.fontStyle = r.fontStyle, this.textEditNode.style.lineHeight = h.length > 1 ? r.lineHeight : "normal", this.textEditNode.style.zIndex = d, this.textEditNode.innerHTML = h.join("<br>"), this.textEditNode.style.display = "block", this.updateTextEditBoxPos(e), this.setIsShowTextEdit(!0), m === "" || m === u ? l(this.textEditNode) : a(this.textEditNode);
79
+ }
80
+ function g(e) {
81
+ this.showTextEdit = e, e ? this.mindMap.keyCommand.stopCheckInSvg() : this.mindMap.keyCommand.recoveryCheckInSvg();
82
+ }
83
+ function _() {
84
+ this.textEditNode && (this.mindMap.opt.customInnerElsAppendTo || document.body).removeChild(this.textEditNode);
85
+ }
86
+ function v() {
87
+ this.hideEditTextBox();
88
+ }
89
+ function y(e) {
90
+ let t = e.node.getBoundingClientRect();
91
+ this.textEditNode && (this.textEditNode.style.minWidth = `${t.width}px`, this.textEditNode.style.minHeight = `${t.height}px`, this.textEditNode.style.left = `${t.left}px`, this.textEditNode.style.top = `${t.top}px`);
92
+ }
93
+ function b() {
94
+ if (!this.showTextEdit) return;
95
+ let { el: e, textNode: t, node: n, range: r } = this.activeOuterFrame, a = i(this.textEditNode.innerHTML);
96
+ a = a === this.mindMap.opt.defaultOuterFrameText ? "" : a, this.updateActiveOuterFrame({ text: a }), this.textEditNode.style.display = "none", this.textEditNode.innerHTML = "", this.setIsShowTextEdit(!1), this.renderText(a, e, t, n, r), this.mindMap.emit("hide_text_edit");
97
+ }
98
+ function x(e, t, r, i, a) {
99
+ if (!e) return;
100
+ r.clear();
101
+ let s = new n();
102
+ r.add(s);
103
+ let c = this.getStyle(this.getNodeRangeFirstNode(i, a)), [l, d, f, p] = c.textFillPadding, m = e.replace(/\n$/g, "").split(/\n/gim), h = new u();
104
+ m.forEach((e, t) => {
105
+ e === "" && (e = "");
106
+ let n = new o().text(e);
107
+ n.y(c.fontSize * c.lineHeight * t), this.styleText(n, c), h.add(n);
108
+ }), r.add(h);
109
+ let { width: g, height: _ } = r.bbox(), v = g + l + f, y = _ + d + p;
110
+ s.size(v, y).x(0).dy(0), this.styleTextShape(s, c);
111
+ let b = 0;
112
+ switch (c.textAlign) {
113
+ case "left":
114
+ b = t.x();
115
+ break;
116
+ case "center":
117
+ b = t.x() + t.width() / 2 - v / 2;
118
+ break;
119
+ case "right":
120
+ b = t.x() + t.width() - v;
121
+ break;
122
+ default: break;
123
+ }
124
+ let x = t.y() - y;
125
+ s.x(b), s.y(x), h.x(b + l), h.y(x + d);
126
+ }
127
+ function S(e, t) {
128
+ e.fill({ color: t.textFill }).radius(t.textFillRadius);
129
+ }
130
+ function C(e, t) {
131
+ e.fill({ color: t.color }).css({
132
+ "font-family": t.fontFamily,
133
+ "font-size": t.fontSize + "px",
134
+ "font-weight": t.fontWeight,
135
+ "font-style": t.fontStyle
136
+ });
137
+ }
138
+ function w(e) {
139
+ let t = e.getData("outerFrame");
140
+ return t && t.text ? t.text : "";
141
+ }
142
+ var T = {
143
+ getText: w,
144
+ createText: m,
145
+ styleTextShape: S,
146
+ styleText: C,
147
+ onScale: v,
148
+ showEditTextBox: h,
149
+ setIsShowTextEdit: g,
150
+ removeTextEditEl: _,
151
+ hideEditTextBox: b,
152
+ updateTextEditBoxPos: y,
153
+ renderText: x
154
+ }, E = {
155
+ radius: 5,
156
+ strokeWidth: 2,
157
+ strokeColor: "#0984e3",
158
+ strokeDasharray: "5,5",
159
+ fill: "rgba(9,132,227,0.05)",
160
+ fontSize: 14,
161
+ fontFamily: "微软雅黑, Microsoft YaHei",
162
+ fontWeight: "normal",
163
+ fontStyle: "normal",
164
+ color: "#fff",
165
+ lineHeight: 1.2,
166
+ textFill: "#0984e3",
167
+ textFillRadius: 5,
168
+ textFillPadding: [
169
+ 5,
170
+ 5,
171
+ 5,
172
+ 5
173
+ ],
174
+ textAlign: "left"
175
+ }, D = "outer-frame-text-edit-warp", O = class {
176
+ constructor(e = {}) {
177
+ this.mindMap = e.mindMap, this.draw = null, this.createDrawContainer(), this.isNotRenderOuterFrames = !1, this.textNodeList = [], this.outerFrameElList = [], this.activeOuterFrame = null, this.textEditNode = null, this.showTextEdit = !1, Object.keys(T).forEach((e) => {
178
+ this[e] = T[e].bind(this);
179
+ }), this.mindMap.addEditNodeClass(D), this.bindEvent();
180
+ }
181
+ createDrawContainer() {
182
+ this.draw = this.mindMap.draw.group(), this.draw.addClass("smm-outer-frame-container"), this.draw.back(), this.draw.forward();
183
+ }
184
+ bindEvent() {
185
+ this.renderOuterFrames = this.renderOuterFrames.bind(this), this.mindMap.on("node_tree_render_end", this.renderOuterFrames), this.mindMap.on("data_change", this.renderOuterFrames), this.clearActiveOuterFrame = this.clearActiveOuterFrame.bind(this), this.mindMap.on("draw_click", this.clearActiveOuterFrame), this.mindMap.on("node_click", this.clearActiveOuterFrame), this.mindMap.on("scale", this.onScale), this.onBeforeDestroy = this.onBeforeDestroy.bind(this), this.mindMap.on("beforeDestroy", this.onBeforeDestroy), this.addOuterFrame = this.addOuterFrame.bind(this), this.mindMap.command.add("ADD_OUTER_FRAME", this.addOuterFrame), this.removeActiveOuterFrame = this.removeActiveOuterFrame.bind(this), this.mindMap.keyCommand.addShortcut("Del|Backspace", this.removeActiveOuterFrame);
186
+ }
187
+ unBindEvent() {
188
+ this.mindMap.off("node_tree_render_end", this.renderOuterFrames), this.mindMap.off("data_change", this.renderOuterFrames), this.mindMap.off("draw_click", this.clearActiveOuterFrame), this.mindMap.off("node_click", this.clearActiveOuterFrame), this.mindMap.off("scale", this.onScale), this.mindMap.off("beforeDestroy", this.onBeforeDestroy), this.mindMap.command.remove("ADD_OUTER_FRAME", this.addOuterFrame), this.mindMap.keyCommand.removeShortcut("Del|Backspace", this.removeActiveOuterFrame);
189
+ }
190
+ onBeforeDestroy() {
191
+ this.hideEditTextBox(), this.removeTextEditEl();
192
+ }
193
+ addOuterFrame(e, n = {}) {
194
+ e = t(e);
195
+ let r = this.mindMap.renderer.activeNodeList;
196
+ if (r.length <= 0 && e.length <= 0) return;
197
+ let i = e.length > 0 ? e : r;
198
+ i = i.filter((e) => !e.isRoot && !e.isGeneralization), d(i).forEach(({ node: e, range: t }) => {
199
+ let r = e.children.slice(t[0], t[1] + 1), i = s();
200
+ r.forEach((e) => {
201
+ let t = e.getData("outerFrame");
202
+ t = t ? {
203
+ ...t,
204
+ ...n,
205
+ groupId: i
206
+ } : {
207
+ ...n,
208
+ groupId: i
209
+ }, this.mindMap.execCommand("SET_NODE_DATA", e, { outerFrame: t });
210
+ });
211
+ });
212
+ }
213
+ getActiveOuterFrame() {
214
+ return this.activeOuterFrame ? { ...this.activeOuterFrame } : null;
215
+ }
216
+ removeActiveOuterFrame() {
217
+ if (!this.activeOuterFrame) return;
218
+ let { node: e, range: t } = this.activeOuterFrame;
219
+ this.getRangeNodeList(e, t).forEach((e) => {
220
+ this.mindMap.execCommand("SET_NODE_DATA", e, { outerFrame: null });
221
+ }), this.mindMap.emit("outer_frame_delete");
222
+ }
223
+ removeActiveOuterFrameText() {
224
+ this.updateActiveOuterFrame({ text: "" });
225
+ }
226
+ updateActiveOuterFrame(e = {}) {
227
+ if (!this.activeOuterFrame) return;
228
+ this.isNotRenderOuterFrames = !0;
229
+ let { el: t, node: n, range: r } = this.activeOuterFrame, i = "";
230
+ this.getRangeNodeList(n, r).forEach((t) => {
231
+ let n = {
232
+ ...t.getData("outerFrame"),
233
+ ...e
234
+ };
235
+ i = n.strokeDasharray, this.mindMap.execCommand("SET_NODE_DATA", t, { outerFrame: n });
236
+ }), t.cacheStyle = { dasharray: i }, this.updateOuterFrameStyle();
237
+ }
238
+ updateOuterFrameStyle() {
239
+ let { el: e, node: t, range: n, textNode: r } = this.activeOuterFrame, i = this.getNodeRangeFirstNode(t, n), a = this.getStyle(i);
240
+ this.styleOuterFrame(e, {
241
+ ...a,
242
+ strokeDasharray: "none"
243
+ });
244
+ let o = this.getText(i);
245
+ this.renderText(o, e, r, t, n);
246
+ }
247
+ getRangeNodeList(e, t) {
248
+ return e.children.slice(t[0], t[1] + 1).filter((e) => e.getData("outerFrame"));
249
+ }
250
+ getNodeRangeFirstNode(e, t) {
251
+ return e.children[t[0]];
252
+ }
253
+ renderOuterFrames() {
254
+ if (this.isNotRenderOuterFrames) {
255
+ this.isNotRenderOuterFrames = !1;
256
+ return;
257
+ }
258
+ this.clearActiveOuterFrame(), this.clearTextNodes(), this.clearOuterFrameElList();
259
+ let t = this.mindMap.renderer.root;
260
+ if (!t) return;
261
+ let n = this.mindMap.draw.transform(), { outerFramePaddingX: r, outerFramePaddingY: i } = this.mindMap.opt;
262
+ c(t, null, (t) => {
263
+ if (!t) return;
264
+ let a = f(t);
265
+ a && a.length > 0 && a.forEach(({ nodeList: a, range: o }) => {
266
+ if (o[0] === -1 || o[1] === -1) return;
267
+ let { left: s, top: c, width: l, height: u } = e(a);
268
+ if (!Number.isFinite(s) || !Number.isFinite(c) || !Number.isFinite(l) || !Number.isFinite(u)) return;
269
+ let d = this.createOuterFrameEl((s - r - this.mindMap.elRect.left - n.translateX) / n.scaleX, (c - i - this.mindMap.elRect.top - n.translateY) / n.scaleY, (l + r * 2) / n.scaleX, (u + i * 2) / n.scaleY, this.getStyle(a[0])), f = this.createText(d, t, o);
270
+ this.textNodeList.push(f), this.renderText(this.getText(a[0]), d, f, t, o), d.on("click", (e) => {
271
+ e.stopPropagation(), this.setActiveOuterFrame(d, t, o, f);
272
+ });
273
+ });
274
+ }, () => {}, !0, 0);
275
+ }
276
+ setActiveOuterFrame(e, t, n, r) {
277
+ this.mindMap.execCommand("CLEAR_ACTIVE_NODE"), this.clearActiveOuterFrame(), this.activeOuterFrame = {
278
+ el: e,
279
+ node: t,
280
+ range: n,
281
+ textNode: r
282
+ }, e.stroke({ dasharray: "none" }), this.getText(this.getNodeRangeFirstNode(t, n)) || this.renderText(this.mindMap.opt.defaultOuterFrameText, e, r, t, n), this.mindMap.emit("outer_frame_active", e, t, n);
283
+ }
284
+ clearActiveOuterFrame() {
285
+ if (!this.activeOuterFrame) return;
286
+ let { el: e, textNode: t, node: n, range: r } = this.activeOuterFrame;
287
+ e.stroke({ dasharray: e.cacheStyle.dasharray || E.strokeDasharray }), this.hideEditTextBox(), this.getText(this.getNodeRangeFirstNode(n, r)) || t.clear(), this.activeOuterFrame = null, this.mindMap.emit("outer_frame_deactivate");
288
+ }
289
+ getStyle(e) {
290
+ return {
291
+ ...E,
292
+ ...e.getData("outerFrame") || {}
293
+ };
294
+ }
295
+ createOuterFrameEl(e, t, n, r, i = {}) {
296
+ let a = this.draw.rect().size(n, r).x(e).y(t);
297
+ return this.styleOuterFrame(a, i), a.cacheStyle = { dasharray: i.strokeDasharray }, this.outerFrameElList.push(a), a;
298
+ }
299
+ styleOuterFrame(e, t) {
300
+ e.radius(t.radius).stroke({
301
+ width: t.strokeWidth,
302
+ color: t.strokeColor,
303
+ dasharray: t.strokeDasharray
304
+ }).fill({ color: t.fill });
305
+ }
306
+ clearTextNodes() {
307
+ this.textNodeList.forEach((e) => {
308
+ e.remove();
309
+ });
310
+ }
311
+ clearOuterFrameElList() {
312
+ this.outerFrameElList.forEach((e) => {
313
+ e.remove();
314
+ }), this.outerFrameElList = [], this.activeOuterFrame = null;
315
+ }
316
+ beforePluginRemove() {
317
+ this.mindMap.deleteEditNodeClass(D), this.unBindEvent();
318
+ }
319
+ beforePluginDestroy() {
320
+ this.mindMap.deleteEditNodeClass(D), this.unBindEvent();
321
+ }
322
+ };
323
+ O.instanceName = "outerFrame", O.defaultStyle = E;
324
+ //#endregion
325
+ export { O as default };
@@ -0,0 +1,42 @@
1
+ import { s as e } from "./utils-DjW7eJ1w.mjs";
2
+ //#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/Painter.js
3
+ var t = class {
4
+ constructor({ mindMap: e }) {
5
+ this.mindMap = e, this.isInPainter = !1, this.painterNode = null, this.bindEvent();
6
+ }
7
+ bindEvent() {
8
+ this.painterOneNode = this.painterOneNode.bind(this), this.onEndPainter = this.onEndPainter.bind(this), this.mindMap.on("node_click", this.painterOneNode), this.mindMap.on("draw_click", this.onEndPainter);
9
+ }
10
+ unBindEvent() {
11
+ this.mindMap.off("node_click", this.painterOneNode), this.mindMap.off("draw_click", this.onEndPainter);
12
+ }
13
+ startPainter() {
14
+ if (this.mindMap.opt.readonly) return;
15
+ let e = this.mindMap.renderer.activeNodeList;
16
+ e.length <= 0 || (this.painterNode = e[0], this.isInPainter = !0, this.mindMap.emit("painter_start"));
17
+ }
18
+ endPainter() {
19
+ this.painterNode = null, this.isInPainter = !1;
20
+ }
21
+ onEndPainter() {
22
+ this.isInPainter && (this.endPainter(), this.mindMap.emit("painter_end"));
23
+ }
24
+ painterOneNode(t) {
25
+ if (!t || !this.isInPainter || !this.painterNode || !t || t.uid === this.painterNode.uid) return;
26
+ let n = {};
27
+ this.mindMap.opt.onlyPainterNodeCustomStyles || (n = { ...this.painterNode.effectiveStyles });
28
+ let r = this.painterNode.getData();
29
+ Object.keys(r).forEach((t) => {
30
+ e(t) && (n[t] = r[t]);
31
+ }), this.mindMap.renderer._handleRemoveCustomStyles(t.getData()), t.setStyles(n);
32
+ }
33
+ beforePluginRemove() {
34
+ this.unBindEvent();
35
+ }
36
+ beforePluginDestroy() {
37
+ this.unBindEvent();
38
+ }
39
+ };
40
+ t.instanceName = "painter";
41
+ //#endregion
42
+ export { t as default };
@@ -0,0 +1,52 @@
1
+ import { O as e, pt as t } from "./utils-DjW7eJ1w.mjs";
2
+ //#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/plugins/RainbowLines.js
3
+ var n = [
4
+ "rgb(255, 213, 73)",
5
+ "rgb(255, 136, 126)",
6
+ "rgb(107, 225, 141)",
7
+ "rgb(151, 171, 255)",
8
+ "rgb(129, 220, 242)",
9
+ "rgb(255, 163, 125)",
10
+ "rgb(152, 132, 234)"
11
+ ], r = class {
12
+ constructor({ mindMap: e }) {
13
+ this.mindMap = e;
14
+ }
15
+ updateRainLinesConfig(e = {}) {
16
+ let t = this.mindMap.opt.rainbowLinesConfig || {};
17
+ t.open = !!e.open, t.colorsList = Array.isArray(e.colorsList) ? e.colorsList : [], this.mindMap.opt.rainbowLinesConfig.open && this.removeNodeLineColor(), this.mindMap.render();
18
+ }
19
+ removeNodeLineColor() {
20
+ let e = this.mindMap.renderer.renderTree;
21
+ e && (t(e, null, (e) => {
22
+ delete e.data.lineColor;
23
+ }, null, !0), this.mindMap.command.addHistory());
24
+ }
25
+ getSecondLayerAncestor(e) {
26
+ if (e.layerIndex === 0) return null;
27
+ if (e.layerIndex === 1) return e;
28
+ {
29
+ let t = e.parent;
30
+ for (; t;) {
31
+ if (t.layerIndex === 1) return t;
32
+ t = t.parent;
33
+ }
34
+ return null;
35
+ }
36
+ }
37
+ getColorsList() {
38
+ let { rainbowLinesConfig: e } = this.mindMap.opt;
39
+ return e && Array.isArray(e.colorsList) && e.colorsList.length > 0 ? e.colorsList : [...n];
40
+ }
41
+ getNodeColor(t) {
42
+ let { rainbowLinesConfig: n } = this.mindMap.opt;
43
+ if (!n || !n.open) return "";
44
+ let r = this.getSecondLayerAncestor(t);
45
+ if (!r) return;
46
+ let i = e(r), a = this.getColorsList();
47
+ return a[i % a.length];
48
+ }
49
+ };
50
+ r.instanceName = "rainbowLines";
51
+ //#endregion
52
+ export { r as default };