@@ -198,6 +198,7 @@ const removePanel = (branch, panel, parent) => {
198198const getConfigFromContent = options => {
199199 const { width, height } = { width : 800 , height : 600 } ;
200200 const getGroupId = getGroupIdFunc ( )
201+ options = filterEmptyContent ( options )
201202 const panels = { } , rootType = options . content [ 0 ] . type
202203 const orientation = rootType === 'column' ? 'VERTICAL' : 'HORIZONTAL' ;
203204 const root = getTree ( options . content [ 0 ] , { width, height, orientation } , options , panels , getGroupId , options )
@@ -212,7 +213,17 @@ const getGroupIdFunc = () => {
212213 let currentId = 0 ;
213214 return ( ) => `${ currentId ++ } ` ;
214215}
215-
216+ const filterEmptyContent = function ( data ) {
217+ if ( ! data || typeof data !== 'object' ) return data ;
218+
219+ if ( Array . isArray ( data . content ) ) {
220+ data . content = data . content
221+ . map ( item => filterEmptyContent ( item ) )
222+ . filter ( item => ! ( Array . isArray ( item . content ) && item . content . length === 0 ) ) ;
223+ }
224+
225+ return data ;
226+ }
216227const getTree = ( contentItem , { width, height, orientation } , parent , panels , getGroupId , options ) => {
217228 const length = parent . content . length ;
218229 const boxSize = orientation === 'HORIZONTAL' ? width : height ;
@@ -233,10 +244,6 @@ const getTree = (contentItem, { width, height, orientation }, parent, panels, ge
233244 if ( contentItem . type === 'row' || contentItem . type === 'column' ) {
234245 obj . type = 'branch' ;
235246 obj . size = getSize ( boxSize , contentItem . width || contentItem . height ) || size
236- if ( contentItem . content . length == 0 || contentItem . content . every ( item => ! item . visible ) ) {
237- obj . size = 0
238- }
239-
240247 obj . data = contentItem . content . map ( item => getTree ( item , { width, height, orientation } , contentItem , panels , getGroupId , options ) )
241248 }
242249 else if ( contentItem . type === 'group' ) {
0 commit comments