@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.js CHANGED
@@ -42323,11 +42323,10 @@ var remarkAnnotation = function(_ref2) {
42323
42323
  node: node,
42324
42324
  content: content2
42325
42325
  });
42326
- } else {
42327
- return [
42328
- node
42329
- ];
42330
42326
  }
42327
+ return [
42328
+ node
42329
+ ];
42331
42330
  });
42332
42331
  };
42333
42332
  };
@@ -42335,12 +42334,7 @@ var remarkAnnotation = function(_ref2) {
42335
42334
  var processNodeWithAnnotations = function(_ref3) {
42336
42335
  var _content$text;
42337
42336
  var node = _ref3.node, content2 = _ref3.content;
42338
- if (!((_content$text = content2.text) !== null && _content$text !== void 0 && (_content$text = _content$text.annotations) !== null && _content$text !== void 0 && _content$text.length)) {
42339
- return [
42340
- node
42341
- ];
42342
- }
42343
- if (!node.position) {
42337
+ 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) {
42344
42338
  return [
42345
42339
  node
42346
42340
  ];
@@ -42355,21 +42349,76 @@ var processNodeWithAnnotations = function(_ref3) {
42355
42349
  });
42356
42350
  } else if (node.type === "link") {
42357
42351
  var linkNode = node;
42358
- linkNode.children = flatMap(linkNode.children, function(childNode) {
42359
- if (childNode.type === "text") {
42352
+ linkNode.children = flatMap(linkNode.children, function(child2) {
42353
+ if (child2.type === "text") {
42360
42354
  return processTextNode({
42361
- node: childNode,
42355
+ node: child2,
42362
42356
  annotations: annotations
42363
42357
  });
42364
- } else {
42365
- return [
42366
- childNode
42367
- ];
42368
42358
  }
42359
+ return [
42360
+ child2
42361
+ ];
42369
42362
  });
42370
- return [
42363
+ if (!linkNode.position) return [
42371
42364
  linkNode
42372
42365
  ];
42366
+ var labelLength = 0;
42367
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
42368
+ try {
42369
+ for(var _iterator = linkNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
42370
+ var child = _step.value;
42371
+ if (child.type === "text" && typeof child.value === "string") {
42372
+ labelLength += child.value.length;
42373
+ }
42374
+ }
42375
+ } catch (err) {
42376
+ _didIteratorError = true;
42377
+ _iteratorError = err;
42378
+ } finally{
42379
+ try {
42380
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
42381
+ _iterator.return();
42382
+ }
42383
+ } finally{
42384
+ if (_didIteratorError) {
42385
+ throw _iteratorError;
42386
+ }
42387
+ }
42388
+ }
42389
+ var linkStart = linkNode.position.start.offset;
42390
+ var urlStartOffset = linkStart + 1 + labelLength + 1 + 1;
42391
+ var urlEndOffset = linkNode.position.end.offset - 1;
42392
+ var matchingURLAnnotations = annotations.filter(function(annotation2) {
42393
+ return annotation2.start_index >= urlStartOffset && annotation2.end_index <= urlEndOffset;
42394
+ });
42395
+ if (matchingURLAnnotations.length > 0) {
42396
+ var annotation = matchingURLAnnotations[0];
42397
+ var newAnnotationNode = {
42398
+ type: "annotation",
42399
+ value: linkNode.url,
42400
+ children: linkNode.children,
42401
+ position: {
42402
+ start: _objectSpread23(_objectSpread23({}, linkNode.position.start), {}, {
42403
+ offset: urlStartOffset
42404
+ }),
42405
+ end: _objectSpread23(_objectSpread23({}, linkNode.position.end), {}, {
42406
+ offset: urlEndOffset
42407
+ })
42408
+ },
42409
+ data: {
42410
+ hName: "annotation",
42411
+ hProperties: _define_property({}, "data-annotation", JSON.stringify(annotation))
42412
+ }
42413
+ };
42414
+ return [
42415
+ newAnnotationNode
42416
+ ];
42417
+ } else {
42418
+ return [
42419
+ linkNode
42420
+ ];
42421
+ }
42373
42422
  } else {
42374
42423
  return [
42375
42424
  node
@@ -42378,26 +42427,20 @@ var processNodeWithAnnotations = function(_ref3) {
42378
42427
  };
42379
42428
  var processTextNode = function(_ref4) {
42380
42429
  var node = _ref4.node, annotations = _ref4.annotations;
42381
- if (!node.position || !node.value) {
42382
- return [
42383
- node
42384
- ];
42385
- }
42430
+ if (!node.position || !node.value) return [
42431
+ node
42432
+ ];
42386
42433
  var nodeStart = node.position.start.offset;
42387
42434
  var nodeEnd = node.position.end.offset;
42388
- if (!isNumber(nodeStart) || !isNumber(nodeEnd)) {
42389
- return [
42390
- node
42391
- ];
42392
- }
42435
+ if (!isNumber(nodeStart) || !isNumber(nodeEnd)) return [
42436
+ node
42437
+ ];
42393
42438
  var newNodes = [];
42394
42439
  var lastIndex = nodeStart;
42395
42440
  annotations.forEach(function(annotation) {
42396
42441
  var annotationStart = annotation.start_index;
42397
42442
  var annotationEnd = annotation.end_index;
42398
- if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) {
42399
- return;
42400
- }
42443
+ if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) return;
42401
42444
  var start = Math.max(nodeStart, annotationStart);
42402
42445
  var end = Math.min(nodeEnd, annotationEnd);
42403
42446
  if (lastIndex < start) {