summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor/rte.summernote.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2019-11-19 15:23:44 +0000
committerqsm-odoo <qsm@odoo.com>2019-12-01 15:49:57 +0000
commitfdac73e99d6edce1544c25534f8903c637a5507e (patch)
tree6fc957b40227130fc325f0abc9b244020e7f8c43 /addons/web_editor/static/src/js/editor/rte.summernote.js
parent216cf93b4dab381286991dcf650e859931bf1a43 (diff)
[IMP] web_editor, *: add new user value colorpicker widget
* web, mass_mailing, website Introduced a new sub-widget for snippet options: we-colorpicker. This allows to retrieve a color value (either a normalized css color or a theme color name) to be used for a snippet option method. This commit replaces the old 'colorpicker' snippet option whose behavior is now simply achieved by defining an xml option using a we-colorpicker widget in combination with the 'selectStyle' standard method. This commit also adds the possibility to control the border-color of elements alongside their border-width. Again, just a we-colorpicker widget in combination with the 'selectStyle' standard method. Note: this commit reviewed what the colorpalette palette widget notifies. This is not a cssColor and a 'isClass' flag to say if it is a css class or not. The colorpalette always returns a color string which can be the name of a color like 'alpha'. This is up to the caller to check if the color string is a css color or not with isCSSColor. In the case it is not, the related code can read the actual color by reading the related css variable. Part of https://github.com/odoo/odoo/pull/40282 In preparation of task-2122935 and other tasks
Diffstat (limited to 'addons/web_editor/static/src/js/editor/rte.summernote.js')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js
index 233a38edb8c..befea94f328 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -4,6 +4,7 @@ odoo.define('web_editor.rte.summernote', function (require) {
var Class = require('web.Class');
const concurrency = require('web.concurrency');
var core = require('web.core');
+const ColorpickerDialog = require('web.ColorpickerDialog');
var ColorPaletteWidget = require('web_editor.ColorPalette').ColorPaletteWidget;
var mixins = require('web.mixins');
var fonts = require('wysiwyg.fonts');
@@ -50,13 +51,17 @@ renderer.createPalette = function ($container, options) {
const targetNode = r.sc;
const targetElement = targetNode.nodeType === Node.ELEMENT_NODE ? targetNode : targetNode.parentNode;
colorpicker = new ColorPaletteWidget(parent, {
- colorPrefix: eventName === "foreColor" ? 'text-' : 'bg-',
excluded: ['transparent_grayscale'],
$editable: rte.Class.prototype.editable(), // Our parent is the root widget, we can't retrieve the editable section from it...
selectedColor: $(targetElement).css(eventName === "foreColor" ? 'color' : 'backgroundColor'),
- targetClasses: [...targetElement.classList],
});
- colorpicker.on('color_picked', null, ev => applyColor(ev.data.target, eventName, ev.data.cssColor));
+ colorpicker.on('color_picked', null, ev => {
+ let color = ev.data.color;
+ if (!ColorpickerDialog.isCSSColor(color)) {
+ color = (eventName === "foreColor" ? 'text-' : 'bg-') + color;
+ }
+ applyColor(ev.data.target, eventName, color);
+ });
colorpicker.on('color_reset', null, ev => applyColor(ev.data.target, eventName, 'inherit'));
return colorpicker.replace(hookEl).then(() => {
if (oldColorpicker) {