@base44-preview/vite-plugin 0.2.22-pr.37.466ee63 → 0.2.22-pr.37.7bfb808
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/visual-edit-agent/capabilities/inline-editing/core.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js +17 -4
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js +5 -7
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js +10 -0
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js +2 -2
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js +23 -7
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js.map +1 -1
- package/dist/injections/visual-edit-agent/index.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/index.js +22 -16
- package/dist/injections/visual-edit-agent/index.js.map +1 -1
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent/ui/overlay.js +0 -3
- package/dist/injections/visual-edit-agent/ui/overlay.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/injections/visual-edit-agent/capabilities/inline-editing/core.ts +19 -4
- package/src/injections/visual-edit-agent/handlers/click-handlers.ts +5 -6
- package/src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts +11 -0
- package/src/injections/visual-edit-agent/handlers/message-handlers.ts +3 -3
- package/src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts +28 -9
- package/src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts +0 -1
- package/src/injections/visual-edit-agent/index.ts +21 -17
- package/src/injections/visual-edit-agent/ui/overlay.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AAQxD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAE9E;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AAQxD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAE9E;AAkBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAYtE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CA4BjE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAqBjE"}
|
|
@@ -11,6 +11,12 @@ let onTextInputChangeCallback = null;
|
|
|
11
11
|
export function setInlineEditCallback(callback) {
|
|
12
12
|
onTextInputChangeCallback = callback;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* WeakMap to track AbortControllers for each element's input listener.
|
|
16
|
+
* Using WeakMap ensures no memory leaks — when an element is garbage collected,
|
|
17
|
+
* its entry is automatically removed.
|
|
18
|
+
*/
|
|
19
|
+
const listenerAbortControllers = new WeakMap();
|
|
14
20
|
/**
|
|
15
21
|
* Internal handler for the native input event
|
|
16
22
|
*/
|
|
@@ -46,8 +52,11 @@ export function enterInlineEditingMode(element) {
|
|
|
46
52
|
element.dataset.originalCursor = element.style.cursor;
|
|
47
53
|
// Enable contentEditable
|
|
48
54
|
element.contentEditable = "true";
|
|
49
|
-
//
|
|
50
|
-
|
|
55
|
+
// Create an AbortController to manage the input listener lifecycle
|
|
56
|
+
const abortController = new AbortController();
|
|
57
|
+
listenerAbortControllers.set(element, abortController);
|
|
58
|
+
// Add input event listener with AbortSignal for automatic cleanup
|
|
59
|
+
element.addEventListener("input", handleInputEvent, { signal: abortController.signal });
|
|
51
60
|
// Set cursor to text
|
|
52
61
|
element.style.cursor = "text";
|
|
53
62
|
// Select all text
|
|
@@ -63,8 +72,12 @@ export function enterInlineEditingMode(element) {
|
|
|
63
72
|
*/
|
|
64
73
|
export function clearInlineEditingMode(element) {
|
|
65
74
|
removeFocusOutlineCSS();
|
|
66
|
-
//
|
|
67
|
-
|
|
75
|
+
// Abort the input event listener using the stored AbortController
|
|
76
|
+
const abortController = listenerAbortControllers.get(element);
|
|
77
|
+
if (abortController) {
|
|
78
|
+
abortController.abort();
|
|
79
|
+
listenerAbortControllers.delete(element);
|
|
80
|
+
}
|
|
68
81
|
// Disable contentEditable
|
|
69
82
|
element.contentEditable = "false";
|
|
70
83
|
// Remove stored original text content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAOpE;;;GAGG;AACH,IAAI,yBAAyB,GAA6B,IAAI,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkC;IACtE,yBAAyB,GAAG,QAAQ,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAoB,CAAQ;IACnD,IAAI,yBAAyB,EAAE,CAAC;QAC9B,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,iCAAiC;IACjC,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QAC7E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mCAAmC;IACnC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,uCAAuC;IACvC,qBAAqB,EAAE,CAAC;IAExB,uBAAuB;IACvB,OAAO,CAAC,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IAChE,OAAO,CAAC,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;IAEtD,yBAAyB;IACzB,OAAO,CAAC,eAAe,GAAG,MAAM,CAAC;IAEjC,
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit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ers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"click-handlers.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/click-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAS1D;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,IAAI,CA4CN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,IAAI,CAoEzE"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { OutgoingMessageType } from "./messages/types.js";
|
|
2
2
|
import { findElementsById } from "../../utils.js";
|
|
3
|
-
import { createOverlay, positionOverlay } from "../ui/overlay.js";
|
|
3
|
+
import { createOverlay, positionOverlay, clearSelection } from "../ui/overlay.js";
|
|
4
4
|
import { clearHoverOverlays } from "./hover-handlers.js";
|
|
5
5
|
import { shouldEnterInlineEditingMode } from "../capabilities/inline-editing/index.js";
|
|
6
6
|
import { handleClearInlineEditingMode, handleEnterInlineEditingMode } from "./inline-edit-handlers.js";
|
|
7
|
-
import { unselectElement } from "./message-handlers.js";
|
|
8
7
|
import { getElementPosition, getElementClasses } from "../utils/dom-utils.js";
|
|
9
8
|
/**
|
|
10
9
|
* Handle element selection (first click)
|
|
11
10
|
*/
|
|
12
11
|
export function handleElementSelection(state, element, visualSelectorId) {
|
|
13
|
-
|
|
12
|
+
if (state.currentEditingElement) {
|
|
13
|
+
handleClearInlineEditingMode(state);
|
|
14
|
+
}
|
|
15
|
+
clearSelection(state);
|
|
14
16
|
// Find all elements with the same ID
|
|
15
17
|
const elements = findElementsById(visualSelectorId);
|
|
16
18
|
// Mark elements as selected
|
|
@@ -95,13 +97,9 @@ export function handleElementClick(state, e) {
|
|
|
95
97
|
// Second click on already-selected element: check if it should enter inline editing
|
|
96
98
|
// Only if the experiment is enabled
|
|
97
99
|
if (state.isInlineEditExperimentEnabled && shouldEnterInlineEditingMode(htmlElement)) {
|
|
98
|
-
console.log('[VisualEditAgent] Entering inline edit mode');
|
|
99
100
|
handleEnterInlineEditingMode(state, htmlElement);
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
|
-
else if (!state.isInlineEditExperimentEnabled) {
|
|
103
|
-
console.log('[VisualEditAgent] Inline edit disabled - experiment flag not enabled');
|
|
104
|
-
}
|
|
105
103
|
}
|
|
106
104
|
// First click: select the element
|
|
107
105
|
handleElementSelection(state, element, visualSelectorId || null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/click-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"click-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/click-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,k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ED,wCAAwC;IACxC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO;IACT,CAAC;IAED,gEAAgE;IAChE,CAAC,CAAC,cAAc,EAAE,CAAC;IACnB,CAAC,CAAC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAE7B,gEAAgE;IAChE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAC5B,mDAAmD,CACpD,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAG,OAAsB,CAAC;IAC3C,MAAM,gBAAgB,GACpB,WAAW,CAAC,OAAO,CAAC,cAAc;QAClC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAEvC,oEAAoE;IACpE,MAAM,iBAAiB,GACrB,KAAK,CAAC,iBAAiB,KAAK,gBAAgB;QAC5C,WAAW,CAAC,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC;IAE1C,IAAI,iBAAiB,EAAE,CAAC;QACtB,oFAAoF;QACpF,oCAAoC;QACpC,IAAI,KAAK,CAAC,6BAA6B,IAAI,4BAA4B,CAAC,WAAW,CAAC,EAAE,CAAC;YACrF,4BAA4B,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACjD,OAAO;QACT,CAAC;IACH,CAAC;IAED,kCAAkC;IAClC,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-edit-handlers.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAW1D;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAmB1F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"inline-edit-handlers.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAW1D;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAmB1F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CA+BpE;AAkED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAE/D"}
|
|
@@ -26,6 +26,11 @@ export function handleEnterInlineEditingMode(state, element) {
|
|
|
26
26
|
export function handleClearInlineEditingMode(state) {
|
|
27
27
|
if (!state.currentEditingElement)
|
|
28
28
|
return;
|
|
29
|
+
// Cancel any pending debounced edit — originalTextContent will be deleted below
|
|
30
|
+
if (state.debouncedSendTimeout) {
|
|
31
|
+
clearTimeout(state.debouncedSendTimeout);
|
|
32
|
+
state.debouncedSendTimeout = null;
|
|
33
|
+
}
|
|
29
34
|
const element = state.currentEditingElement;
|
|
30
35
|
// Clear inline editing mode (from capabilities/inline-editing)
|
|
31
36
|
clearInlineEditingMode(element);
|
|
@@ -70,6 +75,11 @@ function reportInlineEdit(state, element) {
|
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
77
|
* Debounced function to send inline edit messages
|
|
78
|
+
*
|
|
79
|
+
* Intentionally overwrites the previous timeout on each keystroke — this is the
|
|
80
|
+
* correct debounce behavior. We only send ONE message 500ms after the user stops
|
|
81
|
+
* typing, containing the final text. Intermediate keystrokes are not sent to avoid
|
|
82
|
+
* flooding the parent with dozens of messages per second.
|
|
73
83
|
*/
|
|
74
84
|
function debouncedSendInlineEditMessage(state, element) {
|
|
75
85
|
// Clear any existing timeout
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-edit-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE9E;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAiB,EAAE,OAAoB;IAClF,KAAK,CAAC,qBAAqB,GAAG,OAAO,CAAC;IAEtC,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACzC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEhC,gBAAgB;IAChB,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;QACE,IAAI,EAAE,mBAAmB,CAAC,uBAAuB;QACjD,gBAAgB,EAAE,KAAK,CAAC,iBAAiB;KAC1C,EACD,GAAG,CACJ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAiB;IAC5D,IAAI,CAAC,KAAK,CAAC,qBAAqB;QAAE,OAAO;IAEzC,MAAM,OAAO,GAAG,KAAK,CAAC,qBAAqB,CAAC;IAE5C,+DAA+D;IAC/D,sBAAsB,CAAC,OAAO,CAAC,CAAC;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IAChC,OAAO,CAAC,OAAO,CAAC,mBAAmB,GAAG,UAAU,IAAI,EAAE,CAAC;AACzD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"inline-edit-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE9E;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAiB,EAAE,OAAoB;IAClF,KAAK,CAAC,qBAAqB,GAAG,OAAO,CAAC;IAEtC,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACzC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEhC,gBAAgB;IAChB,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;QACE,IAAI,EAAE,mBAAmB,CAAC,uBAAuB;QACjD,gBAAgB,EAAE,KAAK,CAAC,iBAAiB;KAC1C,EACD,GAAG,CACJ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAiB;IAC5D,IAAI,CAAC,KAAK,CAAC,qBAAqB;QAAE,OAAO;IAEzC,gFAAgF;IAChF,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC/B,YAAY,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACz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;IAC3B,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;QACE,IAAI,EAAE,mBAAmB,CAAC,WAAW;QACrC,WAAW;QACX,eAAe;QACf,UAAU;KACX,EACD,GAAG,CACJ,CAAC;IAEF,gCAAgC;IAChC,OAAO,CAAC,OAAO,CAAC,mBAAmB,GAAG,UAAU,IAAI,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,8BAA8B,CAAC,KAAiB,EAAE,OAAoB;IAC7E,6BAA6B;IAC7B,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC/B,YAAY,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,oBAAoB,GAAG,UAAU,CAAC,GAAG,EAAE;QAC3C,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,EAAE,uBAAuB,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,6BAA6B,CAAC,KAAiB;IACtD,OAAO,CAAC,OAAoB,EAAE,EAAE;QAC9B,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAClC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,qBAAqB,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -14,9 +14,9 @@ function sendElementPositionUpdate(state) {
|
|
|
14
14
|
if (!state.selectedElementId)
|
|
15
15
|
return;
|
|
16
16
|
const elements = findElementsById(state.selectedElementId);
|
|
17
|
-
|
|
17
|
+
const [element] = elements;
|
|
18
|
+
if (!element)
|
|
18
19
|
return;
|
|
19
|
-
const element = elements[0];
|
|
20
20
|
const rect = element.getBoundingClientRect();
|
|
21
21
|
window.parent.postMessage({
|
|
22
22
|
type: OutgoingMessageType.ELEMENT_POSITION_UPDATE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/message-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEhF;;GAEG;AACH,SAAS,yBAAyB,CAAC,KAAiB;IAClD,IAAI,CAAC,KAAK,CAAC,iBAAiB;QAAE,OAAO;IAErC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3D,
|
|
1
|
+
{"version":3,"file":"message-handlers.js","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/message-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,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,0BAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC3C,MAAM;QAER,KAAK,mBAAmB,CAAC,wBAAwB;YAC/C,yBAAyB,CAAC,KAAK,CAAC,CAAC;YACjC,MAAM;QAER,KAAK,mBAAmB,CAAC,kBAAkB;YACzC,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC1D,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;gBAClD,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAC5B,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,MAAM;QAER,KAAK,mBAAmB,CAAC,cAAc;YACrC,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBACtD,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC3C,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;oBACxB,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,MAAM;QAER;YACE,MAAM;IACV,CAAC;AACH,CAAC"}
|
package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-inline-edit-mode.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle-inline-edit-mode.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAO9D;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAuDN"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { findElementsById } from "../../../utils.js";
|
|
2
2
|
import { shouldEnterInlineEditingMode } from "../../capabilities/inline-editing/index.js";
|
|
3
|
-
import { handleElementSelection } from "../click-handlers.js";
|
|
4
3
|
import { handleEnterInlineEditingMode, handleClearInlineEditingMode } from "../inline-edit-handlers.js";
|
|
4
|
+
import { clearSelection } from "../../ui/overlay.js";
|
|
5
|
+
import { createOverlay, positionOverlay } from "../../ui/overlay.js";
|
|
5
6
|
/**
|
|
6
7
|
* Handle toggle-inline-edit-mode message (parent-initiated)
|
|
7
8
|
*/
|
|
8
9
|
export function handleToggleInlineEditMode(state, message) {
|
|
9
|
-
// Check if inline edit experiment is enabled
|
|
10
10
|
if (!state.isInlineEditExperimentEnabled) {
|
|
11
|
-
console.log('[VisualEditAgent] toggle-inline-edit-mode ignored - experiment flag not enabled');
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
|
-
console.log('[VisualEditAgent] Processing toggle-inline-edit-mode message');
|
|
15
|
-
// Parent-initiated inline editing mode toggle
|
|
16
13
|
if (!message.data || !message.data.dataSourceLocation) {
|
|
17
|
-
console.warn('[VisualEditAgent] Invalid toggle-inline-edit-mode message - missing dataSourceLocation');
|
|
18
14
|
return;
|
|
19
15
|
}
|
|
20
16
|
const elements = findElementsById(message.data.dataSourceLocation);
|
|
@@ -27,7 +23,27 @@ export function handleToggleInlineEditMode(state, message) {
|
|
|
27
23
|
if (shouldEnterInlineEditingMode(element)) {
|
|
28
24
|
// Select the element first if not already selected
|
|
29
25
|
if (state.selectedElementId !== message.data.dataSourceLocation) {
|
|
30
|
-
|
|
26
|
+
// Clear any existing selection
|
|
27
|
+
if (state.currentEditingElement) {
|
|
28
|
+
handleClearInlineEditingMode(state);
|
|
29
|
+
}
|
|
30
|
+
clearSelection(state);
|
|
31
|
+
// Find all elements with the same ID
|
|
32
|
+
const elements = findElementsById(message.data.dataSourceLocation);
|
|
33
|
+
// Mark elements as selected
|
|
34
|
+
elements.forEach((el) => {
|
|
35
|
+
if (el instanceof HTMLElement) {
|
|
36
|
+
el.dataset.selected = "true";
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// Create selected overlays for all matching elements
|
|
40
|
+
elements.forEach((el) => {
|
|
41
|
+
const overlay = createOverlay(true);
|
|
42
|
+
document.body.appendChild(overlay);
|
|
43
|
+
state.selectedOverlays.push(overlay);
|
|
44
|
+
positionOverlay(overlay, el, true, state.isVisualEditMode);
|
|
45
|
+
});
|
|
46
|
+
state.selectedElementId = message.data.dataSourceLocation;
|
|
31
47
|
}
|
|
32
48
|
handleEnterInlineEditingMode(state, element);
|
|
33
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-inline-edit-mode.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"toggle-inline-edit-mode.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,4BAA4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AAI,EAAE,YAAY,WAAW,EAAE,CAAC;wBAC9B,EAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC;oBAC/B,CAAC;gBACH,CAAC,CAAC,CAAC;gBAEH,qDAAqD;gBACrD,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;oBACtB,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;oBACpC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;oBACnC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrC,eAAe,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAC7D,CAAC,CAAC,CAAC;gBAEH,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC;YAC5D,CAAC;YACD,4BAA4B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,yBAAyB;QACzB,IAAI,KAAK,CAAC,qBAAqB,KAAK,OAAO,EAAE,CAAC;YAC5C,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-visual-edit-mode.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAK9D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAehF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,2BAA2B,GACnC,IAAI,
|
|
1
|
+
{"version":3,"file":"toggle-visual-edit-mode.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAK9D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAehF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAON"}
|
|
@@ -27,7 +27,6 @@ export function handleToggleVisualEditMode(state, message) {
|
|
|
27
27
|
// Update inline edit experiment flag if provided
|
|
28
28
|
if (message.data.specs?.newInlineEditEnabled !== undefined) {
|
|
29
29
|
state.isInlineEditExperimentEnabled = message.data.specs.newInlineEditEnabled;
|
|
30
|
-
console.log('[VisualEditAgent] Inline edit experiment:', state.isInlineEditExperimentEnabled);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=toggle-visual-edit-mode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-visual-edit-mode.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE1E;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAiB,EAAE,SAAkB;IACxE,KAAK,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAEnC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC;YAChC,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,cAAc,CAAC,KAAK,CAAC,CAAC;QACtB,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;IAC3C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAiB,EACjB,OAAoC;IAEpC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElD,iDAAiD;IACjD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC3D,KAAK,CAAC,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle-visual-edit-mode.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE1E;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAiB,EAAE,SAAkB;IACxE,KAAK,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAEnC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC;YAChC,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,cAAc,CAAC,KAAK,CAAC,CAAC;QACtB,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;IAC3C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAiB,EACjB,OAAoC;IAEpC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElD,iDAAiD;IACjD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC3D,KAAK,CAAC,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/injections/visual-edit-agent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/injections/visual-edit-agent/index.ts"],"names":[],"mappings":"AAkGA;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAkB3C"}
|
|
@@ -16,25 +16,28 @@ function initializeElementIds() {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Create mutation observer to detect layout changes
|
|
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.
|
|
20
22
|
*/
|
|
21
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 (let i = 0; i < el.children.length; i++) {
|
|
32
|
+
if (hasVisualId(el.children[i]))
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
22
37
|
return new MutationObserver((mutations) => {
|
|
38
|
+
if (rafHandle !== null)
|
|
39
|
+
return;
|
|
23
40
|
const needsUpdate = mutations.some((mutation) => {
|
|
24
|
-
const hasVisualId = (node) => {
|
|
25
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
26
|
-
const el = node;
|
|
27
|
-
if (el.dataset && el.dataset.visualSelectorId) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
31
|
-
if (hasVisualId(el.children[i])) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
};
|
|
38
41
|
const isLayoutChange = mutation.type === "attributes" &&
|
|
39
42
|
(mutation.attributeName === "style" ||
|
|
40
43
|
mutation.attributeName === "class" ||
|
|
@@ -43,7 +46,10 @@ function createLayoutObserver(onLayoutChange) {
|
|
|
43
46
|
return isLayoutChange && hasVisualId(mutation.target);
|
|
44
47
|
});
|
|
45
48
|
if (needsUpdate) {
|
|
46
|
-
|
|
49
|
+
rafHandle = requestAnimationFrame(() => {
|
|
50
|
+
rafHandle = null;
|
|
51
|
+
onLayoutChange();
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
54
|
});
|
|
49
55
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,oCA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C,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,uBAAuB,EAAE,EAAE,GAAG,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CA4BN;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,CAQlE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAM/D"}
|
|
@@ -24,9 +24,6 @@ export function createOverlay(isSelected = false) {
|
|
|
24
24
|
export function positionOverlay(overlay, element, isSelected = false, isVisualEditMode = true) {
|
|
25
25
|
if (!element || !isVisualEditMode)
|
|
26
26
|
return;
|
|
27
|
-
const htmlElement = element;
|
|
28
|
-
// Force layout recalculation
|
|
29
|
-
void htmlElement.offsetWidth;
|
|
30
27
|
const rect = element.getBoundingClientRect();
|
|
31
28
|
overlay.style.top = `${rect.top + window.scrollY}px`;
|
|
32
29
|
overlay.style.left = `${rect.left + window.scrollX}px`;
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,sBAAsB,CAAC;IACzD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAA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iBAAiB,CAAC,CAAC;IAC3D,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QAChD,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC5B,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAE,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC3E,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,IAAI,KAAK,GAAG,KAAK,CAAC,0BAA0B,CAAC,MAAM,EAAE,CAAC;YACpD,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAE,EAAE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpG,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/statics/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function
|
|
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 m(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 E(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 c(e){e.selectedElementId&&l(e.selectedElementId).forEach(n=>{n instanceof HTMLElement&&delete n.dataset.selected}),h(e.selectedOverlays),e.selectedOverlays=[],e.selectedElementId=null}function u(e){if(!e.selectedElementId)return;let t=l(e.selectedElementId);e.selectedOverlays.forEach((n,o)=>{o<t.length&&E(n,t[o],!0,e.isVisualEditMode)})}function O(e){e.hoverOverlays.forEach((t,n)=>{n<e.currentHighlightedElements.length&&E(t,e.currentHighlightedElements[n],!1,e.isVisualEditMode)})}function s(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){s(e);return}if(n.tagName.toLowerCase()==="path"){s(e);return}let o=n.closest("[data-source-location], [data-visual-selector-id]");if(!o){s(e);return}let r=o,i=r.dataset.sourceLocation||r.dataset.visualSelectorId;if(e.selectedElementId===i){s(e);return}let a=l(i||null);s(e),a.forEach(g=>{let S=m(!1);document.body.appendChild(S),e.hoverOverlays.push(S),E(S,g,!1,e.isVisualEditMode)}),e.currentHighlightedElements=a}function W(e){e.isPopoverDragging||e.currentEditingElement||s(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
2
|
[data-selected="true"][contenteditable="true"]:focus {
|
|
3
3
|
outline: none !important;
|
|
4
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
|
|
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}var C=new WeakMap;function ee(e){x&&x(this)}function f(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";let t=new AbortController;C.set(e,t),e.addEventListener("input",ee,{signal:t.signal}),e.style.cursor="text",L(e),setTimeout(()=>{e.focus()},0)}function D(e){M();let t=C.get(e);t&&(t.abort(),C.delete(e)),e.contentEditable="false",delete e.dataset.originalTextContent,e.dataset.originalCursor!==void 0&&(e.style.cursor=e.dataset.originalCursor,delete e.dataset.originalCursor)}function p(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 Y(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;D(t),e.selectedOverlays.forEach(n=>{n.style.display=""}),u(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:p(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=>{u(e),oe(e,t)}}function $(e){A(ie(e))}function re(e,t,n){e.currentEditingElement&&d(e),c(e);let o=l(n);o.forEach(a=>{a instanceof HTMLElement&&(a.dataset.selected="true")}),o.forEach(a=>{let g=m(!0);document.body.appendChild(g),e.selectedOverlays.push(g),E(g,a,!0,e.isVisualEditMode)}),e.selectedElementId=n,s(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:p(t.getBoundingClientRect())};window.parent.postMessage(i,"*")}function q(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&&f(r)){v(e,r);return}re(e,o,i||null)}function le(e,t){e.isVisualEditMode=t,t?document.body.style.cursor="crosshair":(e.currentEditingElement&&d(e),s(e),c(e),e.currentHighlightedElements=[],document.body.style.cursor="default")}function z(e,t){le(e,t.data.enabled),t.data.specs?.newInlineEditEnabled!==void 0&&(e.isInlineEditExperimentEnabled=t.data.specs.newInlineEditEnabled)}function X(e,t){if(!e.isInlineEditExperimentEnabled||!t.data||!t.data.dataSourceLocation)return;let n=l(t.data.dataSourceLocation);if(n.length===0||!(n[0]instanceof HTMLElement))return;let o=n[0];if(t.data.inlineEditingMode){if(f(o)){if(e.selectedElementId!==t.data.dataSourceLocation){e.currentEditingElement&&d(e),c(e);let r=l(t.data.dataSourceLocation);r.forEach(i=>{i instanceof HTMLElement&&(i.dataset.selected="true")}),r.forEach(i=>{let a=m(!0);document.body.appendChild(a),e.selectedOverlays.push(a),E(a,i,!0,e.isVisualEditMode)}),e.selectedElementId=t.data.dataSourceLocation}v(e,o)}}else e.currentEditingElement===o&&d(e)}function Q(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:p(o),isInViewport:Y(o),visualSelectorId:e.selectedElementId},"*")}function ae(e){e.currentEditingElement&&d(e),c(e)}function se(e,t,n){let o=l(t);o.length!==0&&(P(o,n),setTimeout(()=>{e.selectedElementId===t&&u(e),e.currentHighlightedElements.length>0&&e.currentHighlightedElements[0]?.dataset?.visualSelectorId===t&&O(e)},50))}function de(e,t,n){let o=l(t);o.length!==0&&(o.forEach(r=>{r.innerText=n}),setTimeout(()=>{e.selectedElementId===t&&u(e)},50))}function w(e){Q(e)}function I(e){u(e),O(e)}function Z(e,t){let n=t.data;switch(n.type){case"toggle-visual-edit-mode":z(e,n);break;case"update-classes":n.data&&n.data.classes!==void 0?se(e,n.data.visualSelectorId,n.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",n);break;case"unselect-element":ae(e);break;case"refresh-page":window.location.reload();break;case"update-content":n.data&&n.data.content!==void 0?de(e,n.data.visualSelectorId,n.data.content):console.warn("[VisualEditAgent] Invalid update-content message:",n);break;case"toggle-inline-edit-mode":X(e,n);break;case"request-element-position":Q(e);break;case"popover-drag-state":n.data&&n.data.isDragging!==void 0&&(e.isPopoverDragging=n.data.isDragging,n.data.isDragging&&s(e));break;case"dropdown-state":n.data&&n.data.isOpen!==void 0&&(e.isDropdownOpen=n.data.isOpen,n.data.isOpen&&s(e));break;default:break}}function Ee(){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 ce(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 ue(){document.addEventListener("keydown",e=>{e.target instanceof HTMLElement&&e.target.contentEditable},!0)}function me(e){window.addEventListener("message",t=>Z(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=>q(e,t),!0),document.addEventListener("mouseover",t=>j(e,t)),document.addEventListener("mouseout",()=>W(e))}function J(){let e=R();Ee(),$(e),ue(),me(e),ce(()=>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{J as setupVisualEditAgent};
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/injections/visual-edit-agent/state/agent-state.ts","../../src/injections/utils.ts","../../src/injections/visual-edit-agent/constants.ts","../../src/injections/visual-edit-agent/ui/overlay.ts","../../src/injections/visual-edit-agent/handlers/hover-handlers.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts","../../src/injections/visual-edit-agent/utils/dom-utils.ts","../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/message-handlers.ts","../../src/injections/visual-edit-agent/handlers/click-handlers.ts","../../src/injections/visual-edit-agent/index.ts"],"sourcesContent":["/**\n * Central state management for the visual edit agent\n */\n\nexport interface AgentState {\n isVisualEditMode: boolean;\n isPopoverDragging: boolean;\n isDropdownOpen: boolean;\n hoverOverlays: HTMLDivElement[];\n selectedOverlays: HTMLDivElement[];\n currentHighlightedElements: Element[];\n selectedElementId: string | null;\n currentEditingElement: HTMLElement | null;\n debouncedSendTimeout: ReturnType<typeof setTimeout> | null;\n isInlineEditExperimentEnabled: boolean;\n}\n\nexport function createAgentState(): AgentState {\n return {\n isVisualEditMode: false,\n isPopoverDragging: false,\n isDropdownOpen: false,\n hoverOverlays: [],\n selectedOverlays: [],\n currentHighlightedElements: [],\n selectedElementId: null,\n currentEditingElement: null,\n debouncedSendTimeout: null,\n isInlineEditExperimentEnabled: false,\n };\n}\n","/** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */\nexport function findElementsById(id: string | null): Element[] {\n if (!id) return [];\n const sourceElements = Array.from(\n document.querySelectorAll(`[data-source-location=\"${id}\"]`)\n );\n if (sourceElements.length > 0) {\n return sourceElements;\n }\n return Array.from(\n document.querySelectorAll(`[data-visual-selector-id=\"${id}\"]`)\n );\n}\n\n/**\n * Update element classes by visual selector ID.\n * Uses setAttribute instead of className to support both HTML and SVG elements.\n */\nexport function updateElementClasses(elements: Element[], classes: string): void {\n elements.forEach((element) => {\n element.setAttribute(\"class\", classes);\n }); \n}\n","export const INLINE_EDIT_DEBOUNCE_MS = 500;\nexport const OVERLAY_TRANSITION = \"all 0.1s ease-in-out\";\nexport const OVERLAY_Z_INDEX = \"9999\";\nexport const SELECTED_BORDER_COLOR = \"#2563EB\";\nexport const HOVER_BORDER_COLOR = \"#95a5fc\";\nexport const HOVER_BACKGROUND_COLOR = \"rgba(99, 102, 241, 0.05)\";\nexport const LABEL_TOP_OFFSET = \"-27px\";\nexport const LABEL_LEFT_OFFSET = \"-2px\";\nexport const REPOSITION_DELAY_MS = 50;\n","import {\n OVERLAY_TRANSITION,\n OVERLAY_Z_INDEX,\n SELECTED_BORDER_COLOR,\n HOVER_BORDER_COLOR,\n HOVER_BACKGROUND_COLOR,\n LABEL_TOP_OFFSET,\n LABEL_LEFT_OFFSET,\n} from \"../constants.js\";\nimport type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\n\n/**\n * Create an overlay element for highlighting\n */\nexport function createOverlay(isSelected = false): HTMLDivElement {\n const overlay = document.createElement(\"div\");\n overlay.style.position = \"absolute\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.transition = OVERLAY_TRANSITION;\n overlay.style.zIndex = OVERLAY_Z_INDEX;\n\n if (isSelected) {\n overlay.style.border = `2px solid ${SELECTED_BORDER_COLOR}`;\n } else {\n overlay.style.border = `2px solid ${HOVER_BORDER_COLOR}`;\n overlay.style.backgroundColor = HOVER_BACKGROUND_COLOR;\n }\n\n return overlay;\n}\n\n/**\n * Position overlay relative to element\n */\nexport function positionOverlay(\n overlay: HTMLDivElement,\n element: Element,\n isSelected = false,\n isVisualEditMode = true\n): void {\n if (!element || !isVisualEditMode) return;\n\n const htmlElement = element as HTMLElement;\n // Force layout recalculation\n void htmlElement.offsetWidth;\n\n const rect = element.getBoundingClientRect();\n overlay.style.top = `${rect.top + window.scrollY}px`;\n overlay.style.left = `${rect.left + window.scrollX}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n\n // Check if label already exists in overlay\n let label = overlay.querySelector(\"div\") as HTMLDivElement | null;\n\n if (!label) {\n label = document.createElement(\"div\");\n label.textContent = element.tagName.toLowerCase();\n label.style.position = \"absolute\";\n label.style.top = LABEL_TOP_OFFSET;\n label.style.left = LABEL_LEFT_OFFSET;\n label.style.padding = \"2px 8px\";\n label.style.fontSize = \"11px\";\n label.style.fontWeight = isSelected ? \"500\" : \"400\";\n label.style.color = isSelected ? \"#ffffff\" : \"#526cff\";\n label.style.backgroundColor = isSelected ? \"#526cff\" : \"#DBEAFE\";\n label.style.borderRadius = \"3px\";\n label.style.minWidth = \"24px\";\n label.style.textAlign = \"center\";\n overlay.appendChild(label);\n }\n}\n\n/**\n * Clear all overlays from DOM\n */\nexport function clearOverlays(overlays: HTMLDivElement[]): void {\n overlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n}\n\n/**\n * Remove data-selected attribute, clear selected overlays, and reset selection state\n */\nexport function clearSelection(state: AgentState): void {\n if (state.selectedElementId) {\n const elements = findElementsById(state.selectedElementId);\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n delete el.dataset.selected;\n }\n });\n }\n clearOverlays(state.selectedOverlays);\n state.selectedOverlays = [];\n state.selectedElementId = null;\n}\n\n/**\n * Reposition selected overlays to match current element bounds\n */\nexport function repositionSelectedOverlays(state: AgentState): void {\n if (!state.selectedElementId) return;\n const elements = findElementsById(state.selectedElementId);\n state.selectedOverlays.forEach((overlay, index) => {\n if (index < elements.length) {\n positionOverlay(overlay, elements[index]!, true, state.isVisualEditMode);\n }\n });\n}\n\n/**\n * Reposition hover overlays to match current element bounds\n */\nexport function repositionHoverOverlays(state: AgentState): void {\n state.hoverOverlays.forEach((overlay, index) => {\n if (index < state.currentHighlightedElements.length) {\n positionOverlay(overlay, state.currentHighlightedElements[index]!, false, state.isVisualEditMode);\n }\n });\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay, clearOverlays } from \"../ui/overlay.js\";\n\n/**\n * Clear hover overlays\n */\nexport function clearHoverOverlays(state: AgentState): void {\n clearOverlays(state.hoverOverlays);\n state.hoverOverlays = [];\n state.currentHighlightedElements = [];\n}\n\n/**\n * Handle mouse over event\n */\nexport function handleMouseOver(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode || state.isPopoverDragging || state.currentEditingElement) return;\n\n const target = e.target as Element;\n\n // Prevent hover effects when a dropdown is open\n if (state.isDropdownOpen) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prevent hover effects on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n clearHoverOverlays(state);\n return;\n }\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prefer data-source-location, fallback to data-visual-selector-id\n const htmlElement = element as HTMLElement;\n const selectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Skip if this element is already selected\n if (state.selectedElementId === selectorId) {\n clearHoverOverlays(state);\n return;\n }\n\n // Find all elements with the same ID\n const elements = findElementsById(selectorId || null);\n\n // Clear previous hover overlays\n clearHoverOverlays(state);\n\n // Create overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(false);\n document.body.appendChild(overlay);\n state.hoverOverlays.push(overlay);\n positionOverlay(overlay, el, false, state.isVisualEditMode);\n });\n\n state.currentHighlightedElements = elements;\n}\n\n/**\n * Handle mouse out event\n */\nexport function handleMouseOut(state: AgentState): void {\n if (state.isPopoverDragging || state.currentEditingElement) return;\n clearHoverOverlays(state);\n}\n","/**\n * Inject CSS to suppress the browser's default focus outline on contentEditable elements\n */\nexport function injectFocusOutlineCSS(): void {\n const existingStyle = document.getElementById(\"visual-edit-focus-styles\");\n if (existingStyle) return;\n\n const style = document.createElement(\"style\");\n style.id = \"visual-edit-focus-styles\";\n style.textContent = `\n [data-selected=\"true\"][contenteditable=\"true\"]:focus {\n outline: none !important;\n }\n `;\n document.head.appendChild(style);\n}\n\n/**\n * Remove the injected focus outline CSS\n */\nexport function removeFocusOutlineCSS(): void {\n const style = document.getElementById(\"visual-edit-focus-styles\");\n if (style) {\n style.remove();\n }\n}\n","/**\n * Select all text content in an element using the Selection API\n */\nexport function selectText(element: HTMLElement): void {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n}\n\n/**\n * Check if an element is an editable text element\n * Based on the eligibility rules from inlineEdit.md (non-dynamic only)\n */\nexport function isEditableTextElement(element: Element): boolean {\n // Must be an HTMLElement\n if (!(element instanceof HTMLElement)) {\n return false;\n }\n\n // Must be an allowed tag\n const allowedTags = [\n \"div\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"span\",\n \"li\",\n \"td\",\n \"a\",\n \"button\",\n \"label\",\n ];\n if (!allowedTags.includes(element.tagName.toLowerCase())) {\n return false;\n }\n\n // Must have text content\n const textContent = element.textContent?.trim() || \"\";\n if (textContent.length === 0) {\n return false;\n }\n\n // Must NOT contain img, video, canvas, or svg\n const hasMediaElements =\n element.querySelector(\"img, video, canvas, svg\") !== null;\n if (hasMediaElements) {\n return false;\n }\n\n // Must NOT have complex children (must be a leaf text node or simple container)\n if (element.children.length > 0) {\n return false;\n }\n\n // Must NOT be dynamic content\n if (element.dataset.dynamicContent === \"true\") {\n return false;\n }\n\n return true;\n}\n","import { injectFocusOutlineCSS, removeFocusOutlineCSS } from \"./styles.js\";\nimport { selectText, isEditableTextElement } from \"./validation.js\";\n\n/**\n * Callback function type for handling text input changes\n */\ntype OnTextInputChange = (element: HTMLElement) => void;\n\n/**\n * Global callback that gets triggered on every input event\n * This is set by the visual-edit-agent and includes both updatePosition and reportInlineEdit\n */\nlet onTextInputChangeCallback: OnTextInputChange | null = null;\n\n/**\n * Set the callback function that will be called on text input changes\n */\nexport function setInlineEditCallback(callback: OnTextInputChange | null): void {\n onTextInputChangeCallback = callback;\n}\n\n/**\n * Internal handler for the native input event\n */\nfunction handleInputEvent(this: HTMLElement, e: Event): void {\n if (onTextInputChangeCallback) {\n onTextInputChangeCallback(this);\n }\n}\n\n/**\n * Check if an element should enter inline editing mode\n * Called when user clicks on an already-selected element\n */\nexport function shouldEnterInlineEditingMode(element: Element): boolean {\n // Must have data-selected=\"true\"\n if (!(element instanceof HTMLElement) || element.dataset.selected !== \"true\") {\n return false;\n }\n\n // Must pass all editability checks\n if (!isEditableTextElement(element)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Enable contentEditable mode on an element\n * Follows the exact flow from inlineEdit.md\n */\nexport function enterInlineEditingMode(element: HTMLElement): void {\n // Inject CSS to suppress focus outline\n injectFocusOutlineCSS();\n\n // Store original state\n element.dataset.originalTextContent = element.textContent || \"\";\n element.dataset.originalCursor = element.style.cursor;\n\n // Enable contentEditable\n element.contentEditable = \"true\";\n\n // Add input event listener\n element.addEventListener(\"input\", handleInputEvent);\n\n // Set cursor to text\n element.style.cursor = \"text\";\n\n // Select all text\n selectText(element);\n\n // Focus after render\n setTimeout(() => {\n element.focus();\n }, 0);\n}\n\n/**\n * Disable contentEditable mode on an element\n * Reverses everything done by enterInlineEditingMode\n */\nexport function clearInlineEditingMode(element: HTMLElement): void {\n removeFocusOutlineCSS();\n\n // Remove input event listener\n element.removeEventListener(\"input\", handleInputEvent);\n\n // Disable contentEditable\n element.contentEditable = \"false\";\n\n // Remove stored original text content\n delete element.dataset.originalTextContent;\n\n // Restore original cursor\n if (element.dataset.originalCursor !== undefined) {\n element.style.cursor = element.dataset.originalCursor;\n delete element.dataset.originalCursor;\n }\n}\n","import type { ElementPosition } from \"../handlers/messages/types.js\";\n\n/**\n * Calculate element position from bounding rect\n */\nexport function getElementPosition(rect: DOMRect): ElementPosition {\n return {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n}\n\n/**\n * Check if element rect is in viewport\n */\nexport function isElementInViewport(rect: DOMRect): boolean {\n return (\n rect.top < window.innerHeight &&\n rect.bottom > 0 &&\n rect.left < window.innerWidth &&\n rect.right > 0\n );\n}\n\n/**\n * Get element classes (handles both HTML and SVG)\n */\nexport function getElementClasses(element: Element): string {\n if (element instanceof SVGElement) {\n return (element.className as unknown as SVGAnimatedString)?.baseVal || \"\";\n }\n return element.className || \"\";\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { repositionSelectedOverlays } from \"../ui/overlay.js\";\nimport {\n enterInlineEditingMode,\n clearInlineEditingMode,\n setInlineEditCallback,\n} from \"../capabilities/inline-editing/index.js\";\nimport { INLINE_EDIT_DEBOUNCE_MS } from \"../constants.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Enter inline editing mode\n */\nexport function handleEnterInlineEditingMode(state: AgentState, element: HTMLElement): void {\n state.currentEditingElement = element;\n\n // Hide overlays during editing\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"none\";\n });\n\n // Enter inline editing mode (from capabilities/inline-editing)\n enterInlineEditingMode(element);\n\n // Notify parent\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_STARTED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Clear inline editing mode\n */\nexport function handleClearInlineEditingMode(state: AgentState): void {\n if (!state.currentEditingElement) return;\n\n const element = state.currentEditingElement;\n\n // Clear inline editing mode (from capabilities/inline-editing)\n clearInlineEditingMode(element);\n\n // Show overlays again\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"\";\n });\n\n repositionSelectedOverlays(state);\n\n // Notify parent that editing ended\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_ENDED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n\n state.currentEditingElement = null;\n}\n\n/**\n * Report inline edit to parent\n */\nfunction reportInlineEdit(state: AgentState, element: HTMLElement): void {\n const originalContent = element.dataset.originalTextContent;\n const newContent = element.textContent;\n\n const elementInfo = {\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: state.selectedElementId,\n content: newContent,\n dataSourceLocation: element.dataset.sourceLocation,\n isDynamicContent: element.dataset.dynamicContent === \"true\",\n linenumber: element.dataset.linenumber,\n filename: element.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n\n // Send inline edit message\n window.parent.postMessage(\n {\n type: OutgoingMessageType.INLINE_EDIT,\n elementInfo,\n originalContent,\n newContent,\n },\n \"*\"\n );\n\n // Update baseline for next edit\n element.dataset.originalTextContent = newContent || \"\";\n}\n\n/**\n * Debounced function to send inline edit messages\n */\nfunction debouncedSendInlineEditMessage(state: AgentState, element: HTMLElement): void {\n // Clear any existing timeout\n if (state.debouncedSendTimeout) {\n clearTimeout(state.debouncedSendTimeout);\n }\n\n // Set new timeout\n state.debouncedSendTimeout = setTimeout(() => {\n reportInlineEdit(state, element);\n }, INLINE_EDIT_DEBOUNCE_MS);\n}\n\n/**\n * Callback for text input changes (combines updatePosition and reportInlineEdit)\n */\nfunction createTextInputChangeCallback(state: AgentState) {\n return (element: HTMLElement) => {\n repositionSelectedOverlays(state);\n debouncedSendInlineEditMessage(state, element);\n };\n}\n\n/**\n * Setup inline edit callback\n */\nexport function setupInlineEditCallback(state: AgentState): void {\n setInlineEditCallback(createTextInputChangeCallback(state));\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleVisualEditModeMessage } from \"./types.js\";\nimport { clearSelection } from \"../../ui/overlay.js\";\nimport { clearHoverOverlays } from \"../hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\n\n/**\n * Toggle visual edit mode on/off\n */\nexport function toggleVisualEditMode(state: AgentState, isEnabled: boolean): void {\n state.isVisualEditMode = isEnabled;\n\n if (!isEnabled) {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n\n clearHoverOverlays(state);\n clearSelection(state);\n state.currentHighlightedElements = [];\n document.body.style.cursor = \"default\";\n } else {\n document.body.style.cursor = \"crosshair\";\n }\n}\n\n/**\n * Handle toggle-visual-edit-mode message\n */\nexport function handleToggleVisualEditMode(\n state: AgentState,\n message: ToggleVisualEditModeMessage\n): void {\n toggleVisualEditMode(state, message.data.enabled);\n \n // Update inline edit experiment flag if provided\n if (message.data.specs?.newInlineEditEnabled !== undefined) {\n state.isInlineEditExperimentEnabled = message.data.specs.newInlineEditEnabled;\n console.log('[VisualEditAgent] Inline edit experiment:', state.isInlineEditExperimentEnabled);\n }\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleInlineEditModeMessage } from \"./types.js\";\nimport { findElementsById } from \"../../../utils.js\";\nimport { shouldEnterInlineEditingMode } from \"../../capabilities/inline-editing/index.js\";\nimport { handleElementSelection } from \"../click-handlers.js\";\nimport { handleEnterInlineEditingMode, handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\n\n/**\n * Handle toggle-inline-edit-mode message (parent-initiated)\n */\nexport function handleToggleInlineEditMode(\n state: AgentState,\n message: ToggleInlineEditModeMessage\n): void {\n // Check if inline edit experiment is enabled\n if (!state.isInlineEditExperimentEnabled) {\n console.log('[VisualEditAgent] toggle-inline-edit-mode ignored - experiment flag not enabled');\n return;\n }\n \n console.log('[VisualEditAgent] Processing toggle-inline-edit-mode message');\n \n // Parent-initiated inline editing mode toggle\n if (!message.data || !message.data.dataSourceLocation) {\n console.warn('[VisualEditAgent] Invalid toggle-inline-edit-mode message - missing dataSourceLocation');\n return;\n }\n\n const elements = findElementsById(message.data.dataSourceLocation);\n if (elements.length === 0 || !(elements[0] instanceof HTMLElement)) {\n return;\n }\n\n const element = elements[0];\n\n if (message.data.inlineEditingMode) {\n // Enable inline editing (only for non-dynamic text elements)\n if (shouldEnterInlineEditingMode(element)) {\n // Select the element first if not already selected\n if (state.selectedElementId !== message.data.dataSourceLocation) {\n handleElementSelection(state, element, message.data.dataSourceLocation);\n }\n handleEnterInlineEditingMode(state, element);\n }\n } else {\n // Disable inline editing\n if (state.currentEditingElement === element) {\n handleClearInlineEditingMode(state);\n }\n }\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { IncomingMessageType, OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById, updateElementClasses } from \"../../utils.js\";\nimport { clearSelection, repositionSelectedOverlays, repositionHoverOverlays } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { REPOSITION_DELAY_MS } from \"../constants.js\";\nimport { handleToggleVisualEditMode } from \"./messages/toggle-visual-edit-mode.js\";\nimport { handleToggleInlineEditMode } from \"./messages/toggle-inline-edit-mode.js\";\nimport { getElementPosition, isElementInViewport } from \"../utils/dom-utils.js\";\n\n/**\n * Send element position update to parent\n */\nfunction sendElementPositionUpdate(state: AgentState): void {\n if (!state.selectedElementId) return;\n\n const elements = findElementsById(state.selectedElementId);\n if (elements.length === 0) return;\n\n const element = elements[0];\n const rect = element!.getBoundingClientRect();\n\n window.parent.postMessage(\n {\n type: OutgoingMessageType.ELEMENT_POSITION_UPDATE,\n position: getElementPosition(rect),\n isInViewport: isElementInViewport(rect),\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Unselect the current element\n */\nexport function unselectElement(state: AgentState): void {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n}\n\n/**\n * Update element classes and reposition overlays\n */\nexport function updateElementClassesAndReposition(\n state: AgentState,\n visualSelectorId: string,\n classes: string\n): void {\n const elements = findElementsById(visualSelectorId);\n if (elements.length === 0) return;\n\n updateElementClasses(elements, classes);\n\n // Use a small delay to allow the browser to recalculate layout before repositioning\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n\n if (state.currentHighlightedElements.length > 0) {\n const hoveredElement = state.currentHighlightedElements[0] as HTMLElement;\n if (hoveredElement?.dataset?.visualSelectorId === visualSelectorId) {\n repositionHoverOverlays(state);\n }\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Update element content by visual selector ID\n */\nexport function updateElementContent(\n state: AgentState,\n visualSelectorId: string,\n content: string\n): void {\n const elements = findElementsById(visualSelectorId);\n\n if (elements.length === 0) {\n return;\n }\n\n elements.forEach((element) => {\n (element as HTMLElement).innerText = content;\n });\n\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Handle scroll events to update popover position\n */\nexport function handleScroll(state: AgentState): void {\n sendElementPositionUpdate(state);\n}\n\n/**\n * Handle window resize to reposition overlays\n */\nexport function handleResize(state: AgentState): void {\n repositionSelectedOverlays(state);\n repositionHoverOverlays(state);\n}\n\n/**\n * Handle messages from parent window\n */\nexport function handleMessage(state: AgentState, event: MessageEvent): void {\n const message = event.data;\n\n switch (message.type as IncomingMessageType) {\n case IncomingMessageType.TOGGLE_VISUAL_EDIT_MODE:\n handleToggleVisualEditMode(state, message);\n break;\n\n case IncomingMessageType.UPDATE_CLASSES:\n if (message.data && message.data.classes !== undefined) {\n updateElementClassesAndReposition(\n state,\n message.data.visualSelectorId,\n message.data.classes\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-classes message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.UNSELECT_ELEMENT:\n unselectElement(state);\n break;\n\n case IncomingMessageType.REFRESH_PAGE:\n window.location.reload();\n break;\n\n case IncomingMessageType.UPDATE_CONTENT:\n if (message.data && message.data.content !== undefined) {\n updateElementContent(\n state,\n message.data.visualSelectorId,\n message.data.content\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-content message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.TOGGLE_INLINE_EDIT_MODE:\n handleToggleInlineEditMode(state, message);\n break;\n\n case IncomingMessageType.REQUEST_ELEMENT_POSITION:\n sendElementPositionUpdate(state);\n break;\n\n case IncomingMessageType.POPOVER_DRAG_STATE:\n if (message.data && message.data.isDragging !== undefined) {\n state.isPopoverDragging = message.data.isDragging;\n if (message.data.isDragging) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n case IncomingMessageType.DROPDOWN_STATE:\n if (message.data && message.data.isOpen !== undefined) {\n state.isDropdownOpen = message.data.isOpen;\n if (message.data.isOpen) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n default:\n break;\n }\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { shouldEnterInlineEditingMode } from \"../capabilities/inline-editing/index.js\";\nimport { handleClearInlineEditingMode, handleEnterInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { unselectElement } from \"./message-handlers.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Handle element selection (first click)\n */\nexport function handleElementSelection(\n state: AgentState,\n element: Element,\n visualSelectorId: string | null\n): void {\n unselectElement(state);\n\n // Find all elements with the same ID\n const elements = findElementsById(visualSelectorId);\n\n // Mark elements as selected\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n el.dataset.selected = \"true\";\n }\n });\n\n // Create selected overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n state.selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true, state.isVisualEditMode);\n });\n\n state.selectedElementId = visualSelectorId;\n\n // Clear hover overlays\n clearHoverOverlays(state);\n\n // Send message to parent window with element info\n const htmlElement = element as HTMLElement;\n const elementData = {\n type: OutgoingMessageType.ELEMENT_SELECTED,\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: visualSelectorId,\n content: htmlElement.innerText,\n dataSourceLocation: htmlElement.dataset.sourceLocation,\n isDynamicContent: htmlElement.dataset.dynamicContent === \"true\",\n linenumber: htmlElement.dataset.linenumber,\n filename: htmlElement.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n window.parent.postMessage(elementData, \"*\");\n}\n\n/**\n * Handle element click\n */\nexport function handleElementClick(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode) return;\n\n const target = e.target as Element;\n\n // Bail out early if clicking on a contentEditable element (allow normal editing)\n if (target instanceof HTMLElement && target.contentEditable === \"true\") {\n return;\n }\n\n // If currently editing, clicking outside should exit editing mode\n if (state.currentEditingElement) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n handleClearInlineEditingMode(state);\n return;\n }\n\n // Close dropdowns when clicking anywhere in iframe if a dropdown is open\n if (state.isDropdownOpen) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n window.parent.postMessage({ type: OutgoingMessageType.CLOSE_DROPDOWNS }, \"*\");\n return;\n }\n\n // Prevent clicking on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n return;\n }\n\n // Prevent default behavior immediately when in visual edit mode\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n return;\n }\n\n const htmlElement = element as HTMLElement;\n const visualSelectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Check if this element is already selected (second click scenario)\n const isAlreadySelected =\n state.selectedElementId === visualSelectorId &&\n htmlElement.dataset.selected === \"true\";\n\n if (isAlreadySelected) {\n // Second click on already-selected element: check if it should enter inline editing\n // Only if the experiment is enabled\n if (state.isInlineEditExperimentEnabled && shouldEnterInlineEditingMode(htmlElement)) {\n console.log('[VisualEditAgent] Entering inline edit mode');\n handleEnterInlineEditingMode(state, htmlElement);\n return;\n } else if (!state.isInlineEditExperimentEnabled) {\n console.log('[VisualEditAgent] Inline edit disabled - experiment flag not enabled');\n }\n }\n\n // First click: select the element\n handleElementSelection(state, element, visualSelectorId || null);\n}\n","import { createAgentState } from \"./state/agent-state.js\";\nimport { handleMouseOver, handleMouseOut } from \"./handlers/hover-handlers.js\";\nimport { handleElementClick } from \"./handlers/click-handlers.js\";\nimport { handleMessage, handleScroll, handleResize } from \"./handlers/message-handlers.js\";\nimport { setupInlineEditCallback } from \"./handlers/inline-edit-handlers.js\";\nimport { OutgoingMessageType } from \"./handlers/messages/types.js\";\n\n/**\n * Initialize element IDs for elements with line numbers\n */\nfunction initializeElementIds(): void {\n const elementsWithLineNumber = document.querySelectorAll(\n \"[data-linenumber]:not([data-visual-selector-id])\"\n );\n elementsWithLineNumber.forEach((el, index) => {\n const htmlEl = el as HTMLElement;\n const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;\n htmlEl.dataset.visualSelectorId = id;\n });\n}\n\n/**\n * Create mutation observer to detect layout changes\n */\nfunction createLayoutObserver(onLayoutChange: () => void): MutationObserver {\n return new MutationObserver((mutations) => {\n const needsUpdate = mutations.some((mutation) => {\n const hasVisualId = (node: Node): boolean => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const el = node as HTMLElement;\n if (el.dataset && el.dataset.visualSelectorId) {\n return true;\n }\n for (let i = 0; i < el.children.length; i++) {\n if (hasVisualId(el.children[i]!)) {\n return true;\n }\n }\n }\n return false;\n };\n\n const isLayoutChange =\n mutation.type === \"attributes\" &&\n (mutation.attributeName === \"style\" ||\n mutation.attributeName === \"class\" ||\n mutation.attributeName === \"width\" ||\n mutation.attributeName === \"height\");\n\n return isLayoutChange && hasVisualId(mutation.target);\n });\n\n if (needsUpdate) {\n setTimeout(onLayoutChange, 50);\n }\n });\n}\n\n/**\n * Setup keyboard event protection\n */\nfunction setupKeyboardProtection(): void {\n document.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.target instanceof HTMLElement && e.target.contentEditable === \"true\") {\n // Don't report keyboard events during inline editing\n return;\n }\n // Forward other keyboard events to parent if needed\n }, true);\n}\n\n/**\n * Setup event listeners\n */\nfunction setupEventListeners(state: ReturnType<typeof createAgentState>): void {\n // Message handling\n window.addEventListener(\"message\", (e) => handleMessage(state, e));\n\n // Scroll handling\n window.addEventListener(\"scroll\", () => handleScroll(state), true);\n document.addEventListener(\"scroll\", () => handleScroll(state), true);\n\n // Resize handling\n window.addEventListener(\"resize\", () => handleResize(state));\n window.addEventListener(\"scroll\", () => handleResize(state));\n\n // Click handling\n document.addEventListener(\"click\", (e) => handleElementClick(state, e), true);\n\n // Hover handling\n document.addEventListener(\"mouseover\", (e) => handleMouseOver(state, e));\n document.addEventListener(\"mouseout\", () => handleMouseOut(state));\n}\n\n/**\n * Main setup function for visual edit agent\n */\nexport function setupVisualEditAgent(): void {\n const state = createAgentState();\n initializeElementIds();\n setupInlineEditCallback(state);\n setupKeyboardProtection();\n setupEventListeners(state);\n\n // Create and start mutation observer\n const mutationObserver = createLayoutObserver(() => handleResize(state));\n mutationObserver.observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n attributeFilter: [\"style\", \"class\", \"width\", \"height\"],\n });\n\n // Send ready message to parent\n window.parent.postMessage({ type: OutgoingMessageType.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State","findElementsById","id","sourceElements","updateElementClasses","elements","classes","element","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","createOverlay","isSelected","overlay","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","positionOverlay","element","isVisualEditMode","rect","label","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","clearOverlays","overlays","clearSelection","state","findElementsById","el","repositionSelectedOverlays","elements","index","repositionHoverOverlays","clearHoverOverlays","state","clearOverlays","handleMouseOver","e","target","element","htmlElement","selectorId","elements","findElementsById","el","overlay","createOverlay","positionOverlay","handleMouseOut","injectFocusOutlineCSS","style","removeFocusOutlineCSS","selectText","element","range","selection","isEditableTextElement","onTextInputChangeCallback","setInlineEditCallback","callback","handleInputEvent","shouldEnterInlineEditingMode","element","isEditableTextElement","enterInlineEditingMode","injectFocusOutlineCSS","selectText","clearInlineEditingMode","removeFocusOutlineCSS","getElementPosition","rect","isElementInViewport","getElementClasses","element","handleEnterInlineEditingMode","state","element","overlay","enterInlineEditingMode","handleClearInlineEditingMode","clearInlineEditingMode","repositionSelectedOverlays","reportInlineEdit","originalContent","newContent","elementInfo","getElementClasses","getElementPosition","debouncedSendInlineEditMessage","createTextInputChangeCallback","setupInlineEditCallback","setInlineEditCallback","toggleVisualEditMode","state","isEnabled","handleClearInlineEditingMode","clearHoverOverlays","clearSelection","handleToggleVisualEditMode","message","handleToggleInlineEditMode","state","message","elements","findElementsById","element","shouldEnterInlineEditingMode","handleElementSelection","handleEnterInlineEditingMode","handleClearInlineEditingMode","sendElementPositionUpdate","state","elements","findElementsById","rect","getElementPosition","isElementInViewport","unselectElement","handleClearInlineEditingMode","clearSelection","updateElementClassesAndReposition","visualSelectorId","classes","updateElementClasses","repositionSelectedOverlays","repositionHoverOverlays","updateElementContent","content","element","handleScroll","handleResize","handleMessage","event","message","handleToggleVisualEditMode","handleToggleInlineEditMode","clearHoverOverlays","handleElementSelection","state","element","visualSelectorId","unselectElement","elements","findElementsById","el","overlay","createOverlay","positionOverlay","clearHoverOverlays","htmlElement","elementData","getElementClasses","getElementPosition","handleElementClick","e","target","handleClearInlineEditingMode","shouldEnterInlineEditingMode","handleEnterInlineEditingMode","initializeElementIds","el","index","htmlEl","id","createLayoutObserver","onLayoutChange","mutations","mutation","hasVisualId","node","i","setupKeyboardProtection","setupEventListeners","state","e","handleMessage","handleScroll","handleResize","handleElementClick","handleMouseOver","handleMouseOut","setupVisualEditAgent","createAgentState","setupInlineEditCallback"]}
|
|
1
|
+
{"version":3,"sources":["../../src/injections/visual-edit-agent/state/agent-state.ts","../../src/injections/utils.ts","../../src/injections/visual-edit-agent/constants.ts","../../src/injections/visual-edit-agent/ui/overlay.ts","../../src/injections/visual-edit-agent/handlers/hover-handlers.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts","../../src/injections/visual-edit-agent/utils/dom-utils.ts","../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts","../../src/injections/visual-edit-agent/handlers/click-handlers.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/message-handlers.ts","../../src/injections/visual-edit-agent/index.ts"],"sourcesContent":["/**\n * Central state management for the visual edit agent\n */\n\nexport interface AgentState {\n isVisualEditMode: boolean;\n isPopoverDragging: boolean;\n isDropdownOpen: boolean;\n hoverOverlays: HTMLDivElement[];\n selectedOverlays: HTMLDivElement[];\n currentHighlightedElements: Element[];\n selectedElementId: string | null;\n currentEditingElement: HTMLElement | null;\n debouncedSendTimeout: ReturnType<typeof setTimeout> | null;\n isInlineEditExperimentEnabled: boolean;\n}\n\nexport function createAgentState(): AgentState {\n return {\n isVisualEditMode: false,\n isPopoverDragging: false,\n isDropdownOpen: false,\n hoverOverlays: [],\n selectedOverlays: [],\n currentHighlightedElements: [],\n selectedElementId: null,\n currentEditingElement: null,\n debouncedSendTimeout: null,\n isInlineEditExperimentEnabled: false,\n };\n}\n","/** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */\nexport function findElementsById(id: string | null): Element[] {\n if (!id) return [];\n const sourceElements = Array.from(\n document.querySelectorAll(`[data-source-location=\"${id}\"]`)\n );\n if (sourceElements.length > 0) {\n return sourceElements;\n }\n return Array.from(\n document.querySelectorAll(`[data-visual-selector-id=\"${id}\"]`)\n );\n}\n\n/**\n * Update element classes by visual selector ID.\n * Uses setAttribute instead of className to support both HTML and SVG elements.\n */\nexport function updateElementClasses(elements: Element[], classes: string): void {\n elements.forEach((element) => {\n element.setAttribute(\"class\", classes);\n }); \n}\n","export const INLINE_EDIT_DEBOUNCE_MS = 500;\nexport const OVERLAY_TRANSITION = \"all 0.1s ease-in-out\";\nexport const OVERLAY_Z_INDEX = \"9999\";\nexport const SELECTED_BORDER_COLOR = \"#2563EB\";\nexport const HOVER_BORDER_COLOR = \"#95a5fc\";\nexport const HOVER_BACKGROUND_COLOR = \"rgba(99, 102, 241, 0.05)\";\nexport const LABEL_TOP_OFFSET = \"-27px\";\nexport const LABEL_LEFT_OFFSET = \"-2px\";\nexport const REPOSITION_DELAY_MS = 50;\n","import {\n OVERLAY_TRANSITION,\n OVERLAY_Z_INDEX,\n SELECTED_BORDER_COLOR,\n HOVER_BORDER_COLOR,\n HOVER_BACKGROUND_COLOR,\n LABEL_TOP_OFFSET,\n LABEL_LEFT_OFFSET,\n} from \"../constants.js\";\nimport type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\n\n/**\n * Create an overlay element for highlighting\n */\nexport function createOverlay(isSelected = false): HTMLDivElement {\n const overlay = document.createElement(\"div\");\n overlay.style.position = \"absolute\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.transition = OVERLAY_TRANSITION;\n overlay.style.zIndex = OVERLAY_Z_INDEX;\n\n if (isSelected) {\n overlay.style.border = `2px solid ${SELECTED_BORDER_COLOR}`;\n } else {\n overlay.style.border = `2px solid ${HOVER_BORDER_COLOR}`;\n overlay.style.backgroundColor = HOVER_BACKGROUND_COLOR;\n }\n\n return overlay;\n}\n\n/**\n * Position overlay relative to element\n */\nexport function positionOverlay(\n overlay: HTMLDivElement,\n element: Element,\n isSelected = false,\n isVisualEditMode = true\n): void {\n if (!element || !isVisualEditMode) return;\n\n const rect = element.getBoundingClientRect();\n overlay.style.top = `${rect.top + window.scrollY}px`;\n overlay.style.left = `${rect.left + window.scrollX}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n\n // Check if label already exists in overlay\n let label = overlay.querySelector(\"div\") as HTMLDivElement | null;\n\n if (!label) {\n label = document.createElement(\"div\");\n label.textContent = element.tagName.toLowerCase();\n label.style.position = \"absolute\";\n label.style.top = LABEL_TOP_OFFSET;\n label.style.left = LABEL_LEFT_OFFSET;\n label.style.padding = \"2px 8px\";\n label.style.fontSize = \"11px\";\n label.style.fontWeight = isSelected ? \"500\" : \"400\";\n label.style.color = isSelected ? \"#ffffff\" : \"#526cff\";\n label.style.backgroundColor = isSelected ? \"#526cff\" : \"#DBEAFE\";\n label.style.borderRadius = \"3px\";\n label.style.minWidth = \"24px\";\n label.style.textAlign = \"center\";\n overlay.appendChild(label);\n }\n}\n\n/**\n * Clear all overlays from DOM\n */\nexport function clearOverlays(overlays: HTMLDivElement[]): void {\n overlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n}\n\n/**\n * Remove data-selected attribute, clear selected overlays, and reset selection state\n */\nexport function clearSelection(state: AgentState): void {\n if (state.selectedElementId) {\n const elements = findElementsById(state.selectedElementId);\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n delete el.dataset.selected;\n }\n });\n }\n clearOverlays(state.selectedOverlays);\n state.selectedOverlays = [];\n state.selectedElementId = null;\n}\n\n/**\n * Reposition selected overlays to match current element bounds\n */\nexport function repositionSelectedOverlays(state: AgentState): void {\n if (!state.selectedElementId) return;\n const elements = findElementsById(state.selectedElementId);\n state.selectedOverlays.forEach((overlay, index) => {\n if (index < elements.length) {\n positionOverlay(overlay, elements[index]!, true, state.isVisualEditMode);\n }\n });\n}\n\n/**\n * Reposition hover overlays to match current element bounds\n */\nexport function repositionHoverOverlays(state: AgentState): void {\n state.hoverOverlays.forEach((overlay, index) => {\n if (index < state.currentHighlightedElements.length) {\n positionOverlay(overlay, state.currentHighlightedElements[index]!, false, state.isVisualEditMode);\n }\n });\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay, clearOverlays } from \"../ui/overlay.js\";\n\n/**\n * Clear hover overlays\n */\nexport function clearHoverOverlays(state: AgentState): void {\n clearOverlays(state.hoverOverlays);\n state.hoverOverlays = [];\n state.currentHighlightedElements = [];\n}\n\n/**\n * Handle mouse over event\n */\nexport function handleMouseOver(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode || state.isPopoverDragging || state.currentEditingElement) return;\n\n const target = e.target as Element;\n\n // Prevent hover effects when a dropdown is open\n if (state.isDropdownOpen) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prevent hover effects on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n clearHoverOverlays(state);\n return;\n }\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prefer data-source-location, fallback to data-visual-selector-id\n const htmlElement = element as HTMLElement;\n const selectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Skip if this element is already selected\n if (state.selectedElementId === selectorId) {\n clearHoverOverlays(state);\n return;\n }\n\n // Find all elements with the same ID\n const elements = findElementsById(selectorId || null);\n\n // Clear previous hover overlays\n clearHoverOverlays(state);\n\n // Create overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(false);\n document.body.appendChild(overlay);\n state.hoverOverlays.push(overlay);\n positionOverlay(overlay, el, false, state.isVisualEditMode);\n });\n\n state.currentHighlightedElements = elements;\n}\n\n/**\n * Handle mouse out event\n */\nexport function handleMouseOut(state: AgentState): void {\n if (state.isPopoverDragging || state.currentEditingElement) return;\n clearHoverOverlays(state);\n}\n","/**\n * Inject CSS to suppress the browser's default focus outline on contentEditable elements\n */\nexport function injectFocusOutlineCSS(): void {\n const existingStyle = document.getElementById(\"visual-edit-focus-styles\");\n if (existingStyle) return;\n\n const style = document.createElement(\"style\");\n style.id = \"visual-edit-focus-styles\";\n style.textContent = `\n [data-selected=\"true\"][contenteditable=\"true\"]:focus {\n outline: none !important;\n }\n `;\n document.head.appendChild(style);\n}\n\n/**\n * Remove the injected focus outline CSS\n */\nexport function removeFocusOutlineCSS(): void {\n const style = document.getElementById(\"visual-edit-focus-styles\");\n if (style) {\n style.remove();\n }\n}\n","/**\n * Select all text content in an element using the Selection API\n */\nexport function selectText(element: HTMLElement): void {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n}\n\n/**\n * Check if an element is an editable text element\n * Based on the eligibility rules from inlineEdit.md (non-dynamic only)\n */\nexport function isEditableTextElement(element: Element): boolean {\n // Must be an HTMLElement\n if (!(element instanceof HTMLElement)) {\n return false;\n }\n\n // Must be an allowed tag\n const allowedTags = [\n \"div\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"span\",\n \"li\",\n \"td\",\n \"a\",\n \"button\",\n \"label\",\n ];\n if (!allowedTags.includes(element.tagName.toLowerCase())) {\n return false;\n }\n\n // Must have text content\n const textContent = element.textContent?.trim() || \"\";\n if (textContent.length === 0) {\n return false;\n }\n\n // Must NOT contain img, video, canvas, or svg\n const hasMediaElements =\n element.querySelector(\"img, video, canvas, svg\") !== null;\n if (hasMediaElements) {\n return false;\n }\n\n // Must NOT have complex children (must be a leaf text node or simple container)\n if (element.children.length > 0) {\n return false;\n }\n\n // Must NOT be dynamic content\n if (element.dataset.dynamicContent === \"true\") {\n return false;\n }\n\n return true;\n}\n","import { injectFocusOutlineCSS, removeFocusOutlineCSS } from \"./styles.js\";\nimport { selectText, isEditableTextElement } from \"./validation.js\";\n\n/**\n * Callback function type for handling text input changes\n */\ntype OnTextInputChange = (element: HTMLElement) => void;\n\n/**\n * Global callback that gets triggered on every input event\n * This is set by the visual-edit-agent and includes both updatePosition and reportInlineEdit\n */\nlet onTextInputChangeCallback: OnTextInputChange | null = null;\n\n/**\n * Set the callback function that will be called on text input changes\n */\nexport function setInlineEditCallback(callback: OnTextInputChange | null): void {\n onTextInputChangeCallback = callback;\n}\n\n/**\n * WeakMap to track AbortControllers for each element's input listener.\n * Using WeakMap ensures no memory leaks — when an element is garbage collected,\n * its entry is automatically removed.\n */\nconst listenerAbortControllers = new WeakMap<HTMLElement, AbortController>();\n\n/**\n * Internal handler for the native input event\n */\nfunction handleInputEvent(this: HTMLElement, e: Event): void {\n if (onTextInputChangeCallback) {\n onTextInputChangeCallback(this);\n }\n}\n\n/**\n * Check if an element should enter inline editing mode\n * Called when user clicks on an already-selected element\n */\nexport function shouldEnterInlineEditingMode(element: Element): boolean {\n // Must have data-selected=\"true\"\n if (!(element instanceof HTMLElement) || element.dataset.selected !== \"true\") {\n return false;\n }\n\n // Must pass all editability checks\n if (!isEditableTextElement(element)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Enable contentEditable mode on an element\n * Follows the exact flow from inlineEdit.md\n */\nexport function enterInlineEditingMode(element: HTMLElement): void {\n // Inject CSS to suppress focus outline\n injectFocusOutlineCSS();\n\n // Store original state\n element.dataset.originalTextContent = element.textContent || \"\";\n element.dataset.originalCursor = element.style.cursor;\n\n // Enable contentEditable\n element.contentEditable = \"true\";\n\n // Create an AbortController to manage the input listener lifecycle\n const abortController = new AbortController();\n listenerAbortControllers.set(element, abortController);\n\n // Add input event listener with AbortSignal for automatic cleanup\n element.addEventListener(\"input\", handleInputEvent, { signal: abortController.signal });\n\n // Set cursor to text\n element.style.cursor = \"text\";\n\n // Select all text\n selectText(element);\n\n // Focus after render\n setTimeout(() => {\n element.focus();\n }, 0);\n}\n\n/**\n * Disable contentEditable mode on an element\n * Reverses everything done by enterInlineEditingMode\n */\nexport function clearInlineEditingMode(element: HTMLElement): void {\n removeFocusOutlineCSS();\n\n // Abort the input event listener using the stored AbortController\n const abortController = listenerAbortControllers.get(element);\n if (abortController) {\n abortController.abort();\n listenerAbortControllers.delete(element);\n }\n\n // Disable contentEditable\n element.contentEditable = \"false\";\n\n // Remove stored original text content\n delete element.dataset.originalTextContent;\n\n // Restore original cursor\n if (element.dataset.originalCursor !== undefined) {\n element.style.cursor = element.dataset.originalCursor;\n delete element.dataset.originalCursor;\n }\n}\n","import type { ElementPosition } from \"../handlers/messages/types.js\";\n\n/**\n * Calculate element position from bounding rect\n */\nexport function getElementPosition(rect: DOMRect): ElementPosition {\n return {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n}\n\n/**\n * Check if element rect is in viewport\n */\nexport function isElementInViewport(rect: DOMRect): boolean {\n return (\n rect.top < window.innerHeight &&\n rect.bottom > 0 &&\n rect.left < window.innerWidth &&\n rect.right > 0\n );\n}\n\n/**\n * Get element classes (handles both HTML and SVG)\n */\nexport function getElementClasses(element: Element): string {\n if (element instanceof SVGElement) {\n return (element.className as unknown as SVGAnimatedString)?.baseVal || \"\";\n }\n return element.className || \"\";\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { repositionSelectedOverlays } from \"../ui/overlay.js\";\nimport {\n enterInlineEditingMode,\n clearInlineEditingMode,\n setInlineEditCallback,\n} from \"../capabilities/inline-editing/index.js\";\nimport { INLINE_EDIT_DEBOUNCE_MS } from \"../constants.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Enter inline editing mode\n */\nexport function handleEnterInlineEditingMode(state: AgentState, element: HTMLElement): void {\n state.currentEditingElement = element;\n\n // Hide overlays during editing\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"none\";\n });\n\n // Enter inline editing mode (from capabilities/inline-editing)\n enterInlineEditingMode(element);\n\n // Notify parent\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_STARTED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Clear inline editing mode\n */\nexport function handleClearInlineEditingMode(state: AgentState): void {\n if (!state.currentEditingElement) return;\n\n // Cancel any pending debounced edit — originalTextContent will be deleted below\n if (state.debouncedSendTimeout) {\n clearTimeout(state.debouncedSendTimeout);\n state.debouncedSendTimeout = null;\n }\n\n const element = state.currentEditingElement;\n\n // Clear inline editing mode (from capabilities/inline-editing)\n clearInlineEditingMode(element);\n\n // Show overlays again\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"\";\n });\n\n repositionSelectedOverlays(state);\n\n // Notify parent that editing ended\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_ENDED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n\n state.currentEditingElement = null;\n}\n\n/**\n * Report inline edit to parent\n */\nfunction reportInlineEdit(state: AgentState, element: HTMLElement): void {\n const originalContent = element.dataset.originalTextContent;\n const newContent = element.textContent;\n\n const elementInfo = {\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: state.selectedElementId,\n content: newContent,\n dataSourceLocation: element.dataset.sourceLocation,\n isDynamicContent: element.dataset.dynamicContent === \"true\",\n linenumber: element.dataset.linenumber,\n filename: element.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n\n // Send inline edit message\n window.parent.postMessage(\n {\n type: OutgoingMessageType.INLINE_EDIT,\n elementInfo,\n originalContent,\n newContent,\n },\n \"*\"\n );\n\n // Update baseline for next edit\n element.dataset.originalTextContent = newContent || \"\";\n}\n\n/**\n * Debounced function to send inline edit messages\n * \n * Intentionally overwrites the previous timeout on each keystroke — this is the\n * correct debounce behavior. We only send ONE message 500ms after the user stops\n * typing, containing the final text. Intermediate keystrokes are not sent to avoid\n * flooding the parent with dozens of messages per second.\n */\nfunction debouncedSendInlineEditMessage(state: AgentState, element: HTMLElement): void {\n // Clear any existing timeout\n if (state.debouncedSendTimeout) {\n clearTimeout(state.debouncedSendTimeout);\n }\n\n // Set new timeout\n state.debouncedSendTimeout = setTimeout(() => {\n reportInlineEdit(state, element);\n }, INLINE_EDIT_DEBOUNCE_MS);\n}\n\n/**\n * Callback for text input changes (combines updatePosition and reportInlineEdit)\n */\nfunction createTextInputChangeCallback(state: AgentState) {\n return (element: HTMLElement) => {\n repositionSelectedOverlays(state);\n debouncedSendInlineEditMessage(state, element);\n };\n}\n\n/**\n * Setup inline edit callback\n */\nexport function setupInlineEditCallback(state: AgentState): void {\n setInlineEditCallback(createTextInputChangeCallback(state));\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay, clearSelection } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { shouldEnterInlineEditingMode } from \"../capabilities/inline-editing/index.js\";\nimport { handleClearInlineEditingMode, handleEnterInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Handle element selection (first click)\n */\nexport function handleElementSelection(\n state: AgentState,\n element: Element,\n visualSelectorId: string | null\n): void {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n\n // Find all elements with the same ID\n const elements = findElementsById(visualSelectorId);\n\n // Mark elements as selected\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n el.dataset.selected = \"true\";\n }\n });\n\n // Create selected overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n state.selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true, state.isVisualEditMode);\n });\n\n state.selectedElementId = visualSelectorId;\n\n // Clear hover overlays\n clearHoverOverlays(state);\n\n // Send message to parent window with element info\n const htmlElement = element as HTMLElement;\n const elementData = {\n type: OutgoingMessageType.ELEMENT_SELECTED,\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: visualSelectorId,\n content: htmlElement.innerText,\n dataSourceLocation: htmlElement.dataset.sourceLocation,\n isDynamicContent: htmlElement.dataset.dynamicContent === \"true\",\n linenumber: htmlElement.dataset.linenumber,\n filename: htmlElement.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n window.parent.postMessage(elementData, \"*\");\n}\n\n/**\n * Handle element click\n */\nexport function handleElementClick(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode) return;\n\n const target = e.target as Element;\n\n // Bail out early if clicking on a contentEditable element (allow normal editing)\n if (target instanceof HTMLElement && target.contentEditable === \"true\") {\n return;\n }\n\n // If currently editing, clicking outside should exit editing mode\n if (state.currentEditingElement) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n handleClearInlineEditingMode(state);\n return;\n }\n\n // Close dropdowns when clicking anywhere in iframe if a dropdown is open\n if (state.isDropdownOpen) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n window.parent.postMessage({ type: OutgoingMessageType.CLOSE_DROPDOWNS }, \"*\");\n return;\n }\n\n // Prevent clicking on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n return;\n }\n\n // Prevent default behavior immediately when in visual edit mode\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n return;\n }\n\n const htmlElement = element as HTMLElement;\n const visualSelectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Check if this element is already selected (second click scenario)\n const isAlreadySelected =\n state.selectedElementId === visualSelectorId &&\n htmlElement.dataset.selected === \"true\";\n\n if (isAlreadySelected) {\n // Second click on already-selected element: check if it should enter inline editing\n // Only if the experiment is enabled\n if (state.isInlineEditExperimentEnabled && shouldEnterInlineEditingMode(htmlElement)) {\n handleEnterInlineEditingMode(state, htmlElement);\n return;\n }\n }\n\n // First click: select the element\n handleElementSelection(state, element, visualSelectorId || null);\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleVisualEditModeMessage } from \"./types.js\";\nimport { clearSelection } from \"../../ui/overlay.js\";\nimport { clearHoverOverlays } from \"../hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\n\n/**\n * Toggle visual edit mode on/off\n */\nexport function toggleVisualEditMode(state: AgentState, isEnabled: boolean): void {\n state.isVisualEditMode = isEnabled;\n\n if (!isEnabled) {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n\n clearHoverOverlays(state);\n clearSelection(state);\n state.currentHighlightedElements = [];\n document.body.style.cursor = \"default\";\n } else {\n document.body.style.cursor = \"crosshair\";\n }\n}\n\n/**\n * Handle toggle-visual-edit-mode message\n */\nexport function handleToggleVisualEditMode(\n state: AgentState,\n message: ToggleVisualEditModeMessage\n): void {\n toggleVisualEditMode(state, message.data.enabled);\n \n // Update inline edit experiment flag if provided\n if (message.data.specs?.newInlineEditEnabled !== undefined) {\n state.isInlineEditExperimentEnabled = message.data.specs.newInlineEditEnabled;\n }\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleInlineEditModeMessage } from \"./types.js\";\nimport { findElementsById } from \"../../../utils.js\";\nimport { shouldEnterInlineEditingMode } from \"../../capabilities/inline-editing/index.js\";\nimport { handleEnterInlineEditingMode, handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\nimport { clearSelection } from \"../../ui/overlay.js\";\nimport { createOverlay, positionOverlay } from \"../../ui/overlay.js\";\n\n/**\n * Handle toggle-inline-edit-mode message (parent-initiated)\n */\nexport function handleToggleInlineEditMode(\n state: AgentState,\n message: ToggleInlineEditModeMessage\n): void {\n if (!state.isInlineEditExperimentEnabled) {\n return;\n }\n\n if (!message.data || !message.data.dataSourceLocation) {\n return;\n }\n\n const elements = findElementsById(message.data.dataSourceLocation);\n if (elements.length === 0 || !(elements[0] instanceof HTMLElement)) {\n return;\n }\n\n const element = elements[0];\n\n if (message.data.inlineEditingMode) {\n // Enable inline editing (only for non-dynamic text elements)\n if (shouldEnterInlineEditingMode(element)) {\n // Select the element first if not already selected\n if (state.selectedElementId !== message.data.dataSourceLocation) {\n // Clear any existing selection\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n\n // Find all elements with the same ID\n const elements = findElementsById(message.data.dataSourceLocation);\n\n // Mark elements as selected\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n el.dataset.selected = \"true\";\n }\n });\n\n // Create selected overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n state.selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true, state.isVisualEditMode);\n });\n\n state.selectedElementId = message.data.dataSourceLocation;\n }\n handleEnterInlineEditingMode(state, element);\n }\n } else {\n // Disable inline editing\n if (state.currentEditingElement === element) {\n handleClearInlineEditingMode(state);\n }\n }\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { IncomingMessageType, OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById, updateElementClasses } from \"../../utils.js\";\nimport { clearSelection, repositionSelectedOverlays, repositionHoverOverlays } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { REPOSITION_DELAY_MS } from \"../constants.js\";\nimport { handleToggleVisualEditMode } from \"./messages/toggle-visual-edit-mode.js\";\nimport { handleToggleInlineEditMode } from \"./messages/toggle-inline-edit-mode.js\";\nimport { getElementPosition, isElementInViewport } from \"../utils/dom-utils.js\";\n\n/**\n * Send element position update to parent\n */\nfunction sendElementPositionUpdate(state: AgentState): void {\n if (!state.selectedElementId) return;\n\n const elements = findElementsById(state.selectedElementId);\n const [element] = elements;\n if (!element) return;\n\n const rect = element.getBoundingClientRect();\n\n window.parent.postMessage(\n {\n type: OutgoingMessageType.ELEMENT_POSITION_UPDATE,\n position: getElementPosition(rect),\n isInViewport: isElementInViewport(rect),\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Unselect the current element\n */\nexport function unselectElement(state: AgentState): void {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n}\n\n/**\n * Update element classes and reposition overlays\n */\nexport function updateElementClassesAndReposition(\n state: AgentState,\n visualSelectorId: string,\n classes: string\n): void {\n const elements = findElementsById(visualSelectorId);\n if (elements.length === 0) return;\n\n updateElementClasses(elements, classes);\n\n // Use a small delay to allow the browser to recalculate layout before repositioning\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n\n if (state.currentHighlightedElements.length > 0) {\n const hoveredElement = state.currentHighlightedElements[0] as HTMLElement;\n if (hoveredElement?.dataset?.visualSelectorId === visualSelectorId) {\n repositionHoverOverlays(state);\n }\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Update element content by visual selector ID\n */\nexport function updateElementContent(\n state: AgentState,\n visualSelectorId: string,\n content: string\n): void {\n const elements = findElementsById(visualSelectorId);\n\n if (elements.length === 0) {\n return;\n }\n\n elements.forEach((element) => {\n (element as HTMLElement).innerText = content;\n });\n\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Handle scroll events to update popover position\n */\nexport function handleScroll(state: AgentState): void {\n sendElementPositionUpdate(state);\n}\n\n/**\n * Handle window resize to reposition overlays\n */\nexport function handleResize(state: AgentState): void {\n repositionSelectedOverlays(state);\n repositionHoverOverlays(state);\n}\n\n/**\n * Handle messages from parent window\n */\nexport function handleMessage(state: AgentState, event: MessageEvent): void {\n const message = event.data;\n\n switch (message.type as IncomingMessageType) {\n case IncomingMessageType.TOGGLE_VISUAL_EDIT_MODE:\n handleToggleVisualEditMode(state, message);\n break;\n\n case IncomingMessageType.UPDATE_CLASSES:\n if (message.data && message.data.classes !== undefined) {\n updateElementClassesAndReposition(\n state,\n message.data.visualSelectorId,\n message.data.classes\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-classes message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.UNSELECT_ELEMENT:\n unselectElement(state);\n break;\n\n case IncomingMessageType.REFRESH_PAGE:\n window.location.reload();\n break;\n\n case IncomingMessageType.UPDATE_CONTENT:\n if (message.data && message.data.content !== undefined) {\n updateElementContent(\n state,\n message.data.visualSelectorId,\n message.data.content\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-content message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.TOGGLE_INLINE_EDIT_MODE:\n handleToggleInlineEditMode(state, message);\n break;\n\n case IncomingMessageType.REQUEST_ELEMENT_POSITION:\n sendElementPositionUpdate(state);\n break;\n\n case IncomingMessageType.POPOVER_DRAG_STATE:\n if (message.data && message.data.isDragging !== undefined) {\n state.isPopoverDragging = message.data.isDragging;\n if (message.data.isDragging) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n case IncomingMessageType.DROPDOWN_STATE:\n if (message.data && message.data.isOpen !== undefined) {\n state.isDropdownOpen = message.data.isOpen;\n if (message.data.isOpen) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n default:\n break;\n }\n}\n","import { createAgentState } from \"./state/agent-state.js\";\nimport { handleMouseOver, handleMouseOut } from \"./handlers/hover-handlers.js\";\nimport { handleElementClick } from \"./handlers/click-handlers.js\";\nimport { handleMessage, handleScroll, handleResize } from \"./handlers/message-handlers.js\";\nimport { setupInlineEditCallback } from \"./handlers/inline-edit-handlers.js\";\nimport { OutgoingMessageType } from \"./handlers/messages/types.js\";\n\n/**\n * Initialize element IDs for elements with line numbers\n */\nfunction initializeElementIds(): void {\n const elementsWithLineNumber = document.querySelectorAll(\n \"[data-linenumber]:not([data-visual-selector-id])\"\n );\n elementsWithLineNumber.forEach((el, index) => {\n const htmlEl = el as HTMLElement;\n const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;\n htmlEl.dataset.visualSelectorId = id;\n });\n}\n\n/**\n * Create mutation observer to detect layout changes.\n * Uses requestAnimationFrame to coalesce many rapid mutations into one reposition\n * per paint frame, avoiding stacking multiple timers during CSS transitions.\n */\nfunction createLayoutObserver(onLayoutChange: () => void): MutationObserver {\n let rafHandle: number | null = null;\n\n const hasVisualId = (node: Node): boolean => {\n if (node.nodeType !== Node.ELEMENT_NODE) return false;\n const el = node as HTMLElement;\n if (el.dataset?.visualSelectorId) return true;\n for (let i = 0; i < el.children.length; i++) {\n if (hasVisualId(el.children[i]!)) return true;\n }\n return false;\n };\n\n return new MutationObserver((mutations) => {\n if (rafHandle !== null) return;\n\n const needsUpdate = mutations.some((mutation) => {\n const isLayoutChange =\n mutation.type === \"attributes\" &&\n (mutation.attributeName === \"style\" ||\n mutation.attributeName === \"class\" ||\n mutation.attributeName === \"width\" ||\n mutation.attributeName === \"height\");\n\n return isLayoutChange && hasVisualId(mutation.target);\n });\n\n if (needsUpdate) {\n rafHandle = requestAnimationFrame(() => {\n rafHandle = null;\n onLayoutChange();\n });\n }\n });\n}\n\n/**\n * Setup keyboard event protection\n */\nfunction setupKeyboardProtection(): void {\n document.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.target instanceof HTMLElement && e.target.contentEditable === \"true\") {\n // Don't report keyboard events during inline editing\n return;\n }\n // Forward other keyboard events to parent if needed\n }, true);\n}\n\n/**\n * Setup event listeners\n */\nfunction setupEventListeners(state: ReturnType<typeof createAgentState>): void {\n // Message handling\n window.addEventListener(\"message\", (e) => handleMessage(state, e));\n\n // Scroll handling\n window.addEventListener(\"scroll\", () => handleScroll(state), true);\n document.addEventListener(\"scroll\", () => handleScroll(state), true);\n\n // Resize handling\n window.addEventListener(\"resize\", () => handleResize(state));\n window.addEventListener(\"scroll\", () => handleResize(state));\n\n // Click handling\n document.addEventListener(\"click\", (e) => handleElementClick(state, e), true);\n\n // Hover handling\n document.addEventListener(\"mouseover\", (e) => handleMouseOver(state, e));\n document.addEventListener(\"mouseout\", () => handleMouseOut(state));\n}\n\n/**\n * Main setup function for visual edit agent\n */\nexport function setupVisualEditAgent(): void {\n const state = createAgentState();\n initializeElementIds();\n setupInlineEditCallback(state);\n setupKeyboardProtection();\n setupEventListeners(state);\n\n // Create and start mutation observer\n const mutationObserver = createLayoutObserver(() => handleResize(state));\n mutationObserver.observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n attributeFilter: [\"style\", \"class\", \"width\", \"height\"],\n });\n\n // Send ready message to parent\n window.parent.postMessage({ type: OutgoingMessageType.VISUAL_EDIT_AGENT_READY }, \"*\");\n}\n"],"mappings":"AAiBO,SAASA,GAA+B,CAC7C,MAAO,CACL,iBAAkB,GAClB,kBAAmB,GACnB,eAAgB,GAChB,cAAe,CAAC,EAChB,iBAAkB,CAAC,EACnB,2BAA4B,CAAC,EAC7B,kBAAmB,KACnB,sBAAuB,KACvB,qBAAsB,KACtB,8BAA+B,EACjC,CACF,CC7BO,SAASC,EAAiBC,EAA8B,CAC7D,GAAI,CAACA,EAAI,MAAO,CAAC,EACjB,IAAMC,EAAiB,MAAM,KAC3B,SAAS,iBAAiB,0B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Z,UAAW,GACX,QAAS,GACT,gBAAiB,CAAC,QAAS,QAAS,QAAS,QAAQ,CACvD,CAAC,EAGD,OAAO,OAAO,YAAY,CAAE,8BAAkD,EAAG,GAAG,CACtF","names":["createAgentState","findElementsById","id","sourceElements","updateElementClasses","elements","classes","element","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","createOverlay","isSelected","overlay","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","positionOverlay","element","isVisualEditMode","rect","label","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","clearOverlays","overlays","clearSelection","state","findElementsById","el","repositionSelectedOverlays","elements","index","repositionHoverOverlays","clearHoverOverlays","state","clearOverlays","handleMouseOver","e","target","element","htmlElement","selectorId","elements","findElementsById","el","overlay","createOverlay","positionOverlay","handleMouseOut","injectFocusOutlineCSS","style","removeFocusOutlineCSS","selectText","element","range","selection","isEditableTextElement","onTextInputChangeCallback","setInlineEditCallback","callback","listenerAbortControllers","handleInputEvent","shouldEnterInlineEditingMode","element","isEditableTextElement","enterInlineEditingMode","injectFocusOutlineCSS","abortController","selectText","clearInlineEditingMode","removeFocusOutlineCSS","getElementPosition","rect","isElementInViewport","getElementClasses","element","handleEnterInlineEditingMode","state","element","overlay","enterInlineEditingMode","handleClearInlineEditingMode","clearInlineEditingMode","repositionSelectedOverlays","reportInlineEdit","originalContent","newContent","elementInfo","getElementClasses","getElementPosition","debouncedSendInlineEditMessage","createTextInputChangeCallback","setupInlineEditCallback","setInlineEditCallback","handleElementSelection","state","element","visualSelectorId","handleClearInlineEditingMode","clearSelection","elements","findElementsById","el","overlay","createOverlay","positionOverlay","clearHoverOverlays","htmlElement","elementData","getElementClasses","getElementPosition","handleElementClick","e","target","shouldEnterInlineEditingMode","handleEnterInlineEditingMode","toggleVisualEditMode","state","isEnabled","handleClearInlineEditingMode","clearHoverOverlays","clearSelection","handleToggleVisualEditMode","message","handleToggleInlineEditMode","state","message","elements","findElementsById","element","shouldEnterInlineEditingMode","handleClearInlineEditingMode","clearSelection","el","overlay","createOverlay","positionOverlay","handleEnterInlineEditingMode","sendElementPositionUpdate","state","elements","findElementsById","element","rect","getElementPosition","isElementInViewport","unselectElement","handleClearInlineEditingMode","clearSelection","updateElementClassesAndReposition","visualSelectorId","classes","updateElementClasses","repositionSelectedOverlays","repositionHoverOverlays","updateElementContent","content","handleScroll","handleResize","handleMessage","event","message","handleToggleVisualEditMode","handleToggleInlineEditMode","clearHoverOverlays","initializeElementIds","el","index","htmlEl","id","createLayoutObserver","onLayoutChange","rafHandle","hasVisualId","node","mutations","mutation","setupKeyboardProtection","setupEventListeners","state","e","handleMessage","handleScroll","handleResize","handleElementClick","handleMouseOver","handleMouseOut","setupVisualEditAgent","createAgentState","setupInlineEditCallback"]}
|
package/package.json
CHANGED
|
@@ -19,6 +19,13 @@ export function setInlineEditCallback(callback: OnTextInputChange | null): void
|
|
|
19
19
|
onTextInputChangeCallback = callback;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* WeakMap to track AbortControllers for each element's input listener.
|
|
24
|
+
* Using WeakMap ensures no memory leaks — when an element is garbage collected,
|
|
25
|
+
* its entry is automatically removed.
|
|
26
|
+
*/
|
|
27
|
+
const listenerAbortControllers = new WeakMap<HTMLElement, AbortController>();
|
|
28
|
+
|
|
22
29
|
/**
|
|
23
30
|
* Internal handler for the native input event
|
|
24
31
|
*/
|
|
@@ -61,8 +68,12 @@ export function enterInlineEditingMode(element: HTMLElement): void {
|
|
|
61
68
|
// Enable contentEditable
|
|
62
69
|
element.contentEditable = "true";
|
|
63
70
|
|
|
64
|
-
//
|
|
65
|
-
|
|
71
|
+
// Create an AbortController to manage the input listener lifecycle
|
|
72
|
+
const abortController = new AbortController();
|
|
73
|
+
listenerAbortControllers.set(element, abortController);
|
|
74
|
+
|
|
75
|
+
// Add input event listener with AbortSignal for automatic cleanup
|
|
76
|
+
element.addEventListener("input", handleInputEvent, { signal: abortController.signal });
|
|
66
77
|
|
|
67
78
|
// Set cursor to text
|
|
68
79
|
element.style.cursor = "text";
|
|
@@ -83,8 +94,12 @@ export function enterInlineEditingMode(element: HTMLElement): void {
|
|
|
83
94
|
export function clearInlineEditingMode(element: HTMLElement): void {
|
|
84
95
|
removeFocusOutlineCSS();
|
|
85
96
|
|
|
86
|
-
//
|
|
87
|
-
|
|
97
|
+
// Abort the input event listener using the stored AbortController
|
|
98
|
+
const abortController = listenerAbortControllers.get(element);
|
|
99
|
+
if (abortController) {
|
|
100
|
+
abortController.abort();
|
|
101
|
+
listenerAbortControllers.delete(element);
|
|
102
|
+
}
|
|
88
103
|
|
|
89
104
|
// Disable contentEditable
|
|
90
105
|
element.contentEditable = "false";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { AgentState } from "../state/agent-state.js";
|
|
2
2
|
import { OutgoingMessageType } from "./messages/types.js";
|
|
3
3
|
import { findElementsById } from "../../utils.js";
|
|
4
|
-
import { createOverlay, positionOverlay } from "../ui/overlay.js";
|
|
4
|
+
import { createOverlay, positionOverlay, clearSelection } from "../ui/overlay.js";
|
|
5
5
|
import { clearHoverOverlays } from "./hover-handlers.js";
|
|
6
6
|
import { shouldEnterInlineEditingMode } from "../capabilities/inline-editing/index.js";
|
|
7
7
|
import { handleClearInlineEditingMode, handleEnterInlineEditingMode } from "./inline-edit-handlers.js";
|
|
8
|
-
import { unselectElement } from "./message-handlers.js";
|
|
9
8
|
import { getElementPosition, getElementClasses } from "../utils/dom-utils.js";
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -16,7 +15,10 @@ export function handleElementSelection(
|
|
|
16
15
|
element: Element,
|
|
17
16
|
visualSelectorId: string | null
|
|
18
17
|
): void {
|
|
19
|
-
|
|
18
|
+
if (state.currentEditingElement) {
|
|
19
|
+
handleClearInlineEditingMode(state);
|
|
20
|
+
}
|
|
21
|
+
clearSelection(state);
|
|
20
22
|
|
|
21
23
|
// Find all elements with the same ID
|
|
22
24
|
const elements = findElementsById(visualSelectorId);
|
|
@@ -122,11 +124,8 @@ export function handleElementClick(state: AgentState, e: MouseEvent): void {
|
|
|
122
124
|
// Second click on already-selected element: check if it should enter inline editing
|
|
123
125
|
// Only if the experiment is enabled
|
|
124
126
|
if (state.isInlineEditExperimentEnabled && shouldEnterInlineEditingMode(htmlElement)) {
|
|
125
|
-
console.log('[VisualEditAgent] Entering inline edit mode');
|
|
126
127
|
handleEnterInlineEditingMode(state, htmlElement);
|
|
127
128
|
return;
|
|
128
|
-
} else if (!state.isInlineEditExperimentEnabled) {
|
|
129
|
-
console.log('[VisualEditAgent] Inline edit disabled - experiment flag not enabled');
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
|
|
@@ -39,6 +39,12 @@ export function handleEnterInlineEditingMode(state: AgentState, element: HTMLEle
|
|
|
39
39
|
export function handleClearInlineEditingMode(state: AgentState): void {
|
|
40
40
|
if (!state.currentEditingElement) return;
|
|
41
41
|
|
|
42
|
+
// Cancel any pending debounced edit — originalTextContent will be deleted below
|
|
43
|
+
if (state.debouncedSendTimeout) {
|
|
44
|
+
clearTimeout(state.debouncedSendTimeout);
|
|
45
|
+
state.debouncedSendTimeout = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
const element = state.currentEditingElement;
|
|
43
49
|
|
|
44
50
|
// Clear inline editing mode (from capabilities/inline-editing)
|
|
@@ -99,6 +105,11 @@ function reportInlineEdit(state: AgentState, element: HTMLElement): void {
|
|
|
99
105
|
|
|
100
106
|
/**
|
|
101
107
|
* Debounced function to send inline edit messages
|
|
108
|
+
*
|
|
109
|
+
* Intentionally overwrites the previous timeout on each keystroke — this is the
|
|
110
|
+
* correct debounce behavior. We only send ONE message 500ms after the user stops
|
|
111
|
+
* typing, containing the final text. Intermediate keystrokes are not sent to avoid
|
|
112
|
+
* flooding the parent with dozens of messages per second.
|
|
102
113
|
*/
|
|
103
114
|
function debouncedSendInlineEditMessage(state: AgentState, element: HTMLElement): void {
|
|
104
115
|
// Clear any existing timeout
|
|
@@ -16,10 +16,10 @@ function sendElementPositionUpdate(state: AgentState): void {
|
|
|
16
16
|
if (!state.selectedElementId) return;
|
|
17
17
|
|
|
18
18
|
const elements = findElementsById(state.selectedElementId);
|
|
19
|
-
|
|
19
|
+
const [element] = elements;
|
|
20
|
+
if (!element) return;
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
const rect = element!.getBoundingClientRect();
|
|
22
|
+
const rect = element.getBoundingClientRect();
|
|
23
23
|
|
|
24
24
|
window.parent.postMessage(
|
|
25
25
|
{
|
|
@@ -2,8 +2,9 @@ import type { AgentState } from "../../state/agent-state.js";
|
|
|
2
2
|
import type { ToggleInlineEditModeMessage } from "./types.js";
|
|
3
3
|
import { findElementsById } from "../../../utils.js";
|
|
4
4
|
import { shouldEnterInlineEditingMode } from "../../capabilities/inline-editing/index.js";
|
|
5
|
-
import { handleElementSelection } from "../click-handlers.js";
|
|
6
5
|
import { handleEnterInlineEditingMode, handleClearInlineEditingMode } from "../inline-edit-handlers.js";
|
|
6
|
+
import { clearSelection } from "../../ui/overlay.js";
|
|
7
|
+
import { createOverlay, positionOverlay } from "../../ui/overlay.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Handle toggle-inline-edit-mode message (parent-initiated)
|
|
@@ -12,17 +13,11 @@ export function handleToggleInlineEditMode(
|
|
|
12
13
|
state: AgentState,
|
|
13
14
|
message: ToggleInlineEditModeMessage
|
|
14
15
|
): void {
|
|
15
|
-
// Check if inline edit experiment is enabled
|
|
16
16
|
if (!state.isInlineEditExperimentEnabled) {
|
|
17
|
-
console.log('[VisualEditAgent] toggle-inline-edit-mode ignored - experiment flag not enabled');
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
console.log('[VisualEditAgent] Processing toggle-inline-edit-mode message');
|
|
22
|
-
|
|
23
|
-
// Parent-initiated inline editing mode toggle
|
|
19
|
+
|
|
24
20
|
if (!message.data || !message.data.dataSourceLocation) {
|
|
25
|
-
console.warn('[VisualEditAgent] Invalid toggle-inline-edit-mode message - missing dataSourceLocation');
|
|
26
21
|
return;
|
|
27
22
|
}
|
|
28
23
|
|
|
@@ -38,7 +33,31 @@ export function handleToggleInlineEditMode(
|
|
|
38
33
|
if (shouldEnterInlineEditingMode(element)) {
|
|
39
34
|
// Select the element first if not already selected
|
|
40
35
|
if (state.selectedElementId !== message.data.dataSourceLocation) {
|
|
41
|
-
|
|
36
|
+
// Clear any existing selection
|
|
37
|
+
if (state.currentEditingElement) {
|
|
38
|
+
handleClearInlineEditingMode(state);
|
|
39
|
+
}
|
|
40
|
+
clearSelection(state);
|
|
41
|
+
|
|
42
|
+
// Find all elements with the same ID
|
|
43
|
+
const elements = findElementsById(message.data.dataSourceLocation);
|
|
44
|
+
|
|
45
|
+
// Mark elements as selected
|
|
46
|
+
elements.forEach((el) => {
|
|
47
|
+
if (el instanceof HTMLElement) {
|
|
48
|
+
el.dataset.selected = "true";
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Create selected overlays for all matching elements
|
|
53
|
+
elements.forEach((el) => {
|
|
54
|
+
const overlay = createOverlay(true);
|
|
55
|
+
document.body.appendChild(overlay);
|
|
56
|
+
state.selectedOverlays.push(overlay);
|
|
57
|
+
positionOverlay(overlay, el, true, state.isVisualEditMode);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
state.selectedElementId = message.data.dataSourceLocation;
|
|
42
61
|
}
|
|
43
62
|
handleEnterInlineEditingMode(state, element);
|
|
44
63
|
}
|
|
@@ -36,6 +36,5 @@ export function handleToggleVisualEditMode(
|
|
|
36
36
|
// Update inline edit experiment flag if provided
|
|
37
37
|
if (message.data.specs?.newInlineEditEnabled !== undefined) {
|
|
38
38
|
state.isInlineEditExperimentEnabled = message.data.specs.newInlineEditEnabled;
|
|
39
|
-
console.log('[VisualEditAgent] Inline edit experiment:', state.isInlineEditExperimentEnabled);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
@@ -20,26 +20,27 @@ function initializeElementIds(): void {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Create mutation observer to detect layout changes
|
|
23
|
+
* Create mutation observer to detect layout changes.
|
|
24
|
+
* Uses requestAnimationFrame to coalesce many rapid mutations into one reposition
|
|
25
|
+
* per paint frame, avoiding stacking multiple timers during CSS transitions.
|
|
24
26
|
*/
|
|
25
27
|
function createLayoutObserver(onLayoutChange: () => void): MutationObserver {
|
|
28
|
+
let rafHandle: number | null = null;
|
|
29
|
+
|
|
30
|
+
const hasVisualId = (node: Node): boolean => {
|
|
31
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return false;
|
|
32
|
+
const el = node as HTMLElement;
|
|
33
|
+
if (el.dataset?.visualSelectorId) return true;
|
|
34
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
35
|
+
if (hasVisualId(el.children[i]!)) return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
|
|
26
40
|
return new MutationObserver((mutations) => {
|
|
27
|
-
|
|
28
|
-
const hasVisualId = (node: Node): boolean => {
|
|
29
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
30
|
-
const el = node as HTMLElement;
|
|
31
|
-
if (el.dataset && el.dataset.visualSelectorId) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
35
|
-
if (hasVisualId(el.children[i]!)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
};
|
|
41
|
+
if (rafHandle !== null) return;
|
|
42
42
|
|
|
43
|
+
const needsUpdate = mutations.some((mutation) => {
|
|
43
44
|
const isLayoutChange =
|
|
44
45
|
mutation.type === "attributes" &&
|
|
45
46
|
(mutation.attributeName === "style" ||
|
|
@@ -51,7 +52,10 @@ function createLayoutObserver(onLayoutChange: () => void): MutationObserver {
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
if (needsUpdate) {
|
|
54
|
-
|
|
55
|
+
rafHandle = requestAnimationFrame(() => {
|
|
56
|
+
rafHandle = null;
|
|
57
|
+
onLayoutChange();
|
|
58
|
+
});
|
|
55
59
|
}
|
|
56
60
|
});
|
|
57
61
|
}
|
|
@@ -41,10 +41,6 @@ export function positionOverlay(
|
|
|
41
41
|
): void {
|
|
42
42
|
if (!element || !isVisualEditMode) return;
|
|
43
43
|
|
|
44
|
-
const htmlElement = element as HTMLElement;
|
|
45
|
-
// Force layout recalculation
|
|
46
|
-
void htmlElement.offsetWidth;
|
|
47
|
-
|
|
48
44
|
const rect = element.getBoundingClientRect();
|
|
49
45
|
overlay.style.top = `${rect.top + window.scrollY}px`;
|
|
50
46
|
overlay.style.left = `${rect.left + window.scrollX}px`;
|