Issue #2496Opened January 7, 2020by prabha-9121 reactions

Convert rgb/rgba color value to hex code

Question

Hi Folks,

Steps I followed:

  1. Drag the text block.
  2. set the font color. (its in rgb/rgba format)

What I Expected: Style needs to be updated as like hexa code. (like, #f0f0f0)

I tried to get the particular color update using, editor.on('component:styleUpdate:color', function (model) { . But I could not get the solution. Guide me how to achieve the expected solution.

Thanks in advance, Prabha.

Answers (3)

artfJanuary 12, 20201 reactions

As the StyleManager can target Components and CssRules you have to find out first what was selected

editor.on('component:styleUpdate:color', component => {
	const sm = editor.StyleManager;
    const model = sm.getModelToStyle(component);
	// the model can be a Component or CssRule
    console.log(model.getStyle()['color'])
})
pouyamiralayiJanuary 7, 20200 reactions

@prabha-912

    editor.on('component:styleUpdate:color', function (model) {
            console.log(model.getStyle()['color'])
     })

cheers!

prabha-912January 8, 20200 reactions

It returns undefined for me while updating the color @pouyamiralayi

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.