@@ -326,7 +326,7 @@ const GridItemWrapper = React.memo(React.forwardRef(
326326 const editorState = useContext ( EditorContext ) ;
327327 const { children, ...divProps } = props ;
328328 return (
329- < ItemWrapper ref = { ref } $disableInteract = { editorState . disableInteract } { ...divProps } >
329+ < ItemWrapper ref = { ref } $disableInteract = { editorState ? .disableInteract } { ...divProps } >
330330 { props . children }
331331 </ ItemWrapper >
332332 ) ;
@@ -350,9 +350,9 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
350350 const [ currentRowHeight , setRowHeight ] = useState ( positionParams . rowHeight || DEFAULT_ROW_HEIGHT ) ;
351351 const editorState = useContext ( EditorContext ) ;
352352 const { readOnly } = useContext ( ExternalEditorContext ) ;
353- const appSettingsComp = editorState . getAppSettingsComp ( ) . getView ( ) ;
353+ const appSettingsComp = editorState ? .getAppSettingsComp ( ) . getView ( ) ;
354354
355- const maxWidth = useMemo ( ( ) => appSettingsComp . maxWidth , [ appSettingsComp . maxWidth ] ) ;
355+ const maxWidth = useMemo ( ( ) => appSettingsComp ? .maxWidth , [ appSettingsComp ? .maxWidth ] ) ;
356356
357357 // Falk: TODO: Here we can define the inner grid columns dynamically
358358 const defaultGrid = useMemo ( ( ) => {
@@ -372,10 +372,10 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
372372 getExtraLayout (
373373 props . items ,
374374 props . layout ,
375- editorState . selectedCompNames ,
375+ editorState ? .selectedCompNames ,
376376 props . dragSelectedComps
377377 ) ,
378- [ props . items , props . layout , editorState . selectedCompNames , props . dragSelectedComps ]
378+ [ props . items , props . layout , editorState ? .selectedCompNames , props . dragSelectedComps ]
379379 ) ;
380380
381381 const [ containerSelectNames , setContainerSelectNames ] = useState < Set < string > > ( new Set ( [ ] ) ) ;
@@ -392,8 +392,8 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
392392 } , [ extraLayout , containerSelectNames ] ) ;
393393
394394 const canAddSelect = useMemo (
395- ( ) => _ . size ( containerSelectNames ) === _ . size ( editorState . selectedCompNames ) ,
396- [ containerSelectNames , editorState . selectedCompNames ]
395+ ( ) => _ . size ( containerSelectNames ) === _ . size ( editorState ? .selectedCompNames ) ,
396+ [ containerSelectNames , editorState ? .selectedCompNames ]
397397 ) ;
398398
399399 const dispatchPositionParamsTimerRef = useRef ( 0 ) ;
@@ -446,9 +446,9 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
446446 ) ;
447447 const setSelectedNames = useCallback (
448448 ( names : Set < string > ) => {
449- editorState . setSelectedCompNames ( names ) ;
449+ editorState ? .setSelectedCompNames ( names ) ;
450450 } ,
451- [ editorState . setSelectedCompNames ]
451+ [ editorState ? .setSelectedCompNames ]
452452 ) ;
453453
454454 const { width, ref } = useResizeDetector ( {
@@ -502,7 +502,7 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
502502 style = { props . style }
503503 scrollContainerRef = { props . scrollContainerRef }
504504 width = { width ?? 0 }
505- showGridLines = { editorState . showGridLines ( ) && ( isDroppable || enableGridLines ) }
505+ showGridLines = { editorState ? .showGridLines ( ) && ( isDroppable || enableGridLines ) }
506506 isRowCountLocked = { isRowCountLocked }
507507 isDraggable = { isDraggable }
508508 isResizable = { isResizable }
@@ -519,7 +519,7 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
519519 : defaultLayout ( compType ) ;
520520 return {
521521 size : compLayout ?? defaultSize ,
522- positionParams : editorState . canvasPositionParams ( ) ,
522+ positionParams : editorState ? .canvasPositionParams ( ) ,
523523 } ;
524524 }
525525 } }
@@ -535,18 +535,18 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
535535 const items = _ . pick ( props . items , Object . keys ( layoutItems ) ) ;
536536 draggingUtils . setData ( "sourceDispatch" , props . dispatch ) ;
537537 draggingUtils . setData < Record < string , GridItem > > ( "items" , items ) ;
538- editorState . setDragging ( true ) ;
538+ editorState ? .setDragging ( true ) ;
539539 const names = Object . values ( items ) . map ( ( item ) => item . name ) ;
540- editorState . setSelectedCompNames ( new Set ( names ) ) ;
540+ editorState ? .setSelectedCompNames ( new Set ( names ) ) ;
541541 } }
542542 onFlyDrop = { ( layout , items ) => {
543543 onFlyDrop ( layout , items , props . dispatch ) ;
544544 } }
545545 onResizeStart = { ( _a , _b , _c , _d , event ) => {
546546 event . stopPropagation ( ) ;
547- editorState . setDragging ( true ) ;
547+ editorState ? .setDragging ( true ) ;
548548 } }
549- onResizeStop = { ( ) => editorState . setDragging ( false ) }
549+ onResizeStop = { ( ) => editorState ? .setDragging ( false ) }
550550 margin = { [ 0 , 0 ] }
551551 containerPadding = { props . containerPadding }
552552 fixedRowCount = { props . emptyRows !== DEFAULT_ROW_COUNT }
@@ -560,12 +560,12 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
560560 minHeight = { props . minHeight }
561561 bgColor = { props . bgColor }
562562 radius = { props . radius }
563- hintPlaceholder = { ! editorState . isDragging && ! readOnly && props . hintPlaceholder }
563+ hintPlaceholder = { ! editorState ? .isDragging && ! readOnly && props . hintPlaceholder }
564564 selectedSize = { _ . size ( containerSelectNames ) }
565565 clickItem = { clickItem }
566566 isCanvas = { props . isCanvas }
567567 showName = { props . showName }
568- disableDirectionKey = { editorState . isDragging || readOnly }
568+ disableDirectionKey = { editorState ? .isDragging || readOnly }
569569 >
570570 { itemViews }
571571 </ ReactGridLayout >
0 commit comments