@base44-preview/vite-plugin 0.2.22-pr.36.db00ef7 → 0.2.22-pr.37.68542f2
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/dist/injections/utils.d.ts +0 -6
- package/dist/injections/utils.d.ts.map +1 -1
- package/dist/injections/utils.js +0 -25
- package/dist/injections/utils.js.map +1 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts +25 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js +78 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts +4 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js +4 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts +9 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js +26 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts +10 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js +60 -0
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js.map +1 -0
- package/dist/injections/visual-edit-agent/constants.d.ts +10 -0
- package/dist/injections/visual-edit-agent/constants.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/constants.js +10 -0
- package/dist/injections/visual-edit-agent/constants.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts +10 -0
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js +107 -0
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts +14 -0
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js +64 -0
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts +14 -0
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js +104 -0
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts +26 -0
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js +145 -0
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts +7 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js +42 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts +11 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js +32 -0
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts +86 -0
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/handlers/messages/types.js +28 -0
- package/dist/injections/visual-edit-agent/handlers/messages/types.js.map +1 -0
- package/dist/injections/visual-edit-agent/index.d.ts +5 -0
- package/dist/injections/visual-edit-agent/index.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/index.js +106 -0
- package/dist/injections/visual-edit-agent/index.js.map +1 -0
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts +17 -0
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/state/agent-state.js +18 -0
- package/dist/injections/visual-edit-agent/state/agent-state.js.map +1 -0
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts +26 -0
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/ui/overlay.js +100 -0
- package/dist/injections/visual-edit-agent/ui/overlay.js.map +1 -0
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts +14 -0
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent/utils/dom-utils.js +34 -0
- package/dist/injections/visual-edit-agent/utils/dom-utils.js.map +1 -0
- package/dist/injections/visual-edit-agent.d.ts +1 -1
- package/dist/injections/visual-edit-agent.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent.js +1 -474
- package/dist/injections/visual-edit-agent.js.map +1 -1
- package/dist/statics/index.mjs +5 -1
- package/dist/statics/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/injections/utils.ts +0 -34
- package/src/injections/visual-edit-agent/README.md +222 -0
- package/src/injections/visual-edit-agent/capabilities/inline-editing/core.ts +100 -0
- package/src/injections/visual-edit-agent/capabilities/inline-editing/index.ts +10 -0
- package/src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts +26 -0
- package/src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts +67 -0
- package/src/injections/visual-edit-agent/constants.ts +9 -0
- package/src/injections/visual-edit-agent/handlers/click-handlers.ts +134 -0
- package/src/injections/visual-edit-agent/handlers/hover-handlers.ts +78 -0
- package/src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts +136 -0
- package/src/injections/visual-edit-agent/handlers/message-handlers.ts +191 -0
- package/src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts +51 -0
- package/src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts +40 -0
- package/src/injections/visual-edit-agent/handlers/messages/types.ts +112 -0
- package/src/injections/visual-edit-agent/index.ts +120 -0
- package/src/injections/visual-edit-agent/state/agent-state.ts +31 -0
- package/src/injections/visual-edit-agent/ui/overlay.ts +121 -0
- package/src/injections/visual-edit-agent/utils/dom-utils.ts +39 -0
- package/src/injections/visual-edit-agent.ts +1 -577
- package/dist/injections/layer-dropdown/consts.d.ts +0 -15
- package/dist/injections/layer-dropdown/consts.d.ts.map +0 -1
- package/dist/injections/layer-dropdown/consts.js +0 -36
- package/dist/injections/layer-dropdown/consts.js.map +0 -1
- package/dist/injections/layer-dropdown/controller.d.ts +0 -4
- package/dist/injections/layer-dropdown/controller.d.ts.map +0 -1
- package/dist/injections/layer-dropdown/controller.js +0 -85
- package/dist/injections/layer-dropdown/controller.js.map +0 -1
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts +0 -13
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +0 -1
- package/dist/injections/layer-dropdown/dropdown-ui.js +0 -158
- package/dist/injections/layer-dropdown/dropdown-ui.js.map +0 -1
- package/dist/injections/layer-dropdown/types.d.ts +0 -21
- package/dist/injections/layer-dropdown/types.d.ts.map +0 -1
- package/dist/injections/layer-dropdown/types.js +0 -3
- package/dist/injections/layer-dropdown/types.js.map +0 -1
- package/dist/injections/layer-dropdown/utils.d.ts +0 -23
- package/dist/injections/layer-dropdown/utils.d.ts.map +0 -1
- package/dist/injections/layer-dropdown/utils.js +0 -119
- package/dist/injections/layer-dropdown/utils.js.map +0 -1
- package/src/injections/layer-dropdown/consts.ts +0 -44
- package/src/injections/layer-dropdown/controller.ts +0 -105
- package/src/injections/layer-dropdown/dropdown-ui.ts +0 -221
- package/src/injections/layer-dropdown/types.ts +0 -24
- package/src/injections/layer-dropdown/utils.ts +0 -148
|
@@ -1,475 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { createLayerController } from "./layer-dropdown/controller.js";
|
|
3
|
-
import { LAYER_DROPDOWN_ATTR } from "./layer-dropdown/consts.js";
|
|
4
|
-
export function setupVisualEditAgent() {
|
|
5
|
-
// State variables (replacing React useState/useRef)
|
|
6
|
-
let isVisualEditMode = false;
|
|
7
|
-
let isPopoverDragging = false;
|
|
8
|
-
let isDropdownOpen = false;
|
|
9
|
-
let hoverOverlays = [];
|
|
10
|
-
let selectedOverlays = [];
|
|
11
|
-
let currentHighlightedElements = [];
|
|
12
|
-
let selectedElementId = null;
|
|
13
|
-
// Create overlay element
|
|
14
|
-
const createOverlay = (isSelected = false) => {
|
|
15
|
-
const overlay = document.createElement("div");
|
|
16
|
-
overlay.style.position = "absolute";
|
|
17
|
-
overlay.style.pointerEvents = "none";
|
|
18
|
-
overlay.style.transition = "all 0.1s ease-in-out";
|
|
19
|
-
overlay.style.zIndex = "9999";
|
|
20
|
-
if (isSelected) {
|
|
21
|
-
overlay.style.border = "2px solid #2563EB";
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
overlay.style.border = "2px solid #95a5fc";
|
|
25
|
-
overlay.style.backgroundColor = "rgba(99, 102, 241, 0.05)";
|
|
26
|
-
}
|
|
27
|
-
return overlay;
|
|
28
|
-
};
|
|
29
|
-
// Position overlay relative to element
|
|
30
|
-
const positionOverlay = (overlay, element, isSelected = false) => {
|
|
31
|
-
if (!element || !isVisualEditMode)
|
|
32
|
-
return;
|
|
33
|
-
const htmlElement = element;
|
|
34
|
-
// Force layout recalculation
|
|
35
|
-
void htmlElement.offsetWidth;
|
|
36
|
-
const rect = element.getBoundingClientRect();
|
|
37
|
-
overlay.style.top = `${rect.top + window.scrollY}px`;
|
|
38
|
-
overlay.style.left = `${rect.left + window.scrollX}px`;
|
|
39
|
-
overlay.style.width = `${rect.width}px`;
|
|
40
|
-
overlay.style.height = `${rect.height}px`;
|
|
41
|
-
// Check if label already exists in overlay
|
|
42
|
-
let label = overlay.querySelector("div");
|
|
43
|
-
if (!label) {
|
|
44
|
-
label = document.createElement("div");
|
|
45
|
-
label.textContent = element.tagName.toLowerCase();
|
|
46
|
-
label.style.position = "absolute";
|
|
47
|
-
label.style.top = "-27px";
|
|
48
|
-
label.style.left = "-2px";
|
|
49
|
-
label.style.padding = "2px 8px";
|
|
50
|
-
label.style.fontSize = "11px";
|
|
51
|
-
label.style.fontWeight = isSelected ? "500" : "400";
|
|
52
|
-
label.style.color = isSelected ? "#ffffff" : "#526cff";
|
|
53
|
-
label.style.backgroundColor = isSelected ? "#526cff" : "#DBEAFE";
|
|
54
|
-
label.style.borderRadius = "3px";
|
|
55
|
-
label.style.minWidth = "24px";
|
|
56
|
-
label.style.textAlign = "center";
|
|
57
|
-
overlay.appendChild(label);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
// Clear hover overlays
|
|
61
|
-
const clearHoverOverlays = () => {
|
|
62
|
-
hoverOverlays.forEach((overlay) => {
|
|
63
|
-
if (overlay && overlay.parentNode) {
|
|
64
|
-
overlay.remove();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
hoverOverlays = [];
|
|
68
|
-
currentHighlightedElements = [];
|
|
69
|
-
};
|
|
70
|
-
const clearSelectedOverlays = () => {
|
|
71
|
-
selectedOverlays.forEach((overlay) => {
|
|
72
|
-
if (overlay && overlay.parentNode) {
|
|
73
|
-
overlay.remove();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
selectedOverlays = [];
|
|
77
|
-
};
|
|
78
|
-
const notifyElementSelected = (element) => {
|
|
79
|
-
const htmlElement = element;
|
|
80
|
-
const rect = element.getBoundingClientRect();
|
|
81
|
-
const svgElement = element;
|
|
82
|
-
window.parent.postMessage({
|
|
83
|
-
type: "element-selected",
|
|
84
|
-
tagName: element.tagName,
|
|
85
|
-
classes: svgElement.className?.baseVal ||
|
|
86
|
-
element.className ||
|
|
87
|
-
"",
|
|
88
|
-
visualSelectorId: getElementSelectorId(element),
|
|
89
|
-
content: htmlElement.innerText,
|
|
90
|
-
dataSourceLocation: htmlElement.dataset.sourceLocation,
|
|
91
|
-
isDynamicContent: htmlElement.dataset.dynamicContent === "true",
|
|
92
|
-
linenumber: htmlElement.dataset.linenumber,
|
|
93
|
-
filename: htmlElement.dataset.filename,
|
|
94
|
-
position: {
|
|
95
|
-
top: rect.top,
|
|
96
|
-
left: rect.left,
|
|
97
|
-
right: rect.right,
|
|
98
|
-
bottom: rect.bottom,
|
|
99
|
-
width: rect.width,
|
|
100
|
-
height: rect.height,
|
|
101
|
-
centerX: rect.left + rect.width / 2,
|
|
102
|
-
centerY: rect.top + rect.height / 2,
|
|
103
|
-
},
|
|
104
|
-
}, "*");
|
|
105
|
-
};
|
|
106
|
-
// Select an element: create overlays, update state, notify parent
|
|
107
|
-
const selectElement = (element) => {
|
|
108
|
-
const visualSelectorId = getElementSelectorId(element);
|
|
109
|
-
clearSelectedOverlays();
|
|
110
|
-
const elements = findElementsById(visualSelectorId || null);
|
|
111
|
-
elements.forEach((el) => {
|
|
112
|
-
const overlay = createOverlay(true);
|
|
113
|
-
document.body.appendChild(overlay);
|
|
114
|
-
selectedOverlays.push(overlay);
|
|
115
|
-
positionOverlay(overlay, el, true);
|
|
116
|
-
});
|
|
117
|
-
selectedElementId = visualSelectorId || null;
|
|
118
|
-
clearHoverOverlays();
|
|
119
|
-
notifyElementSelected(element);
|
|
120
|
-
return selectedOverlays[0];
|
|
121
|
-
};
|
|
122
|
-
const unSelectElement = () => {
|
|
123
|
-
selectedElementId = null;
|
|
124
|
-
window.parent.postMessage({ type: "unselect-element" }, "*");
|
|
125
|
-
};
|
|
126
|
-
// Handle mouse over event
|
|
127
|
-
const handleMouseOver = (e) => {
|
|
128
|
-
if (!isVisualEditMode || isPopoverDragging)
|
|
129
|
-
return;
|
|
130
|
-
const target = e.target;
|
|
131
|
-
// Prevent hover effects when a dropdown is open
|
|
132
|
-
if (isDropdownOpen) {
|
|
133
|
-
clearHoverOverlays();
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
// Prevent hover effects on SVG path elements
|
|
137
|
-
if (target.tagName.toLowerCase() === "path") {
|
|
138
|
-
clearHoverOverlays();
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
// Support both data-source-location and data-visual-selector-id
|
|
142
|
-
const element = target.closest("[data-source-location], [data-visual-selector-id]");
|
|
143
|
-
if (!element) {
|
|
144
|
-
clearHoverOverlays();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
// Prefer data-source-location, fallback to data-visual-selector-id
|
|
148
|
-
const htmlElement = element;
|
|
149
|
-
const selectorId = htmlElement.dataset.sourceLocation ||
|
|
150
|
-
htmlElement.dataset.visualSelectorId;
|
|
151
|
-
// Skip if this element is already selected
|
|
152
|
-
if (selectedElementId === selectorId) {
|
|
153
|
-
clearHoverOverlays();
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
// Find all elements with the same ID
|
|
157
|
-
const elements = findElementsById(selectorId || null);
|
|
158
|
-
// Clear previous hover overlays
|
|
159
|
-
clearHoverOverlays();
|
|
160
|
-
// Create overlays for all matching elements
|
|
161
|
-
elements.forEach((el) => {
|
|
162
|
-
const overlay = createOverlay(false);
|
|
163
|
-
document.body.appendChild(overlay);
|
|
164
|
-
hoverOverlays.push(overlay);
|
|
165
|
-
positionOverlay(overlay, el);
|
|
166
|
-
});
|
|
167
|
-
currentHighlightedElements = elements;
|
|
168
|
-
};
|
|
169
|
-
// Handle mouse out event
|
|
170
|
-
const handleMouseOut = () => {
|
|
171
|
-
if (isPopoverDragging)
|
|
172
|
-
return;
|
|
173
|
-
clearHoverOverlays();
|
|
174
|
-
};
|
|
175
|
-
// Handle element click
|
|
176
|
-
const handleElementClick = (e) => {
|
|
177
|
-
if (!isVisualEditMode)
|
|
178
|
-
return;
|
|
179
|
-
const target = e.target;
|
|
180
|
-
// Let layer dropdown clicks pass through without interference
|
|
181
|
-
if (target.closest(`[${LAYER_DROPDOWN_ATTR}]`))
|
|
182
|
-
return;
|
|
183
|
-
// Close dropdowns when clicking anywhere in iframe if a dropdown is open
|
|
184
|
-
if (isDropdownOpen) {
|
|
185
|
-
e.preventDefault();
|
|
186
|
-
e.stopPropagation();
|
|
187
|
-
e.stopImmediatePropagation();
|
|
188
|
-
window.parent.postMessage({ type: "close-dropdowns" }, "*");
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
// Prevent clicking on SVG path elements
|
|
192
|
-
if (target.tagName.toLowerCase() === "path") {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
// Prevent default behavior immediately when in visual edit mode
|
|
196
|
-
e.preventDefault();
|
|
197
|
-
e.stopPropagation();
|
|
198
|
-
e.stopImmediatePropagation();
|
|
199
|
-
// Support both data-source-location and data-visual-selector-id
|
|
200
|
-
const element = target.closest("[data-source-location], [data-visual-selector-id]");
|
|
201
|
-
if (!element) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const selectedOverlay = selectElement(element);
|
|
205
|
-
layerController.attachToOverlay(selectedOverlay, element);
|
|
206
|
-
};
|
|
207
|
-
// Unselect the current element
|
|
208
|
-
const unselectElement = () => {
|
|
209
|
-
clearSelectedOverlays();
|
|
210
|
-
selectedElementId = null;
|
|
211
|
-
};
|
|
212
|
-
const updateElementClassesAndReposition = (visualSelectorId, classes) => {
|
|
213
|
-
const elements = findElementsById(visualSelectorId);
|
|
214
|
-
if (elements.length === 0)
|
|
215
|
-
return;
|
|
216
|
-
updateElementClasses(elements, classes);
|
|
217
|
-
// Use a small delay to allow the browser to recalculate layout before repositioning
|
|
218
|
-
setTimeout(() => {
|
|
219
|
-
// Reposition selected overlays
|
|
220
|
-
if (selectedElementId === visualSelectorId) {
|
|
221
|
-
selectedOverlays.forEach((overlay, index) => {
|
|
222
|
-
if (index < elements.length) {
|
|
223
|
-
positionOverlay(overlay, elements[index]);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
// Reposition hover overlays if needed
|
|
228
|
-
if (currentHighlightedElements.length > 0) {
|
|
229
|
-
const hoveredElement = currentHighlightedElements[0];
|
|
230
|
-
const hoveredId = hoveredElement?.dataset?.visualSelectorId;
|
|
231
|
-
if (hoveredId === visualSelectorId) {
|
|
232
|
-
hoverOverlays.forEach((overlay, index) => {
|
|
233
|
-
if (index < currentHighlightedElements.length) {
|
|
234
|
-
positionOverlay(overlay, currentHighlightedElements[index]);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}, 50);
|
|
240
|
-
};
|
|
241
|
-
// Update element content by visual selector ID
|
|
242
|
-
const updateElementContent = (visualSelectorId, content) => {
|
|
243
|
-
const elements = findElementsById(visualSelectorId);
|
|
244
|
-
if (elements.length === 0) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
elements.forEach((element) => {
|
|
248
|
-
element.innerText = content;
|
|
249
|
-
});
|
|
250
|
-
setTimeout(() => {
|
|
251
|
-
if (selectedElementId === visualSelectorId) {
|
|
252
|
-
selectedOverlays.forEach((overlay, index) => {
|
|
253
|
-
if (index < elements.length) {
|
|
254
|
-
positionOverlay(overlay, elements[index]);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
}, 50);
|
|
259
|
-
};
|
|
260
|
-
// --- Layer dropdown controller ---
|
|
261
|
-
const layerController = createLayerController({
|
|
262
|
-
createPreviewOverlay: (element) => {
|
|
263
|
-
const overlay = createOverlay(false);
|
|
264
|
-
overlay.style.zIndex = "9998";
|
|
265
|
-
document.body.appendChild(overlay);
|
|
266
|
-
positionOverlay(overlay, element);
|
|
267
|
-
return overlay;
|
|
268
|
-
},
|
|
269
|
-
getSelectedElementId: () => selectedElementId,
|
|
270
|
-
selectElement,
|
|
271
|
-
onDeselect: unSelectElement,
|
|
272
|
-
});
|
|
273
|
-
// Toggle visual edit mode
|
|
274
|
-
const toggleVisualEditMode = (isEnabled) => {
|
|
275
|
-
isVisualEditMode = isEnabled;
|
|
276
|
-
if (!isEnabled) {
|
|
277
|
-
layerController.cleanup();
|
|
278
|
-
clearHoverOverlays();
|
|
279
|
-
clearSelectedOverlays();
|
|
280
|
-
currentHighlightedElements = [];
|
|
281
|
-
selectedElementId = null;
|
|
282
|
-
document.body.style.cursor = "default";
|
|
283
|
-
document.removeEventListener("mouseover", handleMouseOver);
|
|
284
|
-
document.removeEventListener("mouseout", handleMouseOut);
|
|
285
|
-
document.removeEventListener("click", handleElementClick, true);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
document.body.style.cursor = "crosshair";
|
|
289
|
-
document.addEventListener("mouseover", handleMouseOver);
|
|
290
|
-
document.addEventListener("mouseout", handleMouseOut);
|
|
291
|
-
document.addEventListener("click", handleElementClick, true);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
// Handle scroll events to update popover position
|
|
295
|
-
const handleScroll = () => {
|
|
296
|
-
if (selectedElementId) {
|
|
297
|
-
const elements = findElementsById(selectedElementId);
|
|
298
|
-
if (elements.length > 0) {
|
|
299
|
-
const element = elements[0];
|
|
300
|
-
const rect = element.getBoundingClientRect();
|
|
301
|
-
const viewportHeight = window.innerHeight;
|
|
302
|
-
const viewportWidth = window.innerWidth;
|
|
303
|
-
const isInViewport = rect.top < viewportHeight &&
|
|
304
|
-
rect.bottom > 0 &&
|
|
305
|
-
rect.left < viewportWidth &&
|
|
306
|
-
rect.right > 0;
|
|
307
|
-
const elementPosition = {
|
|
308
|
-
top: rect.top,
|
|
309
|
-
left: rect.left,
|
|
310
|
-
right: rect.right,
|
|
311
|
-
bottom: rect.bottom,
|
|
312
|
-
width: rect.width,
|
|
313
|
-
height: rect.height,
|
|
314
|
-
centerX: rect.left + rect.width / 2,
|
|
315
|
-
centerY: rect.top + rect.height / 2,
|
|
316
|
-
};
|
|
317
|
-
window.parent.postMessage({
|
|
318
|
-
type: "element-position-update",
|
|
319
|
-
position: elementPosition,
|
|
320
|
-
isInViewport: isInViewport,
|
|
321
|
-
visualSelectorId: selectedElementId,
|
|
322
|
-
}, "*");
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
// Handle messages from parent window
|
|
327
|
-
const handleMessage = (event) => {
|
|
328
|
-
const message = event.data;
|
|
329
|
-
switch (message.type) {
|
|
330
|
-
case "toggle-visual-edit-mode":
|
|
331
|
-
toggleVisualEditMode(message.data.enabled);
|
|
332
|
-
break;
|
|
333
|
-
case "update-classes":
|
|
334
|
-
if (message.data && message.data.classes !== undefined) {
|
|
335
|
-
updateElementClassesAndReposition(message.data.visualSelectorId, message.data.classes);
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
console.warn("[VisualEditAgent] Invalid update-classes message:", message);
|
|
339
|
-
}
|
|
340
|
-
break;
|
|
341
|
-
case "unselect-element":
|
|
342
|
-
unselectElement();
|
|
343
|
-
break;
|
|
344
|
-
case "refresh-page":
|
|
345
|
-
window.location.reload();
|
|
346
|
-
break;
|
|
347
|
-
case "update-content":
|
|
348
|
-
if (message.data && message.data.content !== undefined) {
|
|
349
|
-
updateElementContent(message.data.visualSelectorId, message.data.content);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
console.warn("[VisualEditAgent] Invalid update-content message:", message);
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
case "request-element-position":
|
|
356
|
-
if (selectedElementId) {
|
|
357
|
-
const elements = findElementsById(selectedElementId);
|
|
358
|
-
if (elements.length > 0) {
|
|
359
|
-
const element = elements[0];
|
|
360
|
-
const rect = element.getBoundingClientRect();
|
|
361
|
-
const viewportHeight = window.innerHeight;
|
|
362
|
-
const viewportWidth = window.innerWidth;
|
|
363
|
-
const isInViewport = rect.top < viewportHeight &&
|
|
364
|
-
rect.bottom > 0 &&
|
|
365
|
-
rect.left < viewportWidth &&
|
|
366
|
-
rect.right > 0;
|
|
367
|
-
const elementPosition = {
|
|
368
|
-
top: rect.top,
|
|
369
|
-
left: rect.left,
|
|
370
|
-
right: rect.right,
|
|
371
|
-
bottom: rect.bottom,
|
|
372
|
-
width: rect.width,
|
|
373
|
-
height: rect.height,
|
|
374
|
-
centerX: rect.left + rect.width / 2,
|
|
375
|
-
centerY: rect.top + rect.height / 2,
|
|
376
|
-
};
|
|
377
|
-
window.parent.postMessage({
|
|
378
|
-
type: "element-position-update",
|
|
379
|
-
position: elementPosition,
|
|
380
|
-
isInViewport: isInViewport,
|
|
381
|
-
visualSelectorId: selectedElementId,
|
|
382
|
-
}, "*");
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
break;
|
|
386
|
-
case "popover-drag-state":
|
|
387
|
-
if (message.data && message.data.isDragging !== undefined) {
|
|
388
|
-
isPopoverDragging = message.data.isDragging;
|
|
389
|
-
if (message.data.isDragging) {
|
|
390
|
-
clearHoverOverlays();
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
break;
|
|
394
|
-
case "dropdown-state":
|
|
395
|
-
if (message.data && message.data.isOpen !== undefined) {
|
|
396
|
-
isDropdownOpen = message.data.isOpen;
|
|
397
|
-
if (message.data.isOpen) {
|
|
398
|
-
clearHoverOverlays();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
break;
|
|
402
|
-
default:
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
// Handle window resize to reposition overlays
|
|
407
|
-
const handleResize = () => {
|
|
408
|
-
if (selectedElementId) {
|
|
409
|
-
const elements = findElementsById(selectedElementId);
|
|
410
|
-
selectedOverlays.forEach((overlay, index) => {
|
|
411
|
-
if (index < elements.length) {
|
|
412
|
-
positionOverlay(overlay, elements[index]);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
if (currentHighlightedElements.length > 0) {
|
|
417
|
-
hoverOverlays.forEach((overlay, index) => {
|
|
418
|
-
if (index < currentHighlightedElements.length) {
|
|
419
|
-
positionOverlay(overlay, currentHighlightedElements[index]);
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
// Initialize: Add IDs to elements that don't have them but have linenumbers
|
|
425
|
-
const elementsWithLineNumber = document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])");
|
|
426
|
-
elementsWithLineNumber.forEach((el, index) => {
|
|
427
|
-
const htmlEl = el;
|
|
428
|
-
const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;
|
|
429
|
-
htmlEl.dataset.visualSelectorId = id;
|
|
430
|
-
});
|
|
431
|
-
// Create mutation observer to detect layout changes
|
|
432
|
-
const mutationObserver = new MutationObserver((mutations) => {
|
|
433
|
-
const needsUpdate = mutations.some((mutation) => {
|
|
434
|
-
const hasVisualId = (node) => {
|
|
435
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
436
|
-
const el = node;
|
|
437
|
-
if (el.dataset && el.dataset.visualSelectorId) {
|
|
438
|
-
return true;
|
|
439
|
-
}
|
|
440
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
441
|
-
if (hasVisualId(el.children[i])) {
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
return false;
|
|
447
|
-
};
|
|
448
|
-
const isLayoutChange = mutation.type === "attributes" &&
|
|
449
|
-
(mutation.attributeName === "style" ||
|
|
450
|
-
mutation.attributeName === "class" ||
|
|
451
|
-
mutation.attributeName === "width" ||
|
|
452
|
-
mutation.attributeName === "height");
|
|
453
|
-
return isLayoutChange && hasVisualId(mutation.target);
|
|
454
|
-
});
|
|
455
|
-
if (needsUpdate) {
|
|
456
|
-
setTimeout(handleResize, 50);
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
// Set up event listeners
|
|
460
|
-
window.addEventListener("message", handleMessage);
|
|
461
|
-
window.addEventListener("scroll", handleScroll, true);
|
|
462
|
-
document.addEventListener("scroll", handleScroll, true);
|
|
463
|
-
window.addEventListener("resize", handleResize);
|
|
464
|
-
window.addEventListener("scroll", handleResize);
|
|
465
|
-
// Start observing DOM mutations
|
|
466
|
-
mutationObserver.observe(document.body, {
|
|
467
|
-
attributes: true,
|
|
468
|
-
childList: true,
|
|
469
|
-
subtree: true,
|
|
470
|
-
attributeFilter: ["style", "class", "width", "height"],
|
|
471
|
-
});
|
|
472
|
-
// Send ready message to parent
|
|
473
|
-
window.parent.postMessage({ type: "visual-edit-agent-ready" }, "*");
|
|
474
|
-
}
|
|
1
|
+
export { setupVisualEditAgent } from "./visual-edit-agent/index.js";
|
|
475
2
|
//# sourceMappingURL=visual-edit-agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-edit-agent.js","sourceRoot":"","sources":["../../src/injections/visual-edit-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,UAAU,oBAAoB;IAClC,oDAAoD;IACpD,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,aAAa,GAAqB,EAAE,CAAC;IACzC,IAAI,gBAAgB,GAAqB,EAAE,CAAC;IAC5C,IAAI,0BAA0B,GAAc,EAAE,CAAC;IAC/C,IAAI,iBAAiB,GAAkB,IAAI,CAAC;IAE5C,yBAAyB;IACzB,MAAM,aAAa,GAAG,CAAC,UAAU,GA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IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAChD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAEhD,gCAAgC;IAChC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;QACtC,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;KACvD,CAAC,CAAC;IAEH,+BAA+B;IAC/B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC"}
|
|
1
|
+
{"version":3,"file":"visual-edit-agent.js","sourceRoot":"","sources":["../../src/injections/visual-edit-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/statics/index.mjs
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
function A(t){let r=t;return!!(r.dataset?.sourceLocation||r.dataset?.visualSelectorId)}function y(t){let r=t;return r.dataset?.sourceLocation||r.dataset?.visualSelectorId||null}function w(t){if(!t)return[];let r=Array.from(document.querySelectorAll(`[data-source-location="${t}"]`));return r.length>0?r:Array.from(document.querySelectorAll(`[data-visual-selector-id="${t}"]`))}function $(t,r){t.forEach(l=>{l.setAttribute("class",r)})}var Y={position:"absolute",backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",fontSize:"12px",minWidth:"120px",maxHeight:"200px",overflowY:"auto",zIndex:"10001",padding:"4px 0",pointerEvents:"auto"},X={padding:"4px 12px",cursor:"pointer",color:"#334155",backgroundColor:"transparent",whiteSpace:"nowrap",lineHeight:"1.5",fontWeight:"400"},_="#526cff",G="#DBEAFE",z="600",R="#f1f5f9",F=10,k=" \u25BE",C="data-layer-dropdown",q=2,K=2;function W(t,r){Object.assign(t.style,r)}function j(t){return t.tagName}function de(t,r){let l=[];function d(m,a){if(!(a>r))for(let s=0;s<m.children.length;s++){let i=m.children[s];A(i)?(l.push({element:i,tagName:i.tagName.toLowerCase(),selectorId:y(i)}),d(i,a+1)):d(i,a)}}return d(t,1),l}function U(t,r){let l={element:t,tagName:t.tagName.toLowerCase(),selectorId:y(t)};return r!==void 0&&(l.depth=r),l}function ce(t){let r=[],l=t.parentElement;for(;l&&l!==document.documentElement&&l!==document.body&&r.length<q;)A(l)&&r.push(U(l)),l=l.parentElement;return r.reverse(),r}function ue(t,r){return r.forEach((l,d)=>{t.push({...l,depth:d})}),r.length}function me(t,r,l){t.push(U(r,l));let d=de(r,K);pe(r,d,l+1),t.push(...d)}function J(t){let r=ce(t),l=[],d=ue(l,r);return me(l,t,d),l}function pe(t,r,l){let d=new Set(r.map(s=>s.element)),m=new Map(r.map(s=>[s.element,s]));function a(s,i){for(let E=0;E<s.children.length;E++){let u=s.children[E];d.has(u)?(m.get(u).depth=l+i-1,a(u,i+1)):a(u,i)}}a(t,1)}var O=null,M=null,S=null,x=null;function fe(t,r,l,d,m){let a=document.createElement("div");a.textContent=j(t),W(a,X);let s=t.depth??0;return s>0&&(a.style.paddingLeft=`${12+s*F}px`),r&&(a.style.color=_,a.style.backgroundColor=G,a.style.fontWeight=z),a.addEventListener("mouseenter",()=>{r||(a.style.backgroundColor=R),d&&d(t)}),a.addEventListener("mouseleave",()=>{r||(a.style.backgroundColor="transparent"),m&&m()}),a.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),l(t)}),a}function Ee(t,r,l,d,m){let a=document.createElement("div");return a.setAttribute(C,"true"),W(a,Y),t.forEach(s=>{let i=s.selectorId===r;a.appendChild(fe(s,i,l,d,m))}),a}function Q(t){t.textContent?.includes(k)||(t.textContent=t.textContent+k,t.style.cursor="pointer",t.style.userSelect="none",t.style.pointerEvents="auto",t.setAttribute(C,"true"))}function ge(t,r,l,d,m,a){let s=Array.from(t.children),i=r.findIndex(u=>u.selectorId===l),E=u=>{if(i>=0&&i<s.length){let g=s[i];g.style.color!==_&&(g.style.backgroundColor="transparent")}if(i=u,i>=0&&i<s.length){let g=s[i];g.style.color!==_&&(g.style.backgroundColor=R),g.scrollIntoView({block:"nearest"}),m&&m(r[i])}};x=u=>{u.key==="ArrowDown"?(u.preventDefault(),u.stopPropagation(),E(i<s.length-1?i+1:0)):u.key==="ArrowUp"?(u.preventDefault(),u.stopPropagation(),E(i>0?i-1:s.length-1)):u.key==="Enter"&&i>=0&&(u.preventDefault(),u.stopPropagation(),a&&a(),d(r[i]),L())},document.addEventListener("keydown",x,!0)}function he(t,r){setTimeout(()=>{M=l=>{let d=l.target;!t.contains(d)&&d!==r&&L()},document.addEventListener("mousedown",M,!0)},0)}function Z(t,r,l,d,m,a){L();let s=Ee(r,l,E=>{a&&a(),d(E),L()},m,a),i=t.parentElement;i&&(s.style.top=`${t.offsetTop+t.offsetHeight+2}px`,s.style.left=`${t.offsetLeft}px`,i.appendChild(s),O=s,S=a??null,ge(s,r,l,d,m,a),he(s,t))}function L(){S&&(S(),S=null),O&&O.parentNode&&O.remove(),O=null,M&&(document.removeEventListener("mousedown",M,!0),M=null),x&&(document.removeEventListener("keydown",x,!0),x=null)}function ee(){return O!==null}function te(t){let r=null,l=null,d=null,m=()=>{r&&r.parentNode&&r.remove(),r=null},a=g=>{m(),y(g.element)!==t.getSelectedElementId()&&(r=t.createPreviewOverlay(g.element))},s=g=>{m(),L(),l&&(document.removeEventListener("keydown",l,!0),l=null),d=null;let I=t.selectElement(g.element);E(I,g.element)},i=()=>{l&&(document.removeEventListener("keydown",l,!0),l=null),d&&(s({element:d,tagName:d.tagName.toLowerCase(),selectorId:y(d)}),d=null)},E=(g,I)=>{if(!g)return;let D=g.querySelector("div");if(!D)return;let N=J(I);if(N.length<=1)return;let H=y(I);Q(D),D.addEventListener("click",b=>{b.stopPropagation(),b.preventDefault(),ee()?(L(),i()):(d=I,t.onDeselect(),l=T=>{T.key==="Escape"&&(T.stopPropagation(),L(),i())},document.addEventListener("keydown",l,!0),Z(D,N,H,s,a,m))})};return{attachToOverlay:E,cleanup:()=>{m(),L()}}}function ye(){let t=!1,r=!1,l=!1,d=[],m=[],a=[],s=null,i=(o=!1)=>{let e=document.createElement("div");return e.style.position="absolute",e.style.pointerEvents="none",e.style.transition="all 0.1s ease-in-out",e.style.zIndex="9999",o?e.style.border="2px solid #2563EB":(e.style.border="2px solid #95a5fc",e.style.backgroundColor="rgba(99, 102, 241, 0.05)"),e},E=(o,e,n=!1)=>{if(!e||!t)return;e.offsetWidth;let c=e.getBoundingClientRect();o.style.top=`${c.top+window.scrollY}px`,o.style.left=`${c.left+window.scrollX}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`;let p=o.querySelector("div");p||(p=document.createElement("div"),p.textContent=e.tagName.toLowerCase(),p.style.position="absolute",p.style.top="-27px",p.style.left="-2px",p.style.padding="2px 8px",p.style.fontSize="11px",p.style.fontWeight=n?"500":"400",p.style.color=n?"#ffffff":"#526cff",p.style.backgroundColor=n?"#526cff":"#DBEAFE",p.style.borderRadius="3px",p.style.minWidth="24px",p.style.textAlign="center",o.appendChild(p))},u=()=>{d.forEach(o=>{o&&o.parentNode&&o.remove()}),d=[],a=[]},g=()=>{m.forEach(o=>{o&&o.parentNode&&o.remove()}),m=[]},I=o=>{let e=o,n=o.getBoundingClientRect(),f=o;window.parent.postMessage({type:"element-selected",tagName:o.tagName,classes:f.className?.baseVal||o.className||"",visualSelectorId:y(o),content:e.innerText,dataSourceLocation:e.dataset.sourceLocation,isDynamicContent:e.dataset.dynamicContent==="true",linenumber:e.dataset.linenumber,filename:e.dataset.filename,position:{top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,centerX:n.left+n.width/2,centerY:n.top+n.height/2}},"*")},D=o=>{let e=y(o);return g(),w(e||null).forEach(f=>{let c=i(!0);document.body.appendChild(c),m.push(c),E(c,f,!0)}),s=e||null,u(),I(o),m[0]},N=()=>{s=null,window.parent.postMessage({type:"unselect-element"},"*")},H=o=>{if(!t||r)return;let e=o.target;if(l){u();return}if(e.tagName.toLowerCase()==="path"){u();return}let n=e.closest("[data-source-location], [data-visual-selector-id]");if(!n){u();return}let f=n,c=f.dataset.sourceLocation||f.dataset.visualSelectorId;if(s===c){u();return}let p=w(c||null);u(),p.forEach(h=>{let v=i(!1);document.body.appendChild(v),d.push(v),E(v,h)}),a=p},b=()=>{r||u()},T=o=>{if(!t)return;let e=o.target;if(e.closest(`[${C}]`))return;if(l){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}if(e.tagName.toLowerCase()==="path")return;o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation();let n=e.closest("[data-source-location], [data-visual-selector-id]");if(!n)return;let f=D(n);V.attachToOverlay(f,n)},ne=()=>{g(),s=null},oe=(o,e)=>{let n=w(o);n.length!==0&&($(n,e),setTimeout(()=>{s===o&&m.forEach((f,c)=>{c<n.length&&E(f,n[c])}),a.length>0&&a[0]?.dataset?.visualSelectorId===o&&d.forEach((p,h)=>{h<a.length&&E(p,a[h])})},50))},re=(o,e)=>{let n=w(o);n.length!==0&&(n.forEach(f=>{f.innerText=e}),setTimeout(()=>{s===o&&m.forEach((f,c)=>{c<n.length&&E(f,n[c])})},50))},V=te({createPreviewOverlay:o=>{let e=i(!1);return e.style.zIndex="9998",document.body.appendChild(e),E(e,o),e},getSelectedElementId:()=>s,selectElement:D,onDeselect:N}),se=o=>{t=o,o?(document.body.style.cursor="crosshair",document.addEventListener("mouseover",H),document.addEventListener("mouseout",b),document.addEventListener("click",T,!0)):(V.cleanup(),u(),g(),a=[],s=null,document.body.style.cursor="default",document.removeEventListener("mouseover",H),document.removeEventListener("mouseout",b),document.removeEventListener("click",T,!0))},B=()=>{if(s){let o=w(s);if(o.length>0){let n=o[0].getBoundingClientRect(),f=window.innerHeight,c=window.innerWidth,p=n.top<f&&n.bottom>0&&n.left<c&&n.right>0,h={top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,centerX:n.left+n.width/2,centerY:n.top+n.height/2};window.parent.postMessage({type:"element-position-update",position:h,isInViewport:p,visualSelectorId:s},"*")}}},le=o=>{let e=o.data;switch(e.type){case"toggle-visual-edit-mode":se(e.data.enabled);break;case"update-classes":e.data&&e.data.classes!==void 0?oe(e.data.visualSelectorId,e.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",e);break;case"unselect-element":ne();break;case"refresh-page":window.location.reload();break;case"update-content":e.data&&e.data.content!==void 0?re(e.data.visualSelectorId,e.data.content):console.warn("[VisualEditAgent] Invalid update-content message:",e);break;case"request-element-position":if(s){let n=w(s);if(n.length>0){let c=n[0].getBoundingClientRect(),p=window.innerHeight,h=window.innerWidth,v=c.top<p&&c.bottom>0&&c.left<h&&c.right>0,ie={top:c.top,left:c.left,right:c.right,bottom:c.bottom,width:c.width,height:c.height,centerX:c.left+c.width/2,centerY:c.top+c.height/2};window.parent.postMessage({type:"element-position-update",position:ie,isInViewport:v,visualSelectorId:s},"*")}}break;case"popover-drag-state":e.data&&e.data.isDragging!==void 0&&(r=e.data.isDragging,e.data.isDragging&&u());break;case"dropdown-state":e.data&&e.data.isOpen!==void 0&&(l=e.data.isOpen,e.data.isOpen&&u());break;default:break}},P=()=>{if(s){let o=w(s);m.forEach((e,n)=>{n<o.length&&E(e,o[n])})}a.length>0&&d.forEach((o,e)=>{e<a.length&&E(o,a[e])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((o,e)=>{let n=o,f=`visual-id-${n.dataset.filename}-${n.dataset.linenumber}-${e}`;n.dataset.visualSelectorId=f});let ae=new MutationObserver(o=>{o.some(n=>{let f=p=>{if(p.nodeType===Node.ELEMENT_NODE){let h=p;if(h.dataset&&h.dataset.visualSelectorId)return!0;for(let v=0;v<h.children.length;v++)if(f(h.children[v]))return!0}return!1};return n.type==="attributes"&&(n.attributeName==="style"||n.attributeName==="class"||n.attributeName==="width"||n.attributeName==="height")&&f(n.target)})&&setTimeout(P,50)});window.addEventListener("message",le),window.addEventListener("scroll",B,!0),document.addEventListener("scroll",B,!0),window.addEventListener("resize",P),window.addEventListener("scroll",P),ae.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{ye as setupVisualEditAgent};
|
|
1
|
+
function R(){return{isVisualEditMode:!1,isPopoverDragging:!1,isDropdownOpen:!1,hoverOverlays:[],selectedOverlays:[],currentHighlightedElements:[],selectedElementId:null,currentEditingElement:null,debouncedSendTimeout:null,isInlineEditExperimentEnabled:!1}}function l(e){if(!e)return[];let t=Array.from(document.querySelectorAll(`[data-source-location="${e}"]`));return t.length>0?t:Array.from(document.querySelectorAll(`[data-visual-selector-id="${e}"]`))}function P(e,t){e.forEach(n=>{n.setAttribute("class",t)})}var H="all 0.1s ease-in-out",V="9999",U="#2563EB",G="#95a5fc",B="rgba(99, 102, 241, 0.05)",k="-27px",F="-2px";function f(e=!1){let t=document.createElement("div");return t.style.position="absolute",t.style.pointerEvents="none",t.style.transition=H,t.style.zIndex=V,e?t.style.border=`2px solid ${U}`:(t.style.border=`2px solid ${G}`,t.style.backgroundColor=B),t}function c(e,t,n=!1,o=!0){if(!t||!o)return;let r=t.getBoundingClientRect();e.style.top=`${r.top+window.scrollY}px`,e.style.left=`${r.left+window.scrollX}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`;let i=e.querySelector("div");i||(i=document.createElement("div"),i.textContent=t.tagName.toLowerCase(),i.style.position="absolute",i.style.top=k,i.style.left=F,i.style.padding="2px 8px",i.style.fontSize="11px",i.style.fontWeight=n?"500":"400",i.style.color=n?"#ffffff":"#526cff",i.style.backgroundColor=n?"#526cff":"#DBEAFE",i.style.borderRadius="3px",i.style.minWidth="24px",i.style.textAlign="center",e.appendChild(i))}function h(e){e.forEach(t=>{t&&t.parentNode&&t.remove()})}function u(e){e.selectedElementId&&l(e.selectedElementId).forEach(n=>{n instanceof HTMLElement&&delete n.dataset.selected}),h(e.selectedOverlays),e.selectedOverlays=[],e.selectedElementId=null}function E(e){if(!e.selectedElementId)return;let t=l(e.selectedElementId);e.selectedOverlays.forEach((n,o)=>{o<t.length&&c(n,t[o],!0,e.isVisualEditMode)})}function O(e){e.hoverOverlays.forEach((t,n)=>{n<e.currentHighlightedElements.length&&c(t,e.currentHighlightedElements[n],!1,e.isVisualEditMode)})}function a(e){h(e.hoverOverlays),e.hoverOverlays=[],e.currentHighlightedElements=[]}function j(e,t){if(!e.isVisualEditMode||e.isPopoverDragging||e.currentEditingElement)return;let n=t.target;if(e.isDropdownOpen){a(e);return}if(n.tagName.toLowerCase()==="path"){a(e);return}let o=n.closest("[data-source-location], [data-visual-selector-id]");if(!o){a(e);return}let r=o,i=r.dataset.sourceLocation||r.dataset.visualSelectorId;if(e.selectedElementId===i){a(e);return}let s=l(i||null);a(e),s.forEach(g=>{let S=f(!1);document.body.appendChild(S),e.hoverOverlays.push(S),c(S,g,!1,e.isVisualEditMode)}),e.currentHighlightedElements=s}function Y(e){e.isPopoverDragging||e.currentEditingElement||a(e)}function y(){if(document.getElementById("visual-edit-focus-styles"))return;let t=document.createElement("style");t.id="visual-edit-focus-styles",t.textContent=`
|
|
2
|
+
[data-selected="true"][contenteditable="true"]:focus {
|
|
3
|
+
outline: none !important;
|
|
4
|
+
}
|
|
5
|
+
`,document.head.appendChild(t)}function M(){let e=document.getElementById("visual-edit-focus-styles");e&&e.remove()}function L(e){let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function b(e){return!(!(e instanceof HTMLElement)||!["div","p","h1","h2","h3","h4","h5","h6","span","li","td","a","button","label"].includes(e.tagName.toLowerCase())||(e.textContent?.trim()||"").length===0||e.querySelector("img, video, canvas, svg")!==null||e.children.length>0||e.dataset.dynamicContent==="true")}var x=null;function A(e){x=e}function $(e){x&&x(this)}function p(e){return!(!(e instanceof HTMLElement)||e.dataset.selected!=="true"||!b(e))}function _(e){y(),e.dataset.originalTextContent=e.textContent||"",e.dataset.originalCursor=e.style.cursor,e.contentEditable="true",e.addEventListener("input",$),e.style.cursor="text",L(e),setTimeout(()=>{e.focus()},0)}function C(e){M(),e.removeEventListener("input",$),e.contentEditable="false",delete e.dataset.originalTextContent,e.dataset.originalCursor!==void 0&&(e.style.cursor=e.dataset.originalCursor,delete e.dataset.originalCursor)}function m(e){return{top:e.top,left:e.left,right:e.right,bottom:e.bottom,width:e.width,height:e.height,centerX:e.left+e.width/2,centerY:e.top+e.height/2}}function W(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function T(e){return e instanceof SVGElement?e.className?.baseVal||"":e.className||""}function v(e,t){e.currentEditingElement=t,e.selectedOverlays.forEach(n=>{n.style.display="none"}),_(t),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.selectedElementId},"*")}function d(e){if(!e.currentEditingElement)return;e.debouncedSendTimeout&&(clearTimeout(e.debouncedSendTimeout),e.debouncedSendTimeout=null);let t=e.currentEditingElement;C(t),e.selectedOverlays.forEach(n=>{n.style.display=""}),E(e),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.selectedElementId},"*"),e.currentEditingElement=null}function ne(e,t){let n=t.dataset.originalTextContent,o=t.textContent,r={tagName:t.tagName,classes:T(t),visualSelectorId:e.selectedElementId,content:o,dataSourceLocation:t.dataset.sourceLocation,isDynamicContent:t.dataset.dynamicContent==="true",linenumber:t.dataset.linenumber,filename:t.dataset.filename,position:m(t.getBoundingClientRect())};window.parent.postMessage({type:"inline-edit",elementInfo:r,originalContent:n,newContent:o},"*"),t.dataset.originalTextContent=o||""}function oe(e,t){e.debouncedSendTimeout&&clearTimeout(e.debouncedSendTimeout),e.debouncedSendTimeout=setTimeout(()=>{ne(e,t)},500)}function ie(e){return t=>{E(e),oe(e,t)}}function q(e){A(ie(e))}function N(e,t,n){e.currentEditingElement&&d(e),u(e);let o=l(n);o.forEach(s=>{s instanceof HTMLElement&&(s.dataset.selected="true")}),o.forEach(s=>{let g=f(!0);document.body.appendChild(g),e.selectedOverlays.push(g),c(g,s,!0,e.isVisualEditMode)}),e.selectedElementId=n,a(e);let r=t,i={type:"element-selected",tagName:t.tagName,classes:T(t),visualSelectorId:n,content:r.innerText,dataSourceLocation:r.dataset.sourceLocation,isDynamicContent:r.dataset.dynamicContent==="true",linenumber:r.dataset.linenumber,filename:r.dataset.filename,position:m(t.getBoundingClientRect())};window.parent.postMessage(i,"*")}function z(e,t){if(!e.isVisualEditMode)return;let n=t.target;if(n instanceof HTMLElement&&n.contentEditable==="true")return;if(e.currentEditingElement){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),d(e);return}if(e.isDropdownOpen){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}if(n.tagName.toLowerCase()==="path")return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();let o=n.closest("[data-source-location], [data-visual-selector-id]");if(!o)return;let r=o,i=r.dataset.sourceLocation||r.dataset.visualSelectorId;if(e.selectedElementId===i&&r.dataset.selected==="true"&&e.isInlineEditExperimentEnabled&&p(r)){v(e,r);return}N(e,o,i||null)}function re(e,t){e.isVisualEditMode=t,t?document.body.style.cursor="crosshair":(e.currentEditingElement&&d(e),a(e),u(e),e.currentHighlightedElements=[],document.body.style.cursor="default")}function X(e,t){re(e,t.data.enabled),t.data.specs?.newInlineEditEnabled!==void 0&&(e.isInlineEditExperimentEnabled=t.data.specs.newInlineEditEnabled)}function K(e,t){if(!e.isInlineEditExperimentEnabled){console.log("[VisualEditAgent] toggle-inline-edit-mode ignored - experiment flag not enabled");return}if(console.log("[VisualEditAgent] Processing toggle-inline-edit-mode message"),!t.data||!t.data.dataSourceLocation){console.warn("[VisualEditAgent] Invalid toggle-inline-edit-mode message - missing dataSourceLocation");return}let n=l(t.data.dataSourceLocation);if(n.length===0||!(n[0]instanceof HTMLElement))return;let o=n[0];t.data.inlineEditingMode?p(o)&&(e.selectedElementId!==t.data.dataSourceLocation&&N(e,o,t.data.dataSourceLocation),v(e,o)):e.currentEditingElement===o&&d(e)}function Z(e){if(!e.selectedElementId)return;let t=l(e.selectedElementId),[n]=t;if(!n)return;let o=n.getBoundingClientRect();window.parent.postMessage({type:"element-position-update",position:m(o),isInViewport:W(o),visualSelectorId:e.selectedElementId},"*")}function le(e){e.currentEditingElement&&d(e),u(e)}function ae(e,t,n){let o=l(t);o.length!==0&&(P(o,n),setTimeout(()=>{e.selectedElementId===t&&E(e),e.currentHighlightedElements.length>0&&e.currentHighlightedElements[0]?.dataset?.visualSelectorId===t&&O(e)},50))}function se(e,t,n){let o=l(t);o.length!==0&&(o.forEach(r=>{r.innerText=n}),setTimeout(()=>{e.selectedElementId===t&&E(e)},50))}function w(e){Z(e)}function I(e){E(e),O(e)}function J(e,t){let n=t.data;switch(n.type){case"toggle-visual-edit-mode":X(e,n);break;case"update-classes":n.data&&n.data.classes!==void 0?ae(e,n.data.visualSelectorId,n.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",n);break;case"unselect-element":le(e);break;case"refresh-page":window.location.reload();break;case"update-content":n.data&&n.data.content!==void 0?se(e,n.data.visualSelectorId,n.data.content):console.warn("[VisualEditAgent] Invalid update-content message:",n);break;case"toggle-inline-edit-mode":K(e,n);break;case"request-element-position":Z(e);break;case"popover-drag-state":n.data&&n.data.isDragging!==void 0&&(e.isPopoverDragging=n.data.isDragging,n.data.isDragging&&a(e));break;case"dropdown-state":n.data&&n.data.isOpen!==void 0&&(e.isDropdownOpen=n.data.isOpen,n.data.isOpen&&a(e));break;default:break}}function de(){document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((t,n)=>{let o=t,r=`visual-id-${o.dataset.filename}-${o.dataset.linenumber}-${n}`;o.dataset.visualSelectorId=r})}function Ee(e){let t=null,n=o=>{if(o.nodeType!==Node.ELEMENT_NODE)return!1;let r=o;if(r.dataset?.visualSelectorId)return!0;for(let i=0;i<r.children.length;i++)if(n(r.children[i]))return!0;return!1};return new MutationObserver(o=>{if(t!==null)return;o.some(i=>i.type==="attributes"&&(i.attributeName==="style"||i.attributeName==="class"||i.attributeName==="width"||i.attributeName==="height")&&n(i.target))&&(t=requestAnimationFrame(()=>{t=null,e()}))})}function ce(){document.addEventListener("keydown",e=>{e.target instanceof HTMLElement&&e.target.contentEditable},!0)}function ue(e){window.addEventListener("message",t=>J(e,t)),window.addEventListener("scroll",()=>w(e),!0),document.addEventListener("scroll",()=>w(e),!0),window.addEventListener("resize",()=>I(e)),window.addEventListener("scroll",()=>I(e)),document.addEventListener("click",t=>z(e,t),!0),document.addEventListener("mouseover",t=>j(e,t)),document.addEventListener("mouseout",()=>Y(e))}function ee(){let e=R();de(),q(e),ce(),ue(e),Ee(()=>I(e)).observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{ee as setupVisualEditAgent};
|
|
2
6
|
//# sourceMappingURL=index.mjs.map
|