Socket
Socket
Sign inDemoInstall

mjml-text

Package Overview
Dependencies
Maintainers
4
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mjml-text - npm Package Compare versions

Comparing version 3.3.3-beta.2 to 4.0.0-alpha.1

185

lib/index.js

@@ -7,138 +7,67 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createComponent = require('mjml-core/lib/createComponent');
var _class;
var _conditionalTag = require('mjml-core/lib/helpers/conditionalTag');
var _mjmlCore = require('mjml-core');
var _conditionalTag2 = _interopRequireDefault(_conditionalTag);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var tagName = 'mj-text';
var parentTag = ['mj-column', 'mj-hero-content'];
var endingTag = true;
var defaultMJMLDefinition = {
content: '',
attributes: {
'align': 'left',
'color': '#000000',
'container-background-color': null,
exports.default = (0, _createComponent.createBodyComponent)('mj-text', {
endingTag: true,
allowedAttributes: {
'align': 'enum(left,right,center)',
'background-color': 'color',
'color': 'color',
'font-family': 'string',
'font-size': 'unit(px,%)',
'font-style': 'string',
'font-weight': 'string',
'height': 'unit(px,%)',
'letter-spacing': 'unit(px,%)',
'line-height': 'unit(px,%)',
'padding-bottom': 'unit(px,%)',
'padding-left': 'unit(px,%)',
'padding-right': 'unit(px,%)',
'padding-top': 'unit(px,%)',
'padding': 'unit(px,%){1,4}',
'text-decoration': 'string',
'text-transform': 'string',
'vertical-align': 'string'
},
defaultAttributes: {
align: 'left',
color: '#000000',
'font-family': 'Ubuntu, Helvetica, Arial, sans-serif',
'font-size': '13px',
'font-style': null,
'font-weight': null,
'line-height': '22px',
'letter-spacing': null,
'height': null,
'padding-bottom': null,
'padding-left': null,
'padding-right': null,
'padding-top': null,
'padding': '10px 25px',
'text-decoration': null,
'text-transform': null,
'vertical-align': null,
'css-class': ''
}
};
var baseStyles = {
div: {
cursor: 'auto'
}
};
'line-height': '1',
'padding': '10px 25px'
},
getStyles: function getStyles() {
return {
text: {
'font-family': this.getMjAttribute('font-family'),
'font-size': this.getMjAttribute('font-size'),
'font-weight': this.getMjAttribute('font-weight'),
'letter-spacing': this.getMjAttribute('letter-spacing'),
'line-height': this.getMjAttribute('line-height'),
'text-align': this.getMjAttribute('align'),
'text-decoration': this.getMjAttribute('text-decoration'),
'text-transform': this.getMjAttribute('text-transform'),
'color': this.getMjAttribute('color'),
'height': this.getMjAttribute('height')
}
};
},
renderContent: function renderContent() {
return '\n <div\n ' + this.generateHtmlAttributes({
style: 'text'
}) + '\n >\n ' + this.getMjContent() + '\n </div>\n ';
},
render: function render() {
var height = this.getMjAttribute('height');
var postRender = function postRender($) {
$('.mj-text-height').each(function () {
var height = parseInt($(this).css('height'));
$(_mjmlCore.helpers.startConditionalTag + '\n <table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td height="' + height + '" style="vertical-align:top;height:' + height + 'px;">\n ' + _mjmlCore.helpers.endConditionalTag).insertBefore($(this));
$(_mjmlCore.helpers.startConditionalTag + '\n </td></tr></table>\n ' + _mjmlCore.helpers.endConditionalTag).insertAfter($(this));
$(this).removeClass('mj-text-height').filter('[class=""]').removeAttr('class');
});
return $;
};
var Text = (0, _mjmlCore.MJMLElement)(_class = function (_Component) {
_inherits(Text, _Component);
function Text() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Text);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Text.__proto__ || Object.getPrototypeOf(Text)).call.apply(_ref, [this].concat(args))), _this), _this.styles = _this.getStyles(), _temp), _possibleConstructorReturn(_this, _ret);
return height ? '\n ' + (0, _conditionalTag2.default)('\n <table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td height="' + height + '" style="vertical-align:top;height:' + height + 'px;">\n ') + '\n ' + this.renderContent() + '\n ' + (0, _conditionalTag2.default)('\n </td></tr></table>\n ') + '\n ' : this.renderContent();
}
_createClass(Text, [{
key: 'getStyles',
value: function getStyles() {
var _props = this.props,
mjAttribute = _props.mjAttribute,
defaultUnit = _props.defaultUnit;
return _mjmlCore.helpers.merge({}, baseStyles, {
div: {
color: mjAttribute('color'),
fontFamily: mjAttribute('font-family'),
fontSize: defaultUnit(mjAttribute('font-size')),
fontStyle: mjAttribute('font-style'),
fontWeight: mjAttribute('font-weight'),
lineHeight: mjAttribute('line-height'),
letterSpacing: defaultUnit(mjAttribute('letter-spacing'), "px"),
height: defaultUnit(mjAttribute('height'), "px"),
textAlign: mjAttribute('align'),
textDecoration: mjAttribute('text-decoration'),
textTransform: mjAttribute('text-transform')
}
});
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
mjAttribute = _props2.mjAttribute,
mjContent = _props2.mjContent;
var classNames = (0, _classnames2.default)(mjAttribute('height') ? 'mj-text-height' : '');
return _react2.default.createElement('div', {
className: classNames,
dangerouslySetInnerHTML: { __html: mjContent() },
style: this.styles.div });
}
}]);
return Text;
}(_react.Component)) || _class;
Text.tagName = tagName;
Text.parentTag = parentTag;
Text.endingTag = endingTag;
Text.defaultMJMLDefinition = defaultMJMLDefinition;
Text.baseStyles = baseStyles;
Text.postRender = postRender;
exports.default = Text;
});
module.exports = exports['default'];
{
"name": "mjml-text",
"description": "mjml-text",
"version": "3.3.3-beta.2",
"version": "4.0.0-alpha.1",
"main": "lib/index.js",

@@ -15,8 +15,10 @@ "repository": {

"homepage": "https://mjml.io",
"scripts": {
"clean": "../../node_modules/.bin/rimraf lib",
"build": "../../node_modules/.bin/babel src --out-dir lib"
},
"dependencies": {
"classnames": "^2.2.5",
"lodash": "^4.17.4",
"mjml-core": "~3.3.3-beta.2",
"react": "^15.4.2"
"lodash": "^4.17.2",
"mjml-core": "^4.0.0-alpha.1"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc