Code manager set code
Question
Hi @artf. Is there something similar to this
editor.CodeManager.setCode(component, 'css', {cssc: editor.CssComposer}
to update the css rule of the selected block returned from
editor.CodeManager.getCode(component, 'css', {cssc: editor.CssComposer});
For example:
This is the returned css rule collection from using
editor.CodeManager.getCode(component, 'css', {cssc: editor.CssComposer});
Returned:
.c1234 {
color: 'white';
}
.classx .c1234{
background: black;
}
What I need is to save and update it to like
.c1234 {
color: 'yellow';
}
.classx .c1234{
background: #222222;
}
I tried the cc.setClassRule('c1234', { background: #222222 }); but this csscomposer function is limited for 1 class only I need a dynamic function that can update the content returned by
editor.CodeManager.getCode(component, 'css', {cssc: editor.CssComposer});
Thank you !
Answers (2)
Hi @froderf, for now, the only way to get that rule is to use CssComposer.get method. In your case, .classx .c1234 is stored inside selectorsAdd as not being a single level class selector (eg. .class1.class2)
editor.CssComposer.get([], null, null, { selectorsAdd: '.classx .c1234' })
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 #581
Reading component related events
The Editor API wiki lists a set of component-related events that can be listened to (e.g. component:add, component:update). There is howeve...
Issue #1638
how to stop css repeatition
hi @artf here is my code of Export-template i make it editable Also, i add a media-query to display in view code with this editor.setCompon...
Issue #454
Make block manager default open panel?
I tried this code: It works but doing this will hide the device selector in the top left for some reason.
Issue #513
Model and returned html issue
I have below code to create custom component and wants to retrieve updated html via editor.html() but return wrong html, I am sure I am mis...
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.