@blocklet/discuss-kit-ux 1.5.208 → 1.5.210

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.
@@ -7,6 +7,8 @@ interface Props {
7
7
  size?: 'sm' | 'normal';
8
8
  responsive?: boolean;
9
9
  showProfileCard?: boolean;
10
+ showBadge?: boolean;
11
+ showDID?: boolean;
10
12
  }
11
- export default function AuthorInfo({ user, createdAt, append, size, responsive, showProfileCard, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
13
+ export default function AuthorInfo({ user, createdAt, append, size, responsive, showProfileCard, showBadge, showDID, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
12
14
  export {};
@@ -1,6 +1,7 @@
1
1
  import { InputProps } from './input';
2
2
  interface Props extends Omit<InputProps, 'render'> {
3
3
  sendText?: string;
4
+ allowEmptyContent?: boolean;
4
5
  }
5
- export default function CommentInput({ send, onSuccess, placeholder, sendText, draftKey, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export default function CommentInput({ allowEmptyContent, send, onSuccess, placeholder, sendText, draftKey, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
6
7
  export {};
@@ -8,6 +8,7 @@ interface CommentsProviderProps {
8
8
  children: React.ReactNode;
9
9
  order?: Order;
10
10
  autoCollapse?: boolean;
11
+ autoLoadComments?: boolean;
11
12
  allowCopyLink?: boolean;
12
13
  showProfileCard?: boolean;
13
14
  interactive?: boolean;
@@ -50,5 +51,5 @@ interface CommentsContextValue {
50
51
  }
51
52
  export declare const CommentsContext: import("react").Context<CommentsContextValue>;
52
53
  export declare const useCommentsContext: () => CommentsContextValue;
53
- export declare function CommentsProvider({ target, api, flatView, children, order, autoCollapse, allowCopyLink, showProfileCard, interactive, }: CommentsProviderProps): import("react/jsx-runtime").JSX.Element;
54
+ export declare function CommentsProvider({ target, api, flatView, children, order, autoLoadComments, autoCollapse, allowCopyLink, showProfileCard, interactive, }: CommentsProviderProps): import("react/jsx-runtime").JSX.Element;
54
55
  export {};
@@ -1,8 +1,10 @@
1
- declare const pageGroup: "blog" | "discussion" | "doc" | undefined;
1
+ declare const pageGroup: "blog" | "discussion" | "doc" | "bookmark" | undefined;
2
2
  export declare const blogPrefix: string;
3
3
  export declare const discussionPrefix: string;
4
4
  export declare const docPrefix: string;
5
+ export declare const bookmarkPrefix: string;
5
6
  export declare const blogPath: (path: string) => any;
6
7
  export declare const discussionPath: (path: string) => any;
7
8
  export declare const docPath: (path: string) => any;
9
+ export declare const bookmarkPath: (path: string) => any;
8
10
  export { pageGroup };
@@ -4,11 +4,12 @@ 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-f1140202.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-b4081082.mjs";
8
8
  import "@blocklet/labels";
9
9
  import "@mui/material/styles";
10
10
  import "@mui/material/Box";
11
11
  import "@arcblock/ux/lib/Theme";
12
+ import "lodash/isNil";
12
13
  import "@blocklet/editor/lib/config";
13
14
  import "lexical";
14
15
  import "@lexical/text";
@@ -24,7 +25,7 @@ import "@mui/material/Alert";
24
25
  import "@mui/material/Button";
25
26
  import "@arcblock/did-connect/lib/Avatar";
26
27
  import "@mui/material/useMediaQuery";
27
- import "@arcblock/did-connect/lib/Address";
28
+ import "@arcblock/ux/lib/DID";
28
29
  import "@mui/material/Tooltip";
29
30
  import "@arcblock/ux/lib/RelativeTime";
30
31
  import "@mui/material/Chip";
@@ -39,6 +40,7 @@ import "@iconify/react";
39
40
  import "react-router-dom";
40
41
  import "@mui/material/colors";
41
42
  import "@arcblock/did-connect/lib/Session";
43
+ import "@arcblock/did-connect/lib/Address";
42
44
  import "@blocklet/editor/lib/ext/CheckboxPlugin";
43
45
  import "@mui/material/MenuItem";
44
46
  import "clsx";
@@ -11,6 +11,7 @@ import { useTheme, ThemeProvider, styled as styled$1 } from "@mui/material/style
11
11
  import { useEffect, useRef, lazy, useState, createElement, useContext, isValidElement, Suspense, useMemo, createContext, Fragment as Fragment$1, forwardRef, useCallback } from "react";
12
12
  import Box from "@mui/material/Box";
13
13
  import { styled } from "@arcblock/ux/lib/Theme";
14
+ import isNil from "lodash/isNil";
14
15
  import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
15
16
  import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection } from "lexical";
16
17
  import { $isRootTextContentEmpty } from "@lexical/text";
@@ -26,7 +27,7 @@ import Alert from "@mui/material/Alert";
26
27
  import Button from "@mui/material/Button";
27
28
  import DidAvatar from "@arcblock/did-connect/lib/Avatar";
28
29
  import useMediaQuery$1 from "@mui/material/useMediaQuery";
29
- import DIDAddress from "@arcblock/did-connect/lib/Address";
30
+ import DID from "@arcblock/ux/lib/DID";
30
31
  import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
31
32
  import UxRelativeTime from "@arcblock/ux/lib/RelativeTime";
32
33
  import Chip from "@mui/material/Chip";
@@ -42,6 +43,7 @@ import { Link, useNavigate, useLocation, useSearchParams, unstable_useBlocker }
42
43
  import { green } from "@mui/material/colors";
43
44
  import { SessionContext } from "@arcblock/did-connect/lib/Session";
44
45
  import { useTheme as useTheme$1, useMediaQuery, Box as Box$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Badge as Badge$1 } from "@mui/material";
46
+ import DIDAddress from "@arcblock/did-connect/lib/Address";
45
47
  import CheckboxPlugin from "@blocklet/editor/lib/ext/CheckboxPlugin";
46
48
  import MuiMenuItem from "@mui/material/MenuItem";
47
49
  import clsx from "clsx";
@@ -461,7 +463,7 @@ const Input = ({
461
463
  const originContent = content;
462
464
  try {
463
465
  isChanged.current = true;
464
- const result = await send(JSON.stringify(content));
466
+ const result = await send(isNil(content) ? "" : JSON.stringify(content));
465
467
  setContent(null);
466
468
  if (draftKey) {
467
469
  setDraftContent(null);
@@ -521,7 +523,15 @@ const StyledInput = styled$1(Input)`
521
523
  margin-top: 4px;
522
524
  }
523
525
  `;
524
- function CommentInput({ send, onSuccess, placeholder, sendText, draftKey = "", ...rest }) {
526
+ function CommentInput({
527
+ allowEmptyContent,
528
+ send,
529
+ onSuccess,
530
+ placeholder,
531
+ sendText,
532
+ draftKey = "",
533
+ ...rest
534
+ }) {
525
535
  const { t } = useContext(LocaleContext);
526
536
  return /* @__PURE__ */ jsx(
527
537
  StyledInput,
@@ -569,7 +579,7 @@ function CommentInput({ send, onSuccess, placeholder, sendText, draftKey = "", .
569
579
  /* @__PURE__ */ jsx(Box, { display: "flex", gap: 1, alignItems: "center", children: /* @__PURE__ */ jsx(
570
580
  LoadingButton,
571
581
  {
572
- disabled: !content,
582
+ disabled: allowEmptyContent ? false : !content,
573
583
  loading,
574
584
  loadingPosition: "start",
575
585
  startIcon: /* @__PURE__ */ jsx(Send, { sx: { transform: "rotate(-45deg) translateX(3px)" } }),
@@ -932,14 +942,11 @@ function ProfileCard({ user, ...rest }) {
932
942
  }
933
943
  ),
934
944
  /* @__PURE__ */ jsx(
935
- DIDAddress,
945
+ DID,
936
946
  {
937
- inline: true,
938
- responsive: false,
939
- compact: false,
940
- copyable: false,
941
- style: { marginTop: 4, lineHeight: 1, fontSize: 13 },
942
- children: user.did
947
+ style: { marginTop: 4, lineHeight: 1, height: 14, maxWidth: 250, color: "inherit !important" },
948
+ size: 14,
949
+ did: user.did
943
950
  }
944
951
  )
945
952
  ] })
@@ -976,13 +983,15 @@ function AuthorInfo({
976
983
  size = "normal",
977
984
  responsive = false,
978
985
  showProfileCard,
986
+ showBadge = true,
987
+ showDID = true,
979
988
  ...rest
980
989
  }) {
981
990
  const theme = useTheme();
982
991
  const downMd = useMediaQuery$1(theme.breakpoints.down("md"));
983
992
  const sm = size === "sm";
984
993
  let fontSize = sm ? 12 : 14;
985
- let avatarSize = sm ? 32 : 36;
994
+ let avatarSize = sm ? 32 : 40;
986
995
  if (responsive && downMd) {
987
996
  fontSize = 12;
988
997
  avatarSize = 24;
@@ -999,9 +1008,33 @@ function AuthorInfo({
999
1008
  };
1000
1009
  const renderAvatar = () => {
1001
1010
  if (showProfileCard) {
1002
- return /* @__PURE__ */ jsx(HtmlTooltip$1, { title: /* @__PURE__ */ jsx(ProfileCard, { user }), children: /* @__PURE__ */ jsx(Box, { sx: { display: "flex" }, children: /* @__PURE__ */ jsx(Avatar, { did: user.did, src: user.avatar, size: avatarSize, shape: "circle", variant: "circle" }) }) });
1011
+ return /* @__PURE__ */ jsx(HtmlTooltip$1, { title: /* @__PURE__ */ jsx(ProfileCard, { user }), children: /* @__PURE__ */ jsx(Box, { sx: { display: "flex" }, children: /* @__PURE__ */ jsx(
1012
+ Avatar,
1013
+ {
1014
+ did: user.did,
1015
+ src: user.avatar,
1016
+ size: avatarSize,
1017
+ shape: "circle",
1018
+ variant: "circle",
1019
+ sx: {
1020
+ width: avatarSize
1021
+ }
1022
+ }
1023
+ ) }) });
1003
1024
  }
1004
- return /* @__PURE__ */ jsx(Avatar, { did: user.did, src: user.avatar, size: avatarSize, shape: "circle", variant: "circle" });
1025
+ return /* @__PURE__ */ jsx(
1026
+ Avatar,
1027
+ {
1028
+ did: user.did,
1029
+ src: user.avatar,
1030
+ size: avatarSize,
1031
+ shape: "circle",
1032
+ variant: "circle",
1033
+ sx: {
1034
+ width: avatarSize
1035
+ }
1036
+ }
1037
+ );
1005
1038
  };
1006
1039
  const BadgeRender = /* @__PURE__ */ jsx(
1007
1040
  Badge,
@@ -1021,18 +1054,18 @@ function AuthorInfo({
1021
1054
  sx: { display: "flex", alignItems: "center", minHeight: 20, flexWrap: "wrap", lineHeight: 1.5 },
1022
1055
  lineHeight: 1,
1023
1056
  children: [
1024
- /* @__PURE__ */ jsx("span", { children: user.fullName }),
1057
+ /* @__PURE__ */ jsx("span", { className: "user-fullname", children: user.fullName }),
1025
1058
  createdAt && /* @__PURE__ */ jsxs(Fragment, { children: [
1026
1059
  /* @__PURE__ */ jsx(Box, { component: "span", display: "inline-block", mx: 0.5, children: "·" }),
1027
1060
  renderTime()
1028
1061
  ] }),
1029
1062
  append,
1030
- !downMd && BadgeRender
1063
+ showBadge && !downMd && BadgeRender
1031
1064
  ]
1032
1065
  }
1033
1066
  ),
1034
- downMd && /* @__PURE__ */ jsx(Box, { mt: 0.5, children: BadgeRender }),
1035
- !(responsive && downMd) && /* @__PURE__ */ jsx(DIDAddress, { inline: true, responsive: false, compact: true, copyable: false, style: { lineHeight: 1, height: 20 }, children: user.did })
1067
+ showBadge && downMd && /* @__PURE__ */ jsx(Box, { mt: 0.5, children: BadgeRender }),
1068
+ showDID && !(responsive && downMd) && /* @__PURE__ */ jsx(DID, { style: { lineHeight: 1.5, minHeight: 20, maxWidth: 250 }, size: 14, did: user.did })
1036
1069
  ] })
1037
1070
  ] });
1038
1071
  }
@@ -1269,6 +1302,13 @@ function PostComponent({
1269
1302
  }
1270
1303
  return /* @__PURE__ */ jsx(RelativeTime, { value: post.createdAt });
1271
1304
  };
1305
+ let systemTip = "";
1306
+ if (post.deletedAt) {
1307
+ systemTip = t("deleted");
1308
+ } else if (!post.content) {
1309
+ systemTip = t("emptyContent");
1310
+ }
1311
+ const showSystemTip = systemTip && !editing;
1272
1312
  return /* @__PURE__ */ jsxs(Root$1, { sx: { position: "relative", mt: 2, py: 1 }, ...rest, children: [
1273
1313
  /* @__PURE__ */ jsxs(Box, { id: post.id, flex: "1", className: clsx({ "post-highlighted": isTargetPost }), children: [
1274
1314
  /* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [
@@ -1293,18 +1333,7 @@ function PostComponent({
1293
1333
  ]
1294
1334
  }
1295
1335
  ),
1296
- !post.deletedAt && /* @__PURE__ */ jsx(
1297
- PostContent,
1298
- {
1299
- content: post.content,
1300
- editing,
1301
- onExitEditing: () => setEditing(false),
1302
- onSubmit: (content) => onContentUpdate(post, content),
1303
- autoCollapse
1304
- },
1305
- editing ? "comment-content" : post.synced || 0
1306
- ),
1307
- post.deletedAt && /* @__PURE__ */ jsx(
1336
+ showSystemTip && /* @__PURE__ */ jsx(
1308
1337
  Box,
1309
1338
  {
1310
1339
  display: "inline-block",
@@ -1315,9 +1344,20 @@ function PostComponent({
1315
1344
  bgcolor: "grey.100",
1316
1345
  color: "grey.600",
1317
1346
  borderRadius: 1,
1318
- children: t("deleted")
1347
+ children: systemTip
1319
1348
  }
1320
1349
  ),
1350
+ !showSystemTip && !post.deletedAt && /* @__PURE__ */ jsx(Box, { my: 1, children: /* @__PURE__ */ jsx(
1351
+ PostContent,
1352
+ {
1353
+ content: post.content,
1354
+ editing,
1355
+ onExitEditing: () => setEditing(false),
1356
+ onSubmit: (content) => onContentUpdate(post, content),
1357
+ autoCollapse
1358
+ },
1359
+ editing ? "comment-content" : post.synced || 0
1360
+ ) }),
1321
1361
  render && /* @__PURE__ */ jsx(Box, { sx: { mt: 1 }, children: render(postContext) })
1322
1362
  ] })
1323
1363
  ] }),
@@ -2001,6 +2041,7 @@ function CommentsProvider({
2001
2041
  flatView,
2002
2042
  children,
2003
2043
  order,
2044
+ autoLoadComments = true,
2004
2045
  autoCollapse,
2005
2046
  allowCopyLink,
2006
2047
  showProfileCard,
@@ -2024,6 +2065,10 @@ function CommentsProvider({
2024
2065
  const initialRepliesLimit = -1;
2025
2066
  useEffect(() => {
2026
2067
  const init = async () => {
2068
+ if (!autoLoadComments) {
2069
+ setState({ initialized: true });
2070
+ return;
2071
+ }
2027
2072
  setState({ ...getInitialState(order ? { order } : {}), initialized: false });
2028
2073
  const fetchCommentPosition = () => api.fetchCommentPosition({
2029
2074
  id: highlightedRef.current,
@@ -2573,6 +2618,7 @@ const { pageGroup } = window.blocklet;
2573
2618
  const blogPrefix = pageGroup === "blog" ? "" : "blog";
2574
2619
  const discussionPrefix = pageGroup === "discussion" ? "" : "discussions";
2575
2620
  const docPrefix = pageGroup === "doc" ? "" : "docs";
2621
+ const bookmarkPrefix = pageGroup === "bookmark" ? "" : "bookmark";
2576
2622
  const blogPath = (path) => {
2577
2623
  return window.blocklet.pageGroup === "blog" ? path : joinUrl("/blog", path);
2578
2624
  };
@@ -2582,10 +2628,15 @@ const discussionPath = (path) => {
2582
2628
  const docPath = (path) => {
2583
2629
  return window.blocklet.pageGroup === "doc" ? path : joinUrl("/docs", path);
2584
2630
  };
2631
+ const bookmarkPath = (path) => {
2632
+ return window.blocklet.pageGroup === "bookmark" ? path : joinUrl("/bookmark", path);
2633
+ };
2585
2634
  const routes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2586
2635
  __proto__: null,
2587
2636
  blogPath,
2588
2637
  blogPrefix,
2638
+ bookmarkPath,
2639
+ bookmarkPrefix,
2589
2640
  discussionPath,
2590
2641
  discussionPrefix,
2591
2642
  docPath,
@@ -4345,7 +4396,7 @@ function Pagination({ page, size = 20, total, onChange, routerMode = true, ...re
4345
4396
  }
4346
4397
  );
4347
4398
  }
4348
- const Editor = lazy(() => import("./editor-ee6248bc.mjs"));
4399
+ const Editor = lazy(() => import("./editor-64b50636.mjs"));
4349
4400
  function LazyEditor(props) {
4350
4401
  const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
4351
4402
  /* @__PURE__ */ jsx(Skeleton, {}),
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { K, j, N, A, h, a6, B, z, y, E, Q, O, T, W, o, C, q, v, x, _, $, aa, a1, H, J, D, a9, a8, G, c, b, a7, M, P, ah, n, m, a5, R, S, a2, k, X, Z, ab, ae, ad, af, ai, F, aj, l, p, r, t, d, a3, L, e, U, w, a0, a4, u, ag, ak, Y, ac, f } from "./index-f1140202.mjs";
2
+ import { K, j, N, A, h, a6, B, z, y, E, Q, O, T, W, o, C, q, v, x, _, $, aa, a1, H, J, D, a9, a8, G, c, b, a7, M, P, ah, n, m, a5, R, S, a2, k, X, Z, ab, ae, ad, af, ai, F, aj, l, p, r, t, d, a3, L, e, U, w, a0, a4, u, ag, ak, Y, ac, f } from "./index-b4081082.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -11,6 +11,7 @@ import "@arcblock/did-connect/lib/Session";
11
11
  import "@mui/material";
12
12
  import "@mui/material/styles";
13
13
  import "@arcblock/ux/lib/Theme";
14
+ import "lodash/isNil";
14
15
  import "@blocklet/editor/lib/config";
15
16
  import "lexical";
16
17
  import "@lexical/text";
@@ -22,7 +23,7 @@ import "ahooks";
22
23
  import "@mui/material/Alert";
23
24
  import "@arcblock/did-connect/lib/Avatar";
24
25
  import "@mui/material/useMediaQuery";
25
- import "@arcblock/did-connect/lib/Address";
26
+ import "@arcblock/ux/lib/DID";
26
27
  import "@mui/material/Tooltip";
27
28
  import "@arcblock/ux/lib/RelativeTime";
28
29
  import "@mui/material/Chip";
@@ -36,6 +37,7 @@ import "@mui/icons-material/BrokenImage";
36
37
  import "@iconify/react";
37
38
  import "react-router-dom";
38
39
  import "@mui/material/colors";
40
+ import "@arcblock/did-connect/lib/Address";
39
41
  import "@blocklet/editor/lib/ext/CheckboxPlugin";
40
42
  import "@mui/material/MenuItem";
41
43
  import "clsx";
package/dist/index.umd.js CHANGED
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("react"), require("@mui/material/Box"), require("@arcblock/ux/lib/Theme"), require("@blocklet/editor/lib/config"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/useMediaQuery"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/Tooltip"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("react-router-dom"), require("@mui/material/colors"), require("@arcblock/did-connect/lib/Session"), require("@mui/material"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("react-dom"), require("js-cookie"), require("@arcblock/ws"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "react", "@mui/material/Box", "@arcblock/ux/lib/Theme", "@blocklet/editor/lib/config", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/useMediaQuery", "@arcblock/did-connect/lib/Address", "@mui/material/Tooltip", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "react-router-dom", "@mui/material/colors", "@arcblock/did-connect/lib/Session", "@mui/material", "@blocklet/editor/lib/ext/CheckboxPlugin", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "react-dom", "js-cookie", "@arcblock/ws", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.react, global.Box, global.Theme, global.config, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.Button, global.DidAvatar, global.useMediaQuery, global.DIDAddress, global.Tooltip, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.reactRouterDom, global.colors, global.Session, global.material, global.CheckboxPlugin, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.joinUrl, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.Fab, global.debounce, global.TextField, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.reactDom, global.Cookie, global.ws, global.OnContentChangePlugin, global.ShortcutPlugin, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
9
- })(this, function(exports2, labels, jsxRuntime, styles, react, Box, Theme, config, LexicalComposerContext, lexical$1, ahooks, LoadingButton, iconsMaterial, context, Alert, Button, DidAvatar, useMediaQuery, DIDAddress, Tooltip, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, reactRouterDom, colors, Session, material, CheckboxPlugin, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, joinUrl, dayjs, relativeTime, mitt, CircularProgress, Fab, debounce, TextField, axios, Toast, MuiPagination, unstatedNext, reactDom, Cookie, ws, OnContentChangePlugin, ShortcutPlugin, SafeAreaPlugin, text, ImageNode, VideoNode) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("react"), require("@mui/material/Box"), require("@arcblock/ux/lib/Theme"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("react-router-dom"), require("@mui/material/colors"), require("@arcblock/did-connect/lib/Session"), require("@mui/material"), require("@arcblock/did-connect/lib/Address"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("react-dom"), require("js-cookie"), require("@arcblock/ws"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "react", "@mui/material/Box", "@arcblock/ux/lib/Theme", "lodash/isNil", "@blocklet/editor/lib/config", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "react-router-dom", "@mui/material/colors", "@arcblock/did-connect/lib/Session", "@mui/material", "@arcblock/did-connect/lib/Address", "@blocklet/editor/lib/ext/CheckboxPlugin", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "react-dom", "js-cookie", "@arcblock/ws", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.react, global.Box, global.Theme, global.isNil, global.config, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.Button, global.DidAvatar, global.useMediaQuery, global.DID, global.Tooltip, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.reactRouterDom, global.colors, global.Session, global.material, global.DIDAddress, global.CheckboxPlugin, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.joinUrl, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.Fab, global.debounce, global.TextField, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.reactDom, global.Cookie, global.ws, global.OnContentChangePlugin, global.ShortcutPlugin, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
9
+ })(this, function(exports2, labels, jsxRuntime, styles, react, Box, Theme, isNil, config, LexicalComposerContext, lexical$1, ahooks, LoadingButton, iconsMaterial, context, Alert, Button, DidAvatar, useMediaQuery, DID, Tooltip, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, reactRouterDom, colors, Session, material, DIDAddress, CheckboxPlugin, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, joinUrl, dayjs, relativeTime, mitt, CircularProgress, Fab, debounce, TextField, axios, Toast, MuiPagination, unstatedNext, reactDom, Cookie, ws, OnContentChangePlugin, ShortcutPlugin, SafeAreaPlugin, text, ImageNode, VideoNode) {
10
10
  var _a, _b;
11
11
  "use strict";
12
12
  const themeOverrides = {
@@ -405,7 +405,7 @@ var __publicField = (obj, key, value) => {
405
405
  const originContent = content;
406
406
  try {
407
407
  isChanged.current = true;
408
- const result = await send(JSON.stringify(content));
408
+ const result = await send(isNil(content) ? "" : JSON.stringify(content));
409
409
  setContent(null);
410
410
  if (draftKey) {
411
411
  setDraftContent(null);
@@ -465,7 +465,15 @@ var __publicField = (obj, key, value) => {
465
465
  margin-top: 4px;
466
466
  }
467
467
  `;
468
- function CommentInput({ send, onSuccess, placeholder, sendText, draftKey = "", ...rest }) {
468
+ function CommentInput({
469
+ allowEmptyContent,
470
+ send,
471
+ onSuccess,
472
+ placeholder,
473
+ sendText,
474
+ draftKey = "",
475
+ ...rest
476
+ }) {
469
477
  const { t } = react.useContext(context.LocaleContext);
470
478
  return /* @__PURE__ */ jsxRuntime.jsx(
471
479
  StyledInput,
@@ -513,7 +521,7 @@ var __publicField = (obj, key, value) => {
513
521
  /* @__PURE__ */ jsxRuntime.jsx(Box, { display: "flex", gap: 1, alignItems: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
514
522
  LoadingButton,
515
523
  {
516
- disabled: !content,
524
+ disabled: allowEmptyContent ? false : !content,
517
525
  loading,
518
526
  loadingPosition: "start",
519
527
  startIcon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Send, { sx: { transform: "rotate(-45deg) translateX(3px)" } }),
@@ -876,14 +884,11 @@ var __publicField = (obj, key, value) => {
876
884
  }
877
885
  ),
878
886
  /* @__PURE__ */ jsxRuntime.jsx(
879
- DIDAddress,
887
+ DID,
880
888
  {
881
- inline: true,
882
- responsive: false,
883
- compact: false,
884
- copyable: false,
885
- style: { marginTop: 4, lineHeight: 1, fontSize: 13 },
886
- children: user.did
889
+ style: { marginTop: 4, lineHeight: 1, height: 14, maxWidth: 250, color: "inherit !important" },
890
+ size: 14,
891
+ did: user.did
887
892
  }
888
893
  )
889
894
  ] })
@@ -920,13 +925,15 @@ var __publicField = (obj, key, value) => {
920
925
  size = "normal",
921
926
  responsive = false,
922
927
  showProfileCard,
928
+ showBadge = true,
929
+ showDID = true,
923
930
  ...rest
924
931
  }) {
925
932
  const theme = styles.useTheme();
926
933
  const downMd = useMediaQuery(theme.breakpoints.down("md"));
927
934
  const sm = size === "sm";
928
935
  let fontSize = sm ? 12 : 14;
929
- let avatarSize = sm ? 32 : 36;
936
+ let avatarSize = sm ? 32 : 40;
930
937
  if (responsive && downMd) {
931
938
  fontSize = 12;
932
939
  avatarSize = 24;
@@ -943,9 +950,33 @@ var __publicField = (obj, key, value) => {
943
950
  };
944
951
  const renderAvatar = () => {
945
952
  if (showProfileCard) {
946
- return /* @__PURE__ */ jsxRuntime.jsx(HtmlTooltip$1, { title: /* @__PURE__ */ jsxRuntime.jsx(ProfileCard, { user }), children: /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { display: "flex" }, children: /* @__PURE__ */ jsxRuntime.jsx(Avatar, { did: user.did, src: user.avatar, size: avatarSize, shape: "circle", variant: "circle" }) }) });
953
+ return /* @__PURE__ */ jsxRuntime.jsx(HtmlTooltip$1, { title: /* @__PURE__ */ jsxRuntime.jsx(ProfileCard, { user }), children: /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { display: "flex" }, children: /* @__PURE__ */ jsxRuntime.jsx(
954
+ Avatar,
955
+ {
956
+ did: user.did,
957
+ src: user.avatar,
958
+ size: avatarSize,
959
+ shape: "circle",
960
+ variant: "circle",
961
+ sx: {
962
+ width: avatarSize
963
+ }
964
+ }
965
+ ) }) });
947
966
  }
948
- return /* @__PURE__ */ jsxRuntime.jsx(Avatar, { did: user.did, src: user.avatar, size: avatarSize, shape: "circle", variant: "circle" });
967
+ return /* @__PURE__ */ jsxRuntime.jsx(
968
+ Avatar,
969
+ {
970
+ did: user.did,
971
+ src: user.avatar,
972
+ size: avatarSize,
973
+ shape: "circle",
974
+ variant: "circle",
975
+ sx: {
976
+ width: avatarSize
977
+ }
978
+ }
979
+ );
949
980
  };
950
981
  const BadgeRender = /* @__PURE__ */ jsxRuntime.jsx(
951
982
  Badge,
@@ -965,18 +996,18 @@ var __publicField = (obj, key, value) => {
965
996
  sx: { display: "flex", alignItems: "center", minHeight: 20, flexWrap: "wrap", lineHeight: 1.5 },
966
997
  lineHeight: 1,
967
998
  children: [
968
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: user.fullName }),
999
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "user-fullname", children: user.fullName }),
969
1000
  createdAt && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
970
1001
  /* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", display: "inline-block", mx: 0.5, children: "·" }),
971
1002
  renderTime()
972
1003
  ] }),
973
1004
  append,
974
- !downMd && BadgeRender
1005
+ showBadge && !downMd && BadgeRender
975
1006
  ]
976
1007
  }
977
1008
  ),
978
- downMd && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 0.5, children: BadgeRender }),
979
- !(responsive && downMd) && /* @__PURE__ */ jsxRuntime.jsx(DIDAddress, { inline: true, responsive: false, compact: true, copyable: false, style: { lineHeight: 1, height: 20 }, children: user.did })
1009
+ showBadge && downMd && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 0.5, children: BadgeRender }),
1010
+ showDID && !(responsive && downMd) && /* @__PURE__ */ jsxRuntime.jsx(DID, { style: { lineHeight: 1.5, minHeight: 20, maxWidth: 250 }, size: 14, did: user.did })
980
1011
  ] })
981
1012
  ] });
982
1013
  }
@@ -1213,6 +1244,13 @@ var __publicField = (obj, key, value) => {
1213
1244
  }
1214
1245
  return /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { value: post.createdAt });
1215
1246
  };
1247
+ let systemTip = "";
1248
+ if (post.deletedAt) {
1249
+ systemTip = t("deleted");
1250
+ } else if (!post.content) {
1251
+ systemTip = t("emptyContent");
1252
+ }
1253
+ const showSystemTip = systemTip && !editing;
1216
1254
  return /* @__PURE__ */ jsxRuntime.jsxs(Root$2, { sx: { position: "relative", mt: 2, py: 1 }, ...rest, children: [
1217
1255
  /* @__PURE__ */ jsxRuntime.jsxs(Box, { id: post.id, flex: "1", className: clsx({ "post-highlighted": isTargetPost }), children: [
1218
1256
  /* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [
@@ -1237,18 +1275,7 @@ var __publicField = (obj, key, value) => {
1237
1275
  ]
1238
1276
  }
1239
1277
  ),
1240
- !post.deletedAt && /* @__PURE__ */ jsxRuntime.jsx(
1241
- PostContent,
1242
- {
1243
- content: post.content,
1244
- editing,
1245
- onExitEditing: () => setEditing(false),
1246
- onSubmit: (content) => onContentUpdate(post, content),
1247
- autoCollapse
1248
- },
1249
- editing ? "comment-content" : post.synced || 0
1250
- ),
1251
- post.deletedAt && /* @__PURE__ */ jsxRuntime.jsx(
1278
+ showSystemTip && /* @__PURE__ */ jsxRuntime.jsx(
1252
1279
  Box,
1253
1280
  {
1254
1281
  display: "inline-block",
@@ -1259,9 +1286,20 @@ var __publicField = (obj, key, value) => {
1259
1286
  bgcolor: "grey.100",
1260
1287
  color: "grey.600",
1261
1288
  borderRadius: 1,
1262
- children: t("deleted")
1289
+ children: systemTip
1263
1290
  }
1264
1291
  ),
1292
+ !showSystemTip && !post.deletedAt && /* @__PURE__ */ jsxRuntime.jsx(Box, { my: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
1293
+ PostContent,
1294
+ {
1295
+ content: post.content,
1296
+ editing,
1297
+ onExitEditing: () => setEditing(false),
1298
+ onSubmit: (content) => onContentUpdate(post, content),
1299
+ autoCollapse
1300
+ },
1301
+ editing ? "comment-content" : post.synced || 0
1302
+ ) }),
1265
1303
  render && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { mt: 1 }, children: render(postContext) })
1266
1304
  ] })
1267
1305
  ] }),
@@ -1945,6 +1983,7 @@ var __publicField = (obj, key, value) => {
1945
1983
  flatView,
1946
1984
  children,
1947
1985
  order,
1986
+ autoLoadComments = true,
1948
1987
  autoCollapse,
1949
1988
  allowCopyLink,
1950
1989
  showProfileCard,
@@ -1968,6 +2007,10 @@ var __publicField = (obj, key, value) => {
1968
2007
  const initialRepliesLimit = -1;
1969
2008
  react.useEffect(() => {
1970
2009
  const init = async () => {
2010
+ if (!autoLoadComments) {
2011
+ setState({ initialized: true });
2012
+ return;
2013
+ }
1971
2014
  setState({ ...getInitialState(order ? { order } : {}), initialized: false });
1972
2015
  const fetchCommentPosition = () => api.fetchCommentPosition({
1973
2016
  id: highlightedRef.current,
@@ -2517,6 +2560,7 @@ var __publicField = (obj, key, value) => {
2517
2560
  const blogPrefix = pageGroup === "blog" ? "" : "blog";
2518
2561
  const discussionPrefix = pageGroup === "discussion" ? "" : "discussions";
2519
2562
  const docPrefix = pageGroup === "doc" ? "" : "docs";
2563
+ const bookmarkPrefix = pageGroup === "bookmark" ? "" : "bookmark";
2520
2564
  const blogPath = (path) => {
2521
2565
  return window.blocklet.pageGroup === "blog" ? path : joinUrl("/blog", path);
2522
2566
  };
@@ -2526,10 +2570,15 @@ var __publicField = (obj, key, value) => {
2526
2570
  const docPath = (path) => {
2527
2571
  return window.blocklet.pageGroup === "doc" ? path : joinUrl("/docs", path);
2528
2572
  };
2573
+ const bookmarkPath = (path) => {
2574
+ return window.blocklet.pageGroup === "bookmark" ? path : joinUrl("/bookmark", path);
2575
+ };
2529
2576
  const routes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2530
2577
  __proto__: null,
2531
2578
  blogPath,
2532
2579
  blogPrefix,
2580
+ bookmarkPath,
2581
+ bookmarkPrefix,
2533
2582
  discussionPath,
2534
2583
  discussionPrefix,
2535
2584
  docPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "1.5.208",
3
+ "version": "1.5.210",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@arcblock/ws": "^1.18.103",
32
- "@blocklet/editor": "1.5.208",
33
- "@blocklet/labels": "1.5.208",
32
+ "@blocklet/editor": "1.5.210",
33
+ "@blocklet/labels": "1.5.210",
34
34
  "@blocklet/uploader": "^0.0.52",
35
35
  "@emotion/css": "^11.10.5",
36
36
  "@emotion/react": "^11.10.5",
@@ -92,5 +92,5 @@
92
92
  "resolutions": {
93
93
  "react": "^18.2.0"
94
94
  },
95
- "gitHead": "cb4657e88ffc0f5361a53ef0da788fda78916cc8"
95
+ "gitHead": "dd840fad65551bdb42bfebfc12f20fffcf37cac2"
96
96
  }