diff options
| author | Antoine Guenet <age@odoo.com> | 2019-08-23 09:30:16 +0000 |
|---|---|---|
| committer | Antoine Guenet <age@odoo.com> | 2019-08-23 09:35:57 +0000 |
| commit | 0ff1d5cd40156c2adac98c7d5dea51c5cd95e079 (patch) | |
| tree | 8cc60ed36d065352173a3f2aa258b0baaa2347c2 /addons/web_editor/static/src/js | |
| parent | b51ff07c23625d12e6927c5cfc9c487f87ce0245 (diff) | |
[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>
Diffstat (limited to 'addons/web_editor/static/src/js')
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/plugin/text.js | 7 |
1 files changed, 6 insertions, 1 deletions
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 { |
