From c106384c4e4f25c0acabaaeb32c04d102a707815 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 May 2026 15:06:03 +0200 Subject: [PATCH] fix: template-Feld im JSON-Editor als Textarea rendern --- web/js/editor.js | 32 +++++++++++++++++++++++--------- web/js/modal.js | 8 +------- web/js/templates.js | 2 -- web/js/utils.js | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/web/js/editor.js b/web/js/editor.js index afb1d6b..2528a02 100644 --- a/web/js/editor.js +++ b/web/js/editor.js @@ -180,18 +180,32 @@ function createJsonEditUI(container, jsonData, editPathHint = '') { label.style.cssText = 'font-weight: 600; color: var(--text-primary); display: block; margin-bottom: 4px; font-size: 14px; margin-top: 0;'; fieldContainer.appendChild(label); + // Das 'template'-Feld als Textarea rendern + const isTemplateField = (fullKey === 'template'); const type = typeof value === 'boolean' ? 'checkbox' : typeof value === 'number' ? 'number' : 'text'; - const input = document.createElement('input'); - input.type = type; - input.value = value !== null && value !== undefined ? value : ''; - input.dataset.key = fullKey; - input.dataset.type = typeof value; - if (type === 'checkbox') input.checked = value; - else input.value = String(value !== null && value !== undefined ? value : ''); + if (isTemplateField) { + const textarea = document.createElement('textarea'); + textarea.id = `edit-${fullKey.replace(/[.\s]/g, '-')}`; + textarea.value = value !== null && value !== undefined ? value : ''; + textarea.dataset.key = fullKey; + textarea.dataset.type = typeof value; + textarea.style.cssText = 'width: 100%; min-height: 200px; padding: 8px; background: #222222; color: #ffffff; border: 1px solid #555; border-radius: 3px; font-family: var(--mono); font-size: 13px; resize: vertical;'; + textarea.spellcheck = false; + fieldContainer.appendChild(textarea); + } else { + const input = document.createElement('input'); + input.type = type; + input.value = value !== null && value !== undefined ? value : ''; + input.dataset.key = fullKey; + input.dataset.type = typeof value; - input.style.cssText = 'width: 100%; padding: 8px; background: #222222; color: #ffffff; border: 1px solid #555; border-radius: 3px; font-family: var(--mono); font-size: 13px;'; - fieldContainer.appendChild(input); + if (type === 'checkbox') input.checked = value; + else input.value = String(value !== null && value !== undefined ? value : ''); + + input.style.cssText = 'width: 100%; padding: 8px; background: #222222; color: #ffffff; border: 1px solid #555; border-radius: 3px; font-family: var(--mono); font-size: 13px;'; + fieldContainer.appendChild(input); + } container.appendChild(fieldContainer); }); } diff --git a/web/js/modal.js b/web/js/modal.js index b82d5bf..805efea 100644 --- a/web/js/modal.js +++ b/web/js/modal.js @@ -42,10 +42,4 @@ function rememberViewModalOpen() { window._wasViewModalOpen = true; } -export { - showModal, - closeModal, - closeEditModal, - wasViewModalOpen, - rememberViewModalOpen, -}; +// exported functions are global (loaded as