@@ -141,10 +141,10 @@ export default class Preview extends PreviewCollection {
141
141
events . on ( "column-group:renderAfter" , ( args : ContentTypeAfterRenderEventParamsInterface ) => {
142
142
if ( args . contentType . id === this . contentType . id ) {
143
143
if ( ! this . hasColumnLine ( args . contentType ) ) {
144
- args . element . classList . add ( ' no-column-line' ) ;
144
+ args . element . classList . add ( " no-column-line" ) ;
145
145
} else {
146
- args . element . classList . remove ( ' no-column-line' ) ;
147
- args . element . classList . add ( ' with-column-line' ) ;
146
+ args . element . classList . remove ( " no-column-line" ) ;
147
+ args . element . classList . add ( " with-column-line" ) ;
148
148
}
149
149
}
150
150
} ) ;
@@ -157,63 +157,6 @@ export default class Preview extends PreviewCollection {
157
157
) ;
158
158
}
159
159
160
- /**
161
- * @param {ContentTypeInterface | ContentTypeCollectionInterface } contentType
162
- * @private
163
- */
164
- private hasColumnLine ( contentType : ContentTypeInterface | ContentTypeCollectionInterface ) : boolean {
165
- const children = this . contentType . getChildren ( ) ( ) ;
166
- let hasColumnLine = false ;
167
- if ( children . length === 0 ) {
168
- //new column group, so it has a column line
169
- hasColumnLine = true ;
170
- }
171
- children . forEach ( ( child ) => {
172
- if ( child . config . name === "column-line" ) {
173
- hasColumnLine = true ;
174
- }
175
- } ) ;
176
- return hasColumnLine ;
177
- }
178
-
179
-
180
- /**
181
- * If the column group does not have a column line, move contents to a new column group with a column line
182
- */
183
- private moveContentsToNewColumnGroup ( ) : void {
184
- if ( this . hasColumnLine ( this . contentType ) ) {
185
- // This column-group already has a column line. Don't need to add one.
186
- return ;
187
- }
188
- const indexToInsertNewColumnGroupAt = this . getCurrentIndexInParent ( )
189
- createContentType (
190
- Config . getContentTypeConfig ( "column-group" ) ,
191
- this . contentType . parentContentType ,
192
- this . contentType . stageId ,
193
- ) . then ( ( columnGroup : ContentTypeCollectionInterface ) => {
194
- this . contentType . parentContentType . addChild ( columnGroup , indexToInsertNewColumnGroupAt ) ;
195
- events . trigger ( columnGroup . config . name + ":dropAfter" , { id : columnGroup . id , columnGroup,
196
- columnGroupWithoutColumnLine : this . contentType } ) ;
197
- this . fireMountEvent ( this . contentType , columnGroup ) ;
198
- } ) ;
199
- }
200
-
201
- /**
202
- * @private return index of current content type in parent
203
- */
204
- private getCurrentIndexInParent ( ) : number {
205
- let parentContentType = this . contentType . parentContentType ;
206
- let currentIndex = 0 ;
207
- for ( let sibling of this . contentType . parentContentType . getChildren ( ) ( ) ) {
208
- if ( sibling . id != this . contentType . id ) {
209
- currentIndex ++ ;
210
- continue ;
211
- }
212
- break ;
213
- }
214
- return currentIndex ;
215
- }
216
-
217
160
/**
218
161
* Handle user editing an instance
219
162
*/
@@ -294,7 +237,7 @@ export default class Preview extends PreviewCollection {
294
237
this . contentType . addChild ( columns [ 0 ] , 0 ) ;
295
238
this . contentType . addChild ( columns [ 1 ] , 1 ) ;
296
239
this . fireMountEvent ( this . contentType , columns [ 0 ] , columns [ 1 ] ) ;
297
- } ,
240
+ } ,
298
241
) ;
299
242
}
300
243
@@ -305,7 +248,7 @@ export default class Preview extends PreviewCollection {
305
248
this . contentType . stageId ,
306
249
) . then ( ( columnLine : ContentTypeCollectionInterface ) => {
307
250
this . contentType . addChild ( columnLine , 0 ) ;
308
- if ( args . columnGroupWithoutColumnLine == undefined ) {
251
+ if ( args . columnGroupWithoutColumnLine === undefined ) {
309
252
events . trigger ( columnLine . config . name + ":dropAfter" , { id : columnLine . id , columnLine} ) ;
310
253
} else {
311
254
// Move children of this column group without column line as descendant of new
@@ -674,6 +617,62 @@ export default class Preview extends PreviewCollection {
674
617
}
675
618
}
676
619
620
+ /**
621
+ * @param {ContentTypeInterface | ContentTypeCollectionInterface } contentType
622
+ * @private
623
+ */
624
+ private hasColumnLine ( contentType : ContentTypeInterface | ContentTypeCollectionInterface ) : boolean {
625
+ const children = this . contentType . getChildren ( ) ( ) ;
626
+ let hasColumnLine = false ;
627
+ if ( children . length === 0 ) {
628
+ // new column group, so it has a column line
629
+ hasColumnLine = true ;
630
+ }
631
+ children . forEach ( ( child ) => {
632
+ if ( child . config . name === "column-line" ) {
633
+ hasColumnLine = true ;
634
+ }
635
+ } ) ;
636
+ return hasColumnLine ;
637
+ }
638
+
639
+ /**
640
+ * If the column group does not have a column line, move contents to a new column group with a column line
641
+ */
642
+ private moveContentsToNewColumnGroup ( ) : void {
643
+ if ( this . hasColumnLine ( this . contentType ) ) {
644
+ // This column-group already has a column line. Don't need to add one.
645
+ return ;
646
+ }
647
+ const indexToInsertNewColumnGroupAt = this . getCurrentIndexInParent ( ) ;
648
+ createContentType (
649
+ Config . getContentTypeConfig ( "column-group" ) ,
650
+ this . contentType . parentContentType ,
651
+ this . contentType . stageId ,
652
+ ) . then ( ( columnGroup : ContentTypeCollectionInterface ) => {
653
+ this . contentType . parentContentType . addChild ( columnGroup , indexToInsertNewColumnGroupAt ) ;
654
+ events . trigger ( columnGroup . config . name + ":dropAfter" , { id : columnGroup . id , columnGroup,
655
+ columnGroupWithoutColumnLine : this . contentType } ) ;
656
+ this . fireMountEvent ( this . contentType , columnGroup ) ;
657
+ } ) ;
658
+ }
659
+
660
+ /**
661
+ * @private return index of current content type in parent
662
+ */
663
+ private getCurrentIndexInParent ( ) : number {
664
+ const parentContentType = this . contentType . parentContentType ;
665
+ let currentIndex = 0 ;
666
+ for ( const sibling of this . contentType . parentContentType . getChildren ( ) ( ) ) {
667
+ if ( sibling . id !== this . contentType . id ) {
668
+ currentIndex ++ ;
669
+ continue ;
670
+ }
671
+ break ;
672
+ }
673
+ return currentIndex ;
674
+ }
675
+
677
676
/**
678
677
* Fire the mount event for content types
679
678
*
0 commit comments