From 0ff1d5cd40156c2adac98c7d5dea51c5cd95e079 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 23 Aug 2019 09:30:16 +0000 Subject: [PATCH] [FIX] web_editor: properly paste unwrapped text When pasting from clipboard, the editor filters the nodes to paste. Among other things, it removes `meta`, `style` and `script` nodes. It did so using `jQuery`'s `not` method but that method has a side effect: it removes text and comment nodes as well if you pass it a `jQuery` selector. As a result, unwrapped text nodes could not be pasted. This commit fixes that by using `each` to remove the targeted nodes instead of using `not`. closes odoo/odoo#36012 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/plugin/text.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js index 2b7d10d02fd..f770b8121bf 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js @@ -679,7 +679,12 @@ var TextPlugin = AbstractPlugin.extend({ */ _removeIllegalClipboardElements: function ($clipboardData) { var root = true; - $clipboardData = $clipboardData.not('meta').not('style').not('script'); + $clipboardData.each(function (i, node) { + var tag = node.tagName; + if (tag === 'meta' || tag === 'style' || tag === 'script') { + $(node).remove(); + } + }); var $badNodes = this._filterIllegalClipboardElements($clipboardData); do {