From b836e00d70d723f74c56d40505a583f7fe9454be Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 1 Feb 2017 12:32:52 +0100 Subject: [PATCH] [FIX] web_editor: allow to copy paste when editing translations When editing translations, you were not able to copy/paste texts before this commit. Indeed, in some contexts, in some browsers, copy/pasting text was creating a new paragraph inside the translation, preventing it to be saved. This commit simply adds code to remove these paragraphs each time text is changed. A more elegant solution will be found for master with website and editor improvements. --- addons/web_editor/static/src/js/translator.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/web_editor/static/src/js/translator.js b/addons/web_editor/static/src/js/translator.js index f243a878d2c..cac85b7a0ff 100644 --- a/addons/web_editor/static/src/js/translator.js +++ b/addons/web_editor/static/src/js/translator.js @@ -177,6 +177,10 @@ var Translate = Widget.extend({ }, rte_changed: function (node) { var $node = $(node); + $node.find("p").each(function () { // remove

element which might have been inserted because of copy-paste + var $p = $(this); + $p.after($p.html()).remove(); + }); var trans = this.getTranlationObject($node[0]); $node.toggleClass('o_dirty', trans.value !== $node.html().replace(/[ \t\n\r]+/, ' ')); this.$('button[data-action=save]').prop('disabled', !$('.o_editable.o_dirty').length);