Spaces:
Running
Running
| class CustomEditor extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: flex; | |
| flex-direction: column; | |
| flex: 1; | |
| padding: 2rem; | |
| overflow-y: auto; | |
| } | |
| .toolbar { | |
| display: flex; | |
| gap: 0.5rem; | |
| margin-bottom: 1rem; | |
| padding-bottom: 1rem; | |
| border-bottom: 1px solid #e2e8f0; | |
| } | |
| .tool-btn { | |
| background: none; | |
| border: none; | |
| padding: 0.5rem; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| transition: all 0.2s; | |
| } | |
| .tool-btn:hover { | |
| background-color: #c0f0e2; | |
| } | |
| .content { | |
| min-height: 100%; | |
| outline: none; | |
| } | |
| .content h1 { | |
| font-size: 2rem; | |
| margin-bottom: 1.5rem; | |
| color: #5aa58b; | |
| font-family: 'Inter', sans-serif; | |
| } | |
| .content p { | |
| line-height: 1.6; | |
| margin-bottom: 1rem; | |
| font-family: 'Inter', sans-serif; | |
| } | |
| </style> | |
| <div class="toolbar"> | |
| <button class="tool-btn">H1</button> | |
| <button class="tool-btn">H2</button> | |
| <button class="tool-btn">B</button> | |
| <button class="tool-btn">I</button> | |
| <button class="tool-btn">π</button> | |
| <button class="tool-btn">β </button> | |
| </div> | |
| <div class="content" contenteditable="true"> | |
| <h1>Welcome to MindFlow</h1> | |
| <p>Start writing or type '/' for commands...</p> | |
| </div> | |
| `; | |
| // Add editor functionality | |
| const content = this.shadowRoot.querySelector('.content'); | |
| content.addEventListener('keydown', (e) => { | |
| if (e.key === '/') { | |
| this.showCommandMenu(); | |
| } | |
| }); | |
| } | |
| showCommandMenu() { | |
| // TODO: Implement command menu | |
| console.log('Show command menu'); | |
| } | |
| } | |
| customElements.define('custom-editor', CustomEditor); |