diff --git a/public/assets/js/ui-create.js b/public/assets/js/ui-create.js index 84798a1..f08fa82 100644 --- a/public/assets/js/ui-create.js +++ b/public/assets/js/ui-create.js @@ -18,14 +18,7 @@ export function initCreate(){ const name=document.createElement('input'); name.type='text'; name.required=true; name.placeholder='Name*'; name.className='w-full border rounded-lg px-3 py-2'; name.id='f-name'; fields.appendChild(name); let apiName = null; let apiTouched = false; - if(tab==='templates'){ - apiName=document.createElement('input'); - apiName.type='text'; - apiName.required=true; - apiName.placeholder='API Name* (ohne Leerzeichen)'; - apiName.className='w-full border rounded-lg px-3 py-2'; - apiName.id='f-api-name'; - fields.appendChild(apiName); + const addEditorSelect = () => { const editorSelect = document.createElement('select'); editorSelect.id = 'f-editor-type'; editorSelect.className = 'w-full border rounded-lg px-3 py-2'; @@ -36,6 +29,17 @@ export function initCreate(){ const defaultEditor = (window.__editorDefault || 'grapesjs').toLowerCase(); editorSelect.value = defaultEditor === 'craftjs' ? 'craftjs' : 'grapesjs'; fields.appendChild(editorSelect); + }; + + if(tab==='templates'){ + apiName=document.createElement('input'); + apiName.type='text'; + apiName.required=true; + apiName.placeholder='API Name* (ohne Leerzeichen)'; + apiName.className='w-full border rounded-lg px-3 py-2'; + apiName.id='f-api-name'; + fields.appendChild(apiName); + addEditorSelect(); apiName.addEventListener('input', ()=>{ apiTouched = true; const next = normalizeApiName(apiName.value); @@ -49,6 +53,7 @@ export function initCreate(){ if(tab==='sections') await addSel('f-template','Template','templates'); if(tab==='blocks') await addSel('f-section','Section','sections'); if(tab==='snippets') await addSel('f-block','Block','blocks'); + if (tab !== 'templates') addEditorSelect(); hint.textContent=`Neues ${tab} anlegen`; dlg.showModal(); form.onsubmit=async(e)=>{ e.preventDefault(); @@ -56,8 +61,8 @@ export function initCreate(){ if(tab==='templates') { payload.api_name=(document.getElementById('f-api-name')?.value||'').trim(); if(!payload.api_name) return; - payload.editor_type=(document.getElementById('f-editor-type')?.value||'grapesjs'); } + payload.editor_type=(document.getElementById('f-editor-type')?.value||'grapesjs'); if(tab==='snippets') payload.content=''; else payload.html=''; if(tab==='sections') payload.template_id=document.getElementById('f-template')?.value||null; if(tab==='blocks') payload.section_id =document.getElementById('f-section')?.value ||null; diff --git a/schema.sql b/schema.sql index 312d839..67ba2da 100644 --- a/schema.sql +++ b/schema.sql @@ -75,6 +75,8 @@ CREATE TABLE IF NOT EXISTS `emailtemplate_blocks` ( `category` varchar(100) NOT NULL DEFAULT 'Default', `json_content` mediumtext DEFAULT NULL, `html` mediumtext DEFAULT NULL, + `editor_type` varchar(32) DEFAULT NULL, + `craft_json` mediumtext DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), @@ -153,6 +155,8 @@ CREATE TABLE IF NOT EXISTS `emailtemplate_sections` ( `type` varchar(50) NOT NULL DEFAULT 'html', `z_index` int(11) NOT NULL DEFAULT 0, `html` mediumtext DEFAULT NULL, + `editor_type` varchar(32) DEFAULT NULL, + `craft_json` mediumtext DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), diff --git a/src/ApiKernel.php b/src/ApiKernel.php index 0a46a06..67b29ae 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -623,7 +623,7 @@ class ApiKernel // --- LOGIK mit ERWEITERTER PRÜFUNG ENDE --- if ($editorDbCol) { - if ($editorType === '' && in_array($kind, ['templates', 'snippets'], true)) { + if ($editorType === '') { $settings = $this->getCustomerSettings((int)($auth['customer_id'] ?? 0)); $editorType = strtolower((string)($settings['editor_default'] ?? 'grapesjs')); }