summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-10-10 13:49:55 +0000
committerqsm-odoo <qsm@odoo.com>2018-10-10 15:09:24 +0000
commit1f9bf60260162ae20ff59678db782ddb503cd2a3 (patch)
tree2cf2fa2db118d86a9bab9eab6adbb0747c05fea2 /addons/web_editor/static/src
parent1dbb555aab8910d1739783c39fd502c4a2e145d0 (diff)
[FIX] web_editor, website: review grays
What was designed as a new feature appeared as a regression: users were not able to choose a bootstrap gray as a background color anymore but instead got the possibiility to choose a hardcoded gray. This commit restores the use of the custom gray palette that themes can customize and which automatically uses the correct text color when used as a background. This also allows to remove ugly inline style from snippet definitions and allows to solve bugs like the described below one: --------------------------------------- Also add bg-* classes on snippet cards: --------------------------------------- Snippet cards are often put (or may be put by the user) in an element which have a bg-* class on it. This means that the card will still have a white background (as chosen by BS4 by default) but the text color will be adapted to that ancestor bg-* classed element. This commit forces the card background color (as suggested by BS4) with bg-* classes. closes odoo/odoo#27637
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js19
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js25
-rw-r--r--addons/web_editor/static/src/scss/web_editor.ui.scss2
3 files changed, 30 insertions, 16 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index 8719779c079..dfa77214c3a 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -7,6 +7,7 @@ var core = require('web.core');
var Widget = require('web.Widget');
var weContext = require('web_editor.context');
var summernote = require('web_editor.summernote');
+var summernoteCustomColors = require('web_editor.rte.summernote_custom_colors');
var _t = core._t;
@@ -533,7 +534,8 @@ var RTEWidget = Widget.extend({
'lang': 'odoo',
'onChange': function (html, $editable) {
$editable.trigger('content_changed');
- }
+ },
+ 'colors': summernoteCustomColors,
};
},
/**
@@ -703,3 +705,18 @@ return {
history: history,
};
});
+
+odoo.define('web_editor.rte.summernote_custom_colors', function (require) {
+'use strict';
+
+return [
+ ['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'],
+ ['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'],
+ ['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'],
+ ['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'],
+ ['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'],
+ ['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'],
+ ['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'],
+ ['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']
+];
+});
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js
index aed0ca91a66..59ea0d8447b 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -4,7 +4,7 @@ odoo.define('web_editor.snippets.options', function (require) {
var core = require('web.core');
var Dialog = require('web.Dialog');
var Widget = require('web.Widget');
-var weContext = require('web_editor.context');
+var summernoteCustomColors = require('web_editor.rte.summernote_custom_colors');
var weWidgets = require('web_editor.widget');
var qweb = core.qweb;
@@ -631,7 +631,7 @@ registry.colorpicker = SnippetOption.extend({
var $clpicker = $(qweb.render('web_editor.colorpicker'));
_.each($clpicker.find('.o_colorpicker_section'), function (elem) {
- $(elem).prepend("<div class='text-muted mt8'>" + elem.dataset.display + "</div>")
+ $(elem).prepend("<div class='text-muted mt8'>" + elem.dataset.display + "</div>");
});
// Retrieve excluded palettes list
@@ -651,19 +651,16 @@ registry.colorpicker = SnippetOption.extend({
// Add common colors to palettes if not excluded
if (!('common' in excluded)) {
- var colors = [
- '#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF',
- '#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF',
- '#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE',
- '#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD',
- '#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5',
- '#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B',
- '#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842',
- '#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031'
- ];
var $commonColorSection = $clpicker.find('[data-name="common"]');
- _.each(colors, function (color) {
- $commonColorSection.append('<button class="o_custom_color" style="background-color: ' + color + '" />');
+ _.each(summernoteCustomColors, function (colorRow, i) {
+ var $div = $('<div/>', {class: 'clearfix'}).appendTo($commonColorSection);
+ if (i === 0) {
+ // Ignore the summernote gray palette and use ours
+ return;
+ }
+ _.each(colorRow, function (color) {
+ $div.append('<button class="o_custom_color" style="background-color: ' + color + '" />');
+ });
});
}
diff --git a/addons/web_editor/static/src/scss/web_editor.ui.scss b/addons/web_editor/static/src/scss/web_editor.ui.scss
index f9c30b62c6f..3d465ae18ee 100644
--- a/addons/web_editor/static/src/scss/web_editor.ui.scss
+++ b/addons/web_editor/static/src/scss/web_editor.ui.scss
@@ -904,7 +904,7 @@ table.colorpicker {
clear: both;
}
- > button {
+ button {
float: left;
height: 25px;
width: 25px;