@opentiny/fluent-editor 4.0.0-beta.1 → 4.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.
Files changed (158) hide show
  1. package/es/config/i18n/en-us.es.js +0 -2
  2. package/es/config/i18n/en-us.es.js.map +1 -1
  3. package/es/config/i18n/zh-cn.es.js +0 -2
  4. package/es/config/i18n/zh-cn.es.js.map +1 -1
  5. package/es/fluent-editor.es.js +0 -6
  6. package/es/fluent-editor.es.js.map +1 -1
  7. package/es/index.es.js +0 -4
  8. package/es/index.es.js.map +1 -1
  9. package/es/modules/index.es.js +0 -4
  10. package/es/modules/index.es.js.map +1 -1
  11. package/es/modules/shortcut-key/index.es.js +0 -16
  12. package/es/modules/shortcut-key/index.es.js.map +1 -1
  13. package/es/ui/icons.config.es.js +0 -4
  14. package/es/ui/icons.config.es.js.map +1 -1
  15. package/es/ui/icons.es.js +2 -4
  16. package/es/ui/icons.es.js.map +1 -1
  17. package/lib/config/i18n/en-us.cjs.js +0 -2
  18. package/lib/config/i18n/en-us.cjs.js.map +1 -1
  19. package/lib/config/i18n/zh-cn.cjs.js +0 -2
  20. package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
  21. package/lib/fluent-editor.cjs.js +2 -8
  22. package/lib/fluent-editor.cjs.js.map +1 -1
  23. package/lib/index.cjs.js +5 -9
  24. package/lib/index.cjs.js.map +1 -1
  25. package/lib/modules/index.cjs.js +5 -9
  26. package/lib/modules/index.cjs.js.map +1 -1
  27. package/lib/modules/shortcut-key/index.cjs.js +0 -16
  28. package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
  29. package/lib/ui/icons.cjs.js +1 -3
  30. package/lib/ui/icons.cjs.js.map +1 -1
  31. package/lib/ui/icons.config.cjs.js +0 -4
  32. package/lib/ui/icons.config.cjs.js.map +1 -1
  33. package/package.json +1 -3
  34. package/types/config/i18n/en-us.d.ts +0 -2
  35. package/types/config/i18n/zh-cn.d.ts +0 -2
  36. package/types/config/types/editor-modules.interface.d.ts +0 -4
  37. package/types/modules/index.d.ts +0 -2
  38. package/types/ui/icons.config.d.ts +0 -2
  39. package/es/modules/ai/constants.es.js +0 -50
  40. package/es/modules/ai/constants.es.js.map +0 -1
  41. package/es/modules/ai/icons.es.js +0 -319
  42. package/es/modules/ai/icons.es.js.map +0 -1
  43. package/es/modules/ai/index.es.js +0 -670
  44. package/es/modules/ai/index.es.js.map +0 -1
  45. package/es/modules/flow-chart/config-utils.es.js +0 -102
  46. package/es/modules/flow-chart/config-utils.es.js.map +0 -1
  47. package/es/modules/flow-chart/formats/flow-chart-blot.es.js +0 -369
  48. package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +0 -1
  49. package/es/modules/flow-chart/i18n/en-us.es.js +0 -30
  50. package/es/modules/flow-chart/i18n/en-us.es.js.map +0 -1
  51. package/es/modules/flow-chart/i18n/index.es.js +0 -12
  52. package/es/modules/flow-chart/i18n/index.es.js.map +0 -1
  53. package/es/modules/flow-chart/i18n/zh-cn.es.js +0 -30
  54. package/es/modules/flow-chart/i18n/zh-cn.es.js.map +0 -1
  55. package/es/modules/flow-chart/icons.es.js +0 -27
  56. package/es/modules/flow-chart/icons.es.js.map +0 -1
  57. package/es/modules/flow-chart/index.es.js +0 -45
  58. package/es/modules/flow-chart/index.es.js.map +0 -1
  59. package/es/modules/flow-chart/modules/context-menu.es.js +0 -184
  60. package/es/modules/flow-chart/modules/context-menu.es.js.map +0 -1
  61. package/es/modules/flow-chart/modules/control-panel.es.js +0 -286
  62. package/es/modules/flow-chart/modules/control-panel.es.js.map +0 -1
  63. package/es/modules/flow-chart/modules/custom-resize-action.es.js +0 -150
  64. package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +0 -1
  65. package/es/modules/mind-map/config-utils.es.js +0 -108
  66. package/es/modules/mind-map/config-utils.es.js.map +0 -1
  67. package/es/modules/mind-map/formats/mind-map-blot.es.js +0 -356
  68. package/es/modules/mind-map/formats/mind-map-blot.es.js.map +0 -1
  69. package/es/modules/mind-map/i18n/en-us.es.js +0 -29
  70. package/es/modules/mind-map/i18n/en-us.es.js.map +0 -1
  71. package/es/modules/mind-map/i18n/index.es.js +0 -12
  72. package/es/modules/mind-map/i18n/index.es.js.map +0 -1
  73. package/es/modules/mind-map/i18n/zh-cn.es.js +0 -29
  74. package/es/modules/mind-map/i18n/zh-cn.es.js.map +0 -1
  75. package/es/modules/mind-map/icons.es.js +0 -45
  76. package/es/modules/mind-map/icons.es.js.map +0 -1
  77. package/es/modules/mind-map/index.es.js +0 -56
  78. package/es/modules/mind-map/index.es.js.map +0 -1
  79. package/es/modules/mind-map/modules/context-menu.es.js +0 -128
  80. package/es/modules/mind-map/modules/context-menu.es.js.map +0 -1
  81. package/es/modules/mind-map/modules/control-panel.es.js +0 -425
  82. package/es/modules/mind-map/modules/control-panel.es.js.map +0 -1
  83. package/es/modules/mind-map/modules/custom-resize-action.es.js +0 -161
  84. package/es/modules/mind-map/modules/custom-resize-action.es.js.map +0 -1
  85. package/flow-chart.css +0 -185
  86. package/lib/modules/ai/constants.cjs.js +0 -50
  87. package/lib/modules/ai/constants.cjs.js.map +0 -1
  88. package/lib/modules/ai/icons.cjs.js +0 -319
  89. package/lib/modules/ai/icons.cjs.js.map +0 -1
  90. package/lib/modules/ai/index.cjs.js +0 -670
  91. package/lib/modules/ai/index.cjs.js.map +0 -1
  92. package/lib/modules/flow-chart/config-utils.cjs.js +0 -102
  93. package/lib/modules/flow-chart/config-utils.cjs.js.map +0 -1
  94. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +0 -369
  95. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +0 -1
  96. package/lib/modules/flow-chart/i18n/en-us.cjs.js +0 -30
  97. package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +0 -1
  98. package/lib/modules/flow-chart/i18n/index.cjs.js +0 -12
  99. package/lib/modules/flow-chart/i18n/index.cjs.js.map +0 -1
  100. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +0 -30
  101. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +0 -1
  102. package/lib/modules/flow-chart/icons.cjs.js +0 -27
  103. package/lib/modules/flow-chart/icons.cjs.js.map +0 -1
  104. package/lib/modules/flow-chart/index.cjs.js +0 -45
  105. package/lib/modules/flow-chart/index.cjs.js.map +0 -1
  106. package/lib/modules/flow-chart/modules/context-menu.cjs.js +0 -184
  107. package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +0 -1
  108. package/lib/modules/flow-chart/modules/control-panel.cjs.js +0 -286
  109. package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +0 -1
  110. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +0 -150
  111. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +0 -1
  112. package/lib/modules/mind-map/config-utils.cjs.js +0 -108
  113. package/lib/modules/mind-map/config-utils.cjs.js.map +0 -1
  114. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +0 -356
  115. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +0 -1
  116. package/lib/modules/mind-map/i18n/en-us.cjs.js +0 -29
  117. package/lib/modules/mind-map/i18n/en-us.cjs.js.map +0 -1
  118. package/lib/modules/mind-map/i18n/index.cjs.js +0 -12
  119. package/lib/modules/mind-map/i18n/index.cjs.js.map +0 -1
  120. package/lib/modules/mind-map/i18n/zh-cn.cjs.js +0 -29
  121. package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +0 -1
  122. package/lib/modules/mind-map/icons.cjs.js +0 -45
  123. package/lib/modules/mind-map/icons.cjs.js.map +0 -1
  124. package/lib/modules/mind-map/index.cjs.js +0 -56
  125. package/lib/modules/mind-map/index.cjs.js.map +0 -1
  126. package/lib/modules/mind-map/modules/context-menu.cjs.js +0 -128
  127. package/lib/modules/mind-map/modules/context-menu.cjs.js.map +0 -1
  128. package/lib/modules/mind-map/modules/control-panel.cjs.js +0 -425
  129. package/lib/modules/mind-map/modules/control-panel.cjs.js.map +0 -1
  130. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +0 -161
  131. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +0 -1
  132. package/mind-map.css +0 -224
  133. package/types/modules/ai/constants.d.ts +0 -30
  134. package/types/modules/ai/icons.d.ts +0 -21
  135. package/types/modules/ai/index.d.ts +0 -96
  136. package/types/modules/ai/types.d.ts +0 -16
  137. package/types/modules/flow-chart/config-utils.d.ts +0 -10
  138. package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +0 -43
  139. package/types/modules/flow-chart/i18n/en-us.d.ts +0 -26
  140. package/types/modules/flow-chart/i18n/index.d.ts +0 -1
  141. package/types/modules/flow-chart/i18n/zh-cn.d.ts +0 -26
  142. package/types/modules/flow-chart/icons.d.ts +0 -12
  143. package/types/modules/flow-chart/index.d.ts +0 -10
  144. package/types/modules/flow-chart/modules/context-menu.d.ts +0 -3
  145. package/types/modules/flow-chart/modules/control-panel.d.ts +0 -3
  146. package/types/modules/flow-chart/modules/custom-resize-action.d.ts +0 -22
  147. package/types/modules/flow-chart/options.d.ts +0 -29
  148. package/types/modules/mind-map/config-utils.d.ts +0 -12
  149. package/types/modules/mind-map/formats/mind-map-blot.d.ts +0 -44
  150. package/types/modules/mind-map/i18n/en-us.d.ts +0 -25
  151. package/types/modules/mind-map/i18n/index.d.ts +0 -1
  152. package/types/modules/mind-map/i18n/zh-cn.d.ts +0 -25
  153. package/types/modules/mind-map/icons.d.ts +0 -21
  154. package/types/modules/mind-map/index.d.ts +0 -10
  155. package/types/modules/mind-map/modules/context-menu.d.ts +0 -3
  156. package/types/modules/mind-map/modules/control-panel.d.ts +0 -3
  157. package/types/modules/mind-map/modules/custom-resize-action.d.ts +0 -23
  158. package/types/modules/mind-map/options.d.ts +0 -27
