[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) <dmo@odoo.com>
This commit is contained in:
Antoine Guenet
2019-08-23 09:35:57 +00:00
parent b51ff07c23
commit 0ff1d5cd40
@@ -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 {