diff --git a/registry/components/FooterBase.json b/registry/components/FooterBase.json index c6c24df..1e1e4c7 100644 --- a/registry/components/FooterBase.json +++ b/registry/components/FooterBase.json @@ -6,14 +6,14 @@ "textRules": { "logoText": { "required": false, - "default": "Contact Us ", + "default": "CONTACT US ", "example": "Company Name", "minChars": 2, "maxChars": 30 }, "copyrightText": { "required": false, - "default": "© 2025 | Contact Us ", + "default": "© 2025 | CONTACT US ", "example": "© 2025 Company Name", "minChars": 5, "maxChars": 50 @@ -51,8 +51,8 @@ }, "propsSchema": { "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns (required)", - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/components/FooterBaseCard.json b/registry/components/FooterBaseCard.json index 4e48e8a..2058f89 100644 --- a/registry/components/FooterBaseCard.json +++ b/registry/components/FooterBaseCard.json @@ -6,14 +6,14 @@ "textRules": { "copyrightText": { "required": false, - "example": "© 2025 | Contact Us ", + "example": "© 2025 | CONTACT US ", "minChars": 5, "maxChars": 100, "note": "Copyright text displayed at bottom left" }, "logoText": { "required": false, - "example": "Contact Us ", + "example": "CONTACT US ", "minChars": 2, "maxChars": 30, "note": "Text used for h2 heading" @@ -34,9 +34,9 @@ } }, "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns (required)", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", @@ -51,7 +51,7 @@ "copyrightTextClassName?": "string", "privacyButtonClassName?": "string" }, - "usageExample": " console.log('Privacy clicked')} />", + "usageExample": " console.log('Privacy clicked')} />", "do": [ "Use for general use", "Requires columns[]" diff --git a/registry/components/FooterBaseReveal.json b/registry/components/FooterBaseReveal.json index b32d396..f21b369 100644 --- a/registry/components/FooterBaseReveal.json +++ b/registry/components/FooterBaseReveal.json @@ -6,7 +6,7 @@ "textRules": { "copyrightText": { "required": false, - "default": "© 2025 | Contact Us ", + "default": "© 2025 | CONTACT US ", "example": "© 2025 Company Name", "minChars": 5, "maxChars": 50 diff --git a/registry/components/FooterCard.json b/registry/components/FooterCard.json index 20c1fb7..23cfe1f 100644 --- a/registry/components/FooterCard.json +++ b/registry/components/FooterCard.json @@ -6,14 +6,14 @@ "textRules": { "copyrightText": { "required": false, - "example": "© 2025 | Contact Us ", + "example": "© 2025 | CONTACT US ", "minChars": 5, "maxChars": 100, "note": "Copyright text displayed at bottom left" }, "logoText": { "required": false, - "example": "Contact Us ", + "example": "CONTACT US ", "minChars": 2, "maxChars": 30, "note": "Text used for SVG logo" @@ -33,8 +33,8 @@ } }, "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "socialLinks?": "Array<{ icon: LucideIcon, href: string, ariaLabel: string }> - Social media links", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", @@ -47,7 +47,7 @@ "socialContainerClassName?": "string", "socialIconClassName?": "string" }, - "usageExample": "", + "usageExample": "", "do": [ "Use for general use", "Requires socialLinks?[]" diff --git a/registry/components/FooterLogoEmphasis.json b/registry/components/FooterLogoEmphasis.json index 67720b6..6dded78 100644 --- a/registry/components/FooterLogoEmphasis.json +++ b/registry/components/FooterLogoEmphasis.json @@ -6,7 +6,7 @@ "textRules": { "logoText": { "required": false, - "default": "Contact Us ", + "default": "CONTACT US ", "example": "Company Name", "minChars": 2, "maxChars": 30 diff --git a/registry/components/FooterLogoReveal.json b/registry/components/FooterLogoReveal.json index eb400b1..54070c6 100644 --- a/registry/components/FooterLogoReveal.json +++ b/registry/components/FooterLogoReveal.json @@ -6,7 +6,7 @@ "textRules": { "logoText": { "required": false, - "example": "Contact Us ", + "example": "CONTACT US ", "minChars": 2, "maxChars": 30, "note": "Text used for SVG logo" @@ -20,7 +20,7 @@ } }, "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", "leftLink": "{ text: string, onClick?: () => void, href?: string } (required)", "rightLink": "{ text: string, onClick?: () => void, href?: string } (required)", "ariaLabel?": "string (default: 'Site footer')", @@ -30,7 +30,7 @@ "logoClassName?": "string", "linkClassName?": "string" }, - "usageExample": "", + "usageExample": "", "do": [ "Use for general use" ], diff --git a/registry/components/FooterMedia.json b/registry/components/FooterMedia.json index 574be78..6db71ec 100644 --- a/registry/components/FooterMedia.json +++ b/registry/components/FooterMedia.json @@ -6,14 +6,14 @@ "textRules": { "logoText": { "required": false, - "default": "Contact Us ", + "default": "CONTACT US ", "example": "Company Name", "minChars": 2, "maxChars": 30 }, "copyrightText": { "required": false, - "default": "© 2025 | Contact Us ", + "default": "© 2025 | CONTACT US ", "example": "© 2025 Company Name", "minChars": 5, "maxChars": 50 @@ -66,8 +66,8 @@ "videoSrc": "string (required if no imageSrc)", "videoAriaLabel?": "string (default: 'Footer video')", "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns (required)", - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/components/FooterSimple.json b/registry/components/FooterSimple.json index 7792950..1811e35 100644 --- a/registry/components/FooterSimple.json +++ b/registry/components/FooterSimple.json @@ -12,7 +12,7 @@ }, "bottomRightText": { "required": true, - "example": "Made with Contact Us ", + "example": "Made with CONTACT US ", "minChars": 2, "maxChars": 50 }, @@ -63,7 +63,7 @@ "bottomLeftTextClassName?": "string", "bottomRightTextClassName?": "string" }, - "usageExample": "", + "usageExample": "", "do": [ "Use for feature showcases", "Use for capability displays", diff --git a/registry/components/HeroLogo.json b/registry/components/HeroLogo.json index 29c004d..baf3bae 100644 --- a/registry/components/HeroLogo.json +++ b/registry/components/HeroLogo.json @@ -6,7 +6,7 @@ "textRules": { "logoText": { "required": true, - "example": "Contact Us ", + "example": "CONTACT US ", "minChars": 2, "maxChars": 20 }, @@ -79,7 +79,7 @@ "blurClassName?": "string", "dimOverlayClassName?": "string" }, - "usageExample": "\n \n", + "usageExample": "\n \n", "do": [ "Use for landing pages", "Use for feature showcases", diff --git a/registry/components/NavbarLayoutFloatingInline.json b/registry/components/NavbarLayoutFloatingInline.json index 5537218..ad42b2c 100644 --- a/registry/components/NavbarLayoutFloatingInline.json +++ b/registry/components/NavbarLayoutFloatingInline.json @@ -10,7 +10,7 @@ "required": false, "minChars": 2, "maxChars": 20, - "example": "Contact Us ", + "example": "CONTACT US ", "fallbackBehavior": "Shows brandName text" }, "buttonRules": { @@ -52,7 +52,7 @@ }, "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "button": "{text: string, onClick?: () => void, href?: string}", "animateOnLoad?": "boolean (default: true)", "className?": "string (default: '')", diff --git a/registry/components/NavbarLayoutFloatingOverlay.json b/registry/components/NavbarLayoutFloatingOverlay.json index 7276b52..c434430 100644 --- a/registry/components/NavbarLayoutFloatingOverlay.json +++ b/registry/components/NavbarLayoutFloatingOverlay.json @@ -10,7 +10,7 @@ "required": false, "minChars": 2, "maxChars": 20, - "example": "Contact Us ", + "example": "CONTACT US ", "fallbackBehavior": "Shows brandName text" }, "buttonRules": { @@ -53,7 +53,7 @@ "propsSchema": { "navItems": "Array<{name: string, id: string}>", "className?": "string", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "button": "{text: string, onClick?: () => void, href?: string}", "buttonClassName?": "string (default: '')", "buttonTextClassName?": "string (default: '')" diff --git a/registry/components/NavbarStyleApple.json b/registry/components/NavbarStyleApple.json index 06fa816..d4e64ab 100644 --- a/registry/components/NavbarStyleApple.json +++ b/registry/components/NavbarStyleApple.json @@ -10,7 +10,7 @@ "required": false, "minChars": 2, "maxChars": 20, - "example": "Contact Us ", + "example": "CONTACT US ", "fallbackBehavior": "Shows brandName text" }, "linkRules": { @@ -35,7 +35,7 @@ }, "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')" + "brandName?": "string (default: 'CONTACT US ')" }, "usageExample": "", "do": [ diff --git a/registry/components/NavbarStyleCentered.json b/registry/components/NavbarStyleCentered.json index df1f594..108cbd6 100644 --- a/registry/components/NavbarStyleCentered.json +++ b/registry/components/NavbarStyleCentered.json @@ -10,7 +10,7 @@ "required": false, "minChars": 2, "maxChars": 20, - "example": "Contact Us ", + "example": "CONTACT US ", "fallbackBehavior": "Shows brandName text" }, "buttonRules": { @@ -53,7 +53,7 @@ "propsSchema": { "navItems": "Array<{name: string, id: string}>", "button": "{text: string, onClick?: () => void, href?: string}", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "className?": "string (default: '')" }, "usageExample": "", diff --git a/registry/components/NavbarStyleFullscreen.json b/registry/components/NavbarStyleFullscreen.json index ba1b3f3..1ede9e8 100644 --- a/registry/components/NavbarStyleFullscreen.json +++ b/registry/components/NavbarStyleFullscreen.json @@ -10,7 +10,7 @@ "required": false, "minChars": 2, "maxChars": 20, - "example": "Contact Us ", + "example": "CONTACT US ", "fallbackBehavior": "Shows brandName text" }, "linkRules": { @@ -49,7 +49,7 @@ }, "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "bottomLeftText?": "string (default: 'Global Community')", "bottomRightText?": "string (default: 'hello@example.com')", "topBarClassName?": "string (default: '')" diff --git a/registry/schemas/FooterBase.schema.json b/registry/schemas/FooterBase.schema.json index e01e299..f0f42d1 100644 --- a/registry/schemas/FooterBase.schema.json +++ b/registry/schemas/FooterBase.schema.json @@ -2,8 +2,8 @@ "name": "FooterBase", "propsSchema": { "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns", - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/schemas/FooterBaseCard.schema.json b/registry/schemas/FooterBaseCard.schema.json index 7d63895..9a58b6b 100644 --- a/registry/schemas/FooterBaseCard.schema.json +++ b/registry/schemas/FooterBaseCard.schema.json @@ -1,9 +1,9 @@ { "name": "FooterBaseCard", "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/schemas/FooterCard.schema.json b/registry/schemas/FooterCard.schema.json index 349d749..1019935 100644 --- a/registry/schemas/FooterCard.schema.json +++ b/registry/schemas/FooterCard.schema.json @@ -1,8 +1,8 @@ { "name": "FooterCard", "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "socialLinks?": "Array<{ icon: LucideIcon, href: string, ariaLabel: string }> - Social media links", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/schemas/FooterLogoEmphasis.schema.json b/registry/schemas/FooterLogoEmphasis.schema.json index 04308e6..145b7b2 100644 --- a/registry/schemas/FooterLogoEmphasis.schema.json +++ b/registry/schemas/FooterLogoEmphasis.schema.json @@ -2,7 +2,7 @@ "name": "FooterLogoEmphasis", "propsSchema": { "columns": "Array<{ items: Array<{ label: string, href?: string, onClick?: () => void }> }> - Footer navigation columns (required, max 5)", - "logoText?": "string (default: 'Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", "containerClassName?": "string", diff --git a/registry/schemas/FooterLogoReveal.schema.json b/registry/schemas/FooterLogoReveal.schema.json index db77af5..3cdf54a 100644 --- a/registry/schemas/FooterLogoReveal.schema.json +++ b/registry/schemas/FooterLogoReveal.schema.json @@ -1,7 +1,7 @@ { "name": "FooterLogoReveal", "propsSchema": { - "logoText?": "string (default: 'Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", "logoLineHeight?": "number (default: 1.1)", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/schemas/FooterMedia.schema.json b/registry/schemas/FooterMedia.schema.json index 94f9a8b..db90a98 100644 --- a/registry/schemas/FooterMedia.schema.json +++ b/registry/schemas/FooterMedia.schema.json @@ -6,8 +6,8 @@ "videoSrc": "string (required if no imageSrc)", "videoAriaLabel?": "string (default: 'Footer video')", "columns": "Array<{ title: string, items: Array<{ label: string, href: string }> }> - Footer navigation columns", - "logoText?": "string (default: 'Contact Us ')", - "copyrightText?": "string (default: '© 2025 | Contact Us ')", + "logoText?": "string (default: 'CONTACT US ')", + "copyrightText?": "string (default: '© 2025 | CONTACT US ')", "onPrivacyClick?": "() => void", "ariaLabel?": "string (default: 'Site footer')", "className?": "string", diff --git a/registry/schemas/NavbarLayoutFloatingInline.schema.json b/registry/schemas/NavbarLayoutFloatingInline.schema.json index eb90de3..2a7773c 100644 --- a/registry/schemas/NavbarLayoutFloatingInline.schema.json +++ b/registry/schemas/NavbarLayoutFloatingInline.schema.json @@ -2,7 +2,7 @@ "name": "NavbarLayoutFloatingInline", "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "button": "{text: string, onClick?: () => void, href?: string}", "animateOnLoad?": "boolean (default: true)", "className?": "string (default: '')", diff --git a/registry/schemas/NavbarLayoutFloatingOverlay.schema.json b/registry/schemas/NavbarLayoutFloatingOverlay.schema.json index f0a5e73..80a73e2 100644 --- a/registry/schemas/NavbarLayoutFloatingOverlay.schema.json +++ b/registry/schemas/NavbarLayoutFloatingOverlay.schema.json @@ -3,7 +3,7 @@ "propsSchema": { "navItems": "Array<{name: string, id: string}>", "className?": "string", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "button": "{text: string, onClick?: () => void, href?: string}", "buttonClassName?": "string (default: '')", "buttonTextClassName?": "string (default: '')" diff --git a/registry/schemas/NavbarStyleApple.schema.json b/registry/schemas/NavbarStyleApple.schema.json index 5b565d5..fc132ba 100644 --- a/registry/schemas/NavbarStyleApple.schema.json +++ b/registry/schemas/NavbarStyleApple.schema.json @@ -2,6 +2,6 @@ "name": "NavbarStyleApple", "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')" + "brandName?": "string (default: 'CONTACT US ')" } } \ No newline at end of file diff --git a/registry/schemas/NavbarStyleCentered.schema.json b/registry/schemas/NavbarStyleCentered.schema.json index fb5fe7e..f619a23 100644 --- a/registry/schemas/NavbarStyleCentered.schema.json +++ b/registry/schemas/NavbarStyleCentered.schema.json @@ -4,7 +4,7 @@ "navItems": "Array<{name: string, id: string}>", "button": "{text: string, onClick?: () => void, href?: string}", "topBarButton?": "{text: string, onClick?: () => void, href?: string}", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "className?": "string (default: '')" } } \ No newline at end of file diff --git a/registry/schemas/NavbarStyleFullscreen.schema.json b/registry/schemas/NavbarStyleFullscreen.schema.json index e124c5e..78e88dd 100644 --- a/registry/schemas/NavbarStyleFullscreen.schema.json +++ b/registry/schemas/NavbarStyleFullscreen.schema.json @@ -2,7 +2,7 @@ "name": "NavbarStyleFullscreen", "propsSchema": { "navItems": "Array<{name: string, id: string}>", - "brandName?": "string (default: 'Contact Us ')", + "brandName?": "string (default: 'CONTACT US ')", "bottomLeftText?": "string (default: 'Global Community')", "bottomRightText?": "string (default: 'hello@example.com')", "topBarClassName?": "string (default: '')" diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 5b240bc..930d51b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -626,7 +626,7 @@ export default function RootLayout({ selection.addRange(range); } } catch (e) { - console.warn('[Contact Us ] Could not set caret position:', e); + console.warn('[CONTACT US ] Could not set caret position:', e); } } }; @@ -1151,13 +1151,13 @@ export default function RootLayout({ } } } catch (err) { - console.warn('[Contact Us ] Failed to revert change:', err); + console.warn('[CONTACT US ] Failed to revert change:', err); } }); } clearLocalChanges(); } catch (error) { - console.error('[Contact Us ] Failed to cancel changes:', error); + console.error('[CONTACT US ] Failed to cancel changes:', error); } return; } @@ -1174,7 +1174,7 @@ export default function RootLayout({ try { element = document.querySelector(selector); } catch (err) { - console.warn('[Contact Us ] Invalid selector:', selector); + console.warn('[CONTACT US ] Invalid selector:', selector); } } @@ -1239,7 +1239,1374 @@ export default function RootLayout({ } } } catch (error) { - console.error('[Contact Us ] Invalid selector for button update:', selector, error); + console.error('[CONTACT US ] Invalid selector for button update:', selector, error); + } + return; + } + + if (!isActive) return; + + if (e.data.type === 'webild-replace-image') { + const { selector, newSrc, isBackground, allowMediaTypeSwap } = e.data.data; + let element = null; + + try { + element = document.querySelector(selector); + } catch { + window.parent.postMessage({ + type: 'webild-image-replacement-error', + data: { selector, message: 'Invalid selector: ' + error.message, success: false } + }, '*'); + return; + } + + if (!element) { + window.parent.postMessage({ + type: 'webild-image-replacement-error', + data: { selector, message: 'Element not found', success: false } + }, '*'); + return; + } + + try { + let replaced = false; + let oldValue = ''; + + if (isBackground) { + oldValue = window.getComputedStyle(element).backgroundImage; + element.style.backgroundImage = \`url('\${newSrc}')\`; + replaced = true; + } else if (element.tagName.toLowerCase() === 'img') { + oldValue = element.src; + const newMediaType = getMediaTypeFromUrl(newSrc); + if (newMediaType === 'video' && allowMediaTypeSwap) { + const swapped = swapMediaElement(element, 'video', newSrc); + if (selectedElement === element) selectedElement = swapped; + element = swapped; + } else { + element.src = newSrc; + } + replaced = true; + } else if (element.tagName.toLowerCase() === 'video') { + oldValue = element.src || element.currentSrc || ''; + const newMediaType = getMediaTypeFromUrl(newSrc); + const sources = element.querySelectorAll('source'); + if (newMediaType === 'image' && allowMediaTypeSwap) { + const swapped = swapMediaElement(element, 'img', newSrc); + if (selectedElement === element) selectedElement = swapped; + element = swapped; + } else { + if (sources.length > 0) { + sources.forEach(function(source) { source.src = newSrc; }); + element.load(); + } else { + element.src = newSrc; + element.load(); + } + } + replaced = true; + } else { + const hasBackgroundImage = window.getComputedStyle(element).backgroundImage !== 'none'; + if (hasBackgroundImage) { + oldValue = window.getComputedStyle(element).backgroundImage; + element.style.backgroundImage = \`url('\${newSrc}')\`; + replaced = true; + } + } + + if (replaced) { + const elementInfo = getElementInfo(element); + + let cleanOldValue = oldValue; + if (oldValue.includes('url(')) { + const urlMatch = oldValue.match(/url(['"]?([^'")]+)['"]?)/); + if (urlMatch) { + cleanOldValue = urlMatch[1]; + } + } + + cleanOldValue = extractOriginalUrl(cleanOldValue); + + const change = { + type: 'replaceImage', + selector: selector, + oldValue: cleanOldValue, + newValue: newSrc, + elementType: elementInfo.elementType, + sectionId: elementInfo.sectionId, + timestamp: Date.now() + }; + + saveChangeToStorage(change); + + window.parent.postMessage({ + type: 'webild-element-changed', + data: change + }, '*'); + + window.parent.postMessage({ + type: 'webild-image-replaced', + data: { selector, newSrc, success: true } + }, '*'); + } else { + window.parent.postMessage({ + type: 'webild-image-replacement-error', + data: { selector, message: 'Could not determine how to replace image', success: false } + }, '*'); + } + } catch (error) { + window.parent.postMessage({ + type: 'webild-image-replacement-error', + data: { selector, message: error.message || 'Failed to replace image', success: false } + }, '*'); + } + } + }; + + document.addEventListener('mouseover', handleMouseOver, true); + document.addEventListener('mouseout', handleMouseOut, true); + document.addEventListener('click', handleClick, true); + document.addEventListener('keydown', handleKeyDown, true); + document.addEventListener('blur', handleBlur, true); + window.addEventListener('scroll', handleScroll, true); + window.addEventListener('message', handleMessage, true); + + let lastPathname = window.location.pathname; + + const notifyPageChange = () => { + window.parent.postMessage({ + type: 'webild-page-changed', + data: { pathname: window.location.pathname } + }, '*'); + }; + + window.addEventListener('popstate', () => { + if (lastPathname !== window.location.pathname) { + lastPathname = window.location.pathname; + notifyPageChange(); + } + }, true); + + const urlCheckInterval = setInterval(() => { + if (lastPathname !== window.location.pathname) { + lastPathname = window.location.pathname; + notifyPageChange(); + } + }, 500); + + notifyPageChange(); + + window.webildCleanup = () => { + isActive = false; + + if (selectedElement) { + makeUneditable(selectedElement, false); + } + + removeHoverOverlay(); + removeElementTypeLabel(); + + if (urlCheckInterval) { + clearInterval(urlCheckInterval); + } + + document.removeEventListener('mouseover', handleMouseOver, true); + document.removeEventListener('mouseout', handleMouseOut, true); + document.removeEventListener('click', handleClick, true); + document.removeEventListener('keydown', handleKeyDown, true); + document.removeEventListener('blur', handleBlur, true); + window.removeEventListener('scroll', handleScroll, true); + window.removeEventListener('message', handleMessage, true); + + document.querySelectorAll('.' + hoverClass).forEach(el => { + el.classList.remove(hoverClass); + }); + document.querySelectorAll('.' + selectedClass).forEach(el => { + el.classList.remove(selectedClass); + }); + + const styleEl = document.getElementById('webild-inspector-styles'); + if (styleEl) styleEl.remove(); + + hoveredElement = null; + selectedElement = null; + }; + + window.parent.postMessage({ type: 'webild-editor-ready' }, '*'); +})(); +` + }} + /> + +