upload
This commit is contained in:
@@ -941,6 +941,31 @@
|
||||
eventCounts = {};
|
||||
try {
|
||||
const parsedState = JSON.parse(jsonPayload);
|
||||
const isArray = Array.isArray(parsedState);
|
||||
const hasPages = parsedState && Array.isArray(parsedState.pages);
|
||||
const isLegacy = parsedState && typeof parsedState === 'object'
|
||||
&& !hasPages
|
||||
&& (parsedState.components || parsedState.styles);
|
||||
if (isArray) {
|
||||
ed.setComponents(parsedState);
|
||||
applied = true;
|
||||
log('CONTENT', 'JSON-Komponenten (Array) angewendet.', 'orange');
|
||||
} else if (isLegacy) {
|
||||
if (parsedState.components) {
|
||||
ed.setComponents(parsedState.components);
|
||||
} else {
|
||||
ed.setComponents(parsedState);
|
||||
}
|
||||
if (parsedState.styles) {
|
||||
ed.setStyle(parsedState.styles);
|
||||
}
|
||||
applied = true;
|
||||
log('CONTENT', 'Legacy JSON (components/styles) angewendet.', 'orange');
|
||||
} else if (parsedState && typeof parsedState === 'object' && !hasPages) {
|
||||
ed.setComponents(parsedState);
|
||||
applied = true;
|
||||
log('CONTENT', 'JSON ohne Pages als Komponenten angewendet.', 'orange');
|
||||
} else {
|
||||
ed.loadProjectData(parsedState);
|
||||
applied = true;
|
||||
log('CONTENT', 'JSON-Projektzustand angewendet.', 'orange');
|
||||
@@ -950,9 +975,18 @@
|
||||
log('CONTENT WARN', 'JSON geladen aber leer, wechsle auf HTML-Fallback.', 'orange', 'warn');
|
||||
applied = false;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
log('CONTENT ERROR', `JSON loadProjectData Fehler: ${e.message}`, 'red', 'error');
|
||||
if (!html) {
|
||||
try {
|
||||
const fallback = parsedState && parsedState.components ? parsedState.components : parsedState;
|
||||
if (fallback) {
|
||||
ed.setComponents(fallback);
|
||||
applied = true;
|
||||
log('CONTENT', 'JSON-Fallback via setComponents angewendet.', 'orange');
|
||||
}
|
||||
} catch {}
|
||||
if (!applied && !html) {
|
||||
html = jsonPayload;
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user