@blocklet/discuss-kit 2.1.82 → 2.1.83

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.
@@ -105,7 +105,8 @@ const DiscussKitComments = react.forwardRef(
105
105
  initialContent,
106
106
  sendText,
107
107
  sendIcon,
108
- showTopbar
108
+ showTopbar,
109
+ sendComment
109
110
  }, ref) => {
110
111
  discussKitUx.useDefaultApiErrorHandler({
111
112
  request: api
@@ -158,8 +159,8 @@ const DiscussKitComments = react.forwardRef(
158
159
  if (!initialized) {
159
160
  return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, {}) });
160
161
  }
161
- const sendComment = async (content) => {
162
- const { data } = await api.post("/comments", { content, object });
162
+ const handleSendComment = async (content) => {
163
+ const { data } = await (sendComment ? sendComment({ content, object }) : api.post("/comments", { content, object }));
163
164
  add(formatComment(data));
164
165
  onSendComment == null ? void 0 : onSendComment(data);
165
166
  };
@@ -181,7 +182,7 @@ const DiscussKitComments = react.forwardRef(
181
182
  return /* @__PURE__ */ jsxRuntime.jsx(
182
183
  discussKitUx.CommentInput,
183
184
  {
184
- send: sendComment,
185
+ send: handleSendComment,
185
186
  draftKey: `object-${object.id}`,
186
187
  autoFocus,
187
188
  disabledSend,
@@ -247,7 +248,8 @@ DiscussKitComments.propTypes = {
247
248
  sendText: PropTypes.string,
248
249
  sendIcon: PropTypes.node,
249
250
  commentInputPosition: PropTypes.oneOf(["top", "bottom"]),
250
- showTopbar: PropTypes.bool
251
+ showTopbar: PropTypes.bool,
252
+ sendComment: PropTypes.func
251
253
  };
252
254
  DiscussKitComments.defaultProps = {
253
255
  displayConnectButton: false,
@@ -262,7 +264,8 @@ DiscussKitComments.defaultProps = {
262
264
  sendText: "",
263
265
  sendIcon: null,
264
266
  commentInputPosition: "top",
265
- showTopbar: true
267
+ showTopbar: true,
268
+ sendComment: null
266
269
  };
267
270
  function Wrapper({
268
271
  target,
@@ -345,7 +348,8 @@ Wrapper.propTypes = {
345
348
  renderDonation: PropTypes.any,
346
349
  renderActions: PropTypes.func,
347
350
  renderEditorPlugins: PropTypes.func,
348
- renderInnerFooter: PropTypes.func
351
+ renderInnerFooter: PropTypes.func,
352
+ sendComment: PropTypes.func
349
353
  };
350
354
  Wrapper.defaultProps = {
351
355
  displayConnectButton: false,
@@ -364,7 +368,8 @@ Wrapper.defaultProps = {
364
368
  renderDonation: null,
365
369
  renderActions: null,
366
370
  renderEditorPlugins: null,
367
- renderInnerFooter: null
371
+ renderInnerFooter: null,
372
+ sendComment: null
368
373
  };
369
374
  const Container = Theme.styled("div")`
370
375
  width: 100%;
@@ -104,7 +104,8 @@ const DiscussKitComments = forwardRef(
104
104
  initialContent,
105
105
  sendText,
106
106
  sendIcon,
107
- showTopbar
107
+ showTopbar,
108
+ sendComment
108
109
  }, ref) => {
109
110
  useDefaultApiErrorHandler({
110
111
  request: api
@@ -157,8 +158,8 @@ const DiscussKitComments = forwardRef(
157
158
  if (!initialized) {
158
159
  return /* @__PURE__ */ jsx(Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsx(CircularProgress, {}) });
159
160
  }
160
- const sendComment = async (content) => {
161
- const { data } = await api.post("/comments", { content, object });
161
+ const handleSendComment = async (content) => {
162
+ const { data } = await (sendComment ? sendComment({ content, object }) : api.post("/comments", { content, object }));
162
163
  add(formatComment(data));
163
164
  onSendComment == null ? void 0 : onSendComment(data);
164
165
  };
@@ -180,7 +181,7 @@ const DiscussKitComments = forwardRef(
180
181
  return /* @__PURE__ */ jsx(
181
182
  CommentInput,
182
183
  {
183
- send: sendComment,
184
+ send: handleSendComment,
184
185
  draftKey: `object-${object.id}`,
185
186
  autoFocus,
186
187
  disabledSend,
@@ -246,7 +247,8 @@ DiscussKitComments.propTypes = {
246
247
  sendText: PropTypes.string,
247
248
  sendIcon: PropTypes.node,
248
249
  commentInputPosition: PropTypes.oneOf(["top", "bottom"]),
249
- showTopbar: PropTypes.bool
250
+ showTopbar: PropTypes.bool,
251
+ sendComment: PropTypes.func
250
252
  };
251
253
  DiscussKitComments.defaultProps = {
252
254
  displayConnectButton: false,
@@ -261,7 +263,8 @@ DiscussKitComments.defaultProps = {
261
263
  sendText: "",
262
264
  sendIcon: null,
263
265
  commentInputPosition: "top",
264
- showTopbar: true
266
+ showTopbar: true,
267
+ sendComment: null
265
268
  };
266
269
  function Wrapper({
267
270
  target,
@@ -344,7 +347,8 @@ Wrapper.propTypes = {
344
347
  renderDonation: PropTypes.any,
345
348
  renderActions: PropTypes.func,
346
349
  renderEditorPlugins: PropTypes.func,
347
- renderInnerFooter: PropTypes.func
350
+ renderInnerFooter: PropTypes.func,
351
+ sendComment: PropTypes.func
348
352
  };
349
353
  Wrapper.defaultProps = {
350
354
  displayConnectButton: false,
@@ -363,7 +367,8 @@ Wrapper.defaultProps = {
363
367
  renderDonation: null,
364
368
  renderActions: null,
365
369
  renderEditorPlugins: null,
366
- renderInnerFooter: null
370
+ renderInnerFooter: null,
371
+ sendComment: null
367
372
  };
368
373
  const Container = styled("div")`
369
374
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "2.1.82",
3
+ "version": "2.1.83",
4
4
  "description": "A react component for Discuss Kit blocklet.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/es/index.js",
@@ -49,8 +49,8 @@
49
49
  "rehype-sanitize": "^5.0.1",
50
50
  "timeago.js": "^4.0.2",
51
51
  "url-join": "^4.0.1",
52
- "@blocklet/discuss-kit-ux": "^2.1.82",
53
- "@blocklet/editor": "^2.1.82"
52
+ "@blocklet/discuss-kit-ux": "^2.1.83",
53
+ "@blocklet/editor": "^2.1.83"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@arcblock/did-connect": "^2.10.36",