index.tsx
27 lines
| 1 | import { ChakraProvider } from '@chakra-ui/react'; |
| 2 | import React from 'react'; |
| 3 | import { createRoot } from 'react-dom/client'; |
| 4 | import BuilderAIChat from './BuilderAIChat'; |
| 5 | |
| 6 | // Mount the AI chat widget into the injected #evf-builder-ai div. |
| 7 | const mount = () => { |
| 8 | let container = document.getElementById('evf-builder-ai'); |
| 9 | if (!container) { |
| 10 | container = document.createElement('div'); |
| 11 | container.id = 'evf-builder-ai'; |
| 12 | document.body.appendChild(container); |
| 13 | } |
| 14 | createRoot(container).render( |
| 15 | <ChakraProvider> |
| 16 | <BuilderAIChat /> |
| 17 | </ChakraProvider> |
| 18 | ); |
| 19 | }; |
| 20 | |
| 21 | // Run after DOM is ready. |
| 22 | if (document.readyState === 'loading') { |
| 23 | document.addEventListener('DOMContentLoaded', mount); |
| 24 | } else { |
| 25 | mount(); |
| 26 | } |
| 27 |