Define selected class.
Question
Hello @artf ,
Is there a way to automatically select the class that is created on elements with custom styles.

I'm currently trying to dynamically update classes with a grid system and it's working fine but the auto selection of all classes is creating issues. I've been looking at the code for hours trying to figure this out.
Any directions to the right file where the magic occurs is appreciated.
I'm currently looking at: \src\selector_manager\view\ClassTagView.js
Thanks!
Answers (3)
Update:
Ok I figured out that I can make them all unselect by default by changing src/selector_manager/model/Selector.js
active: false,

and this pretty much solves all my problems as when I change the background color of the block, it will update only c875!.
Closing this as it's now solved.
You can access selectors from the model
model.get('classes').each(selector => selector.set('active', 0))
or for example, disable them all from its module
editor.SelectorManager.getAll().each(selector => selector.set('active', 0))
fyi changing this to false will make your build to fail due to this in the test script:
I just commented this out here: test/specs/selector_manager/model/SelectorModels.js
// it('Has active property', () => {
// expect(obj.has('active')).toEqual(false);
// });
and this
test/specs/css_composer/e2e/CssComposer.js line 129
ruleOut = JSON.parse(JSON.stringify(ruleOut));
var ruleResult = {
mediaText: '',
selectors: [{
active: false, //changed this to false
Related Questions and Answers
Continue research with similar issue discussions.
Issue #394
Text: New div is created every time I hit enter instead of creating a </br>
Hi @artf Is there a reason why when inserting text a new div is created for every break instead of a standard </br> Is it possible to disab...
Issue #987
[BUG/Question] Dropdown indicator not displayed for a custom trait
Hello, the dropdown (select) element arrow indicator icon is not rendered when adding a custom trait to a component: I'm using following co...
Issue #659
Custom button Save in Extensions GrapesJS Aviary
Hi, Does way to custom Save button in Extensions GrapesJS Aviary ? https://github.com/artf/grapesjs/wiki
Issue #1843
Class on different states are not being applied to those states.
I'm trying to apply a class on hover of a component and the class is being applied but not on hover, it applies with normal state. Please l...
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.