diff --git a/src/Components/Editor/Actions/AddContainer.ts b/src/Components/Editor/Actions/AddContainer.ts index 056a7c5..7bff7ab 100644 --- a/src/Components/Editor/Actions/AddContainer.ts +++ b/src/Components/Editor/Actions/AddContainer.ts @@ -264,36 +264,22 @@ function InitializeDefaultChild( return; } - let currentConfig = configuration.AvailableContainers + const currentConfig = configuration.AvailableContainers .find(option => option.Type === containerConfig.DefaultChildType); - let parent = newContainer; - let depth = 0; - const seen = new Set([containerConfig.Type]); + const parent = newContainer; - while (currentConfig !== undefined && - depth <= DEFAULTCHILDTYPE_MAX_DEPTH - ) { - if (!DEFAULTCHILDTYPE_ALLOW_CYCLIC && seen.has(currentConfig.Type)) { - return; - } - - seen.add(currentConfig.Type); - - const newChildContainer = AddNewContainerToParent( - currentConfig, - configuration, - parent, - 0, 0, - newCounters, - symbols - ); - - // iterate - depth++; - parent = newChildContainer; - currentConfig = configuration.AvailableContainers - .find(option => option.Type === (currentConfig as IAvailableContainer).DefaultChildType); + if (currentConfig === undefined) { + return; } + + AddNewContainerToParent( + currentConfig, + configuration, + parent, + 0, 0, + newCounters, + symbols + ); } function InitializeChildrenWithPattern(