grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Get all the style value by ID

Open yashvirsoftobiz opened this issue 8 years ago • 3 comments

@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. modelstyle But in css there are 2 css definition for that ID

idselector

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.

yashvirsoftobiz avatar Jul 24 '18 15:07 yashvirsoftobiz

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

jmrgz avatar Jul 25 '18 17:07 jmrgz

@YashPrince check the API https://grapesjs.com/docs/api/css_composer.html

artf avatar Jul 25 '18 21:07 artf

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.

lock[bot] avatar Sep 17 '19 09:09 lock[bot]