Custom defined css classes do not work if I use editor.setStyle(css_text);
Question
I need to set styles using the data I receive from the database asynchronously. But then the css I composed manually gets removed.
const cssComposer = editor.CssComposer;
var sm = editor.SelectorManager;
var sel1 = sm.add('simple-div');
var rule = cssComposer.add([sel1]);
// Update the style
rule.set('style', {
width: '100%',
height:'auto',
padding:'15px',
float: 'left',
});
the above class .simple-div doesn't exist If I use setStyle()
Answers (1)
Use the setRule API
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3832
BUG: The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link Not there De...
Issue #1215
[Question]Adding Google Font doesn't work
Bonjour, I try to add Google Font : When i click on Typography, script stop in Grapes.jp show: function show() { this.$el.addClass(this.pfx...
Issue #1310
Grape JS works for newsletter
We are testing to use the editor and we want to know if the grape js editor works for content newsletters, we were doing tests but CSS styl...
Issue #1838
How to get the latest css property of a component?
Hi, awesome job with grapesjs! I already read the docs (especially CssComposer) and also relevant issues but still, I am stuck. A custom pl...
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.