@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 {
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { jsx as
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
},
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
"aria-label":
|
|
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.
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
66
|
+
case "mention": return f({
|
|
29
67
|
node: e,
|
|
30
68
|
index: r,
|
|
31
69
|
paragraphIndex: t
|
|
32
70
|
});
|
|
33
|
-
case "text": return
|
|
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
|
-
}),
|
|
42
|
-
let
|
|
43
|
-
return /* @__PURE__ */
|
|
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:
|
|
47
|
-
content:
|
|
84
|
+
children: i.length > 0 ? m({
|
|
85
|
+
content: i,
|
|
48
86
|
paragraphIndex: t,
|
|
49
|
-
intl:
|
|
50
|
-
}) : /* @__PURE__ */
|
|
87
|
+
intl: n
|
|
88
|
+
}) : /* @__PURE__ */ a("br", {})
|
|
51
89
|
}, o);
|
|
52
|
-
},
|
|
53
|
-
let t =
|
|
54
|
-
return !n && n.length === 0 ? null : n.map((e, n) =>
|
|
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 {
|
|
98
|
+
export { g as MessageRenderer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/threaded-annotations",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
20
|
-
"@box/blueprint-web-assets": "^4.118.
|
|
21
|
-
"@box/collaboration-popover": "^1.62.
|
|
22
|
-
"@box/readable-time": "^1.41.
|
|
23
|
-
"@box/user-selector": "^1.76.
|
|
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.
|
|
31
|
-
"@box/blueprint-web-assets": "^4.118.
|
|
32
|
-
"@box/eslint-plugin-blueprint": "1.2.
|
|
33
|
-
"@box/readable-time": "^1.41.
|
|
34
|
-
"@box/storybook-utils": "^0.19.
|
|
35
|
-
"@box/user-selector": "^1.76.
|
|
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
|
},
|