@readme/markdown 6.52.2 → 6.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ Favicon.propTypes = {
10
10
 
11
11
  class Embed extends React.Component {
12
12
  render() {
13
- const { provider, url, title, html, iframe, image, favicon, ...attrs } = this.props;
13
+ const { lazy = true, provider, url, title, html, iframe, image, favicon, ...attrs } = this.props;
14
14
 
15
15
  if (!url) {
16
16
  return <div />;
@@ -27,14 +27,14 @@ class Embed extends React.Component {
27
27
  <div className="embed-media" dangerouslySetInnerHTML={{ __html: html }}></div>
28
28
  ) : (
29
29
  <a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
30
- {!image || <img alt={title} className="embed-img" loading="lazy" src={image} />}
30
+ {!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : ''} src={image} />}
31
31
  {title ? (
32
32
  <div className="embed-body">
33
33
  {!favicon || (
34
34
  <Favicon
35
35
  alt={provider}
36
36
  className="embed-favicon"
37
- loading="lazy"
37
+ loading={lazy ? 'lazy' : ''}
38
38
  src={favicon}
39
39
  style={{ float: 'left' }}
40
40
  />
@@ -69,6 +69,7 @@ Embed.propTypes = {
69
69
  html: propTypes.string,
70
70
  iframe: propTypes.any,
71
71
  image: propTypes.string,
72
+ lazy: propTypes.bool,
72
73
  provider: propTypes.string,
73
74
  title: propTypes.string,
74
75
  url: propTypes.oneOfType([propTypes.string, propTypes.shape({})]),
@@ -79,4 +80,10 @@ Embed.defaultProps = {
79
80
  width: '100%',
80
81
  };
81
82
 
82
- module.exports = Embed;
83
+ const CreateEmbed =
84
+ ({ lazyImages }) =>
85
+ // eslint-disable-next-line react/display-name
86
+ props =>
87
+ <Embed {...props} lazy={lazyImages} />;
88
+
89
+ module.exports = CreateEmbed;
@@ -64,11 +64,12 @@ class Image extends React.Component {
64
64
 
65
65
  render() {
66
66
  const { props } = this;
67
- const { alt } = props;
67
+ const { alt, lazy = true } = props;
68
68
 
69
69
  if (this.isEmoji) {
70
- return <img {...props} alt={alt} loading="lazy" />;
70
+ return <img {...props} alt={alt} loading={lazy ? 'lazy' : ''} />;
71
71
  }
72
+
72
73
  return (
73
74
  <span
74
75
  aria-label={alt}
@@ -78,7 +79,7 @@ class Image extends React.Component {
78
79
  role={'button'}
79
80
  tabIndex={0}
80
81
  >
81
- <img {...props} alt={alt} loading="lazy" />
82
+ <img {...props} alt={alt} loading={lazy ? 'lazy' : ''} />
82
83
  <Lightbox ref={this.lightbox} {...props} onScroll={() => this.toggle(false)} opened={this.state.lightbox} />
83
84
  </span>
84
85
  );
@@ -91,6 +92,7 @@ Image.propTypes = {
91
92
  caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
92
93
  className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
93
94
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
95
+ lazy: PropTypes.bool,
94
96
  src: PropTypes.string.isRequired,
95
97
  title: PropTypes.string,
96
98
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -112,4 +114,10 @@ Image.sanitize = sanitizeSchema => {
112
114
  return sanitizeSchema;
113
115
  };
114
116
 
115
- module.exports = Image;
117
+ const CreateImage =
118
+ ({ lazyImages }) =>
119
+ // eslint-disable-next-line react/display-name
120
+ props =>
121
+ <Image lazy={lazyImages} {...props} />;
122
+
123
+ module.exports = CreateImage;
package/dist/main.js CHANGED
@@ -9505,7 +9505,7 @@ var _extends = __webpack_require__(7154);
9505
9505
  var _objectWithoutProperties = __webpack_require__(6479);
9506
9506
 
9507
9507
  var _excluded = ["src", "alt"],
9508
- _excluded2 = ["provider", "url", "title", "html", "iframe", "image", "favicon"];
9508
+ _excluded2 = ["lazy", "provider", "url", "title", "html", "iframe", "image", "favicon"];
9509
9509
 
9510
9510
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9511
9511
 
@@ -9552,6 +9552,8 @@ var Embed = /*#__PURE__*/function (_React$Component) {
9552
9552
  key: "render",
9553
9553
  value: function render() {
9554
9554
  var _this$props = this.props,
9555
+ _this$props$lazy = _this$props.lazy,
9556
+ lazy = _this$props$lazy === void 0 ? true : _this$props$lazy,
9555
9557
  provider = _this$props.provider,
9556
9558
  url = _this$props.url,
9557
9559
  title = _this$props.title,
@@ -9591,14 +9593,14 @@ var Embed = /*#__PURE__*/function (_React$Component) {
9591
9593
  }, !image || /*#__PURE__*/React.createElement("img", {
9592
9594
  alt: title,
9593
9595
  className: "embed-img",
9594
- loading: "lazy",
9596
+ loading: lazy ? 'lazy' : '',
9595
9597
  src: image
9596
9598
  }), title ? /*#__PURE__*/React.createElement("div", {
9597
9599
  className: "embed-body"
9598
9600
  }, !favicon || /*#__PURE__*/React.createElement(Favicon, {
9599
9601
  alt: provider,
9600
9602
  className: "embed-favicon",
9601
- loading: "lazy",
9603
+ loading: lazy ? 'lazy' : '',
9602
9604
  src: favicon,
9603
9605
  style: {
9604
9606
  float: 'left'
@@ -9629,6 +9631,7 @@ Embed.propTypes = {
9629
9631
  html: propTypes.string,
9630
9632
  iframe: propTypes.any,
9631
9633
  image: propTypes.string,
9634
+ lazy: propTypes.bool,
9632
9635
  provider: propTypes.string,
9633
9636
  title: propTypes.string,
9634
9637
  url: propTypes.oneOfType([propTypes.string, propTypes.shape({})]),
@@ -9638,7 +9641,19 @@ Embed.defaultProps = {
9638
9641
  height: '300px',
9639
9642
  width: '100%'
9640
9643
  };
9641
- module.exports = Embed;
9644
+
9645
+ var CreateEmbed = function CreateEmbed(_ref2) {
9646
+ var lazyImages = _ref2.lazyImages;
9647
+ return (// eslint-disable-next-line react/display-name
9648
+ function (props) {
9649
+ return /*#__PURE__*/React.createElement(Embed, _extends({}, props, {
9650
+ lazy: lazyImages
9651
+ }));
9652
+ }
9653
+ );
9654
+ };
9655
+
9656
+ module.exports = CreateEmbed;
9642
9657
 
9643
9658
  /***/ }),
9644
9659
 
@@ -10077,12 +10092,14 @@ var Image = /*#__PURE__*/function (_React$Component) {
10077
10092
  var _this2 = this;
10078
10093
 
10079
10094
  var props = this.props;
10080
- var alt = props.alt;
10095
+ var alt = props.alt,
10096
+ _props$lazy = props.lazy,
10097
+ lazy = _props$lazy === void 0 ? true : _props$lazy;
10081
10098
 
10082
10099
  if (this.isEmoji) {
10083
10100
  return /*#__PURE__*/React.createElement("img", _extends({}, props, {
10084
10101
  alt: alt,
10085
- loading: "lazy"
10102
+ loading: lazy ? 'lazy' : ''
10086
10103
  }));
10087
10104
  }
10088
10105
 
@@ -10097,7 +10114,7 @@ var Image = /*#__PURE__*/function (_React$Component) {
10097
10114
  tabIndex: 0
10098
10115
  }, /*#__PURE__*/React.createElement("img", _extends({}, props, {
10099
10116
  alt: alt,
10100
- loading: "lazy"
10117
+ loading: lazy ? 'lazy' : ''
10101
10118
  })), /*#__PURE__*/React.createElement(Lightbox, _extends({
10102
10119
  ref: this.lightbox
10103
10120
  }, props, {
@@ -10118,6 +10135,7 @@ Image.propTypes = {
10118
10135
  caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
10119
10136
  className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
10120
10137
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
10138
+ lazy: PropTypes.bool,
10121
10139
  src: PropTypes.string.isRequired,
10122
10140
  title: PropTypes.string,
10123
10141
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
@@ -10137,7 +10155,18 @@ Image.sanitize = function (sanitizeSchema) {
10137
10155
  return sanitizeSchema;
10138
10156
  };
10139
10157
 
10140
- module.exports = Image;
10158
+ var CreateImage = function CreateImage(_ref) {
10159
+ var lazyImages = _ref.lazyImages;
10160
+ return (// eslint-disable-next-line react/display-name
10161
+ function (props) {
10162
+ return /*#__PURE__*/React.createElement(Image, _extends({
10163
+ lazy: lazyImages
10164
+ }, props));
10165
+ }
10166
+ );
10167
+ };
10168
+
10169
+ module.exports = CreateImage;
10141
10170
 
10142
10171
  /***/ }),
10143
10172
 
@@ -27963,6 +27992,7 @@ var options = {
27963
27992
  spacedTable: true,
27964
27993
  paddedTable: true
27965
27994
  },
27995
+ lazyImages: true,
27966
27996
  normalize: true,
27967
27997
  safeMode: false,
27968
27998
  settings: {
@@ -52351,7 +52381,7 @@ function reactProcessor() {
52351
52381
  'rdme-callout': Callout,
52352
52382
  'readme-variable': Variable,
52353
52383
  'readme-glossary-item': GlossaryItem,
52354
- 'rdme-embed': Embed,
52384
+ 'rdme-embed': Embed(opts),
52355
52385
  'rdme-pin': PinWrap,
52356
52386
  table: Table,
52357
52387
  a: Anchor,
@@ -52362,7 +52392,7 @@ function reactProcessor() {
52362
52392
  h5: Heading(5, count, opts),
52363
52393
  h6: Heading(6, count, opts),
52364
52394
  code: Code(opts),
52365
- img: Image,
52395
+ img: Image(opts),
52366
52396
  style: Style(opts)
52367
52397
  }, registerCustomComponents(components, sanitize, opts.customComponentPrefix))
52368
52398
  });
package/dist/main.node.js CHANGED
@@ -9505,7 +9505,7 @@ var _extends = __webpack_require__(7154);
9505
9505
  var _objectWithoutProperties = __webpack_require__(6479);
9506
9506
 
9507
9507
  var _excluded = ["src", "alt"],
9508
- _excluded2 = ["provider", "url", "title", "html", "iframe", "image", "favicon"];
9508
+ _excluded2 = ["lazy", "provider", "url", "title", "html", "iframe", "image", "favicon"];
9509
9509
 
9510
9510
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9511
9511
 
@@ -9552,6 +9552,8 @@ var Embed = /*#__PURE__*/function (_React$Component) {
9552
9552
  key: "render",
9553
9553
  value: function render() {
9554
9554
  var _this$props = this.props,
9555
+ _this$props$lazy = _this$props.lazy,
9556
+ lazy = _this$props$lazy === void 0 ? true : _this$props$lazy,
9555
9557
  provider = _this$props.provider,
9556
9558
  url = _this$props.url,
9557
9559
  title = _this$props.title,
@@ -9591,14 +9593,14 @@ var Embed = /*#__PURE__*/function (_React$Component) {
9591
9593
  }, !image || /*#__PURE__*/React.createElement("img", {
9592
9594
  alt: title,
9593
9595
  className: "embed-img",
9594
- loading: "lazy",
9596
+ loading: lazy ? 'lazy' : '',
9595
9597
  src: image
9596
9598
  }), title ? /*#__PURE__*/React.createElement("div", {
9597
9599
  className: "embed-body"
9598
9600
  }, !favicon || /*#__PURE__*/React.createElement(Favicon, {
9599
9601
  alt: provider,
9600
9602
  className: "embed-favicon",
9601
- loading: "lazy",
9603
+ loading: lazy ? 'lazy' : '',
9602
9604
  src: favicon,
9603
9605
  style: {
9604
9606
  float: 'left'
@@ -9629,6 +9631,7 @@ Embed.propTypes = {
9629
9631
  html: propTypes.string,
9630
9632
  iframe: propTypes.any,
9631
9633
  image: propTypes.string,
9634
+ lazy: propTypes.bool,
9632
9635
  provider: propTypes.string,
9633
9636
  title: propTypes.string,
9634
9637
  url: propTypes.oneOfType([propTypes.string, propTypes.shape({})]),
@@ -9638,7 +9641,19 @@ Embed.defaultProps = {
9638
9641
  height: '300px',
9639
9642
  width: '100%'
9640
9643
  };
9641
- module.exports = Embed;
9644
+
9645
+ var CreateEmbed = function CreateEmbed(_ref2) {
9646
+ var lazyImages = _ref2.lazyImages;
9647
+ return (// eslint-disable-next-line react/display-name
9648
+ function (props) {
9649
+ return /*#__PURE__*/React.createElement(Embed, _extends({}, props, {
9650
+ lazy: lazyImages
9651
+ }));
9652
+ }
9653
+ );
9654
+ };
9655
+
9656
+ module.exports = CreateEmbed;
9642
9657
 
9643
9658
  /***/ }),
9644
9659
 
@@ -10077,12 +10092,14 @@ var Image = /*#__PURE__*/function (_React$Component) {
10077
10092
  var _this2 = this;
10078
10093
 
10079
10094
  var props = this.props;
10080
- var alt = props.alt;
10095
+ var alt = props.alt,
10096
+ _props$lazy = props.lazy,
10097
+ lazy = _props$lazy === void 0 ? true : _props$lazy;
10081
10098
 
10082
10099
  if (this.isEmoji) {
10083
10100
  return /*#__PURE__*/React.createElement("img", _extends({}, props, {
10084
10101
  alt: alt,
10085
- loading: "lazy"
10102
+ loading: lazy ? 'lazy' : ''
10086
10103
  }));
10087
10104
  }
10088
10105
 
@@ -10097,7 +10114,7 @@ var Image = /*#__PURE__*/function (_React$Component) {
10097
10114
  tabIndex: 0
10098
10115
  }, /*#__PURE__*/React.createElement("img", _extends({}, props, {
10099
10116
  alt: alt,
10100
- loading: "lazy"
10117
+ loading: lazy ? 'lazy' : ''
10101
10118
  })), /*#__PURE__*/React.createElement(Lightbox, _extends({
10102
10119
  ref: this.lightbox
10103
10120
  }, props, {
@@ -10118,6 +10135,7 @@ Image.propTypes = {
10118
10135
  caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
10119
10136
  className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
10120
10137
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
10138
+ lazy: PropTypes.bool,
10121
10139
  src: PropTypes.string.isRequired,
10122
10140
  title: PropTypes.string,
10123
10141
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
@@ -10137,7 +10155,18 @@ Image.sanitize = function (sanitizeSchema) {
10137
10155
  return sanitizeSchema;
10138
10156
  };
10139
10157
 
10140
- module.exports = Image;
10158
+ var CreateImage = function CreateImage(_ref) {
10159
+ var lazyImages = _ref.lazyImages;
10160
+ return (// eslint-disable-next-line react/display-name
10161
+ function (props) {
10162
+ return /*#__PURE__*/React.createElement(Image, _extends({
10163
+ lazy: lazyImages
10164
+ }, props));
10165
+ }
10166
+ );
10167
+ };
10168
+
10169
+ module.exports = CreateImage;
10141
10170
 
10142
10171
  /***/ }),
10143
10172
 
@@ -10785,6 +10814,7 @@ var options = {
10785
10814
  spacedTable: true,
10786
10815
  paddedTable: true
10787
10816
  },
10817
+ lazyImages: true,
10788
10818
  normalize: true,
10789
10819
  safeMode: false,
10790
10820
  settings: {
@@ -34696,7 +34726,7 @@ function reactProcessor() {
34696
34726
  'rdme-callout': Callout,
34697
34727
  'readme-variable': Variable,
34698
34728
  'readme-glossary-item': GlossaryItem,
34699
- 'rdme-embed': Embed,
34729
+ 'rdme-embed': Embed(opts),
34700
34730
  'rdme-pin': PinWrap,
34701
34731
  table: Table,
34702
34732
  a: Anchor,
@@ -34707,7 +34737,7 @@ function reactProcessor() {
34707
34737
  h5: Heading(5, count, opts),
34708
34738
  h6: Heading(6, count, opts),
34709
34739
  code: Code(opts),
34710
- img: Image,
34740
+ img: Image(opts),
34711
34741
  style: Style(opts)
34712
34742
  }, registerCustomComponents(components, sanitize, opts.customComponentPrefix))
34713
34743
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@readme/markdown",
3
3
  "description": "ReadMe's React-based Markdown parser",
4
4
  "author": "Rafe Goldberg <rafe@readme.io>",
5
- "version": "6.52.2",
5
+ "version": "6.53.0",
6
6
  "main": "dist/main.node.js",
7
7
  "browser": "dist/main.js",
8
8
  "files": [