@opentiny/fluent-editor 4.0.0-beta.1 → 4.0.0-beta.2
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 +0 -2
- package/es/config/i18n/en-us.es.js.map +1 -1
- package/es/config/i18n/zh-cn.es.js +0 -2
- package/es/config/i18n/zh-cn.es.js.map +1 -1
- package/es/fluent-editor.es.js +0 -6
- package/es/fluent-editor.es.js.map +1 -1
- package/es/index.es.js +0 -4
- package/es/index.es.js.map +1 -1
- package/es/modules/index.es.js +0 -4
- package/es/modules/index.es.js.map +1 -1
- package/es/modules/shortcut-key/index.es.js +0 -16
- package/es/modules/shortcut-key/index.es.js.map +1 -1
- package/es/ui/icons.config.es.js +0 -4
- package/es/ui/icons.config.es.js.map +1 -1
- package/es/ui/icons.es.js +2 -4
- package/es/ui/icons.es.js.map +1 -1
- package/lib/config/i18n/en-us.cjs.js +0 -2
- package/lib/config/i18n/en-us.cjs.js.map +1 -1
- package/lib/config/i18n/zh-cn.cjs.js +0 -2
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js +2 -8
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/index.cjs.js +5 -9
- package/lib/index.cjs.js.map +1 -1
- package/lib/modules/index.cjs.js +5 -9
- package/lib/modules/index.cjs.js.map +1 -1
- package/lib/modules/shortcut-key/index.cjs.js +0 -16
- package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
- package/lib/ui/icons.cjs.js +1 -3
- package/lib/ui/icons.cjs.js.map +1 -1
- package/lib/ui/icons.config.cjs.js +0 -4
- package/lib/ui/icons.config.cjs.js.map +1 -1
- package/package.json +1 -3
- package/types/config/i18n/en-us.d.ts +0 -2
- package/types/config/i18n/zh-cn.d.ts +0 -2
- package/types/config/types/editor-modules.interface.d.ts +0 -4
- package/types/modules/index.d.ts +0 -2
- package/types/ui/icons.config.d.ts +0 -2
- package/es/modules/ai/constants.es.js +0 -50
- package/es/modules/ai/constants.es.js.map +0 -1
- package/es/modules/ai/icons.es.js +0 -319
- package/es/modules/ai/icons.es.js.map +0 -1
- package/es/modules/ai/index.es.js +0 -670
- package/es/modules/ai/index.es.js.map +0 -1
- package/es/modules/flow-chart/config-utils.es.js +0 -102
- package/es/modules/flow-chart/config-utils.es.js.map +0 -1
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js +0 -369
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/en-us.es.js +0 -30
- package/es/modules/flow-chart/i18n/en-us.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/index.es.js +0 -12
- package/es/modules/flow-chart/i18n/index.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/zh-cn.es.js +0 -30
- package/es/modules/flow-chart/i18n/zh-cn.es.js.map +0 -1
- package/es/modules/flow-chart/icons.es.js +0 -27
- package/es/modules/flow-chart/icons.es.js.map +0 -1
- package/es/modules/flow-chart/index.es.js +0 -45
- package/es/modules/flow-chart/index.es.js.map +0 -1
- package/es/modules/flow-chart/modules/context-menu.es.js +0 -184
- package/es/modules/flow-chart/modules/context-menu.es.js.map +0 -1
- package/es/modules/flow-chart/modules/control-panel.es.js +0 -286
- package/es/modules/flow-chart/modules/control-panel.es.js.map +0 -1
- package/es/modules/flow-chart/modules/custom-resize-action.es.js +0 -150
- package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +0 -1
- package/es/modules/mind-map/config-utils.es.js +0 -108
- package/es/modules/mind-map/config-utils.es.js.map +0 -1
- package/es/modules/mind-map/formats/mind-map-blot.es.js +0 -356
- package/es/modules/mind-map/formats/mind-map-blot.es.js.map +0 -1
- package/es/modules/mind-map/i18n/en-us.es.js +0 -29
- package/es/modules/mind-map/i18n/en-us.es.js.map +0 -1
- package/es/modules/mind-map/i18n/index.es.js +0 -12
- package/es/modules/mind-map/i18n/index.es.js.map +0 -1
- package/es/modules/mind-map/i18n/zh-cn.es.js +0 -29
- package/es/modules/mind-map/i18n/zh-cn.es.js.map +0 -1
- package/es/modules/mind-map/icons.es.js +0 -45
- package/es/modules/mind-map/icons.es.js.map +0 -1
- package/es/modules/mind-map/index.es.js +0 -56
- package/es/modules/mind-map/index.es.js.map +0 -1
- package/es/modules/mind-map/modules/context-menu.es.js +0 -128
- package/es/modules/mind-map/modules/context-menu.es.js.map +0 -1
- package/es/modules/mind-map/modules/control-panel.es.js +0 -425
- package/es/modules/mind-map/modules/control-panel.es.js.map +0 -1
- package/es/modules/mind-map/modules/custom-resize-action.es.js +0 -161
- package/es/modules/mind-map/modules/custom-resize-action.es.js.map +0 -1
- package/flow-chart.css +0 -185
- package/lib/modules/ai/constants.cjs.js +0 -50
- package/lib/modules/ai/constants.cjs.js.map +0 -1
- package/lib/modules/ai/icons.cjs.js +0 -319
- package/lib/modules/ai/icons.cjs.js.map +0 -1
- package/lib/modules/ai/index.cjs.js +0 -670
- package/lib/modules/ai/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/config-utils.cjs.js +0 -102
- package/lib/modules/flow-chart/config-utils.cjs.js.map +0 -1
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +0 -369
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/en-us.cjs.js +0 -30
- package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/index.cjs.js +0 -12
- package/lib/modules/flow-chart/i18n/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +0 -30
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +0 -1
- package/lib/modules/flow-chart/icons.cjs.js +0 -27
- package/lib/modules/flow-chart/icons.cjs.js.map +0 -1
- package/lib/modules/flow-chart/index.cjs.js +0 -45
- package/lib/modules/flow-chart/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/context-menu.cjs.js +0 -184
- package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/control-panel.cjs.js +0 -286
- package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +0 -150
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +0 -1
- package/lib/modules/mind-map/config-utils.cjs.js +0 -108
- package/lib/modules/mind-map/config-utils.cjs.js.map +0 -1
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +0 -356
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/en-us.cjs.js +0 -29
- package/lib/modules/mind-map/i18n/en-us.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/index.cjs.js +0 -12
- package/lib/modules/mind-map/i18n/index.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js +0 -29
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +0 -1
- package/lib/modules/mind-map/icons.cjs.js +0 -45
- package/lib/modules/mind-map/icons.cjs.js.map +0 -1
- package/lib/modules/mind-map/index.cjs.js +0 -56
- package/lib/modules/mind-map/index.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/context-menu.cjs.js +0 -128
- package/lib/modules/mind-map/modules/context-menu.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/control-panel.cjs.js +0 -425
- package/lib/modules/mind-map/modules/control-panel.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +0 -161
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +0 -1
- package/mind-map.css +0 -224
- package/types/modules/ai/constants.d.ts +0 -30
- package/types/modules/ai/icons.d.ts +0 -21
- package/types/modules/ai/index.d.ts +0 -96
- package/types/modules/ai/types.d.ts +0 -16
- package/types/modules/flow-chart/config-utils.d.ts +0 -10
- package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +0 -43
- package/types/modules/flow-chart/i18n/en-us.d.ts +0 -26
- package/types/modules/flow-chart/i18n/index.d.ts +0 -1
- package/types/modules/flow-chart/i18n/zh-cn.d.ts +0 -26
- package/types/modules/flow-chart/icons.d.ts +0 -12
- package/types/modules/flow-chart/index.d.ts +0 -10
- package/types/modules/flow-chart/modules/context-menu.d.ts +0 -3
- package/types/modules/flow-chart/modules/control-panel.d.ts +0 -3
- package/types/modules/flow-chart/modules/custom-resize-action.d.ts +0 -22
- package/types/modules/flow-chart/options.d.ts +0 -29
- package/types/modules/mind-map/config-utils.d.ts +0 -12
- package/types/modules/mind-map/formats/mind-map-blot.d.ts +0 -44
- package/types/modules/mind-map/i18n/en-us.d.ts +0 -25
- package/types/modules/mind-map/i18n/index.d.ts +0 -1
- package/types/modules/mind-map/i18n/zh-cn.d.ts +0 -25
- package/types/modules/mind-map/icons.d.ts +0 -21
- package/types/modules/mind-map/index.d.ts +0 -10
- package/types/modules/mind-map/modules/context-menu.d.ts +0 -3
- package/types/modules/mind-map/modules/control-panel.d.ts +0 -3
- package/types/modules/mind-map/modules/custom-resize-action.d.ts +0 -23
- package/types/modules/mind-map/options.d.ts +0 -27
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
require("../../../config/index.cjs.js");
|
|
7
|
-
const i18n = require("../../i18n.cjs.js");
|
|
8
|
-
const index = require("../i18n/index.cjs.js");
|
|
9
|
-
const icons = require("../icons.cjs.js");
|
|
10
|
-
const editor_config = require("../../../config/editor.config.cjs.js");
|
|
11
|
-
class FlowChartControlPanelHandler {
|
|
12
|
-
constructor(quill, blot) {
|
|
13
|
-
__publicField(this, "texts");
|
|
14
|
-
__publicField(this, "lang");
|
|
15
|
-
this.quill = quill;
|
|
16
|
-
this.blot = blot;
|
|
17
|
-
const i18nModule = this.quill.getModule("i18n");
|
|
18
|
-
index.registerFlowChartI18N(i18n.I18N);
|
|
19
|
-
this.lang = i18nModule.options.lang;
|
|
20
|
-
this.texts = this.resolveTexts();
|
|
21
|
-
this.quill.emitter.on(editor_config.CHANGE_LANGUAGE_EVENT, (lang) => {
|
|
22
|
-
this.lang = lang;
|
|
23
|
-
this.texts = this.resolveTexts();
|
|
24
|
-
this.updateControlPanelTexts();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
getText(key) {
|
|
28
|
-
return this.texts[key];
|
|
29
|
-
}
|
|
30
|
-
resolveTexts() {
|
|
31
|
-
return {
|
|
32
|
-
exportTitle: i18n.I18N.parserText("flowChart.controlPanel.exportTitle", this.lang),
|
|
33
|
-
zoomOutTitle: i18n.I18N.parserText("flowChart.controlPanel.zoomOutTitle", this.lang),
|
|
34
|
-
zoomInTitle: i18n.I18N.parserText("flowChart.controlPanel.zoomInTitle", this.lang),
|
|
35
|
-
fitTitle: i18n.I18N.parserText("flowChart.controlPanel.fitTitle", this.lang),
|
|
36
|
-
backTitle: i18n.I18N.parserText("flowChart.controlPanel.backTitle", this.lang),
|
|
37
|
-
forwardTitle: i18n.I18N.parserText("flowChart.controlPanel.forwardTitle", this.lang),
|
|
38
|
-
setEdgeTypeTitle: i18n.I18N.parserText("flowChart.controlPanel.setEdgeTypeTitle", this.lang),
|
|
39
|
-
panelStatusTitle: i18n.I18N.parserText("flowChart.controlPanel.panelStatusTitle", this.lang),
|
|
40
|
-
screenTypeTitle: i18n.I18N.parserText("flowChart.controlPanel.screenTypeTitle", this.lang)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
updateControlPanelTexts() {
|
|
44
|
-
const controlItems = this.blot.domNode.querySelectorAll(".ql-flow-chart-control-item");
|
|
45
|
-
const controlItemMap = {
|
|
46
|
-
"zoom-out": "zoomOutTitle",
|
|
47
|
-
"zoom-in": "zoomInTitle",
|
|
48
|
-
"fit": "fitTitle",
|
|
49
|
-
"back": "backTitle",
|
|
50
|
-
"forward": "forwardTitle",
|
|
51
|
-
"set-edge-type": "setEdgeTypeTitle",
|
|
52
|
-
"panel-status": "panelStatusTitle",
|
|
53
|
-
"screen-type": "screenTypeTitle"
|
|
54
|
-
};
|
|
55
|
-
controlItems.forEach((item) => {
|
|
56
|
-
const controlType = item.dataset.controlType;
|
|
57
|
-
if (controlType && controlItemMap[controlType] && this.texts[controlItemMap[controlType]]) {
|
|
58
|
-
item.title = this.texts[controlItemMap[controlType]];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const controlPanelHandlers = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
const DISABLED_OPACITY = "0.5";
|
|
65
|
-
const ENABLED_OPACITY = "1";
|
|
66
|
-
function createControlPanel(blot, quill) {
|
|
67
|
-
const controlPanel = document.createElement("div");
|
|
68
|
-
controlPanel.className = "ql-flow-chart-control";
|
|
69
|
-
const controlRightUpPanel = document.createElement("div");
|
|
70
|
-
controlRightUpPanel.className = "ql-flow-chart-right-up-control";
|
|
71
|
-
const handler = new FlowChartControlPanelHandler(quill, blot);
|
|
72
|
-
controlPanelHandlers.set(blot, handler);
|
|
73
|
-
const zoomOutBtn = createControlItem("zoom-out", handler.getText("zoomOutTitle"), () => handleZoomOut(blot));
|
|
74
|
-
const zoomInBtn = createControlItem("zoom-in", handler.getText("zoomInTitle"), () => handleZoomIn(blot));
|
|
75
|
-
const resetBtn = createControlItem("fit", handler.getText("fitTitle"), () => handleResetZoom(blot));
|
|
76
|
-
const backBtn = createControlItem("back", handler.getText("backTitle"), () => handleUndo(blot));
|
|
77
|
-
const forwardBtn = createControlItem("forward", handler.getText("forwardTitle"), () => handleRedo(blot));
|
|
78
|
-
const setEdgeTypeBtn = createControlItem("set-edge-type", handler.getText("setEdgeTypeTitle"), () => handleSetEdgeType(blot));
|
|
79
|
-
const panelStatusBtn = createControlItem("panel-status", handler.getText("panelStatusTitle"));
|
|
80
|
-
const screenTypeBtn = createControlItem("screen-type", handler.getText("screenTypeTitle"), () => handleScreenTypeBtn(blot));
|
|
81
|
-
const updateButtonState = (historyData) => {
|
|
82
|
-
if (!historyData.data) {
|
|
83
|
-
backBtn.style.opacity = DISABLED_OPACITY;
|
|
84
|
-
backBtn.style.cursor = "not-allowed";
|
|
85
|
-
forwardBtn.style.opacity = DISABLED_OPACITY;
|
|
86
|
-
forwardBtn.style.cursor = "not-allowed";
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const isUndoAvailable = historyData.data.undoAble || historyData.data.undos.length < 0;
|
|
90
|
-
const isRedoAvailable = historyData.data.redoAble || historyData.data.redos.length > 0;
|
|
91
|
-
if (backBtn) {
|
|
92
|
-
backBtn.style.opacity = isUndoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY;
|
|
93
|
-
backBtn.style.cursor = isUndoAvailable ? "pointer" : "not-allowed";
|
|
94
|
-
}
|
|
95
|
-
if (forwardBtn) {
|
|
96
|
-
forwardBtn.style.opacity = isRedoAvailable ? ENABLED_OPACITY : DISABLED_OPACITY;
|
|
97
|
-
forwardBtn.style.cursor = isRedoAvailable ? "pointer" : "not-allowed";
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
updateButtonState(blot.flowChart.history);
|
|
101
|
-
blot.flowChart.on("history:change", (data) => {
|
|
102
|
-
updateButtonState(data);
|
|
103
|
-
});
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
const controlLeftUpPanel = blot.domNode.querySelector(".lf-dndpanel");
|
|
106
|
-
controlLeftUpPanel.append(setEdgeTypeBtn);
|
|
107
|
-
}, 0);
|
|
108
|
-
controlRightUpPanel.append(panelStatusBtn);
|
|
109
|
-
blot.domNode.appendChild(controlRightUpPanel);
|
|
110
|
-
controlPanel.append(zoomOutBtn, zoomInBtn, resetBtn, screenTypeBtn, backBtn, forwardBtn);
|
|
111
|
-
blot.domNode.appendChild(controlPanel);
|
|
112
|
-
}
|
|
113
|
-
function handleUndo(blot) {
|
|
114
|
-
if (blot.flowChart) {
|
|
115
|
-
blot.flowChart.undo();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function handleRedo(blot) {
|
|
119
|
-
if (blot.flowChart) {
|
|
120
|
-
blot.flowChart.redo();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function handleZoomIn(blot) {
|
|
124
|
-
if (blot.flowChart) {
|
|
125
|
-
blot.flowChart.zoom(true);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function handleZoomOut(blot) {
|
|
129
|
-
if (blot.flowChart) {
|
|
130
|
-
blot.flowChart.zoom(false);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function handleResetZoom(blot) {
|
|
134
|
-
if (blot.flowChart) {
|
|
135
|
-
blot.flowChart.resetZoom();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function createControlItem(iconClass, title, onClick, disabled = false) {
|
|
139
|
-
const controlItem = document.createElement("div");
|
|
140
|
-
controlItem.className = "ql-flow-chart-control-item";
|
|
141
|
-
controlItem.title = title;
|
|
142
|
-
controlItem.dataset.controlType = iconClass;
|
|
143
|
-
controlItem.style.cursor = disabled ? "not-allowed" : "pointer";
|
|
144
|
-
const iconMap = {
|
|
145
|
-
"back": icons.backIcon,
|
|
146
|
-
"forward": icons.forwardIcon,
|
|
147
|
-
"zoom-out": icons.zoomOutIcon,
|
|
148
|
-
"zoom-in": icons.zoomInIcon,
|
|
149
|
-
"fit": icons.fitIcon,
|
|
150
|
-
"screen-type": icons.screenTypeIcon,
|
|
151
|
-
"panel-status": icons.contractIcon,
|
|
152
|
-
"set-edge-type": icons.lineIcon
|
|
153
|
-
};
|
|
154
|
-
const icon = document.createElement("i");
|
|
155
|
-
icon.innerHTML = iconMap[iconClass] || "";
|
|
156
|
-
controlItem.appendChild(icon);
|
|
157
|
-
if (!disabled) {
|
|
158
|
-
controlItem.addEventListener("click", onClick);
|
|
159
|
-
}
|
|
160
|
-
return controlItem;
|
|
161
|
-
}
|
|
162
|
-
function handleSetEdgeType(blot) {
|
|
163
|
-
const controlLeftUpPanel = blot.domNode.querySelector(".lf-dndpanel");
|
|
164
|
-
if (!controlLeftUpPanel) return;
|
|
165
|
-
let edgeTypePanel = controlLeftUpPanel.querySelector(".ql-flow-chart-edge-panel");
|
|
166
|
-
if (!edgeTypePanel) {
|
|
167
|
-
edgeTypePanel = document.createElement("div");
|
|
168
|
-
edgeTypePanel.className = "ql-flow-chart-edge-panel";
|
|
169
|
-
edgeTypePanel.style.display = "flex";
|
|
170
|
-
edgeTypePanel.style.justifyContent = "space-around";
|
|
171
|
-
edgeTypePanel.style.flexWrap = "nowrap";
|
|
172
|
-
edgeTypePanel.style.width = "auto";
|
|
173
|
-
edgeTypePanel.style.minWidth = "100%";
|
|
174
|
-
edgeTypePanel.style.padding = "8px";
|
|
175
|
-
edgeTypePanel.style.boxSizing = "border-box";
|
|
176
|
-
edgeTypePanel.style.position = "absolute";
|
|
177
|
-
edgeTypePanel.style.top = "170px";
|
|
178
|
-
controlLeftUpPanel.appendChild(edgeTypePanel);
|
|
179
|
-
const edgeTypes = [
|
|
180
|
-
{
|
|
181
|
-
name: "line",
|
|
182
|
-
displayName: "直线",
|
|
183
|
-
icon: icons.lineIcon
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "polyline",
|
|
187
|
-
displayName: "折线",
|
|
188
|
-
icon: icons.polyLineIcon
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: "bezier",
|
|
192
|
-
displayName: "贝塞尔曲线",
|
|
193
|
-
icon: icons.bezierIcon
|
|
194
|
-
}
|
|
195
|
-
];
|
|
196
|
-
edgeTypes.forEach((edgeType) => {
|
|
197
|
-
const edgeItem = document.createElement("div");
|
|
198
|
-
edgeItem.className = "ql-flow-chart-edge-item";
|
|
199
|
-
edgeItem.style.padding = "8px";
|
|
200
|
-
edgeItem.style.cursor = "pointer";
|
|
201
|
-
edgeItem.style.textAlign = "center";
|
|
202
|
-
const edgeIcon = document.createElement("div");
|
|
203
|
-
edgeIcon.className = `ql-flow-chart-edge-type-icon`;
|
|
204
|
-
edgeIcon.style.width = "24px";
|
|
205
|
-
edgeIcon.style.height = "24px";
|
|
206
|
-
edgeIcon.style.margin = "0 auto";
|
|
207
|
-
if (edgeType.icon) {
|
|
208
|
-
edgeIcon.innerHTML = edgeType.icon;
|
|
209
|
-
}
|
|
210
|
-
edgeItem.appendChild(edgeIcon);
|
|
211
|
-
edgeItem.addEventListener("click", () => {
|
|
212
|
-
const { edges = [] } = blot.flowChart.getSelectElements();
|
|
213
|
-
if (edges.length > 0) {
|
|
214
|
-
edges.forEach((edge) => {
|
|
215
|
-
blot.flowChart.changeEdgeType(edge.id, edgeType.name);
|
|
216
|
-
});
|
|
217
|
-
blot.data = blot.flowChart.getGraphData();
|
|
218
|
-
blot.domNode.setAttribute("data-flow-chart", JSON.stringify(blot.data));
|
|
219
|
-
}
|
|
220
|
-
edgeTypePanel.style.display = "none";
|
|
221
|
-
});
|
|
222
|
-
edgeTypePanel.appendChild(edgeItem);
|
|
223
|
-
});
|
|
224
|
-
} else {
|
|
225
|
-
edgeTypePanel.style.display = "flex";
|
|
226
|
-
edgeTypePanel.style.justifyContent = "space-around";
|
|
227
|
-
edgeTypePanel.style.flexWrap = "nowrap";
|
|
228
|
-
}
|
|
229
|
-
const handleOutsideClick = (e) => {
|
|
230
|
-
let setEdgeTypeBtn = null;
|
|
231
|
-
const controlItems = controlLeftUpPanel.querySelectorAll(".ql-flow-chart-control-item");
|
|
232
|
-
controlItems.forEach((item) => {
|
|
233
|
-
const iconEl = item.querySelector("i");
|
|
234
|
-
if (iconEl && iconEl.className.includes("set-edge-type")) {
|
|
235
|
-
setEdgeTypeBtn = item;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
if (!edgeTypePanel.contains(e.target) && (!setEdgeTypeBtn || !setEdgeTypeBtn.contains(e.target))) {
|
|
239
|
-
edgeTypePanel.style.display = "none";
|
|
240
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
244
|
-
setTimeout(() => {
|
|
245
|
-
document.addEventListener("click", handleOutsideClick);
|
|
246
|
-
}, 0);
|
|
247
|
-
}
|
|
248
|
-
function handleScreenTypeBtn(blot) {
|
|
249
|
-
const screenTypeBtn = blot.domNode.querySelector('[data-control-type="screen-type"]');
|
|
250
|
-
if (!screenTypeBtn || !blot.domNode) return;
|
|
251
|
-
const flowChartContainer = blot.domNode;
|
|
252
|
-
const isFullscreen = flowChartContainer.style.position === "fixed";
|
|
253
|
-
if (isFullscreen) {
|
|
254
|
-
const originalPosition = flowChartContainer.getAttribute("data-original-position");
|
|
255
|
-
const originalWidth = flowChartContainer.getAttribute("data-original-width");
|
|
256
|
-
const originalHeight = flowChartContainer.getAttribute("data-original-height");
|
|
257
|
-
if (originalWidth && originalHeight) {
|
|
258
|
-
flowChartContainer.style.position = originalPosition;
|
|
259
|
-
flowChartContainer.style.width = originalWidth;
|
|
260
|
-
flowChartContainer.style.height = originalHeight;
|
|
261
|
-
flowChartContainer.style.zIndex = "0";
|
|
262
|
-
}
|
|
263
|
-
const iconElement = screenTypeBtn.querySelector("i");
|
|
264
|
-
if (iconElement) {
|
|
265
|
-
iconElement.innerHTML = icons.screenTypeIcon;
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
flowChartContainer.setAttribute("data-original-position", flowChartContainer.style.position || "");
|
|
269
|
-
flowChartContainer.setAttribute("data-original-width", flowChartContainer.style.width || "");
|
|
270
|
-
flowChartContainer.setAttribute("data-original-height", flowChartContainer.style.height || "");
|
|
271
|
-
flowChartContainer.style.position = "fixed";
|
|
272
|
-
flowChartContainer.style.top = "0";
|
|
273
|
-
flowChartContainer.style.left = "0";
|
|
274
|
-
flowChartContainer.style.width = "100vw";
|
|
275
|
-
flowChartContainer.style.height = "100vh";
|
|
276
|
-
flowChartContainer.style.zIndex = "100";
|
|
277
|
-
const iconElement = screenTypeBtn.querySelector("i");
|
|
278
|
-
if (iconElement) {
|
|
279
|
-
iconElement.innerHTML = icons.screenReduceIcon;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
blot.flowChart.resize();
|
|
283
|
-
blot.flowChart.translateCenter();
|
|
284
|
-
}
|
|
285
|
-
exports.createControlPanel = createControlPanel;
|
|
286
|
-
//# sourceMappingURL=control-panel.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"control-panel.cjs.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":["registerFlowChartI18N","I18N","CHANGE_LANGUAGE_EVENT","backIcon","forwardIcon","zoomOutIcon","zoomInIcon","fitIcon","screenTypeIcon","contractIcon","lineIcon","polyLineIcon","bezierIcon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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,YAAYK,MAAAA;AAAAA,IAC1B;AAAA,EACF;AACA,OAAK,UAAU,OAAA;AACf,OAAK,UAAU,gBAAA;AACjB;;"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
const MIN_WIDTH = 350;
|
|
7
|
-
const MIN_HEIGHT = 290;
|
|
8
|
-
class FlowChartResizeAction {
|
|
9
|
-
constructor(blot) {
|
|
10
|
-
__publicField(this, "topLeftHandle");
|
|
11
|
-
__publicField(this, "topRightHandle");
|
|
12
|
-
__publicField(this, "bottomRightHandle");
|
|
13
|
-
__publicField(this, "bottomLeftHandle");
|
|
14
|
-
__publicField(this, "dragHandle", null);
|
|
15
|
-
__publicField(this, "dragStartX", 0);
|
|
16
|
-
__publicField(this, "dragStartY", 0);
|
|
17
|
-
__publicField(this, "preDragWidth", 0);
|
|
18
|
-
__publicField(this, "preDragHeight", 0);
|
|
19
|
-
__publicField(this, "targetRatio", 0);
|
|
20
|
-
__publicField(this, "blot");
|
|
21
|
-
this.blot = blot;
|
|
22
|
-
this.topLeftHandle = this.createHandle("top-left", "nwse-resize");
|
|
23
|
-
this.topRightHandle = this.createHandle("top-right", "nesw-resize");
|
|
24
|
-
this.bottomRightHandle = this.createHandle("bottom-right", "nwse-resize");
|
|
25
|
-
this.bottomLeftHandle = this.createHandle("bottom-left", "nesw-resize");
|
|
26
|
-
this.init();
|
|
27
|
-
}
|
|
28
|
-
isFullscreen() {
|
|
29
|
-
const container = this.blot.domNode;
|
|
30
|
-
return container.style.position === "fixed" && container.style.width === "100vw" && container.style.height === "100vh";
|
|
31
|
-
}
|
|
32
|
-
init() {
|
|
33
|
-
const container = this.blot.domNode;
|
|
34
|
-
container.style.position = "relative";
|
|
35
|
-
container.appendChild(this.topLeftHandle);
|
|
36
|
-
container.appendChild(this.topRightHandle);
|
|
37
|
-
container.appendChild(this.bottomRightHandle);
|
|
38
|
-
container.appendChild(this.bottomLeftHandle);
|
|
39
|
-
this.repositionHandles();
|
|
40
|
-
}
|
|
41
|
-
createHandle(position, cursor) {
|
|
42
|
-
const box = document.createElement("div");
|
|
43
|
-
box.classList.add("ql-flow-chart-resize-handle");
|
|
44
|
-
box.setAttribute("data-position", position);
|
|
45
|
-
Object.assign(box.style, {
|
|
46
|
-
cursor,
|
|
47
|
-
position: "absolute",
|
|
48
|
-
width: "10px",
|
|
49
|
-
height: "10px",
|
|
50
|
-
background: "#4285f4",
|
|
51
|
-
border: "1px solid white",
|
|
52
|
-
borderRadius: "50%",
|
|
53
|
-
zIndex: "99",
|
|
54
|
-
userSelect: "none"
|
|
55
|
-
});
|
|
56
|
-
box.addEventListener("mousedown", this.onMouseDown.bind(this));
|
|
57
|
-
return box;
|
|
58
|
-
}
|
|
59
|
-
repositionHandles() {
|
|
60
|
-
const container = this.blot.domNode;
|
|
61
|
-
const rect = container.getBoundingClientRect();
|
|
62
|
-
Object.assign(this.topLeftHandle.style, {
|
|
63
|
-
left: "-5px",
|
|
64
|
-
top: "-5px"
|
|
65
|
-
});
|
|
66
|
-
Object.assign(this.topRightHandle.style, {
|
|
67
|
-
right: "-5px",
|
|
68
|
-
top: "-5px"
|
|
69
|
-
});
|
|
70
|
-
Object.assign(this.bottomRightHandle.style, {
|
|
71
|
-
right: "-5px",
|
|
72
|
-
bottom: "-5px"
|
|
73
|
-
});
|
|
74
|
-
Object.assign(this.bottomLeftHandle.style, {
|
|
75
|
-
left: "-5px",
|
|
76
|
-
bottom: "-5px"
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
onMouseDown(event) {
|
|
80
|
-
if (this.isFullscreen()) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (!(event.target instanceof HTMLElement)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this.dragHandle = event.target;
|
|
87
|
-
document.body.style.cursor = this.dragHandle.style.cursor;
|
|
88
|
-
const container = this.blot.domNode;
|
|
89
|
-
const rect = container.getBoundingClientRect();
|
|
90
|
-
this.dragStartX = event.clientX;
|
|
91
|
-
this.dragStartY = event.clientY;
|
|
92
|
-
this.preDragWidth = rect.width;
|
|
93
|
-
this.preDragHeight = rect.height;
|
|
94
|
-
this.targetRatio = rect.height / rect.width;
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
document.addEventListener("mousemove", this.onDrag.bind(this));
|
|
97
|
-
document.addEventListener("mouseup", this.onMouseUp.bind(this));
|
|
98
|
-
}
|
|
99
|
-
onDrag(event) {
|
|
100
|
-
if (!this.dragHandle) return;
|
|
101
|
-
const container = this.blot.domNode;
|
|
102
|
-
let newWidth = this.preDragWidth;
|
|
103
|
-
let newHeight = this.preDragHeight;
|
|
104
|
-
const deltaX = event.clientX - this.dragStartX;
|
|
105
|
-
const deltaY = event.clientY - this.dragStartY;
|
|
106
|
-
switch (this.dragHandle.dataset.position) {
|
|
107
|
-
case "top-left":
|
|
108
|
-
newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
|
|
109
|
-
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
|
|
110
|
-
break;
|
|
111
|
-
case "top-right":
|
|
112
|
-
newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
|
|
113
|
-
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
|
|
114
|
-
break;
|
|
115
|
-
case "bottom-right":
|
|
116
|
-
newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
|
|
117
|
-
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
|
|
118
|
-
break;
|
|
119
|
-
case "bottom-left":
|
|
120
|
-
newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
|
|
121
|
-
newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
container.style.width = `${newWidth}px`;
|
|
125
|
-
container.style.height = `${newHeight}px`;
|
|
126
|
-
container.setAttribute("width", String(newWidth));
|
|
127
|
-
container.setAttribute("height", String(newHeight));
|
|
128
|
-
if (this.blot.flowChart) {
|
|
129
|
-
this.blot.flowChart.resize(newWidth, newHeight);
|
|
130
|
-
}
|
|
131
|
-
this.blot.data.width = newWidth;
|
|
132
|
-
this.blot.data.height = newHeight;
|
|
133
|
-
container.setAttribute("data-flow-chart", JSON.stringify(this.blot.data));
|
|
134
|
-
}
|
|
135
|
-
onMouseUp() {
|
|
136
|
-
document.body.style.cursor = "";
|
|
137
|
-
document.removeEventListener("mousemove", this.onDrag.bind(this));
|
|
138
|
-
document.removeEventListener("mouseup", this.onMouseUp.bind(this));
|
|
139
|
-
this.dragHandle = null;
|
|
140
|
-
}
|
|
141
|
-
destroy() {
|
|
142
|
-
const container = this.blot.domNode;
|
|
143
|
-
container.removeChild(this.topLeftHandle);
|
|
144
|
-
container.removeChild(this.topRightHandle);
|
|
145
|
-
container.removeChild(this.bottomRightHandle);
|
|
146
|
-
container.removeChild(this.bottomLeftHandle);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.FlowChartResizeAction = FlowChartResizeAction;
|
|
150
|
-
//# sourceMappingURL=custom-resize-action.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-resize-action.cjs.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;AA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K,SAAS;AACxB,cAAU,aAAa,mBAAmB,KAAK,UAAU,KAAK,KAAK,IAAI,CAAC;AAAA,EAC1E;AAAA,EAEA,YAAY;AACV,aAAS,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
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function getBackgroundConfig(quill) {
|
|
4
|
-
var _a;
|
|
5
|
-
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
6
|
-
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
if ("background" in MindMapModule) {
|
|
10
|
-
const background = MindMapModule.background;
|
|
11
|
-
if (background === false || background === void 0) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (typeof background === "object" && background !== null) {
|
|
15
|
-
const typedBackground = background;
|
|
16
|
-
const backgroundConfig = {};
|
|
17
|
-
if (typedBackground.color) {
|
|
18
|
-
backgroundConfig.backgroundColor = typedBackground.color;
|
|
19
|
-
}
|
|
20
|
-
if (typedBackground.image) {
|
|
21
|
-
backgroundConfig.backgroundImage = typedBackground.image;
|
|
22
|
-
}
|
|
23
|
-
if (typedBackground.repeat) {
|
|
24
|
-
backgroundConfig.backgroundRepeat = typedBackground.repeat;
|
|
25
|
-
}
|
|
26
|
-
if (typedBackground.position) {
|
|
27
|
-
backgroundConfig.backgroundPosition = typedBackground.position;
|
|
28
|
-
}
|
|
29
|
-
if (typedBackground.size) {
|
|
30
|
-
backgroundConfig.backgroundSize = typedBackground.size;
|
|
31
|
-
}
|
|
32
|
-
return backgroundConfig;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
function getLineConfig(quill) {
|
|
38
|
-
var _a;
|
|
39
|
-
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
40
|
-
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if ("line" in MindMapModule) {
|
|
44
|
-
const line = MindMapModule.line;
|
|
45
|
-
if (line === false || line === void 0) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (typeof line === "object" && line !== null) {
|
|
49
|
-
const typedLine = line;
|
|
50
|
-
const lineConfig = {};
|
|
51
|
-
if (typedLine.color) {
|
|
52
|
-
lineConfig.lineColor = typedLine.color;
|
|
53
|
-
}
|
|
54
|
-
if (typedLine.width) {
|
|
55
|
-
lineConfig.lineWidth = typedLine.width;
|
|
56
|
-
}
|
|
57
|
-
if (typedLine.dasharray) {
|
|
58
|
-
lineConfig.lineDasharray = typedLine.dasharray;
|
|
59
|
-
}
|
|
60
|
-
if (typedLine.style) {
|
|
61
|
-
lineConfig.lineStyle = typedLine.style;
|
|
62
|
-
}
|
|
63
|
-
return lineConfig;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
function getResizeConfig(quill) {
|
|
69
|
-
var _a;
|
|
70
|
-
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
71
|
-
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if ("resize" in MindMapModule) {
|
|
75
|
-
const resize = MindMapModule.resize;
|
|
76
|
-
return resize === true;
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
function getThemeConfig(quill) {
|
|
81
|
-
var _a;
|
|
82
|
-
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
|
|
83
|
-
if (!MindMapModule || typeof MindMapModule !== "object") {
|
|
84
|
-
return "default";
|
|
85
|
-
}
|
|
86
|
-
if ("theme" in MindMapModule) {
|
|
87
|
-
const theme = MindMapModule.theme;
|
|
88
|
-
return theme || "default";
|
|
89
|
-
}
|
|
90
|
-
return "default";
|
|
91
|
-
}
|
|
92
|
-
function getAllConfigs(quill) {
|
|
93
|
-
var _a, _b;
|
|
94
|
-
const deps = (_b = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"]) == null ? void 0 : _b.deps;
|
|
95
|
-
return {
|
|
96
|
-
backgroundConfig: getBackgroundConfig(quill),
|
|
97
|
-
resizeConfig: getResizeConfig(quill),
|
|
98
|
-
lineConfig: getLineConfig(quill),
|
|
99
|
-
themeConfig: getThemeConfig(quill),
|
|
100
|
-
deps
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
exports.getAllConfigs = getAllConfigs;
|
|
104
|
-
exports.getBackgroundConfig = getBackgroundConfig;
|
|
105
|
-
exports.getLineConfig = getLineConfig;
|
|
106
|
-
exports.getResizeConfig = getResizeConfig;
|
|
107
|
-
exports.getThemeConfig = getThemeConfig;
|
|
108
|
-
//# sourceMappingURL=config-utils.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.cjs.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;;AACvE,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;;AACjE,QAAM,iBAAgB,oCAAO,QAAQ,YAAf,mBAAyB;AAC/C,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AACA,MAAI,UAAU,eAAe;AAC3B,UAAM,OAAO,c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