@liveblocks/emails 3.8.1 → 3.9.1-tiptap1

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.8.1";
6
+ var PKG_VERSION = "3.9.1-tiptap1";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/text-mention-notification.tsx
@@ -1091,9 +1091,12 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
1091
1091
  /** @type {Array<GC|Item>} */
1092
1092
  transaction.doc.store.clients.get(clientid)
1093
1093
  );
1094
- for (let i = 0; i < deletes.length; i++) {
1095
- const del = deletes[i];
1096
- iterateStructs(transaction, structs, del.clock, del.len, f);
1094
+ if (structs != null) {
1095
+ const lastStruct = structs[structs.length - 1];
1096
+ const clockState = lastStruct.id.clock + lastStruct.length;
1097
+ for (let i = 0, del = deletes[i]; i < deletes.length && del.clock < clockState; del = deletes[++i]) {
1098
+ iterateStructs(transaction, structs, del.clock, del.len, f);
1099
+ }
1097
1100
  }
1098
1101
  });
1099
1102
  var findIndexDS = (dis, clock) => {
@@ -2132,13 +2135,13 @@ var integrateStructs = (transaction, store, clientsStructRefs) => {
2132
2135
  const addStackToRestSS = () => {
2133
2136
  for (const item of stack) {
2134
2137
  const client = item.id.client;
2135
- const unapplicableItems = clientsStructRefs.get(client);
2136
- if (unapplicableItems) {
2137
- unapplicableItems.i--;
2138
- restStructs.clients.set(client, unapplicableItems.refs.slice(unapplicableItems.i));
2138
+ const inapplicableItems = clientsStructRefs.get(client);
2139
+ if (inapplicableItems) {
2140
+ inapplicableItems.i--;
2141
+ restStructs.clients.set(client, inapplicableItems.refs.slice(inapplicableItems.i));
2139
2142
  clientsStructRefs.delete(client);
2140
- unapplicableItems.i = 0;
2141
- unapplicableItems.refs = [];
2143
+ inapplicableItems.i = 0;
2144
+ inapplicableItems.refs = [];
2142
2145
  } else {
2143
2146
  restStructs.clients.set(client, [item]);
2144
2147
  }
@@ -3647,6 +3650,8 @@ var typeMapSet = (transaction, parent, key, value) => {
3647
3650
  case Boolean:
3648
3651
  case Array:
3649
3652
  case String:
3653
+ case Date:
3654
+ case BigInt:
3650
3655
  content = new ContentAny([value]);
3651
3656
  break;
3652
3657
  case Uint8Array:
@@ -4912,7 +4917,7 @@ var YText = class _YText extends AbstractType {
4912
4917
  /**
4913
4918
  * Apply a {@link Delta} on this shared YText type.
4914
4919
  *
4915
- * @param {any} delta The changes to apply on this element.
4920
+ * @param {Array<any>} delta The changes to apply on this element.
4916
4921
  * @param {object} opts
4917
4922
  * @param {boolean} [opts.sanitize] Sanitize input delta. Removes ending newlines if set to true.
4918
4923
  *
@@ -5259,8 +5264,9 @@ var YXmlTreeWalker = class {
5259
5264
  n = type._start;
5260
5265
  } else {
5261
5266
  while (n !== null) {
5262
- if (n.right !== null) {
5263
- n = n.right;
5267
+ const nxt = n.next;
5268
+ if (nxt !== null) {
5269
+ n = nxt;
5264
5270
  break;
5265
5271
  } else if (n.parent === this._root) {
5266
5272
  n = null;
@@ -5800,7 +5806,7 @@ var YXmlEvent = class extends YEvent {
5800
5806
  * @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
5801
5807
  * @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
5802
5808
  * child list changed.
5803
- * @param {Transaction} transaction The transaction instance with wich the
5809
+ * @param {Transaction} transaction The transaction instance with which the
5804
5810
  * change was created.
5805
5811
  */
5806
5812
  constructor(target, subs, transaction) {
@@ -6010,7 +6016,7 @@ var AbstractStruct = class {
6010
6016
  * This method is already assuming that `this.id.clock + this.length === this.id.clock`.
6011
6017
  * Also this method does *not* remove right from StructStore!
6012
6018
  * @param {AbstractStruct} right
6013
- * @return {boolean} wether this merged with right
6019
+ * @return {boolean} whether this merged with right
6014
6020
  */
6015
6021
  mergeWith(right) {
6016
6022
  return false;
@@ -7024,8 +7030,7 @@ var Item = class _Item extends AbstractStruct {
7024
7030
  if (this.left && this.left.constructor === _Item) {
7025
7031
  this.parent = this.left.parent;
7026
7032
  this.parentSub = this.left.parentSub;
7027
- }
7028
- if (this.right && this.right.constructor === _Item) {
7033
+ } else if (this.right && this.right.constructor === _Item) {
7029
7034
  this.parent = this.right.parent;
7030
7035
  this.parentSub = this.right.parentSub;
7031
7036
  }
@@ -7805,33 +7810,41 @@ function toInlineCSSString(styles) {
7805
7810
  // src/tiptap-editor.ts
7806
7811
 
7807
7812
 
7813
+ // ../../node_modules/y-prosemirror/src/plugins/sync-plugin.js
7814
+ var hashedMarkNameRegex = /(.*)(--[a-zA-Z0-9+/=]{8})$/;
7815
+ var yattr2markname = (attrName) => _nullishCoalesce(_optionalChain([hashedMarkNameRegex, 'access', _7 => _7.exec, 'call', _8 => _8(attrName), 'optionalAccess', _9 => _9[1]]), () => ( attrName));
7816
+
7808
7817
  // ../../node_modules/y-prosemirror/src/lib.js
7809
7818
  function yXmlFragmentToProsemirrorJSON(xmlFragment) {
7810
7819
  const items = xmlFragment.toArray();
7811
- function serialize(item) {
7820
+ const serialize = (item) => {
7812
7821
  let response;
7813
- if (!item.nodeName) {
7822
+ if (item instanceof YXmlText) {
7814
7823
  const delta = item.toDelta();
7815
- response = delta.map((d) => {
7816
- const text = {
7817
- type: "text",
7818
- text: d.insert
7819
- };
7820
- if (d.attributes) {
7821
- text.marks = Object.keys(d.attributes).map((type) => {
7822
- const attrs = d.attributes[type];
7823
- const mark = {
7824
- type
7825
- };
7826
- if (Object.keys(attrs)) {
7827
- mark.attrs = attrs;
7828
- }
7829
- return mark;
7830
- });
7824
+ response = delta.map(
7825
+ /** @param {any} d */
7826
+ (d) => {
7827
+ const text = {
7828
+ type: "text",
7829
+ text: d.insert
7830
+ };
7831
+ if (d.attributes) {
7832
+ text.marks = Object.keys(d.attributes).map((type_) => {
7833
+ const attrs = d.attributes[type_];
7834
+ const type = yattr2markname(type_);
7835
+ const mark = {
7836
+ type
7837
+ };
7838
+ if (Object.keys(attrs)) {
7839
+ mark.attrs = attrs;
7840
+ }
7841
+ return mark;
7842
+ });
7843
+ }
7844
+ return text;
7831
7845
  }
7832
- return text;
7833
- });
7834
- } else {
7846
+ );
7847
+ } else if (item instanceof YXmlElement) {
7835
7848
  response = {
7836
7849
  type: item.nodeName
7837
7850
  };
@@ -7843,9 +7856,11 @@ function yXmlFragmentToProsemirrorJSON(xmlFragment) {
7843
7856
  if (children.length) {
7844
7857
  response.content = children.map(serialize).flat();
7845
7858
  }
7859
+ } else {
7860
+ unexpectedCase();
7846
7861
  }
7847
7862
  return response;
7848
- }
7863
+ };
7849
7864
  return {
7850
7865
  type: "doc",
7851
7866
  content: items.map(serialize)
@@ -8152,8 +8167,8 @@ var resolveMentionsInLiveblocksTextEditorNodes = async (nodes, resolveUsers, res
8152
8167
  async function convertTextMentionContent(nodes, options) {
8153
8168
  const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInLiveblocksTextEditorNodes(
8154
8169
  nodes,
8155
- _optionalChain([options, 'optionalAccess', _7 => _7.resolveUsers]),
8156
- _optionalChain([options, 'optionalAccess', _8 => _8.resolveGroupsInfo])
8170
+ _optionalChain([options, 'optionalAccess', _10 => _10.resolveUsers]),
8171
+ _optionalChain([options, 'optionalAccess', _11 => _11.resolveGroupsInfo])
8157
8172
  );
8158
8173
  const blocks = nodes.map((node, index) => {
8159
8174
  switch (node.type) {
@@ -8256,7 +8271,7 @@ async function prepareTextMentionNotificationEmail(client, event, options, eleme
8256
8271
  const roomInfo = options.resolveRoomInfo ? await options.resolveRoomInfo({ roomId: event.data.roomId }) : void 0;
8257
8272
  const resolvedRoomInfo = {
8258
8273
  ...roomInfo,
8259
- name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _9 => _9.name]), () => ( event.data.roomId))
8274
+ name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _12 => _12.name]), () => ( event.data.roomId))
8260
8275
  };
8261
8276
  const batchUsersResolver = createBatchUsersResolver({
8262
8277
  resolveUsers: options.resolveUsers,
@@ -8319,7 +8334,7 @@ var baseComponents = {
8319
8334
  Container: ({ children }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children }),
8320
8335
  Mention: ({ element, user, group }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-mention": true, children: [
8321
8336
  _core.MENTION_CHARACTER,
8322
- _nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _10 => _10.name]), () => ( _optionalChain([group, 'optionalAccess', _11 => _11.name]))), () => ( element.id))
8337
+ _nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _13 => _13.name]), () => ( _optionalChain([group, 'optionalAccess', _14 => _14.name]))), () => ( element.id))
8323
8338
  ] }),
8324
8339
  Text: ({ element }) => {
8325
8340
  let children = element.text;
@@ -8401,7 +8416,7 @@ async function prepareTextMentionNotificationEmailAsHtml(client, event, options
8401
8416
  return content.join("\n");
8402
8417
  },
8403
8418
  mention: ({ node, user, group }) => {
8404
- return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${_core.MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _12 => _12.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _13 => _13.name])}` : _optionalChain([group, 'optionalAccess', _14 => _14.name]) ? _core.html`${_optionalChain([group, 'optionalAccess', _15 => _15.name])}` : node.id}</span>`;
8419
+ return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${_core.MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _15 => _15.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _16 => _16.name])}` : _optionalChain([group, 'optionalAccess', _17 => _17.name]) ? _core.html`${_optionalChain([group, 'optionalAccess', _18 => _18.name])}` : node.id}</span>`;
8405
8420
  },
8406
8421
  text: ({ node }) => {
8407
8422
  let children = node.text;
@@ -8451,8 +8466,8 @@ async function prepareTextMentionNotificationEmailAsHtml(client, event, options
8451
8466
  async function convertCommentBody(body, options) {
8452
8467
  const { users: resolvedUsers, groups: resolvedGroupsInfo } = await _core.resolveMentionsInCommentBody.call(void 0,
8453
8468
  body,
8454
- _optionalChain([options, 'optionalAccess', _16 => _16.resolveUsers]),
8455
- _optionalChain([options, 'optionalAccess', _17 => _17.resolveGroupsInfo])
8469
+ _optionalChain([options, 'optionalAccess', _19 => _19.resolveUsers]),
8470
+ _optionalChain([options, 'optionalAccess', _20 => _20.resolveGroupsInfo])
8456
8471
  );
8457
8472
  const blocks = body.content.map((block, index) => {
8458
8473
  switch (block.type) {
@@ -8576,12 +8591,12 @@ var getLastUnreadCommentWithMention = ({
8576
8591
  if (mention.kind === "user" && mention.id === mentionedUserId) {
8577
8592
  return comment;
8578
8593
  }
8579
- if (mention.kind === "group" && _optionalChain([mention, 'access', _18 => _18.userIds, 'optionalAccess', _19 => _19.includes, 'call', _20 => _20(mentionedUserId)])) {
8594
+ if (mention.kind === "group" && _optionalChain([mention, 'access', _21 => _21.userIds, 'optionalAccess', _22 => _22.includes, 'call', _23 => _23(mentionedUserId)])) {
8580
8595
  return comment;
8581
8596
  }
8582
8597
  if (mention.kind === "group" && mention.userIds === void 0) {
8583
8598
  const group = groups.get(mention.id);
8584
- if (_optionalChain([group, 'optionalAccess', _21 => _21.members, 'access', _22 => _22.some, 'call', _23 => _23((member) => member.id === mentionedUserId)])) {
8599
+ if (_optionalChain([group, 'optionalAccess', _24 => _24.members, 'access', _25 => _25.some, 'call', _26 => _26((member) => member.id === mentionedUserId)])) {
8585
8600
  return comment;
8586
8601
  }
8587
8602
  }
@@ -8639,7 +8654,7 @@ async function prepareThreadNotificationEmail(client, event, options, elements,
8639
8654
  const roomInfo = options.resolveRoomInfo ? await options.resolveRoomInfo({ roomId: event.data.roomId }) : void 0;
8640
8655
  const resolvedRoomInfo = {
8641
8656
  ...roomInfo,
8642
- name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _24 => _24.name]), () => ( event.data.roomId))
8657
+ name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _27 => _27.name]), () => ( event.data.roomId))
8643
8658
  };
8644
8659
  const batchUsersResolver = createBatchUsersResolver({
8645
8660
  resolveUsers: options.resolveUsers,
@@ -8670,8 +8685,8 @@ async function prepareThreadNotificationEmail(client, event, options, elements,
8670
8685
  authorsIds,
8671
8686
  authorsInfo
8672
8687
  );
8673
- const url = _optionalChain([roomInfo, 'optionalAccess', _25 => _25.url]) ? generateCommentUrl({
8674
- roomUrl: _optionalChain([roomInfo, 'optionalAccess', _26 => _26.url]),
8688
+ const url = _optionalChain([roomInfo, 'optionalAccess', _28 => _28.url]) ? generateCommentUrl({
8689
+ roomUrl: _optionalChain([roomInfo, 'optionalAccess', _29 => _29.url]),
8675
8690
  commentId: comment.id
8676
8691
  }) : void 0;
8677
8692
  return {
@@ -8718,7 +8733,7 @@ async function prepareThreadNotificationEmail(client, event, options, elements,
8718
8733
  );
8719
8734
  const commentBody = commentBodies[index];
8720
8735
  const url = generateCommentUrl({
8721
- roomUrl: _optionalChain([roomInfo, 'optionalAccess', _27 => _27.url]),
8736
+ roomUrl: _optionalChain([roomInfo, 'optionalAccess', _30 => _30.url]),
8722
8737
  commentId: comment.id
8723
8738
  });
8724
8739
  return {
@@ -8760,7 +8775,7 @@ var baseStyles2 = {
8760
8775
  }
8761
8776
  };
8762
8777
  async function prepareThreadNotificationEmailAsHtml(client, event, options = {}) {
8763
- const styles = { ...baseStyles2, ..._optionalChain([options, 'optionalAccess', _28 => _28.styles]) };
8778
+ const styles = { ...baseStyles2, ..._optionalChain([options, 'optionalAccess', _31 => _31.styles]) };
8764
8779
  const data = await prepareThreadNotificationEmail(
8765
8780
  client,
8766
8781
  event,
@@ -8798,7 +8813,7 @@ async function prepareThreadNotificationEmailAsHtml(client, event, options = {})
8798
8813
  return _core.html`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ? _core.html`${element.text}` : element.url}</a>`;
8799
8814
  },
8800
8815
  mention: ({ element, user, group }) => {
8801
- return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${_core.MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _29 => _29.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _30 => _30.name])}` : _optionalChain([group, 'optionalAccess', _31 => _31.name]) ? _core.html`${_optionalChain([group, 'optionalAccess', _32 => _32.name])}` : element.id}</span>`;
8816
+ return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${_core.MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _32 => _32.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _33 => _33.name])}` : _optionalChain([group, 'optionalAccess', _34 => _34.name]) ? _core.html`${_optionalChain([group, 'optionalAccess', _35 => _35.name])}` : element.id}</span>`;
8802
8817
  }
8803
8818
  },
8804
8819
  "prepareThreadNotificationEmailAsHtml"
@@ -8830,11 +8845,11 @@ var baseComponents2 = {
8830
8845
  Link: ({ element, href }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, target: "_blank", rel: "noopener noreferrer", children: _nullishCoalesce(element.text, () => ( element.url)) }),
8831
8846
  Mention: ({ element, user, group }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-mention": true, children: [
8832
8847
  _core.MENTION_CHARACTER,
8833
- _nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _33 => _33.name]), () => ( _optionalChain([group, 'optionalAccess', _34 => _34.name]))), () => ( element.id))
8848
+ _nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _36 => _36.name]), () => ( _optionalChain([group, 'optionalAccess', _37 => _37.name]))), () => ( element.id))
8834
8849
  ] })
8835
8850
  };
8836
8851
  async function prepareThreadNotificationEmailAsReact(client, event, options = {}) {
8837
- const Components = { ...baseComponents2, ..._optionalChain([options, 'optionalAccess', _35 => _35.components]) };
8852
+ const Components = { ...baseComponents2, ..._optionalChain([options, 'optionalAccess', _38 => _38.components]) };
8838
8853
  const data = await prepareThreadNotificationEmail(
8839
8854
  client,
8840
8855
  event,