summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-11-06 16:40:07 +0100
committerChristophe Simonis <chs@odoo.com>2018-11-06 16:40:07 +0100
commitb106b7ce0bfac5d4f955dc98be9a35d79e0947ff (patch)
tree48bb187b80b2b10f7a1d76bf5116bf3ea16669a2 /addons/web_editor/static
parent478691b95de9eb0d03c145e547a773de40ca9a4d (diff)
parentdd70c684268b538f02ea4fa0425f9b70136b3300 (diff)
[MERGE] forward port branch 12.0 up to dd70c684268
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/src/js/content/body_manager.js5
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js12
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js35
-rw-r--r--addons/web_editor/static/src/js/widgets/ace.js3
-rw-r--r--addons/web_editor/static/src/xml/editor.xml2
5 files changed, 48 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/content/body_manager.js b/addons/web_editor/static/src/js/content/body_manager.js
index 85ace262fc5..1045e94a65a 100644
--- a/addons/web_editor/static/src/js/content/body_manager.js
+++ b/addons/web_editor/static/src/js/content/body_manager.js
@@ -44,7 +44,12 @@ var BodyManager = rootWidget.RootWidget.extend(ServiceProviderMixin, {
var route = event.data.args[0];
if (_.str.startsWith(route, '/web/dataset/call_kw/')) {
var params = event.data.args[1];
+ var options = event.data.args[2];
params.kwargs.context = _.extend({}, weContext.get(), params.kwargs.context || {});
+ if (options) {
+ params.kwargs.context = _.omit(params.kwargs.context, options.noContextKeys);
+ event.data.args[2] = _.omit(options, 'noContextKeys');
+ }
params.kwargs.context = JSON.parse(JSON.stringify(params.kwargs.context));
}
}
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index dfa77214c3a..5725bc4eb0f 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -576,7 +576,9 @@ var RTEWidget = Widget.extend({
this._getEscapedElement($el).prop('outerHTML'),
$el.data('oe-xpath') || null,
],
- context: withLang ? context : _.extend({}, context, {lang: undefined}),
+ context: context,
+ }, withLang ? undefined : {
+ noContextKeys: 'lang',
});
},
@@ -609,6 +611,14 @@ var RTEWidget = Widget.extend({
return;
}
+ // Removes strange _moz_abspos attribute when it appears. Cannot
+ // find another solution which works in all cases. A grabber still
+ // appears at the same time which I did not manage to remove.
+ // TODO find a complete and better solution
+ _.defer(function () {
+ $editable.find('[_moz_abspos]').removeAttr('_moz_abspos');
+ });
+
if ($target.is('a')) {
/**
* Remove content editable everywhere and add it on the link only so that characters can be added
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 5df08ee801d..97d3777b95f 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -280,15 +280,36 @@ var SnippetOption = Widget.extend({
*/
_setActive: function () {
var self = this;
- this.$el.find('[data-toggle-class], [data-select-class]')
- .addBack('[data-toggle-class], [data-select-class]')
+ this.$el.find('[data-toggle-class]')
+ .addBack('[data-toggle-class]')
.removeClass('active')
.filter(function () {
- var $elem = $(this);
- var className = $elem.data('toggleClass') || $elem.data('selectClass');
- return self.$target.hasClass(className);
+ var className = $(this).data('toggleClass');
+ return !className || self.$target.hasClass(className);
})
.addClass('active');
+
+ _processSelectClassElements(this.$el);
+ _.each(this.$el.find('.dropdown-menu'), function (group) {
+ _processSelectClassElements($(group).children());
+ });
+
+ function _processSelectClassElements($elements) {
+ var maxNbClasses = -1;
+ $elements.filter('[data-select-class]')
+ .removeClass('active')
+ .filter(function () {
+ var className = $(this).data('selectClass');
+ var nbClasses = className ? className.split(' ').length : 0;
+ if (nbClasses >= maxNbClasses && (!className || self.$target.hasClass(className))) {
+ maxNbClasses = nbClasses;
+ return true;
+ }
+ return false;
+ })
+ .last()
+ .addClass('active');
+ }
},
//--------------------------------------------------------------------------
@@ -749,7 +770,7 @@ registry.colorpicker = SnippetOption.extend({
*/
_onColorResetButtonClick: function () {
this.$target.removeClass(this.classes).css('background-color', '');
- self.$target.trigger('content_changed');
+ this.$target.trigger('content_changed');
this.$el.find('.colorpicker button.selected').removeClass('selected');
},
});
@@ -852,7 +873,9 @@ registry.background = SnippetOption.extend({
*/
setTarget: function () {
this._super.apply(this, arguments);
+ // TODO should be automatic for all options as equal to the start method
this.bindBackgroundEvents();
+ this.__customImageSrc = this._getSrcFromCssValue();
},
//--------------------------------------------------------------------------
diff --git a/addons/web_editor/static/src/js/widgets/ace.js b/addons/web_editor/static/src/js/widgets/ace.js
index bd5b4a9c47a..f3c47f30050 100644
--- a/addons/web_editor/static/src/js/widgets/ace.js
+++ b/addons/web_editor/static/src/js/widgets/ace.js
@@ -594,7 +594,8 @@ var ViewEditor = Widget.extend({
model: 'ir.ui.view',
method: 'write',
args: [[session.id], {arch: session.text}],
- context: _.extend({}, weContext.get(), {lang: undefined}),
+ }, {
+ noContextKeys: 'lang',
}).then(function () {
self._toggleDirtyInfo(session.id, 'xml', false);
def.resolve();
diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml
index ac5cbe6d07b..85cf336130d 100644
--- a/addons/web_editor/static/src/xml/editor.xml
+++ b/addons/web_editor/static/src/xml/editor.xml
@@ -90,7 +90,7 @@
<input type="hidden" name="filters" t-att-value="widget.firstFilters.join('_')"/>
<input t-if="widget.options.res_id" type="hidden" name="res_id" t-att-value="widget.options.res_id"/>
<input t-if="widget.options.res_model" type="hidden" name="res_model" t-att-value="widget.options.res_model"/>
- <div class="card">
+ <div class="o_media_image_card card w-100">
<div class="card-body p-0">
<div class="form-inline">
<input type="file" class="d-none" name="upload" t-att-accept="widget.accept" multiple="multiple"/>