@blocklet/discuss-kit-ux 2.0.70 → 2.0.71

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.
@@ -3,4 +3,3 @@ export { useChanged } from './changed';
3
3
  export { useNow } from './now';
4
4
  export { useInterval } from './interval';
5
5
  export { useDownBreakpoint, useUpBreakpoint } from './responsive';
6
- export { useNotification } from './notification';
@@ -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-DR4mMFMg.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-Crgy_5Hh.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -1126,23 +1126,6 @@ const useResponsiveValue = (values2) => {
1126
1126
  const r = useResponsive();
1127
1127
  return r(values2);
1128
1128
  };
1129
- const useNotification = () => {
1130
- const show = async ({ title, options, onclick }) => {
1131
- if (!("Notification" in window))
1132
- return;
1133
- if (Notification.permission === "granted") {
1134
- const notification = new Notification(title, options);
1135
- notification.onclick = onclick ?? null;
1136
- return;
1137
- }
1138
- if (Notification.permission !== "denied") {
1139
- const permission = await Notification.requestPermission();
1140
- if (permission === "granted")
1141
- show({ title, options, onclick });
1142
- }
1143
- };
1144
- return { show };
1145
- };
1146
1129
  function ProfileCard({ user, click, ...rest }) {
1147
1130
  var _a2, _b2, _c2;
1148
1131
  const { session } = useSessionContext();
@@ -3745,9 +3728,6 @@ function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
3745
3728
  activeChatId: void 0,
3746
3729
  error: void 0
3747
3730
  });
3748
- const chatById = useMemo(() => {
3749
- return state.chats.reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {});
3750
- }, [state.chats]);
3751
3731
  const { markAsUnread } = useUnreadNotification();
3752
3732
  const navigate = useNavigate();
3753
3733
  const { session } = useSessionContext();
@@ -3959,42 +3939,9 @@ function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
3959
3939
  setState((prev) => ({ ...prev, activeChatId: void 0 }));
3960
3940
  }
3961
3941
  }, [state, activeChatId]);
