import { html, type TemplateResult } from '@design.estate/dees-element'; import { DeesModal } from '../dees-modal.js'; import { type IBlock } from './wysiwyg.types.js'; export class WysiwygModalManager { /** * Shows language selection modal for code blocks */ static async showLanguageSelectionModal(): Promise { return new Promise((resolve) => { let selectedLanguage: string | null = null; DeesModal.createAndShow({ heading: 'Select Programming Language', content: html`
${this.getLanguages().map(lang => html`
${lang}
`)}
`, menuOptions: [ { name: 'Cancel', action: async (modal) => { modal.destroy(); resolve(null); } }, { name: 'OK', action: async (modal) => { modal.destroy(); resolve(selectedLanguage); } } ] }); }); } /** * Shows block settings modal */ static async showBlockSettingsModal( block: IBlock, onUpdate: (block: IBlock) => void ): Promise { let content: TemplateResult; if (block.type === 'code') { content = this.getCodeBlockSettings(block, onUpdate); } else { content = html`
No settings available for this block type.
`; } DeesModal.createAndShow({ heading: 'Block Settings', content, menuOptions: [ { name: 'Close', action: async (modal) => { modal.destroy(); } } ] }); } /** * Gets code block settings content */ private static getCodeBlockSettings( block: IBlock, onUpdate: (block: IBlock) => void ): TemplateResult { const currentLanguage = block.metadata?.language || 'plain text'; return html`
Programming Language
${this.getLanguages().map(lang => html`
${lang}
`)}
`; } /** * Gets available programming languages */ private static getLanguages(): string[] { return [ 'JavaScript', 'TypeScript', 'Python', 'Java', 'C++', 'C#', 'Go', 'Rust', 'HTML', 'CSS', 'SQL', 'Shell', 'JSON', 'YAML', 'Markdown', 'Plain Text' ]; } }