fix: template-Feld im JSON-Editor als Textarea rendern
This commit is contained in:
parent
9890763f0f
commit
c106384c4e
4 changed files with 25 additions and 19 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,4 @@ function rememberViewModalOpen() {
|
|||
window._wasViewModalOpen = true;
|
||||
}
|
||||
|
||||
export {
|
||||
showModal,
|
||||
closeModal,
|
||||
closeEditModal,
|
||||
wasViewModalOpen,
|
||||
rememberViewModalOpen,
|
||||
};
|
||||
// exported functions are global (loaded as <script> tags)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
*/
|
||||
|
||||
let currentEditTemplate = null;
|
||||
let editContainerRef = null;
|
||||
let currentIndent = 2;
|
||||
|
||||
/**
|
||||
* Render Template-Karten in den Container
|
||||
|
|
|
|||
|
|
@ -44,4 +44,4 @@ async function copyContentToClipboard(content) {
|
|||
}
|
||||
}
|
||||
|
||||
export { esc, showToast, copyContentToClipboard };
|
||||
// exported functions are global (loaded as <script> tags)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue