diff --git a/web/index.html b/web/index.html
index 9e13b56..fdb0adc 100644
--- a/web/index.html
+++ b/web/index.html
@@ -598,9 +598,12 @@ $ python web/serve.py
formDiv.style.cssText = 'display: flex; flex-direction: column; gap: 16px; padding: 8px; background: var(--bg-card); border-radius: 4px; margin: 0; min-height: 300px; overflow-y: auto;';
// Rekursive Funktion zum Erstellen von Eingabefeldern für alle Properties
- function buildJsonForm(data, prefix = '', level = 0) {
+ function buildJsonForm(data, prefix = '', level = 0, targetElement = null) {
if (typeof data !== 'object' || data === null) return;
+ const container = targetElement || document.getElementById('edit-content-content');
+ if (!container) return;
+
Object.keys(data).forEach(key => {
const fullKey = prefix ? `${prefix}.${key}` : key;
const value = data[key];
@@ -621,13 +624,12 @@ $ python web/serve.py
// Rekursiv innere Properties in den Container einfügen
const innerContainer = document.createElement('div');
innerContainer.style.cssText = 'padding-left: 12px; margin-top: 4px;';
- buildJsonForm(value, fullKey, level + 1);
- const existingChildren = Array.from(innerContainer.children);
- while (innerContainer.firstChild) innerContainer.removeChild(innerContainer.firstChild);
- existingChildren.forEach(ch => innerContainer.appendChild(ch));
+
+ buildJsonForm(value, fullKey, level + 1, innerContainer);
+
fieldContainer.appendChild(innerContainer);
- formDiv.appendChild(fieldContainer);
+ container.appendChild(fieldContainer);
return;
}
@@ -661,10 +663,9 @@ $ python web/serve.py
if (typeof item === 'object' && item !== null) {
const innerObjContainer = document.createElement('div');
innerObjContainer.style.cssText = 'padding-left: 12px; margin-top: 4px;';
- buildJsonForm(item, itemKey, level + 1);
- const existingObjChildren = Array.from(innerObjContainer.children);
- while (innerObjContainer.firstChild) innerObjContainer.removeChild(innerObjContainer.firstChild);
- existingObjChildren.forEach(ch => innerObjContainer.appendChild(ch));
+
+ buildJsonForm(item, itemKey, level + 1, innerObjContainer);
+
itemContainer.appendChild(innerObjContainer);
} else {
const itemFieldContainer = document.createElement('div');
@@ -689,7 +690,7 @@ $ python web/serve.py
arrayItemsContainer.appendChild(itemContainer);
});
arrayContainer.appendChild(arrayItemsContainer);
- formDiv.appendChild(arrayContainer);
+ container.appendChild(arrayContainer);
return;
}
@@ -715,11 +716,11 @@ $ python web/serve.py
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);
- formDiv.appendChild(fieldContainer);
+ container.appendChild(fieldContainer);
});
}
- buildJsonForm(jsonData);
+ buildJsonForm(jsonData, '', 0, formDiv);
container.appendChild(formDiv);
}