@opentiny/fluent-editor 4.0.0 → 4.1.0-alpha.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/es/config/i18n/en-us.es.js +2 -0
- package/es/config/i18n/en-us.es.js.map +1 -1
- package/es/config/i18n/zh-cn.es.js +2 -0
- package/es/config/i18n/zh-cn.es.js.map +1 -1
- package/es/config/index.es.js +1 -1
- package/es/config/index.es.js.map +1 -1
- package/es/fluent-editor.es.js +6 -0
- package/es/fluent-editor.es.js.map +1 -1
- package/es/index.es.js +4 -0
- package/es/index.es.js.map +1 -1
- package/es/modules/ai/constants.es.js +50 -0
- package/es/modules/ai/constants.es.js.map +1 -0
- package/es/modules/ai/icons.es.js +319 -0
- package/es/modules/ai/icons.es.js.map +1 -0
- package/es/modules/ai/index.es.js +670 -0
- package/es/modules/ai/index.es.js.map +1 -0
- package/es/modules/custom-uploader.es.js +42 -6
- package/es/modules/custom-uploader.es.js.map +1 -1
- package/es/modules/file/modules/file-module.es.js +4 -2
- package/es/modules/file/modules/file-module.es.js.map +1 -1
- package/es/modules/flow-chart/config-utils.es.js +102 -0
- package/es/modules/flow-chart/config-utils.es.js.map +1 -0
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js +369 -0
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +1 -0
- package/es/modules/flow-chart/i18n/en-us.es.js +30 -0
- package/es/modules/flow-chart/i18n/en-us.es.js.map +1 -0
- package/es/modules/flow-chart/i18n/index.es.js +12 -0
- package/es/modules/flow-chart/i18n/index.es.js.map +1 -0
- package/es/modules/flow-chart/i18n/zh-cn.es.js +30 -0
- package/es/modules/flow-chart/i18n/zh-cn.es.js.map +1 -0
- package/es/modules/flow-chart/icons.es.js +27 -0
- package/es/modules/flow-chart/icons.es.js.map +1 -0
- package/es/modules/flow-chart/index.es.js +45 -0
- package/es/modules/flow-chart/index.es.js.map +1 -0
- package/es/modules/flow-chart/modules/context-menu.es.js +184 -0
- package/es/modules/flow-chart/modules/context-menu.es.js.map +1 -0
- package/es/modules/flow-chart/modules/control-panel.es.js +286 -0
- package/es/modules/flow-chart/modules/control-panel.es.js.map +1 -0
- package/es/modules/flow-chart/modules/custom-resize-action.es.js +150 -0
- package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +1 -0
- package/es/modules/index.es.js +4 -0
- package/es/modules/index.es.js.map +1 -1
- package/es/modules/mind-map/config-utils.es.js +108 -0
- package/es/modules/mind-map/config-utils.es.js.map +1 -0
- package/es/modules/mind-map/formats/mind-map-blot.es.js +356 -0
- package/es/modules/mind-map/formats/mind-map-blot.es.js.map +1 -0
- package/es/modules/mind-map/i18n/en-us.es.js +29 -0
- package/es/modules/mind-map/i18n/en-us.es.js.map +1 -0
- package/es/modules/mind-map/i18n/index.es.js +12 -0
- package/es/modules/mind-map/i18n/index.es.js.map +1 -0
- package/es/modules/mind-map/i18n/zh-cn.es.js +29 -0
- package/es/modules/mind-map/i18n/zh-cn.es.js.map +1 -0
- package/es/modules/mind-map/icons.es.js +45 -0
- package/es/modules/mind-map/icons.es.js.map +1 -0
- package/es/modules/mind-map/index.es.js +56 -0
- package/es/modules/mind-map/index.es.js.map +1 -0
- package/es/modules/mind-map/modules/context-menu.es.js +128 -0
- package/es/modules/mind-map/modules/context-menu.es.js.map +1 -0
- package/es/modules/mind-map/modules/control-panel.es.js +425 -0
- package/es/modules/mind-map/modules/control-panel.es.js.map +1 -0
- package/es/modules/mind-map/modules/custom-resize-action.es.js +161 -0
- package/es/modules/mind-map/modules/custom-resize-action.es.js.map +1 -0
- package/es/modules/shortcut-key/index.es.js +18 -1
- package/es/modules/shortcut-key/index.es.js.map +1 -1
- package/es/modules/syntax.es.js +19 -0
- package/es/modules/syntax.es.js.map +1 -1
- package/es/themes/snow.es.js +3 -9
- package/es/themes/snow.es.js.map +1 -1
- package/es/ui/icons.config.es.js +4 -0
- package/es/ui/icons.config.es.js.map +1 -1
- package/es/ui/icons.es.js +4 -2
- package/es/ui/icons.es.js.map +1 -1
- package/flow-chart.css +185 -0
- package/lib/config/i18n/en-us.cjs.js +2 -0
- package/lib/config/i18n/en-us.cjs.js.map +1 -1
- package/lib/config/i18n/zh-cn.cjs.js +2 -0
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
- package/lib/config/index.cjs.js +1 -1
- package/lib/config/index.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js +8 -2
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/index.cjs.js +9 -5
- package/lib/index.cjs.js.map +1 -1
- package/lib/modules/ai/constants.cjs.js +50 -0
- package/lib/modules/ai/constants.cjs.js.map +1 -0
- package/lib/modules/ai/icons.cjs.js +319 -0
- package/lib/modules/ai/icons.cjs.js.map +1 -0
- package/lib/modules/ai/index.cjs.js +670 -0
- package/lib/modules/ai/index.cjs.js.map +1 -0
- package/lib/modules/custom-uploader.cjs.js +42 -6
- package/lib/modules/custom-uploader.cjs.js.map +1 -1
- package/lib/modules/file/modules/file-module.cjs.js +4 -2
- package/lib/modules/file/modules/file-module.cjs.js.map +1 -1
- package/lib/modules/flow-chart/config-utils.cjs.js +102 -0
- package/lib/modules/flow-chart/config-utils.cjs.js.map +1 -0
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +369 -0
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +1 -0
- package/lib/modules/flow-chart/i18n/en-us.cjs.js +30 -0
- package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +1 -0
- package/lib/modules/flow-chart/i18n/index.cjs.js +12 -0
- package/lib/modules/flow-chart/i18n/index.cjs.js.map +1 -0
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +30 -0
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +1 -0
- package/lib/modules/flow-chart/icons.cjs.js +27 -0
- package/lib/modules/flow-chart/icons.cjs.js.map +1 -0
- package/lib/modules/flow-chart/index.cjs.js +45 -0
- package/lib/modules/flow-chart/index.cjs.js.map +1 -0
- package/lib/modules/flow-chart/modules/context-menu.cjs.js +184 -0
- package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +1 -0
- package/lib/modules/flow-chart/modules/control-panel.cjs.js +286 -0
- package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +1 -0
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +150 -0
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +1 -0
- package/lib/modules/index.cjs.js +9 -5
- package/lib/modules/index.cjs.js.map +1 -1
- package/lib/modules/mind-map/config-utils.cjs.js +108 -0
- package/lib/modules/mind-map/config-utils.cjs.js.map +1 -0
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +356 -0
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +1 -0
- package/lib/modules/mind-map/i18n/en-us.cjs.js +29 -0
- package/lib/modules/mind-map/i18n/en-us.cjs.js.map +1 -0
- package/lib/modules/mind-map/i18n/index.cjs.js +12 -0
- package/lib/modules/mind-map/i18n/index.cjs.js.map +1 -0
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js +29 -0
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +1 -0
- package/lib/modules/mind-map/icons.cjs.js +45 -0
- package/lib/modules/mind-map/icons.cjs.js.map +1 -0
- package/lib/modules/mind-map/index.cjs.js +56 -0
- package/lib/modules/mind-map/index.cjs.js.map +1 -0
- package/lib/modules/mind-map/modules/context-menu.cjs.js +128 -0
- package/lib/modules/mind-map/modules/context-menu.cjs.js.map +1 -0
- package/lib/modules/mind-map/modules/control-panel.cjs.js +425 -0
- package/lib/modules/mind-map/modules/control-panel.cjs.js.map +1 -0
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +161 -0
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +1 -0
- package/lib/modules/shortcut-key/index.cjs.js +18 -1
- package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
- package/lib/modules/syntax.cjs.js +19 -0
- package/lib/modules/syntax.cjs.js.map +1 -1
- package/lib/themes/snow.cjs.js +3 -9
- package/lib/themes/snow.cjs.js.map +1 -1
- package/lib/ui/icons.cjs.js +3 -1
- package/lib/ui/icons.cjs.js.map +1 -1
- package/lib/ui/icons.config.cjs.js +4 -0
- package/lib/ui/icons.config.cjs.js.map +1 -1
- package/mind-map.css +224 -0
- package/package.json +3 -1
- package/types/config/i18n/en-us.d.ts +2 -0
- package/types/config/i18n/zh-cn.d.ts +2 -0
- package/types/config/types/editor-modules.interface.d.ts +4 -0
- package/types/modules/ai/constants.d.ts +30 -0
- package/types/modules/ai/icons.d.ts +21 -0
- package/types/modules/ai/index.d.ts +96 -0
- package/types/modules/ai/types.d.ts +16 -0
- package/types/modules/custom-uploader.d.ts +14 -4
- package/types/modules/flow-chart/config-utils.d.ts +10 -0
- package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +43 -0
- package/types/modules/flow-chart/i18n/en-us.d.ts +26 -0
- package/types/modules/flow-chart/i18n/index.d.ts +1 -0
- package/types/modules/flow-chart/i18n/zh-cn.d.ts +26 -0
- package/types/modules/flow-chart/icons.d.ts +12 -0
- package/types/modules/flow-chart/index.d.ts +10 -0
- package/types/modules/flow-chart/modules/context-menu.d.ts +3 -0
- package/types/modules/flow-chart/modules/control-panel.d.ts +3 -0
- package/types/modules/flow-chart/modules/custom-resize-action.d.ts +22 -0
- package/types/modules/flow-chart/options.d.ts +29 -0
- package/types/modules/index.d.ts +2 -0
- package/types/modules/mind-map/config-utils.d.ts +12 -0
- package/types/modules/mind-map/formats/mind-map-blot.d.ts +44 -0
- package/types/modules/mind-map/i18n/en-us.d.ts +25 -0
- package/types/modules/mind-map/i18n/index.d.ts +1 -0
- package/types/modules/mind-map/i18n/zh-cn.d.ts +25 -0
- package/types/modules/mind-map/icons.d.ts +21 -0
- package/types/modules/mind-map/index.d.ts +10 -0
- package/types/modules/mind-map/modules/context-menu.d.ts +3 -0
- package/types/modules/mind-map/modules/control-panel.d.ts +3 -0
- package/types/modules/mind-map/modules/custom-resize-action.d.ts +23 -0
- package/types/modules/mind-map/options.d.ts +27 -0
- package/types/ui/icons.config.d.ts +2 -0
- package/types/modules/syntax.d.ts +0 -13
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const MIN_WIDTH = 350;
|
|
5
|
+
const MIN_HEIGHT = 290;
|
|
6
|
+
class FlowChartResizeAction {
|
|
7
|
+
constructor(blot) {
|
|
8
|
+
__publicField(this, "topLeftHandle");
|
|
9
|
+
__publicField(this, "topRightHandle");
|
|
10
|
+
__publicField(this, "bottomRightHandle");
|
|
11
|
+
__publicField(this, "bottomLeftHandle");
|
|
12
|
+
__publicField(this, "dragHandle", null);
|
|
13
|
+
__publicField(this, "dragStartX", 0);
|
|
14
|
+
__publicField(this, "dragStartY", 0);
|
|
15
|
+
__publicField(this, "preDragWidth", 0);
|
|
16
|
+
__publicField(this, "preDragHeight", 0);
|
|
17
|
+
__publicField(this, "targetRatio", 0);
|
|
18
|
+
__publicField(this, "blot");
|
|
19
|
+
this.blot = blot;
|
|
20
|
+
this.topLeftHandle = this.createHandle("top-left", "nwse-resize");
|
|
21
|
+
this.topRightHandle = this.createHandle("top-right", "nesw-resize");
|
|
22
|
+
this.bottomRightHandle = this.createHandle("bottom-right", "nwse-resize");
|
|
23
|
+
this.bottomLeftHandle = this.createHandle("bottom-left", "nesw-resize");
|
|
24
|
+
this.init();
|
|
25
|
+
}
|
|
26
|
+
isFullscreen() {
|
|
27
|
+
const container = this.blot.domNode;
|
|
28
|
+
return container.style.position === "fixed" && container.style.width === "100vw" && container.style.height === "100vh";
|
|
29
|
+
}
|
|
30
|
+
init() {
|
|
31
|
+
const container = this.blot.domNode;
|
|
32
|
+
container.style.position = "relative";
|
|
33
|
+
container.appendChild(this.topLeftHandle);
|
|
34
|
+
container.appendChild(this.topRightHandle);
|
|
35
|
+
container.appendChild(this.bottomRightHandle);
|
|
36
|
+
container.appendChild(this.bottomLeftHandle);
|
|
37
|
+
this.repositionHandles();
|
|
38
|
+
}
|
|
39
|
+
createHandle(position, cursor) {
|
|
40
|
+
const box = document.createElement("div");
|
|
41
|
+
box.classList.add("ql-flow-chart-resize-handle");
|
|
42
|
+
box.setAttribute("data-position", position);
|
|
43
|
+
Object.assign(box.style, {
|
|
44
|
+
cursor,
|
|
45
|
+
position: "absolute",
|
|
46
|
+
width: "10px",
|
|
47
|
+
height: "10px",
|
|
48
|
+
background: "#4285f4",
|
|
49
|
+
border: "1px solid white",
|
|
50
|
+
borderRadius: "50%",
|
|
51
|
+
zIndex: "99",
|
|
52
|
+
userSelect: "none"
|
|
53
|
+
});
|
|
54
|
+
box.addEventListener("mousedown", this.onMouseDown.bind(this));
|
|
55
|
+
return box;
|
|
56
|
+
}
|
|
57
|
+
repositionHandles() {
|
|
58
|
+
const container = this.blot.domNode;
|
|
59
|
+
const rect = container.getBoundingClientRect();
|
|
60
|
+
Object.assign(this.topLeftHandle.style, {
|
|
61
|
+
left: "-5px",
|
|
62
|
+
top: "-5px"
|
|
63
|
+
});
|
|
64
|
+
Object.assign(this.topRightHandle.style, {
|
|
65
|
+
right: "-5px",
|
|
66
|
+
top: "-5px"
|
|
67
|
+
});
|
|
68
|
+
Object.assign(this.bottomRightHandle.style, {
|
|
69
|
+
right: "-5px",
|
|
70
|
+
bottom: "-5px"
|
|
71
|
+
});
|
|
72
|
+
Object.assign(this.bottomLeftHandle.style, {
|
|
73
|
+
left: "-5px",
|
|
74
|
+
bottom: "-5px"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
onMouseDown(event) {
|
|
78
|
+
if (this.isFullscreen()) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.dragHandle = event.target;
|
|
85
|
+
document.body.style.cursor = this.dragHandle.style.cursor;
|
|
86
|
+
const container = this.blot.domNode;
|
|
87
|
+
const rect = container.getBoundingClientRect();
|
|
88
|
+
this.dragStartX = event.clientX;
|
|
89
|
+
this.dragStartY = event.clientY;
|
|
90
|
+
this.preDragWidth = rect.width;
|
|
91
|
+
this.preDragHeight = rect.height;
|
|
92
|
+
this.targetRatio = rect.height / rect.width;
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
document.addEventListener("mousemove", this.onDrag.bind(this));
|
|
95
|
+
document.addEventListener("mouseup", this.onMouseUp.bind(this));
|
|
96
|
+
}
|
|
97
|
+
onDrag(event) {
|
|
98
|
+
if (!this.dragHandle) return;
|
|
99
|
+
const container = this.blot.domNode;
|
|
100
|
+
let newWidth = this.preDragWidth;
|
|
101
|
+
let newHeight = this.preDragHeight;
|
|
102
|
+
const deltaX = event.clientX - this.dragStartX;
|
|
103
|
+
const deltaY = event.clientY - this.dragStartY;
|
|
104
|
+
switch (this.dragHandle.dataset.position) {
|
|
105
|
+
case "top-left":
|
|
106
|
+
newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
|
|
107
|
+
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
|
|
108
|
+
break;
|
|
109
|
+
case "top-right":
|
|
110
|
+
newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
|
|
111
|
+
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
|
|
112
|
+
break;
|
|
113
|
+
case "bottom-right":
|
|
114
|
+
newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
|
|
115
|
+
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
|
|
116
|
+
break;
|
|
117
|
+
case "bottom-left":
|
|
118
|
+
newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
|
|
119
|
+
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
container.style.width = `${newWidth}px`;
|
|
123
|
+
container.style.height = `${newHeight}px`;
|
|
124
|
+
container.setAttribute("width", String(newWidth));
|
|
125
|
+
container.setAttribute("height", String(newHeight));
|
|
126
|
+
if (this.blot.flowChart) {
|
|
127
|
+
this.blot.flowChart.resize(newWidth, newHeight);
|
|
128
|
+
}
|
|
129
|
+
this.blot.data.width = newWidth;
|
|
130
|
+
this.blot.data.height = newHeight;
|
|
131
|
+
container.setAttribute("data-flow-chart", JSON.stringify(this.blot.data));
|
|
132
|
+
}
|
|
133
|
+
onMouseUp() {
|
|
134
|
+
document.body.style.cursor = "";
|
|
135
|
+
document.removeEventListener("mousemove", this.onDrag.bind(this));
|
|
136
|
+
document.removeEventListener("mouseup", this.onMouseUp.bind(this));
|
|
137
|
+
this.dragHandle = null;
|
|
138
|
+
}
|
|
139
|
+
destroy() {
|
|
140
|
+
const container = this.blot.domNode;
|
|
141
|
+
container.removeChild(this.topLeftHandle);
|
|
142
|
+
container.removeChild(this.topRightHandle);
|
|
143
|
+
container.removeChild(this.bottomRightHandle);
|
|
144
|
+
container.removeChild(this.bottomLeftHandle);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
FlowChartResizeAction
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=custom-resize-action.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-resize-action.es.js","sources":["../../../../../src/modules/flow-chart/modules/custom-resize-action.ts"],"sourcesContent":["const MIN_WIDTH = 350\nconst MIN_HEIGHT = 290\n\nexport class FlowChartResizeAction {\n topLeftHandle: HTMLElement\n topRightHandle: HTMLElement\n bottomRightHandle: HTMLElement\n bottomLeftHandle: HTMLElement\n dragHandle: HTMLElement | null = null\n dragStartX: number = 0\n dragStartY: number = 0\n preDragWidth: number = 0\n preDragHeight: number = 0\n targetRatio: number = 0\n blot: any\n\n constructor(blot: any) {\n this.blot = blot\n this.topLeftHandle = this.createHandle('top-left', 'nwse-resize')\n this.topRightHandle = this.createHandle('top-right', 'nesw-resize')\n this.bottomRightHandle = this.createHandle('bottom-right', 'nwse-resize')\n this.bottomLeftHandle = this.createHandle('bottom-left', 'nesw-resize')\n this.init()\n }\n\n isFullscreen(): boolean {\n const container = this.blot.domNode\n return container.style.position === 'fixed' && container.style.width === '100vw' && container.style.height === '100vh'\n }\n\n init() {\n const container = this.blot.domNode\n container.style.position = 'relative'\n container.appendChild(this.topLeftHandle)\n container.appendChild(this.topRightHandle)\n container.appendChild(this.bottomRightHandle)\n container.appendChild(this.bottomLeftHandle)\n this.repositionHandles()\n }\n\n createHandle(position: string, cursor: string): HTMLElement {\n const box = document.createElement('div')\n box.classList.add('ql-flow-chart-resize-handle')\n box.setAttribute('data-position', position)\n Object.assign(box.style, {\n cursor,\n position: 'absolute',\n width: '10px',\n height: '10px',\n background: '#4285f4',\n border: '1px solid white',\n borderRadius: '50%',\n zIndex: '99',\n userSelect: 'none',\n })\n box.addEventListener('mousedown', this.onMouseDown.bind(this))\n return box\n }\n\n repositionHandles() {\n const container = this.blot.domNode\n const rect = container.getBoundingClientRect()\n\n Object.assign(this.topLeftHandle.style, {\n left: '-5px',\n top: '-5px',\n })\n Object.assign(this.topRightHandle.style, {\n right: '-5px',\n top: '-5px',\n })\n Object.assign(this.bottomRightHandle.style, {\n right: '-5px',\n bottom: '-5px',\n })\n Object.assign(this.bottomLeftHandle.style, {\n left: '-5px',\n bottom: '-5px',\n })\n }\n\n onMouseDown(event: MouseEvent) {\n if (this.isFullscreen()) {\n return\n }\n if (!(event.target instanceof HTMLElement)) {\n return\n }\n\n this.dragHandle = event.target\n document.body.style.cursor = this.dragHandle.style.cursor\n\n const container = this.blot.domNode\n const rect = container.getBoundingClientRect()\n\n this.dragStartX = event.clientX\n this.dragStartY = event.clientY\n this.preDragWidth = rect.width\n this.preDragHeight = rect.height\n this.targetRatio = rect.height / rect.width\n\n event.preventDefault()\n document.addEventListener('mousemove', this.onDrag.bind(this))\n document.addEventListener('mouseup', this.onMouseUp.bind(this))\n }\n\n onDrag(event: MouseEvent) {\n if (!this.dragHandle) return\n\n const container = this.blot.domNode\n let newWidth = this.preDragWidth\n let newHeight = this.preDragHeight\n\n const deltaX = event.clientX - this.dragStartX\n const deltaY = event.clientY - this.dragStartY\n\n switch (this.dragHandle.dataset.position) {\n case 'top-left':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY)\n break\n case 'top-right':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY)\n break\n case 'bottom-right':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY)\n break\n case 'bottom-left':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY)\n break\n }\n\n container.style.width = `${newWidth}px`\n container.style.height = `${newHeight}px`\n container.setAttribute('width', String(newWidth))\n container.setAttribute('height', String(newHeight))\n\n if (this.blot.flowChart) {\n this.blot.flowChart.resize(newWidth, newHeight)\n }\n\n this.blot.data.width = newWidth\n this.blot.data.height = newHeight\n container.setAttribute('data-flow-chart', JSON.stringify(this.blot.data))\n }\n\n onMouseUp() {\n document.body.style.cursor = ''\n document.removeEventListener('mousemove', this.onDrag.bind(this))\n document.removeEventListener('mouseup', this.onMouseUp.bind(this))\n this.dragHandle = null\n }\n\n destroy() {\n const container = this.blot.domNode\n container.removeChild(this.topLeftHandle)\n container.removeChild(this.topRightHandle)\n container.removeChild(this.bottomRightHandle)\n container.removeChild(this.bottomLeftHandle)\n }\n}\n"],"names":[],"mappings":";;;AAAA,MAAM,YAAY;AAClB,MAA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AACF;"}
|
package/es/modules/index.es.js
CHANGED
|
@@ -6,10 +6,12 @@ import { FileUploader } from "./custom-uploader.es.js";
|
|
|
6
6
|
import { DividerBlot } from "./divider.es.js";
|
|
7
7
|
import { EmojiModule } from "./emoji.es.js";
|
|
8
8
|
import "./file/index.es.js";
|
|
9
|
+
import { FlowChartModule } from "./flow-chart/index.es.js";
|
|
9
10
|
import { I18N } from "./i18n.es.js";
|
|
10
11
|
import "./link/index.es.js";
|
|
11
12
|
import "./mathlive/index.es.js";
|
|
12
13
|
import "./mention/index.es.js";
|
|
14
|
+
import { MindMapModule } from "./mind-map/index.es.js";
|
|
13
15
|
import { ShortCutKey, shortKey } from "./shortcut-key/index.es.js";
|
|
14
16
|
import "./syntax.es.js";
|
|
15
17
|
import { generateTableUp } from "./table-up/index.es.js";
|
|
@@ -19,7 +21,9 @@ export {
|
|
|
19
21
|
DividerBlot,
|
|
20
22
|
EmojiModule,
|
|
21
23
|
FileUploader,
|
|
24
|
+
FlowChartModule,
|
|
22
25
|
I18N,
|
|
26
|
+
MindMapModule,
|
|
23
27
|
ShortCutKey,
|
|
24
28
|
generateTableUp,
|
|
25
29
|
shortKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
function getBackgroundConfig(quill) {
|
|
2
|
+
var _a;
|
|
3
|
+
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
4
|
+
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if ("background" in MindMapModule) {
|
|
8
|
+
const background = MindMapModule.background;
|
|
9
|
+
if (background === false || background === void 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (typeof background === "object" && background !== null) {
|
|
13
|
+
const typedBackground = background;
|
|
14
|
+
const backgroundConfig = {};
|
|
15
|
+
if (typedBackground.color) {
|
|
16
|
+
backgroundConfig.backgroundColor = typedBackground.color;
|
|
17
|
+
}
|
|
18
|
+
if (typedBackground.image) {
|
|
19
|
+
backgroundConfig.backgroundImage = typedBackground.image;
|
|
20
|
+
}
|
|
21
|
+
if (typedBackground.repeat) {
|
|
22
|
+
backgroundConfig.backgroundRepeat = typedBackground.repeat;
|
|
23
|
+
}
|
|
24
|
+
if (typedBackground.position) {
|
|
25
|
+
backgroundConfig.backgroundPosition = typedBackground.position;
|
|
26
|
+
}
|
|
27
|
+
if (typedBackground.size) {
|
|
28
|
+
backgroundConfig.backgroundSize = typedBackground.size;
|
|
29
|
+
}
|
|
30
|
+
return backgroundConfig;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function getLineConfig(quill) {
|
|
36
|
+
var _a;
|
|
37
|
+
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
38
|
+
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if ("line" in MindMapModule) {
|
|
42
|
+
const line = MindMapModule.line;
|
|
43
|
+
if (line === false || line === void 0) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (typeof line === "object" && line !== null) {
|
|
47
|
+
const typedLine = line;
|
|
48
|
+
const lineConfig = {};
|
|
49
|
+
if (typedLine.color) {
|
|
50
|
+
lineConfig.lineColor = typedLine.color;
|
|
51
|
+
}
|
|
52
|
+
if (typedLine.width) {
|
|
53
|
+
lineConfig.lineWidth = typedLine.width;
|
|
54
|
+
}
|
|
55
|
+
if (typedLine.dasharray) {
|
|
56
|
+
lineConfig.lineDasharray = typedLine.dasharray;
|
|
57
|
+
}
|
|
58
|
+
if (typedLine.style) {
|
|
59
|
+
lineConfig.lineStyle = typedLine.style;
|
|
60
|
+
}
|
|
61
|
+
return lineConfig;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function getResizeConfig(quill) {
|
|
67
|
+
var _a;
|
|
68
|
+
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
69
|
+
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if ("resize" in MindMapModule) {
|
|
73
|
+
const resize = MindMapModule.resize;
|
|
74
|
+
return resize === true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function getThemeConfig(quill) {
|
|
79
|
+
var _a;
|
|
80
|
+
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
81
|
+
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
82
|
+
return "default";
|
|
83
|
+
}
|
|
84
|
+
if ("theme" in MindMapModule) {
|
|
85
|
+
const theme = MindMapModule.theme;
|
|
86
|
+
return theme || "default";
|
|
87
|
+
}
|
|
88
|
+
return "default";
|
|
89
|
+
}
|
|
90
|
+
function getAllConfigs(quill) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
const deps = (_b = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"]) == null ? void 0 : _b.deps;
|
|
93
|
+
return {
|
|
94
|
+
backgroundConfig: getBackgroundConfig(quill),
|
|
95
|
+
resizeConfig: getResizeConfig(quill),
|
|
96
|
+
lineConfig: getLineConfig(quill),
|
|
97
|
+
themeConfig: getThemeConfig(quill),
|
|
98
|
+
deps
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
getAllConfigs,
|
|
103
|
+
getBackgroundConfig,
|
|
104
|
+
getLineConfig,
|
|
105
|
+
getResizeConfig,
|
|
106
|
+
getThemeConfig
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=config-utils.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-utils.es.js","sources":["../../../../src/modules/mind-map/config-utils.ts"],"sourcesContent":["import type Quill from 'quill'\nimport type { BackgroundConfig, LineConfig } from './options'\n\nexport function getBackgroundConfig(quill: Quill | null): false | object {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('background' in MindMapModule) {\n const background = MindMapModule.background as BackgroundConfig | boolean | undefined\n\n if (background === false || background === undefined) {\n return false\n }\n if (typeof background === 'object' && background !== null) {\n const typedBackground = background as BackgroundConfig\n const backgroundConfig: any = {}\n\n if (typedBackground.color) {\n backgroundConfig.backgroundColor = typedBackground.color\n }\n if (typedBackground.image) {\n backgroundConfig.backgroundImage = typedBackground.image\n }\n if (typedBackground.repeat) {\n backgroundConfig.backgroundRepeat = typedBackground.repeat\n }\n if (typedBackground.position) {\n backgroundConfig.backgroundPosition = typedBackground.position\n }\n if (typedBackground.size) {\n backgroundConfig.backgroundSize = typedBackground.size\n }\n return backgroundConfig\n }\n }\n return false\n}\n\nexport function getLineConfig(quill: Quill | null): false | object {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('line' in MindMapModule) {\n const line = MindMapModule.line as LineConfig | boolean | undefined\n\n if (line === false || line === undefined) {\n return false\n }\n if (typeof line === 'object' && line !== null) {\n const typedLine = line as LineConfig\n const lineConfig: any = {}\n\n if (typedLine.color) {\n lineConfig.lineColor = typedLine.color\n }\n if (typedLine.width) {\n lineConfig.lineWidth = typedLine.width\n }\n if (typedLine.dasharray) {\n lineConfig.lineDasharray = typedLine.dasharray\n }\n if (typedLine.style) {\n lineConfig.lineStyle = typedLine.style\n }\n return lineConfig\n }\n }\n return false\n}\n\nexport function getResizeConfig(quill: Quill | null): boolean {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('resize' in MindMapModule) {\n const resize = (MindMapModule as any).resize as boolean | undefined\n return resize === true\n }\n return false\n}\n\nexport function getThemeConfig(quill: Quill | null): string {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return 'default'\n }\n if ('theme' in MindMapModule) {\n const theme = MindMapModule.theme as string | undefined\n return theme || 'default'\n }\n return 'default'\n}\n\nexport function getAllConfigs(quill: Quill | null): {\n backgroundConfig: false | object\n resizeConfig: boolean\n lineConfig: false | object\n themeConfig: string\n deps?: any\n} {\n const deps = (quill?.options.modules?.['mind-map'] as any)?.deps\n return {\n backgroundConfig: getBackgroundConfig(quill),\n resizeConfig: getResizeConfig(quill),\n lineConfig: getLineConfig(quill),\n themeConfig: getThemeConfig(quill),\n deps,\n }\n}\n"],"names":[],"mappings":"AAGO,SAAS,oBAAoB,OAAqC;AAAlE;AACL,QAAM,iBAAgB,oCAAO,QAAQ,YAAf,mBAAyB;AAC/C,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AACA,MAAI,gBAAgB,eAAe;AACjC,UAAM,aAAa,cAAc;AAEjC,QAAI,eAAe,SAAS,eAAe,QAAW;AACpD,aAAO;AAAA,IACT;AACA,QAAI,OAAO,eAAe,YAAY,eAAe,MAAM;AACzD,YAAM,kBAAkB;AACxB,YAAM,mBAAwB,CAAA;AAE9B,UAAI,gBAAgB,OAAO;AACzB,yBAAiB,kBAAkB,gBAAgB;AAAA,MACrD;AACA,UAAI,gBAAgB,OAAO;AACzB,yBAAiB,kBAAkB,gBAAgB;AAAA,MACrD;AACA,UAAI,gBAAgB,QAAQ;AAC1B,yBAAiB,mBAAmB,gBAAgB;AAAA,MACtD;AACA,UAAI,gBAAgB,UAAU;AAC5B,yBAAiB,qBAAqB,gBAAgB;AAAA,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SAAS;AAAA,EAClB;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAM5B;AAnGK;AAoGL,QAAM,QAAQ,0CAAO,QAAQ,YAAf,mBAAyB,gBAAzB,mBAA8C;AAC5D,SAAO;AAAA,IACL,kBAAkB,oBAAoB,KAAK;AAAA,IAC3C,cAAc,gBAAgB,KAAK;AAAA,IACnC,YAAY,cAAc,KAAK;AAAA,IAC/B,aAAa,eAAe,KAAK;AAAA,IACjC;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import Quill from "quill";
|
|
5
|
+
import { getAllConfigs } from "../config-utils.es.js";
|
|
6
|
+
import { expandIcon, contractIcon } from "../icons.es.js";
|
|
7
|
+
import { initContextMenu } from "../modules/context-menu.es.js";
|
|
8
|
+
import { createControlPanel } from "../modules/control-panel.es.js";
|
|
9
|
+
import { MindMapResizeAction } from "../modules/custom-resize-action.es.js";
|
|
10
|
+
/* empty css */
|
|
11
|
+
const BlockEmbed = Quill.import("blots/embed");
|
|
12
|
+
const _MindMapPlaceholderBlot = class _MindMapPlaceholderBlot extends BlockEmbed {
|
|
13
|
+
constructor(scroll, domNode) {
|
|
14
|
+
super(scroll, domNode);
|
|
15
|
+
__publicField(this, "quill", null);
|
|
16
|
+
__publicField(this, "mindMap", null);
|
|
17
|
+
__publicField(this, "data");
|
|
18
|
+
__publicField(this, "zoomCount", 0);
|
|
19
|
+
__publicField(this, "contextMenu", null);
|
|
20
|
+
__publicField(this, "currentNode", null);
|
|
21
|
+
__publicField(this, "width", 100);
|
|
22
|
+
__publicField(this, "height", 500);
|
|
23
|
+
__publicField(this, "parentObserver", null);
|
|
24
|
+
__publicField(this, "nextPObserver", null);
|
|
25
|
+
const data = _MindMapPlaceholderBlot.value(domNode);
|
|
26
|
+
this.width = data.width || 100;
|
|
27
|
+
this.height = data.height || 500;
|
|
28
|
+
this.domNode.style.width = `${this.width}${data.width ? "px" : "%"}`;
|
|
29
|
+
this.domNode.style.height = `${this.height}px`;
|
|
30
|
+
this.domNode.style.maxWidth = "100%";
|
|
31
|
+
this.domNode.style.border = "1px solid #e8e8e8";
|
|
32
|
+
this.domNode.setAttribute("contenteditable", "false");
|
|
33
|
+
this.data = _MindMapPlaceholderBlot.value(domNode);
|
|
34
|
+
this.initMindMap();
|
|
35
|
+
}
|
|
36
|
+
static value(domNode) {
|
|
37
|
+
const dataStr = JSON.parse(domNode.getAttribute("data-mind-map"));
|
|
38
|
+
const value = dataStr;
|
|
39
|
+
if (domNode.hasAttribute("width")) {
|
|
40
|
+
value.width = Number.parseInt(domNode.getAttribute("width"), 10);
|
|
41
|
+
}
|
|
42
|
+
if (domNode.hasAttribute("height")) {
|
|
43
|
+
value.height = Number.parseInt(domNode.getAttribute("height"), 10);
|
|
44
|
+
}
|
|
45
|
+
return dataStr;
|
|
46
|
+
}
|
|
47
|
+
static create(value) {
|
|
48
|
+
const node = super.create();
|
|
49
|
+
if (value) {
|
|
50
|
+
node.setAttribute("data-mind-map", JSON.stringify(value));
|
|
51
|
+
}
|
|
52
|
+
if (value.width) {
|
|
53
|
+
node.setAttribute("width", String(value.width));
|
|
54
|
+
node.style.width = `${value.width}%`;
|
|
55
|
+
}
|
|
56
|
+
if (value.height) {
|
|
57
|
+
node.setAttribute("height", String(value.height));
|
|
58
|
+
node.style.height = `${value.height}px`;
|
|
59
|
+
}
|
|
60
|
+
node.setAttribute("contenteditable", "false");
|
|
61
|
+
return node;
|
|
62
|
+
}
|
|
63
|
+
static findQuill(el) {
|
|
64
|
+
let cur = el;
|
|
65
|
+
while (cur) {
|
|
66
|
+
const q = cur.__quillInstance;
|
|
67
|
+
if (q) return q;
|
|
68
|
+
cur = cur.parentElement;
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
attach() {
|
|
73
|
+
super.attach();
|
|
74
|
+
this.quill = _MindMapPlaceholderBlot.findQuill(this.domNode);
|
|
75
|
+
}
|
|
76
|
+
initMindMap() {
|
|
77
|
+
if (this.domNode.isConnected) {
|
|
78
|
+
this.insertMindMapEditor();
|
|
79
|
+
} else {
|
|
80
|
+
const observer = new MutationObserver(() => {
|
|
81
|
+
if (this.domNode.isConnected) {
|
|
82
|
+
this.insertMindMapEditor();
|
|
83
|
+
observer.disconnect();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
insertMindMapEditor() {
|
|
90
|
+
this.domNode.style.width = `${this.width}${this.data.width ? "px" : "%"}`;
|
|
91
|
+
this.domNode.style.height = `${this.height}px`;
|
|
92
|
+
while (this.domNode.firstChild) {
|
|
93
|
+
this.domNode.removeChild(this.domNode.firstChild);
|
|
94
|
+
}
|
|
95
|
+
this.updateAlignmentStyle();
|
|
96
|
+
this.observeParentAlignment();
|
|
97
|
+
const { backgroundConfig, resizeConfig, lineConfig, themeConfig, deps } = getAllConfigs(this.quill);
|
|
98
|
+
const { SimpleMindMap, Themes, Drag, Export } = deps || window;
|
|
99
|
+
Themes.init(SimpleMindMap);
|
|
100
|
+
SimpleMindMap.usePlugin(Drag).usePlugin(Export);
|
|
101
|
+
this.mindMap = new SimpleMindMap({
|
|
102
|
+
el: this.domNode,
|
|
103
|
+
mousewheelAction: "zoom",
|
|
104
|
+
disableMouseWheelZoom: true,
|
|
105
|
+
layout: this.data.layout,
|
|
106
|
+
theme: themeConfig,
|
|
107
|
+
data: this.data.root ? this.data.root : this.data
|
|
108
|
+
});
|
|
109
|
+
const styleConfig = { ...backgroundConfig };
|
|
110
|
+
if (lineConfig && typeof lineConfig === "object") {
|
|
111
|
+
Object.assign(styleConfig, lineConfig);
|
|
112
|
+
}
|
|
113
|
+
this.mindMap.setThemeConfig(styleConfig);
|
|
114
|
+
const handleScroll = () => {
|
|
115
|
+
if (this.mindMap && this.domNode && this.domNode.isConnected) {
|
|
116
|
+
this.mindMap.getElRectInfo();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
120
|
+
this.domNode.addEventListener("remove", () => {
|
|
121
|
+
window.removeEventListener("scroll", handleScroll);
|
|
122
|
+
});
|
|
123
|
+
if (resizeConfig) {
|
|
124
|
+
new MindMapResizeAction(this);
|
|
125
|
+
}
|
|
126
|
+
createControlPanel(this, this.quill);
|
|
127
|
+
initContextMenu(this, this.quill);
|
|
128
|
+
this.observeOwnParentChange();
|
|
129
|
+
this.observeNextPElement();
|
|
130
|
+
this.addMouseHoverEvents();
|
|
131
|
+
this.mindMap.on("node_tree_render_end", () => {
|
|
132
|
+
this.data = this.mindMap.getData({});
|
|
133
|
+
this.domNode.setAttribute("data-mind-map", JSON.stringify(this.data));
|
|
134
|
+
});
|
|
135
|
+
this.mindMap.on("node_dblclick", this.handleNodeDblClick.bind(this));
|
|
136
|
+
this.domNode.addEventListener("click", (e) => {
|
|
137
|
+
if (this.quill) {
|
|
138
|
+
this.mindMap.getElRectInfo();
|
|
139
|
+
const mindMapBlot = Quill.find(this.domNode);
|
|
140
|
+
const index = this.quill.getIndex(mindMapBlot);
|
|
141
|
+
if (index && typeof index === "number") {
|
|
142
|
+
this.quill.setSelection(index + 1, 0);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
addMouseHoverEvents() {
|
|
148
|
+
this.domNode.addEventListener("mouseenter", () => {
|
|
149
|
+
this.showControlPanel();
|
|
150
|
+
});
|
|
151
|
+
this.domNode.addEventListener("mouseleave", () => {
|
|
152
|
+
this.mindMap.execCommand("CLEAR_ACTIVE_NODE");
|
|
153
|
+
this.hideControlPanel();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
getControlElements() {
|
|
157
|
+
const leftUpControl = this.domNode.querySelector(".ql-mind-map-left-up-control");
|
|
158
|
+
const control = this.domNode.querySelector(".ql-mind-map-control");
|
|
159
|
+
const panelStatusIcon = this.domNode.querySelector('[data-control-type="panel-status"]');
|
|
160
|
+
return { leftUpControl, control, panelStatusIcon };
|
|
161
|
+
}
|
|
162
|
+
showControlPanel() {
|
|
163
|
+
const { leftUpControl, control, panelStatusIcon } = this.getControlElements();
|
|
164
|
+
if (!leftUpControl || !control) return;
|
|
165
|
+
leftUpControl.style.display = "inline-flex";
|
|
166
|
+
control.style.display = "flex";
|
|
167
|
+
if (panelStatusIcon) {
|
|
168
|
+
const iconElement = panelStatusIcon.querySelector("i") || panelStatusIcon;
|
|
169
|
+
iconElement.innerHTML = expandIcon;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
hideControlPanel() {
|
|
173
|
+
const { leftUpControl, control, panelStatusIcon } = this.getControlElements();
|
|
174
|
+
if (!leftUpControl || !control) return;
|
|
175
|
+
leftUpControl.style.display = "none";
|
|
176
|
+
control.style.display = "none";
|
|
177
|
+
if (panelStatusIcon) {
|
|
178
|
+
const iconElement = panelStatusIcon.querySelector("i") || panelStatusIcon;
|
|
179
|
+
iconElement.innerHTML = contractIcon;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// 监听父元素变化
|
|
183
|
+
observeOwnParentChange() {
|
|
184
|
+
let currentParent = this.domNode.parentElement;
|
|
185
|
+
const observer = new MutationObserver(() => {
|
|
186
|
+
if (this.domNode.parentElement !== currentParent) {
|
|
187
|
+
currentParent = this.domNode.parentElement;
|
|
188
|
+
this.observeParentAlignment();
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
observer.observe(document.body, {
|
|
192
|
+
attributes: false,
|
|
193
|
+
childList: true,
|
|
194
|
+
subtree: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// 监听父元素对齐变化
|
|
198
|
+
observeParentAlignment() {
|
|
199
|
+
if (this.parentObserver) {
|
|
200
|
+
this.parentObserver.disconnect();
|
|
201
|
+
}
|
|
202
|
+
const observer = new MutationObserver((mutations) => {
|
|
203
|
+
mutations.forEach((mutation) => {
|
|
204
|
+
if (mutation.attributeName === "class") {
|
|
205
|
+
this.updateAlignmentStyle();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
this.parentObserver = observer;
|
|
210
|
+
const parent = this.domNode.parentElement;
|
|
211
|
+
if (parent) {
|
|
212
|
+
observer.observe(parent, {
|
|
213
|
+
attributes: true,
|
|
214
|
+
attributeFilter: ["class"]
|
|
215
|
+
});
|
|
216
|
+
this.updateAlignmentStyle();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// 更新对齐样式
|
|
220
|
+
updateAlignmentStyle() {
|
|
221
|
+
const parent = this.domNode.parentElement;
|
|
222
|
+
if (!parent) return;
|
|
223
|
+
this.domNode.style.margin = "";
|
|
224
|
+
this.domNode.style.display = "block";
|
|
225
|
+
if (parent.classList.contains("ql-align-center")) {
|
|
226
|
+
this.domNode.style.margin = "0 auto";
|
|
227
|
+
} else if (parent.classList.contains("ql-align-right")) {
|
|
228
|
+
this.domNode.style.marginLeft = "auto";
|
|
229
|
+
this.domNode.style.marginRight = "0";
|
|
230
|
+
} else {
|
|
231
|
+
this.domNode.style.marginLeft = "0";
|
|
232
|
+
this.domNode.style.marginRight = "auto";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
observeNextPElement() {
|
|
236
|
+
if (this.nextPObserver) {
|
|
237
|
+
this.nextPObserver.disconnect();
|
|
238
|
+
}
|
|
239
|
+
const parentElement = this.domNode.parentElement;
|
|
240
|
+
if (!parentElement) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const trackedParentElement = parentElement;
|
|
244
|
+
const parentElementId = parentElement.getAttribute("id") || `mind-map-parent-${Date.now()}`;
|
|
245
|
+
parentElement.setAttribute("id", parentElementId);
|
|
246
|
+
const observer = new MutationObserver(() => {
|
|
247
|
+
if (!document.contains(trackedParentElement)) {
|
|
248
|
+
const elementById = document.getElementById(parentElementId);
|
|
249
|
+
if (!elementById) {
|
|
250
|
+
this.remove();
|
|
251
|
+
observer.disconnect();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
observer.observe(document.body, {
|
|
256
|
+
childList: true,
|
|
257
|
+
subtree: true
|
|
258
|
+
});
|
|
259
|
+
this.nextPObserver = observer;
|
|
260
|
+
}
|
|
261
|
+
handleNodeDblClick(node, e) {
|
|
262
|
+
if (node && node.uid && e) {
|
|
263
|
+
this.currentNode = node;
|
|
264
|
+
this.createEditInput(node, e);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// 创建编辑输入框
|
|
268
|
+
createEditInput(node, e) {
|
|
269
|
+
const input = document.createElement("textarea");
|
|
270
|
+
input.className = "ql-mind-map-edit-input";
|
|
271
|
+
input.value = node.nodeData.data.text || "";
|
|
272
|
+
const autoResize = () => {
|
|
273
|
+
input.style.height = "auto";
|
|
274
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
275
|
+
};
|
|
276
|
+
Object.assign(input.style, {
|
|
277
|
+
position: "absolute",
|
|
278
|
+
boxSizing: "border-box",
|
|
279
|
+
width: "100px",
|
|
280
|
+
height: "35px",
|
|
281
|
+
padding: "5px",
|
|
282
|
+
lineHeight: "1.2",
|
|
283
|
+
fontFamily: "微软雅黑",
|
|
284
|
+
fontSize: "16px",
|
|
285
|
+
whiteSpace: "pre",
|
|
286
|
+
textAlign: "center",
|
|
287
|
+
background: "#fff",
|
|
288
|
+
border: "1px solid #edefed",
|
|
289
|
+
borderRadius: "3px",
|
|
290
|
+
outline: "none",
|
|
291
|
+
transform: "translate(-50%, -50%)",
|
|
292
|
+
resize: "none",
|
|
293
|
+
zIndex: "1000",
|
|
294
|
+
left: `${e.pageX ? e.pageX : 100}px`,
|
|
295
|
+
top: `${e.pageY ? e.pageY : 100}px`,
|
|
296
|
+
overflow: "hidden"
|
|
297
|
+
});
|
|
298
|
+
document.body.appendChild(input);
|
|
299
|
+
autoResize();
|
|
300
|
+
input.addEventListener("keydown", (event) => {
|
|
301
|
+
if (event.key === "Enter" && event.shiftKey) {
|
|
302
|
+
autoResize();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
input.focus();
|
|
306
|
+
const currentNode = node;
|
|
307
|
+
const handleDrawClick = () => {
|
|
308
|
+
this.updateNodeText(input.value, currentNode);
|
|
309
|
+
input.remove();
|
|
310
|
+
this.mindMap.off("draw_click", handleDrawClick);
|
|
311
|
+
};
|
|
312
|
+
this.mindMap.on("draw_click", handleDrawClick);
|
|
313
|
+
input.addEventListener("keydown", (event) => {
|
|
314
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
315
|
+
event.preventDefault();
|
|
316
|
+
this.updateNodeText(input.value, currentNode);
|
|
317
|
+
input.remove();
|
|
318
|
+
this.mindMap.off("draw_click", handleDrawClick);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
updateNodeText(text, node) {
|
|
323
|
+
if (node && this.mindMap) {
|
|
324
|
+
node.setText(text);
|
|
325
|
+
const editWraps = document.querySelectorAll(".smm-node-edit-wrap");
|
|
326
|
+
editWraps.forEach((editWrap) => {
|
|
327
|
+
const input = editWrap.querySelector("input, textarea");
|
|
328
|
+
if (input) {
|
|
329
|
+
input.value = text;
|
|
330
|
+
} else {
|
|
331
|
+
editWrap.textContent = text;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
this.data = this.mindMap.getData({});
|
|
335
|
+
this.domNode.setAttribute("data-mind-map", JSON.stringify(this.data));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
format(name, value) {
|
|
339
|
+
}
|
|
340
|
+
remove() {
|
|
341
|
+
this.mindMap.destroy();
|
|
342
|
+
if (this.nextPObserver) {
|
|
343
|
+
this.nextPObserver.disconnect();
|
|
344
|
+
this.nextPObserver = null;
|
|
345
|
+
}
|
|
346
|
+
super.remove();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
__publicField(_MindMapPlaceholderBlot, "blotName", "mind-map");
|
|
350
|
+
__publicField(_MindMapPlaceholderBlot, "tagName", "div");
|
|
351
|
+
__publicField(_MindMapPlaceholderBlot, "className", "ql-mind-map-item");
|
|
352
|
+
let MindMapPlaceholderBlot = _MindMapPlaceholderBlot;
|
|
353
|
+
export {
|
|
354
|
+
MindMapPlaceholderBlot as default
|
|
355
|
+
};
|
|
356
|
+
//# sourceMappingURL=mind-map-blot.es.js.map
|