GetComponents method doesn't return tree of components
Need to stringify and parse back returned components(works only if components were set programmatically initially) JSON.parse(JSON.stringify(editor.getComponents())) https://jsfiddle.net/w1497xp8/ Upd.: same with editor.getStyles() method
Read full answer below ↓Question
I'm trying to implement multiple pages as per discussion in that issue - https://github.com/artf/grapesjs/issues/1331 But when I trying to get components tree by using 'editor.getComponents()' it returns data with wrong format(model collection I guess). When I try to set components using the editor.SetComponents method nothing happens (in my project, but on JSFiddle I get an error in the console). I want to get the components of the editor in the same format in which the StorageManager sends them in the gjs-components parameter to the server when saving. Could somebody tell me what am I doing...
Answers (2)
Need to stringify and parse back returned components(works only if components were set programmatically initially)
JSON.parse(JSON.stringify(editor.getComponents()))
https://jsfiddle.net/w1497xp8/
Upd.: same with editor.getStyles() method
Yes, this is the correct way to obtain the same string of the StorageManager
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3404
Style Manager Issue.
Hi @artf I want to hide and show style properties for specific component. After referencing this issue https://github.com/artf/grapesjs/iss...
Issue #3419
FEAT: Event to hook into after editor.render has been executed
What are you trying to add to GrapesJS? As described in BUG: Panels "visible" attribute doesn't prevent panel rendering I tried to prevent...
Issue #868
[BUG]: "component:add" event triggers when components are moved
Taken from https://github.com/artf/grapesjs/wiki/API-Editorcomponent:add - Triggered when a new component is added to the editor, the model...
Issue #2498
[Bug] Error when trying to move cell from row.
Bug #2478 after release still exists. Repeat steps and you will get error Uncaught TypeError: Cannot read property 'indexEl' of undefined....
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.