@@ -1,286 +0,0 @@
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 "../../../config/index.es.js";
5
- import { I18N } from "../../i18n.es.js";
6
- import { registerFlowChartI18N } from "../i18n/index.es.js";
7
- import { lineIcon, contractIcon, screenTypeIcon, fitIcon, zoomInIcon, zoomOutIcon, forwardIcon, backIcon, polyLineIcon, bezierIcon, screenReduceIcon } from "../icons.es.js";
8
- import { CHANGE_LANGUAGE_EVENT } from "../../../config/editor.config.es.js";
9
- class FlowChartControlPanelHandler {
10
- constructor(quill, blot) {
11
- __publicField(this, "texts");
12
- __publicField(this, "lang");
13
- this.quill = quill;
14
- this.blot = blot;
15
- const i18nModule = this.quill.getModule("i18n");
16
- registerFlowChartI18N(I18N);
17
- this.lang = i18nModule.options.lang;
18
- this.texts = this.resolveTexts();
19
- this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang) => {
20
- this.lang = lang;
21
- this.texts = this.resolveTexts();
22
- this.updateControlPanelTexts();
23
- });
24
- }
25
- getText(key) {
26
- return this.texts[key];
27
- }
28
- resolveTexts() {
29
- return {
30
- exportTitle: I18N.parserText("flowChart.controlPanel.exportTitle", this.lang),
31
- zoomOutTitle: I18N.parserText("flowChart.controlPanel.zoomOutTitle", this.lang),
32
- zoomInTitle: I18N.parserText("flowChart.controlPanel.zoomInTitle", this.lang),
33
- fitTitle: I18N.parserText("flowChart.controlPanel.fitTitle", this.lang),
34
- backTitle: I18N.parserText("flowChart.controlPanel.backTitle", this.lang),
35
- forwardTitle: I18N.parserText("flowChart.controlPanel.forwardTitle", this.lang),
36
- setEdgeTypeTitle: I18N.parserText("flowChart.controlPanel.setEdgeTypeTitle", this.lang),
37
- panelStatusTitle: I18N.parserText("flowChart.controlPanel.panelStatusTitle", this.lang),
38
- screenTypeTitle: I18N.parserText("flowChart.controlPanel.screenTypeTitle", this.lang)
39
- };
40
- }
41
- updateControlPanelTexts() {
42
- const controlItems = this.blot.domNode.querySelectorAll(".ql-flow-chart-control-item");
43
- const controlItemMap = {
44
- "zoom-out": "zoomOutTitle",
45
- "zoom-in": "zoomInTitle",
46
- "fit": "fitTitle",
47
- "back": "backTitle",
48
- "forward": "forwardTitle",
49
- "set-edge-type": "setEdgeTypeTitle",
50
- "panel-status": "panelStatusTitle",
51
- "screen-type": "screenTypeTitle"
52
- };
53
- controlItems.forEach((item) => {
54
- const controlType = item.dataset.controlType;
55
- if (controlType && controlItemMap[controlType] && this.texts[controlItemMap[controlType]]) {
56
- item.title = this.texts[controlItemMap[controlType]];
57
- }
58
- });
59
- }
60
- }
61
- const controlPanelHandlers = /* @__PURE__ */ new WeakMap();
62
- const DISABLED_OPACITY = "0.5";
63
- const ENABLED_OPACITY = "1";
64
- function createControlPanel(blot, quill) {
65
- const controlPanel = document.createElement("div");
66
- controlPanel.className = "ql-flow-chart-control";
67
- const controlRightUpPanel = document.createElement("div");
68
- controlRightUpPanel.className = "ql-flow-chart-right-up-control";
69
- const handler = new FlowChartControlPanelHandler(quill, blot);
70
- controlPanelHandlers.set(blot, handler);
71
- const zoomOutBtn = createControlItem("zoom-out", handler.getText("zoomOutTitle"), () => handleZoomOut(blot));
72
- const zoomInBtn = createControlItem("zoom-in", handler.getText("zoomInTitle"), () => handleZoomIn(blot));
73
- const resetBtn = createControlItem("fit", handler.getText("fitTitle"), () => handleResetZoom(blot));
74
- const backBtn = createControlItem("back", handler.getText("backTitle"), () => handleUndo(blot));
75
- const forwardBtn = createControlItem("forward", handler.getText("forwardTitle"), () => handleRedo(blot));
76
- const setEdgeTypeBtn = createControlItem("set-edge-type", handler.getText("setEdgeTypeTitle"), () => handleSetEdgeType(blot));
77
- const panelStatusBtn = createControlItem("panel-status", handler.getText("panelStatusTitle"));
78
- const screenTypeBtn = createControlItem("screen-type", handler.getText("screenTypeTitle"), () => handleScreenTypeBtn(blot));
79
- const updateButtonState = (historyData) => {
80
- if (!historyData.data) {
81
- backBtn.style.opacity = DISABLED_OPACITY;
82
- backBtn.style.cursor = "not-allowed";
83
- forwardBtn.style.opacity = DISABLED_OPACITY;
84
- forwardBtn.style.cursor = "not-allowed";
85
- return;
86
- }
87
- const isUndoAvailable = historyData.data.undoAble || historyData.data.undos.length < 0;
88
- const isRedoAvailable = historyData.data.redoAble || historyData.data.redos.length > 0;
89
- if (backBtn) {
90
- backBtn.style.opacity = isUndoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY;
91
- backBtn.style.cursor = isUndoAvailable ? "pointer" : "not-allowed";
92
- }
93
- if (forwardBtn) {
94
- forwardBtn.style.opacity = isRedoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY;
95
- forwardBtn.style.cursor = isRedoAvailable ? "pointer" : "not-allowed";
96
- }
97
- };
98
- updateButtonState(blot.flowChart.history);
99
- blot.flowChart.on("history:change", (data) => {
100
- updateButtonState(data);
101
- });
102
- setTimeout(() => {
103
- const controlLeftUpPanel = blot.domNode.querySelector(".lf-dndpanel");
104
- controlLeftUpPanel.append(setEdgeTypeBtn);
105
- }, 0);
106
- controlRightUpPanel.append(panelStatusBtn);
107
- blot.domNode.appendChild(controlRightUpPanel);
108
- controlPanel.append(zoomOutBtn, zoomInBtn, resetBtn, screenTypeBtn, backBtn, forwardBtn);
109
- blot.domNode.appendChild(controlPanel);
110
- }
111
- function handleUndo(blot) {
112
- if (blot.flowChart) {
113
- blot.flowChart.undo();
114
- }
115
- }
116
- function handleRedo(blot) {
117
- if (blot.flowChart) {
118
- blot.flowChart.redo();
119
- }
120
- }
121
- function handleZoomIn(blot) {
122
- if (blot.flowChart) {
123
- blot.flowChart.zoom(true);
124
- }
125
- }
126
- function handleZoomOut(blot) {
127
- if (blot.flowChart) {
128
- blot.flowChart.zoom(false);
129
- }
130
- }
131
- function handleResetZoom(blot) {
132
- if (blot.flowChart) {
133
- blot.flowChart.resetZoom();
134
- }
135
- }
136
- function createControlItem(iconClass, title, onClick, disabled = false) {
137
- const controlItem = document.createElement("div");
138
- controlItem.className = "ql-flow-chart-control-item";
139
- controlItem.title = title;
140
- controlItem.dataset.controlType = iconClass;
141
- controlItem.style.cursor = disabled ? "not-allowed" : "pointer";
142
- const iconMap = {
143
- "back": backIcon,
144
- "forward": forwardIcon,
145
- "zoom-out": zoomOutIcon,
146
- "zoom-in": zoomInIcon,
147
- "fit": fitIcon,
148
- "screen-type": screenTypeIcon,
149
- "panel-status": contractIcon,
150
- "set-edge-type": lineIcon
151
- };
152
- const icon = document.createElement("i");
153
- icon.innerHTML = iconMap[iconClass] || "";
154
- controlItem.appendChild(icon);
155
- if (!disabled) {
156
- controlItem.addEventListener("click", onClick);
157
- }
158
- return controlItem;
159
- }
160
- function handleSetEdgeType(blot) {
161
- const controlLeftUpPanel = blot.domNode.querySelector(".lf-dndpanel");
162
- if (!controlLeftUpPanel) return;
163
- let edgeTypePanel = controlLeftUpPanel.querySelector(".ql-flow-chart-edge-panel");
164
- if (!edgeTypePanel) {
165
- edgeTypePanel = document.createElement("div");
166
- edgeTypePanel.className = "ql-flow-chart-edge-panel";
167
- edgeTypePanel.style.display = "flex";
168
- edgeTypePanel.style.justifyContent = "space-around";
169
- edgeTypePanel.style.flexWrap = "nowrap";
170
- edgeTypePanel.style.width = "auto";
171
- edgeTypePanel.style.minWidth = "100%";
172
- edgeTypePanel.style.padding = "8px";
173
- edgeTypePanel.style.boxSizing = "border-box";
174
- edgeTypePanel.style.position = "absolute";
175
- edgeTypePanel.style.top = "170px";
176
- controlLeftUpPanel.appendChild(edgeTypePanel);
177
- const edgeTypes = [
178
- {
179
- name: "line",
180
- displayName: "直线",
181
- icon: lineIcon
182
- },
183
- {
184
- name: "polyline",
185
- displayName: "折线",
186
- icon: polyLineIcon
187
- },
188
- {
189
- name: "bezier",
190
- displayName: "贝塞尔曲线",
191
- icon: bezierIcon
192
- }
193
- ];
194
- edgeTypes.forEach((edgeType) => {
195
- const edgeItem = document.createElement("div");
196
- edgeItem.className = "ql-flow-chart-edge-item";
197
- edgeItem.style.padding = "8px";
198
- edgeItem.style.cursor = "pointer";
199
- edgeItem.style.textAlign = "center";
200
- const edgeIcon = document.createElement("div");
201
- edgeIcon.className = `ql-flow-chart-edge-type-icon`;
202
- edgeIcon.style.width = "24px";
203
- edgeIcon.style.height = "24px";
204
- edgeIcon.style.margin = "0 auto";
205
- if (edgeType.icon) {
206
- edgeIcon.innerHTML = edgeType.icon;
207
- }
208
- edgeItem.appendChild(edgeIcon);
209
- edgeItem.addEventListener("click", () => {
210
- const { edges = [] } = blot.flowChart.getSelectElements();
211
- if (edges.length > 0) {
212
- edges.forEach((edge) => {
213
- blot.flowChart.changeEdgeType(edge.id, edgeType.name);
214
- });
215
- blot.data = blot.flowChart.getGraphData();
216
- blot.domNode.setAttribute("data-flow-chart", JSON.stringify(blot.data));
217
- }
218
- edgeTypePanel.style.display = "none";
219
- });
220
- edgeTypePanel.appendChild(edgeItem);
221
- });
222
- } else {
223
- edgeTypePanel.style.display = "flex";
224
- edgeTypePanel.style.justifyContent = "space-around";
225
- edgeTypePanel.style.flexWrap = "nowrap";
226
- }
227
- const handleOutsideClick = (e) => {
228
- let setEdgeTypeBtn = null;
229
- const controlItems = controlLeftUpPanel.querySelectorAll(".ql-flow-chart-control-item");
230
- controlItems.forEach((item) => {
231
- const iconEl = item.querySelector("i");
232
- if (iconEl && iconEl.className.includes("set-edge-type")) {
233
- setEdgeTypeBtn = item;
234
- }
235
- });
236
- if (!edgeTypePanel.contains(e.target) && (!setEdgeTypeBtn || !setEdgeTypeBtn.contains(e.target))) {
237
- edgeTypePanel.style.display = "none";
238
- document.removeEventListener("click", handleOutsideClick);
239
- }
240
- };
241
- document.removeEventListener("click", handleOutsideClick);
242
- setTimeout(() => {
243
- document.addEventListener("click", handleOutsideClick);
244
- }, 0);
245
- }
246
- function handleScreenTypeBtn(blot) {
247
- const screenTypeBtn = blot.domNode.querySelector('[data-control-type="screen-type"]');
248
- if (!screenTypeBtn || !blot.domNode) return;
249
- const flowChartContainer = blot.domNode;
250
- const isFullscreen = flowChartContainer.style.position === "fixed";
251
- if (isFullscreen) {
252
- const originalPosition = flowChartContainer.getAttribute("data-original-position");
253
- const originalWidth = flowChartContainer.getAttribute("data-original-width");
254
- const originalHeight = flowChartContainer.getAttribute("data-original-height");
255
- if (originalWidth && originalHeight) {
256
- flowChartContainer.style.position = originalPosition;
257
- flowChartContainer.style.width = originalWidth;
258
- flowChartContainer.style.height = originalHeight;
259
- flowChartContainer.style.zIndex = "0";
260
- }
261
- const iconElement = screenTypeBtn.querySelector("i");
262
- if (iconElement) {
263
- iconElement.innerHTML = screenTypeIcon;
264
- }
265
- } else {
266
- flowChartContainer.setAttribute("data-original-position", flowChartContainer.style.position || "");
267
- flowChartContainer.setAttribute("data-original-width", flowChartContainer.style.width || "");
268
- flowChartContainer.setAttribute("data-original-height", flowChartContainer.style.height || "");
269
- flowChartContainer.style.position = "fixed";
270
- flowChartContainer.style.top = "0";
271
- flowChartContainer.style.left = "0";
272
- flowChartContainer.style.width = "100vw";
273
- flowChartContainer.style.height = "100vh";
274
- flowChartContainer.style.zIndex = "100";
275
- const iconElement = screenTypeBtn.querySelector("i");
276
- if (iconElement) {
277
- iconElement.innerHTML = screenReduceIcon;
278
- }
279
- }
280
- blot.flowChart.resize();
281
- blot.flowChart.translateCenter();
282
- }
283
- export {
284
- createControlPanel
285
- };
286
- //# sourceMappingURL=control-panel.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"control-panel.es.js","sources":["../../../../../src/modules/flow-chart/modules/control-panel.ts"],"sourcesContent":["import type FluentEditor from '../../../core/fluent-editor'\nimport type FlowChartPlaceholderBlot from '../formats/flow-chart-blot'\nimport { CHANGE_LANGUAGE_EVENT } from '../../../config'\nimport { I18N } from '../../../modules/i18n'\nimport { registerFlowChartI18N } from '../i18n'\nimport { backIcon, bezierIcon, contractIcon, fitIcon, forwardIcon, lineIcon, polyLineIcon, screenReduceIcon, screenTypeIcon, zoomInIcon, zoomOutIcon } from '../icons'\n\nclass FlowChartControlPanelHandler {\n private texts: Record<string, string>\n private lang: string\n getText(key: keyof Record<string, string>): string {\n return this.texts[key]\n }\n\n constructor(private quill: FluentEditor, private blot: FlowChartPlaceholderBlot) {\n const i18nModule = this.quill.getModule('i18n') as I18N\n registerFlowChartI18N(I18N)\n this.lang = i18nModule.options.lang\n this.texts = this.resolveTexts()\n this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang: string) => {\n this.lang = lang\n this.texts = this.resolveTexts()\n this.updateControlPanelTexts()\n })\n }\n\n resolveTexts() {\n return {\n exportTitle: I18N.parserText('flowChart.controlPanel.exportTitle', this.lang),\n zoomOutTitle: I18N.parserText('flowChart.controlPanel.zoomOutTitle', this.lang),\n zoomInTitle: I18N.parserText('flowChart.controlPanel.zoomInTitle', this.lang),\n fitTitle: I18N.parserText('flowChart.controlPanel.fitTitle', this.lang),\n backTitle: I18N.parserText('flowChart.controlPanel.backTitle', this.lang),\n forwardTitle: I18N.parserText('flowChart.controlPanel.forwardTitle', this.lang),\n setEdgeTypeTitle: I18N.parserText('flowChart.controlPanel.setEdgeTypeTitle', this.lang),\n panelStatusTitle: I18N.parserText('flowChart.controlPanel.panelStatusTitle', this.lang),\n screenTypeTitle: I18N.parserText('flowChart.controlPanel.screenTypeTitle', this.lang),\n }\n }\n\n updateControlPanelTexts() {\n const controlItems = this.blot.domNode.querySelectorAll('.ql-flow-chart-control-item')\n\n const controlItemMap: Record<string, string> = {\n 'zoom-out': 'zoomOutTitle',\n 'zoom-in': 'zoomInTitle',\n 'fit': 'fitTitle',\n 'back': 'backTitle',\n 'forward': 'forwardTitle',\n 'set-edge-type': 'setEdgeTypeTitle',\n 'panel-status': 'panelStatusTitle',\n 'screen-type': 'screenTypeTitle',\n }\n\n controlItems.forEach((item) => {\n const controlType = (item as HTMLElement).dataset.controlType\n if (controlType && controlItemMap[controlType] && this.texts[controlItemMap[controlType]]) {\n (item as HTMLElement).title = this.texts[controlItemMap[controlType]]\n }\n })\n }\n}\n\nconst controlPanelHandlers = new WeakMap<FlowChartPlaceholderBlot, FlowChartControlPanelHandler>()\n\nconst DISABLED_OPACITY = '0.5'\nconst ENABLED_OPACITY = '1'\nexport function createControlPanel(blot: FlowChartPlaceholderBlot, quill: FluentEditor): void {\n // 中间的控制面板\n const controlPanel = document.createElement('div')\n controlPanel.className = 'ql-flow-chart-control'\n // 右上的控制面板\n const controlRightUpPanel = document.createElement('div')\n controlRightUpPanel.className = 'ql-flow-chart-right-up-control'\n\n const handler = new FlowChartControlPanelHandler(quill, blot)\n controlPanelHandlers.set(blot, handler)\n const zoomOutBtn = createControlItem('zoom-out', handler.getText('zoomOutTitle'), () => handleZoomOut(blot))\n const zoomInBtn = createControlItem('zoom-in', handler.getText('zoomInTitle'), () => handleZoomIn(blot))\n const resetBtn = createControlItem('fit', handler.getText('fitTitle'), () => handleResetZoom(blot))\n const backBtn = createControlItem('back', handler.getText('backTitle'), () => handleUndo(blot))\n const forwardBtn = createControlItem('forward', handler.getText('forwardTitle'), () => handleRedo(blot))\n const setEdgeTypeBtn = createControlItem('set-edge-type', handler.getText('setEdgeTypeTitle'), () => handleSetEdgeType(blot))\n const panelStatusBtn = createControlItem('panel-status', handler.getText('panelStatusTitle'))\n const screenTypeBtn = createControlItem('screen-type', handler.getText('screenTypeTitle'), () => handleScreenTypeBtn(blot))\n\n const updateButtonState = (historyData: any) => {\n if (!historyData.data) {\n backBtn.style.opacity = DISABLED_OPACITY\n backBtn.style.cursor = 'not-allowed'\n forwardBtn.style.opacity = DISABLED_OPACITY\n forwardBtn.style.cursor = 'not-allowed'\n return\n }\n const isUndoAvailable = historyData.data.undoAble || historyData.data.undos.length < 0\n const isRedoAvailable = historyData.data.redoAble || historyData.data.redos.length > 0\n\n if (backBtn) {\n backBtn.style.opacity = isUndoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY\n backBtn.style.cursor = isUndoAvailable ? 'pointer' : 'not-allowed'\n }\n\n if (forwardBtn) {\n forwardBtn.style.opacity = isRedoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY\n forwardBtn.style.cursor = isRedoAvailable ? 'pointer' : 'not-allowed'\n }\n }\n updateButtonState(blot.flowChart.history)\n blot.flowChart.on('history:change', (data: any) => {\n updateButtonState(data)\n })\n\n setTimeout(() => {\n const controlLeftUpPanel = blot.domNode.querySelector('.lf-dndpanel') as HTMLElement | null\n controlLeftUpPanel.append(setEdgeTypeBtn)\n }, 0)\n controlRightUpPanel.append(panelStatusBtn)\n blot.domNode.appendChild(controlRightUpPanel)\n controlPanel.append(zoomOutBtn, zoomInBtn, resetBtn, screenTypeBtn, backBtn, forwardBtn)\n blot.domNode.appendChild(controlPanel)\n}\n\nfunction handleUndo(blot: FlowChartPlaceholderBlot): void {\n if (blot.flowChart) {\n blot.flowChart.undo()\n }\n}\n\nfunction handleRedo(blot: FlowChartPlaceholderBlot): void {\n if (blot.flowChart) {\n blot.flowChart.redo()\n }\n}\n\nfunction handleZoomIn(blot: FlowChartPlaceholderBlot): void {\n if (blot.flowChart) {\n blot.flowChart.zoom(true)\n }\n}\n\nfunction handleZoomOut(blot: FlowChartPlaceholderBlot): void {\n if (blot.flowChart) {\n blot.flowChart.zoom(false)\n }\n}\n\nfunction handleResetZoom(blot: FlowChartPlaceholderBlot): void {\n if (blot.flowChart) {\n blot.flowChart.resetZoom()\n }\n}\n\nfunction createControlItem(iconClass: string, title: string, onClick?: () => void, disabled = false) {\n const controlItem = document.createElement('div')\n controlItem.className = 'ql-flow-chart-control-item'\n controlItem.title = title\n controlItem.dataset.controlType = iconClass\n controlItem.style.cursor = disabled ? 'not-allowed' : 'pointer'\n\n const iconMap: Record<string, string> = {\n 'back': backIcon,\n 'forward': forwardIcon,\n 'zoom-out': zoomOutIcon,\n 'zoom-in': zoomInIcon,\n 'fit': fitIcon,\n 'screen-type': screenTypeIcon,\n 'panel-status': contractIcon,\n 'set-edge-type': lineIcon,\n }\n\n const icon = document.createElement('i')\n icon.innerHTML = iconMap[iconClass] || ''\n controlItem.appendChild(icon)\n\n if (!disabled) {\n controlItem.addEventListener('click', onClick)\n }\n\n return controlItem\n}\n\nfunction handleSetEdgeType(blot: FlowChartPlaceholderBlot): void {\n const controlLeftUpPanel = blot.domNode.querySelector('.lf-dndpanel') as HTMLElement | null\n if (!controlLeftUpPanel) return\n let edgeTypePanel = controlLeftUpPanel.querySelector('.ql-flow-chart-edge-panel') as HTMLElement\n if (!edgeTypePanel) {\n edgeTypePanel = document.createElement('div')\n edgeTypePanel.className = 'ql-flow-chart-edge-panel'\n edgeTypePanel.style.display = 'flex'\n edgeTypePanel.style.justifyContent = 'space-around'\n edgeTypePanel.style.flexWrap = 'nowrap'\n edgeTypePanel.style.width = 'auto'\n edgeTypePanel.style.minWidth = '100%'\n edgeTypePanel.style.padding = '8px'\n edgeTypePanel.style.boxSizing = 'border-box'\n edgeTypePanel.style.position = 'absolute'\n edgeTypePanel.style.top = '170px'\n controlLeftUpPanel.appendChild(edgeTypePanel)\n\n const edgeTypes = [\n {\n name: 'line',\n displayName: '直线',\n icon: lineIcon,\n },\n {\n name: 'polyline',\n displayName: '折线',\n icon: polyLineIcon,\n },\n {\n name: 'bezier',\n displayName: '贝塞尔曲线',\n icon: bezierIcon,\n },\n ]\n\n edgeTypes.forEach((edgeType) => {\n const edgeItem = document.createElement('div')\n edgeItem.className = 'ql-flow-chart-edge-item'\n edgeItem.style.padding = '8px'\n edgeItem.style.cursor = 'pointer'\n edgeItem.style.textAlign = 'center'\n\n const edgeIcon = document.createElement('div')\n edgeIcon.className = `ql-flow-chart-edge-type-icon`\n edgeIcon.style.width = '24px'\n edgeIcon.style.height = '24px'\n edgeIcon.style.margin = '0 auto'\n if (edgeType.icon) {\n edgeIcon.innerHTML = edgeType.icon\n }\n\n edgeItem.appendChild(edgeIcon)\n\n edgeItem.addEventListener('click', () => {\n const { edges = [] } = blot.flowChart.getSelectElements()\n if (edges.length > 0) {\n edges.forEach((edge) => {\n blot.flowChart.changeEdgeType(edge.id, edgeType.name)\n })\n blot.data = blot.flowChart.getGraphData()\n blot.domNode.setAttribute('data-flow-chart', JSON.stringify(blot.data))\n }\n\n edgeTypePanel.style.display = 'none'\n })\n edgeTypePanel.appendChild(edgeItem)\n })\n }\n else {\n edgeTypePanel.style.display = 'flex'\n edgeTypePanel.style.justifyContent = 'space-around'\n edgeTypePanel.style.flexWrap = 'nowrap'\n }\n\n const handleOutsideClick = (e: MouseEvent) => {\n let setEdgeTypeBtn: HTMLElement | null = null\n const controlItems = controlLeftUpPanel.querySelectorAll('.ql-flow-chart-control-item')\n controlItems.forEach((item) => {\n const iconEl = item.querySelector('i')\n if (iconEl && iconEl.className.includes('set-edge-type')) {\n setEdgeTypeBtn = item as HTMLElement\n }\n })\n if (!edgeTypePanel.contains(e.target as Node)\n && (!setEdgeTypeBtn || !setEdgeTypeBtn.contains(e.target as Node))) {\n edgeTypePanel.style.display = 'none'\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n\n document.removeEventListener('click', handleOutsideClick)\n setTimeout(() => {\n document.addEventListener('click', handleOutsideClick)\n }, 0)\n}\n\nfunction handleScreenTypeBtn(blot: FlowChartPlaceholderBlot): void {\n const screenTypeBtn = blot.domNode.querySelector('[data-control-type=\"screen-type\"]') as HTMLElement | null\n if (!screenTypeBtn || !blot.domNode) return\n\n const flowChartContainer = blot.domNode\n const isFullscreen = flowChartContainer.style.position === 'fixed'\n\n if (isFullscreen) {\n const originalPosition = flowChartContainer.getAttribute('data-original-position')\n const originalWidth = flowChartContainer.getAttribute('data-original-width')\n const originalHeight = flowChartContainer.getAttribute('data-original-height')\n if (originalWidth && originalHeight) {\n flowChartContainer.style.position = originalPosition\n flowChartContainer.style.width = originalWidth\n flowChartContainer.style.height = originalHeight\n flowChartContainer.style.zIndex = '0'\n }\n const iconElement = screenTypeBtn.querySelector('i')\n if (iconElement) {\n iconElement.innerHTML = screenTypeIcon\n }\n }\n else {\n flowChartContainer.setAttribute('data-original-position', flowChartContainer.style.position || '')\n flowChartContainer.setAttribute('data-original-width', flowChartContainer.style.width || '')\n flowChartContainer.setAttribute('data-original-height', flowChartContainer.style.height || '')\n flowChartContainer.style.position = 'fixed'\n flowChartContainer.style.top = '0'\n flowChartContainer.style.left = '0'\n flowChartContainer.style.width = '100vw'\n flowChartContainer.style.height = '100vh'\n flowChartContainer.style.zIndex = '100'\n const iconElement = screenTypeBtn.querySelector('i')\n if (iconElement) {\n iconElement.innerHTML = screenReduceIcon\n }\n }\n blot.flowChart.resize()\n blot.flowChart.translateCenter()\n}\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,6BAA6B;AAAA,EAOjC,YAAoB,OAA6B,MAAgC;AANzE;AACA;AAKY,SAAA,QAAA;AAA6B,SAAA,OAAA;AAC/C,UAAM,aAAa,KAAK,MAAM,UAAU,MAAM;AAC9C,0BAAsB,IAAI;AAC1B,SAAK,OAAO,WAAW,QAAQ;AAC/B,SAAK,QAAQ,KAAK,aAAA;AAClB,SAAK,MAAM,QAAQ,GAAG,uBAAuB,CAAC,SAAiB;AAC7D,WAAK,OAAO;AACZ,WAAK,QAAQ,KAAK,aAAA;AAClB,WAAK,wBAAA;AAAA,IACP,CAAC;AAAA,EACH;AAAA,EAdA,QAAQ,KAA2C;AACjD,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB;AAAA,EAcA,eAAe;AACb,WAAO;AAAA,MACL,aAAa,KAAK,WAAW,sCAAsC,KAAK,IAAI;AAAA,MAC5E,cAAc,KAAK,WAAW,uCAAuC,KAAK,IAAI;AAAA,MAC9E,aAAa,KAAK,WAAW,sCAAsC,KAAK,IAAI;AAAA,MAC5E,UAAU,KAAK,WAAW,mCAAmC,KAAK,IAAI;AAAA,MACtE,WAAW,KAAK,WAAW,oCAAoC,KAAK,IAAI;AAAA,MACxE,cAAc,KAAK,WAAW,uCAAuC,KAAK,IAAI;AAAA,MAC9E,kBAAkB,KAAK,WAAW,2CAA2C,KAAK,IAAI;AAAA,MACtF,kBAAkB,KAAK,WAAW,2CAA2C,KAAK,IAAI;AAAA,MACtF,iBAAiB,KAAK,WAAW,0CAA0C,KAAK,IAAI;AAAA,IAAA;AAAA,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kBAAY,YAAY;AAAA,IAC1B;AAAA,EACF,OACK;AACH,uBAAmB,aAAa,0BAA0B,mBAAmB,MAAM,YAAY,EAAE;AACjG,uBAAmB,aAAa,uBAAuB,mBAAmB,MAAM,SAAS,EAAE;AAC3F,uBAAmB,aAAa,wBAAwB,mBAAmB,MAAM,UAAU,EAAE;AAC7F,uBAAmB,MAAM,WAAW;AACpC,uBAAmB,MAAM,MAAM;AAC/B,uBAAmB,MAAM,OAAO;AAChC,uBAAmB,MAAM,QAAQ;AACjC,uBAAmB,MAAM,SAAS;AAClC,uBAAmB,MAAM,SAAS;AAClC,UAAM,cAAc,cAAc,cAAc,GAAG;AACnD,QAAI,aAAa;AACf,kBAAY,YAAY;AAAA,IAC1B;AAAA,EACF;AACA,OAAK,UAAU,OAAA;AACf,OAAK,UAAU,gBAAA;AACjB;"}
@@ -1,150 +0,0 @@
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
@@ -1 +0,0 @@
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,MAAM,aAAa;AAEZ,MAAM,sBAAsB;AAAA,EAajC,YAAY,MAAW;AAZvB;AACA;AACA;AACA;AACA,sCAAiC;AACjC,sCAAqB;AACrB,sCAAqB;AACrB,wCAAuB;AACvB,yCAAwB;AACxB,uCAAsB;AACtB;AAGE,SAAK,OAAO;AACZ,SAAK,gBAAgB,KAAK,aAAa,YAAY,aAAa;AAChE,SAAK,iBAAiB,KAAK,aAAa,aAAa,aAAa;AAClE,SAAK,oBAAoB,KAAK,aAAa,gBAAgB,aAAa;AACxE,SAAK,mBAAmB,KAAK,aAAa,eAAe,aAAa;AACtE,SAAK,KAAA;AAAA,EACP;AAAA,EAEA,eAAwB;AACtB,UAAM,YAAY,KAAK,KAAK;AAC5B,WAAO,UAAU,MAAM,aAAa,WAAW,UAAU,MAAM,UAAU,WAAW,UAAU,MAAM,WAAW;AAAA,EACjH;AAAA,EAEA,OAAO;AACL,UAAM,YAAY,KAAK,KAAK;AAC5B,cAAU,MAAM,WAAW;AAC3B,cAAU,YAAY,KAAK,aAAa;AACxC,cAAU,YAAY,KAAK,cAAc;AACzC,cAAU,YAAY,KAAK,iBAAiB;AAC5C,cAAU,YAAY,KAAK,gBAAgB;AAC3C,SAAK,kBAAA;AAAA,EACP;AAAA,EAEA,aAAa,UAAkB,QAA6B;AAC1D,UAAM,MAAM,SAAS,cAAc,KAAK;AACxC,QAAI,UAAU,IAAI,6BAA6B;AAC/C,QAA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S,KAAK,MAAM,SAAS;AAC7B,aAAS,oBAAoB,aAAa,KAAK,OAAO,KAAK,IAAI,CAAC;AAChE,aAAS,oBAAoB,WAAW,KAAK,UAAU,KAAK,IAAI,CAAC;AACjE,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,UAAU;AACR,UAAM,YAAY,KAAK,KAAK;AAC5B,cAAU,YAAY,KAAK,aAAa;AACxC,cAAU,YAAY,KAAK,cAAc;AACzC,cAAU,YAAY,KAAK,iBAAiB;AAC5C,cAAU,YAAY,KAAK,gBAAgB;AAAA,EAC7C;AACF;"}
@@ -1,108 +0,0 @@
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
@@ -1 +0,0 @@
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,MACxD;AACA,UAAI,gBAAgB,MAAM;AACxB,yBAAiB,iBAAiB,gBAAgB;AAAA,MACpD;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAAqC;AApC5D;AAqCL,QAAM,iBAAgB,oCAAO,QAAQ,YAAf,mBAAyB;AAC/C,MAAI,CAAC,iBAAiB,O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