This commit is contained in:
2026-01-11 03:03:12 +01:00
parent 8db4c4bd3a
commit bad888c732
2 changed files with 45 additions and 3 deletions

View File

@@ -477,17 +477,37 @@
const resource = EDITOR_MODE; const resource = EDITOR_MODE;
const action = `${resource}.update`; 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'); log('SAVE START', 'Starte Speichern des Inhalts an die API...', '#FF4500');
// 3. Daten für den POST-Request vorbereiten // 3. Daten für den POST-Request vorbereiten
const dataToSend = { const dataToSend = {
action, action,
id: CURRENT_ENTITY_ID, id: CURRENT_ENTITY_ID,
html: htmlContent, html: htmlContent,
// 🚨 KRITISCH: Server erwartet das Feld 'json' // 🚨 KRITISCH: Server erwartet das Feld 'json'
json: jsonProjectDataRaw, 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) { if (B.CURRENT_ENTITY_NAME) {
dataToSend.name = B.CURRENT_ENTITY_NAME; dataToSend.name = B.CURRENT_ENTITY_NAME;
@@ -536,8 +556,8 @@
}); });
// Tastenkürzel für Speichern hinzufügen // Tastenkürzel für Speichern hinzufügen
editor.Keymaps.add('ctrl-s', 'save-data', 'ctrl+s'); editor.Keymaps.add('save-data-ctrl', 'ctrl+s', 'save-data');
editor.Keymaps.add('cmd-s', 'save-data', 'cmd+s'); editor.Keymaps.add('save-data-cmd', 'cmd+s', 'save-data');
log('Speichern-Command und Button/Keymap registriert.', '#FF4500'); log('Speichern-Command und Button/Keymap registriert.', '#FF4500');
}; };

View File

@@ -696,6 +696,7 @@ class ApiKernel
if ($blk !== null && in_array('block_id', $allCols, true)) $data['block_id'] = $blk; if ($blk !== null && in_array('block_id', $allCols, true)) $data['block_id'] = $blk;
if ($updCol) $data[$updCol] = date('Y-m-d H:i:s'); 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); if (!$data) $this->fail('nothing to update', null, 422);
[$tw, $tp] = $this->tenantWhere($auth); [$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 private function replacePlaceholders(string $html, array $placeholders): string
{ {
if ($html === '' || !$placeholders) { if ($html === '' || !$placeholders) {