[REF] web_editor: move normalizeColor function to we-utils for reuse
Part of https://github.com/odoo/odoo/pull/53017 task-2210790
This commit is contained in:
committed by
qsm-odoo
parent
8bf5381d13
commit
995b20fd6a
@@ -187,6 +187,19 @@ function _getCSSVariableValue(key, htmlStyle) {
|
||||
// double-quotes when reading them through getPropertyValue...
|
||||
return value.replace(/"/g, "'");
|
||||
}
|
||||
/**
|
||||
* Normalize a color in case it is a variable name so it can be used outside of
|
||||
* css.
|
||||
*
|
||||
* @param {string} color the color to normalize into a css value
|
||||
* @returns {string} the normalized color
|
||||
*/
|
||||
function _normalizeColor(color) {
|
||||
if (ColorpickerWidget.isCSSColor(color)) {
|
||||
return color;
|
||||
}
|
||||
return _getCSSVariableValue(color);
|
||||
}
|
||||
|
||||
return {
|
||||
CSS_SHORTHANDS: CSS_SHORTHANDS,
|
||||
@@ -199,5 +212,6 @@ return {
|
||||
isColorCombinationName: _isColorCombinationName,
|
||||
computeColorClasses: _computeColorClasses,
|
||||
getCSSVariableValue: _getCSSVariableValue,
|
||||
normalizeColor: _normalizeColor,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ const time = require('web.time');
|
||||
var Widget = require('web.Widget');
|
||||
var ColorPaletteWidget = require('web_editor.ColorPalette').ColorPaletteWidget;
|
||||
const weUtils = require('web_editor.utils');
|
||||
const {normalizeColor} = weUtils;
|
||||
var weWidgets = require('wysiwyg.widgets');
|
||||
const {
|
||||
loadImage,
|
||||
@@ -2831,7 +2832,7 @@ const ImageHandlerOption = SnippetOptionWidget.extend({
|
||||
* @see this.selectClass for parameters
|
||||
*/
|
||||
setFilter(previewMode, widgetValue, params) {
|
||||
this._getImg().dataset.filter = this._normalizeColor(widgetValue);
|
||||
this._getImg().dataset.filter = normalizeColor(widgetValue);
|
||||
return this._applyOptions();
|
||||
},
|
||||
/**
|
||||
@@ -2967,23 +2968,6 @@ const ImageHandlerOption = SnippetOptionWidget.extend({
|
||||
* @returns {Int} the maximum width at which the image can be displayed
|
||||
*/
|
||||
_computeMaxDisplayWidth() {},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Util
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Normalize a color into a css value usable by the canvas rendering context.
|
||||
*
|
||||
* @private
|
||||
* @param {string} color the color to normalize into a css value
|
||||
*/
|
||||
_normalizeColor(color) {
|
||||
if (!ColorpickerWidget.isCSSColor(color)) {
|
||||
color = weUtils.getCSSVariableValue(color);
|
||||
}
|
||||
return color;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user