fix viewport
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { sanitizeRuntimeValuesForPersistence } from './runtimeValuePersistence.js';
|
||||
|
||||
export function serializeWorkflowState(nodes, edges) {
|
||||
const compactObject = (value) => {
|
||||
if (!value || typeof value !== 'object') return null;
|
||||
@@ -20,29 +22,35 @@ export function serializeWorkflowState(nodes, edges) {
|
||||
'warning',
|
||||
].includes(key))
|
||||
));
|
||||
const getRuntimeValues = (node) => compactObject(
|
||||
sanitizeRuntimeValuesForPersistence(node.data?.className, node.data?.runtimeValues),
|
||||
);
|
||||
|
||||
return {
|
||||
version: 1,
|
||||
nodes: nodes.map((node) => ({
|
||||
id: node.id,
|
||||
type: node.type || 'custom',
|
||||
position: node.position,
|
||||
...(node.className ? { className: node.className } : {}),
|
||||
...(node.parentId ? { parentId: node.parentId } : {}),
|
||||
...(node.extent ? { extent: node.extent } : {}),
|
||||
...(node.hidden ? { hidden: true } : {}),
|
||||
...(node.style ? { style: node.style } : {}),
|
||||
dragHandle: node.dragHandle || '.drag-handle',
|
||||
data: {
|
||||
label: node.data?.label || node.data?.className || 'Node',
|
||||
className: node.data?.className || '',
|
||||
widgetValues: node.data?.widgetValues || {},
|
||||
...(compactObject(node.data?.runtimeValues) ? { runtimeValues: compactObject(node.data?.runtimeValues) } : {}),
|
||||
...(getExtraData(node.data) ? { extraData: getExtraData(node.data) } : {}),
|
||||
output: node.data?.definition?.output || [],
|
||||
output_name: node.data?.definition?.output_name || [],
|
||||
},
|
||||
})),
|
||||
nodes: nodes.map((node) => {
|
||||
const runtimeValues = getRuntimeValues(node);
|
||||
return {
|
||||
id: node.id,
|
||||
type: node.type || 'custom',
|
||||
position: node.position,
|
||||
...(node.className ? { className: node.className } : {}),
|
||||
...(node.parentId ? { parentId: node.parentId } : {}),
|
||||
...(node.extent ? { extent: node.extent } : {}),
|
||||
...(node.hidden ? { hidden: true } : {}),
|
||||
...(node.style ? { style: node.style } : {}),
|
||||
dragHandle: node.dragHandle || '.drag-handle',
|
||||
data: {
|
||||
label: node.data?.label || node.data?.className || 'Node',
|
||||
className: node.data?.className || '',
|
||||
widgetValues: node.data?.widgetValues || {},
|
||||
...(runtimeValues ? { runtimeValues } : {}),
|
||||
...(getExtraData(node.data) ? { extraData: getExtraData(node.data) } : {}),
|
||||
output: node.data?.definition?.output || [],
|
||||
output_name: node.data?.definition?.output_name || [],
|
||||
},
|
||||
};
|
||||
}),
|
||||
edges: edges.map((edge) => ({
|
||||
id: edge.id,
|
||||
source: edge.source,
|
||||
|
||||
Reference in New Issue
Block a user