@superinterface/react 3.21.0 → 3.21.1

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.
package/dist/index.cjs CHANGED
@@ -42454,11 +42454,10 @@ var remarkAnnotation = function(_ref2) {
42454
42454
  node: node,
42455
42455
  content: content2
42456
42456
  });
42457
- } else {
42458
- return [
42459
- node
42460
- ];
42461
42457
  }
42458
+ return [
42459
+ node
42460
+ ];
42462
42461
  });
42463
42462
  };
42464
42463
  };
@@ -42466,12 +42465,7 @@ var remarkAnnotation = function(_ref2) {
42466
42465
  var processNodeWithAnnotations = function(_ref3) {
42467
42466
  var _content$text;
42468
42467
  var node = _ref3.node, content2 = _ref3.content;
42469
- if (!((_content$text = content2.text) !== null && _content$text !== void 0 && (_content$text = _content$text.annotations) !== null && _content$text !== void 0 && _content$text.length)) {
42470
- return [
42471
- node
42472
- ];
42473
- }
42474
- if (!node.position) {
42468
+ if (!((_content$text = content2.text) !== null && _content$text !== void 0 && (_content$text = _content$text.annotations) !== null && _content$text !== void 0 && _content$text.length) || !node.position) {
42475
42469
  return [
42476
42470
  node
42477
42471
  ];
@@ -42486,21 +42480,76 @@ var processNodeWithAnnotations = function(_ref3) {
42486
42480
  });
42487
42481
  } else if (node.type === "link") {
42488
42482
  var linkNode = node;
42489
- linkNode.children = (0, import_unist_util_flatmap.default)(linkNode.children, function(childNode) {
42490
- if (childNode.type === "text") {
42483
+ linkNode.children = (0, import_unist_util_flatmap.default)(linkNode.children, function(child2) {
42484
+ if (child2.type === "text") {
42491
42485
  return processTextNode({
42492
- node: childNode,
42486
+ node: child2,
42493
42487
  annotations: annotations
42494
42488
  });
42495
- } else {
42496
- return [
42497
- childNode
42498
- ];
42499
42489
  }
42490
+ return [
42491
+ child2
42492
+ ];
42500
42493
  });
42501
- return [
42494
+ if (!linkNode.position) return [
42502
42495
  linkNode
42503
42496
  ];
42497
+ var labelLength = 0;
42498
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
42499
+ try {
42500
+ for(var _iterator = linkNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
42501
+ var child = _step.value;
42502
+ if (child.type === "text" && typeof child.value === "string") {
42503
+ labelLength += child.value.length;
42504
+ }
42505
+ }
42506
+ } catch (err) {
42507
+ _didIteratorError = true;
42508
+ _iteratorError = err;
42509
+ } finally{
42510
+ try {
42511
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
42512
+ _iterator.return();
42513
+ }
42514
+ } finally{
42515
+ if (_didIteratorError) {
42516
+ throw _iteratorError;
42517
+ }
42518
+ }
42519
+ }
42520
+ var linkStart = linkNode.position.start.offset;
42521
+ var urlStartOffset = linkStart + 1 + labelLength + 1 + 1;
42522
+ var urlEndOffset = linkNode.position.end.offset - 1;
42523
+ var matchingURLAnnotations = annotations.filter(function(annotation2) {
42524
+ return annotation2.start_index >= urlStartOffset && annotation2.end_index <= urlEndOffset;
42525
+ });
42526
+ if (matchingURLAnnotations.length > 0) {
42527
+ var annotation = matchingURLAnnotations[0];
42528
+ var newAnnotationNode = {
42529
+ type: "annotation",
42530
+ value: linkNode.url,
42531
+ children: linkNode.children,
42532
+ position: {
42533
+ start: _objectSpread23(_objectSpread23({}, linkNode.position.start), {}, {
42534
+ offset: urlStartOffset
42535
+ }),
42536
+ end: _objectSpread23(_objectSpread23({}, linkNode.position.end), {}, {
42537
+ offset: urlEndOffset
42538
+ })
42539
+ },
42540
+ data: {
42541
+ hName: "annotation",
42542
+ hProperties: _define_property({}, "data-annotation", JSON.stringify(annotation))
42543
+ }
42544
+ };
42545
+ return [
42546
+ newAnnotationNode
42547
+ ];
42548
+ } else {
42549
+ return [
42550
+ linkNode
42551
+ ];
42552
+ }
42504
42553
  } else {
42505
42554
  return [
42506
42555
  node
@@ -42509,26 +42558,20 @@ var processNodeWithAnnotations = function(_ref3) {
42509
42558
  };
42510
42559
  var processTextNode = function(_ref4) {
42511
42560
  var node = _ref4.node, annotations = _ref4.annotations;
42512
- if (!node.position || !node.value) {
42513
- return [
42514
- node
42515
- ];
42516
- }
42561
+ if (!node.position || !node.value) return [
42562
+ node
42563
+ ];
42517
42564
  var nodeStart = node.position.start.offset;
42518
42565
  var nodeEnd = node.position.end.offset;
42519
- if (!(0, import_radash11.isNumber)(nodeStart) || !(0, import_radash11.isNumber)(nodeEnd)) {
42520
- return [
42521
- node
42522
- ];
42523
- }
42566
+ if (!(0, import_radash11.isNumber)(nodeStart) || !(0, import_radash11.isNumber)(nodeEnd)) return [
42567
+ node
42568
+ ];
42524
42569
  var newNodes = [];
42525
42570
  var lastIndex = nodeStart;
42526
42571
  annotations.forEach(function(annotation) {
42527
42572
  var annotationStart = annotation.start_index;
42528
42573
  var annotationEnd = annotation.end_index;
42529
- if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) {
42530
- return;
42531
- }
42574
+ if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) return;
42532
42575
  var start = Math.max(nodeStart, annotationStart);
42533
42576
  var end = Math.min(nodeEnd, annotationEnd);
42534
42577
  if (lastIndex < start) {