@blocklet/discuss-kit 2.3.105 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api.js +1 -51
- package/lib/cjs/comments-dialog.js +1 -24
- package/lib/cjs/comments-installer.js +1 -18
- package/lib/cjs/comments-with-session.js +1 -15
- package/lib/cjs/comments.js +4 -387
- package/lib/cjs/components/error-fallback.js +1 -17
- package/lib/cjs/components/menu.js +3 -58
- package/lib/cjs/constants.js +1 -4
- package/lib/cjs/hooks/comment-listener.js +1 -17
- package/lib/cjs/hooks/topic-info-sync.js +1 -22
- package/lib/cjs/index.js +1 -25
- package/lib/cjs/lib/utils.js +1 -37
- package/lib/cjs/locales/en.js +1 -52
- package/lib/cjs/locales/index.js +1 -8
- package/lib/cjs/locales/zh.js +1 -54
- package/lib/cjs/session.js +1 -14
- package/lib/es/api.js +30 -37
- package/lib/es/comments-dialog.js +15 -15
- package/lib/es/comments-installer.js +36 -15
- package/lib/es/comments-with-session.js +10 -13
- package/lib/es/comments.js +320 -353
- package/lib/es/components/error-fallback.js +12 -12
- package/lib/es/components/menu.js +40 -41
- package/lib/es/constants.js +2 -2
- package/lib/es/hooks/comment-listener.js +10 -12
- package/lib/es/hooks/topic-info-sync.js +14 -16
- package/lib/es/index.js +11 -11
- package/lib/es/lib/utils.js +16 -31
- package/lib/es/locales/en.js +3 -3
- package/lib/es/locales/index.js +6 -6
- package/lib/es/locales/zh.js +3 -3
- package/lib/es/session.js +10 -11
- package/package.json +18 -17
package/lib/cjs/api.js
CHANGED
|
@@ -1,51 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsSdk = require("@blocklet/js-sdk");
|
|
4
|
-
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
5
|
-
const utils = require("./lib/utils");
|
|
6
|
-
const request = jsSdk.createAxios({
|
|
7
|
-
baseURL: utils.discussKitApiPrefix,
|
|
8
|
-
timeout: 2e4,
|
|
9
|
-
headers: {
|
|
10
|
-
"x-discuss-kit-client-id": discussKitUx.utils.getDiscussKitClientId()
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
request.interceptors.request.use(
|
|
14
|
-
(config) => {
|
|
15
|
-
return config;
|
|
16
|
-
},
|
|
17
|
-
(error) => Promise.reject(error)
|
|
18
|
-
);
|
|
19
|
-
const fetchRatings = async (id) => {
|
|
20
|
-
const { data } = await request.get(`/ratings/${id}`);
|
|
21
|
-
return data;
|
|
22
|
-
};
|
|
23
|
-
const fetchComments = async (params) => {
|
|
24
|
-
try {
|
|
25
|
-
const { data } = await request.get("/comments", { params });
|
|
26
|
-
return data;
|
|
27
|
-
} catch (e) {
|
|
28
|
-
console.error(e);
|
|
29
|
-
throw e;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const reply = async ({ parentId, content }) => {
|
|
33
|
-
const { data } = await request.post("/comments/replies", { content, parentId });
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
const fetchMoreReplies = async ({ commentId, cursor, limit = 10 }) => {
|
|
37
|
-
try {
|
|
38
|
-
const { data } = await request.get(`/comments/${commentId}/replies`, {
|
|
39
|
-
params: { cursor, limit, embed: "rating" }
|
|
40
|
-
});
|
|
41
|
-
return data;
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.default = request;
|
|
48
|
-
exports.fetchComments = fetchComments;
|
|
49
|
-
exports.fetchMoreReplies = fetchMoreReplies;
|
|
50
|
-
exports.fetchRatings = fetchRatings;
|
|
51
|
-
exports.reply = reply;
|
|
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"),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;
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const material = require("@mui/material");
|
|
5
|
-
const CloseIcon = require("@mui/icons-material/Close");
|
|
6
|
-
const Comments = require("./comments");
|
|
7
|
-
function CommentsDialog({ title, open, onClose, ...rest }) {
|
|
8
|
-
const fullScreen = material.useMediaQuery((theme) => theme.breakpoints.down("md"));
|
|
9
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(material.Dialog, { fullScreen, onClose, maxWidth: false, ...rest, open, children: [
|
|
10
|
-
/* @__PURE__ */ jsxRuntime.jsxs(material.DialogTitle, { variant: "h4", sx: { position: "relative" }, children: [
|
|
11
|
-
title,
|
|
12
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13
|
-
material.IconButton,
|
|
14
|
-
{
|
|
15
|
-
onClick: onClose,
|
|
16
|
-
sx: { position: "absolute", right: 8, top: "50%", transform: "translateY(-50%)" },
|
|
17
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
18
|
-
}
|
|
19
|
-
)
|
|
20
|
-
] }),
|
|
21
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.DialogContent, { sx: { width: { xs: 1, sm: 800 } }, children: /* @__PURE__ */ jsxRuntime.jsx(Comments, { ...rest }) })
|
|
22
|
-
] });
|
|
23
|
-
}
|
|
24
|
-
exports.CommentsDialog = CommentsDialog;
|
|
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;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const uiReact = require("@blocklet/ui-react");
|
|
4
|
-
const PropTypes = require("prop-types");
|
|
5
|
-
const Comments = require("./comments");
|
|
6
|
-
const constants = require("./constants");
|
|
7
|
-
function CommentsInstaller({ installerProps, ...rest }) {
|
|
8
|
-
return /* @__PURE__ */ jsxRuntime.jsx(uiReact.ComponentInstaller, { did: constants.DiscussKitDid, ...installerProps, children: /* @__PURE__ */ jsxRuntime.jsx(Comments, { ...rest }) });
|
|
9
|
-
}
|
|
10
|
-
CommentsInstaller.propTypes = {
|
|
11
|
-
...Comments.propTypes,
|
|
12
|
-
installerProps: PropTypes.object
|
|
13
|
-
};
|
|
14
|
-
CommentsInstaller.defaultProps = {
|
|
15
|
-
...Comments.defaultProps,
|
|
16
|
-
installerProps: {}
|
|
17
|
-
};
|
|
18
|
-
module.exports = CommentsInstaller;
|
|
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;
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const utils = require("@arcblock/did-connect/lib/utils");
|
|
4
|
-
const Comments = require("./comments");
|
|
5
|
-
const session = require("./session");
|
|
6
|
-
const CommentsHOC = (WrappedComponent) => {
|
|
7
|
-
const webWalletUrl = utils.getWebWalletUrl();
|
|
8
|
-
return function(props) {
|
|
9
|
-
return /* @__PURE__ */ jsxRuntime.jsx(session.SessionProvider, { serviceHost: "/", webWalletUrl, children: (session2) => {
|
|
10
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props, session: session2.session, showConnectBtn: true });
|
|
11
|
-
} });
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const commentsWithSession = CommentsHOC(Comments);
|
|
15
|
-
module.exports = commentsWithSession;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("@arcblock/did-connect/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;
|
package/lib/cjs/comments.js
CHANGED
|
@@ -1,391 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const Theme = require("@arcblock/ux/lib/Theme");
|
|
5
|
-
const PropTypes = require("prop-types");
|
|
6
|
-
const Session = require("@arcblock/did-connect/lib/Session");
|
|
7
|
-
const material = require("@mui/material");
|
|
8
|
-
const context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
-
const reactErrorBoundary = require("react-error-boundary");
|
|
10
|
-
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
11
|
-
const ahooks = require("ahooks");
|
|
12
|
-
const ErrorFallback = require("./components/error-fallback");
|
|
13
|
-
const locales = require("./locales");
|
|
14
|
-
const utils = require("./lib/utils");
|
|
15
|
-
const api = require("./api");
|
|
16
|
-
const topicInfoSync = require("./hooks/topic-info-sync");
|
|
17
|
-
const getCurrentBlockletComponentName = () => {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const ensureTrailingSlash = (str) => str.endsWith("/") ? str : `${str}/`;
|
|
20
|
-
const matched = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
21
|
-
(x) => {
|
|
22
|
-
var _a2;
|
|
23
|
-
return ensureTrailingSlash(x.mountPoint) === ensureTrailingSlash((_a2 = window.blocklet) == null ? void 0 : _a2.prefix);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
return matched == null ? void 0 : matched.title;
|
|
27
|
-
};
|
|
28
|
-
const formatComment = (comment) => {
|
|
29
|
-
var _a;
|
|
30
|
-
return {
|
|
31
|
-
...comment,
|
|
32
|
-
rootId: comment.rootCommentId,
|
|
33
|
-
createdAt: comment.createdAt ? new Date(comment.createdAt) : null,
|
|
34
|
-
updatedAt: comment.updatedAt ? new Date(comment.updatedAt) : null,
|
|
35
|
-
deletedAt: comment.deletedAt ? new Date(comment.deletedAt) : null,
|
|
36
|
-
pinnedAt: comment.pinnedAt ? new Date(comment.pinnedAt) : null,
|
|
37
|
-
replies: (_a = comment.replies) == null ? void 0 : _a.map(formatComment)
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const commentAPI = {
|
|
41
|
-
fetchComments: async (params) => {
|
|
42
|
-
const copy = {
|
|
43
|
-
...params,
|
|
44
|
-
embed: params.rootId ? "rating" : "replies,rating",
|
|
45
|
-
size: params.limit
|
|
46
|
-
};
|
|
47
|
-
const {
|
|
48
|
-
data: { data, nextCursor, total }
|
|
49
|
-
} = await api.get("/comments", { params: copy });
|
|
50
|
-
return { data: data == null ? void 0 : data.map(formatComment), nextCursor, total };
|
|
51
|
-
},
|
|
52
|
-
fetchPinnedComments: async (objectId) => {
|
|
53
|
-
const { data } = await api.get("/comments/pinned", { params: { objectId } });
|
|
54
|
-
return ((data == null ? void 0 : data.data) || []).map(formatComment);
|
|
55
|
-
},
|
|
56
|
-
fetchCommentPosition: async ({ id, ...params }) => {
|
|
57
|
-
const { data } = await api.get(`/comments/${id}/position`, { params });
|
|
58
|
-
return data;
|
|
59
|
-
},
|
|
60
|
-
deleteComment: async ({ id }) => {
|
|
61
|
-
const { data } = await api.delete(`/comments/${id}`);
|
|
62
|
-
return data;
|
|
63
|
-
},
|
|
64
|
-
updateComment: async ({ id, updatedAt }, content) => {
|
|
65
|
-
const { data } = await api.put(`/comments/${id}`, { content, updatedAt });
|
|
66
|
-
return formatComment(data);
|
|
67
|
-
},
|
|
68
|
-
reply: async ({ id }, content) => {
|
|
69
|
-
const { data } = await api.post("/comments/replies", {
|
|
70
|
-
content,
|
|
71
|
-
parentId: id,
|
|
72
|
-
link: window.location.href
|
|
73
|
-
});
|
|
74
|
-
return formatComment(data);
|
|
75
|
-
},
|
|
76
|
-
rate: async (comment, value, ratingType) => {
|
|
77
|
-
await api.post(`/topics/${comment.topicId}/comments/${comment.id}/ratings`, { ratingType, value });
|
|
78
|
-
},
|
|
79
|
-
unrate: async (comment) => {
|
|
80
|
-
await api.delete(`/topics/${comment.topicId}/comments/${comment.id}/ratings`);
|
|
81
|
-
},
|
|
82
|
-
fetchRatings: async (id) => {
|
|
83
|
-
const { data } = await api.get(`/ratings/${id}`);
|
|
84
|
-
return data;
|
|
85
|
-
},
|
|
86
|
-
togglePin: async ({ post, value }) => {
|
|
87
|
-
if (value) {
|
|
88
|
-
await api.put(`/posts/${post.id}/pinned`);
|
|
89
|
-
} else {
|
|
90
|
-
await api.delete(`/posts/${post.id}/pinned`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const useDiscussKitStatus = () => {
|
|
95
|
-
const [available, setAvailable] = react.useState(true);
|
|
96
|
-
ahooks.useRequest(
|
|
97
|
-
() => api.get("/status", { muteError: true }).then(() => setAvailable(true)).catch(() => setAvailable(false)),
|
|
98
|
-
{ cacheKey: "discuss-kit-status", staleTime: -1 }
|
|
99
|
-
);
|
|
100
|
-
return { available };
|
|
101
|
-
};
|
|
102
|
-
const DiscussKitComments = react.forwardRef(
|
|
103
|
-
({
|
|
104
|
-
displayReaction,
|
|
105
|
-
object,
|
|
106
|
-
onChange,
|
|
107
|
-
onSendComment,
|
|
108
|
-
commentInputPosition,
|
|
109
|
-
autoFocus,
|
|
110
|
-
disabledSend,
|
|
111
|
-
initialContent,
|
|
112
|
-
sendText,
|
|
113
|
-
sendIcon,
|
|
114
|
-
showTopbar,
|
|
115
|
-
sendComment,
|
|
116
|
-
reactionAppend,
|
|
117
|
-
skeleton,
|
|
118
|
-
placeholder,
|
|
119
|
-
onInput,
|
|
120
|
-
draftKey,
|
|
121
|
-
inputSx,
|
|
122
|
-
editorRef,
|
|
123
|
-
disableCmdEnter
|
|
124
|
-
}, ref) => {
|
|
125
|
-
discussKitUx.useDefaultApiErrorHandler({
|
|
126
|
-
request: api
|
|
127
|
-
});
|
|
128
|
-
const { available } = useDiscussKitStatus();
|
|
129
|
-
const { session } = react.useContext(Session.SessionContext) || {};
|
|
130
|
-
const { state, sort, add, updateCommentState, interactive, findById, renderInnerFooter } = discussKitUx.useCommentsContext();
|
|
131
|
-
const { total, order, initialized } = state;
|
|
132
|
-
const { t } = context.useLocaleContext();
|
|
133
|
-
topicInfoSync.useTopicInfoSync(object);
|
|
134
|
-
const handlers = {
|
|
135
|
-
ADD_COMMENT: (data) => {
|
|
136
|
-
add(formatComment(data));
|
|
137
|
-
onChange == null ? void 0 : onChange();
|
|
138
|
-
},
|
|
139
|
-
UPDATE_COMMENT: (data) => {
|
|
140
|
-
const comment = findById(data.id);
|
|
141
|
-
if (comment && comment.content !== data.content) {
|
|
142
|
-
updateCommentState(data.id, (current) => {
|
|
143
|
-
current.content = data.content;
|
|
144
|
-
current.updatedAt = data.updatedAt;
|
|
145
|
-
current.synced = Date.now();
|
|
146
|
-
return current;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
RATING_COMMENT: async ({ commentId }) => {
|
|
151
|
-
const rating = await api.fetchRatings(commentId);
|
|
152
|
-
updateCommentState(commentId, (current) => ({
|
|
153
|
-
...current,
|
|
154
|
-
rating
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
discussKitUx.useSubscription(
|
|
159
|
-
object.id,
|
|
160
|
-
({ event, data }) => {
|
|
161
|
-
var _a;
|
|
162
|
-
(_a = handlers[event]) == null ? void 0 : _a.call(handlers, data);
|
|
163
|
-
},
|
|
164
|
-
[object.id, state]
|
|
165
|
-
);
|
|
166
|
-
if (!available) {
|
|
167
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(material.Alert, { severity: "info", children: [
|
|
168
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.AlertTitle, { children: t("apiUnavailable.title") }),
|
|
169
|
-
t("apiUnavailable.desc")
|
|
170
|
-
] });
|
|
171
|
-
}
|
|
172
|
-
if (!initialized) {
|
|
173
|
-
return skeleton || /* @__PURE__ */ jsxRuntime.jsx(material.Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, {}) });
|
|
174
|
-
}
|
|
175
|
-
const handleSendComment = async (content) => {
|
|
176
|
-
const { data } = await (sendComment ? sendComment({ content, object }) : api.post("/comments", { content, object }));
|
|
177
|
-
add(formatComment(data));
|
|
178
|
-
onSendComment == null ? void 0 : onSendComment(data);
|
|
179
|
-
};
|
|
180
|
-
const renderCommentInput = () => {
|
|
181
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
-
discussKitUx.CommentInput,
|
|
183
|
-
{
|
|
184
|
-
editorRef,
|
|
185
|
-
placeholder,
|
|
186
|
-
send: handleSendComment,
|
|
187
|
-
draftKey: draftKey || `object-${object.id}`,
|
|
188
|
-
autoFocus,
|
|
189
|
-
disabledSend,
|
|
190
|
-
initialContent,
|
|
191
|
-
sendText,
|
|
192
|
-
sendIcon,
|
|
193
|
-
renderInnerFooter,
|
|
194
|
-
onChange: onInput,
|
|
195
|
-
disableCmdEnter
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Container, { ref, children: [
|
|
200
|
-
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
201
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: displayReaction && /* @__PURE__ */ jsxRuntime.jsxs(discussKitUx.IconButtonGroup, { sx: { alignItems: "flex-end" }, children: [
|
|
202
|
-
/* @__PURE__ */ jsxRuntime.jsx(discussKitUx.GithubReactionContainer, { id: object.id, request: api, interactive }),
|
|
203
|
-
reactionAppend
|
|
204
|
-
] }) }),
|
|
205
|
-
session.user && interactive && commentInputPosition === "top" && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { mt: 2, className: "comment-editor", children: renderCommentInput() })
|
|
206
|
-
] }),
|
|
207
|
-
!!total && showTopbar && /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { display: "flex", justifyContent: "space-between", alignItems: "center", mt: 3, children: [
|
|
208
|
-
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { fontWeight: "medium" }, children: [
|
|
209
|
-
total > 0 ? `${total} ${t("comments")}` : t("comment"),
|
|
210
|
-
" "
|
|
211
|
-
] }),
|
|
212
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
-
discussKitUx.SegmentedControl,
|
|
214
|
-
{
|
|
215
|
-
value: order,
|
|
216
|
-
options: [
|
|
217
|
-
{ value: "desc", label: t("newest") },
|
|
218
|
-
{ value: "asc", label: t("oldest") }
|
|
219
|
-
],
|
|
220
|
-
onChange: (value) => sort(value)
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
] }),
|
|
224
|
-
/* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentList, { className: "comment-list" }),
|
|
225
|
-
session.user && interactive && commentInputPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mt: 6, ...inputSx }, children: renderCommentInput() })
|
|
226
|
-
] });
|
|
227
|
-
}
|
|
228
|
-
);
|
|
229
|
-
DiscussKitComments.propTypes = {
|
|
230
|
-
displayReaction: PropTypes.bool,
|
|
231
|
-
object: PropTypes.object.isRequired,
|
|
232
|
-
onChange: PropTypes.func,
|
|
233
|
-
onSendComment: PropTypes.func,
|
|
234
|
-
disabledSend: PropTypes.bool,
|
|
235
|
-
autoFocus: PropTypes.bool,
|
|
236
|
-
initialContent: PropTypes.string,
|
|
237
|
-
sendText: PropTypes.string,
|
|
238
|
-
sendIcon: PropTypes.node,
|
|
239
|
-
commentInputPosition: PropTypes.oneOf(["top", "bottom"]),
|
|
240
|
-
showTopbar: PropTypes.bool,
|
|
241
|
-
sendComment: PropTypes.func,
|
|
242
|
-
reactionAppend: PropTypes.any,
|
|
243
|
-
skeleton: PropTypes.node,
|
|
244
|
-
placeholder: PropTypes.string,
|
|
245
|
-
onInput: PropTypes.func,
|
|
246
|
-
draftKey: PropTypes.string,
|
|
247
|
-
editorRef: PropTypes.object,
|
|
248
|
-
inputSx: PropTypes.object,
|
|
249
|
-
disableCmdEnter: PropTypes.bool
|
|
250
|
-
};
|
|
251
|
-
DiscussKitComments.defaultProps = {
|
|
252
|
-
displayReaction: true,
|
|
253
|
-
onChange: () => {
|
|
254
|
-
},
|
|
255
|
-
onSendComment: () => {
|
|
256
|
-
},
|
|
257
|
-
disabledSend: void 0,
|
|
258
|
-
autoFocus: false,
|
|
259
|
-
initialContent: "",
|
|
260
|
-
sendText: "",
|
|
261
|
-
sendIcon: null,
|
|
262
|
-
commentInputPosition: "top",
|
|
263
|
-
showTopbar: true,
|
|
264
|
-
sendComment: null,
|
|
265
|
-
reactionAppend: null,
|
|
266
|
-
skeleton: null,
|
|
267
|
-
placeholder: "",
|
|
268
|
-
onInput: () => {
|
|
269
|
-
},
|
|
270
|
-
draftKey: "",
|
|
271
|
-
editorRef: null,
|
|
272
|
-
inputSx: {},
|
|
273
|
-
disableCmdEnter: false
|
|
274
|
-
};
|
|
275
|
-
function Wrapper({
|
|
276
|
-
target,
|
|
277
|
-
flatView,
|
|
278
|
-
autoCollapse,
|
|
279
|
-
autoLoadComments,
|
|
280
|
-
order,
|
|
281
|
-
allowCopyLink,
|
|
282
|
-
showProfileCard,
|
|
283
|
-
interactive,
|
|
284
|
-
renderComments,
|
|
285
|
-
renderDonation,
|
|
286
|
-
renderActions,
|
|
287
|
-
renderEditorPlugins,
|
|
288
|
-
enableAutoTranslate,
|
|
289
|
-
renderInnerFooter,
|
|
290
|
-
...rest
|
|
291
|
-
}) {
|
|
292
|
-
if (!(target == null ? void 0 : target.id)) {
|
|
293
|
-
throw new Error("target is required.");
|
|
294
|
-
}
|
|
295
|
-
const { locale = "en" } = context.useLocaleContext() || {};
|
|
296
|
-
const containerRef = react.useRef();
|
|
297
|
-
const object = react.useMemo(
|
|
298
|
-
() => ({
|
|
299
|
-
link: window.location.href,
|
|
300
|
-
blockletName: getCurrentBlockletComponentName(),
|
|
301
|
-
...target
|
|
302
|
-
}),
|
|
303
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
304
|
-
[target]
|
|
305
|
-
);
|
|
306
|
-
const wsClient = discussKitUx.getWsClient(utils.discussKitPrefix);
|
|
307
|
-
react.useEffect(() => {
|
|
308
|
-
wsClient.connect();
|
|
309
|
-
return () => {
|
|
310
|
-
if (wsClient.isConnected()) ;
|
|
311
|
-
};
|
|
312
|
-
}, []);
|
|
313
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { FallbackComponent: ErrorFallback, children: /* @__PURE__ */ jsxRuntime.jsx(context.LocaleProvider, { translations: locales.translations, locale, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.UploaderProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.ConfirmProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
314
|
-
discussKitUx.CommentsProvider,
|
|
315
|
-
{
|
|
316
|
-
target: object,
|
|
317
|
-
api: commentAPI,
|
|
318
|
-
flatView,
|
|
319
|
-
order,
|
|
320
|
-
autoCollapse,
|
|
321
|
-
autoLoadComments,
|
|
322
|
-
allowCopyLink,
|
|
323
|
-
showProfileCard,
|
|
324
|
-
interactive,
|
|
325
|
-
containerRef,
|
|
326
|
-
renderDonation,
|
|
327
|
-
renderActions,
|
|
328
|
-
renderEditorPlugins,
|
|
329
|
-
enableAutoTranslate,
|
|
330
|
-
renderComments,
|
|
331
|
-
renderInnerFooter,
|
|
332
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DiscussKitComments, { ...rest, object, ref: containerRef })
|
|
333
|
-
}
|
|
334
|
-
) }) }) }) }) }) });
|
|
335
|
-
}
|
|
336
|
-
Wrapper.propTypes = {
|
|
337
|
-
target: PropTypes.shape({
|
|
338
|
-
id: PropTypes.string.isRequired,
|
|
339
|
-
title: PropTypes.string,
|
|
340
|
-
desc: PropTypes.string,
|
|
341
|
-
owner: PropTypes.string
|
|
342
|
-
}).isRequired,
|
|
343
|
-
displayReaction: PropTypes.bool,
|
|
344
|
-
onChange: PropTypes.func,
|
|
345
|
-
flatView: PropTypes.bool,
|
|
346
|
-
autoCollapse: PropTypes.bool,
|
|
347
|
-
autoLoadComments: PropTypes.bool,
|
|
348
|
-
allowCopyLink: PropTypes.bool,
|
|
349
|
-
disabledSend: PropTypes.bool,
|
|
350
|
-
showProfileCard: PropTypes.bool,
|
|
351
|
-
order: PropTypes.oneOf(["asc", "desc"]),
|
|
352
|
-
interactive: PropTypes.bool,
|
|
353
|
-
renderComments: PropTypes.func,
|
|
354
|
-
renderDonation: PropTypes.any,
|
|
355
|
-
renderActions: PropTypes.func,
|
|
356
|
-
renderEditorPlugins: PropTypes.func,
|
|
357
|
-
enableAutoTranslate: PropTypes.bool,
|
|
358
|
-
renderInnerFooter: PropTypes.func,
|
|
359
|
-
sendComment: PropTypes.func,
|
|
360
|
-
reactionAppend: PropTypes.any
|
|
361
|
-
};
|
|
362
|
-
Wrapper.defaultProps = {
|
|
363
|
-
displayReaction: true,
|
|
364
|
-
onChange: () => {
|
|
365
|
-
},
|
|
366
|
-
flatView: false,
|
|
367
|
-
autoCollapse: false,
|
|
368
|
-
autoLoadComments: true,
|
|
369
|
-
allowCopyLink: false,
|
|
370
|
-
disabledSend: void 0,
|
|
371
|
-
showProfileCard: false,
|
|
372
|
-
order: void 0,
|
|
373
|
-
interactive: true,
|
|
374
|
-
renderComments: null,
|
|
375
|
-
renderDonation: null,
|
|
376
|
-
renderActions: null,
|
|
377
|
-
renderEditorPlugins: null,
|
|
378
|
-
enableAutoTranslate: false,
|
|
379
|
-
renderInnerFooter: null,
|
|
380
|
-
sendComment: null,
|
|
381
|
-
reactionAppend: null
|
|
382
|
-
};
|
|
383
|
-
const Container = Theme.styled("div")`
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),x=require("react"),Q=require("@arcblock/ux/lib/Theme"),t=require("prop-types"),X=require("@arcblock/did-connect/lib/Session"),d=require("@mui/material"),E=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=o=>o.endsWith("/")?o:`${o}/`;return window.blocklet?.componentMountPoints?.find(o=>e(o.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 n={...e,embed:e.rootId?"rating":"replies,rating",size:e.limit},{data:{data:o,nextCursor:c,total:f}}=await r.default.get("/comments",{params:n});return{data:o?.map(u),nextCursor:c,total:f}},fetchPinnedComments:async e=>{const{data:n}=await r.default.get("/comments/pinned",{params:{objectId:e}});return(n?.data||[]).map(u)},fetchCommentPosition:async({id:e,...n})=>{const{data:o}=await r.default.get(`/comments/${e}/position`,{params:n});return o},deleteComment:async({id:e})=>{const{data:n}=await r.default.delete(`/comments/${e}`);return n},updateComment:async({id:e,updatedAt:n},o)=>{const{data:c}=await r.default.put(`/comments/${e}`,{content:o,updatedAt:n});return u(c)},reply:async({id:e},n)=>{const{data:o}=await r.default.post("/comments/replies",{content:n,parentId:e,link:window.location.href});return u(o)},rate:async(e,n,o)=>{await r.default.post(`/topics/${e.topicId}/comments/${e.id}/ratings`,{ratingType:o,value:n})},unrate:async e=>{await r.default.delete(`/topics/${e.topicId}/comments/${e.id}/ratings`)},fetchRatings:async e=>{const{data:n}=await r.default.get(`/ratings/${e}`);return n},togglePin:async({post:e,value:n})=>{n?await r.default.put(`/posts/${e.id}/pinned`):await r.default.delete(`/posts/${e.id}/pinned`)}},re=()=>{const[e,n]=x.useState(!0);return Z.useRequest(()=>r.default.get("/status",{muteError:!0}).then(()=>n(!0)).catch(()=>n(!1)),{cacheKey:"discuss-kit-status",staleTime:-1}),{available:e}};function F({ref:e=void 0,displayReaction:n=!0,object:o,onChange:c=()=>{},onSendComment:f=()=>{},commentInputPosition:C="top",autoFocus:w=!1,disabledSend:j=void 0,initialContent:A="",sendText:q="",sendIcon:v=null,showTopbar:I=!0,sendComment:h=null,reactionAppend:P=null,skeleton:S=null,placeholder:T="",onInput:$=()=>{},draftKey:b="",inputSx:g={},editorRef:y=null,disableCmdEnter:O=!1}){a.useDefaultApiErrorHandler({request:r.default});const{available:U}=re(),{session:k}=x.useContext(X.SessionContext)||{},{state:B,sort:W,add:M,updateCommentState:N,interactive:R,findById:z,renderInnerFooter:G}=a.useCommentsContext(),{total:D,order:_,initialized:H}=B,{t:p}=E.useLocaleContext();oe.useTopicInfoSync(o);const V={ADD_COMMENT:i=>{M(u(i)),c?.()},UPDATE_COMMENT:i=>{const l=z(i.id);l&&l.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 l=await r.fetchRatings(i);N(i,m=>({...m,rating:l}))}};if(a.useSubscription(o.id,({event:i,data:l})=>{V[i]?.(l)},[o.id,B]),!U)return s.jsxs(d.Alert,{severity:"info",children:[s.jsx(d.AlertTitle,{children:p("apiUnavailable.title")}),p("apiUnavailable.desc")]});if(!H)return S||s.jsx(d.Box,{sx:{width:"100%",display:"flex",justifyContent:"center"},children:s.jsx(d.CircularProgress,{})});const J=async i=>{const{data:l}=await(h?h({content:i,object:o}):r.default.post("/comments",{content:i,object:o}));M(u(l)),f?.(l)},K=()=>s.jsx(a.CommentInput,{editorRef:y,placeholder:T,send:J,draftKey:b||`object-${o.id}`,autoFocus:w,disabledSend:j,initialContent:A,sendText:q,sendIcon:v,renderInnerFooter:G,onChange:$,disableCmdEnter:O});return s.jsxs(ae,{ref:e,children:[s.jsxs(s.Fragment,{children:[s.jsx(d.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"end"},children:n&&s.jsxs(a.IconButtonGroup,{sx:{alignItems:"flex-end"},children:[s.jsx(a.GithubReactionContainer,{id:o.id,request:r.default,interactive:R}),P]})}),k.user&&R&&C==="top"&&s.jsx(d.Box,{className:"comment-editor",sx:{mt:2},children:K()})]}),!!D&&I&&s.jsxs(d.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:3},children:[s.jsxs(d.Box,{sx:{fontWeight:"medium"},children:[D>0?`${D} ${p("comments")}`:p("comment")," "]}),s.jsx(a.SegmentedControl,{value:_,options:[{value:"desc",label:p("newest")},{value:"asc",label:p("oldest")}],onChange:i=>W(i)})]}),s.jsx(a.CommentList,{className:"comment-list"}),k.user&&R&&C==="bottom"&&s.jsx(d.Box,{sx:{mt:6,...g},children:K()})]})}F.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:n=!1,autoCollapse:o=!1,autoLoadComments:c=!0,order:f=void 0,allowCopyLink:C=!1,showProfileCard:w=!1,interactive:j=!0,renderComments:A=null,renderDonation:q=null,renderActions:v=null,renderEditorPlugins:I=null,enableAutoTranslate:h=!1,renderInnerFooter:P=null,...S}){const T=Object.assign({},{displayReaction:!0,onChange:()=>{},onSendComment:()=>{},disabledSend:void 0,sendComment:null,reactionAppend:null},S);if(!e?.id)throw new Error("target is required.");const{locale:$="en"}=E.useLocaleContext()||{},b=x.useRef(),g=x.useMemo(()=>({link:window.location.href,blockletName:se(),...e}),[e]),y=a.getWsClient(ne.discussKitPrefix);return x.useEffect(()=>(y.connect(),()=>{y.isConnected()}),[]),s.jsx(Y.ErrorBoundary,{FallbackComponent:ee,children:s.jsx(E.LocaleProvider,{translations:te.translations,locale:$,children:s.jsx(a.UploaderProvider,{children:s.jsx(a.InternalThemeProvider,{children:s.jsx(a.ConfirmProvider,{children:s.jsx(a.DefaultEditorConfigProvider,{request:r.default,children:s.jsx(a.CommentsProvider,{target:g,api:ie,flatView:n,order:f,autoCollapse:o,autoLoadComments:c,allowCopyLink:C,showProfileCard:w,interactive:j,containerRef:b,renderDonation:q,renderActions:v,renderEditorPlugins:I,enableAutoTranslate:h,renderComments:A,renderInnerFooter:P,children:s.jsx(F,{...T,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")`
|
|
384
2
|
width: 100%;
|
|
385
3
|
margin: 0 auto;
|
|
386
4
|
box-sizing: border-box;
|
|
387
|
-
padding: ${
|
|
388
|
-
border: ${
|
|
5
|
+
padding: ${e=>e.padding?"20px":"0"};
|
|
6
|
+
border: ${e=>e.border?"1px solid rgb(208, 215, 222)":"none"};
|
|
389
7
|
border-radius: 6px;
|
|
390
|
-
`;
|
|
391
|
-
module.exports = Wrapper;
|
|
8
|
+
`;module.exports=L;
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const PropTypes = require("prop-types");
|
|
4
|
-
const Alert = require("@mui/material/Alert");
|
|
5
|
-
const AlertTitle = require("@mui/material/AlertTitle");
|
|
6
|
-
function ErrorFallback({ error }) {
|
|
7
|
-
const errorMessageElement = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ jsxRuntime.jsx("pre", { children: error.message });
|
|
8
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Alert, { severity: "warning", children: [
|
|
9
|
-
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { children: "Oops!" }),
|
|
10
|
-
"Discuss Kit is not working properly.",
|
|
11
|
-
errorMessageElement
|
|
12
|
-
] });
|
|
13
|
-
}
|
|
14
|
-
ErrorFallback.propTypes = {
|
|
15
|
-
error: PropTypes.instanceOf(Error).isRequired
|
|
16
|
-
};
|
|
17
|
-
module.exports = ErrorFallback;
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),i=require("prop-types"),o=require("@mui/material/Alert"),t=require("@mui/material/AlertTitle");function e({error:s}){const n=process.env.NODE_ENV==="production"?null:r.jsx("pre",{children:s.message});return r.jsxs(o,{severity:"warning",children:[r.jsx(t,{children:"Oops!"}),"Discuss Kit is not working properly.",n]})}e.propTypes={error:i.instanceOf(Error).isRequired};module.exports=e;
|
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const PropTypes = require("prop-types");
|
|
5
|
-
const Theme = require("@arcblock/ux/lib/Theme");
|
|
6
|
-
const IconButton = require("@mui/material/IconButton");
|
|
7
|
-
const iconsMaterial = require("@mui/icons-material");
|
|
8
|
-
const Box = require("@mui/material/Box");
|
|
9
|
-
const MuiMenu = require("@mui/material/Menu");
|
|
10
|
-
const MuiMenuItem = require("@mui/material/MenuItem");
|
|
11
|
-
function Menu({ items, ...rest }) {
|
|
12
|
-
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
13
|
-
const open = Boolean(anchorEl);
|
|
14
|
-
const handleClick = (event) => {
|
|
15
|
-
setAnchorEl(event.currentTarget);
|
|
16
|
-
};
|
|
17
|
-
const handleClose = () => {
|
|
18
|
-
setAnchorEl(null);
|
|
19
|
-
};
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Root, { ...rest, children: [
|
|
21
|
-
/* @__PURE__ */ jsxRuntime.jsx(IconButton, { size: "medium", onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.MoreVert, { sx: { fontSize: 18 } }) }),
|
|
22
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
-
MuiMenu,
|
|
24
|
-
{
|
|
25
|
-
anchorEl,
|
|
26
|
-
anchorOrigin: {
|
|
27
|
-
vertical: "bottom",
|
|
28
|
-
horizontal: "right"
|
|
29
|
-
},
|
|
30
|
-
transformOrigin: {
|
|
31
|
-
vertical: "top",
|
|
32
|
-
horizontal: "right"
|
|
33
|
-
},
|
|
34
|
-
open,
|
|
35
|
-
onClose: handleClose,
|
|
36
|
-
children: items.map(({ onClick, text, ...itemProps }, index) => {
|
|
37
|
-
const handleClick2 = () => {
|
|
38
|
-
onClick();
|
|
39
|
-
handleClose();
|
|
40
|
-
};
|
|
41
|
-
return (
|
|
42
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
43
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { onClick: handleClick2, ...itemProps, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { minWidth: 100, children: text }) }, index)
|
|
44
|
-
);
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
] });
|
|
49
|
-
}
|
|
50
|
-
Menu.propTypes = {
|
|
51
|
-
items: PropTypes.array.isRequired
|
|
52
|
-
};
|
|
53
|
-
Menu.defaultProps = {};
|
|
54
|
-
const Root = Theme.styled("div")`
|
|
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")`
|
|
55
2
|
display: inline-block;
|
|
56
|
-
|
|
57
|
-
const StyledMenuItem = Theme.styled(MuiMenuItem)`
|
|
3
|
+
`,z=i.styled(g)`
|
|
58
4
|
font-size: 14px;
|
|
59
|
-
`;
|
|
60
|
-
module.exports = Menu;
|
|
5
|
+
`;module.exports=s;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const DiscussKitDid = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
|
|
4
|
-
exports.DiscussKitDid = DiscussKitDid;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";exports.DiscussKitDid=i;
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
4
|
-
const utils = require("../lib/utils");
|
|
5
|
-
const useCommentsListener = (objectId, handleNewComment) => {
|
|
6
|
-
discussKitUx.useSubscription(
|
|
7
|
-
objectId,
|
|
8
|
-
({ event, data }) => {
|
|
9
|
-
if (event === "ADD_COMMENT") {
|
|
10
|
-
handleNewComment(data);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
[objectId],
|
|
14
|
-
utils.discussKitPrefix
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
exports.useCommentsListener = useCommentsListener;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@blocklet/discuss-kit-ux"),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;
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
5
|
-
const request = require("../api");
|
|
6
|
-
const utils = require("../lib/utils");
|
|
7
|
-
const useTopicInfoSync = (options) => {
|
|
8
|
-
react.useEffect(() => {
|
|
9
|
-
const sync = () => {
|
|
10
|
-
request.put(`/comments/topics/${options.id}`, {
|
|
11
|
-
title: options.title,
|
|
12
|
-
link: options.link
|
|
13
|
-
}).catch((err) => {
|
|
14
|
-
console.error(err);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
if (!discussKitUx.utils.isInDiscussKitApp && !utils.isInIframe()) {
|
|
18
|
-
sync();
|
|
19
|
-
}
|
|
20
|
-
}, []);
|
|
21
|
-
};
|
|
22
|
-
exports.useTopicInfoSync = useTopicInfoSync;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=require("@blocklet/discuss-kit-ux"),n=require("../api.js"),r=require("../lib/utils.js"),u=e=>{s.useEffect(()=>{const t=()=>{n.default.put(`/comments/topics/${e.id}`,{title:e.title,link:e.link}).catch(i=>{console.error(i)})};!c.utils.isInDiscussKitApp&&!r.isInIframe()&&t()},[])};exports.useTopicInfoSync=u;
|