From 7228b29cb2dfca8004ef65d41fa588cbed367121 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 4 Nov 2015 13:31:44 +0100 Subject: [PATCH] [FIX] web_editor: edition of monetary value Issue: if the currency is before the value and we try to add a number at the begin of the value, the number is not saved (because the browser insert the number before the span). Add a onEnableEditableArea in the rte to change the contenteditable value and the default behavior. --- addons/web_editor/static/src/js/rte.js | 5 +++++ addons/web_editor/static/src/js/widgets.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index d1f94ed46f5..a2833334085 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -546,9 +546,14 @@ var RTE = Widget.extend({ if (dom.isImg($target[0])) { $target.trigger('mousedown'); // for activate selection on picture } + + rte.onEnableEditableArea($editable); } }, + onEnableEditableArea: function ($editable) { + }, + onMouseup: function (event) { var $target = $(event.target); var $editable = $target.closest('.o_editable'); diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index 7508ce1c392..236b1dc4fc8 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -597,7 +597,13 @@ rte.Class.include({ init: function (EditorBar) { this._super.apply(this, arguments); computeFonts(); - } + }, + onEnableEditableArea: function ($editable) { + if ($editable.data('oe-type') === "monetary") { + $editable.attr('contenteditable', false); + $editable.find('.oe_currency_value').attr('contenteditable', true); + } + }, }); /* list of font icons to load by editor. The icons are displayed in the media editor and