mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[fieldFormats/colors] escape style values
This commit is contained in:
parent
a69ab2df1b
commit
3a5095bd6e
1 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,7 @@ import colorTemplate from 'ui/stringify/editors/color.html';
|
|||
export default function ColorFormatProvider(Private) {
|
||||
|
||||
const FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||
const convertTemplate = _.template('<span style="<%- style %>"><%- val %></span>');
|
||||
const DEFAULT_COLOR = {
|
||||
range: `${Number.NEGATIVE_INFINITY}:${Number.POSITIVE_INFINITY}`,
|
||||
text: '#000000',
|
||||
|
@ -50,9 +51,10 @@ export default function ColorFormatProvider(Private) {
|
|||
|
||||
if (!color) return _.asPrettyString(val);
|
||||
|
||||
const styleColor = color.text ? `color: ${color.text};` : '';
|
||||
const styleBackgroundColor = color.background ? `background-color: ${color.background};` : '';
|
||||
return `<span style="${styleColor}${styleBackgroundColor}">${_.escape(val)}</span>`;
|
||||
let style = '';
|
||||
if (color.text) style += `color: ${color.text};`;
|
||||
if (color.background) style += `background-color: ${color.background};`;
|
||||
return convertTemplate({ val, style });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue