[QUESTION] How to update styles in Style Manager
See original GitHub issueHello. I created custom component where I set backgraound-image via custom asset manager Custom block code:
domc.addType('image-block', {
extend: 'default',
model: {
defaults() {
return {
name: 'Background image',
type: 'image-block',
tagName: 'div',
void: false,
droppable: true,
};
},
},
view: {
init() {
this.listenTo(this.model, 'change:src', this.updateImage);
},
events: {
dblclick: 'onActive',
},
onActive() {
editor.runCommand('open-assets');
},
updateImage(model, url) {
if (url) {
const style = model.getStyle();
model.setStyle({
'background-image': style['background-color'] || `url("${url}")`,
'background-size': style['background-size'] || 'cover',
'background-position':
style['background-position'] || 'center center',
'background-repeat': style['background-repeat'] || 'no-repeat',
'min-height': style['min-height'] || '200px',
});
}
},
},
isComponent(el) {
if (el.dataset && el.dataset.type === 'image-block') {
return { type: 'image-block' };
}
},
});
Command which I run to set new image:
cmd.add('set-image-url', {
run(editor, sender, { url }) {
const target = editor.getSelected();
target.set('src', url);
},
});
It is working fine, image sets. But background property in Styles Manager doesn’t update after image set.
How can I update background property in style manager?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
5 ways to modify and customize styles in Microsoft Word
Click the Home tab, right-click the style you want to modify in the Style Gallery, and then choose Modify. In the Modify Style...
Read more >Style manager in MS Word 2016 for mac? - Microsoft Community
Open the Word application> Click on the Format in the menu bar> Select the Styles> Choose the Style you want to modify> Click...
Read more >How to modify styles in Microsoft Word - ShaunaKelly.com
Word 2002 and Word 2003: Format > Styles and Formatting. Right-click your style. Choose Modify. Other versions of Word: Format > Style. Click...
Read more >Organizing Styles In WORD 🔥🔥 - YouTube
Organizing Styles In WORD** Enroll in complete course**https://www.udemy.com/user/syedraza2/📒 Show Description and Resources 📒1.
Read more >Word 2016 - How to Modify a Style in Microsoft MS - YouTube
This Microsoft Word 2016 tutorial shows you how to create a styles. Creating a style in MS Office 365 can be done using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Noticed that in general when you update styles for a
component
through code they do not reflect in theStyles Manager
until you deselect and reselect thecomponent
and I can’t find anything in the docs about refreshing theStyles Manager
.As a workaround you can use:
Check here on why you would want to use a custom css parser if you’re gonna be setting some styles outside of the
Styles Manager
Thanks for suggestion with this workaround. It’s not ideal but it’s working. If someone knows better solution it would be nice.
And thanks for postcss-parser advice. I’ll try it.