snapshot restore node sizes

This commit is contained in:
2026-03-29 22:10:39 -07:00
parent e84b6c033e
commit adfb3ea354
3 changed files with 26 additions and 4 deletions

View File

@@ -26,14 +26,23 @@ export function serializeWorkflowState(nodes, edges) {
sanitizeRuntimeValuesForPersistence(node.data?.className, node.data?.runtimeValues),
);
const snapDim = (v) => {
const n = Math.round(Number(v));
return Number.isFinite(n) && n > 0 ? n : undefined;
};
return {
version: 1,
nodes: nodes.map((node) => {
const runtimeValues = getRuntimeValues(node);
const width = snapDim(node.measured?.width ?? node.width);
const height = snapDim(node.measured?.height ?? node.height);
return {
id: node.id,
type: node.type || 'custom',
position: node.position,
...(width != null ? { width } : {}),
...(height != null ? { height } : {}),
...(node.className ? { className: node.className } : {}),
...(node.parentId ? { parentId: node.parentId } : {}),
...(node.extent ? { extent: node.extent } : {}),