@blocklet/discuss-kit 2.5.31 → 2.5.33
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/comments.js +2 -2
- package/lib/es/comments.js +153 -177
- package/package.json +3 -3
package/lib/cjs/comments.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),p=require("react"),M=require("@arcblock/ux/lib/Theme"),t=require("prop-types"),H=require("@arcblock/did-connect-react/lib/Session"),i=require("@mui/material"),R=require("@arcblock/ux/lib/Locale/context"),V=require("react-error-boundary"),a=require("@blocklet/discuss-kit-ux"),J=require("ahooks"),Q=require("./components/error-fallback.js"),X=require("./locales/index.js"),Y=require("./lib/utils.js"),r=require("./api.js"),Z=require("./hooks/topic-info-sync.js"),_=()=>{const e=s=>s.endsWith("/")?s:`${s}/`;return window.blocklet?.componentMountPoints?.find(s=>e(s.mountPoint)===e(window.blocklet?.prefix))?.title},u=e=>({...e,rootId:e.rootCommentId,createdAt:e.createdAt?new Date(e.createdAt):null,updatedAt:e.updatedAt?new Date(e.updatedAt):null,deletedAt:e.deletedAt?new Date(e.deletedAt):null,pinnedAt:e.pinnedAt?new Date(e.pinnedAt):null,replies:e.replies?.map(u)}),ee={fetchComments:async e=>{const o={...e,embed:e.rootId?"rating":"replies,rating",size:e.limit},{data:{data:s,nextCursor:l,total:d}}=await r.default.get("/comments",{params:o});return{data:s?.map(u),nextCursor:l,total:d}},fetchPinnedComments:async e=>{const{data:o}=await r.default.get("/comments/pinned",{params:{objectId:e}});return(o?.data||[]).map(u)},fetchCommentPosition:async({id:e,...o})=>{const{data:s}=await r.default.get(`/comments/${e}/position`,{params:o});return s},deleteComment:async({id:e})=>{const{data:o}=await r.default.delete(`/comments/${e}`);return o},updateComment:async({id:e,updatedAt:o},s)=>{const{data:l}=await r.default.put(`/comments/${e}`,{content:s,updatedAt:o});return u(l)},reply:async({id:e},o)=>{const{data:s}=await r.default.post("/comments/replies",{content:o,parentId:e,link:window.location.href});return u(s)},rate:async(e,o,s)=>{await r.default.post(`/topics/${e.topicId}/comments/${e.id}/ratings`,{ratingType:s,value:o})},unrate:async e=>{await r.default.delete(`/topics/${e.topicId}/comments/${e.id}/ratings`)},fetchRatings:async e=>{const{data:o}=await r.default.get(`/ratings/${e}`);return o},togglePin:async({post:e,value:o})=>{o?await r.default.put(`/posts/${e.id}/pinned`):await r.default.delete(`/posts/${e.id}/pinned`)}},te=()=>{const[e,o]=p.useState(!0);return J.useRequest(()=>r.default.get("/status",{muteError:!0}).then(()=>o(!0)).catch(()=>o(!1)),{cacheKey:"discuss-kit-status",staleTime:-1}),{available:e}};function E({ref:e=void 0,displayReaction:o=!0,object:s,onSendComment:l=()=>{},commentInputPosition:d="top",autoFocus:b=!1,disabledSend:g=void 0,initialContent:w="",sendText:y="",sendIcon:j=null,showTopbar:q=!0,sendComment:m=null,reactionAppend:v=null,skeleton:A=null,placeholder:I="",onInput:S=()=>{},draftKey:k="",inputSx:f={},editorRef:x=null,disableCmdEnter:h=!1}){a.useDefaultApiErrorHandler({request:r.default});const{available:K}=te(),{session:T}=p.useContext(H.SessionContext)||{},{state:L,sort:N,add:U,interactive:P,renderInnerFooter:W}=a.useCommentsContext(),{total:$,order:z,initialized:O}=L,{t:c}=R.useLocaleContext();if(Z.useTopicInfoSync(s),!K)return n.jsxs(i.Alert,{severity:"info",children:[n.jsx(i.AlertTitle,{children:c("apiUnavailable.title")}),c("apiUnavailable.desc")]});if(!O)return A||n.jsx(i.Box,{sx:{width:"100%",display:"flex",justifyContent:"center"},children:n.jsx(i.CircularProgress,{})});const G=async C=>{const{data:D}=await(m?m({content:C,object:s}):r.default.post("/comments",{content:C,object:s}));U(u(D)),l?.(D)},B=()=>n.jsx(p.Suspense,{fallback:n.jsxs(n.Fragment,{children:[n.jsx(i.Skeleton,{}),n.jsx(i.Skeleton,{width:"80%"}),n.jsx(i.Skeleton,{width:"60%"}),n.jsx(i.Skeleton,{width:"40%"})]}),children:n.jsx(a.CommentInput,{editorRef:x,placeholder:I,send:G,draftKey:k||`object-${s.id}`,autoFocus:b,disabledSend:g,initialContent:w,sendText:y,sendIcon:j,renderInnerFooter:W,onChange:S,disableCmdEnter:h})});return n.jsxs(ne,{ref:e,children:[n.jsxs(n.Fragment,{children:[n.jsx(i.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"end"},children:o&&n.jsxs(a.IconButtonGroup,{sx:{alignItems:"flex-end"},children:[n.jsx(a.GithubReactionContainer,{id:s.id,request:r.default,interactive:P}),v]})}),T.user&&P&&d==="top"&&n.jsx(i.Box,{className:"comment-editor",sx:{mt:2},children:B()})]}),!!$&&q&&n.jsxs(i.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:3},children:[n.jsxs(i.Box,{sx:{fontWeight:"medium"},children:[$>0?`${$} ${c("comments")}`:c("comment")," "]}),n.jsx(a.SegmentedControl,{value:z,options:[{value:"desc",label:c("newest")},{value:"asc",label:c("oldest")}],onChange:C=>N(C)})]}),n.jsx(a.CommentList,{className:"comment-list"}),T.user&&P&&d==="bottom"&&n.jsx(i.Box,{sx:{mt:6,...f},children:B()})]})}E.propTypes={ref:t.any,displayReaction:t.bool,object:t.object.isRequired,onSendComment:t.func,disabledSend:t.bool,autoFocus:t.bool,initialContent:t.string,sendText:t.string,sendIcon:t.node,commentInputPosition:t.oneOf(["top","bottom"]),showTopbar:t.bool,sendComment:t.func,reactionAppend:t.any,skeleton:t.node,placeholder:t.string,onInput:t.func,draftKey:t.string,editorRef:t.object,inputSx:t.object,disableCmdEnter:t.bool};function F({target:e,flatView:o=!1,autoCollapse:s=!1,autoLoadComments:l=!0,order:d=void 0,allowCopyLink:b=!1,showProfileCard:g=!1,interactive:w=!0,renderComments:y=null,renderDonation:j=null,renderActions:q=null,renderEditorPlugins:m=null,enableAutoTranslate:v=!1,renderInnerFooter:A=null,...I}){const S=Object.assign({},{displayReaction:!0,onChange:()=>{},onSendComment:()=>{},disabledSend:void 0,sendComment:null,reactionAppend:null},I);if(!e?.id)throw new Error("target is required.");const{locale:k="en"}=R.useLocaleContext()||{},f=p.useRef(),x=p.useMemo(()=>({link:window.location.href,blockletName:_(),...e}),[e]),h=a.getWsClient(Y.discussKitPrefix);return p.useEffect(()=>(h.connect(),()=>{h.isConnected()}),[]),n.jsx(V.ErrorBoundary,{FallbackComponent:Q,children:n.jsx(R.LocaleProvider,{translations:X.translations,locale:k,children:n.jsx(a.UploaderProvider,{children:n.jsx(a.InternalThemeProvider,{children:n.jsx(a.ConfirmProvider,{children:n.jsx(a.DefaultEditorConfigProvider,{request:r.default,children:n.jsx(a.CommentsProvider,{target:x,api:ee,flatView:o,order:d,autoCollapse:s,autoLoadComments:l,allowCopyLink:b,showProfileCard:g,interactive:w,containerRef:f,renderDonation:j,renderActions:q,renderEditorPlugins:m,enableAutoTranslate:v,renderComments:y,renderInnerFooter:A,children:n.jsx(E,{...S,object:x,ref:f})})})})})})})})}F.propTypes={target:t.shape({id:t.string.isRequired,title:t.string,desc:t.string,owner:t.string}).isRequired,displayReaction:t.bool,onChange:t.func,flatView:t.bool,autoCollapse:t.bool,autoLoadComments:t.bool,allowCopyLink:t.bool,disabledSend:t.bool,showProfileCard:t.bool,order:t.oneOf(["asc","desc"]),interactive:t.bool,renderComments:t.func,renderDonation:t.any,renderActions:t.func,renderEditorPlugins:t.func,enableAutoTranslate:t.bool,renderInnerFooter:t.func,sendComment:t.func,reactionAppend:t.any};const ne=M.styled("div")`
|
|
2
2
|
width: 100%;
|
|
3
3
|
margin: 0 auto;
|
|
4
4
|
box-sizing: border-box;
|
|
5
5
|
padding: ${e=>e.padding?"20px":"0"};
|
|
6
6
|
border: ${e=>e.border?"1px solid rgb(208, 215, 222)":"none"};
|
|
7
7
|
border-radius: 6px;
|
|
8
|
-
`;module.exports=
|
|
8
|
+
`;module.exports=F;
|
package/lib/es/comments.js
CHANGED
|
@@ -1,216 +1,192 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { styled as
|
|
1
|
+
import { jsx as r, jsxs as a, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as M, useMemo as H, useEffect as V, useContext as J, useState as Q, Suspense as X } from "react";
|
|
3
|
+
import { styled as Y } from "@arcblock/ux/lib/Theme";
|
|
4
4
|
import t from "prop-types";
|
|
5
|
-
import { SessionContext as
|
|
6
|
-
import { Alert as
|
|
7
|
-
import { useLocaleContext as
|
|
8
|
-
import { ErrorBoundary as
|
|
9
|
-
import { getWsClient as
|
|
10
|
-
import { useRequest as
|
|
11
|
-
import
|
|
12
|
-
import { translations as
|
|
13
|
-
import { discussKitPrefix as
|
|
14
|
-
import
|
|
15
|
-
import { useTopicInfoSync as
|
|
16
|
-
const
|
|
5
|
+
import { SessionContext as Z } from "@arcblock/did-connect-react/lib/Session";
|
|
6
|
+
import { Alert as _, AlertTitle as ee, Box as c, CircularProgress as te, Skeleton as C } from "@mui/material";
|
|
7
|
+
import { useLocaleContext as F, LocaleProvider as ne } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import { ErrorBoundary as oe } from "react-error-boundary";
|
|
9
|
+
import { getWsClient as re, UploaderProvider as ie, InternalThemeProvider as se, ConfirmProvider as ae, DefaultEditorConfigProvider as le, CommentsProvider as de, useDefaultApiErrorHandler as ce, useCommentsContext as ue, IconButtonGroup as me, GithubReactionContainer as pe, SegmentedControl as fe, CommentList as he, CommentInput as be } from "@blocklet/discuss-kit-ux";
|
|
10
|
+
import { useRequest as Ce } from "ahooks";
|
|
11
|
+
import ge from "./components/error-fallback.js";
|
|
12
|
+
import { translations as we } from "./locales/index.js";
|
|
13
|
+
import { discussKitPrefix as ye } from "./lib/utils.js";
|
|
14
|
+
import i from "./api.js";
|
|
15
|
+
import { useTopicInfoSync as xe } from "./hooks/topic-info-sync.js";
|
|
16
|
+
const ve = () => {
|
|
17
17
|
const e = (o) => o.endsWith("/") ? o : `${o}/`;
|
|
18
18
|
return window.blocklet?.componentMountPoints?.find(
|
|
19
19
|
(o) => e(o.mountPoint) === e(window.blocklet?.prefix)
|
|
20
20
|
)?.title;
|
|
21
|
-
},
|
|
21
|
+
}, u = (e) => ({
|
|
22
22
|
...e,
|
|
23
23
|
rootId: e.rootCommentId,
|
|
24
24
|
createdAt: e.createdAt ? new Date(e.createdAt) : null,
|
|
25
25
|
updatedAt: e.updatedAt ? new Date(e.updatedAt) : null,
|
|
26
26
|
deletedAt: e.deletedAt ? new Date(e.deletedAt) : null,
|
|
27
27
|
pinnedAt: e.pinnedAt ? new Date(e.pinnedAt) : null,
|
|
28
|
-
replies: e.replies?.map(
|
|
29
|
-
}),
|
|
28
|
+
replies: e.replies?.map(u)
|
|
29
|
+
}), Ae = {
|
|
30
30
|
fetchComments: async (e) => {
|
|
31
31
|
const n = {
|
|
32
32
|
...e,
|
|
33
33
|
embed: e.rootId ? "rating" : "replies,rating",
|
|
34
34
|
size: e.limit
|
|
35
35
|
}, {
|
|
36
|
-
data: { data: o, nextCursor:
|
|
37
|
-
} = await
|
|
38
|
-
return { data: o?.map(
|
|
36
|
+
data: { data: o, nextCursor: s, total: l }
|
|
37
|
+
} = await i.get("/comments", { params: n });
|
|
38
|
+
return { data: o?.map(u), nextCursor: s, total: l };
|
|
39
39
|
},
|
|
40
40
|
fetchPinnedComments: async (e) => {
|
|
41
|
-
const { data: n } = await
|
|
42
|
-
return (n?.data || []).map(
|
|
41
|
+
const { data: n } = await i.get("/comments/pinned", { params: { objectId: e } });
|
|
42
|
+
return (n?.data || []).map(u);
|
|
43
43
|
},
|
|
44
44
|
fetchCommentPosition: async ({ id: e, ...n }) => {
|
|
45
|
-
const { data: o } = await
|
|
45
|
+
const { data: o } = await i.get(`/comments/${e}/position`, { params: n });
|
|
46
46
|
return o;
|
|
47
47
|
},
|
|
48
48
|
deleteComment: async ({ id: e }) => {
|
|
49
|
-
const { data: n } = await
|
|
49
|
+
const { data: n } = await i.delete(`/comments/${e}`);
|
|
50
50
|
return n;
|
|
51
51
|
},
|
|
52
52
|
updateComment: async ({ id: e, updatedAt: n }, o) => {
|
|
53
|
-
const { data:
|
|
54
|
-
return
|
|
53
|
+
const { data: s } = await i.put(`/comments/${e}`, { content: o, updatedAt: n });
|
|
54
|
+
return u(s);
|
|
55
55
|
},
|
|
56
56
|
reply: async ({ id: e }, n) => {
|
|
57
|
-
const { data: o } = await
|
|
57
|
+
const { data: o } = await i.post("/comments/replies", {
|
|
58
58
|
content: n,
|
|
59
59
|
parentId: e,
|
|
60
60
|
link: window.location.href
|
|
61
61
|
});
|
|
62
|
-
return
|
|
62
|
+
return u(o);
|
|
63
63
|
},
|
|
64
64
|
rate: async (e, n, o) => {
|
|
65
|
-
await
|
|
65
|
+
await i.post(`/topics/${e.topicId}/comments/${e.id}/ratings`, { ratingType: o, value: n });
|
|
66
66
|
},
|
|
67
67
|
unrate: async (e) => {
|
|
68
|
-
await
|
|
68
|
+
await i.delete(`/topics/${e.topicId}/comments/${e.id}/ratings`);
|
|
69
69
|
},
|
|
70
70
|
fetchRatings: async (e) => {
|
|
71
|
-
const { data: n } = await
|
|
71
|
+
const { data: n } = await i.get(`/ratings/${e}`);
|
|
72
72
|
return n;
|
|
73
73
|
},
|
|
74
74
|
togglePin: async ({ post: e, value: n }) => {
|
|
75
|
-
n ? await
|
|
75
|
+
n ? await i.put(`/posts/${e.id}/pinned`) : await i.delete(`/posts/${e.id}/pinned`);
|
|
76
76
|
}
|
|
77
|
-
},
|
|
78
|
-
const [e, n] =
|
|
79
|
-
return
|
|
80
|
-
() =>
|
|
77
|
+
}, Ie = () => {
|
|
78
|
+
const [e, n] = Q(!0);
|
|
79
|
+
return Ce(
|
|
80
|
+
() => i.get("/status", { muteError: !0 }).then(() => n(!0)).catch(() => n(!1)),
|
|
81
81
|
{ cacheKey: "discuss-kit-status", staleTime: -1 }
|
|
82
82
|
), { available: e };
|
|
83
83
|
};
|
|
84
|
-
function
|
|
84
|
+
function K({
|
|
85
85
|
ref: e = void 0,
|
|
86
86
|
displayReaction: n = !0,
|
|
87
87
|
object: o,
|
|
88
|
-
onChange
|
|
88
|
+
// onChange = () => {},
|
|
89
|
+
onSendComment: s = () => {
|
|
89
90
|
},
|
|
90
|
-
|
|
91
|
+
commentInputPosition: l = "top",
|
|
92
|
+
autoFocus: g = !1,
|
|
93
|
+
disabledSend: w = void 0,
|
|
94
|
+
initialContent: y = "",
|
|
95
|
+
sendText: x = "",
|
|
96
|
+
sendIcon: v = null,
|
|
97
|
+
showTopbar: A = !0,
|
|
98
|
+
sendComment: m = null,
|
|
99
|
+
reactionAppend: I = null,
|
|
100
|
+
skeleton: P = null,
|
|
101
|
+
placeholder: $ = "",
|
|
102
|
+
onInput: S = () => {
|
|
91
103
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
sendText: I = "",
|
|
97
|
-
sendIcon: P = null,
|
|
98
|
-
showTopbar: S = !0,
|
|
99
|
-
sendComment: C = null,
|
|
100
|
-
reactionAppend: T = null,
|
|
101
|
-
skeleton: $ = null,
|
|
102
|
-
placeholder: R = "",
|
|
103
|
-
onInput: k = () => {
|
|
104
|
-
},
|
|
105
|
-
draftKey: b = "",
|
|
106
|
-
inputSx: g = {},
|
|
107
|
-
editorRef: w = null,
|
|
108
|
-
disableCmdEnter: L = !1
|
|
104
|
+
draftKey: k = "",
|
|
105
|
+
inputSx: p = {},
|
|
106
|
+
editorRef: f = null,
|
|
107
|
+
disableCmdEnter: h = !1
|
|
109
108
|
}) {
|
|
110
|
-
|
|
111
|
-
request:
|
|
109
|
+
ce({
|
|
110
|
+
request: i
|
|
112
111
|
});
|
|
113
|
-
const { available:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
UPDATE_COMMENT: (r) => {
|
|
120
|
-
const a = z(r.id);
|
|
121
|
-
a && a.content !== r.content && j(r.id, (m) => (m.content = r.content, m.updatedAt = r.updatedAt, m.synced = Date.now(), m));
|
|
122
|
-
},
|
|
123
|
-
RATING_COMMENT: async ({ commentId: r }) => {
|
|
124
|
-
const a = await Te(r);
|
|
125
|
-
j(r, (m) => ({
|
|
126
|
-
...m,
|
|
127
|
-
rating: a
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
if (be(
|
|
132
|
-
o.id,
|
|
133
|
-
({ event: r, data: a }) => {
|
|
134
|
-
V[r]?.(a);
|
|
135
|
-
},
|
|
136
|
-
[o.id, M]
|
|
137
|
-
), !U)
|
|
138
|
-
return /* @__PURE__ */ d(ie, { severity: "info", children: [
|
|
139
|
-
/* @__PURE__ */ i(re, { children: u("apiUnavailable.title") }),
|
|
140
|
-
u("apiUnavailable.desc")
|
|
112
|
+
const { available: L } = Ie(), { session: q } = J(Z) || {}, { state: B, sort: N, add: W, interactive: R, renderInnerFooter: z } = ue(), { total: T, order: O, initialized: U } = B, { t: d } = F();
|
|
113
|
+
if (xe(o), !L)
|
|
114
|
+
return /* @__PURE__ */ a(_, { severity: "info", children: [
|
|
115
|
+
/* @__PURE__ */ r(ee, { children: d("apiUnavailable.title") }),
|
|
116
|
+
d("apiUnavailable.desc")
|
|
141
117
|
] });
|
|
142
|
-
if (!
|
|
143
|
-
return
|
|
144
|
-
|
|
118
|
+
if (!U)
|
|
119
|
+
return P || /* @__PURE__ */ r(
|
|
120
|
+
c,
|
|
145
121
|
{
|
|
146
122
|
sx: {
|
|
147
123
|
width: "100%",
|
|
148
124
|
display: "flex",
|
|
149
125
|
justifyContent: "center"
|
|
150
126
|
},
|
|
151
|
-
children: /* @__PURE__ */
|
|
127
|
+
children: /* @__PURE__ */ r(te, {})
|
|
152
128
|
}
|
|
153
129
|
);
|
|
154
|
-
const
|
|
155
|
-
const { data:
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
|
|
130
|
+
const G = async (b) => {
|
|
131
|
+
const { data: E } = await (m ? m({ content: b, object: o }) : i.post("/comments", { content: b, object: o }));
|
|
132
|
+
W(u(E)), s?.(E);
|
|
133
|
+
}, D = () => /* @__PURE__ */ r(
|
|
134
|
+
X,
|
|
159
135
|
{
|
|
160
|
-
fallback: /* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */
|
|
136
|
+
fallback: /* @__PURE__ */ a(j, { children: [
|
|
137
|
+
/* @__PURE__ */ r(C, {}),
|
|
138
|
+
/* @__PURE__ */ r(C, { width: "80%" }),
|
|
139
|
+
/* @__PURE__ */ r(C, { width: "60%" }),
|
|
140
|
+
/* @__PURE__ */ r(C, { width: "40%" })
|
|
165
141
|
] }),
|
|
166
|
-
children: /* @__PURE__ */
|
|
167
|
-
|
|
142
|
+
children: /* @__PURE__ */ r(
|
|
143
|
+
be,
|
|
168
144
|
{
|
|
169
|
-
editorRef:
|
|
170
|
-
placeholder:
|
|
171
|
-
send:
|
|
172
|
-
draftKey:
|
|
173
|
-
autoFocus:
|
|
174
|
-
disabledSend:
|
|
175
|
-
initialContent:
|
|
176
|
-
sendText:
|
|
177
|
-
sendIcon:
|
|
178
|
-
renderInnerFooter:
|
|
179
|
-
onChange:
|
|
180
|
-
disableCmdEnter:
|
|
145
|
+
editorRef: f,
|
|
146
|
+
placeholder: $,
|
|
147
|
+
send: G,
|
|
148
|
+
draftKey: k || `object-${o.id}`,
|
|
149
|
+
autoFocus: g,
|
|
150
|
+
disabledSend: w,
|
|
151
|
+
initialContent: y,
|
|
152
|
+
sendText: x,
|
|
153
|
+
sendIcon: v,
|
|
154
|
+
renderInnerFooter: z,
|
|
155
|
+
onChange: S,
|
|
156
|
+
disableCmdEnter: h
|
|
181
157
|
}
|
|
182
158
|
)
|
|
183
159
|
}
|
|
184
160
|
);
|
|
185
|
-
return /* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
161
|
+
return /* @__PURE__ */ a($e, { ref: e, children: [
|
|
162
|
+
/* @__PURE__ */ a(j, { children: [
|
|
163
|
+
/* @__PURE__ */ r(
|
|
164
|
+
c,
|
|
189
165
|
{
|
|
190
166
|
sx: {
|
|
191
167
|
display: "flex",
|
|
192
168
|
justifyContent: "space-between",
|
|
193
169
|
alignItems: "end"
|
|
194
170
|
},
|
|
195
|
-
children: n && /* @__PURE__ */
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
|
|
171
|
+
children: n && /* @__PURE__ */ a(me, { sx: { alignItems: "flex-end" }, children: [
|
|
172
|
+
/* @__PURE__ */ r(pe, { id: o.id, request: i, interactive: R }),
|
|
173
|
+
I
|
|
198
174
|
] })
|
|
199
175
|
}
|
|
200
176
|
),
|
|
201
|
-
q.user &&
|
|
202
|
-
|
|
177
|
+
q.user && R && l === "top" && /* @__PURE__ */ r(
|
|
178
|
+
c,
|
|
203
179
|
{
|
|
204
180
|
className: "comment-editor",
|
|
205
181
|
sx: {
|
|
206
182
|
mt: 2
|
|
207
183
|
},
|
|
208
|
-
children:
|
|
184
|
+
children: D()
|
|
209
185
|
}
|
|
210
186
|
)
|
|
211
187
|
] }),
|
|
212
|
-
!!
|
|
213
|
-
|
|
188
|
+
!!T && A && /* @__PURE__ */ a(
|
|
189
|
+
c,
|
|
214
190
|
{
|
|
215
191
|
sx: {
|
|
216
192
|
display: "flex",
|
|
@@ -219,33 +195,33 @@ function B({
|
|
|
219
195
|
mt: 3
|
|
220
196
|
},
|
|
221
197
|
children: [
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
|
|
198
|
+
/* @__PURE__ */ a(c, { sx: { fontWeight: "medium" }, children: [
|
|
199
|
+
T > 0 ? `${T} ${d("comments")}` : d("comment"),
|
|
224
200
|
" "
|
|
225
201
|
] }),
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
|
|
202
|
+
/* @__PURE__ */ r(
|
|
203
|
+
fe,
|
|
228
204
|
{
|
|
229
|
-
value:
|
|
205
|
+
value: O,
|
|
230
206
|
options: [
|
|
231
|
-
{ value: "desc", label:
|
|
232
|
-
{ value: "asc", label:
|
|
207
|
+
{ value: "desc", label: d("newest") },
|
|
208
|
+
{ value: "asc", label: d("oldest") }
|
|
233
209
|
],
|
|
234
|
-
onChange: (
|
|
210
|
+
onChange: (b) => N(b)
|
|
235
211
|
}
|
|
236
212
|
)
|
|
237
213
|
]
|
|
238
214
|
}
|
|
239
215
|
),
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
q.user &&
|
|
216
|
+
/* @__PURE__ */ r(he, { className: "comment-list" }),
|
|
217
|
+
q.user && R && l === "bottom" && /* @__PURE__ */ r(c, { sx: { mt: 6, ...p }, children: D() })
|
|
242
218
|
] });
|
|
243
219
|
}
|
|
244
|
-
|
|
220
|
+
K.propTypes = {
|
|
245
221
|
ref: t.any,
|
|
246
222
|
displayReaction: t.bool,
|
|
247
223
|
object: t.object.isRequired,
|
|
248
|
-
onChange:
|
|
224
|
+
// onChange: PropTypes.func,
|
|
249
225
|
onSendComment: t.func,
|
|
250
226
|
disabledSend: t.bool,
|
|
251
227
|
autoFocus: t.bool,
|
|
@@ -264,24 +240,24 @@ B.propTypes = {
|
|
|
264
240
|
inputSx: t.object,
|
|
265
241
|
disableCmdEnter: t.bool
|
|
266
242
|
};
|
|
267
|
-
function
|
|
243
|
+
function Pe({
|
|
268
244
|
target: e,
|
|
269
245
|
flatView: n = !1,
|
|
270
246
|
autoCollapse: o = !1,
|
|
271
|
-
autoLoadComments:
|
|
272
|
-
order:
|
|
273
|
-
allowCopyLink:
|
|
274
|
-
showProfileCard:
|
|
275
|
-
interactive:
|
|
276
|
-
renderComments:
|
|
277
|
-
renderDonation:
|
|
278
|
-
renderActions:
|
|
279
|
-
renderEditorPlugins:
|
|
280
|
-
enableAutoTranslate:
|
|
281
|
-
renderInnerFooter:
|
|
247
|
+
autoLoadComments: s = !0,
|
|
248
|
+
order: l = void 0,
|
|
249
|
+
allowCopyLink: g = !1,
|
|
250
|
+
showProfileCard: w = !1,
|
|
251
|
+
interactive: y = !0,
|
|
252
|
+
renderComments: x = null,
|
|
253
|
+
renderDonation: v = null,
|
|
254
|
+
renderActions: A = null,
|
|
255
|
+
renderEditorPlugins: m = null,
|
|
256
|
+
enableAutoTranslate: I = !1,
|
|
257
|
+
renderInnerFooter: P = null,
|
|
282
258
|
...$
|
|
283
259
|
}) {
|
|
284
|
-
const
|
|
260
|
+
const S = Object.assign(
|
|
285
261
|
{},
|
|
286
262
|
{
|
|
287
263
|
displayReaction: !0,
|
|
@@ -297,41 +273,41 @@ function Ee({
|
|
|
297
273
|
);
|
|
298
274
|
if (!e?.id)
|
|
299
275
|
throw new Error("target is required.");
|
|
300
|
-
const { locale: k = "en" } =
|
|
276
|
+
const { locale: k = "en" } = F() || {}, p = M(), f = H(
|
|
301
277
|
() => ({
|
|
302
278
|
link: window.location.href,
|
|
303
|
-
blockletName:
|
|
279
|
+
blockletName: ve(),
|
|
304
280
|
...e
|
|
305
281
|
}),
|
|
306
282
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
307
283
|
[e]
|
|
308
|
-
),
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
}), []), /* @__PURE__ */
|
|
312
|
-
|
|
284
|
+
), h = re(ye);
|
|
285
|
+
return V(() => (h.connect(), () => {
|
|
286
|
+
h.isConnected();
|
|
287
|
+
}), []), /* @__PURE__ */ r(oe, { FallbackComponent: ge, children: /* @__PURE__ */ r(ne, { translations: we, locale: k, children: /* @__PURE__ */ r(ie, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(ae, { children: /* @__PURE__ */ r(le, { request: i, children: /* @__PURE__ */ r(
|
|
288
|
+
de,
|
|
313
289
|
{
|
|
314
|
-
target:
|
|
315
|
-
api:
|
|
290
|
+
target: f,
|
|
291
|
+
api: Ae,
|
|
316
292
|
flatView: n,
|
|
317
|
-
order:
|
|
293
|
+
order: l,
|
|
318
294
|
autoCollapse: o,
|
|
319
|
-
autoLoadComments:
|
|
320
|
-
allowCopyLink:
|
|
321
|
-
showProfileCard:
|
|
322
|
-
interactive:
|
|
323
|
-
containerRef:
|
|
324
|
-
renderDonation:
|
|
325
|
-
renderActions:
|
|
326
|
-
renderEditorPlugins:
|
|
327
|
-
enableAutoTranslate:
|
|
328
|
-
renderComments:
|
|
329
|
-
renderInnerFooter:
|
|
330
|
-
children: /* @__PURE__ */
|
|
295
|
+
autoLoadComments: s,
|
|
296
|
+
allowCopyLink: g,
|
|
297
|
+
showProfileCard: w,
|
|
298
|
+
interactive: y,
|
|
299
|
+
containerRef: p,
|
|
300
|
+
renderDonation: v,
|
|
301
|
+
renderActions: A,
|
|
302
|
+
renderEditorPlugins: m,
|
|
303
|
+
enableAutoTranslate: I,
|
|
304
|
+
renderComments: x,
|
|
305
|
+
renderInnerFooter: P,
|
|
306
|
+
children: /* @__PURE__ */ r(K, { ...S, object: f, ref: p })
|
|
331
307
|
}
|
|
332
308
|
) }) }) }) }) }) });
|
|
333
309
|
}
|
|
334
|
-
|
|
310
|
+
Pe.propTypes = {
|
|
335
311
|
target: t.shape({
|
|
336
312
|
id: t.string.isRequired,
|
|
337
313
|
title: t.string,
|
|
@@ -357,7 +333,7 @@ Ee.propTypes = {
|
|
|
357
333
|
sendComment: t.func,
|
|
358
334
|
reactionAppend: t.any
|
|
359
335
|
};
|
|
360
|
-
const
|
|
336
|
+
const $e = Y("div")`
|
|
361
337
|
width: 100%;
|
|
362
338
|
margin: 0 auto;
|
|
363
339
|
box-sizing: border-box;
|
|
@@ -366,5 +342,5 @@ const qe = ne("div")`
|
|
|
366
342
|
border-radius: 6px;
|
|
367
343
|
`;
|
|
368
344
|
export {
|
|
369
|
-
|
|
345
|
+
Pe as default
|
|
370
346
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.33",
|
|
4
4
|
"description": "A react component for Discuss Kit blocklet.",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/es/index.js",
|
|
@@ -49,8 +49,8 @@
|
|
|
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.5.
|
|
53
|
-
"@blocklet/editor": "2.5.
|
|
52
|
+
"@blocklet/discuss-kit-ux": "2.5.33",
|
|
53
|
+
"@blocklet/editor": "2.5.33"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@arcblock/did-connect-react": "^3.1.5",
|