class CustomCommandPanel extends HTMLElement { constructor() { super(); this.isOpen = false; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); this.setupEventListeners(); } render() { this.shadowRoot.innerHTML = `
CMD
Command Center
⏱ Recent Commands
  • 📝
    /task create "API integration" @john
  • ↔️
    /bulk assign sprint:Q1-3 to:@alice
  • 🗓️
    /schedule pto @bob from:3/1 to:3/5
📚 Command Templates
  • 📝
    Create Task
    Create a new task with specified details
  • ↔️
    Move Task
    Move task to different date/assignee
  • 🔄
    Update Status
    Update task properties
  • 🗑️
    Delete Task
    Delete specific task
  • 🗓️
    Scheduling (6 commands)
  • 📋
    Multi-Task Operations (8 commands)
💡 Context Suggestions
Based on your selection:
  • • Assign 3 selected tasks to...
  • • Move selection to next sprint
  • • Mark selected as complete
`; } setupEventListeners() { const toggleButton = this.shadowRoot.getElementById('toggle-button'); const closeButton = this.shadowRoot.getElementById('close-button'); const commandPanel = this.shadowRoot.getElementById('command-panel'); const searchInput = this.shadowRoot.getElementById('search-input'); toggleButton.addEventListener('click', () => { this.togglePanel(); }); closeButton.addEventListener('click', () => { this.closePanel(); }); // Close panel when clicking outside document.addEventListener('click', (event) => { if (this.isOpen && !commandPanel.contains(event.target) && !toggleButton.contains(event.target)) { this.closePanel(); } }); // Keyboard shortcuts document.addEventListener('keydown', (event) => { // Ctrl+K or Cmd+K to toggle panel if ((event.ctrlKey || event.metaKey) && event.key === 'k') { event.preventDefault(); this.togglePanel(); } // Escape to close panel if (event.key === 'Escape' && this.isOpen) { this.closePanel(); } }); // Focus search input when panel opens searchInput.addEventListener('focus', () => { // Handle autocomplete suggestions }); } togglePanel() { this.isOpen = !this.isOpen; const panel = this.shadowRoot.getElementById('command-panel'); const toggleButton = this.shadowRoot.getElementById('toggle-button'); if (this.isOpen) { panel.classList.add('panel-open'); toggleButton.textContent = '×'; } else { panel.classList.remove('panel-open'); toggleButton.textContent = 'CMD'; } } openPanel(template = null) { this.isOpen = true; const panel = this.shadowRoot.getElementById('command-panel'); const toggleButton = this.shadowRoot.getElementById('toggle-button'); panel.classList.add('panel-open'); toggleButton.textContent = '×'; // If template specified, load that template if (template) { this.loadTemplate(template); } } closePanel() { this.isOpen = false; const panel = this.shadowRoot.getElementById('command-panel'); const toggleButton = this.shadowRoot.getElementById('toggle-button'); panel.classList.remove('panel-open'); toggleButton.textContent = 'CMD'; } loadTemplate(templateName) { // Load specific command template console.log('Loading template:', templateName); } } customElements.define('custom-command-panel', CustomCommandPanel);