mjml-core
Advanced tools
Comparing version 4.0.5 to 4.1.0-beta.1
@@ -172,3 +172,3 @@ 'use strict'; | ||
if (value) { | ||
if (!(0, _lodash.isNil)(value)) { | ||
return output + ' ' + name + '="' + value + '"'; | ||
@@ -218,2 +218,4 @@ } | ||
childrens = childrens || this.props.children; | ||
if (rawXML) { | ||
@@ -225,6 +227,13 @@ return childrens.map(function (child) { | ||
childrens = childrens || this.props.children; | ||
var sibling = childrens.length; | ||
var rawComponents = (0, _lodash.filter)(_components2.default, function (c) { | ||
return c.isRawElement(); | ||
}); | ||
var nonRawSiblings = childrens.filter(function (child) { | ||
return !(0, _lodash.find)(rawComponents, function (c) { | ||
return c.getTagName() === child.tagName; | ||
}); | ||
}).length; | ||
var output = ''; | ||
@@ -243,3 +252,4 @@ var index = 0; | ||
last: index + 1 === sibling, | ||
sibling: sibling | ||
sibling: sibling, | ||
nonRawSiblings: nonRawSiblings | ||
}) | ||
@@ -288,2 +298,3 @@ }) | ||
if (!component) { | ||
// eslint-disable-next-line no-console | ||
console.log('No matching component for tag : ' + children.tagName); | ||
@@ -290,0 +301,0 @@ return; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
exports.default = function (_ref) { | ||
var jsonToXML = function jsonToXML(_ref) { | ||
var tagName = _ref.tagName, | ||
@@ -20,3 +20,3 @@ attributes = _ref.attributes, | ||
var subNode = children && children.length > 0 ? children.map(jsonToXML).join('\n') : content ? content : ''; | ||
var subNode = children && children.length > 0 ? children.map(jsonToXML).join('\n') : content || ''; | ||
@@ -30,2 +30,3 @@ var stringAttrs = (0, _keys2.default)(attributes).map(function (attr) { | ||
exports.default = jsonToXML; | ||
module.exports = exports['default']; |
@@ -6,6 +6,7 @@ 'use strict'; | ||
}); | ||
exports.buildMediaQueriesTags = buildMediaQueriesTags; | ||
exports.default = buildMediaQueriesTags; | ||
var _lodash = require('lodash'); | ||
// eslint-disable-next-line import/prefer-default-export | ||
function buildMediaQueriesTags(breakpoint) { | ||
@@ -27,2 +28,3 @@ var mediaQueries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return '\n <style type="text/css">\n @media only screen and (min-width:' + breakpoint + ') {\n ' + baseMediaQueries.join('\n') + '\n }\n </style>\n ' + (forceOWADesktop ? '<style type="text/css">\n' + owaQueries.join('\n') + '\n</style>' : '') + '\n '; | ||
} | ||
} | ||
module.exports = exports['default']; |
@@ -18,2 +18,4 @@ 'use strict'; | ||
var _mediaQueries2 = _interopRequireDefault(_mediaQueries); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,6 +43,9 @@ | ||
forceOWADesktop = options.forceOWADesktop, | ||
inlineStyle = options.inlineStyle; | ||
inlineStyle = options.inlineStyle, | ||
lang = options.lang; | ||
return '\n <!doctype html>\n <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">\n <head>\n <title>\n ' + title + '\n </title>\n <!--[if !mso]><!-- -->\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <!--<![endif]-->\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <style type="text/css">\n #outlook a { padding:0; }\n .ReadMsgBody { width:100%; }\n .ExternalClass { width:100%; }\n .ExternalClass * { line-height:100%; }\n body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }\n table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }\n img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }\n p { display:block;margin:13px 0; }\n </style>\n <!--[if !mso]><!-->\n <style type="text/css">\n @media only screen and (max-width:480px) {\n @-ms-viewport { width:320px; }\n @viewport { width:320px; }\n }\n </style>\n <!--<![endif]-->\n <!--[if mso]>\n <xml>\n <o:OfficeDocumentSettings>\n <o:AllowPNG/>\n <o:PixelsPerInch>96</o:PixelsPerInch>\n </o:OfficeDocumentSettings>\n </xml>\n <![endif]-->\n <!--[if lte mso 11]>\n <style type="text/css">\n .outlook-group-fix { width:100% !important; }\n </style>\n <![endif]-->\n ' + (0, _fonts.buildFontsTags)(content, inlineStyle, fonts) + '\n ' + (0, _mediaQueries.buildMediaQueriesTags)(breakpoint, mediaQueries, forceOWADesktop) + '\n <style type="text/css">\n ' + (0, _lodash.reduce)(componentsHeadStyle, function (result, compHeadStyle) { | ||
var langAttribute = lang ? 'lang="' + lang + '" ' : ''; | ||
return '\n <!doctype html>\n <html ' + langAttribute + 'xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">\n <head>\n <title>\n ' + title + '\n </title>\n <!--[if !mso]><!-- -->\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <!--<![endif]-->\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <style type="text/css">\n #outlook a { padding:0; }\n .ReadMsgBody { width:100%; }\n .ExternalClass { width:100%; }\n .ExternalClass * { line-height:100%; }\n body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }\n table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }\n img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }\n p { display:block;margin:13px 0; }\n </style>\n <!--[if !mso]><!-->\n <style type="text/css">\n @media only screen and (max-width:480px) {\n @-ms-viewport { width:320px; }\n @viewport { width:320px; }\n }\n </style>\n <!--<![endif]-->\n <!--[if mso]>\n <xml>\n <o:OfficeDocumentSettings>\n <o:AllowPNG/>\n <o:PixelsPerInch>96</o:PixelsPerInch>\n </o:OfficeDocumentSettings>\n </xml>\n <![endif]-->\n <!--[if lte mso 11]>\n <style type="text/css">\n .outlook-group-fix { width:100% !important; }\n </style>\n <![endif]-->\n ' + (0, _fonts.buildFontsTags)(content, inlineStyle, fonts) + '\n ' + (0, _mediaQueries2.default)(breakpoint, mediaQueries, forceOWADesktop) + '\n <style type="text/css">\n ' + (0, _lodash.reduce)(componentsHeadStyle, function (result, compHeadStyle) { | ||
return result + '\n' + compHeadStyle(breakpoint); | ||
@@ -47,0 +52,0 @@ }, '') + '\n ' + (0, _lodash.reduce)(headStyle, function (result, headStyle) { |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.HeadComponent = exports.BodyComponent = exports.registerComponent = exports.initComponent = exports.components = undefined; | ||
exports.HeadComponent = exports.BodyComponent = exports.suffixCssClasses = exports.registerComponent = exports.initComponent = exports.components = undefined; | ||
@@ -56,2 +56,6 @@ var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _fs = require('fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _juice = require('juice'); | ||
@@ -79,2 +83,6 @@ | ||
var _suffixCssClasses = require('./helpers/suffixCssClasses'); | ||
var _suffixCssClasses2 = _interopRequireDefault(_suffixCssClasses); | ||
var _mergeOutlookConditionnals = require('./helpers/mergeOutlookConditionnals'); | ||
@@ -84,2 +92,6 @@ | ||
var _minifyOutlookConditionnals = require('./helpers/minifyOutlookConditionnals'); | ||
var _minifyOutlookConditionnals2 = _interopRequireDefault(_minifyOutlookConditionnals); | ||
var _skeleton = require('./helpers/skeleton'); | ||
@@ -113,3 +125,7 @@ | ||
if (typeof options.skeleton === 'string') { | ||
/* eslint-disable global-require */ | ||
/* eslint-disable import/no-dynamic-require */ | ||
options.skeleton = require(options.skeleton.charAt(0) === '.' ? _path2.default.resolve(process.cwd(), options.skeleton) : options.skeleton); | ||
/* eslint-enable global-require */ | ||
/* eslint-enable import/no-dynamic-require */ | ||
} | ||
@@ -162,3 +178,4 @@ | ||
title: '', | ||
forceOWADesktop: (0, _lodash.get)(mjml, 'attributes.owa', 'mobile') === 'desktop' | ||
forceOWADesktop: (0, _lodash.get)(mjml, 'attributes.owa', 'mobile') === 'desktop', | ||
lang: (0, _lodash.get)(mjml, 'attributes.lang') | ||
}; | ||
@@ -227,4 +244,13 @@ | ||
var attributesClasses = (0, _lodash.reduce)(classes, function (acc, value) { | ||
return (0, _extends3.default)({}, acc, globalDatas.classes[value]); | ||
var mjClassValues = globalDatas.classes[value]; | ||
var multipleClasses = {}; | ||
if (acc['css-class'] && (0, _lodash.get)(mjClassValues, 'css-class')) { | ||
multipleClasses = { | ||
'css-class': acc['css-class'] + ' ' + mjClassValues['css-class'] | ||
}; | ||
} | ||
return (0, _extends3.default)({}, acc, mjClassValues, multipleClasses); | ||
}, {}); | ||
var defaultAttributesForClasses = (0, _lodash.reduce)(parentMjClass.split(' '), function (acc, value) { | ||
@@ -280,3 +306,7 @@ return (0, _extends3.default)({}, acc, (0, _lodash.get)(globalDatas.classesDefault, value + '.' + tagName)); | ||
if (params.length > 1) { | ||
globalDatas[attr][params[0]] = params[1]; | ||
if ((0, _lodash.isObject)(globalDatas[attr][params[0]])) { | ||
globalDatas[attr][params[0]] = (0, _extends3.default)({}, globalDatas[attr][params[0]], params[1]); | ||
} else { | ||
globalDatas[attr][params[0]] = params[1]; | ||
} | ||
} else { | ||
@@ -295,2 +325,6 @@ globalDatas[attr] = params[0]; | ||
if (minify && minify !== 'false') { | ||
content = (0, _minifyOutlookConditionnals2.default)(content); | ||
} | ||
content = skeleton((0, _extends3.default)({ | ||
@@ -316,8 +350,9 @@ content: content | ||
content = minify && minify !== 'false' ? (0, _htmlMinifier.minify)(content, { | ||
collapseWhitespace: true, | ||
minifyCSS: false, | ||
removeEmptyAttributes: true, | ||
processConditionalComments: true | ||
}) : content; | ||
if (minify && minify !== 'false') { | ||
content = (0, _htmlMinifier.minify)(content, { | ||
collapseWhitespace: true, | ||
minifyCSS: false, | ||
removeEmptyAttributes: true | ||
}); | ||
} | ||
@@ -332,4 +367,20 @@ content = (0, _mergeOutlookConditionnals2.default)(content); | ||
// register components from mjmlconfig | ||
try { | ||
var mjmlConfig = _fs2.default.readFileSync(_path2.default.join(process.cwd(), '.mjmlconfig')); | ||
var customComps = JSON.parse(mjmlConfig).packages; | ||
customComps.forEach(function (compPath) { | ||
var requiredComp = require(_path2.default.join(process.cwd(), compPath)); // eslint-disable-line global-require, import/no-dynamic-require | ||
(0, _components.registerComponent)(requiredComp.default || requiredComp); | ||
}); | ||
} catch (e) { | ||
if (e.code !== 'ENOENT') { | ||
console.log('Error when registering custom components : ', e); // eslint-disable-line no-console | ||
} | ||
} | ||
exports.components = _components2.default; | ||
exports.initComponent = _components.initComponent; | ||
exports.registerComponent = _components.registerComponent; | ||
exports.registerComponent = _components.registerComponent; | ||
exports.suffixCssClasses = _suffixCssClasses2.default; |
{ | ||
"name": "mjml-core", | ||
"description": "mjml-core", | ||
"version": "4.0.5", | ||
"version": "4.1.0-beta.1", | ||
"main": "lib/index.js", | ||
@@ -24,7 +24,7 @@ "repository": { | ||
"juice": "^4.1.0", | ||
"lodash": "^4.17.3", | ||
"mjml-migrate": "^4.0.5", | ||
"mjml-parser-xml": "^4.0.5", | ||
"mjml-validator": "^4.0.5" | ||
"lodash": "^4.17.2", | ||
"mjml-migrate": "^4.1.0-beta.1", | ||
"mjml-parser-xml": "^4.1.0-beta.1", | ||
"mjml-validator": "^4.1.0-beta.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
132250
47
2266
1
8
Updatedlodash@^4.17.2
Updatedmjml-migrate@^4.1.0-beta.1
Updatedmjml-validator@^4.1.0-beta.1