3962
- const { t } = useLocaleContext();
3963
- const { show } = useNotification();
3964
- const resolveChatNotification = (chatId, { id: id2, content, sender, type, link, sourceUser, comment, reply, post }) => {
3965
- if (isInWallet || sender.did === currentUser.did)
3966
- return;
3967
- const chat = chatById[chatId];
3968
- if (!chat)
3969
- return;
3970
- const isSystem = chat.type === "notification";
3971
- const isChannel = chat.type === "channel";
3972
- const getNotificationMeta = () => {
3973
- const getOpener = (url) => () => window.open(url, "_blank");
3974
- const getTitle = (i18nKey) => `${sourceUser == null ? void 0 : sourceUser.fullName} ${t(`chat.${i18nKey}`)}`;
3975
- const onclick2 = getOpener(link);
3976
- const map = {
3977
- message: {
3978
- title: `${t("chat.newMsg")} ${isChannel ? chat.name : sender.fullName}`,
3979
- body: getExcerptFromLexicalContent(content),
3980
- onclick: getOpener(joinURL(discussKitMountPoint ?? "", "/chat", chatId))
3981
- },
3982
- comment: { title: getTitle("commentedYourPost"), body: comment == null ? void 0 : comment.excerpt, onclick: onclick2 },
3983
- reply: { title: getTitle("replyYourComment"), body: reply == null ? void 0 : reply.excerpt, onclick: onclick2 },
3984
- mentionInComment: { title: getTitle("mentionInComment"), body: comment == null ? void 0 : comment.excerpt, onclick: onclick2 },
3985
- mentionInPost: { title: getTitle("mentionInPost"), body: post == null ? void 0 : post.excerpt, onclick: onclick2 }
3986
- };
3987
- return map[type];
3988
- };
3989
- const icon = isSystem ? sourceUser == null ? void 0 : sourceUser.avatar : sender.avatar;
3990
- const { title, body, onclick } = getNotificationMeta();
3991
- if (title)
3992
- show({ title, onclick, options: { tag: id2, icon, body } });
3993
- };
3994
3942
  useEffect(() => {
3995
3943
  const cancels = [
3996
3944
  client2.onMessage(({ chatId, message }) => {
3997
- resolveChatNotification(chatId, message);
3998
3945
  addMessage(chatId, message);
3999
3946
  if (message.sender.did === (currentUser == null ? void 0 : currentUser.did)) {
4000
3947
  updateLastAckTime(chatId, true);
@@ -4802,7 +4749,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4802
4749
  }
4803
4750
  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" }) });
4804
4751
  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" }) });
4805
- const Editor = lazy(() => import("./editor-D5fQYtn3.mjs"));
4752
+ const Editor = lazy(() => import("./editor-CcCcYrHu.mjs"));
4806
4753
  function LazyEditor(props) {
4807
4754
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4808
4755
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -12271,89 +12218,88 @@ function SegmentedControl({ value, options, onChange, sx, ...rest }) {
12271
12218
  ) });
12272
12219
  }
12273
12220
  export {
12274
- ChatListInWallet as $,
12221
+ ChatHeaderAddon as $,
12275
12222
  Avatar as A,
12276
12223
  Badge as B,
12277
12224
  CommentInput as C,
12278
12225
  DefaultEditorConfigProvider as D,
12279
- useCommentsContext as E,
12280
- CommentsProvider as F,
12281
- BinaryThumb as G,
12282
- GithubReaction as H,
12226
+ CommentsProvider as E,
12227
+ BinaryThumb as F,
12228
+ GithubReaction as G,
12229
+ EmptyStatus as H,
12283
12230
  ImagePathFixerPlugin as I,
12284
- EmptyStatus as J,
12285
- BlogListWrapper as K,
12286
- BlogCard as L,
12231
+ BlogListWrapper as J,
12232
+ BlogCard as K,
12233
+ BlogPermaLink as L,
12287
12234
  Menu as M,
12288
- BlogPermaLink as N,
12289
- getBlogLink as O,
12235
+ getBlogLink as N,
12236
+ CoverImage as O,
12290
12237
  Pagination as P,
12291
- CoverImage as Q,
12238
+ CoverImageUpload as Q,
12292
12239
  RelativeTime as R,
12293
12240
  ScrollableEditorWrapper as S,
12294
- CoverImageUpload as T,
12295
- AccessControl as U,
12241
+ AccessControl as T,
12242
+ useAuthzContext as U,
12296
12243
  VideoPathFixerPlugin as V,
12297
- useAuthzContext as W,
12298
- AuthzProvider as X,
12299
- ChatClient as Y,
12300
- Chat as Z,
12301
- ChatInWallet as _,
12244
+ AuthzProvider as W,
12245
+ ChatClient as X,
12246
+ Chat as Y,
12247
+ ChatInWallet as Z,
12248
+ ChatListInWallet as _,
12302
12249
  isEmptyContent as a,
12303
- ChatHeaderAddon as a0,
12304
- useChatContext as a1,
12305
- ChatProvider as a2,
12306
- UnreadNotificationContext as a3,
12307
- useUnreadNotification as a4,
12308
- UnreadNotificationProvider as a5,
12309
- Confirm as a6,
12310
- ConfirmContext as a7,
12311
- useConfirm as a8,
12312
- ConfirmProvider as a9,
12313
- SecureLabelPicker as aa,
12314
- useApiErrorHandler as ab,
12315
- useDefaultApiErrorHandler as ac,
12316
- DefaultApiErrorHandler as ad,
12317
- Back as ae,
12318
- LazyEditor as af,
12319
- EditorPreview as ag,
12320
- DirtyPromptContainer as ah,
12321
- ConfirmNavigation as ai,
12322
- UploaderContext as aj,
12323
- useUploader as ak,
12324
- UploaderTrigger as al,
12325
- UploaderProvider as am,
12326
- composeImageUrl as an,
12327
- usePointUpContext as ao,
12328
- PointUpProvider as ap,
12329
- ButtonGroup as aq,
12330
- SegmentedControl as ar,
12331
- create as as,
12332
- getWsClient as at,
12333
- useSubscription as au,
12250
+ useChatContext as a0,
12251
+ ChatProvider as a1,
12252
+ UnreadNotificationContext as a2,
12253
+ useUnreadNotification as a3,
12254
+ UnreadNotificationProvider as a4,
12255
+ Confirm as a5,
12256
+ ConfirmContext as a6,
12257
+ useConfirm as a7,
12258
+ ConfirmProvider as a8,
12259
+ SecureLabelPicker as a9,
12260
+ useApiErrorHandler as aa,
12261
+ useDefaultApiErrorHandler as ab,
12262
+ DefaultApiErrorHandler as ac,
12263
+ Back as ad,
12264
+ LazyEditor as ae,
12265
+ EditorPreview as af,
12266
+ DirtyPromptContainer as ag,
12267
+ ConfirmNavigation as ah,
12268
+ UploaderContext as ai,
12269
+ useUploader as aj,
12270
+ UploaderTrigger as ak,
12271
+ UploaderProvider as al,
12272
+ composeImageUrl as am,
12273
+ usePointUpContext as an,
12274
+ PointUpProvider as ao,
12275
+ ButtonGroup as ap,
12276
+ SegmentedControl as aq,
12277
+ create as ar,
12278
+ getWsClient as as,
12279
+ useSubscription as at,
12334
12280
  Input as b,
12335
12281
  useChanged as c,
12336
12282
  useSessionContext as d,
12337
- useNotification as e,
12338
- utils as f,
12283
+ utils as e,
12284
+ preferences as f,
12339
12285
  getExcerptSync as g,
12340
- preferences as h,
12286
+ typography as h,
12341
12287
  inferInitialEditorState as i,
12342
- typography as j,
12343
- themeOverrides as k,
12288
+ themeOverrides as j,
12289
+ InternalThemeProvider as k,
12344
12290
  lexical as l,
12345
- InternalThemeProvider as m,
12346
- Avatars as n,
12347
- AuthorInfo as o,
12291
+ Avatars as m,
12292
+ AuthorInfo as n,
12293
+ SystemUser as o,
12348
12294
  preloadInput as p,
12349
- SystemUser as q,
12295
+ PostContent as q,
12350
12296
  routes as r,
12351
12297
  stringify as s,
12352
12298
  translations as t,
12353
12299
  useNow as u,
12354
- PostContent as v,
12355
- PostComponent as w,
12356
- Comment as x,
12357
- CommentList as y,
12358
- CommentsContext as z
12300
+ PostComponent as v,
12301
+ Comment as w,
12302
+ CommentList as x,
12303
+ CommentsContext as y,
12304
+ useCommentsContext as z
12359
12305
  };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export * from './components/editor';
18
18
  export * as lexicalUtils from './components/lexical';
19
19
  export * from './components/dirty-prompt';
20
20
  export { translations } from './components/locale';
21
- export { useNow, useChanged, useSessionContext, useNotification } from './components/hooks';
21
+ export { useNow, useChanged, useSessionContext } from './components/hooks';
22
22
  export * as utils from './components/utils';
23
23
  export * as routes from './components/routes';
24
24
  export { default as preferences } from './preferences';
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { U, o, X, A, n, ae, B, G, L, K, N, aq, Z, Y, a0, _, $, a2, x, C, y, z, F, a6, a7, ai, a9, Q, T, ad, D, ah, ag, J, H, b, m, af, M, P, ap, w, v, R, S, aa, ar, q, a3, a5, aj, am, al, an, as, O, at, l, h, p, r, k, t, j, ab, W, c, a1, E, a8, ac, e, u, ao, d, au, a4, ak, f } from "./index-DR4mMFMg.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-Crgy_5Hh.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -9,83 +9,82 @@ import "@mui/icons-material";
9
9
  import "@arcblock/ux/lib/Locale/context";
10
10
  import "@mui/material";
11
11
  export {
12
- U as AccessControl,
13
- o as AuthorInfo,
14
- X as AuthzProvider,
12
+ T as AccessControl,
13
+ n as AuthorInfo,
14
+ W as AuthzProvider,
15
15
  A as Avatar,
16
- n as Avatars,
17
- ae as Back,
16
+ m as Avatars,
17
+ ad as Back,
18
18
  B as Badge,
19
- G as BinaryThumb,
20
- L as BlogCard,
21
- K as BlogList,
22
- N as BlogPermaLink,
23
- aq as ButtonGroup,
24
- Z as Chat,
25
- Y as ChatClient,
26
- a0 as ChatHeaderAddon,
27
- _ as ChatInWallet,
28
- $ as ChatListInWallet,
29
- a2 as ChatProvider,
30
- x as Comment,
19
+ F as BinaryThumb,
20
+ K as BlogCard,
21
+ J as BlogList,
22
+ L as BlogPermaLink,
23
+ ap as ButtonGroup,
24
+ Y as Chat,
25
+ X as ChatClient,
26
+ $ as ChatHeaderAddon,
27
+ Z as ChatInWallet,
28
+ _ as ChatListInWallet,
29
+ a1 as ChatProvider,
30
+ w as Comment,
31
31
  C as CommentInput,
32
- y as CommentList,
33
- z as CommentsContext,
34
- F as CommentsProvider,
35
- a6 as Confirm,
36
- a7 as ConfirmContext,
37
- ai as ConfirmNavigation,
38
- a9 as ConfirmProvider,
39
- Q as CoverImage,
40
- T as CoverImageUpload,
41
- ad as DefaultApiErrorHandler,
32
+ x as CommentList,
33
+ y as CommentsContext,
34
+ E as CommentsProvider,
35
+ a5 as Confirm,
36
+ a6 as ConfirmContext,
37
+ ah as ConfirmNavigation,
38
+ a8 as ConfirmProvider,
39
+ O as CoverImage,
40
+ Q as CoverImageUpload,
41
+ ac as DefaultApiErrorHandler,
42
42
  D as DefaultEditorConfigProvider,
43
- ah as DirtyPromptContainer,
44
- ag as EditorPreview,
45
- J as EmptyStatus,
46
- H as GithubReaction,
43
+ ag as DirtyPromptContainer,
44
+ af as EditorPreview,
45
+ H as EmptyStatus,
46
+ G as GithubReaction,
47
47
  b as Input,
48
- m as InternalThemeProvider,
49
- af as LazyEditor,
48
+ k as InternalThemeProvider,
49
+ ae as LazyEditor,
50
50
  M as Menu,
51
51
  P as Pagination,
52
- ap as PointUpProvider,
53
- w as Post,
54
- v as PostContent,
52
+ ao as PointUpProvider,
53
+ v as Post,
54
+ q as PostContent,
55
55
  R as RelativeTime,
56
56
  S as ScrollableEditorWrapper,
57
- aa as SecureLabelPicker,
58
- ar as SegmentedControl,
59
- q as SystemUser,
60
- a3 as UnreadNotificationContext,
61
- a5 as UnreadNotificationProvider,
62
- aj as UploaderContext,
63
- am as UploaderProvider,
64
- al as UploaderTrigger,
65
- an as composeImageUrl,
66
- as as create,
67
- O as getBlogLink,
68
- at as getWsClient,
57
+ a9 as SecureLabelPicker,
58
+ aq as SegmentedControl,
59
+ o as SystemUser,
60
+ a2 as UnreadNotificationContext,
61
+ a4 as UnreadNotificationProvider,
62
+ ai as UploaderContext,
63
+ al as UploaderProvider,
64
+ ak as UploaderTrigger,
65
+ am as composeImageUrl,
66
+ ar as create,
67
+ N as getBlogLink,
68
+ as as getWsClient,
69
69
  l as lexicalUtils,
70
- h as preferences,
70
+ f as preferences,
71
71
  p as preloadInput,
72
72
  r as routes,
73
- k as themeOverrides,
73
+ j as themeOverrides,
74
74
  t as translations,
75
- j as typography,
76
- ab as useApiErrorHandler,
77
- W as useAuthzContext,
75
+ h as typography,
76
+ aa as useApiErrorHandler,
77
+ U as useAuthzContext,
78
78
  c as useChanged,
79
- a1 as useChatContext,
80
- E as useCommentsContext,
81
- a8 as useConfirm,
82
- ac as useDefaultApiErrorHandler,
83
- e as useNotification,
79
+ a0 as useChatContext,
80
+ z as useCommentsContext,
81
+ a7 as useConfirm,
82
+ ab as useDefaultApiErrorHandler,
84
83
  u as useNow,
85
- ao as usePointUpContext,
84
+ an as usePointUpContext,
86
85
  d as useSessionContext,
87
- au as useSubscription,
88
- a4 as useUnreadNotification,
89
- ak as useUploader,
90
- f as utils
86
+ at as useSubscription,
87
+ a3 as useUnreadNotification,
88
+ aj as useUploader,
89
+ e as utils
91
90
  };
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/react-hooks"), 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("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), 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("react-dom"), require("url-join"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("ufo"), require("@blocklet/editor"), require("@mui/material/Fab"), require("lodash/debounce"), require("@blocklet/editor/lib/main/hooks/useIsFocused"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), 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", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/react-hooks", "@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", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "semver-compare", "@arcblock/bridge", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "react-dom", "url-join", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "ufo", "@blocklet/editor", "@mui/material/Fab", "lodash/debounce", "@blocklet/editor/lib/main/hooks/useIsFocused", "@mui/material/TextField", "@mui/icons-material/Add", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@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.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.reactHooks, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.cmp, global.bridge, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.ReactDOM, global.joinUrl, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.ufo, global.editor$1, global.Fab, global.debounce, global.useIsFocused, global.TextField, global.AddIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin$1, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
3
- })(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, reactHooks, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, cmp, bridge, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, ReactDOM, joinUrl, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, ufo, editor$1, Fab, debounce, useIsFocused, TextField, AddIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin$1, SafeAreaPlugin, text, ImageNode, VideoNode) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/react-hooks"), 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("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), 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("react-dom"), require("url-join"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("@blocklet/editor"), require("@mui/material/Fab"), require("lodash/debounce"), require("@blocklet/editor/lib/main/hooks/useIsFocused"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("ufo"), 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", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/react-hooks", "@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", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "semver-compare", "@arcblock/bridge", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "react-dom", "url-join", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "@blocklet/editor", "@mui/material/Fab", "lodash/debounce", "@blocklet/editor/lib/main/hooks/useIsFocused", "@mui/material/TextField", "@mui/icons-material/Add", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "ufo", "@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.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.reactHooks, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.cmp, global.bridge, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.ReactDOM, global.joinUrl, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.editor$1, global.Fab, global.debounce, global.useIsFocused, global.TextField, global.AddIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin$1, global.SafeAreaPlugin, global.text, global.ufo, global.ImageNode, global.VideoNode));
3
+ })(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, reactHooks, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, cmp, bridge, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, ReactDOM, joinUrl, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, TextField, AddIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin$1, SafeAreaPlugin, text, ufo, ImageNode, VideoNode) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -1052,23 +1052,6 @@ var __publicField = (obj, key, value) => {
1052
1052
  const r = useResponsive();
1053
1053
  return r(values2);
1054
1054
  };
