11import React , { useState , useCallback , useMemo , useEffect } from 'react' ;
22import { SchemaRenderer } from '@object-ui/react' ;
3- import { ComponentRegistry } from '@object-ui/core' ;
3+ import { ComponentRegistry , type SchemaNode } from '@object-ui/core' ;
44import { useDesigner } from '../context/DesignerContext' ;
55import { ContextMenu } from './ContextMenu' ;
66import { ResizeHandles , ResizeDirection } from './ResizeHandle' ;
@@ -206,7 +206,8 @@ export const Canvas: React.FC<CanvasProps> = React.memo(({ className }) => {
206206 }
207207
208208 // Apply constraints from component config
209- const config = ComponentRegistry . getConfig ( schema . type ) ;
209+ const currentNode = findNodeInSchema ( schema , resizingNode . nodeId ) ;
210+ const config = currentNode ? ComponentRegistry . getConfig ( currentNode . type ) : null ;
210211 if ( config ?. resizeConstraints ) {
211212 const constraints = config . resizeConstraints ;
212213 if ( constraints . minWidth ) newWidth = Math . max ( constraints . minWidth , newWidth ) ;
@@ -232,25 +233,13 @@ export const Canvas: React.FC<CanvasProps> = React.memo(({ className }) => {
232233 const width = element . style . width ;
233234 const height = element . style . height ;
234235
235- // Update node with new dimensions in className
236- // We'll add custom width/height to the existing className
237- const currentNode = findNodeInSchema ( schema , resizingNode . nodeId ) ;
238- if ( currentNode ) {
239- const existingClasses = currentNode . className || '' ;
240- // Remove any existing width/height classes
241- let newClassName = existingClasses
242- . split ( ' ' )
243- . filter ( c => ! c . startsWith ( 'w-' ) && ! c . startsWith ( 'h-' ) && ! c . includes ( 'width' ) && ! c . includes ( 'height' ) )
244- . join ( ' ' ) ;
245-
246- // Add inline style instead via data attribute for persistent sizing
247- updateNode ( resizingNode . nodeId , {
248- style : {
249- width,
250- height
251- }
252- } ) ;
253- }
236+ // Persist new dimensions via style on the node schema
237+ updateNode ( resizingNode . nodeId , {
238+ style : {
239+ width,
240+ height
241+ }
242+ } ) ;
254243
255244 // Clear inline style after update
256245 element . style . width = '' ;
@@ -270,16 +259,18 @@ export const Canvas: React.FC<CanvasProps> = React.memo(({ className }) => {
270259 } , [ resizingNode , setResizingNode , updateNode , schema ] ) ;
271260
272261 // Helper to find node in schema
273- const findNodeInSchema = ( node : any , targetId : string ) : any => {
262+ const findNodeInSchema = ( node : SchemaNode , targetId : string ) : SchemaNode | null => {
274263 if ( node . id === targetId ) return node ;
275264
276265 if ( Array . isArray ( node . body ) ) {
277266 for ( const child of node . body ) {
278- const found = findNodeInSchema ( child , targetId ) ;
279- if ( found ) return found ;
267+ if ( typeof child === 'object' && child !== null ) {
268+ const found = findNodeInSchema ( child as SchemaNode , targetId ) ;
269+ if ( found ) return found ;
270+ }
280271 }
281272 } else if ( node . body && typeof node . body === 'object' ) {
282- return findNodeInSchema ( node . body , targetId ) ;
273+ return findNodeInSchema ( node . body as SchemaNode , targetId ) ;
283274 }
284275
285276 return null ;
@@ -480,7 +471,12 @@ export const Canvas: React.FC<CanvasProps> = React.memo(({ className }) => {
480471 /* Resizing state cursor override */
481472 ${ resizingNode ? `
482473 * {
483- cursor: ${ resizingNode . direction . includes ( 'e' ) || resizingNode . direction . includes ( 'w' ) ? 'ew-resize' : 'ns-resize' } !important;
474+ cursor: ${
475+ resizingNode . direction === 'ne' || resizingNode . direction === 'sw' ? 'nesw-resize' :
476+ resizingNode . direction === 'nw' || resizingNode . direction === 'se' ? 'nwse-resize' :
477+ resizingNode . direction . includes ( 'e' ) || resizingNode . direction . includes ( 'w' ) ? 'ew-resize' :
478+ 'ns-resize'
479+ } !important;
484480 }
485481
486482 [data-obj-id="${ resizingNode . nodeId } "] {
0 commit comments