How to get the changed property from StyleManager
@AbdiasM i think this is kinda backbone related stuff and to my knowledge currently not possible. This is how it should be: Cheers!
Read full answer below ↓Question
Hi,
Is there a way to find out which property was changed in the StyleManager? For eg. If I select a Text component and change its background-color property from the StyleManager, is there any event where I can get the property that was changed. I've tried the 'component:styleUpdate' event, but it passes the component's model as argument, not the property.
Any help is appreciated.
Answers (3)
@AbdiasM i think this is kinda backbone related stuff and to my knowledge currently not possible. This is how it should be:
editor.on('component:styleUpdate', component => {
console.log(Object.keys(component.changedAttributes()))
})
Cheers!
Actually, you get the changed property as a second argument of the callback
editor.on('component:styleUpdate', (component, propChanged) => {
...
})
Hi @AbdiasM based on component:styleUpdate or component:styleUpdate:{propertyName} you can get the property like below: Cheers!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2193
[QUESTION] Reset trait on edit the content of a custom component
Hi, I have a custom component which content can be changed by switching trait select options, but also can be edited similar to the text co...
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Issue #2433
[Bug] Changing layerable in an an event at runtime doesn't immediately update
When I change the layerable option of a custom component in an event, it still shows up in the layers until you drag it once. Is there some...
Issue #1904
Get change in property float
I'm trying to listen to the change in the 'float' property whether it was shifted to the 'left' or 'right' or 'none' in Style Manager using...
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 →Related tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.