@blocklet/discuss-kit 2.3.106 → 2.4.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.
- package/lib/cjs/api.js +1 -51
- package/lib/cjs/comments-dialog.js +1 -24
- package/lib/cjs/comments-installer.js +1 -18
- package/lib/cjs/comments-with-session.js +1 -15
- package/lib/cjs/comments.js +4 -387
- package/lib/cjs/components/error-fallback.js +1 -17
- package/lib/cjs/components/menu.js +3 -58
- package/lib/cjs/constants.js +1 -4
- package/lib/cjs/hooks/comment-listener.js +1 -17
- package/lib/cjs/hooks/topic-info-sync.js +1 -22
- package/lib/cjs/index.js +1 -25
- package/lib/cjs/lib/utils.js +1 -37
- package/lib/cjs/locales/en.js +1 -52
- package/lib/cjs/locales/index.js +1 -8
- package/lib/cjs/locales/zh.js +1 -54
- package/lib/cjs/session.js +1 -14
- package/lib/es/api.js +30 -37
- package/lib/es/comments-dialog.js +15 -15
- package/lib/es/comments-installer.js +36 -15
- package/lib/es/comments-with-session.js +10 -13
- package/lib/es/comments.js +320 -353
- package/lib/es/components/error-fallback.js +12 -12
- package/lib/es/components/menu.js +40 -41
- package/lib/es/constants.js +2 -2
- package/lib/es/hooks/comment-listener.js +10 -12
- package/lib/es/hooks/topic-info-sync.js +14 -16
- package/lib/es/index.js +11 -11
- package/lib/es/lib/utils.js +16 -31
- package/lib/es/locales/en.js +3 -3
- package/lib/es/locales/index.js +6 -6
- package/lib/es/locales/zh.js +3 -3
- package/lib/es/session.js +10 -11
- package/package.json +18 -17
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
1
|
+
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import i from "prop-types";
|
|
3
|
+
import t from "@mui/material/Alert";
|
|
4
|
+
import n from "@mui/material/AlertTitle";
|
|
5
|
+
function p({ error: e }) {
|
|
6
|
+
const o = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ r("pre", { children: e.message });
|
|
7
|
+
return /* @__PURE__ */ s(t, { severity: "warning", children: [
|
|
8
|
+
/* @__PURE__ */ r(n, { children: "Oops!" }),
|
|
9
9
|
"Discuss Kit is not working properly.",
|
|
10
|
-
|
|
10
|
+
o
|
|
11
11
|
] });
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
error:
|
|
13
|
+
p.propTypes = {
|
|
14
|
+
error: i.instanceOf(Error).isRequired
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
p as default
|
|
18
18
|
};
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { styled } from "@arcblock/ux/lib/Theme";
|
|
5
|
-
import
|
|
6
|
-
import { MoreVert } from "@mui/icons-material";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
const [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsxs as h, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u } from "react";
|
|
3
|
+
import f from "prop-types";
|
|
4
|
+
import { styled as e } from "@arcblock/ux/lib/Theme";
|
|
5
|
+
import x from "@mui/material/IconButton";
|
|
6
|
+
import { MoreVert as C } from "@mui/icons-material";
|
|
7
|
+
import M from "@mui/material/Box";
|
|
8
|
+
import k from "@mui/material/Menu";
|
|
9
|
+
import y from "@mui/material/MenuItem";
|
|
10
|
+
function g({ items: l, ...m }) {
|
|
11
|
+
const [t, n] = u(null), c = !!t, s = (r) => {
|
|
12
|
+
n(r.currentTarget);
|
|
13
|
+
}, i = () => {
|
|
14
|
+
n(null);
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* @__PURE__ */ jsx(IconButton, { size: "medium", onClick: handleClick, children: /* @__PURE__ */ jsx(MoreVert, { sx: { fontSize: 18 } }) }),
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
MuiMenu,
|
|
16
|
+
return /* @__PURE__ */ h(z, { ...m, children: [
|
|
17
|
+
/* @__PURE__ */ o(x, { size: "medium", onClick: s, children: /* @__PURE__ */ o(C, { sx: { fontSize: 18 } }) }),
|
|
18
|
+
/* @__PURE__ */ o(
|
|
19
|
+
k,
|
|
23
20
|
{
|
|
24
|
-
anchorEl,
|
|
21
|
+
anchorEl: t,
|
|
25
22
|
anchorOrigin: {
|
|
26
23
|
vertical: "bottom",
|
|
27
24
|
horizontal: "right"
|
|
@@ -30,32 +27,34 @@ function Menu({ items, ...rest }) {
|
|
|
30
27
|
vertical: "top",
|
|
31
28
|
horizontal: "right"
|
|
32
29
|
},
|
|
33
|
-
open,
|
|
34
|
-
onClose:
|
|
35
|
-
children:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
open: c,
|
|
31
|
+
onClose: i,
|
|
32
|
+
children: l.map(({ onClick: r, text: a, ...p }, d) => (
|
|
33
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
34
|
+
/* @__PURE__ */ o(v, { onClick: () => {
|
|
35
|
+
r(), i();
|
|
36
|
+
}, ...p, children: /* @__PURE__ */ o(
|
|
37
|
+
M,
|
|
38
|
+
{
|
|
39
|
+
sx: {
|
|
40
|
+
minWidth: 100
|
|
41
|
+
},
|
|
42
|
+
children: a
|
|
43
|
+
}
|
|
44
|
+
) }, d)
|
|
45
|
+
))
|
|
45
46
|
}
|
|
46
47
|
)
|
|
47
48
|
] });
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
items:
|
|
50
|
+
g.propTypes = {
|
|
51
|
+
items: f.array.isRequired
|
|
51
52
|
};
|
|
52
|
-
|
|
53
|
-
const Root = styled("div")`
|
|
53
|
+
const z = e("div")`
|
|
54
54
|
display: inline-block;
|
|
55
|
-
|
|
56
|
-
const StyledMenuItem = styled(MuiMenuItem)`
|
|
55
|
+
`, v = e(y)`
|
|
57
56
|
font-size: 14px;
|
|
58
57
|
`;
|
|
59
58
|
export {
|
|
60
|
-
|
|
59
|
+
g as default
|
|
61
60
|
};
|
package/lib/es/constants.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { useSubscription } from "@blocklet/discuss-kit-ux";
|
|
2
|
-
import { discussKitPrefix } from "../lib/utils";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
({ event, data }) => {
|
|
7
|
-
|
|
8
|
-
handleNewComment(data);
|
|
9
|
-
}
|
|
1
|
+
import { useSubscription as t } from "@blocklet/discuss-kit-ux";
|
|
2
|
+
import { discussKitPrefix as e } from "../lib/utils.js";
|
|
3
|
+
const n = (i, s) => {
|
|
4
|
+
t(
|
|
5
|
+
i,
|
|
6
|
+
({ event: r, data: o }) => {
|
|
7
|
+
r === "ADD_COMMENT" && s(o);
|
|
10
8
|
},
|
|
11
|
-
[
|
|
12
|
-
|
|
9
|
+
[i],
|
|
10
|
+
e
|
|
13
11
|
);
|
|
14
12
|
};
|
|
15
13
|
export {
|
|
16
|
-
useCommentsListener
|
|
14
|
+
n as useCommentsListener
|
|
17
15
|
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { utils } from "@blocklet/discuss-kit-ux";
|
|
3
|
-
import
|
|
4
|
-
import { isInIframe } from "../lib/utils";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
title:
|
|
10
|
-
link:
|
|
11
|
-
}).catch((
|
|
12
|
-
console.error(
|
|
1
|
+
import { useEffect as r } from "react";
|
|
2
|
+
import { utils as s } from "@blocklet/discuss-kit-ux";
|
|
3
|
+
import c from "../api.js";
|
|
4
|
+
import { isInIframe as e } from "../lib/utils.js";
|
|
5
|
+
const l = (t) => {
|
|
6
|
+
r(() => {
|
|
7
|
+
const i = () => {
|
|
8
|
+
c.put(`/comments/topics/${t.id}`, {
|
|
9
|
+
title: t.title,
|
|
10
|
+
link: t.link
|
|
11
|
+
}).catch((o) => {
|
|
12
|
+
console.error(o);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
sync();
|
|
17
|
-
}
|
|
15
|
+
!s.isInDiscussKitApp && !e() && i();
|
|
18
16
|
}, []);
|
|
19
17
|
};
|
|
20
18
|
export {
|
|
21
|
-
useTopicInfoSync
|
|
19
|
+
l as useTopicInfoSync
|
|
22
20
|
};
|
package/lib/es/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AutoTranslateHeaderAddon, Translate } from "@blocklet/discuss-kit-ux";
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { useCommentsListener } from "./hooks/comment-listener";
|
|
5
|
-
import { CommentsDialog } from "./comments-dialog";
|
|
1
|
+
import { AutoTranslateHeaderAddon as t, Translate as r } from "@blocklet/discuss-kit-ux";
|
|
2
|
+
import { default as s } from "./comments-installer.js";
|
|
3
|
+
import { default as n } from "./comments-with-session.js";
|
|
4
|
+
import { useCommentsListener as d } from "./hooks/comment-listener.js";
|
|
5
|
+
import { CommentsDialog as p } from "./comments-dialog.js";
|
|
6
6
|
export {
|
|
7
|
-
AutoTranslateHeaderAddon,
|
|
8
|
-
|
|
9
|
-
CommentsDialog,
|
|
10
|
-
|
|
11
|
-
Translate,
|
|
12
|
-
useCommentsListener
|
|
7
|
+
t as AutoTranslateHeaderAddon,
|
|
8
|
+
s as Comments,
|
|
9
|
+
p as CommentsDialog,
|
|
10
|
+
n as CommentsWithSession,
|
|
11
|
+
r as Translate,
|
|
12
|
+
d as useCommentsListener
|
|
13
13
|
};
|
package/lib/es/lib/utils.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
session.login(() => resolve(action()));
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
|
-
const minDelay = (promise, ms) => {
|
|
13
|
-
return Promise.all([promise, sleep(ms)]).then(([result]) => result);
|
|
14
|
-
};
|
|
15
|
-
const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
16
|
-
(x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
|
|
17
|
-
);
|
|
18
|
-
const discussKitPrefix = discussKitService ? joinUrl(discussKitService.mountPoint, "/") : "";
|
|
19
|
-
const discussKitApiPrefix = joinUrl(discussKitPrefix, "/api/");
|
|
20
|
-
const isDiscussKitRunning = (discussKitService == null ? void 0 : discussKitService.status) === "running";
|
|
21
|
-
const isInIframe = () => {
|
|
1
|
+
import s from "url-join";
|
|
2
|
+
const c = (n, t) => n.user ? t() : new Promise((i) => {
|
|
3
|
+
n.login(() => i(t()));
|
|
4
|
+
}), e = (n) => new Promise((t) => setTimeout(t, n)), d = (n, t) => Promise.all([n, e(t)]).then(([i]) => i), o = window.blocklet?.componentMountPoints?.find(
|
|
5
|
+
(n) => n.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
|
|
6
|
+
), r = o ? s(o.mountPoint, "/") : "", m = s(r, "/api/"), p = o?.status === "running", w = () => {
|
|
22
7
|
try {
|
|
23
8
|
return window.self !== window.top;
|
|
24
|
-
} catch
|
|
25
|
-
return
|
|
9
|
+
} catch {
|
|
10
|
+
return !0;
|
|
26
11
|
}
|
|
27
12
|
};
|
|
28
13
|
export {
|
|
29
|
-
discussKitApiPrefix,
|
|
30
|
-
discussKitPrefix,
|
|
31
|
-
discussKitService,
|
|
32
|
-
isDiscussKitRunning,
|
|
33
|
-
isInIframe,
|
|
34
|
-
minDelay,
|
|
35
|
-
protectLogin,
|
|
36
|
-
sleep
|
|
14
|
+
m as discussKitApiPrefix,
|
|
15
|
+
r as discussKitPrefix,
|
|
16
|
+
o as discussKitService,
|
|
17
|
+
p as isDiscussKitRunning,
|
|
18
|
+
w as isInIframe,
|
|
19
|
+
d as minDelay,
|
|
20
|
+
c as protectLogin,
|
|
21
|
+
e as sleep
|
|
37
22
|
};
|
package/lib/es/locales/en.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import e from "flat";
|
|
2
|
+
const s = e({
|
|
3
3
|
comments: "Comments",
|
|
4
4
|
comment: "Comment",
|
|
5
5
|
poweredBy: "- powered by Discuss Kit",
|
|
@@ -49,5 +49,5 @@ const en = flat({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
export {
|
|
52
|
-
|
|
52
|
+
s as default
|
|
53
53
|
};
|
package/lib/es/locales/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { translations as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import o from "flat";
|
|
2
|
+
import { translations as t } from "@blocklet/discuss-kit-ux";
|
|
3
|
+
import r from "./en.js";
|
|
4
|
+
import n from "./zh.js";
|
|
5
|
+
const f = { zh: { ...n, ...o(t.zh) }, en: { ...r, ...o(t.en) } };
|
|
6
6
|
export {
|
|
7
|
-
translations
|
|
7
|
+
f as translations
|
|
8
8
|
};
|
package/lib/es/locales/zh.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import e from "flat";
|
|
2
|
+
const s = e({
|
|
3
3
|
comments: "条评论",
|
|
4
4
|
comment: "评论",
|
|
5
5
|
poweredBy: "- 由 Discuss Kit 提供支持",
|
|
@@ -51,5 +51,5 @@ const zh = flat({
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
export {
|
|
54
|
-
|
|
54
|
+
s as default
|
|
55
55
|
};
|
package/lib/es/session.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { createAuthServiceSessionContext } from "@arcblock/did-connect/lib/Session";
|
|
3
|
-
const { SessionProvider, SessionContext, SessionConsumer, withSession } =
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
return data;
|
|
1
|
+
import { useContext as e } from "react";
|
|
2
|
+
import { createAuthServiceSessionContext as o } from "@arcblock/did-connect/lib/Session";
|
|
3
|
+
const { SessionProvider: r, SessionContext: t, SessionConsumer: S, withSession: u } = o();
|
|
4
|
+
function a() {
|
|
5
|
+
return e(t);
|
|
7
6
|
}
|
|
8
7
|
export {
|
|
9
|
-
SessionConsumer,
|
|
10
|
-
SessionContext,
|
|
11
|
-
SessionProvider,
|
|
12
|
-
useSessionContext,
|
|
13
|
-
withSession
|
|
8
|
+
S as SessionConsumer,
|
|
9
|
+
t as SessionContext,
|
|
10
|
+
r as SessionProvider,
|
|
11
|
+
a as useSessionContext,
|
|
12
|
+
u as withSession
|
|
14
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A react component for Discuss Kit blocklet.",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/es/index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@dnd-kit/core": "^6.1.0",
|
|
33
33
|
"@dnd-kit/sortable": "^8.0.0",
|
|
34
34
|
"@dnd-kit/utilities": "^3.2.2",
|
|
35
|
-
"@emotion/react": "^11.
|
|
36
|
-
"@emotion/styled": "^11.
|
|
37
|
-
"@mui/icons-material": "^
|
|
38
|
-
"@mui/lab": "^
|
|
39
|
-
"@mui/material": "^
|
|
35
|
+
"@emotion/react": "^11.14.0",
|
|
36
|
+
"@emotion/styled": "^11.14.1",
|
|
37
|
+
"@mui/icons-material": "^7.1.2",
|
|
38
|
+
"@mui/lab": "^7.0.0-beta.14",
|
|
39
|
+
"@mui/material": "^7.1.2",
|
|
40
40
|
"@uiw/react-md-editor": "^3.25.6",
|
|
41
41
|
"ahooks": "^3.8.1",
|
|
42
42
|
"axios": "^0.27.2",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"rehype-sanitize": "^5.0.1",
|
|
50
50
|
"timeago.js": "^4.0.2",
|
|
51
51
|
"url-join": "^4.0.1",
|
|
52
|
-
"@blocklet/discuss-kit-ux": "^2.
|
|
53
|
-
"@blocklet/editor": "^2.
|
|
52
|
+
"@blocklet/discuss-kit-ux": "^2.4.0",
|
|
53
|
+
"@blocklet/editor": "^2.4.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@arcblock/did-connect": "^
|
|
57
|
-
"@arcblock/ux": "^
|
|
58
|
-
"@blocklet/ui-react": "^
|
|
59
|
-
"react": "
|
|
60
|
-
"react-dom": "
|
|
56
|
+
"@arcblock/did-connect": "^3.0.1",
|
|
57
|
+
"@arcblock/ux": "^3.0.1",
|
|
58
|
+
"@blocklet/ui-react": "^3.0.1",
|
|
59
|
+
"react": "^19.1.0",
|
|
60
|
+
"react-dom": "^19.1.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
@@ -67,12 +67,13 @@
|
|
|
67
67
|
"@babel/core": "^7.25.2",
|
|
68
68
|
"@babel/preset-env": "^7.25.4",
|
|
69
69
|
"@babel/preset-react": "^7.24.7",
|
|
70
|
-
"@vitejs/plugin-react": "^4.
|
|
70
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
71
71
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
72
|
+
"fast-glob": "^3.3.3",
|
|
72
73
|
"jest": "^24.9.0",
|
|
73
|
-
"vite": "^
|
|
74
|
-
"vite-plugin-
|
|
75
|
-
"vite-plugin-svgr": "^4.
|
|
74
|
+
"vite": "^7.0.0",
|
|
75
|
+
"vite-plugin-no-bundle": "^4.0.0",
|
|
76
|
+
"vite-plugin-svgr": "^4.3.0"
|
|
76
77
|
},
|
|
77
78
|
"scripts": {
|
|
78
79
|
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|