Issue #1904πŸ’¬ AnsweredOpened March 19, 2019by sakshigarg91 reactions

Get change in property float

Quick answerby prashant2018❀ 1

You can use the "model" passed as a parameter to get the current property. After inspecting the model object I figured out we can get the style using model.attributes.style You should get the desired output by modifying your code snippet in the following way: editor.on('component:styleUpdate:float', (model) => { conso...

Read full answer below ↓

Question

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 an event but my code doesn't seem to give the desired result.

  editor.on('component:styleUpdate:float', (model) => 
  { console.log('style update', editor.StyleManager.getProperty('General','float')); });

It gives style update null as the output. Desirable output would be float:right, float:left or float:none

Answers (3)

prashant2018β€’ March 23, 2019

You can use the "model" passed as a parameter to get the current property. After inspecting the model object I figured out we can get the style using model.attributes.style You should get the desired output by modifying your code snippet in the following way: editor.on('component:styleUpdate:float'...

prashant2018β€’ March 24, 2019

@sakshigarg9 The approach I mentioned above is not working for some of the components, to be more precise what I observed is that the style property is giving empty string on the components which have a class defined. Your approach of using editor is correct and also works for all the components, o...

lock[bot]β€’ March 27, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

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.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.