grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Removing class from css when chained

Open Dari4sho opened this issue 8 years ago • 2 comments

Hey guys, following example of my problem: I select an element on the canvas - next to the existing class, I add a custom class in the style manager (both selected so it's chained: .class.class) - edit some styles - remove the custom class = the chained css-code stays for export (.class.class)

Editing classes independently (.class) and deleting them also deletes the class in the css-code. Is this intentioned behaviour? If not, can we do something about it?

I love this project! Thanks for all the work.

Dari4sho avatar Jul 08 '17 22:07 Dari4sho

Thanks @Dari4sho I'd say the exporter is not optimizing properly

artf avatar Jul 10 '17 21:07 artf

Hello @artf , Is there any update on core clear canvas command. the unused CSS are not removed. I am using latest version of grape min /*! grapesjs - 0.19.4 */ Please let me know any hook or something methods so that I can clear forcefully

Palash-Mandal avatar Jul 13 '22 10:07 Palash-Mandal

Closing this as it's quite old and inactive.

Anyway removing not used CSS rules it's not always a safe option (eg. one class might be toggled dynamically via JS in the final template) but in case you're aware of that you can get the CSS with only matched rules

editor.getCss({ onlyMatched: true })

artf avatar Jul 26 '23 11:07 artf