[REF] web_editor: import odoo-editor utils into convertInline

Some code from odoo-editor utils is needed in convertInline. In order to
avoid duplication, we need to import that code. To that effect, we can't
have the utils being lazy loaded into mass mailing's iframe while
convertInline is loaded the usual way.
This loads the lightweight utils together with convertInline and turns
convertInline into an odoo-module, which makes it easier to simply
import the utils and delete duplicated code.

X-original-commit: 067c94b009609caa0bd78a75b826247e37557417
Part-of: odoo/odoo#80621
This commit is contained in:
Antoine Guenet
2021-12-08 09:35:00 +00:00
parent 54a0b8d853
commit d4b3daa871
2 changed files with 5 additions and 19 deletions
+1 -1
View File
@@ -41,7 +41,6 @@ Odoo Web Editor widget.
'web_editor/static/lib/odoo-editor/src/utils/constants.js',
'web_editor/static/lib/odoo-editor/src/utils/sanitize.js',
'web_editor/static/lib/odoo-editor/src/utils/serialize.js',
'web_editor/static/lib/odoo-editor/src/utils/utils.js',
'web_editor/static/lib/odoo-editor/src/utils/DOMPurify.js',
'web_editor/static/lib/odoo-editor/src/tablepicker/TablePicker.js',
'web_editor/static/lib/odoo-editor/src/powerbox/patienceDiff.js',
@@ -88,6 +87,7 @@ Odoo Web Editor widget.
'web.assets_common': [
'web_editor/static/lib/vkbeautify/**/*',
'web_editor/static/src/js/common/**/*',
'web_editor/static/lib/odoo-editor/src/utils/utils.js',
],
'web.assets_backend': [
'web_editor/static/src/scss/web_editor.common.scss',
@@ -1,24 +1,11 @@
odoo.define('web_editor.convertInline', function (require) {
/** @odoo-module alias=web_editor.convertInline */
'use strict';
var FieldHtml = require('web_editor.field.html');
import FieldHtml from 'web_editor.field.html';
import { rgbToHex } from '../../../lib/odoo-editor/src/utils/utils';
const SELECTORS_IGNORE = /(^\*$|:hover|:before|:after|:active|:link|::|'|\([^(),]+[,(])/;
// Note: duplicated from odoo-editor utils.
// DOES NOT SUPPORT RGBA (Outlook doesn't support transparency)
function rgbToHex(rgb = '') {
return (
'#' +
(rgb.match(/\d{1,3}/g) || [])
.map(x => {
x = parseInt(x).toString(16);
return x.length === 1 ? '0' + x : x;
})
.join('')
);
}
/**
* Returns the css rules which applies on an element, tweaked so that they are
* browser/mail client ok.
@@ -839,7 +826,7 @@ FieldHtml.include({
},
});
return {
export default {
fontToImg: fontToImg,
bootstrapToTable: bootstrapToTable,
cardToTable: cardToTable,
@@ -851,4 +838,3 @@ return {
normalizeRem: normalizeRem,
attachmentThumbnailToLinkImg: attachmentThumbnailToLinkImg,
};
});