leo-mind-map
Version:
一个简单的web在线思维导图
1,567 lines (1,564 loc) • 374 kB
JavaScript
import { ForeignObject as Ne, SVG as A, Path as ve, Polygon as re, Text as K, Circle as St, G as z, Image as At, A as we, Rect as U } from "@svgdotjs/svg.js";
const x = {
CHANGE_THEME: "changeTheme",
CHANGE_LAYOUT: "changeLayout",
MODE: {
READONLY: "readonly",
EDIT: "edit"
},
LAYOUT: {
LOGICAL_STRUCTURE: "logicalStructure",
LOGICAL_STRUCTURE_LEFT: "logicalStructureLeft",
MIND_MAP: "mindMap",
ORGANIZATION_STRUCTURE: "organizationStructure",
CATALOG_ORGANIZATION: "catalogOrganization",
TIMELINE: "timeline",
TIMELINE2: "timeline2",
FISHBONE: "fishbone",
FISHBONE2: "fishbone2",
RIGHT_FISHBONE: "rightFishbone",
RIGHT_FISHBONE2: "rightFishbone2",
VERTICAL_TIMELINE: "verticalTimeline",
VERTICAL_TIMELINE2: "verticalTimeline2",
VERTICAL_TIMELINE3: "verticalTimeline3"
},
DIR: {
UP: "up",
LEFT: "left",
DOWN: "down",
RIGHT: "right"
},
KEY_DIR: {
LEFT: "Left",
UP: "Up",
RIGHT: "Right",
DOWN: "Down"
},
SHAPE: {
RECTANGLE: "rectangle",
DIAMOND: "diamond",
PARALLELOGRAM: "parallelogram",
ROUNDED_RECTANGLE: "roundedRectangle",
OCTAGONAL_RECTANGLE: "octagonalRectangle",
OUTER_TRIANGULAR_RECTANGLE: "outerTriangularRectangle",
INNER_TRIANGULAR_RECTANGLE: "innerTriangularRectangle",
ELLIPSE: "ellipse",
CIRCLE: "circle"
},
MOUSE_WHEEL_ACTION: {
ZOOM: "zoom",
MOVE: "move"
},
INIT_ROOT_NODE_POSITION: {
LEFT: "left",
TOP: "top",
RIGHT: "right",
BOTTOM: "bottom",
CENTER: "center"
},
LAYOUT_GROW_DIR: {
LEFT: "left",
TOP: "top",
RIGHT: "right",
BOTTOM: "bottom"
},
PASTE_TYPE: {
CLIP_BOARD: "clipBoard",
CANVAS: "canvas"
},
SCROLL_BAR_DIR: {
VERTICAL: "vertical",
HORIZONTAL: "horizontal"
},
CREATE_NEW_NODE_BEHAVIOR: {
DEFAULT: "default",
NOT_ACTIVE: "notActive",
ACTIVE_ONLY: "activeOnly"
},
TAG_PLACEMENT: {
RIGHT: "right",
BOTTOM: "bottom"
},
IMG_PLACEMENT: {
LEFT: "left",
TOP: "top",
RIGHT: "right",
BOTTOM: "bottom"
}
}, Ft = {
[x.INIT_ROOT_NODE_POSITION.LEFT]: 0,
[x.INIT_ROOT_NODE_POSITION.TOP]: 0,
[x.INIT_ROOT_NODE_POSITION.RIGHT]: 1,
[x.INIT_ROOT_NODE_POSITION.BOTTOM]: 1,
[x.INIT_ROOT_NODE_POSITION.CENTER]: 0.5
};
x.LAYOUT.LOGICAL_STRUCTURE, x.LAYOUT.LOGICAL_STRUCTURE_LEFT, x.LAYOUT.MIND_MAP, x.LAYOUT.ORGANIZATION_STRUCTURE, x.LAYOUT.CATALOG_ORGANIZATION, x.LAYOUT.TIMELINE, x.LAYOUT.TIMELINE2, x.LAYOUT.VERTICAL_TIMELINE, x.LAYOUT.VERTICAL_TIMELINE2, x.LAYOUT.VERTICAL_TIMELINE3, x.LAYOUT.FISHBONE, x.LAYOUT.FISHBONE2, x.LAYOUT.RIGHT_FISHBONE, x.LAYOUT.RIGHT_FISHBONE2;
const bt = [
x.LAYOUT.LOGICAL_STRUCTURE,
x.LAYOUT.LOGICAL_STRUCTURE_LEFT,
x.LAYOUT.MIND_MAP,
x.LAYOUT.CATALOG_ORGANIZATION,
x.LAYOUT.ORGANIZATION_STRUCTURE,
x.LAYOUT.TIMELINE,
x.LAYOUT.TIMELINE2,
x.LAYOUT.VERTICAL_TIMELINE,
x.LAYOUT.VERTICAL_TIMELINE2,
x.LAYOUT.VERTICAL_TIMELINE3,
x.LAYOUT.FISHBONE,
x.LAYOUT.FISHBONE2,
x.LAYOUT.RIGHT_FISHBONE,
x.LAYOUT.RIGHT_FISHBONE2
], ut = [
"text",
"image",
"imageTitle",
"imageSize",
"icon",
"tag",
"hyperlink",
"hyperlinkTitle",
"note",
"expand",
"isActive",
"generalization",
"richText",
"resetRichText",
// 重新创建富文本内容,去掉原有样式
"uid",
"activeStyle",
"associativeLineTargets",
"associativeLineTargetControlOffsets",
"associativeLinePoint",
"associativeLineText",
"attachmentUrl",
"attachmentName",
"notation",
"outerFrame",
"number",
"range",
"customLeft",
"customTop",
"customTextWidth",
"checkbox",
"dir",
"needUpdate",
// 重新创建节点内容
"imgMap",
"nodeLink"
], et = {
READ_CLIPBOARD_ERROR: "read_clipboard_error",
PARSE_PASTE_DATA_ERROR: "parse_paste_data_error",
CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR: "custom_handle_clipboard_text_error",
LOAD_CLIPBOARD_IMAGE_ERROR: "load_clipboard_image_error",
BEFORE_TEXT_EDIT_ERROR: "before_text_edit_error",
EXPORT_ERROR: "export_error",
EXPORT_LOAD_IMAGE_ERROR: "export_load_image_error",
DATA_CHANGE_DETAIL_EVENT_ERROR: "data_change_detail_event_error"
}, Te = `
/* 鼠标hover和激活时渲染的矩形 */
.smm-hover-node{
display: none;
opacity: 0.6;
stroke-width: 1;
}
.smm-node:not(.smm-node-dragging):hover .smm-hover-node{
display: block;
}
.smm-node.active .smm-hover-node, .smm-node-highlight .smm-hover-node{
display: block;
opacity: 1;
stroke-width: 2;
}
.smm-text-node-wrap, .smm-expand-btn-text {
user-select: none;
}
`, gt = 1.2, Ce = [
"fontFamily",
"fontSize",
"fontWeight",
"fontStyle",
"textDecoration",
"color",
"textAlign"
];
class ye {
// 构造函数
constructor(t = {}) {
this.opt = t, this.mindMap = this.opt.mindMap, this.scale = 1, this.sx = 0, this.sy = 0, this.x = 0, this.y = 0, this.firstDrag = !0, this.setTransformData(this.mindMap.opt.viewData), this.bind();
}
// 绑定
bind() {
this.mindMap.keyCommand.addShortcut("Control+=", () => {
this.enlarge();
}), this.mindMap.keyCommand.addShortcut("Control+-", () => {
this.narrow();
}), this.mindMap.keyCommand.addShortcut("Control+i", () => {
this.fit();
}), this.mindMap.event.on("mousedown", (t) => {
const { isDisableDrag: e, mousedownEventPreventDefault: i } = this.mindMap.opt;
e || (i && t.preventDefault(), this.sx = this.x, this.sy = this.y);
}), this.mindMap.event.on("drag", (t, e) => {
t.ctrlKey || t.metaKey || this.mindMap.opt.isDisableDrag || (this.firstDrag && (this.firstDrag = !1, this.mindMap.renderer.activeNodeList.length > 0 && this.mindMap.execCommand("CLEAR_ACTIVE_NODE")), this.x = this.sx + e.mousemoveOffset.x, this.y = this.sy + e.mousemoveOffset.y, this.transform());
}), this.mindMap.event.on("mouseup", () => {
this.firstDrag = !0;
}), this.mindMap.event.on("mousewheel", (t, e, i, n) => {
const {
customHandleMousewheel: s,
mousewheelAction: a,
mouseScaleCenterUseMousePosition: h,
mousewheelMoveStep: r,
mousewheelZoomActionReverse: l,
disableMouseWheelZoom: d,
translateRatio: c
} = this.mindMap.opt;
if (s && typeof s == "function")
return s(t);
if (a === x.MOUSE_WHEEL_ACTION.ZOOM || t.ctrlKey || t.metaKey) {
if (d)
return;
const { x: p, y: g } = this.mindMap.toPos(
t.clientX,
t.clientY
), f = h ? p : void 0, m = h ? g : void 0;
switch (n && (e.includes(x.DIR.LEFT) || e.includes(x.DIR.RIGHT)) && (e = e.filter((u) => ![x.DIR.LEFT, x.DIR.RIGHT].includes(u))), !0) {
case e.includes(x.DIR.UP || x.DIR.LEFT):
l ? this.enlarge(f, m, n) : this.narrow(f, m, n);
break;
case e.includes(x.DIR.DOWN || x.DIR.RIGHT):
l ? this.narrow(f, m, n) : this.enlarge(f, m, n);
break;
}
} else {
let p = 0, g = 0;
n ? (p = Math.abs(t.wheelDeltaX), g = Math.abs(t.wheelDeltaY)) : p = g = r;
let f = 0, m = 0;
e.includes(x.DIR.DOWN) && (m = -g), e.includes(x.DIR.UP) && (m = g), e.includes(x.DIR.LEFT) && (f = p), e.includes(x.DIR.RIGHT) && (f = -p), this.translateXY(f * c, m * c);
}
}), this.mindMap.on("resize", () => {
this.checkNeedMindMapInCanvas() && this.transform();
});
}
// 获取当前变换状态数据
getTransformData() {
return {
transform: this.mindMap.draw.transform(),
state: {
scale: this.scale,
x: this.x,
y: this.y,
sx: this.sx,
sy: this.sy
}
};
}
// 动态设置变换状态数据
setTransformData(t) {
t && (Object.keys(t.state).forEach((e) => {
this[e] = t.state[e];
}), this.mindMap.draw.transform({
...t.transform
}), this.mindMap.emit("view_data_change", this.getTransformData()), this.emitEvent("scale"), this.emitEvent("translate"));
}
// 平移x,y方向
translateXY(t, e) {
t === 0 && e === 0 || (this.x += t, this.y += e, this.transform(), this.emitEvent("translate"));
}
// 平移x方向
translateX(t) {
t !== 0 && (this.x += t, this.transform(), this.emitEvent("translate"));
}
// 平移x方式到
translateXTo(t) {
this.x = t, this.transform(), this.emitEvent("translate");
}
// 平移y方向
translateY(t) {
t !== 0 && (this.y += t, this.transform(), this.emitEvent("translate"));
}
// 平移y方向到
translateYTo(t) {
this.y = t, this.transform(), this.emitEvent("translate");
}
// 应用变换
transform() {
try {
this.limitMindMapInCanvas();
} catch {
}
this.mindMap.draw.transform({
origin: [0, 0],
scale: this.scale,
translate: [this.x, this.y]
}), this.mindMap.emit("view_data_change", this.getTransformData());
}
// 恢复
reset() {
const t = this.scale !== 1, e = this.x !== 0 || this.y !== 0;
this.scale = 1, this.x = 0, this.y = 0, this.transform(), t && this.emitEvent("scale"), e && this.emitEvent("translate");
}
// 缩小
narrow(t, e, i) {
let { scaleRatio: n, minZoomRatio: s } = this.mindMap.opt;
n = n / (i ? 5 : 1);
const a = Math.max(this.scale - n, s / 100);
this.scaleInCenter(a, t, e), this.transform(), this.emitEvent("scale");
}
// 放大
enlarge(t, e, i) {
let { scaleRatio: n, maxZoomRatio: s } = this.mindMap.opt;
n = n / (i ? 5 : 1);
let a = 0;
s === -1 ? a = this.scale + n : a = Math.min(this.scale + n, s / 100), this.scaleInCenter(a, t, e), this.transform(), this.emitEvent("scale");
}
// 基于指定中心进行缩放,cx,cy 可不指定,此时会使用画布中心点
scaleInCenter(t, e, i) {
(e === void 0 || i === void 0) && (e = this.mindMap.width / 2, i = this.mindMap.height / 2);
const n = this.scale, s = 1 - t / n, a = (e - this.x) * s, h = (i - this.y) * s;
this.x += a, this.y += h, this.scale = t;
}
// 设置缩放
setScale(t, e, i) {
e !== void 0 && i !== void 0 ? this.scaleInCenter(t, e, i) : this.scale = t, this.transform(), this.emitEvent("scale");
}
// 适应画布大小
fit(t = () => {
}, e = !1, i) {
i = i === void 0 ? this.mindMap.opt.fitPadding : i;
const n = this.mindMap.draw, s = n.transform(), a = t() || n.rbox(), h = a.width / s.scaleX, r = a.height / s.scaleY, l = h / r;
let { width: d, height: c } = this.mindMap.elRect;
d = d - i * 2, c = c - i * 2;
const p = d / c;
let g = 0, f = "";
if (h <= d && r <= c && !e)
g = 1, f = 1;
else {
let v = 0;
l > p ? (v = d, f = 2) : (v = c * l, f = 3), g = v / h;
}
this.setScale(g);
const m = t() || n.rbox();
m.x -= this.mindMap.elRect.left, m.y -= this.mindMap.elRect.top;
let u = 0, E = 0;
f === 1 ? (u = -m.x + i + (d - m.width) / 2, E = -m.y + i + (c - m.height) / 2) : f === 2 ? (u = -m.x + i, E = -m.y + i + (c - m.height) / 2) : f === 3 && (u = -m.x + i + (d - m.width) / 2, E = -m.y + i), this.translateXY(u, E);
}
// 判断是否需要将思维导图限制在画布内
checkNeedMindMapInCanvas() {
if (this.mindMap.demonstrate && this.mindMap.demonstrate.isInDemonstrate)
return !1;
const { isLimitMindMapInCanvasWhenHasScrollbar: t, isLimitMindMapInCanvas: e } = this.mindMap.opt;
return this.mindMap.scrollbar ? t : e;
}
// 将思维导图限制在画布内
limitMindMapInCanvas() {
if (!this.checkNeedMindMapInCanvas())
return;
let { scale: t, left: e, top: i, right: n, bottom: s } = this.getPositionLimit();
const a = (this.mindMap.width - this.mindMap.initWidth) / 2 * t, h = (this.mindMap.height - this.mindMap.initHeight) / 2 * t, r = this.scale / t;
e *= r, n *= r, i *= r, s *= r;
const l = this.mindMap.width / 2, d = this.mindMap.height / 2, c = this.scale - 1;
e -= c * l - a, n -= c * l - a, i -= c * d - h, s -= c * d - h, this.x > e && (this.x = e), this.x < n && (this.x = n), this.y > i && (this.y = i), this.y < s && (this.y = s);
}
// 计算图形四个方向的位置边界值
getPositionLimit() {
const { scaleX: t, scaleY: e } = this.mindMap.draw.transform(), i = this.mindMap.draw.rbox(), n = this.mindMap.renderer.root.group.rbox(), s = this.mindMap.renderer.layout.getRootCenterOffset(
n.width,
n.height
), a = n.x - i.x - s.x * t, h = n.x - i.x2 - s.x * t, r = n.y - i.y - s.y * e, l = n.y - i.y2 - s.y * e;
return {
scale: t,
left: a,
right: h,
top: r,
bottom: l
};
}
// 派发事件
emitEvent(t) {
switch (t) {
case "scale":
this.mindMap.emit("scale", this.scale);
case "translate":
this.mindMap.emit("translate", this.x, this.y);
}
}
}
function Le(o) {
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
}
var le = { exports: {} };
(function(o) {
var t = Object.prototype.hasOwnProperty, e = "~";
function i() {
}
Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (e = !1));
function n(r, l, d) {
this.fn = r, this.context = l, this.once = d || !1;
}
function s(r, l, d, c, p) {
if (typeof d != "function")
throw new TypeError("The listener must be a function");
var g = new n(d, c || r, p), f = e ? e + l : l;
return r._events[f] ? r._events[f].fn ? r._events[f] = [r._events[f], g] : r._events[f].push(g) : (r._events[f] = g, r._eventsCount++), r;
}
function a(r, l) {
--r._eventsCount === 0 ? r._events = new i() : delete r._events[l];
}
function h() {
this._events = new i(), this._eventsCount = 0;
}
h.prototype.eventNames = function() {
var l = [], d, c;
if (this._eventsCount === 0)
return l;
for (c in d = this._events)
t.call(d, c) && l.push(e ? c.slice(1) : c);
return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(d)) : l;
}, h.prototype.listeners = function(l) {
var d = e ? e + l : l, c = this._events[d];
if (!c)
return [];
if (c.fn)
return [c.fn];
for (var p = 0, g = c.length, f = new Array(g); p < g; p++)
f[p] = c[p].fn;
return f;
}, h.prototype.listenerCount = function(l) {
var d = e ? e + l : l, c = this._events[d];
return c ? c.fn ? 1 : c.length : 0;
}, h.prototype.emit = function(l, d, c, p, g, f) {
var m = e ? e + l : l;
if (!this._events[m])
return !1;
var u = this._events[m], E = arguments.length, v, M;
if (u.fn) {
switch (u.once && this.removeListener(l, u.fn, void 0, !0), E) {
case 1:
return u.fn.call(u.context), !0;
case 2:
return u.fn.call(u.context, d), !0;
case 3:
return u.fn.call(u.context, d, c), !0;
case 4:
return u.fn.call(u.context, d, c, p), !0;
case 5:
return u.fn.call(u.context, d, c, p, g), !0;
case 6:
return u.fn.call(u.context, d, c, p, g, f), !0;
}
for (M = 1, v = new Array(E - 1); M < E; M++)
v[M - 1] = arguments[M];
u.fn.apply(u.context, v);
} else {
var N = u.length, w;
for (M = 0; M < N; M++)
switch (u[M].once && this.removeListener(l, u[M].fn, void 0, !0), E) {
case 1:
u[M].fn.call(u[M].context);
break;
case 2:
u[M].fn.call(u[M].context, d);
break;
case 3:
u[M].fn.call(u[M].context, d, c);
break;
case 4:
u[M].fn.call(u[M].context, d, c, p);
break;
default:
if (!v)
for (w = 1, v = new Array(E - 1); w < E; w++)
v[w - 1] = arguments[w];
u[M].fn.apply(u[M].context, v);
}
}
return !0;
}, h.prototype.on = function(l, d, c) {
return s(this, l, d, c, !1);
}, h.prototype.once = function(l, d, c) {
return s(this, l, d, c, !0);
}, h.prototype.removeListener = function(l, d, c, p) {
var g = e ? e + l : l;
if (!this._events[g])
return this;
if (!d)
return a(this, g), this;
var f = this._events[g];
if (f.fn)
f.fn === d && (!p || f.once) && (!c || f.context === c) && a(this, g);
else {
for (var m = 0, u = [], E = f.length; m < E; m++)
(f[m].fn !== d || p && !f[m].once || c && f[m].context !== c) && u.push(f[m]);
u.length ? this._events[g] = u.length === 1 ? u[0] : u : a(this, g);
}
return this;
}, h.prototype.removeAllListeners = function(l) {
var d;
return l ? (d = e ? e + l : l, this._events[d] && a(this, d)) : (this._events = new i(), this._eventsCount = 0), this;
}, h.prototype.off = h.prototype.removeListener, h.prototype.addListener = h.prototype.on, h.prefixed = e, h.EventEmitter = h, o.exports = h;
})(le);
var _e = le.exports;
const De = /* @__PURE__ */ Le(_e);
class Re extends De {
// 构造函数
constructor(t = {}) {
super(), this.opt = t, this.mindMap = t.mindMap, this.isLeftMousedown = !1, this.isRightMousedown = !1, this.isMiddleMousedown = !1, this.mousedownPos = {
x: 0,
y: 0
}, this.mousemovePos = {
x: 0,
y: 0
}, this.mousemoveOffset = {
x: 0,
y: 0
}, this.bindFn(), this.bind();
}
// 绑定函数上下文
bindFn() {
this.onBodyMousedown = this.onBodyMousedown.bind(this), this.onBodyClick = this.onBodyClick.bind(this), this.onDrawClick = this.onDrawClick.bind(this), this.onMousedown = this.onMousedown.bind(this), this.onMousemove = this.onMousemove.bind(this), this.onMouseup = this.onMouseup.bind(this), this.onNodeMouseup = this.onNodeMouseup.bind(this), this.onMousewheel = this.onMousewheel.bind(this), this.onContextmenu = this.onContextmenu.bind(this), this.onSvgMousedown = this.onSvgMousedown.bind(this), this.onKeyup = this.onKeyup.bind(this), this.onMouseenter = this.onMouseenter.bind(this), this.onMouseleave = this.onMouseleave.bind(this);
}
// 绑定事件
bind() {
document.body.addEventListener("mousedown", this.onBodyMousedown), document.body.addEventListener("click", this.onBodyClick), this.mindMap.svg.on("click", this.onDrawClick), this.mindMap.el.addEventListener("mousedown", this.onMousedown), this.mindMap.svg.on("mousedown", this.onSvgMousedown), window.addEventListener("mousemove", this.onMousemove), window.addEventListener("mouseup", this.onMouseup), this.on("node_mouseup", this.onNodeMouseup), this.mindMap.el.addEventListener("wheel", this.onMousewheel), this.mindMap.svg.on("contextmenu", this.onContextmenu), this.mindMap.svg.on("mouseenter", this.onMouseenter), this.mindMap.svg.on("mouseleave", this.onMouseleave), window.addEventListener("keyup", this.onKeyup);
}
// 解绑事件
unbind() {
document.body.removeEventListener("mousedown", this.onBodyMousedown), document.body.removeEventListener("click", this.onBodyClick), this.mindMap.svg.off("click", this.onDrawClick), this.mindMap.el.removeEventListener("mousedown", this.onMousedown), window.removeEventListener("mousemove", this.onMousemove), window.removeEventListener("mouseup", this.onMouseup), this.off("node_mouseup", this.onNodeMouseup), this.mindMap.el.removeEventListener("wheel", this.onMousewheel), this.mindMap.svg.off("contextmenu", this.onContextmenu), this.mindMap.svg.off("mouseenter", this.onMouseenter), this.mindMap.svg.off("mouseleave", this.onMouseleave), window.removeEventListener("keyup", this.onKeyup);
}
// 画布的单击事件
onDrawClick(t) {
this.emit("draw_click", t);
}
// 页面的鼠标按下事件
onBodyMousedown(t) {
this.emit("body_mousedown", t);
}
// 页面的单击事件
onBodyClick(t) {
this.emit("body_click", t);
}
// svg画布的鼠标按下事件
onSvgMousedown(t) {
this.emit("svg_mousedown", t);
}
// 鼠标按下事件
onMousedown(t) {
t.which === 1 ? this.isLeftMousedown = !0 : t.which === 3 ? this.isRightMousedown = !0 : t.which === 2 && (this.isMiddleMousedown = !0), this.mousedownPos.x = t.clientX, this.mousedownPos.y = t.clientY, this.emit("mousedown", t, this);
}
// 鼠标移动事件
onMousemove(t) {
let { useLeftKeySelectionRightKeyDrag: e } = this.mindMap.opt;
this.mousemovePos.x = t.clientX, this.mousemovePos.y = t.clientY, this.mousemoveOffset.x = t.clientX - this.mousedownPos.x, this.mousemoveOffset.y = t.clientY - this.mousedownPos.y, this.emit("mousemove", t, this), (this.isMiddleMousedown || (e ? this.isRightMousedown : this.isLeftMousedown)) && (t.preventDefault(), this.emit("drag", t, this));
}
// 鼠标松开事件
onMouseup(t) {
this.onNodeMouseup(), this.emit("mouseup", t, this);
}
// 节点鼠标松开事件
onNodeMouseup() {
this.isLeftMousedown = !1, this.isRightMousedown = !1, this.isMiddleMousedown = !1;
}
// 鼠标滚动/触控板滑动
onMousewheel(t) {
t.stopPropagation(), t.preventDefault();
const e = [];
t.deltaY < 0 && e.push(x.DIR.UP), t.deltaY > 0 && e.push(x.DIR.DOWN), t.deltaX < 0 && e.push(x.DIR.LEFT), t.deltaX > 0 && e.push(x.DIR.RIGHT);
let i = !1;
const { customCheckIsTouchPad: n } = this.mindMap.opt;
typeof n == "function" ? i = n(t) : i = Math.abs(t.deltaY) <= 10, this.emit("mousewheel", t, e, this, i);
}
// 鼠标右键菜单事件
onContextmenu(t) {
t.preventDefault(), !t.ctrlKey && this.emit("contextmenu", t);
}
// 按键松开事件
onKeyup(t) {
this.emit("keyup", t);
}
// 进入
onMouseenter(t) {
this.emit("svg_mouseenter", t);
}
// 离开
onMouseleave(t) {
this.emit("svg_mouseleave", t);
}
}
var mt = function(t) {
return Se(t) && !Ae(t);
};
function Se(o) {
return !!o && typeof o == "object";
}
function Ae(o) {
var t = Object.prototype.toString.call(o);
return t === "[object RegExp]" || t === "[object Date]" || ze(o);
}
var Ie = typeof Symbol == "function" && Symbol.for, Oe = Ie ? Symbol.for("react.element") : 60103;
function ze(o) {
return o.$$typeof === Oe;
}
function Fe(o) {
return Array.isArray(o) ? [] : {};
}
function ht(o, t) {
var e = t && t.clone === !0;
return e && mt(o) ? it(Fe(o), o, t) : o;
}
function Bt(o, t, e) {
var i = o.slice();
return t.forEach(function(n, s) {
typeof i[s] > "u" ? i[s] = ht(n, e) : mt(n) ? i[s] = it(o[s], n, e) : o.indexOf(n) === -1 && i.push(ht(n, e));
}), i;
}
function be(o, t, e) {
var i = {};
return mt(o) && Object.keys(o).forEach(function(n) {
i[n] = ht(o[n], e);
}), Object.keys(t).forEach(function(n) {
!mt(t[n]) || !o[n] ? i[n] = ht(t[n], e) : i[n] = it(o[n], t[n], e);
}), i;
}
function it(o, t, e) {
var i = Array.isArray(t), n = Array.isArray(o), s = e || { arrayMerge: Bt }, a = i === n;
if (a)
if (i) {
var h = s.arrayMerge || Bt;
return h(o, t, e);
} else
return be(o, t, e);
else
return ht(t, e);
}
it.all = function(t, e) {
if (!Array.isArray(t) || t.length < 2)
throw new Error("first argument should be an array with at least two elements");
return t.reduce(function(i, n) {
return it(i, n, e);
});
};
var xt = it;
let dt;
const Be = new Uint8Array(16);
function Pe() {
if (!dt && (dt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !dt))
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
return dt(Be);
}
const I = [];
for (let o = 0; o < 256; ++o)
I.push((o + 256).toString(16).slice(1));
function ke(o, t = 0) {
return I[o[t + 0]] + I[o[t + 1]] + I[o[t + 2]] + I[o[t + 3]] + "-" + I[o[t + 4]] + I[o[t + 5]] + "-" + I[o[t + 6]] + I[o[t + 7]] + "-" + I[o[t + 8]] + I[o[t + 9]] + "-" + I[o[t + 10]] + I[o[t + 11]] + I[o[t + 12]] + I[o[t + 13]] + I[o[t + 14]] + I[o[t + 15]];
}
const He = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Pt = {
randomUUID: He
};
function Ue(o, t, e) {
if (Pt.randomUUID && !t && !o)
return Pt.randomUUID();
o = o || {};
const i = o.random || (o.rng || Pe)();
if (i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, t) {
e = e || 0;
for (let n = 0; n < 16; ++n)
t[e + n] = i[n];
return t;
}
return ke(i);
}
function It(o) {
this.N = 624, this.M = 397, this.MATRIX_A = 2567483615, this.UPPER_MASK = 2147483648, this.LOWER_MASK = 2147483647, this.mt = new Array(this.N), this.mti = this.N + 1, this.init_genrand(o);
}
It.prototype.init_genrand = function(o) {
for (this.mt[0] = o >>> 0, this.mti = 1; this.mti < this.N; this.mti++)
o = this.mt[this.mti - 1] ^ this.mt[this.mti - 1] >>> 30, this.mt[this.mti] = (((o & 4294901760) >>> 16) * 1812433253 << 16) + (o & 65535) * 1812433253 + this.mti, this.mt[this.mti] >>>= 0;
};
It.prototype.genrand_int32 = function() {
var o, t = new Array(0, this.MATRIX_A);
if (this.mti >= this.N) {
var e;
for (this.mti == this.N + 1 && this.init_genrand(5489), e = 0; e < this.N - this.M; e++)
o = this.mt[e] & this.UPPER_MASK | this.mt[e + 1] & this.LOWER_MASK, this.mt[e] = this.mt[e + this.M] ^ o >>> 1 ^ t[o & 1];
for (; e < this.N - 1; e++)
o = this.mt[e] & this.UPPER_MASK | this.mt[e + 1] & this.LOWER_MASK, this.mt[e] = this.mt[e + (this.M - this.N)] ^ o >>> 1 ^ t[o & 1];
o = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK, this.mt[this.N - 1] = this.mt[this.M - 1] ^ o >>> 1 ^ t[o & 1], this.mti = 0;
}
return o = this.mt[this.mti++], o ^= o >>> 11, o ^= o << 7 & 2636928640, o ^= o << 15 & 4022730752, o ^= o >>> 18, o >>> 0;
};
const de = {
// 节点内边距
paddingX: 15,
paddingY: 5,
// 图片显示的最大宽度
imgMaxWidth: 200,
// 图片显示的最大高度
imgMaxHeight: 100,
// icon的大小
iconSize: 20,
// 连线的粗细
lineWidth: 1,
// 连线的颜色
lineColor: "#549688",
// 连线样式
lineDasharray: "none",
// 连线是否开启流动效果,仅在虚线时有效(需要注册LineFlow插件)
lineFlow: !1,
// 流动效果一个周期的时间,单位:s
lineFlowDuration: 1,
// 流动方向是否是从父节点到子节点
lineFlowForward: !0,
// 连线风格
lineStyle: "straight",
// 曲线(curve)【仅支持logicalStructure、mindMap、verticalTimeline三种结构】、直线(straight)、直连(direct)【仅支持logicalStructure、mindMap、organizationStructure、verticalTimeline四种结构】
// 曲线连接时,根节点和其他节点的连接线样式保持统一,默认根节点为 ( 型,其他节点为 { 型,设为true后,都为 { 型。仅支持logicalStructure、mindMap两种结构
rootLineKeepSameInCurve: !0,
// 曲线连接时,根节点和其他节点的连线起始位置保持统一,默认根节点的连线起始位置在节点中心,其他节点在节点右侧(或左侧),如果该配置设为true,那么根节点的连线起始位置也会在节点右侧(或左侧)
rootLineStartPositionKeepSameInCurve: !1,
// 直线连接(straight)时,连线的圆角大小,设置为0代表没有圆角,仅支持logicalStructure、mindMap、verticalTimeline三种结构
lineRadius: 5,
// 连线是否显示标记,目前只支持箭头
showLineMarker: !1,
// 概要连线的粗细
generalizationLineWidth: 1,
// 概要连线的颜色
generalizationLineColor: "#549688",
// 概要曲线距节点的距离
generalizationLineMargin: 0,
// 概要节点距节点的距离
generalizationNodeMargin: 20,
// 关联线默认状态的粗细
associativeLineWidth: 2,
// 关联线默认状态的颜色
associativeLineColor: "rgb(51, 51, 51)",
// 关联线激活状态的粗细
associativeLineActiveWidth: 8,
// 关联线激活状态的颜色
associativeLineActiveColor: "rgba(2, 167, 240, 1)",
// 关联线样式
associativeLineDasharray: "6,4",
// 关联线文字颜色
associativeLineTextColor: "rgb(51, 51, 51)",
// 关联线文字大小
associativeLineTextFontSize: 14,
// 关联线文字行高
associativeLineTextLineHeight: 1.2,
// 关联线文字字体
associativeLineTextFontFamily: "微软雅黑, Microsoft YaHei",
// 背景颜色
backgroundColor: "#fafafa",
// 背景图片
backgroundImage: "none",
// 背景重复
backgroundRepeat: "no-repeat",
// 设置背景图像的起始位置
backgroundPosition: "center center",
// 设置背景图片大小
backgroundSize: "cover",
// 节点使用只有底边横线的样式,仅支持logicalStructure、mindMap、catalogOrganization、organizationStructure四种结构
nodeUseLineStyle: !1,
// 根节点样式
root: {
shape: "rectangle",
fillColor: "#549688",
fontFamily: "微软雅黑, Microsoft YaHei",
color: "#fff",
fontSize: 16,
fontWeight: "bold",
fontStyle: "normal",
borderColor: "transparent",
borderWidth: 0,
borderDasharray: "none",
borderRadius: 5,
textDecoration: "none",
gradientStyle: !1,
startColor: "#549688",
endColor: "#fff",
startDir: [0, 0],
endDir: [1, 0],
// 连线标记的位置,start(头部)、end(尾部),该配置在showLineMarker配置为true时生效
lineMarkerDir: "end",
// 节点鼠标hover和激活时显示的矩形边框的颜色,主题里不设置,默认会取hoverRectColor实例化选项的值
hoverRectColor: "",
// 点鼠标hover和激活时显示的矩形边框的圆角大小
hoverRectRadius: 5,
// 文本对齐
textAlign: "left",
// right、center、justify、left
// 图片放置位置,相对于整个文本内容
imgPlacement: "top",
// left、right、bottom、top
// 标签放置位置
tagPlacement: "right"
// right(文字右侧)、bottom(文本内容下方)
// 下列样式也支持给节点设置,用于覆盖最外层的设置
// paddingX,
// paddingY,
// lineWidth,
// lineColor,
// lineDasharray,
// lineFlow,
// lineFlowDuration,
// lineFlowForward
// 关联线的所有样式
},
// 二级节点样式
second: {
shape: "rectangle",
marginX: 100,
marginY: 40,
fillColor: "#fff",
fontFamily: "微软雅黑, Microsoft YaHei",
color: "#565656",
fontSize: 16,
fontWeight: "normal",
fontStyle: "normal",
borderColor: "#549688",
borderWidth: 1,
borderDasharray: "none",
borderRadius: 5,
textDecoration: "none",
gradientStyle: !1,
startColor: "#549688",
endColor: "#fff",
startDir: [0, 0],
endDir: [1, 0],
lineMarkerDir: "end",
hoverRectColor: "",
hoverRectRadius: 5,
textAlign: "left",
imgPlacement: "top",
tagPlacement: "right"
},
// 三级及以下节点样式
node: {
shape: "rectangle",
marginX: 50,
marginY: 0,
fillColor: "transparent",
fontFamily: "微软雅黑, Microsoft YaHei",
color: "#6a6d6c",
fontSize: 14,
fontWeight: "normal",
fontStyle: "normal",
borderColor: "transparent",
borderWidth: 0,
borderRadius: 5,
borderDasharray: "none",
textDecoration: "none",
gradientStyle: !1,
startColor: "#549688",
endColor: "#fff",
startDir: [0, 0],
endDir: [1, 0],
lineMarkerDir: "end",
hoverRectColor: "",
hoverRectRadius: 5,
textAlign: "left",
imgPlacement: "top",
tagPlacement: "right"
},
// 概要节点样式
generalization: {
shape: "rectangle",
marginX: 100,
marginY: 40,
fillColor: "#fff",
fontFamily: "微软雅黑, Microsoft YaHei",
color: "#565656",
fontSize: 16,
fontWeight: "normal",
fontStyle: "normal",
borderColor: "#549688",
borderWidth: 1,
borderDasharray: "none",
borderRadius: 5,
textDecoration: "none",
gradientStyle: !1,
startColor: "#549688",
endColor: "#fff",
startDir: [0, 0],
endDir: [1, 0],
hoverRectColor: "",
hoverRectRadius: 5,
textAlign: "left",
imgPlacement: "top",
tagPlacement: "right"
}
}, $e = [
"lineWidth",
"lineColor",
"lineDasharray",
"lineStyle",
"generalizationLineWidth",
"generalizationLineColor",
"associativeLineWidth",
"associativeLineColor",
"associativeLineActiveWidth",
"associativeLineActiveColor",
"associativeLineTextColor",
"associativeLineTextFontSize",
"associativeLineTextLineHeight",
"associativeLineTextFontFamily",
"backgroundColor",
"backgroundImage",
"backgroundRepeat",
"backgroundPosition",
"backgroundSize",
"rootLineKeepSameInCurve",
"rootLineStartPositionKeepSameInCurve",
"showLineMarker",
"lineRadius",
"hoverRectColor",
"hoverRectRadius",
"lineFlow",
"lineFlowDuration",
"lineFlowForward",
"textAlign"
], Ge = (o) => {
let t = Object.keys(o);
for (let e = 0; e < t.length; e++)
if (!$e.find((i) => i === t[e]))
return !1;
return !0;
}, Ct = [
"lineColor",
"lineDasharray",
"lineWidth",
"lineMarkerDir",
"lineFlow",
"lineFlowDuration",
"lineFlowForward"
], C = (o, t, e, i, n, s = 0, a = 0, h = []) => {
let r = !1;
if (e && (r = e(o, t, n, s, a, h)), !r && o.children && o.children.length > 0) {
let l = s + 1;
o.children.forEach((d, c) => {
C(
d,
o,
e,
i,
!1,
l,
c,
[...h, o]
);
});
}
i && i(o, t, n, s, a, h);
}, We = (o, t) => {
let e = [o], i = !1;
for (t(o, null) === "stop" && (i = !0); e.length && !i; ) {
let n = e.shift();
n.children && n.children.length && n.children.forEach((s) => {
i || (e.push(s), t(s, n) === "stop" && (i = !0));
});
}
}, Ye = (o, t, e, i) => {
let n = o / t, s = [];
if (e && i)
if (o <= e && t <= i)
s = [o, t];
else {
let a = e / i;
n > a ? s = [e, e / n] : s = [n * i, i];
}
else
e ? o <= e ? s = [o, t] : s = [e, e / n] : i && (t <= i ? s = [o, t] : s = [n * i, i]);
return s;
}, Ve = (o) => {
o = o.replace(/<br>/gim, `
`);
let t = document.createElement("div");
return t.innerHTML = o, o = t.textContent, o;
}, P = (o) => {
try {
return JSON.parse(JSON.stringify(o));
} catch {
return null;
}
}, ce = (o, t, e = !1) => (o.data = P(t.data), e && (o.data.isActive = !1, Et(o.data).forEach((n) => {
n.isActive = !1;
})), o.children = [], t.children && t.children.length > 0 && t.children.forEach((i, n) => {
o.children[n] = ce({}, i, e);
}), Object.keys(t).forEach((i) => {
!["data", "children"].includes(i) && !/^_/.test(i) && (o[i] = t[i]);
}), o), rt = (o, t, e = !1, i = !0) => {
const n = t.nodeData ? t.nodeData : t;
return o.data = P(n.data), i ? delete o.data.uid : o.data.uid || (o.data.uid = H()), e && (o.data.isActive = !1), o.children = [], t.children && t.children.length > 0 ? t.children.forEach((s, a) => {
o.children[a] = rt({}, s, e, i);
}) : t.nodeData && t.nodeData.children && t.nodeData.children.length > 0 && t.nodeData.children.forEach((s, a) => {
o.children[a] = rt({}, s, e, i);
}), Object.keys(n).forEach((s) => {
!["data", "children"].includes(s) && !/^_/.test(s) && (o[s] = n[s]);
}), o;
}, fe = (o, t = 300, e) => {
let i = null;
return (...n) => {
i || (i = setTimeout(() => {
o.call(e, ...n), i = null;
}, t));
};
}, Xe = (o, t = 300, e) => {
let i = null;
return (...n) => {
i && clearTimeout(i), i = setTimeout(() => {
i = null, o.apply(e, n);
}, t);
};
}, Z = (o, t = () => {
}) => {
let e = 0, i = o.length;
if (i <= 0)
return t();
let n = () => {
if (e >= i) {
t();
return;
}
o[e](), setTimeout(() => {
e++, n();
}, 0);
};
n();
}, Q = (o) => o * (Math.PI / 180), je = (o) => o.replace(/([a-z])([A-Z])/g, (...t) => t[1] + "-" + t[2].toLowerCase()), Ke = function(o, t) {
let e = !1, i = null, n = () => {
e = !1, t ? o.call(t) : o();
};
if (typeof MutationObserver < "u") {
let s = 1, a = new MutationObserver(n), h = document.createTextNode(s);
a.observe(h, {
characterData: !0
// 设为 true 表示监视指定目标节点或子节点树中节点所包含的字符数据的变化
}), i = function() {
s = (s + 1) % 2, h.data = s;
};
} else
i = setTimeout;
return function() {
e || (e = !0, i(n, 0));
};
}, Ze = (o, t, e = 0, i = 0) => {
let n = o.elRect, { scaleX: s, scaleY: a, translateX: h, translateY: r } = o.draw.transform(), { left: l, top: d, width: c, height: p } = t, g = (l + c) * s + h, f = (d + p) * a + r;
l = l * s + h, d = d * a + r;
let m = 0, u = 0;
return l < 0 + e && (m = -l + e), g > n.width - e && (m = -(g - n.width) - e), d < 0 + i && (u = -d + i), f > n.height - i && (u = -(f - n.height) - i), {
isOuter: m !== 0 || u !== 0,
offsetLeft: m,
offsetTop: u
};
};
let ct = null;
const pe = (o) => (ct || (ct = document.createElement("div")), ct.innerHTML = o, ct.textContent), qe = (o) => new Promise((t) => {
let e = new Image();
e.src = o, e.onload = () => {
t({
width: e.width,
height: e.height
});
}, e.onerror = () => {
t({
width: 0,
height: 0
});
};
}), H = () => Ue(), Qe = (o) => new Promise((t, e) => {
let i = new FileReader();
i.readAsDataURL(o), i.onload = async (n) => {
let s = n.target.result, a = await qe(s);
t({
url: s,
size: a
});
}, i.onerror = (n) => {
e(n);
};
}), X = (o) => Object.prototype.toString.call(o).slice(8, -1), W = (o) => o == null || o === "";
let ft = null;
const Je = (o) => {
ft || (ft = document.createElement("div")), ft.innerHTML = o;
for (let t = ft.childNodes, e = t.length; e--; )
if (t[e].nodeType == 1)
return !0;
return !1;
}, ue = (o) => (o = String(o).replace(/\s+/g, ""), ["#fff", "#ffffff", "#FFF", "#FFFFFF", "rgb(255,255,255)"].includes(
o
) || /rgba\(255,255,255,[^)]+\)/.test(o)), ti = (o) => (o = String(o).replace(/\s+/g, ""), ["", "transparent"].includes(o) || /rgba\(\d+,\d+,\d+,0\)/.test(o)), ei = (o) => {
let { lineColor: t, root: e, second: i, node: n } = o, s = [
t,
e.fillColor,
e.color,
i.fillColor,
i.color,
n.fillColor,
n.color,
e.borderColor,
i.borderColor,
n.borderColor
];
for (let a = 0; a < s.length; a++) {
let h = s[a];
if (!ti(h) && !ue(h))
return h;
}
};
let G = null;
const ii = (o) => {
G || (G = document.createElement("div")), G.innerHTML = o;
const t = G.querySelectorAll(".ql-formula");
Array.from(t).forEach((n) => {
const s = document.createTextNode("$smmformula$");
n.parentNode.replaceChild(s, n);
});
const e = G.childNodes;
let i = [];
for (let n = 0; n < e.length; n++) {
const s = e[n];
s.nodeType === 1 ? i.push(s.textContent) : s.nodeType === 3 && i.push(s.nodeValue);
}
if (o = i.map((n) => `<p><span>${Mt(n)}</span></p>`).join(""), t.length > 0) {
o = o.replace(/\$smmformula\$/g, '<span class="smmformula"></span>'), G.innerHTML = o;
const n = G.querySelectorAll(".smmformula");
Array.from(n).forEach((s, a) => {
s.parentNode.replaceChild(t[a], s);
}), o = G.innerHTML;
}
return o;
}, ni = (o, t) => {
const e = {};
return Object.keys(t).forEach((i) => {
const n = o[i], s = t[i];
if (X(n) !== X(s)) {
e[i] = s;
return;
}
if (X(n) === "Object") {
if (JSON.stringify(n) !== JSON.stringify(s)) {
e[i] = s;
return;
}
} else if (n !== s) {
e[i] = s;
return;
}
}), e;
}, yt = (o) => /^_/.test(o) ? !1 : !ut.includes(o), si = (o) => {
const t = [...Ct], e = Object.keys(o);
for (let i = 0; i < e.length; i++)
if (!t.includes(e[i]))
return !1;
return !0;
}, ai = (o) => o.reduce((t, e) => {
const i = t.find((n) => n.type === e.type);
return i ? e.list.forEach((n) => {
const s = i.list.find((a) => a.name === n.name);
s ? s.icon = n.icon : i.list.push(n);
}) : t.push({ ...e }), t;
}, []), kt = (o) => {
let t = [];
return o.forEach((e) => {
o.find((i) => i.uid !== e.uid && i.isAncestor(e)) || t.push(e);
}), t;
}, oi = (o) => {
const t = {}, e = {};
o.forEach((n) => {
const s = n.parent;
if (s) {
const a = s.uid;
e[a] = s;
const h = n.getIndexInBrothers(), r = {
node: n,
index: h
};
t[a] ? t[a].find((l) => l.index === r.index) || t[a].push(r) : t[a] = [r];
}
});
const i = [];
return Object.keys(t).forEach((n) => {
if (t[n].length > 1) {
const s = t[n].map((a) => a.index).sort((a, h) => a - h);
i.push({
node: e[n],
range: [s[0], s[s.length - 1]]
});
} else
i.push({
node: t[n][0].node
});
}), i;
}, hi = (o) => {
let t = window.getSelection(), e = document.createRange();
e.selectNodeContents(o), e.collapse(), t.removeAllRanges(), t.addRange(e);
}, ri = (o) => {
let t = window.getSelection(), e = document.createRange();
e.selectNodeContents(o), t.removeAllRanges(), t.addRange(e);
}, pt = (o, t = {}) => {
t = { ...t }, t && t.richText && t.resetRichText && delete t.resetRichText;
const i = (n) => {
n.forEach((s) => {
s.data = {
...s.data,
...t
}, s.children && s.children.length > 0 && i(s.children);
});
};
return i(o), o;
}, at = (o, t = !1, e = null, i = !1) => {
const n = (s) => {
s.forEach((a) => {
a.data || (a.data = {}), (t || W(a.data.uid)) && (a.data.uid = H()), i && Et(a.data).forEach((r) => {
(t || W(r.uid)) && (r.uid = H());
}), e && e(a), a.children && a.children.length > 0 && n(a.children);
});
};
return n(o), o;
}, b = (o) => o ? Array.isArray(o) ? o : [o] : [], ot = (o) => o.parent ? o.parent.nodeData.children.findIndex((t) => t.data.uid === o.uid) : 0, O = (o, t) => t.findIndex((e) => e.uid === o.uid), ge = (o) => {
let t = 0;
for (let n = 0; n < o.length; n++)
t = o.charCodeAt(n) + ((t << 5) - t);
return "hsla(" + new It(t).genrand_int32() % 360 + ", 50%, 50%, 1)";
}, Mt = (o) => ([
["&", "&"],
["<", "<"],
[">", ">"]
].forEach((t) => {
o = o.replace(new RegExp(t[0], "g"), t[1]);
}), o), Lt = (o, t) => {
const e = X(o);
if (e !== X(t))
return !1;
if (e === "Object") {
const i = Object.keys(o), n = Object.keys(t);
if (i.length !== n.length)
return !1;
for (let s = 0; s < i.length; s++) {
const a = i[s];
if (!n.includes(a) || !Lt(o[a], t[a]))
return !1;
}
return !0;
} else if (e === "Array") {
if (o.length !== t.length)
return !1;
for (let i = 0; i < o.length; i++) {
const n = o[i], s = t[i], a = X(n), h = X(s);
if (a !== h || !Lt(n, s))
return !1;
}
return !0;
} else
return o === t;
}, me = () => navigator.clipboard && typeof navigator.clipboard.read == "function", Ht = (o) => {
navigator.clipboard && navigator.clipboard.writeText && navigator.clipboard.writeText(JSON.stringify(o));
}, li = async () => {
let o = null, t = null;
if (me()) {
const e = await navigator.clipboard.read();
if (e && e.length > 0)
for (const i of e)
for (const n of i.types)
/^image\//.test(n) ? t = await i.getType(n) : n === "text/plain" && (o = await (await i.getType(n)).text());
}
return {
text: o,
img: t
};
}, wt = (o) => {
if (!o || !o.parent)
return;
const t = ot(o);
t !== -1 && o.parent.nodeData.children.splice(t, 1);
}, di = (o, t) => {
if (o.length !== t.length)
return !1;
for (let e = 0; e < o.length; e++)
if (!t.find((i) => i.uid === o[e].uid))
return !1;
return !0;
}, Ut = (o) => ({
simpleMindMap: !0,
data: o
}), _t = (o) => {
let t = null;
if (typeof o == "string")
try {
const i = JSON.parse(o);
typeof i == "object" && i.simpleMindMap && (t = i.data);
} catch {
}
else
typeof o == "object" && o.simpleMindMap && (t = o.data);
const e = !!t;
return {
isSmm: e,
data: e ? t : String(o)
};
}, $t = (o, t) => {
o.preventDefault();
const e = window.getSelection();
if (!e.rangeCount)
return;
e.deleteFromDocument(), t = t || o.clipboardData.getData("text"), t = Mt(t), t = pe(t);
const i = t.split(/\n/g), n = document.createDocumentFragment();
i.forEach((s, a) => {
const h = document.createTextNode(s);
if (n.appendChild(h), a < i.length - 1) {
const r = document.createElement("br");
n.appendChild(r);
}
}), e.getRangeAt(0).insertNode(n), e.collapseToEnd();
}, Gt = (o) => {
const t = {}, e = (i, n) => {
const s = i.data.uid;
n && n.children.push(s), t[s] = {
isRoot: !n,
data: {
...i.data
},
children: []
}, i.children && i.children.length > 0 && i.children.forEach((a) => {
e(a, t[s]);
});
};
return e(o, null), t;
}, ci = ({
addContentToHeader: o,
addContentToFooter: t
}) => {
const e = [];
let i = null, n = 0, s = null, a = 0;
const h = (r, l) => {
if (typeof r == "function") {
const d = r();
if (!d)
return;
const { el: c, cssText: p, height: g } = d;
if (c instanceof HTMLElement) {
tt(c);
const f = J({ el: c, height: g });
l(f, g);
}
p && e.push(p);
}
};
return h(o, (r, l) => {
i = r, n = l;
}), h(t, (r, l) => {
s = r, a = l;
}), {
cssTextList: e,
header: i,
headerHeight: n,
footer: s,
footerHeight: a
};
}, fi = (o, t = 0, e = 0, i = 0, n = 0, s = !1, a = !1) => {
let h = 1 / 0, r = -1 / 0, l = 1 / 0, d = -1 / 0;
const c = (p, g) => {
if (!(g && s) && p.group)
try {
const { x: f, y: m, width: u, height: E } = p.group.findOne(".smm-node-shape").rbox();
f < h && (h = f), f + u > r && (r = f + u), m < l && (l = m), m + E > d && (d = m + E);
} catch {
}
!a && p._generalizationList.length > 0 && p._generalizationList.forEach((f) => {
c(f.generalizationNode);
}), p.children && p.children.forEach((f) => {
c(f);
});
};
return c(o, !0), h = h - t + i, l = l - e + n, r = r - t + i, d = d - e + n, {
left: h,
top: l,
width: r - h,
height: d - l
};
}, pi = () => {
if (document.documentElement.requestFullScreen)
return "fullscreenchange";
if (document.documentElement.webkitRequestFullScreen)
return "webkitfullscreenchange";
if (document.documentElement.mozRequestFullScreen)
return "mozfullscreenchange";
if (document.documentElement.msRequestFullscreen)
return "msfullscreenchange";
};
pi();
const J = ({ el: o, width: t, height: e }) => {
const i = new Ne();
return t !== void 0 && i.width(t), e !== void 0 && i.height(e), i.add(o), i;
}, Et = (o) => {
const t = o.generalization;
return t ? Array.isArray(t) ? t : [t] : [];
}, tt = (o) => {
o.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
}, Wt = (o) => (o = [...o], o.sort((t, e) => t.sortIndex - e.sortIndex), o), xe = (o, t) => xt(o, t, {
arrayMerge: (e, i) => i
}), ui = (o) => {
const t = {};
return Ce.forEach((e) => {
let i = o.style.merge(e);
e === "fontSize" && (i = i + "px"), t[e] = i;
}), t;
}, Yt = [
"backgroundColor",
"backgroundImage",
"backgroundRepeat",
"backgroundPosition",
"backgroundSize"
], Ee = [
"gradientStyle",
"startColor",
"endColor",
"startDir",
"endDir",
"fillColor",
"borderColor",
"borderWidth",
"borderDasharray"
];
class B {
// 设置背景样式
static setBackgroundStyle(t, e) {
if (!t)
return;
if (!B.cacheStyle) {
B.cacheStyle = {};
let r = window.getComputedStyle(t);
Yt.forEach((l) => {
B.cacheStyle[l] = r[l];
});
}
let {
backgroundColor: i,
backgroundImage: n,
backgroundRepeat: s,
backgroundPosition: a,
backgroundSize: h
} = e;
t.style.backgroundColor = i, n && n !== "none" ? (t.style.backgroundImage = `url(${n})`, t.style.backgroundRepeat = s, t.style.backgroundPosition = a, t.style.backgroundSize = h) : t.style.backgroundImage = "none";
}
// 移除背景样式
static removeBackgroundStyle(t) {
B.cacheStyle && (Yt.forEach((e) => {
t.style[e] = B.cacheStyle[e];
}), B.cacheStyle = null);
}
// 添加阴影效果
addShadow(t) {
const e = {
boxShadowHorizontal: this.merge("boxShadowHorizontal"),
boxShadowVertical: this.merge("boxShadowVertical"),
boxShadowBlur: this.merge("boxShadowBlur"),
boxShadowColor: this.merge("boxShadowColor")
};
if (e.boxShadowColor && (e.boxShadowHorizontal || e.boxShadowVertical || e.boxShadowBlur)) {
const i = e.boxShadowHorizontal || 0, n = e.boxShadowVertical || 0, s = e.boxShadowBlur || 0, a = e.boxShadowColor;
t.attr("filter", `drop-shadow(${i}px ${n}px ${s}px ${a})`);
}
}
// 构造函数
constructor(t) {
this.ctx = t, this._markerPath = null, this._marker = null, this._gradient = null;
}
// 合并样式
merge(t, e) {
let i = this.ctx.mindMap.themeConfig, n = null, s = !1;
e ? (s = !0, n = i) : this.ctx.isGeneralization ? n = i.generalization : this.ctx.layerIndex === 0 ? n = i.root : this.ctx.layerIndex === 1 ? n = i.second : n = i.node;
let a = "";
return this.getSelfStyle(t) !== void 0 ? a = this.getSelfStyle(t) : n[t] !== void 0 ? a = n[t] : a = i[t], s || this.addToEffectiveStyles({
[t]: a
}), a;
}
// 获取某个样式值
getStyle(t, e) {
return this.merge(t, e);
}
// 获取自身自定义样式
getSelfStyle(t) {
return this.ctx.getData(t);
}
// 更新当前节点生效的样式数据
addToEffectiveStyles(t) {
this.ctx.mindMap.painter && (this.ctx.effectiveStyles = {
...this.ctx.effectiveStyles,
...t
});
}
// // 矩形
// rect(node) {
// this.shape(node)
// node.radius(this.merge('borderRadius')
// }
// 形状
shape(t) {
const e = {};
Ee.forEach((i) => {
e[i] = this.merge(i);
}), e.gradientStyle ? (this._gradient || (this._gradient = this.ctx.nodeDraw.gradient("linear")), this._gradient.update((i) => {
i.stop(0, e.startColor), i.stop(1, e.endColor);
}), this._gradient.from(...e.startDir).to(...e.endDir), t.fill(this._gradient)) : t.fill({
color: e.fillColor
}), this.addShadow(t), t.stroke({
color: e.borderColor,
width: e.borderWidth,
dasharray: e.borderDasharray
});
}
// 文字
text(t) {
const e = {
color: this.merge("color"),
fontFamily: this.merge("fontFamily"),
fontSize: this.merge("fontSize"),
fontWeight: this.merge("fontWeight"),
fontStyle: this.merge("fontStyle"),
textDecoration: this.merge("textDecoration")
};
t.fill({
color: e.color
}).css({
"font-family": e.fontFamily,
"font-size": e.fontSize + "px",
"font-weight": e.fontWeight,
"font-style": e.fontStyle,
"text-decoration": e.textDecoration
});
}
// html文字节点
domText(t, e = 1) {
const i = {
color: this.merge("color"),
fontFamily: this.merge("fontFamily"),
fontSize: this.merge("fontSize"),
fontWeight: this.merge("fontWeight"),
fontStyle: this.merge("fontStyle"),
textDecoration: this.merge("textDecoration"),
textAlign: this.merge("textAlign")
};
t.style.color = i.color, t.style.textDecoration = i.textDecoration, t.style.fontFamily = i.fontFamily, t.style.fontSize = i.fontSize * e + "px", t.style.fontWeight = i.fontWeight || "normal", t.style.fontStyle = i.fontStyle, t.style.textAlign = i.textAlign;
}
// 标签文字
tagText(t, e) {
t.fill({
color: "#fff"
}).css({
"font-size": e.fontSize + "px"
});
}
// 标签矩形
tagRect(t, e) {
t.fill({
color: e.fill
}), e.radius && t.radius(e.radius);
}
// 内置图标
iconNode(t, e) {
t.attr({
fill: e || this.merge("color")
});
}
// 连线
line(t, { width: e, color: i, dasharray: n } = {}, s, a) {
const { customHandleLine: h } = this.ctx.mindMap.opt;
if (typeof h == "function" && h(this.ctx, t, { width: e, c