@blocklet/discuss-kit 1.5.132 → 1.5.133
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 -3
- package/lib/cjs/comments-with-session.js +5 -15
- package/lib/cjs/comments.js +126 -263
- package/lib/cjs/components/error-fallback.js +9 -18
- package/lib/cjs/components/menu.js +33 -55
- package/lib/cjs/index.js +4 -17
- package/lib/cjs/lib/utils.js +1 -1
- package/lib/cjs/locales/en.js +2 -4
- package/lib/cjs/locales/index.js +2 -6
- package/lib/cjs/locales/zh.js +21 -23
- package/lib/cjs/session.js +1 -1
- package/lib/cjs/theme-provider.js +7 -23
- package/lib/cjs/ws.js +2 -4
- package/lib/es/comments-with-session.js +4 -12
- package/lib/es/comments.js +101 -227
- package/lib/es/components/error-fallback.js +8 -13
- package/lib/es/components/menu.js +31 -47
- package/lib/es/locales/en.js +1 -1
- package/lib/es/locales/zh.js +20 -20
- package/lib/es/theme-provider.js +5 -19
- package/package.json +8 -8
package/lib/cjs/api.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const axios = require("axios");
|
|
4
|
-
const
|
|
5
|
-
const axios__default = /* @__PURE__ */ _interopDefaultLegacy(axios);
|
|
6
|
-
const request = axios__default.default.create({ baseURL: "/", timeout: 2e4 });
|
|
4
|
+
const request = axios.create({ baseURL: "/", timeout: 2e4 });
|
|
7
5
|
request.interceptors.request.use(
|
|
8
6
|
(config) => {
|
|
9
7
|
return config;
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
2
3
|
const utils = require("@arcblock/did-connect/lib/utils");
|
|
3
4
|
const Comments = require("./comments");
|
|
4
5
|
const session = require("./session");
|
|
5
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
7
|
-
const Comments__default = /* @__PURE__ */ _interopDefaultLegacy(Comments);
|
|
8
6
|
const CommentsHOC = (WrappedComponent) => {
|
|
9
7
|
const webWalletUrl = utils.getWebWalletUrl();
|
|
10
8
|
return function(props) {
|
|
11
|
-
return /* @__PURE__ */ jsxRuntime.jsx(session.SessionProvider, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
children: (session2) => {
|
|
15
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, {
|
|
16
|
-
...props,
|
|
17
|
-
session: session2.session,
|
|
18
|
-
showConnectBtn: true
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsx(session.SessionProvider, { serviceHost: "/", webWalletUrl, children: (session2) => {
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props, session: session2.session, showConnectBtn: true });
|
|
11
|
+
} });
|
|
22
12
|
};
|
|
23
13
|
};
|
|
24
|
-
const commentsWithSession = CommentsHOC(
|
|
14
|
+
const commentsWithSession = CommentsHOC(Comments);
|
|
25
15
|
module.exports = commentsWithSession;
|
package/lib/cjs/comments.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
2
3
|
const react = require("react");
|
|
3
4
|
const Theme = require("@arcblock/ux/lib/Theme");
|
|
4
5
|
const joinUrl = require("url-join");
|
|
@@ -17,40 +18,24 @@ const ErrorFallback = require("./components/error-fallback");
|
|
|
17
18
|
const locales = require("./locales");
|
|
18
19
|
const getWsClient = require("./ws");
|
|
19
20
|
const api = require("./api");
|
|
20
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
22
|
-
const joinUrl__default = /* @__PURE__ */ _interopDefaultLegacy(joinUrl);
|
|
23
|
-
const PropTypes__default = /* @__PURE__ */ _interopDefaultLegacy(PropTypes);
|
|
24
|
-
const SessionManager__default = /* @__PURE__ */ _interopDefaultLegacy(SessionManager);
|
|
25
|
-
const Button__default = /* @__PURE__ */ _interopDefaultLegacy(Button);
|
|
26
|
-
const Box__default = /* @__PURE__ */ _interopDefaultLegacy(Box);
|
|
27
|
-
const CircularProgress__default = /* @__PURE__ */ _interopDefaultLegacy(CircularProgress);
|
|
28
|
-
const ButtonGroup__default = /* @__PURE__ */ _interopDefaultLegacy(ButtonGroup);
|
|
29
|
-
const ErrorFallback__default = /* @__PURE__ */ _interopDefaultLegacy(ErrorFallback);
|
|
30
|
-
const getWsClient__default = /* @__PURE__ */ _interopDefaultLegacy(getWsClient);
|
|
31
|
-
const api__default = /* @__PURE__ */ _interopDefaultLegacy(api);
|
|
32
21
|
const useAsyncRetry = (fn, deps = []) => {
|
|
33
|
-
const state = ahooks.useRequest(fn, {
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
value: state == null ? void 0 : state.data,
|
|
39
|
-
retry: state == null ? void 0 : state.run
|
|
40
|
-
};
|
|
22
|
+
const state = ahooks.useRequest(fn, { refreshDeps: deps });
|
|
23
|
+
return { ...state, value: state == null ? void 0 : state.data, retry: state == null ? void 0 : state.run };
|
|
41
24
|
};
|
|
42
25
|
const getPrefix = () => {
|
|
43
26
|
var _a, _b;
|
|
44
27
|
const service = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find((x) => x.name === "did-comments");
|
|
45
|
-
return service ?
|
|
28
|
+
return service ? joinUrl(service.mountPoint, "/") : "";
|
|
46
29
|
};
|
|
47
30
|
const getCurrentBlockletComponentName = () => {
|
|
48
31
|
var _a, _b;
|
|
49
32
|
const ensureTrailingSlash = (str) => str.endsWith("/") ? str : `${str}/`;
|
|
50
|
-
const matched = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
const matched = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
34
|
+
(x) => {
|
|
35
|
+
var _a2;
|
|
36
|
+
return ensureTrailingSlash(x.mountPoint) === ensureTrailingSlash((_a2 = window.blocklet) == null ? void 0 : _a2.prefix);
|
|
37
|
+
}
|
|
38
|
+
);
|
|
54
39
|
return matched == null ? void 0 : matched.title;
|
|
55
40
|
};
|
|
56
41
|
const formatComment = (comment) => {
|
|
@@ -72,58 +57,24 @@ const commentAPI = {
|
|
|
72
57
|
size: params.limit
|
|
73
58
|
};
|
|
74
59
|
const {
|
|
75
|
-
data: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
total
|
|
79
|
-
}
|
|
80
|
-
} = await api__default.default.get("/comments", {
|
|
81
|
-
params: copy
|
|
82
|
-
});
|
|
83
|
-
return {
|
|
84
|
-
data: data == null ? void 0 : data.map(formatComment),
|
|
85
|
-
nextCursor,
|
|
86
|
-
total
|
|
87
|
-
};
|
|
60
|
+
data: { data, nextCursor, total }
|
|
61
|
+
} = await api.get("/comments", { params: copy });
|
|
62
|
+
return { data: data == null ? void 0 : data.map(formatComment), nextCursor, total };
|
|
88
63
|
},
|
|
89
|
-
fetchCommentPosition: async ({
|
|
90
|
-
id
|
|
91
|
-
...params
|
|
92
|
-
}) => {
|
|
93
|
-
const {
|
|
94
|
-
data
|
|
95
|
-
} = await api__default.default.get(`/comments/${id}/position`, {
|
|
96
|
-
params
|
|
97
|
-
});
|
|
64
|
+
fetchCommentPosition: async ({ id, ...params }) => {
|
|
65
|
+
const { data } = await api.get(`/comments/${id}/position`, { params });
|
|
98
66
|
return data;
|
|
99
67
|
},
|
|
100
|
-
deleteComment: async ({
|
|
101
|
-
id
|
|
102
|
-
}) => {
|
|
103
|
-
const {
|
|
104
|
-
data
|
|
105
|
-
} = await api__default.default.delete(`/comments/${id}`);
|
|
68
|
+
deleteComment: async ({ id }) => {
|
|
69
|
+
const { data } = await api.delete(`/comments/${id}`);
|
|
106
70
|
return data;
|
|
107
71
|
},
|
|
108
|
-
updateComment: async ({
|
|
109
|
-
id,
|
|
110
|
-
updatedAt
|
|
111
|
-
}, content) => {
|
|
112
|
-
const {
|
|
113
|
-
data
|
|
114
|
-
} = await api__default.default.put(`/comments/${id}`, {
|
|
115
|
-
content,
|
|
116
|
-
updatedAt
|
|
117
|
-
});
|
|
72
|
+
updateComment: async ({ id, updatedAt }, content) => {
|
|
73
|
+
const { data } = await api.put(`/comments/${id}`, { content, updatedAt });
|
|
118
74
|
return formatComment(data);
|
|
119
75
|
},
|
|
120
|
-
reply: async ({
|
|
121
|
-
id
|
|
122
|
-
rootId
|
|
123
|
-
}, content) => {
|
|
124
|
-
const {
|
|
125
|
-
data
|
|
126
|
-
} = await api__default.default.post(`/comments/${rootId || id}/replies`, {
|
|
76
|
+
reply: async ({ id, rootId }, content) => {
|
|
77
|
+
const { data } = await api.post(`/comments/${rootId || id}/replies`, {
|
|
127
78
|
content,
|
|
128
79
|
parentId: id,
|
|
129
80
|
link: window.location.href
|
|
@@ -131,18 +82,13 @@ const commentAPI = {
|
|
|
131
82
|
return formatComment(data);
|
|
132
83
|
},
|
|
133
84
|
rate: async (comment, value, ratingType) => {
|
|
134
|
-
await
|
|
135
|
-
ratingType,
|
|
136
|
-
value
|
|
137
|
-
});
|
|
85
|
+
await api.post(`/topics/${comment.topicId}/comments/${comment.id}/ratings`, { ratingType, value });
|
|
138
86
|
},
|
|
139
87
|
unrate: async (comment) => {
|
|
140
|
-
await
|
|
88
|
+
await api.delete(`/topics/${comment.topicId}/comments/${comment.id}/ratings`);
|
|
141
89
|
},
|
|
142
90
|
fetchRatings: async (id) => {
|
|
143
|
-
const {
|
|
144
|
-
data
|
|
145
|
-
} = await api__default.default.get(`/ratings/${id}`);
|
|
91
|
+
const { data } = await api.get(`/ratings/${id}`);
|
|
146
92
|
return data;
|
|
147
93
|
}
|
|
148
94
|
};
|
|
@@ -154,26 +100,11 @@ function DiscussKitComments({
|
|
|
154
100
|
commentInputPosition,
|
|
155
101
|
showTopbar
|
|
156
102
|
}) {
|
|
157
|
-
discussKitUx.useDefaultApiErrorHandler({
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
const {
|
|
161
|
-
|
|
162
|
-
} = react.useContext(Session.SessionContext) || {};
|
|
163
|
-
const {
|
|
164
|
-
state,
|
|
165
|
-
sort,
|
|
166
|
-
add,
|
|
167
|
-
updateCommentState
|
|
168
|
-
} = discussKitUx.useCommentsContext();
|
|
169
|
-
const {
|
|
170
|
-
total,
|
|
171
|
-
order,
|
|
172
|
-
initialized
|
|
173
|
-
} = state;
|
|
174
|
-
const {
|
|
175
|
-
t
|
|
176
|
-
} = context.useLocaleContext();
|
|
103
|
+
discussKitUx.useDefaultApiErrorHandler({ request: api });
|
|
104
|
+
const { session } = react.useContext(Session.SessionContext) || {};
|
|
105
|
+
const { state, sort, add, updateCommentState } = discussKitUx.useCommentsContext();
|
|
106
|
+
const { total, order, initialized } = state;
|
|
107
|
+
const { t } = context.useLocaleContext();
|
|
177
108
|
const objectRatingState = useAsyncRetry(() => api.fetchRatings(object.id));
|
|
178
109
|
const handlers = {
|
|
179
110
|
ADD_COMMENT: (data) => {
|
|
@@ -188,9 +119,7 @@ function DiscussKitComments({
|
|
|
188
119
|
});
|
|
189
120
|
},
|
|
190
121
|
RATING: () => objectRatingState.retry(),
|
|
191
|
-
RATING_COMMENT: async ({
|
|
192
|
-
commentId
|
|
193
|
-
}) => {
|
|
122
|
+
RATING_COMMENT: async ({ commentId }) => {
|
|
194
123
|
const rating = await api.fetchRatings(commentId);
|
|
195
124
|
updateCommentState(commentId, (current) => ({
|
|
196
125
|
...current,
|
|
@@ -198,140 +127,89 @@ function DiscussKitComments({
|
|
|
198
127
|
}));
|
|
199
128
|
}
|
|
200
129
|
};
|
|
201
|
-
getWsClient.useSubscription(
|
|
202
|
-
|
|
203
|
-
data
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
130
|
+
getWsClient.useSubscription(
|
|
131
|
+
object.id,
|
|
132
|
+
({ event, data }) => {
|
|
133
|
+
var _a;
|
|
134
|
+
(_a = handlers[event]) == null ? void 0 : _a.call(handlers, data);
|
|
135
|
+
},
|
|
136
|
+
[object.id, state]
|
|
137
|
+
);
|
|
208
138
|
if (!initialized) {
|
|
209
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
210
|
-
width: "100%",
|
|
211
|
-
display: "flex",
|
|
212
|
-
justifyContent: "center",
|
|
213
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgress__default.default, {})
|
|
214
|
-
});
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {}) });
|
|
215
140
|
}
|
|
216
141
|
const sendComment = async (content) => {
|
|
217
|
-
const {
|
|
218
|
-
data
|
|
219
|
-
} = await api__default.default.post("/comments", {
|
|
220
|
-
content,
|
|
221
|
-
object
|
|
222
|
-
});
|
|
142
|
+
const { data } = await api.post("/comments", { content, object });
|
|
223
143
|
add(formatComment(data));
|
|
224
144
|
};
|
|
225
|
-
const handleOnRate = async ({
|
|
226
|
-
ratingType,
|
|
227
|
-
value
|
|
228
|
-
}) => {
|
|
145
|
+
const handleOnRate = async ({ ratingType, value }) => {
|
|
229
146
|
if (!session.user) {
|
|
230
147
|
session.login();
|
|
231
148
|
throw new Error("Unauthenticated.");
|
|
232
149
|
}
|
|
233
|
-
await
|
|
234
|
-
ratingType,
|
|
235
|
-
value
|
|
236
|
-
});
|
|
150
|
+
await api.post(`/topics/${object.id}/ratings`, { ratingType, value });
|
|
237
151
|
};
|
|
238
152
|
const handleOnUnrate = async () => {
|
|
239
153
|
if (!session.user) {
|
|
240
154
|
session.login();
|
|
241
155
|
throw new Error("Unauthenticated.");
|
|
242
156
|
}
|
|
243
|
-
await
|
|
157
|
+
await api.delete(`/topics/${object.id}/ratings`);
|
|
244
158
|
};
|
|
245
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Container, {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
292
|
-
})]
|
|
293
|
-
}), !!total && showTopbar && /* @__PURE__ */ jsxRuntime.jsxs(Box__default.default, {
|
|
294
|
-
display: "flex",
|
|
295
|
-
justifyContent: "space-between",
|
|
296
|
-
mt: 3,
|
|
297
|
-
children: [/* @__PURE__ */ jsxRuntime.jsxs("span", {
|
|
298
|
-
children: [total > 0 ? `${total} ${t("comments")}` : t("comment"), " "]
|
|
299
|
-
}), /* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup__default.default, {
|
|
300
|
-
children: [/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, {
|
|
301
|
-
variant: "contained",
|
|
302
|
-
color: order !== "desc" ? "primary" : "inherit",
|
|
303
|
-
size: "small",
|
|
304
|
-
onClick: () => sort("asc"),
|
|
305
|
-
className: order !== "desc" ? "" : "unselected-button",
|
|
306
|
-
children: t("oldest")
|
|
307
|
-
}), /* @__PURE__ */ jsxRuntime.jsx(Button__default.default, {
|
|
308
|
-
variant: "contained",
|
|
309
|
-
color: order === "desc" ? "primary" : "inherit",
|
|
310
|
-
size: "small",
|
|
311
|
-
onClick: () => sort("desc"),
|
|
312
|
-
className: order === "desc" ? "" : "unselected-button",
|
|
313
|
-
children: t("newest")
|
|
314
|
-
})]
|
|
315
|
-
})]
|
|
316
|
-
}), /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentList, {
|
|
317
|
-
className: "comment-list"
|
|
318
|
-
}), session.user && commentInputPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(Box__default.default, {
|
|
319
|
-
mt: 6,
|
|
320
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentInput, {
|
|
321
|
-
send: sendComment,
|
|
322
|
-
draftKey: `object-${object.id}`,
|
|
323
|
-
autoFocus: false
|
|
324
|
-
})
|
|
325
|
-
})]
|
|
326
|
-
});
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Container, { className: "comment-container", children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: [
|
|
162
|
+
displayReaction && objectRatingState.value && /* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.GithubReaction, { data: objectRatingState.value, onRate: handleOnRate, onUnrate: handleOnUnrate }) }),
|
|
163
|
+
displayConnectButton && (session.user ? /* @__PURE__ */ jsxRuntime.jsx(SessionManager, { style: { padding: 0 }, showText: true, showRole: true, session }) : /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "medium", variant: "contained", color: "primary", onClick: () => session.login(), children: t("connect") }))
|
|
164
|
+
] }),
|
|
165
|
+
displayConnectButton && !session.user && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "input-no-connect", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "connect-tip", children: [
|
|
166
|
+
t("connectDIDWallet"),
|
|
167
|
+
" ",
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { className: "down-load-wallet", href: "https://www.didwallet.io/", target: "_blank", rel: "noreferrer", children: t("installDIDWallet") })
|
|
169
|
+
] }) }),
|
|
170
|
+
session.user && commentInputPosition === "top" && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, className: "comment-editor", children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentInput, { send: sendComment, draftKey: `object-${object.id}`, autoFocus: false }) })
|
|
171
|
+
] }),
|
|
172
|
+
!!total && showTopbar && /* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", justifyContent: "space-between", mt: 3, children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
174
|
+
total > 0 ? `${total} ${t("comments")}` : t("comment"),
|
|
175
|
+
" "
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { children: [
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
179
|
+
Button,
|
|
180
|
+
{
|
|
181
|
+
variant: "contained",
|
|
182
|
+
color: order !== "desc" ? "primary" : "inherit",
|
|
183
|
+
size: "small",
|
|
184
|
+
onClick: () => sort("asc"),
|
|
185
|
+
className: order !== "desc" ? "" : "unselected-button",
|
|
186
|
+
children: t("oldest")
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
+
Button,
|
|
191
|
+
{
|
|
192
|
+
variant: "contained",
|
|
193
|
+
color: order === "desc" ? "primary" : "inherit",
|
|
194
|
+
size: "small",
|
|
195
|
+
onClick: () => sort("desc"),
|
|
196
|
+
className: order === "desc" ? "" : "unselected-button",
|
|
197
|
+
children: t("newest")
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] })
|
|
201
|
+
] }),
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentList, { className: "comment-list" }),
|
|
203
|
+
session.user && commentInputPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 6, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentInput, { send: sendComment, draftKey: `object-${object.id}`, autoFocus: false }) })
|
|
204
|
+
] });
|
|
327
205
|
}
|
|
328
206
|
DiscussKitComments.propTypes = {
|
|
329
|
-
displayConnectButton:
|
|
330
|
-
displayReaction:
|
|
331
|
-
object:
|
|
332
|
-
onChange:
|
|
333
|
-
commentInputPosition:
|
|
334
|
-
showTopbar:
|
|
207
|
+
displayConnectButton: PropTypes.bool,
|
|
208
|
+
displayReaction: PropTypes.bool,
|
|
209
|
+
object: PropTypes.object.isRequired,
|
|
210
|
+
onChange: PropTypes.func,
|
|
211
|
+
commentInputPosition: PropTypes.oneOf(["top", "bottom"]),
|
|
212
|
+
showTopbar: PropTypes.bool
|
|
335
213
|
};
|
|
336
214
|
DiscussKitComments.defaultProps = {
|
|
337
215
|
displayConnectButton: false,
|
|
@@ -354,22 +232,21 @@ function Wrapper({
|
|
|
354
232
|
if (!(target == null ? void 0 : target.id)) {
|
|
355
233
|
throw new Error("target is required.");
|
|
356
234
|
}
|
|
357
|
-
const {
|
|
358
|
-
locale = "en"
|
|
359
|
-
} = context.useLocaleContext() || {};
|
|
235
|
+
const { locale = "en" } = context.useLocaleContext() || {};
|
|
360
236
|
const object = react.useMemo(
|
|
361
237
|
() => ({
|
|
362
238
|
...target,
|
|
363
239
|
link: window.location.href,
|
|
364
240
|
blockletName: getCurrentBlockletComponentName()
|
|
365
241
|
}),
|
|
242
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
366
243
|
[target]
|
|
367
244
|
);
|
|
368
245
|
const _prefix = prefix || getPrefix();
|
|
369
246
|
if (!_prefix) {
|
|
370
247
|
throw new Error("prefix is required.");
|
|
371
248
|
}
|
|
372
|
-
const wsClient =
|
|
249
|
+
const wsClient = getWsClient(_prefix);
|
|
373
250
|
react.useEffect(() => {
|
|
374
251
|
wsClient.connect();
|
|
375
252
|
return () => {
|
|
@@ -378,51 +255,37 @@ function Wrapper({
|
|
|
378
255
|
}
|
|
379
256
|
};
|
|
380
257
|
}, []);
|
|
381
|
-
|
|
382
|
-
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.UploaderProvider, {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
order,
|
|
396
|
-
autoCollapse,
|
|
397
|
-
allowCopyLink,
|
|
398
|
-
showProfileCard,
|
|
399
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DiscussKitComments, {
|
|
400
|
-
...rest,
|
|
401
|
-
object
|
|
402
|
-
})
|
|
403
|
-
})
|
|
404
|
-
})
|
|
405
|
-
})
|
|
406
|
-
})
|
|
407
|
-
})
|
|
408
|
-
});
|
|
258
|
+
api.defaults.baseURL = joinUrl(_prefix, "/api/");
|
|
259
|
+
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.UploaderProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { FallbackComponent: ErrorFallback, children: /* @__PURE__ */ jsxRuntime.jsx(context.LocaleProvider, { translations: locales.translations, locale, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
260
|
+
discussKitUx.CommentsProvider,
|
|
261
|
+
{
|
|
262
|
+
target: object,
|
|
263
|
+
api: commentAPI,
|
|
264
|
+
flatView,
|
|
265
|
+
order,
|
|
266
|
+
autoCollapse,
|
|
267
|
+
allowCopyLink,
|
|
268
|
+
showProfileCard,
|
|
269
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DiscussKitComments, { ...rest, object })
|
|
270
|
+
}
|
|
271
|
+
) }) }) }) }) });
|
|
409
272
|
}
|
|
410
273
|
Wrapper.propTypes = {
|
|
411
|
-
target:
|
|
412
|
-
id:
|
|
413
|
-
title:
|
|
414
|
-
desc:
|
|
415
|
-
owner:
|
|
274
|
+
target: PropTypes.shape({
|
|
275
|
+
id: PropTypes.string.isRequired,
|
|
276
|
+
title: PropTypes.string,
|
|
277
|
+
desc: PropTypes.string,
|
|
278
|
+
owner: PropTypes.string
|
|
416
279
|
}).isRequired,
|
|
417
|
-
displayConnectButton:
|
|
418
|
-
displayReaction:
|
|
419
|
-
onChange:
|
|
420
|
-
prefix:
|
|
421
|
-
flatView:
|
|
422
|
-
autoCollapse:
|
|
423
|
-
allowCopyLink:
|
|
424
|
-
showProfileCard:
|
|
425
|
-
order:
|
|
280
|
+
displayConnectButton: PropTypes.bool,
|
|
281
|
+
displayReaction: PropTypes.bool,
|
|
282
|
+
onChange: PropTypes.func,
|
|
283
|
+
prefix: PropTypes.string,
|
|
284
|
+
flatView: PropTypes.bool,
|
|
285
|
+
autoCollapse: PropTypes.bool,
|
|
286
|
+
allowCopyLink: PropTypes.bool,
|
|
287
|
+
showProfileCard: PropTypes.bool,
|
|
288
|
+
order: PropTypes.oneOf(["asc", "desc"])
|
|
426
289
|
};
|
|
427
290
|
Wrapper.defaultProps = {
|
|
428
291
|
displayConnectButton: false,
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
2
3
|
const PropTypes = require("prop-types");
|
|
3
4
|
const Alert = require("@mui/material/Alert");
|
|
4
5
|
const AlertTitle = require("@mui/material/AlertTitle");
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) {
|
|
13
|
-
const errorMessageElement = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ jsxRuntime.jsx("pre", {
|
|
14
|
-
children: error.message
|
|
15
|
-
});
|
|
16
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Alert__default.default, {
|
|
17
|
-
severity: "warning",
|
|
18
|
-
children: [/* @__PURE__ */ jsxRuntime.jsx(AlertTitle__default.default, {
|
|
19
|
-
children: "Oops!"
|
|
20
|
-
}), "Discuss Kit is not working properly.", errorMessageElement]
|
|
21
|
-
});
|
|
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
|
+
] });
|
|
22
13
|
}
|
|
23
14
|
ErrorFallback.propTypes = {
|
|
24
|
-
error:
|
|
15
|
+
error: PropTypes.instanceOf(Error).isRequired
|
|
25
16
|
};
|
|
26
17
|
module.exports = ErrorFallback;
|