summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2016-01-18 16:47:36 +0100
committerChristophe Matthieu <chm@odoo.com>2016-01-18 17:09:01 +0100
commitb27d24bfe9404c6013405df7dbeef69c31e9d58c (patch)
tree1056663becdd1241ffc57533dda9f422f5eb2699 /addons/web_editor/static/src
parentda880a48db7e5f7fb1335b5e9e0824edee84ce88 (diff)
[FIX] web_editor: don't limit the css inliner to the class but for all tag
(can reduce the performances)
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/css/backend.css8
-rw-r--r--addons/web_editor/static/src/js/transcoder.js47
2 files changed, 33 insertions, 22 deletions
diff --git a/addons/web_editor/static/src/css/backend.css b/addons/web_editor/static/src/css/backend.css
index 2462aea3b09..33a7155354c 100644
--- a/addons/web_editor/static/src/css/backend.css
+++ b/addons/web_editor/static/src/css/backend.css
@@ -13,10 +13,9 @@
border: 0;
}
.oe_form_field_html_text .note-editable p {
- margin: initial;
-}
-.oe_form_field_html_text .note-editable a, .oe_form_field_html_text .note-editable a:hover {
- color: initial;
+ font-family: 'Lucida Grande', Helvetica, Verdana, Arial, sans-serif;
+ -webkit-margin-before: 0;
+ font-size: 13px;
}
.oe_form_field_html iframe {
@@ -54,7 +53,6 @@
overflow: hidden !important;
}
-
.openerp .oe_form .oe_form_field_html_translate textarea {
min-width: 60px;
width: 100%;
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index bd7848d2e97..852201c6f49 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -30,9 +30,7 @@ var getMatchedCSSRules = function (a) {
var selectorText = rules[r].selectorText;
if (selectorText &&
rules[r].cssText &&
- selectorText.indexOf(".") !== -1 &&
- selectorText.indexOf(".note-") === -1 &&
-
+ selectorText !== "*" &&
selectorText.indexOf(":hover") === -1 &&
selectorText.indexOf(":before") === -1 &&
selectorText.indexOf(":after") === -1 &&
@@ -83,12 +81,31 @@ var getMatchedCSSRules = function (a) {
var style = {};
_.each(css, function (v,k) {
_.each(v[1], function (v,k) {
- if (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1) {
+ if (k.indexOf('-webkit') === -1 && (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1)) {
style[k] = v;
}
});
});
- return cache[a.tagName + "." +a.className] = style;
+
+ if (style.display === 'block') {
+ delete style.display;
+ }
+ if (style['margin-top']) {
+ style.margin = (style['margin-top'] || 0) + ' ' + (style['margin-right'] || 0) + ' ' + (style['margin-bottom'] || 0) + ' ' + (style['margin-left'] || 0);
+ delete style['margin-top'];
+ delete style['margin-right'];
+ delete style['margin-bottom'];
+ delete style['margin-left'];
+ }
+ if (style['padding-top']) {
+ style.padding = (style['padding-top'] || 0) + ' ' + (style['padding-right'] || 0) + ' ' + (style['padding-bottom'] || 0) + ' ' + (style['padding-left'] || 0);
+ delete style['padding-top'];
+ delete style['padding-right'];
+ delete style['padding-bottom'];
+ delete style['padding-left'];
+ }
+
+ return a.className ? cache[a.tagName + "." +a.className] = style : style;
};
// convert font awsome into image
@@ -138,8 +155,7 @@ var class_to_style = function ($editable) {
if (!rulesCache.length) {
getMatchedCSSRules($editable[0]);
}
- var selector = _.map(rulesCache, function (a) { return a.selector;}).join(",");
- $editable.find(selector).each(function () {
+ $editable.find('*').each(function () {
var $target = $(this);
var css = getMatchedCSSRules(this);
var style = $target.attr("style") || "";
@@ -154,18 +170,10 @@ var class_to_style = function ($editable) {
// convert style into inline class from mail
var style_to_class = function ($editable) {
getMatchedCSSRules($editable[0]);
- var classes = [];
- $editable.find("[class]").each(function () {
- classes = classes.concat(this.className.split(/\s+/));
- });
- classes = _.compact(classes);
-
- var maybe_selector = _.filter(rulesCache, function (a) { return !!_.find(classes, function (b) { return a.selector.indexOf("."+b) !== -1; } ); });
- var selector = _.map(maybe_selector, function (a) { return a.selector;}).join(",");
var $c = $('<span/>').appendTo("body");
- $editable.find(selector).each(function () {
+ $editable.find('*').each(function () {
var $target = $(this);
var css = getMatchedCSSRules(this);
var style = "";
@@ -179,7 +187,12 @@ var style_to_class = function ($editable) {
_.each(css, function (v) {
style = style.replace(v, '');
});
- $target.attr("style", style.replace(/;+(\s;)*/g, ';').replace(/^;/g, ''));
+ style = style.replace(/;+(\s;)*/g, ';').replace(/^;/g, '');
+ if (style !== '') {
+ $target.attr("style", style);
+ } else {
+ $target.removeAttr("style");
+ }
});
$c.remove();
};