Hello @artf ,
I have a question about the grapes editor that I can not find in the documentation, so I hope you have an answer.
Basic setup:
The configuration of all components is set with the init
this.editor = grapesjs.init(defaultConfiguration);
The components from an earlier saved json are added with setComponents().
this.editor.setComponents(templateComponents)
The problem:
I have a custom component from which I want to update the config. In my case I want to update the stylable property to false.
So I changed the components config and now when I add a new component to the canvas it has the stylable false property. Thats good.
But the other components that are set with setComponents, still have the stylable: true property. Because the json was created earlier with a different configuration.
However, when I edit the component, only then all the components on the canvas are re-added and it overwrites the old components config (new json). (to stylable: false )
My question is:
How should we deal with new component configurations while we still have lots of persisted older JSON configs that have an old configuration? Can the editor pick up on the new component config without having to add a new component to the canvas manually?
Thanks in advance!
Can the editor pick up on the new component config without having to add a new component to the canvas manually?
Not really, if you store the component definition in one way, the editor will load that definition.
One only thing I can suggest is to use avoidDefaults (true by default from v0.15.5). This avoids storing all the default component properties, which can prevent you from those situations
Thanks for your response!
I'm going to use avoidDefaults: true and make it work :)
Most helpful comment
Not really, if you store the component definition in one way, the editor will load that definition.
One only thing I can suggest is to use
avoidDefaults(trueby default from v0.15.5). This avoids storing all the default component properties, which can prevent you from those situations