@@ -326,7 +326,7 @@ const GridItemWrapper = React.memo(React.forwardRef(
326
326
const editorState = useContext ( EditorContext ) ;
327
327
const { children, ...divProps } = props ;
328
328
return (
329
- < ItemWrapper ref = { ref } $disableInteract = { editorState . disableInteract } { ...divProps } >
329
+ < ItemWrapper ref = { ref } $disableInteract = { editorState ? .disableInteract } { ...divProps } >
330
330
{ props . children }
331
331
</ ItemWrapper >
332
332
) ;
@@ -350,9 +350,9 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
350
350
const [ currentRowHeight , setRowHeight ] = useState ( positionParams . rowHeight || DEFAULT_ROW_HEIGHT ) ;
351
351
const editorState = useContext ( EditorContext ) ;
352
352
const { readOnly } = useContext ( ExternalEditorContext ) ;
353
- const appSettingsComp = editorState . getAppSettingsComp ( ) . getView ( ) ;
353
+ const appSettingsComp = editorState ? .getAppSettingsComp ( ) . getView ( ) ;
354
354
355
- const maxWidth = useMemo ( ( ) => appSettingsComp . maxWidth , [ appSettingsComp . maxWidth ] ) ;
355
+ const maxWidth = useMemo ( ( ) => appSettingsComp ? .maxWidth , [ appSettingsComp ? .maxWidth ] ) ;
356
356
357
357
// Falk: TODO: Here we can define the inner grid columns dynamically
358
358
const defaultGrid = useMemo ( ( ) => {
@@ -372,10 +372,10 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
372
372
getExtraLayout (
373
373
props . items ,
374
374
props . layout ,
375
- editorState . selectedCompNames ,
375
+ editorState ? .selectedCompNames ,
376
376
props . dragSelectedComps
377
377
) ,
378
- [ props . items , props . layout , editorState . selectedCompNames , props . dragSelectedComps ]
378
+ [ props . items , props . layout , editorState ? .selectedCompNames , props . dragSelectedComps ]
379
379
) ;
380
380
381
381
const [ containerSelectNames , setContainerSelectNames ] = useState < Set < string > > ( new Set ( [ ] ) ) ;
@@ -392,8 +392,8 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
392
392
} , [ extraLayout , containerSelectNames ] ) ;
393
393
394
394
const canAddSelect = useMemo (
395
- ( ) => _ . size ( containerSelectNames ) === _ . size ( editorState . selectedCompNames ) ,
396
- [ containerSelectNames , editorState . selectedCompNames ]
395
+ ( ) => _ . size ( containerSelectNames ) === _ . size ( editorState ? .selectedCompNames ) ,
396
+ [ containerSelectNames , editorState ? .selectedCompNames ]
397
397
) ;
398
398
399
399
const dispatchPositionParamsTimerRef = useRef ( 0 ) ;
@@ -446,9 +446,9 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
446
446
) ;
447
447
const setSelectedNames = useCallback (
448
448
( names : Set < string > ) => {
449
- editorState . setSelectedCompNames ( names ) ;
449
+ editorState ? .setSelectedCompNames ( names ) ;
450
450
} ,
451
- [ editorState . setSelectedCompNames ]
451
+ [ editorState ? .setSelectedCompNames ]
452
452
) ;
453
453
454
454
const { width, ref } = useResizeDetector ( {
@@ -502,7 +502,7 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
502
502
style = { props . style }
503
503
scrollContainerRef = { props . scrollContainerRef }
504
504
width = { width ?? 0 }
505
- showGridLines = { editorState . showGridLines ( ) && ( isDroppable || enableGridLines ) }
505
+ showGridLines = { editorState ? .showGridLines ( ) && ( isDroppable || enableGridLines ) }
506
506
isRowCountLocked = { isRowCountLocked }
507
507
isDraggable = { isDraggable }
508
508
isResizable = { isResizable }
@@ -519,7 +519,7 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
519
519
: defaultLayout ( compType ) ;
520
520
return {
521
521
size : compLayout ?? defaultSize ,
522
- positionParams : editorState . canvasPositionParams ( ) ,
522
+ positionParams : editorState ? .canvasPositionParams ( ) ,
523
523
} ;
524
524
}
525
525
} }
@@ -535,18 +535,18 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
535
535
const items = _ . pick ( props . items , Object . keys ( layoutItems ) ) ;
536
536
draggingUtils . setData ( "sourceDispatch" , props . dispatch ) ;
537
537
draggingUtils . setData < Record < string , GridItem > > ( "items" , items ) ;
538
- editorState . setDragging ( true ) ;
538
+ editorState ? .setDragging ( true ) ;
539
539
const names = Object . values ( items ) . map ( ( item ) => item . name ) ;
540
- editorState . setSelectedCompNames ( new Set ( names ) ) ;
540
+ editorState ? .setSelectedCompNames ( new Set ( names ) ) ;
541
541
} }
542
542
onFlyDrop = { ( layout , items ) => {
543
543
onFlyDrop ( layout , items , props . dispatch ) ;
544
544
} }
545
545
onResizeStart = { ( _a , _b , _c , _d , event ) => {
546
546
event . stopPropagation ( ) ;
547
- editorState . setDragging ( true ) ;
547
+ editorState ? .setDragging ( true ) ;
548
548
} }
549
- onResizeStop = { ( ) => editorState . setDragging ( false ) }
549
+ onResizeStop = { ( ) => editorState ? .setDragging ( false ) }
550
550
margin = { [ 0 , 0 ] }
551
551
containerPadding = { props . containerPadding }
552
552
fixedRowCount = { props . emptyRows !== DEFAULT_ROW_COUNT }
@@ -560,12 +560,12 @@ export const InnerGrid = React.memo((props: ViewPropsWithSelect) => {
560
560
minHeight = { props . minHeight }
561
561
bgColor = { props . bgColor }
562
562
radius = { props . radius }
563
- hintPlaceholder = { ! editorState . isDragging && ! readOnly && props . hintPlaceholder }
563
+ hintPlaceholder = { ! editorState ? .isDragging && ! readOnly && props . hintPlaceholder }
564
564
selectedSize = { _ . size ( containerSelectNames ) }
565
565
clickItem = { clickItem }
566
566
isCanvas = { props . isCanvas }
567
567
showName = { props . showName }
568
- disableDirectionKey = { editorState . isDragging || readOnly }
568
+ disableDirectionKey = { editorState ? .isDragging || readOnly }
569
569
>
570
570
{ itemViews }
571
571
</ ReactGridLayout >
0 commit comments