class CustomPromptInput extends HTMLElement { constructor() { super(); this.mode = 'image'; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); this.attachEvents(); } render() { this.shadowRoot.innerHTML = `
8K cinematic HDR landscape Ultra-detailed portrait Photorealistic 16K IMAX quality
`; } attachEvents() { const textarea = this.shadowRoot.getElementById('prompt-input'); const charCount = this.shadowRoot.getElementById('char-count'); const generateBtn = this.shadowRoot.getElementById('generate-btn'); const modeBtns = this.shadowRoot.querySelectorAll('.mode-btn'); const suggestions = this.shadowRoot.querySelectorAll('.suggestion-chip'); // Character count textarea.addEventListener('input', () => { charCount.textContent = textarea.value.length; }); // Mode selection modeBtns.forEach(btn => { btn.addEventListener('click', () => { modeBtns.forEach(b => b.classList.remove('active')); btn.classList.add('active'); this.mode = btn.dataset.mode; }); }); // Generate generateBtn.addEventListener('click', () => { const prompt = textarea.value.trim(); if (!prompt) { textarea.focus(); return; } generateBtn.disabled = true; generateBtn.classList.add('loading'); generateBtn.innerHTML = ` Generating... `; document.dispatchEvent(new CustomEvent('submitPrompt', { detail: { prompt, mode: this.mode, settings: { ...window.VortexAI?.state?.settings, width: this.selectedResolution?.width || 3840, height: this.selectedResolution?.height || 2160 } } })); }); // Quality presets const qualityPresets = this.shadowRoot.querySelectorAll('.quality-preset'); qualityPresets.forEach(preset => { preset.addEventListener('click', () => { qualityPresets.forEach(p => p.classList.remove('active')); preset.classList.add('active'); // Store selected resolution this.selectedResolution = { width: parseInt(preset.dataset.w), height: parseInt(preset.dataset.h) }; }); }); // Set default resolution this.selectedResolution = { width: 3840, height: 2160 }; // Suggestions suggestions.forEach(chip => { chip.addEventListener('click', () => { textarea.value = chip.textContent; charCount.textContent = textarea.value.length; textarea.focus(); }); }); // Random prompt const randomBtn = this.shadowRoot.querySelector('[title="Random prompt"]'); const randomPrompts = [ 'A cyberpunk samurai standing on a rooftop in Tokyo, neon lights reflecting on wet streets', 'An underwater city with bioluminescent architecture and manta rays swimming through', 'A steampunk airship battle above Victorian London at sunset', 'Crystalline forest with light refractions creating rainbow pathways', 'Mars colony interior with hydroponic gardens and Earth view through windows' ]; randomBtn.addEventListener('click', () => { const random = randomPrompts[Math.floor(Math.random() * randomPrompts.length)]; textarea.value = random; charCount.textContent = random.length; }); } } customElements.define('custom-prompt-input', CustomPromptInput);