mjml-core
Advanced tools
Comparing version 4.11.0 to 4.12.0
@@ -79,5 +79,8 @@ "use strict"; | ||
props = {}, | ||
globalAttributes = {} | ||
globalAttributes = {}, | ||
absoluteFilePath = null | ||
} = initialDatas; | ||
this.props = { ...props, | ||
this.props = { | ||
absoluteFilePath, | ||
...props, | ||
children, | ||
@@ -84,0 +87,0 @@ content |
@@ -27,5 +27,16 @@ "use strict"; | ||
try { | ||
mjmlConfigPath = _path.default.basename(configPathOrDir) === '.mjmlconfig' ? _path.default.resolve(configPathOrDir) : _path.default.resolve(configPathOrDir, '.mjmlconfig'); | ||
mjmlConfigPath = _path.default.basename(configPathOrDir).match(/^\.mjmlconfig(\.js)?$/) ? _path.default.resolve(configPathOrDir) : _path.default.resolve(configPathOrDir, '.mjmlconfig'); | ||
componentRootPath = _path.default.dirname(mjmlConfigPath); | ||
const mjmlConfig = JSON.parse(_fs.default.readFileSync(_path.default.resolve(mjmlConfigPath), 'utf8')); | ||
const fullPath = _path.default.resolve(mjmlConfigPath); | ||
let mjmlConfig; | ||
if (_path.default.extname(mjmlConfigPath) === '.js') { | ||
delete require.cache[fullPath]; | ||
mjmlConfig = require(fullPath); // eslint-disable-line global-require, import/no-dynamic-require | ||
} else { | ||
mjmlConfig = JSON.parse(_fs.default.readFileSync(fullPath, 'utf8')); | ||
} | ||
return { | ||
@@ -32,0 +43,0 @@ mjmlConfig, |
@@ -29,2 +29,3 @@ "use strict"; | ||
backgroundColor = '', | ||
beforeDoctype = '', | ||
breakpoint = '480px', | ||
@@ -45,52 +46,51 @@ content = '', | ||
const langAttribute = lang ? `lang="${lang}" ` : ''; | ||
return ` | ||
<!doctype html> | ||
<html ${langAttribute}xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> | ||
<head> | ||
<title> | ||
${title} | ||
</title> | ||
<!--[if !mso]><!--> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<!--<![endif]--> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style type="text/css"> | ||
#outlook a { padding:0; } | ||
body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } | ||
table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } | ||
img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } | ||
p { display:block;margin:13px 0; } | ||
</style> | ||
<!--[if mso]> | ||
<noscript> | ||
<xml> | ||
<o:OfficeDocumentSettings> | ||
<o:AllowPNG/> | ||
<o:PixelsPerInch>96</o:PixelsPerInch> | ||
</o:OfficeDocumentSettings> | ||
</xml> | ||
</noscript> | ||
<![endif]--> | ||
<!--[if lte mso 11]> | ||
<style type="text/css"> | ||
.mj-outlook-group-fix { width:100% !important; } | ||
</style> | ||
<![endif]--> | ||
${(0, _fonts.buildFontsTags)(content, inlineStyle, fonts)} | ||
${(0, _mediaQueries.default)(breakpoint, mediaQueries, forceOWADesktop)} | ||
<style type="text/css"> | ||
${(0, _reduce2.default)(componentsHeadStyle, (result, compHeadStyle) => `${result}\n${compHeadStyle(breakpoint)}`, '')} | ||
${(0, _reduce2.default)(headStyle, (result, headStyle) => `${result}\n${headStyle(breakpoint)}`, '')} | ||
</style> | ||
<style type="text/css"> | ||
${(0, _map2.default)(style, s => (0, _isFunction2.default)(s) ? s(breakpoint) : s).join('')} | ||
</style> | ||
${headRaw.filter((0, _negate2.default)(_isNil2.default)).join('\n')} | ||
</head> | ||
<body style="word-spacing:normal;${backgroundColor ? `background-color:${backgroundColor};` : ''}"> | ||
${(0, _preview.default)(preview)} | ||
${content} | ||
</body> | ||
</html> | ||
return `${beforeDoctype ? `${beforeDoctype}\n` : ''}<!doctype html> | ||
<html ${langAttribute}xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> | ||
<head> | ||
<title> | ||
${title} | ||
</title> | ||
<!--[if !mso]><!--> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<!--<![endif]--> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style type="text/css"> | ||
#outlook a { padding:0; } | ||
body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } | ||
table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } | ||
img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } | ||
p { display:block;margin:13px 0; } | ||
</style> | ||
<!--[if mso]> | ||
<noscript> | ||
<xml> | ||
<o:OfficeDocumentSettings> | ||
<o:AllowPNG/> | ||
<o:PixelsPerInch>96</o:PixelsPerInch> | ||
</o:OfficeDocumentSettings> | ||
</xml> | ||
</noscript> | ||
<![endif]--> | ||
<!--[if lte mso 11]> | ||
<style type="text/css"> | ||
.mj-outlook-group-fix { width:100% !important; } | ||
</style> | ||
<![endif]--> | ||
${(0, _fonts.buildFontsTags)(content, inlineStyle, fonts)} | ||
${(0, _mediaQueries.default)(breakpoint, mediaQueries, forceOWADesktop)} | ||
<style type="text/css"> | ||
${(0, _reduce2.default)(componentsHeadStyle, (result, compHeadStyle) => `${result}\n${compHeadStyle(breakpoint)}`, '')} | ||
${(0, _reduce2.default)(headStyle, (result, headStyle) => `${result}\n${headStyle(breakpoint)}`, '')} | ||
</style> | ||
<style type="text/css"> | ||
${(0, _map2.default)(style, s => (0, _isFunction2.default)(s) ? s(breakpoint) : s).join('')} | ||
</style> | ||
${headRaw.filter((0, _negate2.default)(_isNil2.default)).join('\n')} | ||
</head> | ||
<body style="word-spacing:normal;${backgroundColor ? `background-color:${backgroundColor};` : ''}"> | ||
${(0, _preview.default)(preview)} | ||
${content} | ||
</body> | ||
</html> | ||
`; | ||
@@ -97,0 +97,0 @@ } |
@@ -90,2 +90,4 @@ "use strict"; | ||
var _filter2 = _interopRequireDefault(require("lodash/filter")); | ||
var _find2 = _interopRequireDefault(require("lodash/find")); | ||
@@ -161,2 +163,3 @@ | ||
let mjmlConfigOptions = {}; | ||
let confPreprocessors = []; | ||
let error = null; | ||
@@ -170,3 +173,4 @@ let componentRootPath = null; | ||
packages, | ||
options: confOptions | ||
options: confOptions, | ||
preprocessors: confPreprocessors | ||
}, | ||
@@ -210,3 +214,4 @@ componentRootPath, | ||
} = { ...mjmlConfigOptions, | ||
...options | ||
...options, | ||
preprocessors: options.preprocessors ? [...confPreprocessors, ...options.preprocessors] : confPreprocessors | ||
}; | ||
@@ -238,2 +243,3 @@ const components = { ..._components.default | ||
backgroundColor: '', | ||
beforeDoctype: '', | ||
breakpoint: '480px', | ||
@@ -287,2 +293,5 @@ classes: {}, | ||
}); | ||
const mjOutsideRaws = (0, _filter2.default)(mjml.children, { | ||
tagName: 'mj-raw' | ||
}); | ||
@@ -405,4 +414,17 @@ const processing = (node, context, parseMJML = _identity2.default) => { | ||
content = processing(mjBody, bodyHelpers, applyAttributes); | ||
if (!content) { | ||
throw new Error('Malformed MJML. Check that your structure is correct and enclosed in <mjml> tags.'); | ||
} | ||
content = (0, _minifyOutlookConditionnals.default)(content); | ||
if (mjOutsideRaws.length) { | ||
const toAddBeforeDoctype = mjOutsideRaws.filter(elt => elt.attributes.position && elt.attributes.position === 'file-start'); | ||
if (toAddBeforeDoctype.length) { | ||
globalDatas.beforeDoctype = toAddBeforeDoctype.map(elt => elt.content).join('\n'); | ||
} | ||
} | ||
if (!(0, _isEmpty2.default)(globalDatas.htmlAttributes)) { | ||
@@ -409,0 +431,0 @@ const $ = _cheerio.default.load(content, { |
{ | ||
"name": "mjml-core", | ||
"description": "mjml-core", | ||
"version": "4.11.0", | ||
"version": "4.12.0", | ||
"main": "lib/index.js", | ||
@@ -32,5 +32,5 @@ "files": [ | ||
"lodash": "^4.17.21", | ||
"mjml-migrate": "4.11.0", | ||
"mjml-parser-xml": "4.11.0", | ||
"mjml-validator": "4.11.0" | ||
"mjml-migrate": "4.12.0", | ||
"mjml-parser-xml": "4.12.0", | ||
"mjml-validator": "4.12.0" | ||
}, | ||
@@ -42,3 +42,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "0f4c64196ab251e116f1c80a1066f911e82697cf" | ||
"gitHead": "afc85c09963ef25f0fd6fe60bdcdea740094ff22" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61241
1495
7
+ Addedmjml-migrate@4.12.0(transitive)
+ Addedmjml-parser-xml@4.12.0(transitive)
+ Addedmjml-validator@4.12.0(transitive)
- Removedmjml-migrate@4.11.0(transitive)
- Removedmjml-parser-xml@4.11.0(transitive)
- Removedmjml-validator@4.11.0(transitive)
Updatedmjml-migrate@4.12.0
Updatedmjml-parser-xml@4.12.0
Updatedmjml-validator@4.12.0