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