diff --git a/public/assets/js/bridge/blocks-api.js b/public/assets/js/bridge/blocks-api.js index 1395fa8..afb1bf3 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -173,9 +173,16 @@ } // 1. Daten extrahieren - const htmlContent = editor.getHtml() + ''; - // 2. KRITISCH: Holt die JSON-Repräsentation des Editors - const jsonProjectData = editor.getProjectData(); + const htmlContent = editor.getHtml() + ''; + // 2. KRITISCH: Holt die JSON-Repräsentation des Editors + let jsonProjectDataRaw = ''; + try { + const jsonProjectData = editor.getProjectData(); + jsonProjectDataRaw = JSON.stringify(jsonProjectData); + } catch (e) { + console.error('[bridge-blocks-api] getProjectData stringify failed', e); + jsonProjectDataRaw = ''; + } const resource = EDITOR_MODE; const action = `${resource}.update`; @@ -183,13 +190,13 @@ log('SAVE START', 'Starte Speichern des Inhalts an die API...', '#FF4500'); // 3. Daten für den POST-Request vorbereiten - const dataToSend = { - action, - id: CURRENT_ENTITY_ID, - html: htmlContent, - // 🚨 KRITISCH: Server erwartet das Feld 'json' - json: jsonProjectData, - }; + const dataToSend = { + action, + id: CURRENT_ENTITY_ID, + html: htmlContent, + // 🚨 KRITISCH: Server erwartet das Feld 'json' + json: jsonProjectDataRaw, + }; if (B.CURRENT_ENTITY_NAME) { dataToSend.name = B.CURRENT_ENTITY_NAME; diff --git a/public/editor/editor-core.php b/public/editor/editor-core.php index daaa0b5..f6da171 100644 --- a/public/editor/editor-core.php +++ b/public/editor/editor-core.php @@ -10,7 +10,7 @@ $ts = time();