diff --git a/js/editor.js b/js/editor.js index 667fe04..e666f40 100644 --- a/js/editor.js +++ b/js/editor.js @@ -96,8 +96,6 @@ function initEditor() { // beim Abschicken verbleibende Blöcke auslesen UND gelöschte Bilder ermitteln form.addEventListener("submit", function(e) { - e.preventDefault(); - const blocks = []; const currentImages = []; @@ -150,9 +148,20 @@ function initEditor() { // Existierende Blöcke laden (stellt alte Daten aus der Session wieder her) try { - const initialBlocks = JSON.parse(hiddenContentInput.value); + const initialBlocks = JSON.parse(hiddenContentInput.value.trim()); if (Array.isArray(initialBlocks)) { - initialBlocks.forEach(b => addBlockElement(b.type, b.value)); + initialBlocks.forEach(b => { + if (b.type === "image" && b.value && typeof b.value === 'string' && !b.value.startsWith('data:image/')) { + let cleanPath = b.value.trim().replace(/\\\//g, '/'); // Verwandelt \/ in / + + initialImages.push(cleanPath); + addBlockElement(b.type, cleanPath); + + } else { + addBlockElement(b.type, b.value); + } + }); + console.log("Erfolgreich registrierte Start-Bilder:", initialImages); } } catch(e) { if (hiddenContentInput.value.trim() !== "") {