@box/threaded-annotations 1.89.9 → 1.90.0

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.
@@ -1,36 +1,74 @@
1
1
  import { t as e } from "../../../../../../chunks/mention-component.js";
2
2
  import t from "../messages.js";
3
- import { Text as n } from "@box/blueprint-web";
4
- import { useIntl as r } from "react-intl";
5
- import { jsx as i } from "react/jsx-runtime";
6
- var a = ({ node: t, index: n, paragraphIndex: r }) => {
7
- let a = `mention-${t.attrs.mentionedUserId}-${r}-${n}`;
8
- return /* @__PURE__ */ i(e, {
3
+ import { Link as n, Text as r } from "@box/blueprint-web";
4
+ import { useIntl as i } from "react-intl";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ var o = /((?:(?:ht|f)tps?:\/\/)[\w.-]+(?::\d+)?(?:\/[\w\-.~+/#?&%=:[\]@!$'()*;,]*)?)/gi, s = /[.,;:!?]/, c = {
7
+ ")": "(",
8
+ "]": "["
9
+ }, l = (e) => {
10
+ let t = e[e.length - 1];
11
+ if (s.test(t)) return !0;
12
+ let n = c[t];
13
+ if (n) {
14
+ let r = e.split(n).length - 1;
15
+ return e.split(t).length - 1 > r;
16
+ }
17
+ return !1;
18
+ }, u = (e) => {
19
+ let t = e;
20
+ for (; t.length > 0 && l(t);) t = t.slice(0, -1);
21
+ return t;
22
+ }, d = (e) => {
23
+ let t = Array.from(e.matchAll(o)).filter((e) => e.index !== void 0), n = [], r = 0;
24
+ for (let i of t) {
25
+ let t = i.index, a = i[0], o = u(a), s = t + o.length;
26
+ t > r && n.push({
27
+ type: "text",
28
+ value: e.slice(r, t)
29
+ }), n.push({
30
+ type: "url",
31
+ value: o
32
+ }), r = s;
33
+ }
34
+ return r < e.length && n.push({
35
+ type: "text",
36
+ value: e.slice(r)
37
+ }), n;
38
+ }, f = ({ node: t, index: n, paragraphIndex: r }) => {
39
+ let i = `mention-${t.attrs.mentionedUserId}-${r}-${n}`;
40
+ return /* @__PURE__ */ a(e, {
9
41
  authorId: t.attrs.authorId,
10
42
  mentionedUserEmail: t.attrs.mentionedUserEmail,
11
43
  mentionedUserId: t.attrs.mentionedUserId,
12
44
  mentionedUserName: t.attrs.mentionedUserName,
13
45
  mentionId: t.attrs.mentionId
14
- }, a);
15
- }, o = ({ node: e, index: r, paragraphIndex: a, intl: o }) => {
16
- let s = `text-${e.text.substring(0, 20)}-${a}-${r}`;
17
- return /* @__PURE__ */ i(n, {
18
- "aria-label": o.formatMessage(t.textMessageAriaLabel),
46
+ }, i);
47
+ }, p = ({ node: e, index: i, paragraphIndex: o, intl: s }) => {
48
+ let c = `text-${e.text.substring(0, 20)}-${o}-${i}`, l = d(e.text);
49
+ return /* @__PURE__ */ a(r, {
50
+ "aria-label": s.formatMessage(t.textMessageAriaLabel),
19
51
  as: "span",
20
52
  color: "textOnLightDefault",
21
53
  variant: "bodyDefault",
22
54
  "data-no-expand": !0,
23
55
  style: { cursor: "auto" },
24
- children: e.text
25
- }, s);
26
- }, s = ({ content: e, paragraphIndex: t, intl: n }) => e.map((e, r) => {
56
+ children: l.map((e, t) => e.type === "url" ? /* @__PURE__ */ a(n, {
57
+ href: e.value,
58
+ inheritFont: !0,
59
+ rel: "noopener noreferrer",
60
+ target: "_blank",
61
+ children: e.value
62
+ }, `${c}-segment-${t}`) : e.value)
63
+ }, c);
64
+ }, m = ({ content: e, paragraphIndex: t, intl: n }) => e.map((e, r) => {
27
65
  switch (e.type) {
28
- case "mention": return a({
66
+ case "mention": return f({
29
67
  node: e,
30
68
  index: r,
31
69
  paragraphIndex: t
32
70
  });
33
- case "text": return o({
71
+ case "text": return p({
34
72
  node: e,
35
73
  index: r,
36
74
  paragraphIndex: t,
@@ -38,23 +76,23 @@ var a = ({ node: t, index: n, paragraphIndex: r }) => {
38
76
  });
39
77
  default: return [];
40
78
  }
41
- }), c = ({ paragraph: e, index: t, intl: r }) => {
42
- let a = e.content || [], o = `paragraph-${t}`;
43
- return /* @__PURE__ */ i(n, {
79
+ }), h = ({ paragraph: e, index: t, intl: n }) => {
80
+ let i = e.content || [], o = `paragraph-${t}`;
81
+ return /* @__PURE__ */ a(r, {
44
82
  as: "p",
45
83
  variant: "bodyDefault",
46
- children: a.length > 0 ? s({
47
- content: a,
84
+ children: i.length > 0 ? m({
85
+ content: i,
48
86
  paragraphIndex: t,
49
- intl: r
50
- }) : /* @__PURE__ */ i("br", {})
87
+ intl: n
88
+ }) : /* @__PURE__ */ a("br", {})
51
89
  }, o);
52
- }, l = ({ messageObject: e }) => {
53
- let t = r(), { content: n } = e;
54
- return !n && n.length === 0 ? null : n.map((e, n) => c({
90
+ }, g = ({ messageObject: e }) => {
91
+ let t = i(), { content: n } = e;
92
+ return !n && n.length === 0 ? null : n.map((e, n) => h({
55
93
  paragraph: e,
56
94
  index: n,
57
95
  intl: t
58
96
  }));
59
97
  };
60
- export { l as MessageRenderer };
98
+ export { g as MessageRenderer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/threaded-annotations",
3
- "version": "1.89.9",
3
+ "version": "1.90.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "dependencies": {
6
6
  "@tanstack/react-virtual": "^3.10.8",
@@ -16,23 +16,23 @@
16
16
  "uuid": "^9.0.1"
17
17
  },
18
18
  "peerDependencies": {
19
- "@box/blueprint-web": "^14.31.0",
20
- "@box/blueprint-web-assets": "^4.118.3",
21
- "@box/collaboration-popover": "^1.62.10",
22
- "@box/readable-time": "^1.41.10",
23
- "@box/user-selector": "^1.76.10",
19
+ "@box/blueprint-web": "^14.31.1",
20
+ "@box/blueprint-web-assets": "^4.118.4",
21
+ "@box/collaboration-popover": "^1.62.11",
22
+ "@box/readable-time": "^1.41.11",
23
+ "@box/user-selector": "^1.76.11",
24
24
  "clsx": "^1.2.1",
25
25
  "react": "^18.0.0",
26
26
  "react-dom": "^18.0.0",
27
27
  "react-intl": "^6.4.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@box/blueprint-web": "^14.31.0",
31
- "@box/blueprint-web-assets": "^4.118.3",
32
- "@box/eslint-plugin-blueprint": "1.2.1",
33
- "@box/readable-time": "^1.41.10",
34
- "@box/storybook-utils": "^0.19.7",
35
- "@box/user-selector": "^1.76.10",
30
+ "@box/blueprint-web": "^14.31.1",
31
+ "@box/blueprint-web-assets": "^4.118.4",
32
+ "@box/eslint-plugin-blueprint": "1.2.2",
33
+ "@box/readable-time": "^1.41.11",
34
+ "@box/storybook-utils": "^0.19.8",
35
+ "@box/user-selector": "^1.76.11",
36
36
  "react": "^18.0.0",
37
37
  "react-dom": "^18.0.0"
38
38
  },