Helpers/color

colorToHex

colorToHex(color): string | false

Converts rgba text representation of color in hex

Parameters

Name Type Description
color string string like rgba(red, green, blue, alpha) or rgb(red, green, blue)

Returns

string | false

hex color view, NaN - for transparent color

Example

var p = document.createElement('p');
p.style.color = '#ffffff';
console.log(p.getAttribute('style')); // color: rgb(255, 255, 255);
console.log(colorTohex(p.style.color)); // #ffffff

Defined in

jodit/src/core/helpers/color/color-to-hex.ts:24