@blocklet/discuss-kit-ux 2.0.29 → 2.0.30

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.
@@ -1,5 +1,5 @@
1
1
  import { BlogPost } from './types';
2
2
 
3
3
  type PartialBlog = Pick<BlogPost, 'id' | 'slug' | 'createdAt' | 'locale'>;
4
- export declare const getBlogLink: (post: PartialBlog) => any;
4
+ export declare const getBlogLink: (post: PartialBlog, locale?: string) => any;
5
5
  export {};
@@ -2,6 +2,11 @@ import { Post, Target, CommentAPI } from '../../../types';
2
2
  import { default as React } from 'react';
3
3
 
4
4
  type Order = 'asc' | 'desc';
5
+ export type CommentsRender = (value: {
6
+ comments: Post[];
7
+ renderComment: (comment: Post) => React.ReactNode;
8
+ order: Order;
9
+ }) => React.ReactNode;
5
10
  interface CommentsProviderProps {
6
11
  target: Target;
7
12
  api: CommentAPI;
@@ -14,6 +19,7 @@ interface CommentsProviderProps {
14
19
  showProfileCard?: boolean;
15
20
  interactive?: boolean;
16
21
  containerRef: React.RefObject<HTMLDivElement>;
22
+ renderComments?: CommentsRender;
17
23
  }
18
24
  interface State {
19
25
  comments: Post[];
@@ -50,8 +56,9 @@ interface CommentsContextValue {
50
56
  deleteComment: CommentAPI['deleteComment'];
51
57
  reply: CommentAPI['reply'];
52
58
  findById: (id: string) => Post | undefined;
59
+ renderComments?: CommentsRender;
53
60
  }
54
61
  export declare const CommentsContext: React.Context<CommentsContextValue>;
55
62
  export declare const useCommentsContext: () => CommentsContextValue;
56
- export declare function CommentsProvider({ target, api, flatView, children, order, autoLoadComments, autoCollapse, allowCopyLink, showProfileCard, interactive, containerRef, }: CommentsProviderProps): import("react/jsx-runtime").JSX.Element;
63
+ export declare function CommentsProvider({ target, api, flatView, children, order, autoLoadComments, autoCollapse, allowCopyLink, showProfileCard, interactive, containerRef, renderComments, }: CommentsProviderProps): import("react/jsx-runtime").JSX.Element;
57
64
  export {};
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { lazy } from "react";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-D6DplcsK.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-DpeAMRFO.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -2498,7 +2498,8 @@ function CommentsProvider({
2498
2498
  allowCopyLink,
2499
2499
  showProfileCard,
2500
2500
  interactive,
2501
- containerRef
2501
+ containerRef,
2502
+ renderComments
2502
2503
  }) {
2503
2504
  var _a2;
2504
2505
  const [state, setState] = useSetState(getInitialState(order ? { order } : {}));
@@ -2698,7 +2699,8 @@ function CommentsProvider({
2698
2699
  deleteComment,
2699
2700
  reply,
2700
2701
  loadMoreReplies,
2701
- findById
2702
+ findById,
2703
+ renderComments
2702
2704
  }),
2703
2705
  // eslint-disable-next-line react-hooks/exhaustive-deps
2704
2706
  [target, state]
@@ -2793,7 +2795,7 @@ function SegmentalList({ ...rest }) {
2793
2795
  function CommentList(props) {
2794
2796
  const { t } = useLocaleContext();
2795
2797
  const {
2796
- state: { comments, nextCursor, highlighted },
2798
+ state: { comments, order, nextCursor, highlighted },
2797
2799
  autoCollapse,
2798
2800
  allowCopyLink,
2799
2801
  showProfileCard,
@@ -2803,29 +2805,31 @@ function CommentList(props) {
2803
2805
  deleteComment,
2804
2806
  reply,
2805
2807
  loadMoreReplies,
2806
- api
2808
+ api,
2809
+ renderComments
2807
2810
  } = useCommentsContext();
2808
2811
  if (highlighted) {
2809
2812
  return /* @__PURE__ */ jsx(SegmentalList, { ...props });
2810
2813
  }
2814
+ const renderComment = (comment) => /* @__PURE__ */ jsx(
2815
+ Comment,
2816
+ {
2817
+ post: comment,
2818
+ onDelete: deleteComment,
2819
+ onContentUpdate: updateComment,
2820
+ onRate: api.rate,
2821
+ onUnrate: api.unrate,
2822
+ onReply: reply,
2823
+ onLoadMoreReplies: loadMoreReplies,
2824
+ autoCollapse,
2825
+ allowCopyLink,
2826
+ showProfileCard,
2827
+ interactive
2828
+ },
2829
+ comment.id
2830
+ );
2811
2831
  return /* @__PURE__ */ jsxs("div", { ...props, children: [
2812
- comments == null ? void 0 : comments.map((comment) => /* @__PURE__ */ jsx(
2813
- Comment,
2814
- {
2815
- post: comment,
2816
- onDelete: deleteComment,
2817
- onContentUpdate: updateComment,
2818
- onRate: api.rate,
2819
- onUnrate: api.unrate,
2820
- onReply: reply,
2821
- onLoadMoreReplies: loadMoreReplies,
2822
- autoCollapse,
2823
- allowCopyLink,
2824
- showProfileCard,
2825
- interactive
2826
- },
2827
- comment.id
2828
- )),
2832
+ renderComments ? renderComments({ order, comments, renderComment }) : comments == null ? void 0 : comments.map(renderComment),
2829
2833
  nextCursor && /* @__PURE__ */ jsx(Box$1, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsx(
2830
2834
  Button,
2831
2835
  {
@@ -3098,16 +3102,17 @@ const routes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
3098
3102
  docPrefix,
3099
3103
  pageGroup
3100
3104
  }, Symbol.toStringTag, { value: "Module" }));
3101
- const getBlogLink = (post) => {
3105
+ const getBlogLink = (post, locale) => {
3106
+ const mergedLocale = locale || post.locale || "en";
3102
3107
  const slug = post.slug || post.id;
3103
3108
  const datePrefix = `${dayjs(post.createdAt).format("YYYY-MM-DD")}-`;
3104
3109
  if (slug.startsWith(datePrefix)) {
3105
3110
  return blogPath(
3106
- `/${post.locale || "en"}/post/${dayjs(post.createdAt).format("YYYY/MM/DD")}/${slug.replace(datePrefix, "")}`
3111
+ `/${mergedLocale || "en"}/post/${dayjs(post.createdAt).format("YYYY/MM/DD")}/${slug.replace(datePrefix, "")}`
3107
3112
  );
3108
3113
  }
3109
- if (post.locale) {
3110
- return blogPath(`/${post.locale}/${slug}`);
3114
+ if (mergedLocale) {
3115
+ return blogPath(`/${mergedLocale}/${slug}`);
3111
3116
  }
3112
3117
  return blogPath(`/${slug}`);
3113
3118
  };
@@ -4701,7 +4706,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4701
4706
  }
4702
4707
  const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
4703
4708
  const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
4704
- const Editor = lazy(() => import("./editor-BPtozKU9.mjs"));
4709
+ const Editor = lazy(() => import("./editor-CUgQ0SdF.mjs"));
4705
4710
  function LazyEditor(props) {
4706
4711
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4707
4712
  /* @__PURE__ */ jsx(Skeleton, {}),
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-D6DplcsK.mjs";
2
+ import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-DpeAMRFO.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -2424,7 +2424,8 @@ var __publicField = (obj, key, value) => {
2424
2424
  allowCopyLink,
2425
2425
  showProfileCard,
2426
2426
  interactive,
2427
- containerRef
2427
+ containerRef,
2428
+ renderComments
2428
2429
  }) {
2429
2430
  var _a2;
2430
2431
  const [state, setState] = ahooks.useSetState(getInitialState(order ? { order } : {}));
@@ -2624,7 +2625,8 @@ var __publicField = (obj, key, value) => {
2624
2625
  deleteComment,
2625
2626
  reply,
2626
2627
  loadMoreReplies,
2627
- findById
2628
+ findById,
2629
+ renderComments
2628
2630
  }),
2629
2631
  // eslint-disable-next-line react-hooks/exhaustive-deps
2630
2632
  [target, state]
@@ -2719,7 +2721,7 @@ var __publicField = (obj, key, value) => {
2719
2721
  function CommentList(props) {
2720
2722
  const { t } = context.useLocaleContext();
2721
2723
  const {
2722
- state: { comments, nextCursor, highlighted },
2724
+ state: { comments, order, nextCursor, highlighted },
2723
2725
  autoCollapse,
2724
2726
  allowCopyLink,
2725
2727
  showProfileCard,
@@ -2729,29 +2731,31 @@ var __publicField = (obj, key, value) => {
2729
2731
  deleteComment,
2730
2732
  reply,
2731
2733
  loadMoreReplies,
2732
- api
2734
+ api,
2735
+ renderComments
2733
2736
  } = useCommentsContext();
2734
2737
  if (highlighted) {
2735
2738
  return /* @__PURE__ */ jsxRuntime.jsx(SegmentalList, { ...props });
2736
2739
  }
2740
+ const renderComment = (comment) => /* @__PURE__ */ jsxRuntime.jsx(
2741
+ Comment,
2742
+ {
2743
+ post: comment,
2744
+ onDelete: deleteComment,
2745
+ onContentUpdate: updateComment,
2746
+ onRate: api.rate,
2747
+ onUnrate: api.unrate,
2748
+ onReply: reply,
2749
+ onLoadMoreReplies: loadMoreReplies,
2750
+ autoCollapse,
2751
+ allowCopyLink,
2752
+ showProfileCard,
2753
+ interactive
2754
+ },
2755
+ comment.id
2756
+ );
2737
2757
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...props, children: [
2738
- comments == null ? void 0 : comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsx(
2739
- Comment,
2740
- {
2741
- post: comment,
2742
- onDelete: deleteComment,
2743
- onContentUpdate: updateComment,
2744
- onRate: api.rate,
2745
- onUnrate: api.unrate,
2746
- onReply: reply,
2747
- onLoadMoreReplies: loadMoreReplies,
2748
- autoCollapse,
2749
- allowCopyLink,
2750
- showProfileCard,
2751
- interactive
2752
- },
2753
- comment.id
2754
- )),
2758
+ renderComments ? renderComments({ order, comments, renderComment }) : comments == null ? void 0 : comments.map(renderComment),
2755
2759
  nextCursor && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2756
2760
  Button,
2757
2761
  {
@@ -3024,16 +3028,17 @@ var __publicField = (obj, key, value) => {
3024
3028
  docPrefix,
3025
3029
  pageGroup
3026
3030
  }, Symbol.toStringTag, { value: "Module" }));
3027
- const getBlogLink = (post) => {
3031
+ const getBlogLink = (post, locale) => {
3032
+ const mergedLocale = locale || post.locale || "en";
3028
3033
  const slug = post.slug || post.id;
3029
3034
  const datePrefix = `${dayjs(post.createdAt).format("YYYY-MM-DD")}-`;
3030
3035
  if (slug.startsWith(datePrefix)) {
3031
3036
  return blogPath(
3032
- `/${post.locale || "en"}/post/${dayjs(post.createdAt).format("YYYY/MM/DD")}/${slug.replace(datePrefix, "")}`
3037
+ `/${mergedLocale || "en"}/post/${dayjs(post.createdAt).format("YYYY/MM/DD")}/${slug.replace(datePrefix, "")}`
3033
3038
  );
3034
3039
  }
3035
- if (post.locale) {
3036
- return blogPath(`/${post.locale}/${slug}`);
3040
+ if (mergedLocale) {
3041
+ return blogPath(`/${mergedLocale}/${slug}`);
3037
3042
  }
3038
3043
  return blogPath(`/${slug}`);
3039
3044
  };
@@ -25,7 +25,12 @@ declare const preferences: {
25
25
  displayReactionOnBlog: boolean;
26
26
  displayReplyButtonForAnonymousUsers: boolean;
27
27
  disableNotificationBadge: boolean;
28
- disableActionLog: boolean;
28
+ enableDiscussLog: boolean;
29
+ discussLogPosition: "top" | "standard";
30
+ enableBlogLog: boolean;
31
+ blogLogPosition: "top" | "standard";
32
+ enableDocsLog: boolean;
33
+ docsLogPosition: "top" | "standard";
29
34
  badgeList: any[];
30
35
  socialShareButtonsDiscussion: boolean;
31
36
  socialShareButtonsBlog: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.0.29",
3
+ "version": "2.0.30",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -31,8 +31,8 @@
31
31
  "@arcblock/bridge": "^2.10.1",
32
32
  "@arcblock/react-hooks": "^2.10.1",
33
33
  "@arcblock/ws": "^1.18.123",
34
- "@blocklet/editor": "2.0.29",
35
- "@blocklet/labels": "2.0.29",
34
+ "@blocklet/editor": "2.0.30",
35
+ "@blocklet/labels": "2.0.30",
36
36
  "@blocklet/uploader": "^0.1.15",
37
37
  "@emotion/css": "^11.10.5",
38
38
  "@emotion/react": "^11.10.5",
@@ -100,5 +100,5 @@
100
100
  "resolutions": {
101
101
  "react": "^18.2.0"
102
102
  },
103
- "gitHead": "29a8c245893184dc46702087c472a4e1cdf1b829"
103
+ "gitHead": "af5244086d8945315aa554858ad12dcdde6bf102"
104
104
  }