@blocklet/discuss-kit-lite 2.6.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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2018-2020 ArcBlock
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Discuss Kit React Component
2
+
3
+ A react component for Discuss Kit blocklet.
4
+
5
+ ## Install
6
+
7
+ ```
8
+ npm install @did-comment/react
9
+ ```
10
+
11
+ or
12
+
13
+ ```
14
+ yarn add @did-comment/react
15
+ ```
package/lib/cjs/api.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@blocklet/js-sdk"),n=require("@blocklet/discuss-kit-ux-lite"),o=require("./lib/utils.js"),s=i.createAxios({baseURL:o.discussKitApiPrefix,timeout:2e4,headers:{"x-discuss-kit-client-id":n.utils.getDiscussKitClientId()}});s.interceptors.request.use(e=>e,e=>Promise.reject(e));const a=async e=>{const{data:t}=await s.get(`/ratings/${e}`);return t},u=async e=>{try{const{data:t}=await s.get("/comments",{params:e});return t}catch(t){throw console.error(t),t}},l=async({parentId:e,content:t})=>{const{data:c}=await s.post("/comments/replies",{content:t,parentId:e});return c},d=async({commentId:e,cursor:t,limit:c=10})=>{try{const{data:r}=await s.get(`/comments/${e}/replies`,{params:{cursor:t,limit:c,embed:"rating"}});return r}catch(r){throw console.error(r),r}};exports.default=s;exports.fetchComments=u;exports.fetchMoreReplies=d;exports.fetchRatings=a;exports.reply=l;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@mui/material"),a=require("@mui/icons-material/Close"),c=require("./comments.js");function u({title:o,open:s,onClose:i,...n}){const r=t.useMediaQuery(l=>l.breakpoints.down("md"));return e.jsxs(t.Dialog,{fullScreen:r,onClose:i,maxWidth:!1,...n,open:s,children:[e.jsxs(t.DialogTitle,{variant:"h4",sx:{position:"relative"},children:[o,e.jsx(t.IconButton,{onClick:i,sx:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)"},children:e.jsx(a,{})})]}),e.jsx(t.DialogContent,{sx:{width:{xs:1,sm:800}},children:e.jsx(c,{...n})})]})}exports.CommentsDialog=u;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("@blocklet/ui-react/lib/ComponentInstaller"),i=require("prop-types"),n=require("./comments.js"),a=require("./constants.js");function r({installerProps:s={},...o}){const t=Object.assign({},{displayReaction:!0,onChange:()=>{},flatView:!1,autoCollapse:!1,autoLoadComments:!0,allowCopyLink:!1,disabledSend:void 0,showProfileCard:!1,order:void 0,interactive:!0,renderComments:null,renderDonation:null,renderActions:null,renderEditorPlugins:null,enableAutoTranslate:!1,renderInnerFooter:null,sendComment:null,reactionAppend:null},s);return e.jsx(l,{did:a.DiscussKitDid,...t,children:e.jsx(n,{...o})})}r.propTypes={...n.propTypes,installerProps:i.object};module.exports=r;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),o=require("@arcblock/did-connect-react/lib/utils"),i=require("./comments.js"),c=require("./session.js"),u=s=>{const t=o.getWebWalletUrl();return function(n){return e.jsx(c.SessionProvider,{serviceHost:"/",webWalletUrl:t,children:r=>e.jsx(s,{...n,session:r.session,showConnectBtn:!0})})}},l=u(i);module.exports=l;
@@ -0,0 +1,8 @@
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-lite"),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
+ width: 100%;
3
+ margin: 0 auto;
4
+ box-sizing: border-box;
5
+ padding: ${e=>e.padding?"20px":"0"};
6
+ border: ${e=>e.border?"1px solid rgb(208, 215, 222)":"none"};
7
+ border-radius: 6px;
8
+ `;module.exports=F;
@@ -0,0 +1 @@
1
+ "use strict";const s=require("react/jsx-runtime"),i=require("react"),c=require("prop-types"),l=require("@mui/material/Alert"),a=require("@mui/material/AlertTitle"),u=require("@mui/material/Button"),p=require("@mui/material/Collapse"),d=require("@mui/material/Box");function t({error:e}){const[r,n]=i.useState(!1);return i.useEffect(()=>{console.error(e)},[e]),s.jsxs(l,{severity:"warning",action:e?s.jsx(u,{color:"inherit",size:"small",onClick:()=>n(o=>!o),children:r?"Hide details":"Show details"}):void 0,sx:{".MuiAlert-action":{flex:"0 0 auto"}},children:[s.jsx(a,{children:"Oops!"}),"Discuss Kit is not working properly.",e&&s.jsx(p,{in:r,children:s.jsxs(d,{component:"pre",sx:{mt:1,mb:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[e.message,s.jsx("br",{}),e.stack]})})]})}t.propTypes={error:c.instanceOf(Error).isRequired};module.exports=t;
@@ -0,0 +1,5 @@
1
+ "use strict";const e=require("react/jsx-runtime"),p=require("react"),q=require("prop-types"),i=require("@arcblock/ux/lib/Theme"),M=require("@mui/material/IconButton"),j=require("@mui/icons-material"),y=require("@mui/material/Box"),C=require("@mui/material/Menu"),g=require("@mui/material/MenuItem");function s({items:c,...l}){const[r,t]=p.useState(null),u=!!r,a=n=>{t(n.currentTarget)},o=()=>{t(null)};return e.jsxs(k,{...l,children:[e.jsx(M,{size:"medium",onClick:a,children:e.jsx(j.MoreVert,{sx:{fontSize:18}})}),e.jsx(C,{anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:u,onClose:o,children:c.map(({onClick:n,text:h,...d},x)=>{const m=()=>{n(),o()};return e.jsx(z,{onClick:m,...d,children:e.jsx(y,{sx:{minWidth:100},children:h})},x)})})]})}s.propTypes={items:q.array.isRequired};const k=i.styled("div")`
2
+ display: inline-block;
3
+ `,z=i.styled(g)`
4
+ font-size: 14px;
5
+ `;module.exports=s;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";exports.DiscussKitDid=i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@blocklet/discuss-kit-ux-lite"),u=require("../lib/utils.js"),n=(e,s)=>{r.useSubscription(e,({event:i,data:t})=>{i==="ADD_COMMENT"&&s(t)},[e],u.discussKitPrefix)};exports.useCommentsListener=n;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("../api.js"),o=require("../lib/utils.js"),r=e=>{i.useEffect(()=>{const t=()=>{n.default.put(`/comments/topics/${e.id}`,{title:e.title,link:e.link}).catch(c=>{console.error(c)})};!window.blocklet.componentId?.endsWith("z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu")&&!o.isInIframe()&&t()},[])};exports.useTopicInfoSync=r;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./comments-installer.js"),t=require("./comments-with-session.js"),s=require("./hooks/comment-listener.js"),o=require("./comments-dialog.js");exports.Comments=e;exports.CommentsWithSession=t;exports.useCommentsListener=s.useCommentsListener;exports.CommentsDialog=o.CommentsDialog;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("ufo"),u=(i,s)=>i.user?s():new Promise(e=>{i.login(()=>e(s()))}),o=i=>new Promise(s=>setTimeout(s,i)),c=(i,s)=>Promise.all([i,o(s)]).then(([e])=>e),t=window.blocklet?.componentMountPoints?.find(i=>i.did==="z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"),r=t?n.joinURL(t.mountPoint,"/"):"",d=n.joinURL(r,"/api/"),l=t?.status==="running",f=()=>{try{return window.self!==window.top}catch{return!0}};exports.discussKitApiPrefix=d;exports.discussKitPrefix=r;exports.discussKitService=t;exports.isDiscussKitRunning=l;exports.isInIframe=f;exports.minDelay=c;exports.protectLogin=u;exports.sleep=o;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("flat"),t=e({comments:"Comments",comment:"Comment",poweredBy:"- powered by Discuss Kit",connect:"Connect",inputPlaceHolder:"Write a comment",oldest:"Oldest",newest:"Newest",loadMore:"Click To Load More",connectDIDWallet:"Please connect DID Wallet.",installDIDWallet:"Click to get your own DID Wallet→",empty:"Be the first to leave a comment.",delete:"Delete",edit:"Edit",confirm:"Confirm",cancel:"Cancel",tip:"Tip",deleteCommentDesc:"Confirm delete this comment?",readMore:"Read More",showMoreReplies:"Show more replies",deleted:"This comment has been deleted",emptyContent:"No comment yet",userActionLog:{and:"and",added:"added the",removed:"removed the",label:"label",labels:"labels",assigned:"assigned",unassigned:"unassigned",selfAssigned:"self-assigned this",selfUnassigned:"self-unassigned this",published:"published this",unpublished:"unpublished this",changeTitle:"changed the title",changeBoard:"changed the board",mention:"mentioned this",pin:"pinned this",unpin:"unpinned this",markAsFeatured:"marked this as featured",unmarkAsFeatured:"unmarked this as featured",passport:"passport",passports:"passports"},apiUnavailable:{title:"Comment service is not available",desc:"Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."}});module.exports=t;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("flat"),e=require("@blocklet/discuss-kit-ux-lite"),n=require("./en.js"),s=require("./zh.js"),r={zh:{...s,...t(e.translations.zh)},en:{...n,...t(e.translations.en)}};exports.translations=r;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("flat"),t=e({comments:"条评论",comment:"评论",poweredBy:"- 由 Discuss Kit 提供支持",connect:"连接",inputPlaceHolder:"写评论",oldest:"最旧",newest:"最新",loadMore:"点击加载更多",connectDIDWallet:"请先连接 DID Wallet.",installDIDWallet:"点击拥有你的 DID Wallet→",empty:"成为第一个留下评论的人.",delete:"删除",edit:"编辑",confirm:"确认",cancel:"取消",tip:"提示",deleteCommentDesc:"确认删除这条评论?",readMore:"更多内容",showMoreReplies:"显示更多回复",deleted:"该评论已被删除",emptyContent:"暂无评论内容",userActionLog:{and:"和",added:"添加",removed:"移除",label:"标签",labels:"标签",assigned:"分配",unassigned:"取消分配",selfAssigned:"分配自己",selfUnassigned:"取消分配自己",published:"发布",unpublished:"取消发布",changeTitle:"修改标题",edited:"编辑",created:"创建",changeBoard:"修改板块",mention:"提到",pin:"置顶",unpin:"取消置顶",markAsFeatured:"标记为精品",unmarkAsFeatured:"取消精品",passport:"通行证",passports:"通行证"},apiUnavailable:{title:"评论服务不可用",desc:"无法访问评论服务,请检查 Discuss Kit Blocklet 是否运行正常 (服务是否运行中、服务是否设置了访问限制)"}});module.exports=t;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),o=require("@arcblock/did-connect-react/lib/Session"),{SessionProvider:t,SessionContext:e,SessionConsumer:n,withSession:i}=o.createAuthServiceSessionContext();function r(){return s.useContext(e)}exports.SessionConsumer=n;exports.SessionContext=e;exports.SessionProvider=t;exports.useSessionContext=r;exports.withSession=i;
package/lib/es/api.js ADDED
@@ -0,0 +1,44 @@
1
+ import { createAxios as a } from "@blocklet/js-sdk";
2
+ import { utils as c } from "@blocklet/discuss-kit-ux-lite";
3
+ import { discussKitApiPrefix as n } from "./lib/utils.js";
4
+ const s = a({
5
+ baseURL: n,
6
+ timeout: 2e4,
7
+ headers: {
8
+ "x-discuss-kit-client-id": c.getDiscussKitClientId()
9
+ }
10
+ });
11
+ s.interceptors.request.use(
12
+ (t) => t,
13
+ (t) => Promise.reject(t)
14
+ );
15
+ const p = async (t) => {
16
+ const { data: e } = await s.get(`/ratings/${t}`);
17
+ return e;
18
+ }, d = async (t) => {
19
+ try {
20
+ const { data: e } = await s.get("/comments", { params: t });
21
+ return e;
22
+ } catch (e) {
23
+ throw console.error(e), e;
24
+ }
25
+ }, l = async ({ parentId: t, content: e }) => {
26
+ const { data: o } = await s.post("/comments/replies", { content: e, parentId: t });
27
+ return o;
28
+ }, f = async ({ commentId: t, cursor: e, limit: o = 10 }) => {
29
+ try {
30
+ const { data: r } = await s.get(`/comments/${t}/replies`, {
31
+ params: { cursor: e, limit: o, embed: "rating" }
32
+ });
33
+ return r;
34
+ } catch (r) {
35
+ throw console.error(r), r;
36
+ }
37
+ };
38
+ export {
39
+ s as default,
40
+ d as fetchComments,
41
+ f as fetchMoreReplies,
42
+ p as fetchRatings,
43
+ l as reply
44
+ };
@@ -0,0 +1,24 @@
1
+ import { jsxs as r, jsx as o } from "react/jsx-runtime";
2
+ import { useMediaQuery as l, Dialog as m, DialogTitle as p, IconButton as c, DialogContent as d } from "@mui/material";
3
+ import f from "@mui/icons-material/Close";
4
+ import h from "./comments.js";
5
+ function C({ title: n, open: e, onClose: i, ...t }) {
6
+ const s = l((a) => a.breakpoints.down("md"));
7
+ return /* @__PURE__ */ r(m, { fullScreen: s, onClose: i, maxWidth: !1, ...t, open: e, children: [
8
+ /* @__PURE__ */ r(p, { variant: "h4", sx: { position: "relative" }, children: [
9
+ n,
10
+ /* @__PURE__ */ o(
11
+ c,
12
+ {
13
+ onClick: i,
14
+ sx: { position: "absolute", right: 8, top: "50%", transform: "translateY(-50%)" },
15
+ children: /* @__PURE__ */ o(f, {})
16
+ }
17
+ )
18
+ ] }),
19
+ /* @__PURE__ */ o(d, { sx: { width: { xs: 1, sm: 800 } }, children: /* @__PURE__ */ o(h, { ...t }) })
20
+ ] });
21
+ }
22
+ export {
23
+ C as CommentsDialog
24
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import t from "@blocklet/ui-react/lib/ComponentInstaller";
3
+ import s from "prop-types";
4
+ import r from "./comments.js";
5
+ import { DiscussKitDid as a } from "./constants.js";
6
+ function i({ installerProps: o = {}, ...n }) {
7
+ const l = Object.assign(
8
+ {},
9
+ {
10
+ displayReaction: !0,
11
+ onChange: () => {
12
+ },
13
+ flatView: !1,
14
+ autoCollapse: !1,
15
+ autoLoadComments: !0,
16
+ allowCopyLink: !1,
17
+ disabledSend: void 0,
18
+ showProfileCard: !1,
19
+ order: void 0,
20
+ interactive: !0,
21
+ renderComments: null,
22
+ renderDonation: null,
23
+ renderActions: null,
24
+ renderEditorPlugins: null,
25
+ enableAutoTranslate: !1,
26
+ renderInnerFooter: null,
27
+ sendComment: null,
28
+ reactionAppend: null
29
+ },
30
+ o
31
+ );
32
+ return /* @__PURE__ */ e(t, { did: a, ...l, children: /* @__PURE__ */ e(r, { ...n }) });
33
+ }
34
+ i.propTypes = {
35
+ ...r.propTypes,
36
+ installerProps: s.object
37
+ };
38
+ export {
39
+ i as default
40
+ };
@@ -0,0 +1,13 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { getWebWalletUrl as n } from "@arcblock/did-connect-react/lib/utils";
3
+ import i from "./comments.js";
4
+ import { SessionProvider as m } from "./session.js";
5
+ const c = (e) => {
6
+ const o = n();
7
+ return function(t) {
8
+ return /* @__PURE__ */ r(m, { serviceHost: "/", webWalletUrl: o, children: (s) => /* @__PURE__ */ r(e, { ...t, session: s.session, showConnectBtn: !0 }) });
9
+ };
10
+ }, a = c(i);
11
+ export {
12
+ a as default
13
+ };
@@ -0,0 +1,346 @@
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
+ import t from "prop-types";
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-lite";
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
+ const e = (o) => o.endsWith("/") ? o : `${o}/`;
18
+ return window.blocklet?.componentMountPoints?.find(
19
+ (o) => e(o.mountPoint) === e(window.blocklet?.prefix)
20
+ )?.title;
21
+ }, u = (e) => ({
22
+ ...e,
23
+ rootId: e.rootCommentId,
24
+ createdAt: e.createdAt ? new Date(e.createdAt) : null,
25
+ updatedAt: e.updatedAt ? new Date(e.updatedAt) : null,
26
+ deletedAt: e.deletedAt ? new Date(e.deletedAt) : null,
27
+ pinnedAt: e.pinnedAt ? new Date(e.pinnedAt) : null,
28
+ replies: e.replies?.map(u)
29
+ }), Ae = {
30
+ fetchComments: async (e) => {
31
+ const n = {
32
+ ...e,
33
+ embed: e.rootId ? "rating" : "replies,rating",
34
+ size: e.limit
35
+ }, {
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
+ },
40
+ fetchPinnedComments: async (e) => {
41
+ const { data: n } = await i.get("/comments/pinned", { params: { objectId: e } });
42
+ return (n?.data || []).map(u);
43
+ },
44
+ fetchCommentPosition: async ({ id: e, ...n }) => {
45
+ const { data: o } = await i.get(`/comments/${e}/position`, { params: n });
46
+ return o;
47
+ },
48
+ deleteComment: async ({ id: e }) => {
49
+ const { data: n } = await i.delete(`/comments/${e}`);
50
+ return n;
51
+ },
52
+ updateComment: async ({ id: e, updatedAt: n }, o) => {
53
+ const { data: s } = await i.put(`/comments/${e}`, { content: o, updatedAt: n });
54
+ return u(s);
55
+ },
56
+ reply: async ({ id: e }, n) => {
57
+ const { data: o } = await i.post("/comments/replies", {
58
+ content: n,
59
+ parentId: e,
60
+ link: window.location.href
61
+ });
62
+ return u(o);
63
+ },
64
+ rate: async (e, n, o) => {
65
+ await i.post(`/topics/${e.topicId}/comments/${e.id}/ratings`, { ratingType: o, value: n });
66
+ },
67
+ unrate: async (e) => {
68
+ await i.delete(`/topics/${e.topicId}/comments/${e.id}/ratings`);
69
+ },
70
+ fetchRatings: async (e) => {
71
+ const { data: n } = await i.get(`/ratings/${e}`);
72
+ return n;
73
+ },
74
+ togglePin: async ({ post: e, value: n }) => {
75
+ n ? await i.put(`/posts/${e.id}/pinned`) : await i.delete(`/posts/${e.id}/pinned`);
76
+ }
77
+ }, Ie = () => {
78
+ const [e, n] = Q(!0);
79
+ return Ce(
80
+ () => i.get("/status", { muteError: !0 }).then(() => n(!0)).catch(() => n(!1)),
81
+ { cacheKey: "discuss-kit-status", staleTime: -1 }
82
+ ), { available: e };
83
+ };
84
+ function K({
85
+ ref: e = void 0,
86
+ displayReaction: n = !0,
87
+ object: o,
88
+ // onChange = () => {},
89
+ onSendComment: s = () => {
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 = () => {
103
+ },
104
+ draftKey: k = "",
105
+ inputSx: p = {},
106
+ editorRef: f = null,
107
+ disableCmdEnter: h = !1
108
+ }) {
109
+ ce({
110
+ request: i
111
+ });
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")
117
+ ] });
118
+ if (!U)
119
+ return P || /* @__PURE__ */ r(
120
+ c,
121
+ {
122
+ sx: {
123
+ width: "100%",
124
+ display: "flex",
125
+ justifyContent: "center"
126
+ },
127
+ children: /* @__PURE__ */ r(te, {})
128
+ }
129
+ );
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,
135
+ {
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%" })
141
+ ] }),
142
+ children: /* @__PURE__ */ r(
143
+ be,
144
+ {
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
157
+ }
158
+ )
159
+ }
160
+ );
161
+ return /* @__PURE__ */ a($e, { ref: e, children: [
162
+ /* @__PURE__ */ a(j, { children: [
163
+ /* @__PURE__ */ r(
164
+ c,
165
+ {
166
+ sx: {
167
+ display: "flex",
168
+ justifyContent: "space-between",
169
+ alignItems: "end"
170
+ },
171
+ children: n && /* @__PURE__ */ a(me, { sx: { alignItems: "flex-end" }, children: [
172
+ /* @__PURE__ */ r(pe, { id: o.id, request: i, interactive: R }),
173
+ I
174
+ ] })
175
+ }
176
+ ),
177
+ q.user && R && l === "top" && /* @__PURE__ */ r(
178
+ c,
179
+ {
180
+ className: "comment-editor",
181
+ sx: {
182
+ mt: 2
183
+ },
184
+ children: D()
185
+ }
186
+ )
187
+ ] }),
188
+ !!T && A && /* @__PURE__ */ a(
189
+ c,
190
+ {
191
+ sx: {
192
+ display: "flex",
193
+ justifyContent: "space-between",
194
+ alignItems: "center",
195
+ mt: 3
196
+ },
197
+ children: [
198
+ /* @__PURE__ */ a(c, { sx: { fontWeight: "medium" }, children: [
199
+ T > 0 ? `${T} ${d("comments")}` : d("comment"),
200
+ " "
201
+ ] }),
202
+ /* @__PURE__ */ r(
203
+ fe,
204
+ {
205
+ value: O,
206
+ options: [
207
+ { value: "desc", label: d("newest") },
208
+ { value: "asc", label: d("oldest") }
209
+ ],
210
+ onChange: (b) => N(b)
211
+ }
212
+ )
213
+ ]
214
+ }
215
+ ),
216
+ /* @__PURE__ */ r(he, { className: "comment-list" }),
217
+ q.user && R && l === "bottom" && /* @__PURE__ */ r(c, { sx: { mt: 6, ...p }, children: D() })
218
+ ] });
219
+ }
220
+ K.propTypes = {
221
+ ref: t.any,
222
+ displayReaction: t.bool,
223
+ object: t.object.isRequired,
224
+ // onChange: PropTypes.func,
225
+ onSendComment: t.func,
226
+ disabledSend: t.bool,
227
+ autoFocus: t.bool,
228
+ initialContent: t.string,
229
+ sendText: t.string,
230
+ sendIcon: t.node,
231
+ commentInputPosition: t.oneOf(["top", "bottom"]),
232
+ showTopbar: t.bool,
233
+ sendComment: t.func,
234
+ reactionAppend: t.any,
235
+ skeleton: t.node,
236
+ placeholder: t.string,
237
+ onInput: t.func,
238
+ draftKey: t.string,
239
+ editorRef: t.object,
240
+ inputSx: t.object,
241
+ disableCmdEnter: t.bool
242
+ };
243
+ function Pe({
244
+ target: e,
245
+ flatView: n = !1,
246
+ autoCollapse: o = !1,
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,
258
+ ...$
259
+ }) {
260
+ const S = Object.assign(
261
+ {},
262
+ {
263
+ displayReaction: !0,
264
+ onChange: () => {
265
+ },
266
+ onSendComment: () => {
267
+ },
268
+ disabledSend: void 0,
269
+ sendComment: null,
270
+ reactionAppend: null
271
+ },
272
+ $
273
+ );
274
+ if (!e?.id)
275
+ throw new Error("target is required.");
276
+ const { locale: k = "en" } = F() || {}, p = M(), f = H(
277
+ () => ({
278
+ link: window.location.href,
279
+ blockletName: ve(),
280
+ ...e
281
+ }),
282
+ // eslint-disable-next-line react-hooks/exhaustive-deps
283
+ [e]
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,
289
+ {
290
+ target: f,
291
+ api: Ae,
292
+ flatView: n,
293
+ order: l,
294
+ autoCollapse: o,
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 })
307
+ }
308
+ ) }) }) }) }) }) });
309
+ }
310
+ Pe.propTypes = {
311
+ target: t.shape({
312
+ id: t.string.isRequired,
313
+ title: t.string,
314
+ desc: t.string,
315
+ owner: t.string
316
+ }).isRequired,
317
+ displayReaction: t.bool,
318
+ onChange: t.func,
319
+ flatView: t.bool,
320
+ autoCollapse: t.bool,
321
+ autoLoadComments: t.bool,
322
+ allowCopyLink: t.bool,
323
+ disabledSend: t.bool,
324
+ showProfileCard: t.bool,
325
+ order: t.oneOf(["asc", "desc"]),
326
+ interactive: t.bool,
327
+ renderComments: t.func,
328
+ renderDonation: t.any,
329
+ renderActions: t.func,
330
+ renderEditorPlugins: t.func,
331
+ enableAutoTranslate: t.bool,
332
+ renderInnerFooter: t.func,
333
+ sendComment: t.func,
334
+ reactionAppend: t.any
335
+ };
336
+ const $e = Y("div")`
337
+ width: 100%;
338
+ margin: 0 auto;
339
+ box-sizing: border-box;
340
+ padding: ${(e) => e.padding ? "20px" : "0"};
341
+ border: ${(e) => e.border ? "1px solid rgb(208, 215, 222)" : "none"};
342
+ border-radius: 6px;
343
+ `;
344
+ export {
345
+ Pe as default
346
+ };
@@ -0,0 +1,36 @@
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import { useState as n, useEffect as p } from "react";
3
+ import l from "prop-types";
4
+ import a from "@mui/material/Alert";
5
+ import m from "@mui/material/AlertTitle";
6
+ import c from "@mui/material/Button";
7
+ import d from "@mui/material/Collapse";
8
+ import f from "@mui/material/Box";
9
+ function u({ error: e }) {
10
+ const [o, t] = n(!1);
11
+ return p(() => {
12
+ console.error(e);
13
+ }, [e]), /* @__PURE__ */ i(
14
+ a,
15
+ {
16
+ severity: "warning",
17
+ action: e ? /* @__PURE__ */ r(c, { color: "inherit", size: "small", onClick: () => t((s) => !s), children: o ? "Hide details" : "Show details" }) : void 0,
18
+ sx: { ".MuiAlert-action": { flex: "0 0 auto" } },
19
+ children: [
20
+ /* @__PURE__ */ r(m, { children: "Oops!" }),
21
+ "Discuss Kit is not working properly.",
22
+ e && /* @__PURE__ */ r(d, { in: o, children: /* @__PURE__ */ i(f, { component: "pre", sx: { mt: 1, mb: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: [
23
+ e.message,
24
+ /* @__PURE__ */ r("br", {}),
25
+ e.stack
26
+ ] }) })
27
+ ]
28
+ }
29
+ );
30
+ }
31
+ u.propTypes = {
32
+ error: l.instanceOf(Error).isRequired
33
+ };
34
+ export {
35
+ u as default
36
+ };
@@ -0,0 +1,60 @@
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
+ };
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,
20
+ {
21
+ anchorEl: t,
22
+ anchorOrigin: {
23
+ vertical: "bottom",
24
+ horizontal: "right"
25
+ },
26
+ transformOrigin: {
27
+ vertical: "top",
28
+ horizontal: "right"
29
+ },
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
+ ))
46
+ }
47
+ )
48
+ ] });
49
+ }
50
+ g.propTypes = {
51
+ items: f.array.isRequired
52
+ };
53
+ const z = e("div")`
54
+ display: inline-block;
55
+ `, v = e(y)`
56
+ font-size: 14px;
57
+ `;
58
+ export {
59
+ g as default
60
+ };
@@ -0,0 +1,4 @@
1
+ const i = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
2
+ export {
3
+ i as DiscussKitDid
4
+ };
@@ -0,0 +1,15 @@
1
+ import { useSubscription as t } from "@blocklet/discuss-kit-ux-lite";
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);
8
+ },
9
+ [i],
10
+ e
11
+ );
12
+ };
13
+ export {
14
+ n as useCommentsListener
15
+ };
@@ -0,0 +1,19 @@
1
+ import { useEffect as i } from "react";
2
+ import c from "../api.js";
3
+ import { isInIframe as n } from "../lib/utils.js";
4
+ const s = (o) => {
5
+ i(() => {
6
+ const t = () => {
7
+ c.put(`/comments/topics/${o.id}`, {
8
+ title: o.title,
9
+ link: o.link
10
+ }).catch((e) => {
11
+ console.error(e);
12
+ });
13
+ };
14
+ !window.blocklet.componentId?.endsWith("z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu") && !n() && t();
15
+ }, []);
16
+ };
17
+ export {
18
+ s as useTopicInfoSync
19
+ };
@@ -0,0 +1,10 @@
1
+ import { default as m } from "./comments-installer.js";
2
+ import { default as s } from "./comments-with-session.js";
3
+ import { useCommentsListener as f } from "./hooks/comment-listener.js";
4
+ import { CommentsDialog as a } from "./comments-dialog.js";
5
+ export {
6
+ m as Comments,
7
+ a as CommentsDialog,
8
+ s as CommentsWithSession,
9
+ f as useCommentsListener
10
+ };
@@ -0,0 +1,22 @@
1
+ import { joinURL as s } from "ufo";
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 = () => {
7
+ try {
8
+ return window.self !== window.top;
9
+ } catch {
10
+ return !0;
11
+ }
12
+ };
13
+ export {
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
22
+ };
@@ -0,0 +1,53 @@
1
+ import e from "flat";
2
+ const s = e({
3
+ comments: "Comments",
4
+ comment: "Comment",
5
+ poweredBy: "- powered by Discuss Kit",
6
+ connect: "Connect",
7
+ inputPlaceHolder: "Write a comment",
8
+ oldest: "Oldest",
9
+ newest: "Newest",
10
+ loadMore: "Click To Load More",
11
+ connectDIDWallet: "Please connect DID Wallet.",
12
+ installDIDWallet: "Click to get your own DID Wallet→",
13
+ empty: "Be the first to leave a comment.",
14
+ delete: "Delete",
15
+ edit: "Edit",
16
+ confirm: "Confirm",
17
+ cancel: "Cancel",
18
+ tip: "Tip",
19
+ deleteCommentDesc: "Confirm delete this comment?",
20
+ readMore: "Read More",
21
+ showMoreReplies: "Show more replies",
22
+ deleted: "This comment has been deleted",
23
+ emptyContent: "No comment yet",
24
+ userActionLog: {
25
+ and: "and",
26
+ added: "added the",
27
+ removed: "removed the",
28
+ label: "label",
29
+ labels: "labels",
30
+ assigned: "assigned",
31
+ unassigned: "unassigned",
32
+ selfAssigned: "self-assigned this",
33
+ selfUnassigned: "self-unassigned this",
34
+ published: "published this",
35
+ unpublished: "unpublished this",
36
+ changeTitle: "changed the title",
37
+ changeBoard: "changed the board",
38
+ mention: "mentioned this",
39
+ pin: "pinned this",
40
+ unpin: "unpinned this",
41
+ markAsFeatured: "marked this as featured",
42
+ unmarkAsFeatured: "unmarked this as featured",
43
+ passport: "passport",
44
+ passports: "passports"
45
+ },
46
+ apiUnavailable: {
47
+ title: "Comment service is not available",
48
+ desc: "Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."
49
+ }
50
+ });
51
+ export {
52
+ s as default
53
+ };
@@ -0,0 +1,8 @@
1
+ import o from "flat";
2
+ import { translations as t } from "@blocklet/discuss-kit-ux-lite";
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
+ export {
7
+ f as translations
8
+ };
@@ -0,0 +1,55 @@
1
+ import e from "flat";
2
+ const s = e({
3
+ comments: "条评论",
4
+ comment: "评论",
5
+ poweredBy: "- 由 Discuss Kit 提供支持",
6
+ connect: "连接",
7
+ inputPlaceHolder: "写评论",
8
+ oldest: "最旧",
9
+ newest: "最新",
10
+ loadMore: "点击加载更多",
11
+ connectDIDWallet: "请先连接 DID Wallet.",
12
+ installDIDWallet: "点击拥有你的 DID Wallet→",
13
+ empty: "成为第一个留下评论的人.",
14
+ delete: "删除",
15
+ edit: "编辑",
16
+ confirm: "确认",
17
+ cancel: "取消",
18
+ tip: "提示",
19
+ deleteCommentDesc: "确认删除这条评论?",
20
+ readMore: "更多内容",
21
+ showMoreReplies: "显示更多回复",
22
+ deleted: "该评论已被删除",
23
+ emptyContent: "暂无评论内容",
24
+ userActionLog: {
25
+ and: "和",
26
+ added: "添加",
27
+ removed: "移除",
28
+ label: "标签",
29
+ labels: "标签",
30
+ assigned: "分配",
31
+ unassigned: "取消分配",
32
+ selfAssigned: "分配自己",
33
+ selfUnassigned: "取消分配自己",
34
+ published: "发布",
35
+ unpublished: "取消发布",
36
+ changeTitle: "修改标题",
37
+ edited: "编辑",
38
+ created: "创建",
39
+ changeBoard: "修改板块",
40
+ mention: "提到",
41
+ pin: "置顶",
42
+ unpin: "取消置顶",
43
+ markAsFeatured: "标记为精品",
44
+ unmarkAsFeatured: "取消精品",
45
+ passport: "通行证",
46
+ passports: "通行证"
47
+ },
48
+ apiUnavailable: {
49
+ title: "评论服务不可用",
50
+ desc: "无法访问评论服务,请检查 Discuss Kit Blocklet 是否运行正常 (服务是否运行中、服务是否设置了访问限制)"
51
+ }
52
+ });
53
+ export {
54
+ s as default
55
+ };
@@ -0,0 +1,13 @@
1
+ import { useContext as e } from "react";
2
+ import { createAuthServiceSessionContext as o } from "@arcblock/did-connect-react/lib/Session";
3
+ const { SessionProvider: r, SessionContext: t, SessionConsumer: S, withSession: u } = o();
4
+ function a() {
5
+ return e(t);
6
+ }
7
+ export {
8
+ S as SessionConsumer,
9
+ t as SessionContext,
10
+ r as SessionProvider,
11
+ a as useSessionContext,
12
+ u as withSession
13
+ };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@blocklet/discuss-kit-lite",
3
+ "version": "2.6.0",
4
+ "description": "A react component for Discuss Kit blocklet.",
5
+ "main": "./lib/cjs/index.js",
6
+ "module": "./lib/es/index.js",
7
+ "typings": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./lib/es/index.js",
11
+ "require": "./lib/cjs/index.js"
12
+ },
13
+ "./components/": {
14
+ "import": "./lib/es/components/",
15
+ "require": "./lib/cjs/components/"
16
+ }
17
+ },
18
+ "keywords": [
19
+ "did"
20
+ ],
21
+ "files": [
22
+ "lib",
23
+ "LICENSE",
24
+ "package.json",
25
+ "README.md"
26
+ ],
27
+ "author": "Nate <nate@arcblock.io> (http://github.com/NateRobinson)",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@arcblock/ws": "^1.27.16",
31
+ "@blocklet/js-sdk": "^1.17.7-beta-20251225-073259-cb6ecf68",
32
+ "@dnd-kit/core": "^6.1.0",
33
+ "@dnd-kit/sortable": "^8.0.0",
34
+ "@dnd-kit/utilities": "^3.2.2",
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
+ "@uiw/react-md-editor": "^3.25.6",
41
+ "ahooks": "^3.8.1",
42
+ "axios": "^0.27.2",
43
+ "clsx": "^1.2.1",
44
+ "flat": "^5.0.2",
45
+ "js-cookie": "^3.0.5",
46
+ "lodash": "^4.17.21",
47
+ "prop-types": "^15.8.1",
48
+ "react-error-boundary": "^3.1.4",
49
+ "rehype-sanitize": "^5.0.1",
50
+ "timeago.js": "^4.0.2",
51
+ "@blocklet/discuss-kit-ux-lite": "2.6.0",
52
+ "@blocklet/editor-lite": "2.6.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@arcblock/did-connect-react": "^3.1.5",
56
+ "@arcblock/ux": "^3.1.5",
57
+ "@blocklet/ui-react": "^3.0.1",
58
+ "react": "^19.1.0",
59
+ "react-dom": "^19.1.0"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "devDependencies": {
65
+ "@vitejs/plugin-react": "^4.6.0",
66
+ "eslint-plugin-react-hooks": "^4.6.2",
67
+ "fast-glob": "^3.3.3",
68
+ "jest": "^24.9.0",
69
+ "vite": "^7.0.0",
70
+ "vite-plugin-no-bundle": "^4.0.0",
71
+ "vite-plugin-svgr": "^4.3.0"
72
+ },
73
+ "scripts": {
74
+ "lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
75
+ "lint:fix": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx --fix",
76
+ "build": "vite build",
77
+ "watch": "vite build --watch",
78
+ "prepublish": "npm run build"
79
+ }
80
+ }