summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/helper.js3
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/text.js5
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, '&lt;').replace(/>/g, '&gt;')
+ .replace(allNewlines, '<br>');
+ clipboardData = $('<p>' + clipboardData + '</p>').contents().toArray();
}
// Delete selection