mjml-text
Advanced tools
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
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
2
30966
4
65
1
0
+ Added@babel/runtime@7.25.7(transitive)
+ Addedansi-colors@4.1.3(transitive)
+ Addedcheerio@1.0.0-rc.12(transitive)
+ Addedcheerio-select@2.1.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcommander@2.20.36.2.1(transitive)
+ Addedcss-select@5.1.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddetect-node@2.1.0(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.1.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-goat@3.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedhtml-minifier@4.0.0(transitive)
+ Addedhtmlparser2@5.0.18.0.29.1.0(transitive)
+ Addedjuice@10.0.1(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedmjml-core@4.15.3(transitive)
+ Addedmjml-migrate@4.15.3(transitive)
+ Addedmjml-parser-xml@4.15.3(transitive)
+ Addedmjml-validator@4.15.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedparse5@7.1.2(transitive)
+ Addedparse5-htmlparser2-tree-adapter@7.0.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedvalid-data-url@3.0.1(transitive)
+ Addedweb-resource-inliner@6.0.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedclassnames@^2.2.5
- Removedreact@^15.4.2
- Removedajv@6.12.6(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedasap@2.0.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasync@3.2.6(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcheerio@0.22.0(transitive)
- Removedclassnames@2.5.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.17.12.19.0(transitive)
- Removedcore-js@1.2.7(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcreate-react-class@15.7.0(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedcss-select@1.2.0(transitive)
- Removedcss-what@2.1.3(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddatauri@2.0.0(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddeep-extend@0.5.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddom-serializer@0.1.1(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.5.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedencoding@0.1.13(transitive)
- Removedentities@1.1.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfbjs@0.8.18(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhoist-non-react-statics@1.2.0(transitive)
- Removedhtml-minifier@3.5.21(transitive)
- Removedhtmlparser2@3.10.14.1.0(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedimage-size@0.7.5(transitive)
- Removedimmutable@3.8.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjquery@3.7.1(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedjuice@4.3.2(transitive)
- Removedlodash.assignin@4.2.0(transitive)
- Removedlodash.bind@4.2.1(transitive)
- Removedlodash.defaults@4.2.0(transitive)
- Removedlodash.filter@4.6.0(transitive)
- Removedlodash.flatten@4.4.0(transitive)
- Removedlodash.foreach@4.5.0(transitive)
- Removedlodash.map@4.6.0(transitive)
- Removedlodash.merge@4.6.2(transitive)
- Removedlodash.pick@4.4.0(transitive)
- Removedlodash.reduce@4.6.0(transitive)
- Removedlodash.reject@4.6.0(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedlodash.unescape@4.0.1(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmimer@1.1.1(transitive)
- Removedmjml-core@3.3.5(transitive)
- Removedmjml-validator@3.3.5(transitive)
- Removedms@2.0.0(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removednth-check@1.0.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpromise@7.3.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedreact@15.7.0(transitive)
- Removedreact-dom@15.7.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedua-parser-js@0.7.39(transitive)
- Removeduglify-js@3.4.10(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedvalid-data-url@2.0.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedwarning@3.0.0(transitive)
- Removedweb-resource-inliner@4.3.4(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)
- Removedwhich@1.3.1(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updatedlodash@^4.17.2
Updatedmjml-core@^4.0.0-alpha.1