Get all the style value by ID
Question
@artf I want to get all the style associated with model selected by ID after save the template and reload and re init the editor.
But I can not get all the style value of the selected model.
But in css there are 2 css definition for that ID

I want to know How can I get all the style value applied for a ID either it is 2 time or multiple time. Please also tell me how to prevent css composer to add new style tag for same ID after page reload or editor re-init so that it will not create new style and it only update the previous style.
Answers (3)
editor.getCss(); -> will give you all the CSS, is up to you to find what you need.
comp = editor.getSelected(); const html = comp.toHTML(); -> selected comp html const css = editor.CodeManager.getCode(comp, 'css', {cssc: editor.CssComposer}); -> selected comp CSS
@YashPrince check the API https://grapesjs.com/docs/api/css_composer.html
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.
Issue #1706
[Question]: How to get href from rte?
I have this rte toolbar where you can type and click 'save' and it's going to create a link for the selected text. but the problem is that...
Issue #1294
How to add category for default block manager?
@artf I want put all default blocks to category named "Basic". But I can't find any documents about it. I use editor.BlockManager.getAll()....
Issue #1490
How to send value from the layout section
@artf I need your help to solve my issue with grapesjs i have this code in the template: I want to pass that value in this way but when I e...
Issue #1534
Update property Input value from model style.
@artf I want to update height of the element and want to give a custom height using following code It's working fine and it's update the se...
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.