diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-07-16 15:45:24 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-16 15:45:24 +0000 |
| commit | 5d57e1862f3d178313534fc201216fdd31e5247d (patch) | |
| tree | 1d78d498b6805baa9979f3b0860b669c9346c765 /addons/web_editor/static/src | |
| parent | 02c48e71f06ba335dcbde020d7fe28663e1afd00 (diff) | |
| parent | beba36416fdf25df74cf8a581c66948a418173b6 (diff) | |
[MERGE] Forward port of saas-12.4 to master up to beba36416fdf2
closes odoo/odoo#34924
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/plugin/helper.js | 3 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/plugin/text.js | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js index a025d6a0082..1738e6e7b48 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js @@ -1885,6 +1885,9 @@ var HelperPlugin = AbstractPlugin.extend({ // Create empty text node to have a range into the node if (range.sc.tagName && !dom.isVoid(range.sc) && !range.sc.childNodes[range.so]) { $(range.sc).append(invisible); + if (invisible.previousSibling && invisible.previousSibling.tagName === "BR") { + invisible.previousSibling.remove(); + } range = this.context.invoke('editor.setRange', invisible, 0); } 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 f2834c531f7..9014b367fee 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js @@ -780,7 +780,10 @@ var TextPlugin = AbstractPlugin.extend({ clipboardData = e.originalEvent.clipboardData.getData('text/plain'); // get that text as an array of text nodes separated by <br> where needed var allNewlines = /\n/g; - clipboardData = $('<p>' + clipboardData.replace(allNewlines, '<br>') + '</p>').contents().toArray(); + clipboardData = _.str.trim(clipboardData) + .replace(/</g, '<').replace(/>/g, '>') + .replace(allNewlines, '<br>'); + clipboardData = $('<p>' + clipboardData + '</p>').contents().toArray(); } // Delete selection |
