New toolbar button works only for new added components and not for existing ones
Probably the editor doesn't change a component during runtime when it's model is changed, so the component on the canvas was created before the model was modified therefore it wont show the changes to the toolbar.
Read full answer below ↓Question
Hi everybody, can somebody explain me please why when I create a new custom toolbar button this button shows only when I add a new component and not an existing one even this components are the same. I was thinking that might be something about the editor initiation that I'm not including. @artf What am I missing to make it work on init? Here is an example of how I'm adding the button. It works perfectly but like I said only for new components added and not for existing ones (example, if I init the editor with some code inside the gjs container the components won't have this new option in the...
Answers (3)
Probably the editor doesn't change a component during runtime when it's model is changed, so the component on the canvas was created before the model was modified therefore it wont show the changes to the toolbar.
I've gotten around this by loading the canvas after loading all components and component modifications, but I guess depending on storage setup running editor.load() might fix that.
Thanks for your response @Ju99ernaut, any ideas of how can I change them during runtime? I think It can work if I make those changes in the core but I was thinking in make some plugins with this type of functions and this way we can't make it work in external plugins. So it has to be after init (I...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #6152
CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #3135
[Help Wanted] How to easily override existing component ?
For example, I want to add a double click event handler on the default video component to open the assets manager. My basic idea was to get...
Issue #3417
FEAT: How Map component works? How we can create weather components and render it?
Could you please expain how map components are rendered after draged? How we can create a new component for weather and how it will render...
Issue #3309
TextNodes interfere when changing content on element
Version: 0.16.44 Hi @artf I have a custom block with a custom button component, which its content is similar to this one. <a data-gjs-type=...
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.