@readme/markdown 6.36.2 → 6.38.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.
@@ -63,9 +63,11 @@ class Image extends React.Component {
63
63
  }
64
64
 
65
65
  render() {
66
- const { alt } = this.props;
66
+ const { props } = this;
67
+ const { alt } = props;
68
+
67
69
  if (this.isEmoji) {
68
- return <img {...this.props} alt={alt} loading="lazy" />;
70
+ return <img {...props} alt={alt} loading="lazy" />;
69
71
  }
70
72
  return (
71
73
  <span
@@ -76,13 +78,8 @@ class Image extends React.Component {
76
78
  role={'button'}
77
79
  tabIndex={0}
78
80
  >
79
- <img {...this.props} alt={alt} />
80
- <Lightbox
81
- ref={this.lightbox}
82
- {...this.props}
83
- onScroll={() => this.toggle(false)}
84
- opened={this.state.lightbox}
85
- />
81
+ <img {...props} alt={alt} loading="lazy" />
82
+ <Lightbox ref={this.lightbox} {...props} onScroll={() => this.toggle(false)} opened={this.state.lightbox} />
86
83
  </span>
87
84
  );
88
85
  }
package/dist/main.js CHANGED
@@ -10026,10 +10026,11 @@ var Image = /*#__PURE__*/function (_React$Component) {
10026
10026
  value: function render() {
10027
10027
  var _this2 = this;
10028
10028
 
10029
- var alt = this.props.alt;
10029
+ var props = this.props;
10030
+ var alt = props.alt;
10030
10031
 
10031
10032
  if (this.isEmoji) {
10032
- return /*#__PURE__*/React.createElement("img", _extends({}, this.props, {
10033
+ return /*#__PURE__*/React.createElement("img", _extends({}, props, {
10033
10034
  alt: alt,
10034
10035
  loading: "lazy"
10035
10036
  }));
@@ -10044,11 +10045,12 @@ var Image = /*#__PURE__*/function (_React$Component) {
10044
10045
  onKeyDown: this.handleKey,
10045
10046
  role: 'button',
10046
10047
  tabIndex: 0
10047
- }, /*#__PURE__*/React.createElement("img", _extends({}, this.props, {
10048
- alt: alt
10048
+ }, /*#__PURE__*/React.createElement("img", _extends({}, props, {
10049
+ alt: alt,
10050
+ loading: "lazy"
10049
10051
  })), /*#__PURE__*/React.createElement(Lightbox, _extends({
10050
10052
  ref: this.lightbox
10051
- }, this.props, {
10053
+ }, props, {
10052
10054
  onScroll: function onScroll() {
10053
10055
  return _this2.toggle(false);
10054
10056
  },
@@ -27968,13 +27970,13 @@ module.exports = function CodeTabsCompiler() {
27968
27970
  /***/ 58:
27969
27971
  /***/ ((module) => {
27970
27972
 
27971
- /* div blocks directly alias the paragraph container; use for display only! */
27972
27973
  module.exports = function DivCompiler() {
27973
27974
  var Compiler = this.Compiler;
27974
27975
  var visitors = Compiler.prototype.visitors;
27975
27976
 
27976
27977
  visitors.div = function compile(node) {
27977
- return visitors.paragraph.call(this, node);
27978
+ var data = node.data.hProperties;
27979
+ return "\n[block:".concat(node.data.hName, "]\n").concat(JSON.stringify(data, null, 2), "\n[/block]\n");
27978
27980
  };
27979
27981
  };
27980
27982
 
@@ -28012,24 +28014,46 @@ module.exports = function () {
28012
28014
 
28013
28015
  var _slicedToArray = __webpack_require__(3038);
28014
28016
 
28017
+ var _defineProperty = __webpack_require__(9713);
28018
+
28019
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
28020
+
28021
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
28022
+
28015
28023
  var _require = __webpack_require__(7589),
28016
28024
  imgSizeByWidth = _require.imgSizeByWidth;
28017
28025
 
28026
+ var compileImage = function compileImage(image) {
28027
+ var img = _objectSpread(_objectSpread({
28028
+ image: [image.url, image.title]
28029
+ }, image.data.hProperties.width && {
28030
+ sizing: imgSizeByWidth[image.data.hProperties.width]
28031
+ }), image.border && {
28032
+ border: image.border
28033
+ });
28034
+
28035
+ return img;
28036
+ };
28037
+
28018
28038
  module.exports = function FigureCompiler() {
28019
28039
  var Compiler = this.Compiler;
28020
28040
  var visitors = Compiler.prototype.visitors;
28021
28041
 
28022
28042
  visitors.figure = function figureCompiler(node) {
28023
- var _node$children = _slicedToArray(node.children, 2),
28024
- image = _node$children[0],
28025
- caption = _node$children[1];
28026
-
28027
- var img = {
28028
- image: [image.url, image.title],
28029
- caption: this.block(caption),
28030
- sizing: imgSizeByWidth[image.data.hProperties.width]
28031
- };
28032
- if (image.border) img.border = image.border;
28043
+ var image;
28044
+ var caption;
28045
+
28046
+ if (node.children) {
28047
+ var _node$children = _slicedToArray(node.children, 2);
28048
+
28049
+ image = _node$children[0];
28050
+ caption = _node$children[1];
28051
+ } else {
28052
+ image = node;
28053
+ }
28054
+
28055
+ var img = compileImage(image);
28056
+ if (caption) img.caption = this.block(caption);
28033
28057
  var block = {
28034
28058
  images: [img]
28035
28059
  };
@@ -28076,16 +28100,17 @@ module.exports = function () {
28076
28100
  module.exports = function ImageCompiler() {
28077
28101
  var Compiler = this.Compiler;
28078
28102
  var visitors = Compiler.prototype.visitors;
28079
- var original = visitors.image;
28080
28103
 
28081
28104
  visitors.image = function compile(node) {
28082
- var _node$data, _node$data$hPropertie;
28105
+ var _node$data, _node$data$hPropertie, _visitors$figure;
28106
+
28107
+ if (((_node$data = node.data) === null || _node$data === void 0 ? void 0 : (_node$data$hPropertie = _node$data.hProperties) === null || _node$data$hPropertie === void 0 ? void 0 : _node$data$hPropertie.className) === 'emoji') return node.title;
28083
28108
 
28084
28109
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
28085
28110
  args[_key - 1] = arguments[_key];
28086
28111
  }
28087
28112
 
28088
- return ((_node$data = node.data) === null || _node$data === void 0 ? void 0 : (_node$data$hPropertie = _node$data.hProperties) === null || _node$data$hPropertie === void 0 ? void 0 : _node$data$hPropertie.className) === 'emoji' ? node.title : original.call.apply(original, [this, node].concat(args));
28113
+ return (_visitors$figure = visitors.figure).call.apply(_visitors$figure, [this, node].concat(args));
28089
28114
  };
28090
28115
  };
28091
28116
 
@@ -28584,10 +28609,10 @@ __webpack_require__.r(__webpack_exports__);
28584
28609
  /***/ 7589:
28585
28610
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
28586
28611
 
28587
- var _defineProperty = __webpack_require__(9713);
28588
-
28589
28612
  var _toConsumableArray = __webpack_require__(319);
28590
28613
 
28614
+ var _defineProperty = __webpack_require__(9713);
28615
+
28591
28616
  var _slicedToArray = __webpack_require__(3038);
28592
28617
 
28593
28618
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
@@ -28710,10 +28735,11 @@ function tokenize(eat, value) {
28710
28735
  title: title,
28711
28736
  alt: 'caption' in img ? img.caption : '',
28712
28737
  data: {
28713
- hProperties: {
28714
- className: img.border ? 'border' : '',
28738
+ hProperties: _objectSpread({
28739
+ className: img.border ? 'border' : ''
28740
+ }, img.sizing && {
28715
28741
  width: imgWidthBySize[img.sizing]
28716
- }
28742
+ })
28717
28743
  }
28718
28744
  };
28719
28745
  if (!img.caption) return block;
package/dist/main.node.js CHANGED
@@ -10026,10 +10026,11 @@ var Image = /*#__PURE__*/function (_React$Component) {
10026
10026
  value: function render() {
10027
10027
  var _this2 = this;
10028
10028
 
10029
- var alt = this.props.alt;
10029
+ var props = this.props;
10030
+ var alt = props.alt;
10030
10031
 
10031
10032
  if (this.isEmoji) {
10032
- return /*#__PURE__*/React.createElement("img", _extends({}, this.props, {
10033
+ return /*#__PURE__*/React.createElement("img", _extends({}, props, {
10033
10034
  alt: alt,
10034
10035
  loading: "lazy"
10035
10036
  }));
@@ -10044,11 +10045,12 @@ var Image = /*#__PURE__*/function (_React$Component) {
10044
10045
  onKeyDown: this.handleKey,
10045
10046
  role: 'button',
10046
10047
  tabIndex: 0
10047
- }, /*#__PURE__*/React.createElement("img", _extends({}, this.props, {
10048
- alt: alt
10048
+ }, /*#__PURE__*/React.createElement("img", _extends({}, props, {
10049
+ alt: alt,
10050
+ loading: "lazy"
10049
10051
  })), /*#__PURE__*/React.createElement(Lightbox, _extends({
10050
10052
  ref: this.lightbox
10051
- }, this.props, {
10053
+ }, props, {
10052
10054
  onScroll: function onScroll() {
10053
10055
  return _this2.toggle(false);
10054
10056
  },
@@ -10791,13 +10793,13 @@ module.exports = function CodeTabsCompiler() {
10791
10793
  /***/ 58:
10792
10794
  /***/ ((module) => {
10793
10795
 
10794
- /* div blocks directly alias the paragraph container; use for display only! */
10795
10796
  module.exports = function DivCompiler() {
10796
10797
  var Compiler = this.Compiler;
10797
10798
  var visitors = Compiler.prototype.visitors;
10798
10799
 
10799
10800
  visitors.div = function compile(node) {
10800
- return visitors.paragraph.call(this, node);
10801
+ var data = node.data.hProperties;
10802
+ return "\n[block:".concat(node.data.hName, "]\n").concat(JSON.stringify(data, null, 2), "\n[/block]\n");
10801
10803
  };
10802
10804
  };
10803
10805
 
@@ -10835,24 +10837,46 @@ module.exports = function () {
10835
10837
 
10836
10838
  var _slicedToArray = __webpack_require__(3038);
10837
10839
 
10840
+ var _defineProperty = __webpack_require__(9713);
10841
+
10842
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
10843
+
10844
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10845
+
10838
10846
  var _require = __webpack_require__(7589),
10839
10847
  imgSizeByWidth = _require.imgSizeByWidth;
10840
10848
 
10849
+ var compileImage = function compileImage(image) {
10850
+ var img = _objectSpread(_objectSpread({
10851
+ image: [image.url, image.title]
10852
+ }, image.data.hProperties.width && {
10853
+ sizing: imgSizeByWidth[image.data.hProperties.width]
10854
+ }), image.border && {
10855
+ border: image.border
10856
+ });
10857
+
10858
+ return img;
10859
+ };
10860
+
10841
10861
  module.exports = function FigureCompiler() {
10842
10862
  var Compiler = this.Compiler;
10843
10863
  var visitors = Compiler.prototype.visitors;
10844
10864
 
10845
10865
  visitors.figure = function figureCompiler(node) {
10846
- var _node$children = _slicedToArray(node.children, 2),
10847
- image = _node$children[0],
10848
- caption = _node$children[1];
10849
-
10850
- var img = {
10851
- image: [image.url, image.title],
10852
- caption: this.block(caption),
10853
- sizing: imgSizeByWidth[image.data.hProperties.width]
10854
- };
10855
- if (image.border) img.border = image.border;
10866
+ var image;
10867
+ var caption;
10868
+
10869
+ if (node.children) {
10870
+ var _node$children = _slicedToArray(node.children, 2);
10871
+
10872
+ image = _node$children[0];
10873
+ caption = _node$children[1];
10874
+ } else {
10875
+ image = node;
10876
+ }
10877
+
10878
+ var img = compileImage(image);
10879
+ if (caption) img.caption = this.block(caption);
10856
10880
  var block = {
10857
10881
  images: [img]
10858
10882
  };
@@ -10899,16 +10923,17 @@ module.exports = function () {
10899
10923
  module.exports = function ImageCompiler() {
10900
10924
  var Compiler = this.Compiler;
10901
10925
  var visitors = Compiler.prototype.visitors;
10902
- var original = visitors.image;
10903
10926
 
10904
10927
  visitors.image = function compile(node) {
10905
- var _node$data, _node$data$hPropertie;
10928
+ var _node$data, _node$data$hPropertie, _visitors$figure;
10929
+
10930
+ if (((_node$data = node.data) === null || _node$data === void 0 ? void 0 : (_node$data$hPropertie = _node$data.hProperties) === null || _node$data$hPropertie === void 0 ? void 0 : _node$data$hPropertie.className) === 'emoji') return node.title;
10906
10931
 
10907
10932
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
10908
10933
  args[_key - 1] = arguments[_key];
10909
10934
  }
10910
10935
 
10911
- return ((_node$data = node.data) === null || _node$data === void 0 ? void 0 : (_node$data$hPropertie = _node$data.hProperties) === null || _node$data$hPropertie === void 0 ? void 0 : _node$data$hPropertie.className) === 'emoji' ? node.title : original.call.apply(original, [this, node].concat(args));
10936
+ return (_visitors$figure = visitors.figure).call.apply(_visitors$figure, [this, node].concat(args));
10912
10937
  };
10913
10938
  };
10914
10939
 
@@ -11407,10 +11432,10 @@ __webpack_require__.r(__webpack_exports__);
11407
11432
  /***/ 7589:
11408
11433
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11409
11434
 
11410
- var _defineProperty = __webpack_require__(9713);
11411
-
11412
11435
  var _toConsumableArray = __webpack_require__(319);
11413
11436
 
11437
+ var _defineProperty = __webpack_require__(9713);
11438
+
11414
11439
  var _slicedToArray = __webpack_require__(3038);
11415
11440
 
11416
11441
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
@@ -11533,10 +11558,11 @@ function tokenize(eat, value) {
11533
11558
  title: title,
11534
11559
  alt: 'caption' in img ? img.caption : '',
11535
11560
  data: {
11536
- hProperties: {
11537
- className: img.border ? 'border' : '',
11561
+ hProperties: _objectSpread({
11562
+ className: img.border ? 'border' : ''
11563
+ }, img.sizing && {
11538
11564
  width: imgWidthBySize[img.sizing]
11539
- }
11565
+ })
11540
11566
  }
11541
11567
  };
11542
11568
  if (!img.caption) return block;
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.36.2",
5
+ "version": "6.38.0",
6
6
  "main": "dist/main.node.js",
7
7
  "browser": "dist/main.js",
8
8
  "files": [
@@ -23,7 +23,7 @@
23
23
  "start": "webpack serve --config ./webpack.dev.js --open --mode development",
24
24
  "sync": "rdme docs ./docs --version=2",
25
25
  "test": "jest --coverage --runInBand --testPathIgnorePatterns '__tests__/browser'",
26
- "test.watch": "jest --watch --coverage=false",
26
+ "test.watch": "jest --watch --coverage=false --testPathIgnorePatterns '__tests__/browser'",
27
27
  "test.browser": "jest --runInBand --testPathPattern '__tests__/browser'",
28
28
  "watch": "webpack -w --progress --mode production"
29
29
  },