summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-04-24 17:42:41 +0200
committerChristophe Simonis <chs@odoo.com>2018-04-24 17:42:41 +0200
commitb192431aeecc59b48898ce9c6f276b82d65cbfa6 (patch)
tree598ec468eac64914858e24d2235827d905692c80 /addons/web_editor
parentddf601d44367a791848da38df9cff02b3e32b95b (diff)
parentec5e27bb7cc7808d7128eae4e7e67910f40492c0 (diff)
[MERGE] forward port branch saas-11.3 up to ec5e27bb7cc
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/i18n/tr.po5
-rw-r--r--addons/web_editor/static/src/js/editor/editor.js4
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js10
-rw-r--r--addons/web_editor/static/src/js/editor/transcoder.js76
4 files changed, 79 insertions, 16 deletions
diff --git a/addons/web_editor/i18n/tr.po b/addons/web_editor/i18n/tr.po
index fc757d677a0..619a84af27d 100644
--- a/addons/web_editor/i18n/tr.po
+++ b/addons/web_editor/i18n/tr.po
@@ -15,13 +15,14 @@
# Saban Yildiz <sabany@projetgrup.com>, 2017
# Cem Uygur <cemuygur.beb@gmail.com>, 2017
# İlknur Püskül <ilknurpuskull@gmail.com>, 2017
+# Umur Akın <umura@projetgrup.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server saas~11.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-22 14:11+0000\n"
"PO-Revision-Date: 2018-03-22 14:11+0000\n"
-"Last-Translator: İlknur Püskül <ilknurpuskull@gmail.com>, 2017\n"
+"Last-Translator: Umur Akın <umura@projetgrup.com>, 2018\n"
"Language-Team: Turkish (https://www.transifex.com/odoo/teams/41243/tr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -1219,7 +1220,7 @@ msgstr ""
#: code:addons/web_editor/static/src/js/widgets/ace.js:572
#, python-format
msgid "Server error"
-msgstr ""
+msgstr "Sunucu hatas"
#. module: web_editor
#. openerp-web
diff --git a/addons/web_editor/static/src/js/editor/editor.js b/addons/web_editor/static/src/js/editor/editor.js
index 353104c2c93..95831dd306a 100644
--- a/addons/web_editor/static/src/js/editor/editor.js
+++ b/addons/web_editor/static/src/js/editor/editor.js
@@ -47,8 +47,8 @@ var EditorMenuBar = Widget.extend({
var self = this;
var defs = [this._super.apply(this, arguments)];
- core.bus.on('editor_save_request', this, this._onSaveRequest);
- core.bus.on('editor_discard_request', this, this._onDiscardRequest);
+ core.bus.on('editor_save_request', this, this.save);
+ core.bus.on('editor_discard_request', this, this.cancel);
$('.dropdown-toggle').dropdown();
diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js
index f6e2ac63aa9..ddf588eb569 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -665,7 +665,15 @@ function summernote_mousedown(event) {
}
// restore range if range lost after clicking on non-editable area
- r = range.create();
+ try {
+ r = range.create();
+ } catch (e) {
+ // If this code is running inside an iframe-editor and that the range
+ // is outside of this iframe, this will fail as the iframe does not have
+ // the permission to check the outside content this way. In that case,
+ // we simply ignore the exception as it is as if there was no range.
+ return;
+ }
var editables = $(".o_editable[contenteditable], .note-editable[contenteditable]");
var r_editable = editables.has((r||{}).sc);
if (!r_editable.closest('.note-editor').is($editable) && !r_editable.filter('.o_editable').is(editables)) {
diff --git a/addons/web_editor/static/src/js/editor/transcoder.js b/addons/web_editor/static/src/js/editor/transcoder.js
index 1a77b3d19e7..4fa30978f84 100644
--- a/addons/web_editor/static/src/js/editor/transcoder.js
+++ b/addons/web_editor/static/src/js/editor/transcoder.js
@@ -105,25 +105,47 @@ function getMatchedCSSRules(a) {
delete style.display;
}
- _.each(['margin', 'padding'], function (p) {
- if (style[p+'-top'] || style[p+'-right'] || style[p+'-bottom'] || style[p+'-left']) {
- if (style[p+'-top'] === style[p+'-right'] && style[p+'-top'] === style[p+'-bottom'] && style[p+'-top'] === style[p+'-left']) {
+ // The css generates all the attributes separately and not in simplified form.
+ // In order to have a better compatibility (outlook for example) we simplify the css tags.
+ // e.g. border-left-style: none; border-bottom-s .... will be simplified in border-style = none
+ _.each([['margin'], ['padding'], ['border', 'style']], function (attr) {
+ var p = attr[0];
+ var e = attr[1] ? '-' + attr[1] : '';
+
+ if (style[p+'-top'+e] || style[p+'-right'+e] || style[p+'-bottom'+e] || style[p+'-left'+e]) {
+ if (style[p+'-top'+e] === style[p+'-right'+e] && style[p+'-top'+e] === style[p+'-bottom'+e] && style[p+'-top'+e] === style[p+'-left'+e]) {
// keep => property: [top/right/bottom/left value];
- style[p] = style[p+'-top'];
+ style[p+e] = style[p+'-top'+e];
}
else {
// keep => property: [top value] [right value] [bottom value] [left value];
- style[p] = (style[p+'-top'] || 0) + ' ' + (style[p+'-right'] || 0) + ' ' + (style[p+'-bottom'] || 0) + ' ' + (style[p+'-left'] || 0);
- if (style[p].indexOf('inherit') !== -1 || style[p].indexOf('initial') !== -1) {
+ style[p+e] = (style[p+'-top'+e] || 0) + ' ' + (style[p+'-right'+e] || 0) + ' ' + (style[p+'-bottom'+e] || 0) + ' ' + (style[p+'-left'+e] || 0);
+ if (style[p+e].indexOf('inherit') !== -1 || style[p+e].indexOf('initial') !== -1) {
// keep => property-top: [top value]; property-right: [right value]; property-bottom: [bottom value]; property-left: [left value];
- delete style[p];
+ delete style[p+e];
return;
}
}
- delete style[p+'-top'];
- delete style[p+'-right'];
- delete style[p+'-bottom'];
- delete style[p+'-left'];
+ delete style[p+'-top'+e];
+ delete style[p+'-right'+e];
+ delete style[p+'-bottom'+e];
+ delete style[p+'-left'+e];
+ }
+ });
+
+ if (style['border-bottom-left-radius']) {
+ style['border-radius'] = style['border-bottom-left-radius'];
+ delete style['border-bottom-left-radius'];
+ delete style['border-bottom-right-radius'];
+ delete style['border-top-left-radius'];
+ delete style['border-top-right-radius'];
+ }
+
+ // if the border styling is initial we remove it to simplify the css tags for compatibility.
+ // Also, since we do not send a css style tag, the initial value of the border is useless.
+ _.each(_.keys(style), function (k) {
+ if (k.indexOf('border') !== -1 && style[k] === 'initial') {
+ delete style[k];
}
});
@@ -229,6 +251,33 @@ function classToStyle($editable) {
} else {
$target.attr('style', style);
}
+ // Apple Mail
+ if (this.nodeName === 'TD' && !this.childNodes.length) {
+ this.innerHTML = '&nbsp;';
+ }
+
+ // Outlook
+ if (this.nodeName === 'A' && $target.hasClass('btn') && !$target.children().length) {
+ var $hack = $('<table class="o_outlook_hack"><tr><td></td></tr></table>');
+ $hack.find('td')
+ .attr('height', $target.outerHeight())
+ .css({
+ 'margin': $target.css('padding'),
+ 'border-radius': $target.css('border-radius'),
+ 'background-color': $target.css('background-color'),
+ });
+ $target.after($hack);
+ $target.appendTo($hack.find('td'));
+ // the space add a line when it's a table but it's invisible when it's a link
+ var node = $hack[0].previousSibling;
+ if (node && node.nodeType === Node.TEXT_NODE && !node.textContent.match(/\S/)) {
+ $(node).remove();
+ }
+ node = $hack[0].nextSibling;
+ if (node && node.nodeType === Node.TEXT_NODE && !node.textContent.match(/\S/)) {
+ $(node).remove();
+ }
+ }
});
}
@@ -239,6 +288,11 @@ function classToStyle($editable) {
* @param {jQuery} $editable
*/
function styleToClass($editable) {
+ // Outlook revert
+ $editable.find('table.o_outlook_hack').each(function () {
+ $(this).after($('a', this));
+ }).remove();
+
getMatchedCSSRules($editable[0]);
var $c = $('<span/>').appendTo(document.body);