@@ -17,11 +17,8 @@ function Canvas(props): JSX.Element {
17
17
18
18
useEffect ( ( ) => {
19
19
if ( newComp ) {
20
- console . log ( 'inside use effect' , { state} ) ;
21
- console . log ( 'copiedComp' , copiedComp . name )
22
20
//find updated comp
23
21
const copy = state . components . find ( comp => comp . name === copiedComp . name )
24
- console . log ( { copy} )
25
22
// make a array of copied children from the copied component
26
23
if ( copy . children . length ) {
27
24
const masterArr = [ ] ;
@@ -31,25 +28,19 @@ function Canvas(props): JSX.Element {
31
28
const child = children [ i ] ;
32
29
let id = ( parentId ) ? parentId : null ;
33
30
if ( child . typeId < 1000 ) {
34
- console . log ( { child} )
35
31
masterArr . push ( {
36
32
type : "HTML Element" ,
37
33
typeId : child . typeId ,
38
34
childId : id
39
35
} )
40
36
if ( child . children . length ) {
41
- console . log ( 'do a recursive call' ) ;
42
- console . log ( 'child.childrean array in recursion' , child . children )
43
- console . log ( 'child.children.id' , child . childId )
44
37
deepChildCopy ( child . children , child . childId ) ;
45
38
}
46
39
}
47
40
}
48
41
}
49
42
deepChildCopy ( children , null ) ;
50
- console . log ( { masterArr} )
51
43
setCopiedChildrenArr ( masterArr ) ;
52
- console . log ( 'SADJBFSDJBFLJSHDBFJLDHS' , copiedChildrenArr )
53
44
}
54
45
55
46
const components = state . components
@@ -68,31 +59,6 @@ function Canvas(props): JSX.Element {
68
59
setNewComp ( false )
69
60
} , [ newComp ] )
70
61
71
- // useEffect(()=>{
72
- // const lastComp = state.components[state.components.length - 1];
73
- // if (copiedChildrenArr.length) {
74
- // console.log('setCopiedChildrenArr use effect running')
75
- // // copiedChildrenArr.forEach(com => console.log(com))
76
- // // console.log(copiedChildrenArr[0])
77
- // // console.log(copiedChildrenArr[1])
78
- // for (let i = 0; i < copiedChildrenArr.length; i++) {
79
- // dispatch({
80
- // type: 'ADD CHILD',
81
- // payload: {...copiedChildrenArr[i], copyId: lastComp.id}
82
- // });
83
- // }
84
- // // dispatch({
85
- // // type: 'ADD CHILD',
86
- // // payload: {...copiedChildrenArr[1], copyId: lastComp.id}
87
- // // });
88
- // // setCopiedChildrenArr(copiedChildrenArr.slice(1))
89
- // setCopiedChildrenArr([])
90
- // }
91
-
92
- // },[copiedChildrenArr])
93
-
94
-
95
-
96
62
// Caret start
97
63
Arrow . deleteLines ( ) ;
98
64
// find the current component to render on the canvas
@@ -154,7 +120,6 @@ function Canvas(props): JSX.Element {
154
120
if ( child . name === 'seperator' ) continue ;
155
121
// check if the item.instanceTypeId matches and child ID
156
122
if ( item . instanceTypeId === child . typeId ) {
157
- console . log ( 'parent found' , comp )
158
123
// check if the name of the parent matches the canvas focus name
159
124
// comp is the parent component
160
125
// currentComponent is the canvas.focus component
@@ -163,7 +128,6 @@ function Canvas(props): JSX.Element {
163
128
break ;
164
129
} else {
165
130
// if false
166
- console . log ( 'different parent' ) ;
167
131
setCopiedComp ( child ) ;
168
132
hasDiffParent = true ;
169
133
newChildName = child . name ;
@@ -183,25 +147,23 @@ function Canvas(props): JSX.Element {
183
147
}
184
148
} ) ;
185
149
} else {
150
+
151
+ // able to duplicate a component in dev only does not work for prod
186
152
// create a new component
187
- let name = prompt ( "Component already has a parent. \nDo you want to create a new component and import its elements?" , "Enter component name here" ) ;
188
- // console.log({newChildName}, 1)
189
- while ( components . some ( comp => comp . name === name ) ) {
190
- name = prompt ( `${ name } component already exists. \nPlease pick a new name.` ) ;
191
- }
192
- if ( name ) {
193
- dispatch ( {
194
- type : 'ADD COMPONENT' ,
195
- payload : { componentName : name , root : false }
196
- } ) ;
153
+
154
+ // let name = prompt("Component already has a parent. \nDo you want to create a new component and import its elements?", "Enter component name here");
155
+ // while (components.some(comp => comp.name === name)) {
156
+ // name = prompt(`${name} component already exists. \nPlease pick a new name.`);
157
+ // }
158
+ // if (name) {
159
+ // dispatch({
160
+ // type: 'ADD COMPONENT',
161
+ // payload: { componentName: name, root: false }
162
+ // });
197
163
198
- setNewComp ( true ) ;
199
- console . log ( { newComp} )
200
-
201
- // console.log({components})
202
- // console.log({newId})
203
- setNewComp ( ! newComp )
204
- }
164
+ // setNewComp(true);
165
+ // setNewComp(!newComp)
166
+ // }
205
167
206
168
}
207
169
0 commit comments