summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorJulien Legros <jle@odoo.com>2016-01-25 11:26:27 +0100
committerJulien Legros <jle@odoo.com>2016-01-25 11:26:27 +0100
commite5e7c4c1217c04d93820cf6007fd8ceed30d0cfa (patch)
tree0c475b2aa9f8f1b92f1550466cc189f1ba36230b /addons/web_editor/static
parent85b39df834c8689fd22e1a56d780af703a61909d (diff)
parent6872aae8ef9c1a1fc6a8283aa9d12ce3a6859157 (diff)
[MERGE] forward port of branch 9.0 up to 6872aae
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/lib/summernote/src/js/module/Clipboard.js14
-rw-r--r--addons/web_editor/static/src/js/backend.js21
-rw-r--r--addons/web_editor/static/src/js/summernote.js37
-rw-r--r--addons/web_editor/static/src/js/tour.rte.js2
-rw-r--r--addons/web_editor/static/src/js/transcoder.js2
5 files changed, 49 insertions, 27 deletions
diff --git a/addons/web_editor/static/lib/summernote/src/js/module/Clipboard.js b/addons/web_editor/static/lib/summernote/src/js/module/Clipboard.js
index 1d5a99b31f5..8b42726ff7a 100644
--- a/addons/web_editor/static/lib/summernote/src/js/module/Clipboard.js
+++ b/addons/web_editor/static/lib/summernote/src/js/module/Clipboard.js
@@ -150,12 +150,26 @@ define([
$(this).replaceWith($(this).contents());
});
$node.find('span + span').each(function () {
+
+ if (dom.isText(this.previousSibling)) {
+ if (dom.isVisibleText(this.previousSibling)) {
+ return;
+ } else { // keep space between 2 tags, but can merge the both tags
+ $(this).prev().append(this.previousSibling);
+ }
+ }
if ($(this).attr('class') === $(this).prev().attr('class') && $(this).attr('style') === $(this).prev().attr('style')) {
$(this).prev().append($(this).contents());
$(this).remove();
}
});
+ // remove empty table row and td
+ var $tdr;
+ while(($tdr = $node.find('tr:empty, td:empty, th:empty, tbody:empty, t-head:empty, table:empty')) && $tdr.length) {
+ $tdr.remove();
+ }
+
/*
reset architecture HTML node and add <p> tag
*/
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index 6fe895b154b..becd0fe4769 100644
--- a/addons/web_editor/static/src/js/backend.js
+++ b/addons/web_editor/static/src/js/backend.js
@@ -65,12 +65,17 @@ var FieldTextHtmlSimple = widget.extend({
this.$content = $();
if (this.get("effective_readonly")) {
- this.$textarea.hide().after('<iframe class="o_readonly"/>');
- setTimeout(function () {
- self.$content = $("body", self.$('iframe').contents()[0]);
- self.$content.html(self.text_to_html(self.get('value')));
- self.resize();
- });
+ if (this.options['style-inline']) {
+ this.$textarea.hide().after('<iframe class="o_readonly"/>');
+ setTimeout(function () {
+ self.$content = $("body", self.$('iframe').contents()[0]);
+ self.$content.html(self.text_to_html(self.get('value')));
+ self.resize();
+ });
+ } else {
+ this.$content = $('<div class="note-editable o_readonly"/>');
+ this.$textarea.hide().after(this.$content);
+ }
} else {
this.$textarea.summernote(this._config());
@@ -119,10 +124,10 @@ var FieldTextHtmlSimple = widget.extend({
return this.$content.focusInEnd();
} catch (e) {
return this.$content.focus();
- };
+ }
},
resize: function() {
- this.$('iframe').css('height', '0px').css('height', Math.max(180, Math.min(this.$content[0] ? this.$content[0].scrollHeight : 0, 500)) + 'px');
+ this.$('iframe').css('height', '0px').css('height', Math.max(30, Math.min(this.$content[0] ? this.$content[0].scrollHeight : 0, 500)) + 'px');
},
render_value: function() {
var value = this.get('value');
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index 6ed7be2039f..e31faaab601 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -558,13 +558,15 @@ dom.removeBetween = function (sc, so, ec, eo, towrite) {
};
};
dom.indent = function (node) {
- var margin = parseFloat(node.style.marginLeft || 0)+1.5;
- node.style.marginLeft = margin + "em";
+ var style = dom.isCell(node) ? 'paddingLeft' : 'marginLeft';
+ var margin = parseFloat(node.style[style] || 0)+1.5;
+ node.style[style] = margin + "em";
return margin;
};
dom.outdent = function (node) {
- var margin = parseFloat(node.style.marginLeft || 0)-1.5;
- node.style.marginLeft = margin > 0 ? margin + "em" : "";
+ var style = dom.isCell(node) ? 'paddingLeft' : 'marginLeft';
+ var margin = parseFloat(node.style[style] || 0)-1.5;
+ node.style[style] = margin > 0 ? margin + "em" : "";
return margin;
};
dom.scrollIntoViewIfNeeded = function (node) {
@@ -950,9 +952,10 @@ $.summernote.pluginEvents.tab = function (event, editor, layoutInfo, outdent) {
$editable.data('NoteHistory').recordUndo($editable, 'tab');
var r = range.create();
var outdent = outdent || false;
+ event.preventDefault();
- if (r && r.isCollapsed()) {
- if (r.isOnCell() && r.isOnCellFirst()) {
+ if (r && (dom.ancestor(r.sc, dom.isCell) || dom.ancestor(r.ec, dom.isCell))) {
+ if (r.isCollapsed() && r.isOnCell() && r.isOnCellFirst()) {
var td = dom.ancestor(r.sc, dom.isCell);
if (!outdent && !dom.nextElementSibling(td) && !dom.nextElementSibling(td.parentNode)) {
var last = dom.lastChild(td);
@@ -963,10 +966,10 @@ $.summernote.pluginEvents.tab = function (event, editor, layoutInfo, outdent) {
} else {
editor.table.tab(r, outdent);
}
- event.preventDefault();
- return false;
+ } else {
+ $.summernote.pluginEvents.indent(event, editor, layoutInfo, outdent);
}
-
+ } else if (r && r.isCollapsed()) {
if (!r.sc.textContent.slice(0,r.so).match(/\S/) && r.isOnList()) {
if (outdent) {
$.summernote.pluginEvents.outdent(event, editor, layoutInfo);
@@ -993,11 +996,8 @@ $.summernote.pluginEvents.tab = function (event, editor, layoutInfo, outdent) {
next.textContent = next.textContent.replace(/^(\u00A0)+/g, '');
range.create(r.sc, r.sc.textContent.length, r.sc, r.sc.textContent.length).select();
}
- event.preventDefault();
- return false;
}
}
- event.preventDefault();
return false;
};
$.summernote.pluginEvents.untab = function (event, editor, layoutInfo) {
@@ -1724,7 +1724,7 @@ $.summernote.pluginEvents.indent = function (event, editor, layoutInfo, outdent)
dom.merge(parent, start, 0, end, 1, null, true);
}
function indentOther (p, start, end) {
- if (p === start || $.contains(p, start)) {
+ if (p === start || $.contains(p, start) || $.contains(start, p)) {
flag = true;
}
if (flag) {
@@ -1734,7 +1734,7 @@ $.summernote.pluginEvents.indent = function (event, editor, layoutInfo, outdent)
dom.indent(p);
}
}
- if (p === end || $.contains(p, end)) {
+ if (p === end || $.contains(p, end) || $.contains(end, p)) {
flag = false;
}
}
@@ -1743,15 +1743,18 @@ $.summernote.pluginEvents.indent = function (event, editor, layoutInfo, outdent)
var $dom = $(ancestor);
if (!dom.isList(ancestor)) {
- $dom = $(ancestor).children();
+ $dom = $(dom.node(ancestor)).children();
}
if (!$dom.length) {
- $dom = $(dom.ancestor(r.sc, dom.isList));
+ $dom = $(dom.ancestor(r.sc, dom.isList) || dom.ancestor(r.sc, dom.isCell));
if (!$dom.length) {
$dom = $(r.sc).closest(options.styleTags.join(','));
}
}
+ // if select tr, take the first td
+ $dom = $dom.map(function () { return this.tagName === "TR" ? dom.firstElementChild(this) : this; });
+
$dom.each(function () {
if (flag || $.contains(this, r.sc)) {
if (dom.isList(this)) {
@@ -1760,7 +1763,7 @@ $.summernote.pluginEvents.indent = function (event, editor, layoutInfo, outdent)
} else {
indentUL(this, r.sc, r.ec);
}
- } else if (isFormatNode(this)) {
+ } else if (isFormatNode(this) || dom.ancestor(this, dom.isCell)) {
indentOther(this, r.sc, r.ec);
}
}
diff --git a/addons/web_editor/static/src/js/tour.rte.js b/addons/web_editor/static/src/js/tour.rte.js
index 5205e60eef8..8c3c494a73f 100644
--- a/addons/web_editor/static/src/js/tour.rte.js
+++ b/addons/web_editor/static/src/js/tour.rte.js
@@ -20,7 +20,7 @@ Tour.register({
id: 'rte',
name: "Test RTE",
mode: 'test',
- path: '/web_editor/field/html?callback=FieldTextHtml_0&enable_editor=1&datarecord=%7B%7D',
+ path: '/web_editor/field/html?debug&callback=FieldTextHtml_0&enable_editor=1&datarecord=%7B%7D',
steps: [
{
title: "Change html for this test",
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index 5e699367dc2..20779bf19aa 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -84,7 +84,7 @@ var getMatchedCSSRules = function (a) {
var style = {};
_.each(css, function (v,k) {
_.each(v[1], function (v,k) {
- if (k.indexOf('-webkit') === -1 && (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1)) {
+ if (v && k.indexOf('-webkit') === -1 && (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1)) {
style[k] = v;
}
});