summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/summernote.js
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2015-12-21 11:37:53 +0100
committerMartin Trigaux <mat@odoo.com>2015-12-21 11:37:53 +0100
commite4bf03aeaf2c8200164c27f0d93994e2c173bded (patch)
treeabce75b917f931d042dba1e34060efd625f90ed7 /addons/web_editor/static/src/js/summernote.js
parent82a495eed52a9f42e5b88caa52c20a85f8d81ce3 (diff)
parentc298cf3250fcfa351775dc57c3b913169e30e418 (diff)
[MERGE] Forward port of branch saas-7 up to c298cf3
Diffstat (limited to 'addons/web_editor/static/src/js/summernote.js')
-rw-r--r--addons/web_editor/static/src/js/summernote.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index ff509800c50..14db16a831c 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -1115,7 +1115,7 @@ $.summernote.pluginEvents.enter = function (event, editor, layoutInfo) {
$(node).html(br);
node = br;
} else {
- node = dom.splitTree(last, {'node': r.sc, 'offset': r.so});
+ node = dom.splitTree(last, {'node': r.sc, 'offset': r.so}) || r.sc;
if (!contentBefore) {
var cur = dom.node(dom.lastChild(node.previousSibling));
if (!dom.isBR(cur)) {
@@ -2298,7 +2298,7 @@ function summernote_paste (event) {
// keep norma feature if copy a picture
var clipboardData = event.originalEvent.clipboardData;
- if (clipboardData.items) {
+ if (!_.isEmpty(clipboardData.items)) {
var item = list.last(clipboardData.items);
var isClipboardImage = item.kind === 'file' && item.type.indexOf('image/') !== -1;
if (isClipboardImage) {
@@ -2336,8 +2336,8 @@ function summernote_paste (event) {
$node.find('*').each(function() {
var $node = $(this);
- if ($(this).attr('style')) {
- var style = _.filter($(this).attr('style').split(/\s*;\s*/), function (style) {
+ if ($node.attr('style')) {
+ var style = _.filter($node.attr('style').split(/\s*;\s*/), function (style) {
return /width|height|color|background-color|font-weight|text-align|font-style|text-decoration/i.test(style) && $node.css(style.split(':')[0]) !== $('body').css(style.split(':')[0]);
}).join(';');
if (style.length) {
@@ -2347,8 +2347,8 @@ function summernote_paste (event) {
}
}
- if ($(this).attr('class')) {
- var classes = _.filter($(this).attr('class').split(/\s+/), function (style) {
+ if ($node.attr('class')) {
+ var classes = _.filter($node.attr('class').split(/\s+/), function (style) {
return /(^|\s)(fa|pull|text|bg)(\s|-|$)/.test(style);
}).join(' ');
if (classes.length) {
@@ -2365,6 +2365,12 @@ function summernote_paste (event) {
$node.find('span:not([class]):not([style])').each(function () {
$(this).replaceWith($(this).contents());
});
+ $node.find('span + span').each(function () {
+ if ($(this).attr('class') === $(this).prev().attr('class') && $(this).attr('style') === $(this).prev().attr('style')) {
+ $(this).prev().append($(this).contents());
+ $(this).remove();
+ }
+ });
/*
reset architecture HTML node and add <p> tag