@@ -14,11 +14,11 @@ const separator = {
14
14
const manageSeparators : ManageSeparators = {
15
15
nextTopSeparatorId : 1000 ,
16
16
// this function checks for two separators in a row or missing separators and adds/removes as needed
17
- handleSeparators : ( arr , str ) => {
17
+ handleSeparators : ( arr : ChildElement [ ] , str ? ) => {
18
18
if (
19
19
( str === 'delete' || str === 'change position' ) &&
20
20
arr . length === 1 &&
21
- arr . slice ( 0 , 1 ) . name === 'separator'
21
+ arr [ 0 ] . name === 'separator'
22
22
) {
23
23
arr . splice ( 0 , 1 ) ;
24
24
}
@@ -44,7 +44,12 @@ const manageSeparators: ManageSeparators = {
44
44
name : 'separator' ,
45
45
childId : manageSeparators . nextTopSeparatorId ,
46
46
style : separator . style ,
47
- children : [ ]
47
+ attributes : { } , // Added
48
+ events : { } , // Added
49
+ stateProps : [ ] , // Added
50
+ passedInProps : [ ] , // Added
51
+ children : [ ] ,
52
+
48
53
} ;
49
54
// add a topSeparator before the element that does not have one
50
55
arr . splice ( index , 0 , topSeparator ) ;
@@ -55,7 +60,7 @@ const manageSeparators: ManageSeparators = {
55
60
if (
56
61
arr [ index ] . name !== 'input' &&
57
62
arr [ index ] . name !== 'img' &&
58
- arr [ index ] . children . length
63
+ arr [ index ] . children ? .length
59
64
) {
60
65
// recursive call if children array
61
66
str === 'delete' || str === 'change position'
@@ -67,22 +72,22 @@ const manageSeparators: ManageSeparators = {
67
72
} ,
68
73
69
74
// this function replaces separators onto which an element is dropped with the element itself
70
- mergeSeparator : ( arr : object [ ] , index : number ) => {
75
+ mergeSeparator : ( arr : ChildElement [ ] , index : number ) => {
71
76
return arr . map ( ( child ) => {
72
77
// Added additional nested types for lists
73
78
if (
74
79
( child . name === 'div' ||
75
- child . name === 'form' ||
76
- child . name === 'ol' ||
77
- child . name === 'ul' ) &&
78
- child . children . length
80
+ child . name === 'form' ||
81
+ child . name === 'ol' ||
82
+ child . name === 'ul' ) &&
83
+ child ? .children ? .length
79
84
) {
80
85
const divContents = manageSeparators . mergeSeparator (
81
86
child . children ,
82
87
index
83
- ) ;
88
+ )
84
89
return { ...child , children : divContents } ;
85
- } else if ( child . name === 'separator' && child . children . length ) {
90
+ } else if ( child . name === 'separator' && child ? .children ? .length ) {
86
91
return child . children [ index ] ;
87
92
} else return child ;
88
93
} ) ;
0 commit comments