1055
- const useNotification = () => {
1056
- const show = async ({ title, options, onclick }) => {
1057
- if (!("Notification" in window))
1058
- return;
1059
- if (Notification.permission === "granted") {
1060
- const notification = new Notification(title, options);
1061
- notification.onclick = onclick ?? null;
1062
- return;
1063
- }
1064
- if (Notification.permission !== "denied") {
1065
- const permission = await Notification.requestPermission();
1066
- if (permission === "granted")
1067
- show({ title, options, onclick });
1068
- }
1069
- };
1070
- return { show };
1071
- };
1072
1055
  function ProfileCard({ user, click, ...rest }) {
1073
1056
  var _a2, _b2, _c2;
1074
1057
  const { session } = useSessionContext();
@@ -3671,9 +3654,6 @@ var __publicField = (obj, key, value) => {
3671
3654
  activeChatId: void 0,
3672
3655
  error: void 0
3673
3656
  });
3674
- const chatById = react.useMemo(() => {
3675
- return state.chats.reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {});
3676
- }, [state.chats]);
3677
3657
  const { markAsUnread } = useUnreadNotification();
3678
3658
  const navigate = reactRouterDom.useNavigate();
3679
3659
  const { session } = useSessionContext();
@@ -3885,42 +3865,9 @@ var __publicField = (obj, key, value) => {
3885
3865
  setState((prev) => ({ ...prev, activeChatId: void 0 }));
3886
3866
  }
