[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.
This commit is contained in:
qsm-odoo
2017-02-01 13:09:16 +01:00
parent b8922c964c
commit b836e00d70
@@ -177,6 +177,10 @@ var Translate = Widget.extend({
},
rte_changed: function (node) {
var $node = $(node);
$node.find("p").each(function () { // remove <p/> 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);