How to apply traits to components used for GrapesJs initialization
currently there is a problem on storing custom types unless they are defined inside a plugin. Not a problem 😬, you just need to load custom types before the content and using plugins is the only wayI can't add all possible such elements as plugins https://jsfiddle.net/artur_arseniev/9tg0a36c/
Read full answer below ↓Question
I am using This works but only for blocks which are added/drag-dropped to the editor manually after it is initialized. If we supply components when we call grapesjs.init({..., components: [..]}), the components defined in components do not have the traits. How can we apply traits to initially loaded components too, not only to these added later manually ?
Answers (3)
currently there is a problem on storing custom types unless they are defined inside a plugin. Not a problem 😬, you just need to load custom types before the content and using plugins is the only wayI can't add all possible such elements as plugins https://jsfiddle.net/artur_arseniev/9tg0a36c/
This is how it can be reproduced:Go to https://jsfiddle.net/nwsy6mv1/3/Open blocks and place "1 Column" blockClick inside the column and go to "Settings"You will see the drop-down trait with label "Trait label"At this time the grapesjs components are saved in the local storage because it is configu...
Hi @varadero please define your custom type as a plugin. cheers!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3225
How to Update Style from checkbox Trait?
Hi @artf I am trying to update the style using the checkbox trait but it's not calling the function. Here is the code I really appreciate a...
Issue #3228
Component Value is not changing
Hi @artf I've added a new component here is the code on selecting the h1 and h2 tag it's changing the value in the HTML section as you can...
Issue #2614
[QUESTION] Recursive view update of custom component
Hi, I have defined a custom type like: I want to keep the customTag in my model and show the content (HTML) in the view. However, in the co...
Issue #2103
[QUESTION] Custom Component dragging issue
This is how I've created a custom component: This is my custom block: The thing is that I have wrapped the image tag inside <a> tag when it...
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.