UNPKG

@composable-svelte/code

Version:

Code editor, syntax highlighting, and node-based canvas components for Composable Svelte - Built with Prism.js, CodeMirror, and SvelteFlow

45 lines (44 loc) 1.18 kB
/** * Node Canvas Types * * Type definitions for node-based canvas editor with SvelteFlow integration. * Follows Composable Architecture patterns with state, actions, and reducer. */ // ============================================================================ // Helper Types // ============================================================================ /** * Helper to create initial canvas state with defaults. */ export function createInitialNodeCanvasState(overrides) { return { nodes: {}, edges: {}, viewport: { x: 0, y: 0, zoom: 1 }, selectedNodes: new Set(), selectedEdges: new Set(), connectionInProgress: null, readonly: false, showMiniMap: true, showControls: true, snapToGrid: false, gridSize: 15, ...overrides }; } /** * Helper to convert state.nodes Record to array for SvelteFlow. */ export function nodesToArray(nodes) { return Object.values(nodes); } /** * Helper to convert state.edges Record to array for SvelteFlow. */ export function edgesToArray(edges) { return Object.values(edges); }