From bad888c732e16f9a4b9e6ad011ef2742fea0ba60 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sun, 11 Jan 2026 03:03:12 +0100 Subject: [PATCH] asdad --- public/assets/js/bridge/blocks-api.js | 26 +++++++++++++++++++++++--- src/ApiKernel.php | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/public/assets/js/bridge/blocks-api.js b/public/assets/js/bridge/blocks-api.js index 8d62221..32c5488 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -477,17 +477,37 @@ const resource = EDITOR_MODE; const action = `${resource}.update`; + const debugSave = (() => { + try { + const params = new URLSearchParams(window.location.search || ''); + if (params.get('debug_save') === '1') return true; + return localStorage.getItem('et_debug_save') === '1'; + } catch (e) { + return false; + } + })(); log('SAVE START', 'Starte Speichern des Inhalts an die API...', '#FF4500'); // 3. Daten für den POST-Request vorbereiten - const dataToSend = { + const dataToSend = { action, id: CURRENT_ENTITY_ID, html: htmlContent, // 🚨 KRITISCH: Server erwartet das Feld 'json' json: jsonProjectDataRaw, }; + if (debugSave) { + dataToSend.debug = 1; + console.log('[ET DEBUG] save-data payload', { + id: CURRENT_ENTITY_ID, + mode: resource, + htmlLength: htmlContent.length, + jsonLength: jsonProjectDataRaw.length, + htmlPreview: htmlContent.slice(0, 200), + jsonPreview: jsonProjectDataRaw.slice(0, 200), + }); + } if (B.CURRENT_ENTITY_NAME) { dataToSend.name = B.CURRENT_ENTITY_NAME; @@ -536,8 +556,8 @@ }); // Tastenkürzel für Speichern hinzufügen - editor.Keymaps.add('ctrl-s', 'save-data', 'ctrl+s'); - editor.Keymaps.add('cmd-s', 'save-data', 'cmd+s'); + editor.Keymaps.add('save-data-ctrl', 'ctrl+s', 'save-data'); + editor.Keymaps.add('save-data-cmd', 'cmd+s', 'save-data'); log('Speichern-Command und Button/Keymap registriert.', '#FF4500'); }; diff --git a/src/ApiKernel.php b/src/ApiKernel.php index ed74750..5b507d2 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -696,6 +696,7 @@ class ApiKernel if ($blk !== null && in_array('block_id', $allCols, true)) $data['block_id'] = $blk; if ($updCol) $data[$updCol] = date('Y-m-d H:i:s'); + $this->debugSavePayload($kind, $id, $html, $json); if (!$data) $this->fail('nothing to update', null, 422); [$tw, $tp] = $this->tenantWhere($auth); @@ -903,6 +904,27 @@ class ApiKernel } } + private function debugSavePayload(string $kind, $id, $html, $json): void + { + if (empty($this->in['debug'])) { + return; + } + + $payload = [ + 'time' => date(DATE_ATOM), + 'kind' => $kind, + 'id' => $id, + 'html_length' => is_string($html) ? strlen($html) : null, + 'json_length' => is_string($json) ? strlen($json) : null, + 'html_preview' => is_string($html) ? substr($html, 0, 200) : null, + 'json_preview' => is_string($json) ? substr($json, 0, 200) : null, + 'json_is_empty' => is_string($json) ? trim($json) === '' : ($json === null), + ]; + + $line = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\n"; + @file_put_contents(sys_get_temp_dir() . '/emailtemplate_debug_save.log', $line, FILE_APPEND); + } + private function replacePlaceholders(string $html, array $placeholders): string { if ($html === '' || !$placeholders) {