3887
3867
  }, [state, activeChatId]);
3888
- const { t } = context.useLocaleContext();
3889
- const { show } = useNotification();
3890
- const resolveChatNotification = (chatId, { id: id2, content, sender, type, link, sourceUser, comment, reply, post }) => {
3891
- if (isInWallet || sender.did === currentUser.did)
3892
- return;
3893
- const chat = chatById[chatId];
3894
- if (!chat)
3895
- return;
3896
- const isSystem = chat.type === "notification";
3897
- const isChannel = chat.type === "channel";
3898
- const getNotificationMeta = () => {
3899
- const getOpener = (url) => () => window.open(url, "_blank");
3900
- const getTitle = (i18nKey) => `${sourceUser == null ? void 0 : sourceUser.fullName} ${t(`chat.${i18nKey}`)}`;
3901
- const onclick2 = getOpener(link);
3902
- const map = {
3903
- message: {
3904
- title: `${t("chat.newMsg")} ${isChannel ? chat.name : sender.fullName}`,
3905
- body: getExcerptFromLexicalContent(content),
3906
- onclick: getOpener(ufo.joinURL(discussKitMountPoint ?? "", "/chat", chatId))
3907
- },
3908
- comment: { title: getTitle("commentedYourPost"), body: comment == null ? void 0 : comment.excerpt, onclick: onclick2 },
3909
- reply: { title: getTitle("replyYourComment"), body: reply == null ? void 0 : reply.excerpt, onclick: onclick2 },
3910
- mentionInComment: { title: getTitle("mentionInComment"), body: comment == null ? void 0 : comment.excerpt, onclick: onclick2 },
3911
- mentionInPost: { title: getTitle("mentionInPost"), body: post == null ? void 0 : post.excerpt, onclick: onclick2 }
3912
- };
3913
- return map[type];
3914
- };
3915
- const icon = isSystem ? sourceUser == null ? void 0 : sourceUser.avatar : sender.avatar;
3916
- const { title, body, onclick } = getNotificationMeta();
3917
- if (title)
3918
- show({ title, onclick, options: { tag: id2, icon, body } });
3919
- };
3920
3868
  react.useEffect(() => {
3921
3869
  const cancels = [
3922
3870
  client2.onMessage(({ chatId, message }) => {
3923
- resolveChatNotification(chatId, message);
3924
3871
  addMessage(chatId, message);
3925
3872
  if (message.sender.did === (currentUser == null ? void 0 : currentUser.did)) {
3926
3873
  updateLastAckTime(chatId, true);
@@ -12306,7 +12253,6 @@ var __publicField = (obj, key, value) => {
12306
12253
  exports2.useCommentsContext = useCommentsContext;
12307
12254
  exports2.useConfirm = useConfirm;
12308
12255
  exports2.useDefaultApiErrorHandler = useDefaultApiErrorHandler;
12309
- exports2.useNotification = useNotification;
12310
12256
  exports2.useNow = useNow;
12311
12257
  exports2.usePointUpContext = usePointUpContext;
12312
12258
  exports2.useSessionContext = useSessionContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.0.70",
3
+ "version": "2.0.71",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -31,8 +31,8 @@
31
31
  "@arcblock/bridge": "^2.10.6",
32
32
  "@arcblock/react-hooks": "^2.10.6",
33
33
  "@arcblock/ws": "^1.18.126",
34
- "@blocklet/editor": "2.0.70",
35
- "@blocklet/labels": "2.0.70",
34
+ "@blocklet/editor": "2.0.71",
35
+ "@blocklet/labels": "2.0.71",
36
36
  "@blocklet/uploader": "^0.1.19",
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": "33b4b65368af257ac54c965ae8658093bb801531"
103
+ "gitHead": "4d10bc0c2b3a9ff3f449c2f0c6d540611c490b85"
104
104
  }
@@ -1,9 +0,0 @@
1
- interface UseNotificationProps {
2
- title: string;
3
- options?: NotificationOptions;
4
- onclick?: () => void;
5
- }
6
- export declare const useNotification: () => {
7
- show: ({ title, options, onclick }: UseNotificationProps) => Promise<void>;
8
- };
9
- export {};