[Question] How to handle old components (json) with new editor configuration?
Question
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!
Answers (2)
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 :)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1341
[Question] How to work with Custom Components
Hello, I have some questions and issues about and with the grapes editorProblem 1 In a component, which class is there extended? Is it real...
Issue #696
click binding question
Hello everyone, I'm new to all of this and I've been going through the documentation but I still dont understand how to bind click event. I...
Issue #3041
Question: How to render the website in frontend after designing it in the editor?
Hi all, I am wondering how to render the website with our own components designed by the editor into frontend? I cannot find any info about...
Issue #2894
[Question]: How Do I Hide / Disable Dropzone in AM Modal
Hello, I've been reviewing the documentation and this link, trying to find the right configuration setting to disable the dropzone in the A...
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.