diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2020-06-08 11:38:01 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2020-06-12 15:39:25 +0000 |
| commit | a8e9a8181442d2e5aaa1b60bf38e373d4ae1715c (patch) | |
| tree | 9cdad01b753b28ec07b7331db1bb3f615f5ea5a8 /addons/website/static/src/js/editor | |
| parent | b4b0828e25fc59f58a054e679841e87a3c921fd2 (diff) | |
[FIX] web_editor: translatable after pasted translation
Fixes same issue as b836e00d70d but for `<div/>` tag.
When we translate html content, all text and (currently) this subset of
inline tags are allowed inside translations: 'abbr', 'b', 'bdi', 'bdo',
'br', 'cite', 'code', 'data', 'del', 'dfn', 'em', 'font', 'i', 'ins',
'kbd', 'keygen', 'mark', 'math', 'meter', 'output', 'progress', 'q',
'ruby', 's', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'time',
'u', 'var', 'wbr', 'text'.
In b836e00d70d an issue was fixed that `<p/>` would possibly get inside
translation when copy-pasting, testing some scenario in current chromium
browser (83.0) it seems the pasted content contains `<div/>` tags.
opw-2259367
opw-2260711
closes #52592
closes odoo/odoo#52932
X-original-commit: eed9fb771521143c0b514d96b5efdcb9715051f0
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/website/static/src/js/editor')
| -rw-r--r-- | addons/website/static/src/js/editor/wysiwyg_multizone_translate.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/website/static/src/js/editor/wysiwyg_multizone_translate.js b/addons/website/static/src/js/editor/wysiwyg_multizone_translate.js index 476c84b7f74..0541d60bf33 100644 --- a/addons/website/static/src/js/editor/wysiwyg_multizone_translate.js +++ b/addons/website/static/src/js/editor/wysiwyg_multizone_translate.js @@ -72,6 +72,7 @@ var AttributeTranslateDialog = Dialog.extend({ var WysiwygTranslate = WysiwygMultizone.extend({ custom_events: _.extend({}, WysiwygMultizone.prototype.custom_events || {}, { ready_to_save: '_onSave', + rte_change: '_onChange', }), /** @@ -125,7 +126,9 @@ var WysiwygTranslate = WysiwygMultizone.extend({ self.$editables_attr = self._getEditableArea().filter('.o_translatable_attribute'); self.$editables_attribute = $('.o_editable_translatable_attribute'); - self.$editables_attribute.on('change', self._onChange.bind(self)); + self.$editables_attribute.on('change', function () { + self.trigger_up('rte_change', {target: this}); + }); self._markTranslatableNodes(); }); @@ -199,11 +202,11 @@ var WysiwygTranslate = WysiwygMultizone.extend({ * @param {Jquery Event} [ev] */ _onChange: function (ev) { - var $node = $(ev && ev.target || this._getFocusedEditable()); + var $node = $(ev.data.target); if (!$node.length) { return; } - $node.find('p').each(function () { // remove <p/> element which might have been inserted because of copy-paste + $node.find('div,p').each(function () { // remove P,DIV elements which might have been inserted because of copy-paste var $p = $(this); $p.after($p.html()).remove(); }); |
