@ecency/render-helper 2.4.19 → 2.4.21

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.
@@ -80,6 +80,8 @@ var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
80
80
  var ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/[^/?#]+(?:$|[?#])/i;
81
81
  var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(?:play\.)?3speak\.([a-z]+)\/embed\?v=))([A-Za-z0-9_\-\.\/]+)(&.*)?/i;
82
82
  var SPEAK_EMBED_REGEX = /^(https?:)?\/\/(?:play\.)?3speak\.([a-z]+)\/(?:embed|watch)\?.+$/i;
83
+ var SPEAK_AUDIO_REGEX = /https?:\/\/audio\.3speak\.tv\/play\?[^\s]+/i;
84
+ var SPEAK_AUDIO_EMBED_REGEX = /^https?:\/\/audio\.3speak\.tv\/play\?.+$/i;
83
85
  var TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi;
84
86
  var SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi;
85
87
  var RUMBLE_REGEX = /^https:\/\/rumble.com\/embed\/([a-zA-Z0-9-]+)\/\?pub=\w+/;
@@ -925,6 +927,19 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext) {
925
927
  }
926
928
  }
927
929
  }
930
+ if (href.match(SPEAK_AUDIO_REGEX) && el.textContent.trim() === href) {
931
+ el.setAttribute("class", "markdown-audio-link markdown-audio-link-speak");
932
+ el.removeAttribute("href");
933
+ const embedSrc = /[?&]iframe=/.test(href) ? href : `${href}&iframe=1`;
934
+ const finalSrc = /[?&]mode=/.test(embedSrc) ? embedSrc : `${embedSrc}&mode=compact`;
935
+ el.textContent = "";
936
+ const ifr = el.ownerDocument.createElement("iframe");
937
+ ifr.setAttribute("frameborder", "0");
938
+ ifr.setAttribute("src", finalSrc);
939
+ ifr.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups");
940
+ el.appendChild(ifr);
941
+ return;
942
+ }
928
943
  const matchT = href.match(TWITTER_REGEX);
929
944
  if (matchT && el.textContent.trim() === href) {
930
945
  TWITTER_REGEX.lastIndex = 0;
@@ -1046,6 +1061,20 @@ function iframe(el, parentDomain = "ecency.com") {
1046
1061
  el.setAttribute("class", "speak-iframe");
1047
1062
  return;
1048
1063
  }
1064
+ if (src.match(SPEAK_AUDIO_EMBED_REGEX)) {
1065
+ let normalizedSrc = src;
1066
+ if (!/[?&]iframe=/.test(normalizedSrc)) {
1067
+ normalizedSrc = `${normalizedSrc}&iframe=1`;
1068
+ }
1069
+ if (!/[?&]mode=/.test(normalizedSrc)) {
1070
+ normalizedSrc = `${normalizedSrc}&mode=compact`;
1071
+ }
1072
+ el.setAttribute("src", normalizedSrc);
1073
+ el.setAttribute("class", "speak-audio-iframe");
1074
+ el.setAttribute("frameborder", "0");
1075
+ el.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups");
1076
+ return;
1077
+ }
1049
1078
  if (src.match(SPOTIFY_EMBED_REGEX)) {
1050
1079
  el.setAttribute("src", src);
1051
1080
  el.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups");
@@ -1285,9 +1314,10 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1285
1314
  if (!node || !node.childNodes) {
1286
1315
  return;
1287
1316
  }
1288
- const children = Array.from(node.childNodes);
1289
- children.forEach((child) => {
1290
- if (!child) return;
1317
+ let child = node.firstChild;
1318
+ while (child) {
1319
+ const next = child.nextSibling;
1320
+ const prev = child.previousSibling;
1291
1321
  if (child.nodeName.toLowerCase() === "a") {
1292
1322
  a(child, forApp, parentDomain, seoContext);
1293
1323
  }
@@ -1305,8 +1335,14 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1305
1335
  }
1306
1336
  if (child.parentNode) {
1307
1337
  traverse(child, forApp, depth + 1, state, parentDomain, seoContext);
1338
+ } else {
1339
+ const possibleReplacement = next ? next.previousSibling : node.lastChild;
1340
+ if (possibleReplacement && possibleReplacement !== prev && possibleReplacement.parentNode === node) {
1341
+ traverse(possibleReplacement, forApp, depth + 1, state, parentDomain, seoContext);
1342
+ }
1308
1343
  }
1309
- });
1344
+ child = next;
1345
+ }
1310
1346
  }
1311
1347
 
1312
1348
  // src/methods/clean-reply.method.ts