@liveblocks/emails 3.1.1 → 3.1.2-url1

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
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/emails";
6
- var PKG_VERSION = "3.1.1";
6
+ var PKG_VERSION = "3.1.2-url1";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/text-mention-notification.tsx
@@ -8376,9 +8376,20 @@ async function convertCommentBody(body, options) {
8376
8376
  );
8377
8377
  }
8378
8378
  if (_core.isCommentBodyLink.call(void 0, inline)) {
8379
- const href = _nullishCoalesce(_core.toAbsoluteUrl.call(void 0, inline.url), () => ( inline.url));
8379
+ const href = _core.sanitizeUrl.call(void 0, inline.url);
8380
+ if (href === null) {
8381
+ return options.elements.text(
8382
+ {
8383
+ element: { text: _nullishCoalesce(inline.text, () => ( inline.url)) }
8384
+ },
8385
+ inlineIndex
8386
+ );
8387
+ }
8380
8388
  return options.elements.link(
8381
- { element: inline, href },
8389
+ {
8390
+ element: inline,
8391
+ href
8392
+ },
8382
8393
  inlineIndex
8383
8394
  );
8384
8395
  }
@@ -8479,6 +8490,15 @@ var extractThreadNotificationData = async ({
8479
8490
  comments: unreadComments
8480
8491
  };
8481
8492
  };
8493
+ function generateCommentUrl({
8494
+ roomUrl,
8495
+ commentId
8496
+ }) {
8497
+ if (!roomUrl) {
8498
+ return;
8499
+ }
8500
+ return _core.generateUrl.call(void 0, roomUrl, void 0, commentId);
8501
+ }
8482
8502
  async function prepareThreadNotificationEmail(client, event, options, elements, callerName) {
8483
8503
  const data = await extractThreadNotificationData({ client, event });
8484
8504
  if (data === null) {
@@ -8510,10 +8530,10 @@ async function prepareThreadNotificationEmail(client, event, options, elements,
8510
8530
  commentBodyPromise
8511
8531
  ]);
8512
8532
  const authorInfo = authorsInfo.get(comment.userId);
8513
- const url = _optionalChain([roomInfo, 'optionalAccess', _16 => _16.url]) ? _core.generateCommentUrl.call(void 0, {
8514
- roomUrl: _optionalChain([roomInfo, 'optionalAccess', _17 => _17.url]),
8533
+ const url = generateCommentUrl({
8534
+ roomUrl: _optionalChain([roomInfo, 'optionalAccess', _16 => _16.url]),
8515
8535
  commentId: comment.id
8516
- }) : void 0;
8536
+ });
8517
8537
  return {
8518
8538
  type: "unreadMention",
8519
8539
  comment: {
@@ -8553,10 +8573,10 @@ async function prepareThreadNotificationEmail(client, event, options, elements,
8553
8573
  comments: comments.map((comment, index) => {
8554
8574
  const authorInfo = authorsInfo.get(comment.userId);
8555
8575
  const commentBody = commentBodies[index];
8556
- const url = _optionalChain([roomInfo, 'optionalAccess', _18 => _18.url]) ? _core.generateCommentUrl.call(void 0, {
8557
- roomUrl: _optionalChain([roomInfo, 'optionalAccess', _19 => _19.url]),
8576
+ const url = generateCommentUrl({
8577
+ roomUrl: _optionalChain([roomInfo, 'optionalAccess', _17 => _17.url]),
8558
8578
  commentId: comment.id
8559
- }) : void 0;
8579
+ });
8560
8580
  return {
8561
8581
  id: comment.id,
8562
8582
  threadId: comment.threadId,
@@ -8596,7 +8616,7 @@ var baseStyles2 = {
8596
8616
  }
8597
8617
  };
8598
8618
  async function prepareThreadNotificationEmailAsHtml(client, event, options = {}) {
8599
- const styles = { ...baseStyles2, ..._optionalChain([options, 'optionalAccess', _20 => _20.styles]) };
8619
+ const styles = { ...baseStyles2, ..._optionalChain([options, 'optionalAccess', _18 => _18.styles]) };
8600
8620
  const data = await prepareThreadNotificationEmail(
8601
8621
  client,
8602
8622
  event,
@@ -8633,7 +8653,7 @@ async function prepareThreadNotificationEmailAsHtml(client, event, options = {})
8633
8653
  return _core.html`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ? _core.html`${element.text}` : element.url}</a>`;
8634
8654
  },
8635
8655
  mention: ({ element, user }) => {
8636
- return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _21 => _21.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _22 => _22.name])}` : element.id}</span>`;
8656
+ return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _19 => _19.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _20 => _20.name])}` : element.id}</span>`;
8637
8657
  }
8638
8658
  },
8639
8659
  "prepareThreadNotificationEmailAsHtml"
@@ -8665,11 +8685,11 @@ var baseComponents2 = {
8665
8685
  Link: ({ element, href }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, target: "_blank", rel: "noopener noreferrer", children: _nullishCoalesce(element.text, () => ( element.url)) }),
8666
8686
  Mention: ({ element, user }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-mention": true, children: [
8667
8687
  MENTION_CHARACTER,
8668
- _nullishCoalesce(_optionalChain([user, 'optionalAccess', _23 => _23.name]), () => ( element.id))
8688
+ _nullishCoalesce(_optionalChain([user, 'optionalAccess', _21 => _21.name]), () => ( element.id))
8669
8689
  ] })
8670
8690
  };
8671
8691
  async function prepareThreadNotificationEmailAsReact(client, event, options = {}) {
8672
- const Components = { ...baseComponents2, ..._optionalChain([options, 'optionalAccess', _24 => _24.components]) };
8692
+ const Components = { ...baseComponents2, ..._optionalChain([options, 'optionalAccess', _22 => _22.components]) };
8673
8693
  const data = await prepareThreadNotificationEmail(
8674
8694
  client,
8675
8695
  event,