class CustomSidebar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; // Add event listeners for element buttons setTimeout(() => { const buttons = this.shadowRoot.querySelectorAll('.element-btn'); buttons.forEach(button => { button.addEventListener('click', () => { const type = button.getAttribute('data-type'); this.addElement(type); }); }, 100); }); } addElement(type) { const canvasContainer = document.getElementById('canvasContainer'); let newElement; switch(type) { case 'text': newElement = document.createElement('div'); newElement.className = 'editable-element'; newElement.setAttribute('contenteditable', 'true'); newElement.style.position = 'absolute'; newElement.style.left = '100px'; newElement.style.top = '100px'; newElement.style.padding = '10px'; newElement.style.background = 'white'; newElement.style.border = '1px solid #e5e7eb'; newElement.style.borderRadius = '6px'; newElement.style.minWidth = '200px'; newElement.style.minHeight = '40px'; newElement.style.zIndex = '1000'; newElement.textContent = 'Double click to edit text'; break; case 'image': newElement = document.createElement('div'); newElement.className = 'editable-element'; newElement.style.position = 'absolute'; newElement.style.left = '150px'; newElement.style.top = '150px'; newElement.style.width = '200px'; newElement.style.height = '150px'; newElement.style.background = '#f3f4f6'; newElement.style.border = '2px dashed #d1d5db'; newElement.style.borderRadius = '6px'; newElement.style.display = 'flex'; newElement.style.alignItems = 'center'; newElement.style.justifyContent = 'center'; newElement.innerHTML = ` Add Image `; break; case 'chart': newElement = document.createElement('div'); newElement.className = 'editable-element'; newElement.style.position = 'absolute'; newElement.style.left = '200px'; newElement.style.top = '200px'; newElement.style.width = '300