getComponents doesn't return components
Question
It's as if it's not parsing down the DOM
Reproduce. View console log https://codesandbox.io/s/lxl7x2mnq
You can see there are way more than 5 components / models in this sandbox.
But console log only shows 5

If I add one to the root of the dom tree, it will show 6. But if I add one to a child component, it will not see it.
Try dragging Link or any other component around in several places until you see the issue
Answers (3)
@Geczy probably I've to update the description, but getComponents just returns wrapper's components (with its children), if you want to return an array of all components you can do this:
const getAllComponents = (model, result = []) => {
result.push(model);
model.components().each(mod => getAllComponents(mod, result))
return result;
}
const all = getAllComponents(editor.DomComponents.getWrapper());
Works great, thanks
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #392
Define selected class.
Hello @artf , Is there a way to automatically select the class that is created on elements with custom styles. I'm currently trying to dyna...
Issue #1539
How and where to define form's action in grapesjs
Hello All, how can i get data from forms in grapesjs. i have droped a form on canvas as u can see that below . so there is an action proper...
Issue #394
Text: New div is created every time I hit enter instead of creating a </br>
Hi @artf Is there a reason why when inserting text a new div is created for every break instead of a standard </br> Is it possible to disab...
Issue #416
image upload with cross Origin issue
I have checked all the issues history,but didin't find a way out. i changed here to allow fetch to cross origin access. my asset manager is...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.