@base44-preview/vite-plugin 0.2.27-pr.41.77be9cb → 0.2.27-pr.44.489d834
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/capabilities/inline-edit/controller.d.ts.map +1 -1
- package/dist/capabilities/inline-edit/controller.js +9 -3
- package/dist/capabilities/inline-edit/controller.js.map +1 -1
- package/dist/capabilities/inline-edit/dom-utils.d.ts +1 -0
- package/dist/capabilities/inline-edit/dom-utils.d.ts.map +1 -1
- package/dist/capabilities/inline-edit/dom-utils.js +17 -7
- package/dist/capabilities/inline-edit/dom-utils.js.map +1 -1
- 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 +576 -1
- package/dist/injections/visual-edit-agent.js.map +1 -1
- package/dist/statics/index.mjs +2 -2
- package/dist/statics/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/inline-edit/controller.ts +35 -29
- package/src/capabilities/inline-edit/dom-utils.ts +14 -4
- package/src/injections/visual-edit-agent.ts +714 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts +0 -25
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js +0 -95
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts +0 -4
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js +0 -4
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts +0 -9
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js +0 -26
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts +0 -17
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js +0 -76
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js.map +0 -1
- package/dist/injections/visual-edit-agent/constants.d.ts +0 -10
- package/dist/injections/visual-edit-agent/constants.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/constants.js +0 -10
- package/dist/injections/visual-edit-agent/constants.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts +0 -10
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js +0 -117
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts +0 -14
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js +0 -64
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts +0 -14
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js +0 -114
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts +0 -26
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js +0 -148
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts +0 -7
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js +0 -54
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts +0 -11
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js +0 -32
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts +0 -105
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/types.js +0 -28
- package/dist/injections/visual-edit-agent/handlers/messages/types.js.map +0 -1
- package/dist/injections/visual-edit-agent/index.d.ts +0 -6
- package/dist/injections/visual-edit-agent/index.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/index.js +0 -109
- package/dist/injections/visual-edit-agent/index.js.map +0 -1
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts +0 -17
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/state/agent-state.js +0 -18
- package/dist/injections/visual-edit-agent/state/agent-state.js.map +0 -1
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts +0 -26
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/ui/overlay.js +0 -104
- package/dist/injections/visual-edit-agent/ui/overlay.js.map +0 -1
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts +0 -14
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/utils/dom-utils.js +0 -34
- package/dist/injections/visual-edit-agent/utils/dom-utils.js.map +0 -1
- package/src/injections/visual-edit-agent/README.md +0 -222
- package/src/injections/visual-edit-agent/capabilities/inline-editing/core.ts +0 -120
- package/src/injections/visual-edit-agent/capabilities/inline-editing/index.ts +0 -10
- package/src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts +0 -26
- package/src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts +0 -87
- package/src/injections/visual-edit-agent/constants.ts +0 -9
- package/src/injections/visual-edit-agent/handlers/click-handlers.ts +0 -146
- package/src/injections/visual-edit-agent/handlers/hover-handlers.ts +0 -78
- package/src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts +0 -146
- package/src/injections/visual-edit-agent/handlers/message-handlers.ts +0 -201
- package/src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts +0 -65
- package/src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts +0 -40
- package/src/injections/visual-edit-agent/handlers/messages/types.ts +0 -134
- package/src/injections/visual-edit-agent/index.ts +0 -121
- package/src/injections/visual-edit-agent/state/agent-state.ts +0 -31
- package/src/injections/visual-edit-agent/ui/overlay.ts +0 -126
- package/src/injections/visual-edit-agent/utils/dom-utils.ts +0 -39
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { createAgentState } from "./state/agent-state.js";
|
|
2
|
-
import { handleMouseOver, handleMouseOut } from "./handlers/hover-handlers.js";
|
|
3
|
-
import { handleElementClick } from "./handlers/click-handlers.js";
|
|
4
|
-
import { handleMessage, handleScroll, handleResize } from "./handlers/message-handlers.js";
|
|
5
|
-
import { setupInlineEditCallback } from "./handlers/inline-edit-handlers.js";
|
|
6
|
-
import { OutgoingMessageType } from "./handlers/messages/types.js";
|
|
7
|
-
/**
|
|
8
|
-
* Initialize element IDs for elements with line numbers
|
|
9
|
-
*/
|
|
10
|
-
function initializeElementIds() {
|
|
11
|
-
const elementsWithLineNumber = document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])");
|
|
12
|
-
elementsWithLineNumber.forEach((el, index) => {
|
|
13
|
-
const htmlEl = el;
|
|
14
|
-
const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;
|
|
15
|
-
htmlEl.dataset.visualSelectorId = id;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Create mutation observer to detect layout changes.
|
|
20
|
-
* Uses requestAnimationFrame to coalesce many rapid mutations into one reposition
|
|
21
|
-
* per paint frame, avoiding stacking multiple timers during CSS transitions.
|
|
22
|
-
*/
|
|
23
|
-
function createLayoutObserver(onLayoutChange) {
|
|
24
|
-
let rafHandle = null;
|
|
25
|
-
const hasVisualId = (node) => {
|
|
26
|
-
if (node.nodeType !== Node.ELEMENT_NODE)
|
|
27
|
-
return false;
|
|
28
|
-
const el = node;
|
|
29
|
-
if (el.dataset?.visualSelectorId)
|
|
30
|
-
return true;
|
|
31
|
-
for (const child of Array.from(el.children)) {
|
|
32
|
-
if (hasVisualId(child))
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
return new MutationObserver((mutations) => {
|
|
38
|
-
if (rafHandle !== null)
|
|
39
|
-
return;
|
|
40
|
-
const needsUpdate = mutations.some((mutation) => {
|
|
41
|
-
const isLayoutChange = mutation.type === "attributes" &&
|
|
42
|
-
(mutation.attributeName === "style" ||
|
|
43
|
-
mutation.attributeName === "class" ||
|
|
44
|
-
mutation.attributeName === "width" ||
|
|
45
|
-
mutation.attributeName === "height");
|
|
46
|
-
return isLayoutChange && hasVisualId(mutation.target);
|
|
47
|
-
});
|
|
48
|
-
if (needsUpdate) {
|
|
49
|
-
// Coalesce rapid mutations into a single reposition per paint frame,
|
|
50
|
-
// avoiding stacked timers during CSS transitions
|
|
51
|
-
rafHandle = requestAnimationFrame(() => {
|
|
52
|
-
rafHandle = null;
|
|
53
|
-
onLayoutChange();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Setup event listeners, returning a function that removes them all.
|
|
60
|
-
*/
|
|
61
|
-
function setupEventListeners(state) {
|
|
62
|
-
const onMessage = (e) => handleMessage(state, e);
|
|
63
|
-
const onScroll = () => handleScroll(state);
|
|
64
|
-
const onResize = () => handleResize(state);
|
|
65
|
-
const onClick = (e) => handleElementClick(state, e);
|
|
66
|
-
const onMouseOver = (e) => handleMouseOver(state, e);
|
|
67
|
-
const onMouseOut = () => handleMouseOut(state);
|
|
68
|
-
window.addEventListener("message", onMessage);
|
|
69
|
-
window.addEventListener("scroll", onScroll, true);
|
|
70
|
-
document.addEventListener("scroll", onScroll, true);
|
|
71
|
-
window.addEventListener("resize", onResize);
|
|
72
|
-
window.addEventListener("scroll", onResize);
|
|
73
|
-
document.addEventListener("click", onClick, true);
|
|
74
|
-
document.addEventListener("mouseover", onMouseOver);
|
|
75
|
-
document.addEventListener("mouseout", onMouseOut);
|
|
76
|
-
return () => {
|
|
77
|
-
window.removeEventListener("message", onMessage);
|
|
78
|
-
window.removeEventListener("scroll", onScroll, true);
|
|
79
|
-
document.removeEventListener("scroll", onScroll, true);
|
|
80
|
-
window.removeEventListener("resize", onResize);
|
|
81
|
-
window.removeEventListener("scroll", onResize);
|
|
82
|
-
document.removeEventListener("click", onClick, true);
|
|
83
|
-
document.removeEventListener("mouseover", onMouseOver);
|
|
84
|
-
document.removeEventListener("mouseout", onMouseOut);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Main setup function for visual edit agent.
|
|
89
|
-
* Returns a teardown function that disconnects the observer and removes all event listeners.
|
|
90
|
-
*/
|
|
91
|
-
export function setupVisualEditAgent() {
|
|
92
|
-
const state = createAgentState();
|
|
93
|
-
initializeElementIds();
|
|
94
|
-
setupInlineEditCallback(state);
|
|
95
|
-
const removeEventListeners = setupEventListeners(state);
|
|
96
|
-
const mutationObserver = createLayoutObserver(() => handleResize(state));
|
|
97
|
-
mutationObserver.observe(document.body, {
|
|
98
|
-
attributes: true,
|
|
99
|
-
childList: true,
|
|
100
|
-
subtree: true,
|
|
101
|
-
attributeFilter: ["style", "class", "width", "height"],
|
|
102
|
-
});
|
|
103
|
-
window.parent.postMessage({ type: OutgoingMessageType.VISUAL_EDIT_AGENT_READY }, "*");
|
|
104
|
-
return () => {
|
|
105
|
-
mutationObserver.disconnect();
|
|
106
|
-
removeEventListeners();
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/injections/visual-edit-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;GAEG;AACH,SAAS,oBAAoB;IAC3B,MAAM,sBAAsB,GAAG,QAAQ,CAAC,gBAAgB,CACtD,kDAAkD,CACnD,CAAC;IACF,sBAAsB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,EAAiB,CAAC;QACjC,MAAM,EAAE,GAAG,aAAa,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK,EAAE,CAAC;QACxF,MAAM,CAAC,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,cAA0B;IACtD,IAAI,SAAS,GAAk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|
-
/**
|
|
2
|
-
* Central state management for the visual edit agent
|
|
3
|
-
*/
|
|
4
|
-
export interface AgentState {
|
|
5
|
-
isVisualEditMode: boolean;
|
|
6
|
-
isPopoverDragging: boolean;
|
|
7
|
-
isDropdownOpen: boolean;
|
|
8
|
-
hoverOverlays: HTMLDivElement[];
|
|
9
|
-
selectedOverlays: HTMLDivElement[];
|
|
10
|
-
currentHighlightedElements: Element[];
|
|
11
|
-
selectedElementId: string | null;
|
|
12
|
-
currentEditingElement: HTMLElement | null;
|
|
13
|
-
debouncedSendTimeout: ReturnType<typeof setTimeout> | null;
|
|
14
|
-
isInlineEditExperimentEnabled: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function createAgentState(): AgentState;
|
|
17
|
-
//# sourceMappingURL=agent-state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-state.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/state/agent-state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,0BAA0B,EAAE,OAAO,EAAE,CAAC;IACtC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,oBAAoB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAC3D,6BAA6B,EAAE,OAAO,CAAC;CACxC;AAED,wBAAgB,gBAAgB,IAAI,UAAU,CAa7C"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Central state management for the visual edit agent
|
|
3
|
-
*/
|
|
4
|
-
export function createAgentState() {
|
|
5
|
-
return {
|
|
6
|
-
isVisualEditMode: false,
|
|
7
|
-
isPopoverDragging: false,
|
|
8
|
-
isDropdownOpen: false,
|
|
9
|
-
hoverOverlays: [],
|
|
10
|
-
selectedOverlays: [],
|
|
11
|
-
currentHighlightedElements: [],
|
|
12
|
-
selectedElementId: null,
|
|
13
|
-
currentEditingElement: null,
|
|
14
|
-
debouncedSendTimeout: null,
|
|
15
|
-
isInlineEditExperimentEnabled: false,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=agent-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-state.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/state/agent-state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,KAAK;QACxB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,EAAE;QACjB,gBAAgB,EAAE,EAAE;QACpB,0BAA0B,EAAE,EAAE;QAC9B,iBAAiB,EAAE,IAAI;QACvB,qBAAqB,EAAE,IAAI;QAC3B,oBAAoB,EAAE,IAAI;QAC1B,6BAA6B,EAAE,KAAK;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { AgentState } from "../state/agent-state.js";
|
|
2
|
-
/**
|
|
3
|
-
* Create an overlay element for highlighting
|
|
4
|
-
*/
|
|
5
|
-
export declare function createOverlay(isSelected?: boolean): HTMLDivElement;
|
|
6
|
-
/**
|
|
7
|
-
* Position overlay relative to element
|
|
8
|
-
*/
|
|
9
|
-
export declare function positionOverlay(overlay: HTMLDivElement, element: Element, isSelected?: boolean, isVisualEditMode?: boolean): void;
|
|
10
|
-
/**
|
|
11
|
-
* Clear all overlays from DOM
|
|
12
|
-
*/
|
|
13
|
-
export declare function clearOverlays(overlays: HTMLDivElement[]): void;
|
|
14
|
-
/**
|
|
15
|
-
* Remove data-selected attribute, clear selected overlays, and reset selection state
|
|
16
|
-
*/
|
|
17
|
-
export declare function clearSelection(state: AgentState): void;
|
|
18
|
-
/**
|
|
19
|
-
* Reposition selected overlays to match current element bounds
|
|
20
|
-
*/
|
|
21
|
-
export declare function repositionSelectedOverlays(state: AgentState): void;
|
|
22
|
-
/**
|
|
23
|
-
* Reposition hover overlays to match current element bounds
|
|
24
|
-
*/
|
|
25
|
-
export declare function repositionHoverOverlays(state: AgentState): void;
|
|
26
|
-
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/ui/overlay.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,UAAQ,GAAG,cAAc,CAehE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,OAAO,EAChB,UAAU,UAAQ,EAClB,gBAAgB,UAAO,GACtB,IAAI,CA+BN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,CAM9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAYtD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CASlE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAO/D"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { OVERLAY_TRANSITION, OVERLAY_Z_INDEX, SELECTED_BORDER_COLOR, HOVER_BORDER_COLOR, HOVER_BACKGROUND_COLOR, LABEL_TOP_OFFSET, LABEL_LEFT_OFFSET, } from "../constants.js";
|
|
2
|
-
import { findElementsById } from "../../utils.js";
|
|
3
|
-
/**
|
|
4
|
-
* Create an overlay element for highlighting
|
|
5
|
-
*/
|
|
6
|
-
export function createOverlay(isSelected = false) {
|
|
7
|
-
const overlay = document.createElement("div");
|
|
8
|
-
overlay.style.position = "absolute";
|
|
9
|
-
overlay.style.pointerEvents = "none";
|
|
10
|
-
overlay.style.transition = OVERLAY_TRANSITION;
|
|
11
|
-
overlay.style.zIndex = OVERLAY_Z_INDEX;
|
|
12
|
-
if (isSelected) {
|
|
13
|
-
overlay.style.border = `2px solid ${SELECTED_BORDER_COLOR}`;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
overlay.style.border = `2px solid ${HOVER_BORDER_COLOR}`;
|
|
17
|
-
overlay.style.backgroundColor = HOVER_BACKGROUND_COLOR;
|
|
18
|
-
}
|
|
19
|
-
return overlay;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Position overlay relative to element
|
|
23
|
-
*/
|
|
24
|
-
export function positionOverlay(overlay, element, isSelected = false, isVisualEditMode = true) {
|
|
25
|
-
if (!element || !isVisualEditMode)
|
|
26
|
-
return;
|
|
27
|
-
// Force layout recalculation before reading bounding rect
|
|
28
|
-
void element.offsetWidth;
|
|
29
|
-
const rect = element.getBoundingClientRect();
|
|
30
|
-
overlay.style.top = `${rect.top + window.scrollY}px`;
|
|
31
|
-
overlay.style.left = `${rect.left + window.scrollX}px`;
|
|
32
|
-
overlay.style.width = `${rect.width}px`;
|
|
33
|
-
overlay.style.height = `${rect.height}px`;
|
|
34
|
-
// Check if label already exists in overlay
|
|
35
|
-
let label = overlay.querySelector("div");
|
|
36
|
-
if (!label) {
|
|
37
|
-
label = document.createElement("div");
|
|
38
|
-
label.textContent = element.tagName.toLowerCase();
|
|
39
|
-
label.style.position = "absolute";
|
|
40
|
-
label.style.top = LABEL_TOP_OFFSET;
|
|
41
|
-
label.style.left = LABEL_LEFT_OFFSET;
|
|
42
|
-
label.style.padding = "2px 8px";
|
|
43
|
-
label.style.fontSize = "11px";
|
|
44
|
-
label.style.fontWeight = isSelected ? "500" : "400";
|
|
45
|
-
label.style.color = isSelected ? "#ffffff" : "#526cff";
|
|
46
|
-
label.style.backgroundColor = isSelected ? "#526cff" : "#DBEAFE";
|
|
47
|
-
label.style.borderRadius = "3px";
|
|
48
|
-
label.style.minWidth = "24px";
|
|
49
|
-
label.style.textAlign = "center";
|
|
50
|
-
overlay.appendChild(label);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Clear all overlays from DOM
|
|
55
|
-
*/
|
|
56
|
-
export function clearOverlays(overlays) {
|
|
57
|
-
overlays.forEach((overlay) => {
|
|
58
|
-
if (overlay && overlay.parentNode) {
|
|
59
|
-
overlay.remove();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Remove data-selected attribute, clear selected overlays, and reset selection state
|
|
65
|
-
*/
|
|
66
|
-
export function clearSelection(state) {
|
|
67
|
-
if (state.isInlineEditExperimentEnabled && state.selectedElementId) {
|
|
68
|
-
const elements = findElementsById(state.selectedElementId);
|
|
69
|
-
elements.forEach((el) => {
|
|
70
|
-
if (el instanceof HTMLElement) {
|
|
71
|
-
delete el.dataset.selected;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
clearOverlays(state.selectedOverlays);
|
|
76
|
-
state.selectedOverlays = [];
|
|
77
|
-
state.selectedElementId = null;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Reposition selected overlays to match current element bounds
|
|
81
|
-
*/
|
|
82
|
-
export function repositionSelectedOverlays(state) {
|
|
83
|
-
if (!state.selectedElementId)
|
|
84
|
-
return;
|
|
85
|
-
const elements = findElementsById(state.selectedElementId);
|
|
86
|
-
state.selectedOverlays.forEach((overlay, index) => {
|
|
87
|
-
const element = elements[index];
|
|
88
|
-
if (element) {
|
|
89
|
-
positionOverlay(overlay, element, true, state.isVisualEditMode);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Reposition hover overlays to match current element bounds
|
|
95
|
-
*/
|
|
96
|
-
export function repositionHoverOverlays(state) {
|
|
97
|
-
state.hoverOverlays.forEach((overlay, index) => {
|
|
98
|
-
const element = state.currentHighlightedElements[index];
|
|
99
|
-
if (element) {
|
|
100
|
-
positionOverlay(overlay, element, false, state.isVisualEditMode);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=overlay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/ui/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,UAAU,GAAG,KAAK;IAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,kBAAkB,CAAC;IAC9C,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC;IAEvC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,qBAAqB,EAAE,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,kBAAkB,EAAE,CAAC;QACzD,O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,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC5B,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAiB;IAC1D,IAAI,CAAC,KAAK,CAAC,iBAAiB;QAAE,OAAO;IACrC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3D,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,OAAO,EAAE,CAAC;YACZ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ElementPosition } from "../handlers/messages/types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Calculate element position from bounding rect
|
|
4
|
-
*/
|
|
5
|
-
export declare function getElementPosition(rect: DOMRect): ElementPosition;
|
|
6
|
-
/**
|
|
7
|
-
* Check if element rect is in viewport
|
|
8
|
-
*/
|
|
9
|
-
export declare function isElementInViewport(rect: DOMRect): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Get element classes (handles both HTML and SVG)
|
|
12
|
-
*/
|
|
13
|
-
export declare function getElementClasses(element: Element): string;
|
|
14
|
-
//# sourceMappingURL=dom-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom-utils.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/utils/dom-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAWjE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAO1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAK1D"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate element position from bounding rect
|
|
3
|
-
*/
|
|
4
|
-
export function getElementPosition(rect) {
|
|
5
|
-
return {
|
|
6
|
-
top: rect.top,
|
|
7
|
-
left: rect.left,
|
|
8
|
-
right: rect.right,
|
|
9
|
-
bottom: rect.bottom,
|
|
10
|
-
width: rect.width,
|
|
11
|
-
height: rect.height,
|
|
12
|
-
centerX: rect.left + rect.width / 2,
|
|
13
|
-
centerY: rect.top + rect.height / 2,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Check if element rect is in viewport
|
|
18
|
-
*/
|
|
19
|
-
export function isElementInViewport(rect) {
|
|
20
|
-
return (rect.top < window.innerHeight &&
|
|
21
|
-
rect.bottom > 0 &&
|
|
22
|
-
rect.left < window.innerWidth &&
|
|
23
|
-
rect.right > 0);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get element classes (handles both HTML and SVG)
|
|
27
|
-
*/
|
|
28
|
-
export function getElementClasses(element) {
|
|
29
|
-
if (element instanceof SVGElement) {
|
|
30
|
-
return element.className?.baseVal || "";
|
|
31
|
-
}
|
|
32
|
-
return element.className || "";
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=dom-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom-utils.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/utils/dom-utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAa;IAC9C,OAAO;QACL,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC;QACnC,OAAO,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,OAAO,CACL,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,WAAW;QAC7B,IAAI,CAAC,MAAM,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU;QAC7B,IAAI,CAAC,KAAK,GAAG,CAAC,CACf,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;QAClC,OAAQ,OAAO,CAAC,SAA0C,EAAE,OAAO,IAAI,EAAE,CAAC;IAC5E,CAAC;IACD,OAAO,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
# Visual Edit Agent - Modular Architecture
|
|
2
|
-
|
|
3
|
-
The visual edit agent has been refactored into a clean, modular structure with proper separation of concerns.
|
|
4
|
-
|
|
5
|
-
## Directory Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
src/injections/visual-edit-agent/
|
|
9
|
-
├── index.ts # Main entry point & setup orchestration
|
|
10
|
-
├── constants.ts # Shared constants
|
|
11
|
-
├── state/
|
|
12
|
-
│ └── agent-state.ts # Centralized state management
|
|
13
|
-
├── ui/
|
|
14
|
-
│ └── overlay.ts # Overlay creation, positioning & selection helpers
|
|
15
|
-
├── utils/
|
|
16
|
-
│ └── dom-utils.ts # DOM helpers (position, viewport, classes)
|
|
17
|
-
├── handlers/
|
|
18
|
-
│ ├── hover-handlers.ts # Mouse hover interactions
|
|
19
|
-
│ ├── click-handlers.ts # Element selection & click handling
|
|
20
|
-
│ ├── inline-edit-handlers.ts # Bridges to inline editing capability
|
|
21
|
-
│ ├── message-handlers.ts # Parent window message handling
|
|
22
|
-
│ └── messages/
|
|
23
|
-
│ ├── types.ts # Message type enums & interfaces
|
|
24
|
-
│ ├── toggle-visual-edit-mode.ts # Handles toggle-visual-edit-mode
|
|
25
|
-
│ └── toggle-inline-edit-mode.ts # Handles toggle-inline-edit-mode
|
|
26
|
-
└── capabilities/
|
|
27
|
-
└── inline-editing/ # Inline text editing capability
|
|
28
|
-
├── index.ts # Public API
|
|
29
|
-
├── core.ts # ContentEditable logic
|
|
30
|
-
├── validation.ts # Element eligibility checks
|
|
31
|
-
├── styles.ts # CSS injection / removal
|
|
32
|
-
└── README.md # Documentation
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Module Responsibilities
|
|
36
|
-
|
|
37
|
-
### `index.ts` - Setup & Orchestration
|
|
38
|
-
- Initializes the visual edit agent
|
|
39
|
-
- Sets up all event listeners
|
|
40
|
-
- Creates mutation observers
|
|
41
|
-
- Coordinates between different modules
|
|
42
|
-
|
|
43
|
-
### `constants.ts` - Configuration
|
|
44
|
-
- Defines all magic numbers and styling constants
|
|
45
|
-
- Single source of truth for configuration values
|
|
46
|
-
- Easy to modify behavior without touching logic
|
|
47
|
-
|
|
48
|
-
### `state/agent-state.ts` - State Management
|
|
49
|
-
- **`AgentState` interface**: TypeScript interface defining all state
|
|
50
|
-
- **`createAgentState()`**: Factory function to create initial state
|
|
51
|
-
- Centralizes all state in one place for easier debugging
|
|
52
|
-
|
|
53
|
-
### `ui/overlay.ts` - UI Components & Overlay State Helpers
|
|
54
|
-
- **`createOverlay()`**: Creates hover/selection overlay elements
|
|
55
|
-
- **`positionOverlay()`**: Positions a single overlay relative to an element
|
|
56
|
-
- **`clearOverlays()`**: Removes overlay elements from the DOM
|
|
57
|
-
- **`clearSelection(state)`**: Removes `data-selected`, clears selected overlays, and nulls `selectedElementId` — single source of truth for deselection used by `unselectElement`, `handleElementSelection`, and `toggleVisualEditMode`
|
|
58
|
-
- **`repositionSelectedOverlays(state)`**: Re-positions all selected overlays after layout changes
|
|
59
|
-
- **`repositionHoverOverlays(state)`**: Re-positions all hover overlays after layout changes
|
|
60
|
-
|
|
61
|
-
### `handlers/hover-handlers.ts` - Hover Interactions
|
|
62
|
-
- **`handleMouseOver()`**: Shows hover overlays on element hover
|
|
63
|
-
- **`handleMouseOut()`**: Clears hover overlays
|
|
64
|
-
- **`clearHoverOverlays()`**: Cleanup utility
|
|
65
|
-
- Manages the hover state and visual feedback
|
|
66
|
-
|
|
67
|
-
### `handlers/click-handlers.ts` - Selection Logic
|
|
68
|
-
- **`handleElementClick()`**: Main click event handler
|
|
69
|
-
- **`handleElementSelection()`**: Handles first click (selection)
|
|
70
|
-
- Manages the selection flow and second-click inline editing trigger
|
|
71
|
-
- Sends `element-selected` messages to parent
|
|
72
|
-
|
|
73
|
-
### `handlers/inline-edit-handlers.ts` - Inline Editing
|
|
74
|
-
- **`handleEnterInlineEditingMode()`**: Enables contentEditable
|
|
75
|
-
- **`handleClearInlineEditingMode()`**: Disables contentEditable
|
|
76
|
-
- **`setupInlineEditCallback()`**: Wires up text input handler
|
|
77
|
-
- **Debounced reporting**: 500ms debounce for `inline-edit` messages
|
|
78
|
-
- Bridges between visual edit agent and the inline-editing capability
|
|
79
|
-
|
|
80
|
-
### `capabilities/inline-editing/` - Inline Editing Capability
|
|
81
|
-
Reusable inline text editing using contentEditable.
|
|
82
|
-
- **`core.ts`**: Main contentEditable logic — `enterInlineEditingMode` injects the focus-suppression CSS; `clearInlineEditingMode` removes it automatically
|
|
83
|
-
- **`validation.ts`**: Element eligibility checks
|
|
84
|
-
- **`styles.ts`**: CSS injection (`injectFocusOutlineCSS`) and removal (`removeFocusOutlineCSS`)
|
|
85
|
-
- **`README.md`**: Complete documentation
|
|
86
|
-
- See [capabilities/inline-editing/README.md](./capabilities/inline-editing/README.md) for details
|
|
87
|
-
|
|
88
|
-
### `handlers/messages/` - Per-Message Handlers
|
|
89
|
-
Split out of `message-handlers.ts` to keep each handler focused:
|
|
90
|
-
- **`types.ts`**: `IncomingMessageType` / `OutgoingMessageType` enums and all message interfaces
|
|
91
|
-
- **`toggle-visual-edit-mode.ts`**: Enables/disables visual edit mode, clears all overlays & selection via `clearSelection`, updates the inline-edit experiment flag
|
|
92
|
-
- **`toggle-inline-edit-mode.ts`**: Programmatically enters/exits inline editing for a given element
|
|
93
|
-
|
|
94
|
-
### `handlers/message-handlers.ts` - Parent Communication
|
|
95
|
-
- **`handleMessage()`**: Switch-board for all incoming messages — delegates to per-message handlers above
|
|
96
|
-
- **`handleScroll()`**: Sends `element-position-update` to parent on scroll
|
|
97
|
-
- **`handleResize()`**: Calls `repositionSelectedOverlays` + `repositionHoverOverlays` on resize
|
|
98
|
-
- **`updateElementClassesAndReposition()`**: Updates classes & repositions overlays after CSS reflow
|
|
99
|
-
- **`updateElementContent()`**: Updates element `innerText` & repositions overlays
|
|
100
|
-
- **`unselectElement()`**: Exits inline editing if active, then delegates to `clearSelection`
|
|
101
|
-
- Central hub for all parent-iframe communication
|
|
102
|
-
|
|
103
|
-
## State Flow
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
User Action
|
|
107
|
-
↓
|
|
108
|
-
Handler (e.g., handleElementClick)
|
|
109
|
-
↓
|
|
110
|
-
Modifies State (AgentState)
|
|
111
|
-
↓
|
|
112
|
-
Updates UI (overlay.ts)
|
|
113
|
-
↓
|
|
114
|
-
Sends Message to Parent (window.parent.postMessage)
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Position Update Strategy
|
|
118
|
-
|
|
119
|
-
Following Framewire's reactive pattern, we **update positions at the source** instead of using a broad MutationObserver. This is more performant and predictable.
|
|
120
|
-
|
|
121
|
-
### Position Updates Happen:
|
|
122
|
-
1. **Element Selection** - When user clicks an element
|
|
123
|
-
2. **Inline Editing** - During text input (debounced)
|
|
124
|
-
3. **Scroll Events** - Via scroll listener
|
|
125
|
-
4. **Window Resize** - Via resize listener
|
|
126
|
-
5. **Parent Updates** - When parent sends class/content changes (with 50ms delay for CSS reflow)
|
|
127
|
-
6. **Hover Events** - When user hovers over elements
|
|
128
|
-
|
|
129
|
-
See [POSITION_UPDATES.md](./POSITION_UPDATES.md) for detailed analysis.
|
|
130
|
-
|
|
131
|
-
## Key Features
|
|
132
|
-
|
|
133
|
-
### 1. **Separation of Concerns**
|
|
134
|
-
Each module has a single, well-defined responsibility
|
|
135
|
-
|
|
136
|
-
### 2. **Shared Helpers Over Repeated Logic**
|
|
137
|
-
Overlay repositioning and selection clearing live in `overlay.ts` as named helpers (`repositionSelectedOverlays`, `repositionHoverOverlays`, `clearSelection`) rather than being duplicated across handler files
|
|
138
|
-
|
|
139
|
-
### 3. **Centralized State**
|
|
140
|
-
All state is in `AgentState`, passed to handlers explicitly
|
|
141
|
-
|
|
142
|
-
### 4. **Type Safety**
|
|
143
|
-
TypeScript interfaces define clear contracts between modules
|
|
144
|
-
|
|
145
|
-
### 5. **Easy to Extend**
|
|
146
|
-
Adding new handlers or message types is straightforward
|
|
147
|
-
|
|
148
|
-
### 6. **Better Debugging**
|
|
149
|
-
Smaller files and clear responsibilities make debugging easier
|
|
150
|
-
|
|
151
|
-
## Message Types
|
|
152
|
-
|
|
153
|
-
### Incoming (from Parent)
|
|
154
|
-
- `toggle-visual-edit-mode` - Enable/disable visual edit mode + experiment flags
|
|
155
|
-
- `update-classes` - Update element classes
|
|
156
|
-
- `update-content` - Update element text content
|
|
157
|
-
- `unselect-element` - Clear current selection
|
|
158
|
-
- `refresh-page` - Reload the page
|
|
159
|
-
- `toggle-inline-edit-mode` - Programmatically enable/disable inline editing
|
|
160
|
-
- `request-element-position` - Request position of selected element
|
|
161
|
-
- `popover-drag-state` - Notify about popover drag state
|
|
162
|
-
- `dropdown-state` - Notify about dropdown open state
|
|
163
|
-
|
|
164
|
-
### Outgoing (to Parent)
|
|
165
|
-
- `visual-edit-agent-ready` - Agent initialized and ready
|
|
166
|
-
- `element-selected` - Element was selected
|
|
167
|
-
- `element-position-update` - Selected element position changed
|
|
168
|
-
- `content-editing-started` - Inline editing began
|
|
169
|
-
- `inline-edit` - Debounced content change during editing
|
|
170
|
-
- `content-editing-ended` - Inline editing finished
|
|
171
|
-
- `close-dropdowns` - Request to close dropdowns
|
|
172
|
-
|
|
173
|
-
## Inline Editing Experiment
|
|
174
|
-
|
|
175
|
-
Inline editing is gated behind an experiment flag: `specs.newInlineEditEnabled`
|
|
176
|
-
|
|
177
|
-
**Enable via:**
|
|
178
|
-
```typescript
|
|
179
|
-
{
|
|
180
|
-
type: "toggle-visual-edit-mode",
|
|
181
|
-
data: {
|
|
182
|
-
enabled: true,
|
|
183
|
-
specs: {
|
|
184
|
-
newInlineEditEnabled: true
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**When enabled:**
|
|
191
|
-
- Second click on selected text element enters inline edit mode
|
|
192
|
-
- `toggle-inline-edit-mode` messages work
|
|
193
|
-
- 500ms debounced `inline-edit` messages sent during typing
|
|
194
|
-
|
|
195
|
-
**When disabled:**
|
|
196
|
-
- Second click does nothing
|
|
197
|
-
- `toggle-inline-edit-mode` messages ignored
|
|
198
|
-
|
|
199
|
-
## Constants
|
|
200
|
-
|
|
201
|
-
All configurable values are in `constants.ts`:
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
INLINE_EDIT_DEBOUNCE_MS = 500 // Debounce time for inline edits
|
|
205
|
-
OVERLAY_Z_INDEX = "9999" // Z-index for overlays
|
|
206
|
-
SELECTED_BORDER_COLOR = "#2563EB" // Selected element border color
|
|
207
|
-
HOVER_BORDER_COLOR = "#95a5fc" // Hover element border color
|
|
208
|
-
REPOSITION_DELAY_MS = 50 // Delay before repositioning overlays
|
|
209
|
-
// ... and more
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Usage
|
|
213
|
-
|
|
214
|
-
Import and call the setup function:
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
import { setupVisualEditAgent } from './visual-edit-agent.js';
|
|
218
|
-
|
|
219
|
-
setupVisualEditAgent();
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
That's it! The agent will initialize, set up all listeners, and start responding to messages.
|