@base44-preview/vite-plugin 0.3.3-pr.51.d4ba9e8 → 0.3.3-pr.54.d511550
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/layer-dropdown/consts.d.ts +4 -5
- package/dist/injections/layer-dropdown/consts.d.ts.map +1 -1
- package/dist/injections/layer-dropdown/consts.js +4 -5
- package/dist/injections/layer-dropdown/consts.js.map +1 -1
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +1 -1
- package/dist/injections/layer-dropdown/dropdown-ui.js +8 -15
- package/dist/injections/layer-dropdown/dropdown-ui.js.map +1 -1
- package/dist/injections/unhandled-errors-handlers.js +7 -0
- package/dist/injections/unhandled-errors-handlers.js.map +1 -1
- package/dist/injections/utils.d.ts +0 -17
- package/dist/injections/utils.d.ts.map +1 -1
- package/dist/injections/utils.js +0 -36
- package/dist/injections/utils.js.map +1 -1
- package/dist/injections/visual-edit-agent.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent.js +35 -34
- package/dist/injections/visual-edit-agent.js.map +1 -1
- package/dist/statics/index.mjs +4 -4
- package/dist/statics/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/injections/layer-dropdown/consts.ts +4 -6
- package/src/injections/layer-dropdown/dropdown-ui.ts +7 -16
- package/src/injections/unhandled-errors-handlers.ts +7 -0
- package/src/injections/utils.ts +0 -37
- package/src/injections/visual-edit-agent.ts +44 -44
|
@@ -33,12 +33,10 @@ export const DROPDOWN_ITEM_HOVER_BG = "#f1f5f9";
|
|
|
33
33
|
|
|
34
34
|
export const DEPTH_INDENT_PX = 10;
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
export const CHEVRON_COLLAPSED =
|
|
38
|
-
/**
|
|
39
|
-
export const CHEVRON_EXPANDED =
|
|
40
|
-
|
|
41
|
-
export const CHEVRON_ATTR = "data-chevron";
|
|
36
|
+
/** Chevron shown when dropdown is collapsed (click to expand) */
|
|
37
|
+
export const CHEVRON_COLLAPSED = " \u25BE";
|
|
38
|
+
/** Chevron shown when dropdown is expanded (click to collapse) */
|
|
39
|
+
export const CHEVRON_EXPANDED = " \u25B4";
|
|
42
40
|
|
|
43
41
|
export const BASE_PADDING_PX = 12;
|
|
44
42
|
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
BASE_PADDING_PX,
|
|
12
12
|
CHEVRON_COLLAPSED,
|
|
13
13
|
CHEVRON_EXPANDED,
|
|
14
|
-
CHEVRON_ATTR,
|
|
15
14
|
LAYER_DROPDOWN_ATTR,
|
|
16
15
|
} from "./consts.js";
|
|
17
16
|
import { applyStyles, getLayerDisplayName } from "./utils.js";
|
|
@@ -84,16 +83,10 @@ export function createDropdownElement(
|
|
|
84
83
|
|
|
85
84
|
/** Add chevron indicator and pointer-events to the label */
|
|
86
85
|
export function enhanceLabelWithChevron(label: HTMLDivElement): void {
|
|
87
|
-
|
|
86
|
+
const t = label.textContent ?? "";
|
|
87
|
+
if (t.endsWith(CHEVRON_COLLAPSED) || t.endsWith(CHEVRON_EXPANDED)) return;
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
chevron.setAttribute(CHEVRON_ATTR, "true");
|
|
91
|
-
chevron.style.display = "inline-flex";
|
|
92
|
-
chevron.innerHTML = CHEVRON_COLLAPSED;
|
|
93
|
-
label.appendChild(chevron);
|
|
94
|
-
|
|
95
|
-
label.style.display = "inline-flex";
|
|
96
|
-
label.style.alignItems = "center";
|
|
89
|
+
label.textContent = t + CHEVRON_COLLAPSED;
|
|
97
90
|
label.style.cursor = "pointer";
|
|
98
91
|
label.style.userSelect = "none";
|
|
99
92
|
label.style.whiteSpace = "nowrap";
|
|
@@ -197,9 +190,8 @@ export function showDropdown(
|
|
|
197
190
|
overlay.appendChild(dropdown);
|
|
198
191
|
activeDropdown = dropdown;
|
|
199
192
|
activeLabel = label;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
chevronEl.innerHTML = CHEVRON_EXPANDED;
|
|
193
|
+
if (label.textContent?.endsWith(CHEVRON_COLLAPSED.trim())) {
|
|
194
|
+
label.textContent = label.textContent.slice(0, -CHEVRON_COLLAPSED.length) + CHEVRON_EXPANDED;
|
|
203
195
|
}
|
|
204
196
|
activeOnHoverEnd = callbacks.onHoverEnd ?? null;
|
|
205
197
|
|
|
@@ -209,9 +201,8 @@ export function showDropdown(
|
|
|
209
201
|
|
|
210
202
|
/** Close the active dropdown and clean up listeners */
|
|
211
203
|
export function closeDropdown(): void {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
chevronEl.innerHTML = CHEVRON_COLLAPSED;
|
|
204
|
+
if (activeLabel?.textContent?.includes(CHEVRON_EXPANDED)) {
|
|
205
|
+
activeLabel.textContent = activeLabel.textContent.replace(CHEVRON_EXPANDED, CHEVRON_COLLAPSED);
|
|
215
206
|
}
|
|
216
207
|
activeLabel = null;
|
|
217
208
|
|
|
@@ -22,6 +22,13 @@ if (import.meta.hot) {
|
|
|
22
22
|
suppressionTimer = null;
|
|
23
23
|
}, import.meta.env.VITE_HMR_ERROR_SUPPRESSION_DELAY ?? 10000);
|
|
24
24
|
});
|
|
25
|
+
import.meta.hot.on("vite:afterUpdate", () => {
|
|
26
|
+
shouldPropagateErrors = true;
|
|
27
|
+
if (suppressionTimer) {
|
|
28
|
+
clearTimeout(suppressionTimer);
|
|
29
|
+
suppressionTimer = null;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
25
32
|
import.meta.hot.on("vite:beforeFullReload", () => {
|
|
26
33
|
shouldPropagateErrors = false;
|
|
27
34
|
if (suppressionTimer) {
|
package/src/injections/utils.ts
CHANGED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
const LABEL_HEIGHT = 27;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Positions an element-tag label relative to its highlighted overlay.
|
|
5
|
-
*
|
|
6
|
-
* Strategy (in priority order):
|
|
7
|
-
* 1. If the element is near the viewport top AND tall enough (>= 2x label height),
|
|
8
|
-
* place the label **inside** the element at the top-left.
|
|
9
|
-
* 2. If the element is near the viewport top but too short, place the label
|
|
10
|
-
* **below** the element.
|
|
11
|
-
* 3. Otherwise, place the label **above** the element (default).
|
|
12
|
-
*
|
|
13
|
-
* For full-width elements (spanning nearly the entire viewport), the left offset
|
|
14
|
-
* is nudged inward (6px) to prevent clipping against the viewport edge.
|
|
15
|
-
*
|
|
16
|
-
* @param label - The label div to position (style.top and style.left are set).
|
|
17
|
-
* @param rect - The bounding client rect of the highlighted element.
|
|
18
|
-
*/
|
|
19
|
-
export function positionLabel(label: HTMLDivElement, rect: DOMRect): void {
|
|
20
|
-
const nearTop = rect.top < LABEL_HEIGHT;
|
|
21
|
-
const tallEnough = rect.height >= LABEL_HEIGHT * 2;
|
|
22
|
-
const isFullWidth = rect.width >= window.innerWidth - 4;
|
|
23
|
-
const edgeLeft = isFullWidth ? "8px" : "-2px";
|
|
24
|
-
const insideLeft = isFullWidth ? "8px" : "4px";
|
|
25
|
-
|
|
26
|
-
if (nearTop && tallEnough) {
|
|
27
|
-
label.style.top = "2px";
|
|
28
|
-
label.style.left = insideLeft;
|
|
29
|
-
} else if (nearTop) {
|
|
30
|
-
label.style.top = `${rect.height + 2}px`;
|
|
31
|
-
label.style.left = edgeLeft;
|
|
32
|
-
} else {
|
|
33
|
-
label.style.top = `-${LABEL_HEIGHT}px`;
|
|
34
|
-
label.style.left = edgeLeft;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
1
|
/** Check if an element has instrumentation attributes */
|
|
39
2
|
export function isInstrumentedElement(element: Element): boolean {
|
|
40
3
|
const htmlEl = element as HTMLElement;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { findElementsById, updateElementClasses, updateElementAttribute, collectAllowedAttributes, ALLOWED_ATTRIBUTES, getElementSelectorId, stopAnimations, resumeAnimations, findInstrumentedElement, resolveHoverTarget
|
|
1
|
+
import { findElementsById, updateElementClasses, updateElementAttribute, collectAllowedAttributes, ALLOWED_ATTRIBUTES, getElementSelectorId, stopAnimations, resumeAnimations, findInstrumentedElement, resolveHoverTarget } from "./utils.js";
|
|
2
2
|
import { createLayerController } from "./layer-dropdown/controller.js";
|
|
3
3
|
import { LAYER_DROPDOWN_ATTR } from "./layer-dropdown/consts.js";
|
|
4
4
|
import { createInlineEditController } from "../capabilities/inline-edit/index.js";
|
|
5
5
|
|
|
6
|
-
const REPOSITION_DELAY_MS = 50;
|
|
7
|
-
|
|
8
6
|
export function setupVisualEditAgent() {
|
|
9
7
|
// State variables (replacing React useState/useRef)
|
|
10
8
|
let isVisualEditMode = false;
|
|
@@ -14,7 +12,8 @@ export function setupVisualEditAgent() {
|
|
|
14
12
|
let selectedOverlays: HTMLDivElement[] = [];
|
|
15
13
|
let currentHighlightedElements: Element[] = [];
|
|
16
14
|
let selectedElementId: string | null = null;
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
const REPOSITION_DELAY_MS = 50;
|
|
18
17
|
|
|
19
18
|
// Create overlay element
|
|
20
19
|
const createOverlay = (isSelected = false): HTMLDivElement => {
|
|
@@ -59,19 +58,18 @@ export function setupVisualEditAgent() {
|
|
|
59
58
|
label = document.createElement("div");
|
|
60
59
|
label.textContent = element.tagName.toLowerCase();
|
|
61
60
|
label.style.position = "absolute";
|
|
61
|
+
label.style.top = "-27px";
|
|
62
62
|
label.style.left = "-2px";
|
|
63
63
|
label.style.padding = "2px 8px";
|
|
64
64
|
label.style.fontSize = "11px";
|
|
65
65
|
label.style.fontWeight = isSelected ? "500" : "400";
|
|
66
66
|
label.style.color = isSelected ? "#ffffff" : "#526cff";
|
|
67
|
-
label.style.backgroundColor = isSelected ? "#
|
|
67
|
+
label.style.backgroundColor = isSelected ? "#526cff" : "#DBEAFE";
|
|
68
68
|
label.style.borderRadius = "3px";
|
|
69
69
|
label.style.minWidth = "24px";
|
|
70
70
|
label.style.textAlign = "center";
|
|
71
71
|
overlay.appendChild(label);
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
positionLabel(label, rect);
|
|
75
73
|
};
|
|
76
74
|
|
|
77
75
|
// --- Inline edit controller ---
|
|
@@ -84,7 +82,6 @@ export function setupVisualEditAgent() {
|
|
|
84
82
|
inlineEdit.clearSelectedMarks(selectedElementId);
|
|
85
83
|
clearSelectedOverlays();
|
|
86
84
|
selectedElementId = null;
|
|
87
|
-
selectedElement = null;
|
|
88
85
|
},
|
|
89
86
|
createSelectionOverlays: (elements, elementId) => {
|
|
90
87
|
elements.forEach((el) => {
|
|
@@ -101,7 +98,6 @@ export function setupVisualEditAgent() {
|
|
|
101
98
|
inlineEdit.clearSelectedMarks(selectedElementId);
|
|
102
99
|
clearSelectedOverlays();
|
|
103
100
|
selectedElementId = null;
|
|
104
|
-
selectedElement = null;
|
|
105
101
|
};
|
|
106
102
|
|
|
107
103
|
// Clear hover overlays
|
|
@@ -184,7 +180,6 @@ export function setupVisualEditAgent() {
|
|
|
184
180
|
});
|
|
185
181
|
|
|
186
182
|
selectedElementId = visualSelectorId || null;
|
|
187
|
-
selectedElement = element;
|
|
188
183
|
clearHoverOverlays();
|
|
189
184
|
notifyElementSelected(element);
|
|
190
185
|
|
|
@@ -441,9 +436,10 @@ export function setupVisualEditAgent() {
|
|
|
441
436
|
// Handle scroll events to update popover position
|
|
442
437
|
const handleScroll = () => {
|
|
443
438
|
if (selectedElementId) {
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const
|
|
439
|
+
const elements = findElementsById(selectedElementId);
|
|
440
|
+
if (elements.length > 0) {
|
|
441
|
+
const element = elements[0];
|
|
442
|
+
const rect = element!.getBoundingClientRect();
|
|
447
443
|
|
|
448
444
|
const viewportHeight = window.innerHeight;
|
|
449
445
|
const viewportWidth = window.innerWidth;
|
|
@@ -547,37 +543,41 @@ export function setupVisualEditAgent() {
|
|
|
547
543
|
break;
|
|
548
544
|
|
|
549
545
|
case "request-element-position":
|
|
550
|
-
if (selectedElementId
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
546
|
+
if (selectedElementId) {
|
|
547
|
+
const elements = findElementsById(selectedElementId);
|
|
548
|
+
if (elements.length > 0) {
|
|
549
|
+
const element = elements[0];
|
|
550
|
+
const rect = element!.getBoundingClientRect();
|
|
551
|
+
|
|
552
|
+
const viewportHeight = window.innerHeight;
|
|
553
|
+
const viewportWidth = window.innerWidth;
|
|
554
|
+
const isInViewport =
|
|
555
|
+
rect.top < viewportHeight &&
|
|
556
|
+
rect.bottom > 0 &&
|
|
557
|
+
rect.left < viewportWidth &&
|
|
558
|
+
rect.right > 0;
|
|
559
|
+
|
|
560
|
+
const elementPosition = {
|
|
561
|
+
top: rect.top,
|
|
562
|
+
left: rect.left,
|
|
563
|
+
right: rect.right,
|
|
564
|
+
bottom: rect.bottom,
|
|
565
|
+
width: rect.width,
|
|
566
|
+
height: rect.height,
|
|
567
|
+
centerX: rect.left + rect.width / 2,
|
|
568
|
+
centerY: rect.top + rect.height / 2,
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
window.parent.postMessage(
|
|
572
|
+
{
|
|
573
|
+
type: "element-position-update",
|
|
574
|
+
position: elementPosition,
|
|
575
|
+
isInViewport: isInViewport,
|
|
576
|
+
visualSelectorId: selectedElementId,
|
|
577
|
+
},
|
|
578
|
+
"*"
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
581
|
}
|
|
582
582
|
break;
|
|
583
583
|
|