import { html, type TemplateResult, cssManager } from '@design.estate/dees-element'; import { DeesModal } from '../dees-modal.js'; import { type IBlock } from './wysiwyg.types.js'; import { WysiwygShortcuts } from './wysiwyg.shortcuts.js'; import { PROGRAMMING_LANGUAGES } from './wysiwyg.constants.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); } } ] }); }); } /** * Shows block settings modal */ static async showBlockSettingsModal( block: IBlock, onUpdate: (block: IBlock) => void ): Promise { const content = html`
${this.getBlockTypeSelector(block, onUpdate)} ${block.type === 'code' ? this.getCodeBlockSettings(block, onUpdate) : ''}
`; DeesModal.createAndShow({ heading: 'Block Settings', content, menuOptions: [ { name: 'Done', 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 || 'javascript'; return html`
Programming Language
${this.getLanguages().map(lang => html`
${lang}
`)}
`; } /** * Gets available programming languages */ private static getLanguages(): string[] { return [...PROGRAMMING_LANGUAGES]; } /** * Gets block type selector */ private static getBlockTypeSelector( block: IBlock, onUpdate: (block: IBlock) => void ): TemplateResult { const blockTypes = WysiwygShortcuts.getSlashMenuItems().filter(item => item.type !== 'divider'); return html`
Block Type
${blockTypes.map(item => html`
${item.icon} ${item.label}
`)}
`; } }