@blocklet/discuss-kit-ux 2.4.36 → 2.4.38

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.
Files changed (222) hide show
  1. package/dist/axios.d.ts +8 -0
  2. package/dist/blocklets.d.ts +1 -1
  3. package/dist/blocklets.mjs +17 -0
  4. package/dist/components/api-error-handler/api-error-handler.d.ts +1 -1
  5. package/dist/components/api-error-handler/api-error-handler.mjs +25 -0
  6. package/dist/components/api-error-handler/default-handler.mjs +69 -0
  7. package/dist/components/api-error-handler/index.mjs +2 -0
  8. package/dist/components/api-error-handler/json-validation-interceptor.d.ts +1 -1
  9. package/dist/components/api-error-handler/json-validation-interceptor.mjs +9 -0
  10. package/dist/components/arcsphere/index.mjs +51 -0
  11. package/dist/components/authz/access-control.d.ts +15 -1
  12. package/dist/components/authz/access-control.mjs +15 -0
  13. package/dist/components/authz/context.d.ts +2 -1
  14. package/dist/components/authz/context.mjs +30 -0
  15. package/dist/components/authz/index.d.ts +1 -1
  16. package/dist/components/authz/index.mjs +2 -0
  17. package/dist/components/auto-translate/api.d.ts +1 -1
  18. package/dist/components/auto-translate/api.mjs +23 -0
  19. package/dist/components/auto-translate/auto-translate-button.d.ts +2 -1
  20. package/dist/components/auto-translate/auto-translate-button.mjs +47 -0
  21. package/dist/components/auto-translate/editor-store-adaptor.mjs +14 -0
  22. package/dist/components/auto-translate/index.mjs +6 -0
  23. package/dist/components/auto-translate/languages.mjs +61 -0
  24. package/dist/components/auto-translate/post-auto-translate-plugin.d.ts +4 -3
  25. package/dist/components/auto-translate/post-auto-translate-plugin.mjs +32 -0
  26. package/dist/components/auto-translate/store.d.ts +3 -3
  27. package/dist/components/auto-translate/store.mjs +23 -0
  28. package/dist/components/auto-translate/translate.d.ts +3 -2
  29. package/dist/components/auto-translate/translate.mjs +103 -0
  30. package/dist/components/auto-translate/utils.d.ts +1 -1
  31. package/dist/components/auto-translate/utils.mjs +14 -0
  32. package/dist/components/auto-translate/with-availibility-check.d.ts +1 -1
  33. package/dist/components/auto-translate/with-availibility-check.mjs +10 -0
  34. package/dist/components/avatars/author-info.d.ts +3 -2
  35. package/dist/components/avatars/author-info.mjs +184 -0
  36. package/dist/components/avatars/avatar.d.ts +2 -1
  37. package/dist/components/avatars/avatar.mjs +9 -0
  38. package/dist/components/avatars/avatars.d.ts +4 -3
  39. package/dist/components/avatars/avatars.mjs +49 -0
  40. package/dist/components/avatars/badge.d.ts +2 -1
  41. package/dist/components/avatars/badge.mjs +178 -0
  42. package/dist/components/avatars/index.mjs +5 -0
  43. package/dist/components/avatars/system-user.d.ts +1 -1
  44. package/dist/components/avatars/system-user.mjs +58 -0
  45. package/dist/components/back.d.ts +2 -1
  46. package/dist/components/back.mjs +28 -0
  47. package/dist/components/blog/blog-link.mjs +16 -0
  48. package/dist/components/blog/blog-list.d.ts +4 -3
  49. package/dist/components/blog/blog-list.mjs +441 -0
  50. package/dist/components/blog/cover-image.d.ts +4 -3
  51. package/dist/components/blog/cover-image.mjs +160 -0
  52. package/dist/components/blog/index.mjs +4 -0
  53. package/dist/components/blog/permalink.d.ts +3 -2
  54. package/dist/components/blog/permalink.mjs +78 -0
  55. package/dist/components/blog/types.d.ts +1 -1
  56. package/dist/components/blog/types.mjs +0 -0
  57. package/dist/components/button-group/button-group.d.ts +2 -1
  58. package/dist/components/button-group/button-group.mjs +195 -0
  59. package/dist/components/button-group/index.mjs +1 -0
  60. package/dist/components/chat/channel-group.d.ts +3 -2
  61. package/dist/components/chat/channel-group.mjs +41 -0
  62. package/dist/components/chat/chat-client.d.ts +2 -2
  63. package/dist/components/chat/chat-client.mjs +33 -0
  64. package/dist/components/chat/chat-header-addon.d.ts +2 -1
  65. package/dist/components/chat/chat-header-addon.mjs +26 -0
  66. package/dist/components/chat/chat-in-wallet.d.ts +2 -1
  67. package/dist/components/chat/chat-in-wallet.mjs +67 -0
  68. package/dist/components/chat/chat-input.d.ts +3 -2
  69. package/dist/components/chat/chat-input.mjs +295 -0
  70. package/dist/components/chat/chat-list-in-wallet.d.ts +2 -1
  71. package/dist/components/chat/chat-list-in-wallet.mjs +113 -0
  72. package/dist/components/chat/chat-list.d.ts +2 -1
  73. package/dist/components/chat/chat-list.mjs +109 -0
  74. package/dist/components/chat/chat-room.d.ts +3 -2
  75. package/dist/components/chat/chat-room.mjs +225 -0
  76. package/dist/components/chat/chat.d.ts +2 -1
  77. package/dist/components/chat/chat.mjs +163 -0
  78. package/dist/components/chat/context.d.ts +4 -3
  79. package/dist/components/chat/context.mjs +303 -0
  80. package/dist/components/chat/hooks.d.ts +1 -1
  81. package/dist/components/chat/hooks.mjs +59 -0
  82. package/dist/components/chat/index.mjs +7 -0
  83. package/dist/components/chat/message-list.d.ts +3 -2
  84. package/dist/components/chat/message-list.mjs +151 -0
  85. package/dist/components/chat/message.d.ts +4 -3
  86. package/dist/components/chat/message.mjs +312 -0
  87. package/dist/components/chat/participants.d.ts +3 -2
  88. package/dist/components/chat/participants.mjs +60 -0
  89. package/dist/components/chat/time.d.ts +1 -1
  90. package/dist/components/chat/time.mjs +16 -0
  91. package/dist/components/chat/types.d.ts +1 -1
  92. package/dist/components/chat/types.mjs +0 -0
  93. package/dist/components/chat/unread-notification.d.ts +2 -2
  94. package/dist/components/chat/unread-notification.mjs +43 -0
  95. package/dist/components/chat/user-search.d.ts +2 -1
  96. package/dist/components/chat/user-search.mjs +143 -0
  97. package/dist/components/check-mark.d.ts +2 -1
  98. package/dist/components/check-mark.mjs +98 -0
  99. package/dist/components/confirm.d.ts +4 -4
  100. package/dist/components/confirm.mjs +103 -0
  101. package/dist/components/dayjs.d.ts +1 -1
  102. package/dist/components/dayjs.mjs +4 -0
  103. package/dist/components/default-editor-config-provider.d.ts +3 -2
  104. package/dist/components/default-editor-config-provider.mjs +107 -0
  105. package/dist/components/dirty-prompt.d.ts +3 -2
  106. package/dist/components/dirty-prompt.mjs +117 -0
  107. package/dist/components/editor/editor.d.ts +4 -3
  108. package/dist/{editor-BsHdgrDc.mjs → components/editor/editor.mjs} +7 -8
  109. package/dist/components/editor/index.mjs +2 -0
  110. package/dist/components/editor/lazy-editor.d.ts +3 -2
  111. package/dist/components/editor/lazy-editor.mjs +14 -0
  112. package/dist/components/editor/plugins/video-path-fixer-plugin.mjs +29 -0
  113. package/dist/components/editor/preview.d.ts +4 -3
  114. package/dist/components/editor/preview.mjs +32 -0
  115. package/dist/components/emoji-icon.d.ts +2 -1
  116. package/dist/components/emoji-icon.mjs +62 -0
  117. package/dist/components/empty-status/empty-status.d.ts +2 -1
  118. package/dist/components/empty-status/empty-status.mjs +24 -0
  119. package/dist/components/empty-status/index.mjs +1 -0
  120. package/dist/components/hooks/changed.mjs +34 -0
  121. package/dist/components/hooks/index.mjs +6 -0
  122. package/dist/components/hooks/interval.mjs +16 -0
  123. package/dist/components/hooks/locale-context.mjs +12 -0
  124. package/dist/components/hooks/measure.mjs +8 -0
  125. package/dist/components/hooks/now.mjs +10 -0
  126. package/dist/components/hooks/responsive.d.ts +1 -1
  127. package/dist/components/hooks/responsive.mjs +25 -0
  128. package/dist/components/hooks/session.d.ts +1 -0
  129. package/dist/components/hooks/session.mjs +41 -0
  130. package/dist/components/hooks/use-event-callback.mjs +14 -0
  131. package/dist/components/icon-button.d.ts +4 -3
  132. package/dist/components/icon-button.mjs +37 -0
  133. package/dist/components/input/auto-clear-plugin.mjs +26 -0
  134. package/dist/components/input/comment-input.d.ts +2 -1
  135. package/dist/components/input/comment-input.mjs +107 -0
  136. package/dist/components/input/image-path-fixer-plugin.mjs +29 -0
  137. package/dist/components/input/index.mjs +4 -0
  138. package/dist/components/input/input.d.ts +4 -4
  139. package/dist/components/input/input.mjs +152 -0
  140. package/dist/components/input/post-edit.d.ts +2 -1
  141. package/dist/components/input/post-edit.mjs +49 -0
  142. package/dist/components/input/scrollable-editor-wrapper.d.ts +2 -1
  143. package/dist/components/input/scrollable-editor-wrapper.mjs +18 -0
  144. package/dist/components/input/shortcut-plugin.mjs +28 -0
  145. package/dist/components/label-picker.d.ts +2 -1
  146. package/dist/components/label-picker.mjs +41 -0
  147. package/dist/components/lexical.mjs +69 -0
  148. package/dist/components/locale/en.mjs +92 -0
  149. package/dist/components/locale/index.mjs +3 -0
  150. package/dist/components/locale/zh.mjs +94 -0
  151. package/dist/components/pagination.d.ts +3 -2
  152. package/dist/components/pagination.mjs +44 -0
  153. package/dist/components/paywall.d.ts +2 -2
  154. package/dist/components/paywall.mjs +110 -0
  155. package/dist/components/point-up/{box-animation.json.d.ts → box-animation.json} +1 -4
  156. package/dist/components/point-up/index.d.ts +3 -2
  157. package/dist/components/point-up/index.mjs +153 -0
  158. package/dist/components/point-up/lottie-component.d.ts +2 -1
  159. package/dist/components/point-up/lottie-component.mjs +7 -0
  160. package/dist/components/posts/comment-list/comment-list.d.ts +2 -1
  161. package/dist/components/posts/comment-list/comment-list.mjs +163 -0
  162. package/dist/components/posts/comment-list/context.d.ts +4 -4
  163. package/dist/components/posts/comment-list/context.mjs +318 -0
  164. package/dist/components/posts/comment.d.ts +3 -2
  165. package/dist/components/posts/comment.mjs +184 -0
  166. package/dist/components/posts/index.mjs +6 -0
  167. package/dist/components/posts/menu.d.ts +3 -2
  168. package/dist/components/posts/menu.mjs +83 -0
  169. package/dist/components/posts/post-content.d.ts +2 -1
  170. package/dist/components/posts/post-content.mjs +86 -0
  171. package/dist/components/posts/post.d.ts +4 -4
  172. package/dist/components/posts/post.mjs +198 -0
  173. package/dist/components/profile-card/index.mjs +1 -0
  174. package/dist/components/profile-card/profile-card.d.ts +4 -3
  175. package/dist/components/profile-card/profile-card.mjs +162 -0
  176. package/dist/components/rating/binary-thumb.d.ts +4 -3
  177. package/dist/components/rating/binary-thumb.mjs +157 -0
  178. package/dist/components/rating/github-reaction-container.d.ts +2 -1
  179. package/dist/components/rating/github-reaction-container.mjs +46 -0
  180. package/dist/components/rating/github-reaction.d.ts +3 -2
  181. package/dist/components/rating/github-reaction.mjs +173 -0
  182. package/dist/components/rating/index.mjs +3 -0
  183. package/dist/components/rating/rater-list.d.ts +3 -2
  184. package/dist/components/rating/rater-list.mjs +33 -0
  185. package/dist/components/rating/rating.d.ts +1 -1
  186. package/dist/components/rating/rating.mjs +50 -0
  187. package/dist/components/routes.d.ts +1 -1
  188. package/dist/components/routes.mjs +27 -0
  189. package/dist/components/segmented-control.d.ts +3 -2
  190. package/dist/components/segmented-control.mjs +55 -0
  191. package/dist/components/shared/relative-time.d.ts +2 -1
  192. package/dist/components/shared/relative-time.mjs +21 -0
  193. package/dist/components/toast.d.ts +1 -1
  194. package/dist/components/toast.mjs +44 -0
  195. package/dist/components/uploader/index.d.ts +3 -3
  196. package/dist/components/uploader/index.mjs +70 -0
  197. package/dist/components/uploader/utils.mjs +16 -0
  198. package/dist/components/utils.d.ts +4 -4
  199. package/dist/components/utils.mjs +139 -0
  200. package/dist/components/view-more.d.ts +1 -1
  201. package/dist/components/view-more.mjs +50 -0
  202. package/dist/constants.mjs +14 -0
  203. package/dist/global.d.ts +1 -0
  204. package/dist/index.mjs +37 -0
  205. package/dist/preferences.mjs +9 -0
  206. package/dist/theme/index.d.ts +3 -3
  207. package/dist/theme/index.mjs +96 -0
  208. package/dist/theme/typography.d.ts +1 -1
  209. package/dist/theme/typography.mjs +66 -0
  210. package/dist/type-override.d.ts +7 -0
  211. package/dist/types.mjs +0 -0
  212. package/dist/vite-env.d.ts +1 -0
  213. package/dist/ws.d.ts +2 -2
  214. package/dist/ws.mjs +39 -0
  215. package/package.json +14 -21
  216. package/dist/components/avatars/Avatars.stories.d.ts +0 -5
  217. package/dist/components/posts/Post.stories.d.ts +0 -7
  218. package/dist/index-BZDpbkvV.mjs +0 -7631
  219. package/dist/index.es.js +0 -118
  220. package/dist/index.umd.js +0 -7589
  221. package/dist/test/fixtures/index.d.ts +0 -4
  222. package/dist/test/fixtures/mock-session.d.ts +0 -3
@@ -0,0 +1,152 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { createElement } from "react";
3
+ import { useState, useRef } from "react";
4
+ import { Box } from "@mui/material";
5
+ import isNil from "lodash/isNil";
6
+ import { EditorConfigProvider, useEditorConfig } from "@blocklet/editor/lib/config";
7
+ import { lazyWithPreload } from "react-lazy-with-preload";
8
+ import { isEmptyContent, inferInitialEditorState } from "../lexical.mjs";
9
+ import ShortcutPlugin from "./shortcut-plugin.mjs";
10
+ import ImagePathFixerPlugin from "./image-path-fixer-plugin.mjs";
11
+ import { VideoPathFixerPlugin } from "../editor/plugins/video-path-fixer-plugin.mjs";
12
+ import AutoClearPlugin from "./auto-clear-plugin.mjs";
13
+ import useMeasure from "../hooks/measure.mjs";
14
+ import { mergeSx } from "../utils.mjs";
15
+ import { MAX_COMMENT_LENGTH } from "../../constants.mjs";
16
+ const BlockletEditor = lazyWithPreload(() => import("@blocklet/editor"));
17
+ export const preloadInput = () => BlockletEditor.preload();
18
+ const Input = ({
19
+ initialContent = "",
20
+ send,
21
+ placeholder,
22
+ onSuccess,
23
+ onChange,
24
+ autoFocus,
25
+ draftKey = "",
26
+ shortcut,
27
+ children,
28
+ renderInnerFooter,
29
+ renderEditorFooter,
30
+ editorRef,
31
+ disableCmdEnter = false,
32
+ ...rest
33
+ }) => {
34
+ const sessionKey = draftKey || "";
35
+ const [content, setContent] = useState(null);
36
+ const [error, setError] = useState("");
37
+ const [loading, setLoading] = useState(false);
38
+ const [ref, { width }] = useMeasure();
39
+ const isChanged = useRef(false);
40
+ const editorConfig = useEditorConfig();
41
+ const inSmallView = width < 700;
42
+ const draftContent = sessionStorage.getItem(sessionKey);
43
+ const setDraftContent = (data) => {
44
+ if (data) {
45
+ try {
46
+ sessionStorage.setItem(sessionKey, JSON.stringify(data));
47
+ } catch (err) {
48
+ console.log(err);
49
+ }
50
+ } else {
51
+ sessionStorage.removeItem(sessionKey);
52
+ sessionStorage.removeItem(`${sessionKey}:title`);
53
+ }
54
+ };
55
+ const handleChange = async (state, editor) => {
56
+ const isEmpty = await isEmptyContent(state, editor);
57
+ if (isEmpty) {
58
+ setContent(null);
59
+ onChange?.(null);
60
+ } else {
61
+ setContent(state);
62
+ onChange?.(state);
63
+ }
64
+ if (draftKey) {
65
+ setDraftContent(state);
66
+ }
67
+ setError("");
68
+ };
69
+ const submit = async () => {
70
+ if (!send) {
71
+ return;
72
+ }
73
+ setLoading(true);
74
+ setError("");
75
+ const originContent = content;
76
+ try {
77
+ isChanged.current = true;
78
+ const result = await send(isNil(content) ? "" : JSON.stringify(content));
79
+ setContent(null);
80
+ if (draftKey) {
81
+ setDraftContent(null);
82
+ }
83
+ onSuccess?.(result);
84
+ } catch (e) {
85
+ setContent(originContent);
86
+ setError(e?.status === 429 ? e.response?.data || e.message : e.message);
87
+ console.error(e);
88
+ } finally {
89
+ setLoading(false);
90
+ setTimeout(() => {
91
+ isChanged.current = false;
92
+ }, 300);
93
+ }
94
+ };
95
+ const handleCmdEnterPressed = () => {
96
+ if (content && !loading) {
97
+ submit();
98
+ }
99
+ };
100
+ const mergedEditorConfig = {
101
+ ...editorConfig,
102
+ ...inSmallView && {
103
+ toolbar: {
104
+ items: ["component", "block", "italic", "bold", "underline", "media", ...editorConfig?.toolbar?.items || []]
105
+ }
106
+ },
107
+ characterLimitConfig: {
108
+ maxLength: MAX_COMMENT_LENGTH,
109
+ indicatorStyle: {
110
+ position: "absolute",
111
+ bottom: 6,
112
+ left: { xs: 12, md: 32 }
113
+ },
114
+ alignLeft: false
115
+ }
116
+ };
117
+ const editorState = draftKey && draftContent && !initialContent ? draftContent : inferInitialEditorState(initialContent);
118
+ const mergedSx = mergeSx(
119
+ {
120
+ position: "relative",
121
+ ".be-shell": {
122
+ border: 1,
123
+ borderColor: "divider",
124
+ borderRadius: 1,
125
+ overflow: "hidden"
126
+ },
127
+ ".be-editable, .be-content": {
128
+ minHeight: 150
129
+ }
130
+ },
131
+ rest.sx
132
+ );
133
+ return /* @__PURE__ */ createElement(Box, { ref, ...rest, key: draftKey, sx: mergedSx }, /* @__PURE__ */ jsx(EditorConfigProvider, { value: mergedEditorConfig, children: /* @__PURE__ */ jsxs(
134
+ BlockletEditor,
135
+ {
136
+ editorRef,
137
+ placeholder,
138
+ editorState,
139
+ onChange: handleChange,
140
+ autoFocus,
141
+ children: [
142
+ !disableCmdEnter && /* @__PURE__ */ jsx(ShortcutPlugin, { shortcut, callback: handleCmdEnterPressed }),
143
+ /* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
144
+ /* @__PURE__ */ jsx(VideoPathFixerPlugin, {}),
145
+ /* @__PURE__ */ jsx(AutoClearPlugin, { value: content, isChanged: isChanged.current }),
146
+ children,
147
+ renderInnerFooter?.({ submit, content, loading, error, inSmallView })
148
+ ]
149
+ }
150
+ ) }), renderEditorFooter?.({ submit, content, loading, error, inSmallView }));
151
+ };
152
+ export default Input;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Send } from './input';
2
3
  interface Props {
3
4
  content: string;
@@ -5,5 +6,5 @@ interface Props {
5
6
  onCancel?: () => void;
6
7
  onSuccess?: () => void;
7
8
  }
8
- export default function PostEdit({ content, send, onCancel, onSuccess, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export default function PostEdit({ content, send, onCancel, onSuccess, ...rest }: Props): import("react").JSX.Element;
9
10
  export {};
@@ -0,0 +1,49 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import Box from "@mui/material/Box";
4
+ import Button from "@mui/material/Button";
5
+ import LoadingButton from "@mui/lab/LoadingButton";
6
+ import { Save as SaveIcon } from "@mui/icons-material";
7
+ import { LocaleContext } from "@arcblock/ux/lib/Locale/context";
8
+ import Input from "./input.mjs";
9
+ export default function PostEdit({ content, send, onCancel, onSuccess, ...rest }) {
10
+ const { t } = useContext(LocaleContext);
11
+ return /* @__PURE__ */ jsx(
12
+ Input,
13
+ {
14
+ initialContent: content,
15
+ send,
16
+ onSuccess,
17
+ ...rest,
18
+ renderEditorFooter: ({ submit, content: content2, loading }) => /* @__PURE__ */ jsxs(
19
+ Box,
20
+ {
21
+ sx: {
22
+ display: "flex",
23
+ justifyContent: "flex-end",
24
+ alignItems: "flex-end",
25
+ gap: 1,
26
+ mt: 1
27
+ },
28
+ children: [
29
+ /* @__PURE__ */ jsx(Button, { variant: "text", color: "primary", onClick: onCancel, children: t("cancel") }),
30
+ /* @__PURE__ */ jsx(
31
+ LoadingButton,
32
+ {
33
+ disabled: !content2,
34
+ loading,
35
+ loadingPosition: "start",
36
+ startIcon: /* @__PURE__ */ jsx(SaveIcon, {}),
37
+ variant: "contained",
38
+ color: "primary",
39
+ title: "\u2318 Enter",
40
+ onClick: submit,
41
+ children: t("saveChanges")
42
+ }
43
+ )
44
+ ]
45
+ }
46
+ )
47
+ }
48
+ );
49
+ }
@@ -1,8 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import { SxProps } from '@mui/material';
2
3
  interface Props {
3
4
  safeDistance?: number;
4
5
  sx?: SxProps;
5
6
  children: React.ReactNode;
6
7
  }
7
- export default function ScrollableEditorWrapper({ safeDistance, sx, children, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export default function ScrollableEditorWrapper({ safeDistance, sx, children, ...rest }: Props): import("react").JSX.Element;
8
9
  export {};
@@ -0,0 +1,18 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { styled } from "@arcblock/ux/lib/Theme";
3
+ import Box from "@mui/material/Box";
4
+ import useMeasure from "../hooks/measure.mjs";
5
+ const Root = styled(Box)`
6
+ height: 100%;
7
+ .be-editable {
8
+ overflow-y: auto;
9
+ }
10
+ `;
11
+ export default function ScrollableEditorWrapper({ safeDistance = 0, sx, children, ...rest }) {
12
+ const [ref, { height }] = useMeasure();
13
+ const mergedSx = [...Array.isArray(sx) ? sx : [sx]];
14
+ if (height) {
15
+ mergedSx.push({ ".be-editable": { height: height - safeDistance } });
16
+ }
17
+ return /* @__PURE__ */ jsx(Root, { sx: mergedSx, ...rest, ref, children });
18
+ }
@@ -0,0 +1,28 @@
1
+ import { useEffect } from "react";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ import { KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW } from "lexical";
4
+ export default function CmdEnterShortcutPlugin({
5
+ callback,
6
+ shortcut = "CMD_ENTER"
7
+ }) {
8
+ const [editor] = useLexicalComposerContext();
9
+ useEffect(() => {
10
+ return editor.registerCommand(
11
+ KEY_ENTER_COMMAND,
12
+ (e) => {
13
+ if (shortcut === "CMD_ENTER" && (e.metaKey || e.ctrlKey)) {
14
+ callback();
15
+ return true;
16
+ }
17
+ if (shortcut === "ENTER" && !e.shiftKey) {
18
+ e.preventDefault();
19
+ callback();
20
+ return true;
21
+ }
22
+ return false;
23
+ },
24
+ COMMAND_PRIORITY_LOW
25
+ );
26
+ }, [editor, callback]);
27
+ return null;
28
+ }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Label } from '@blocklet/labels';
2
3
  interface LabelPickerProps {
3
4
  data: Label[];
@@ -6,5 +7,5 @@ interface LabelPickerProps {
6
7
  compact?: boolean;
7
8
  editable?: boolean;
8
9
  }
9
- export declare function SecureLabelPicker(props: LabelPickerProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function SecureLabelPicker(props: LabelPickerProps): import("react").JSX.Element;
10
11
  export {};
@@ -0,0 +1,41 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Link } from "react-router-dom";
3
+ import Box from "@mui/material/Box";
4
+ import { LabelPicker as InnerLabelPicker } from "@blocklet/labels";
5
+ import EditOutlineIcon from "virtual:icons/material-symbols/edit-outline";
6
+ import { AccessControl, useAuthzContext } from "./authz/index.mjs";
7
+ export function SecureLabelPicker(props) {
8
+ const { isAdmin } = useAuthzContext();
9
+ const editable = typeof props.editable === "boolean" ? props.editable : isAdmin;
10
+ const addon = editable ? (
11
+ // @ts-ignore
12
+ /* @__PURE__ */ jsx(AccessControl, { roles: ["admin", "owner"], children: /* @__PURE__ */ jsxs(
13
+ Box,
14
+ {
15
+ className: "label-box",
16
+ component: Link,
17
+ to: "/labels",
18
+ sx: {
19
+ position: "absolute",
20
+ bottom: 0,
21
+ display: "flex",
22
+ alignItems: "center",
23
+ gap: 1,
24
+ width: "100%",
25
+ height: 36,
26
+ pl: 2,
27
+ borderTop: "1px solid #eee",
28
+ fontSize: 14,
29
+ color: "grey.600",
30
+ cursor: "pointer",
31
+ textDecoration: "none"
32
+ },
33
+ children: [
34
+ /* @__PURE__ */ jsx(EditOutlineIcon, {}),
35
+ /* @__PURE__ */ jsx("span", { children: "Edit labels" })
36
+ ]
37
+ }
38
+ ) })
39
+ ) : null;
40
+ return /* @__PURE__ */ jsx(InnerLabelPicker, { ...props, editable, addon });
41
+ }
@@ -0,0 +1,69 @@
1
+ import { $createParagraphNode, $createTextNode, $getRoot } from "lexical";
2
+ import { $isRootTextContentEmpty } from "@lexical/text";
3
+ import { tryParseJSONObject } from "./utils.mjs";
4
+ export const getTextContent = (editorState) => {
5
+ return new Promise((resolve) => {
6
+ editorState.read(() => {
7
+ const root = $getRoot();
8
+ const text = root.getTextContent();
9
+ resolve(text);
10
+ });
11
+ });
12
+ };
13
+ export const isEmptyContent = (editorState, editor) => {
14
+ const data = editorState.toJSON();
15
+ if (data.root.children?.length === 1 && !data.root.children[0].children?.length) {
16
+ return true;
17
+ }
18
+ const textOnly = !data.root.children.some((p) => {
19
+ if (p.type !== "paragraph") {
20
+ return true;
21
+ }
22
+ return p.children?.some((item) => item.type !== "text");
23
+ });
24
+ if (!textOnly) {
25
+ return false;
26
+ }
27
+ return new Promise((resolve) => {
28
+ editorState.read(() => {
29
+ resolve($isRootTextContentEmpty(editor.isComposing(), true));
30
+ });
31
+ });
32
+ };
33
+ export const inferInitialEditorState = (str) => {
34
+ str = str ?? "";
35
+ if (typeof str === "string" && !tryParseJSONObject(str)) {
36
+ return () => {
37
+ const paragraph = $createParagraphNode();
38
+ const text = $createTextNode(str);
39
+ paragraph.append(text);
40
+ $getRoot().append(paragraph);
41
+ };
42
+ }
43
+ return str;
44
+ };
45
+ export const getExcerpt = (editorState) => {
46
+ if (!editorState) {
47
+ return "";
48
+ }
49
+ return new Promise((resolve) => {
50
+ editorState.read(() => {
51
+ const root = $getRoot();
52
+ const text = root.getTextContent();
53
+ resolve(text.replace(/\n/g, "").slice(0, 150));
54
+ });
55
+ });
56
+ };
57
+ export const getExcerptSync = (editorState) => {
58
+ if (!editorState) {
59
+ return "";
60
+ }
61
+ return editorState.read(() => {
62
+ const root = $getRoot();
63
+ const text = root.getTextContent();
64
+ return text.replace(/\n/g, "").slice(0, 150);
65
+ });
66
+ };
67
+ export const stringify = (editorState) => {
68
+ return editorState ? JSON.stringify(editorState) : "";
69
+ };
@@ -0,0 +1,92 @@
1
+ export default {
2
+ cancel: "Cancel",
3
+ confirm: "Confirm",
4
+ commentInputPlaceholder: "Write a comment",
5
+ copyLink: "Copy Link",
6
+ delete: "Delete",
7
+ deleted: "This comment has been deleted",
8
+ edit: "Edit",
9
+ empty: "Be the first to leave a comment.",
10
+ loadMore: "Load More",
11
+ readMore: "Read More",
12
+ saveChanges: "Save Changes",
13
+ sendComment: "Comment",
14
+ showMoreReplies: "Show more replies",
15
+ all: "All",
16
+ messages: "Messages",
17
+ deleteMessage: {
18
+ title: "Delete message",
19
+ desc: "Do you want to delete this message permanently?"
20
+ },
21
+ deleteComment: {
22
+ title: "Delete comment",
23
+ desc: "Do you want to delete this comment?"
24
+ },
25
+ profile: {
26
+ empty: "Nothing here for now"
27
+ },
28
+ unsaved: {
29
+ title: "Leave without saving",
30
+ desc: "Your changes have not been saved. If you leave now, you will lose your changes.",
31
+ leave: "Leave anyway",
32
+ stay: "Stay on this page"
33
+ },
34
+ apiError: {
35
+ 400: "Bad request: please retry the request later",
36
+ 401: "Request unauthorized: authentication is required",
37
+ 403: "Request forbidden: you may not have the necessary permissions for the requested resource",
38
+ 409: "This record has been updated by another user. Please refresh the page to access the latest version",
39
+ staleTip: "You may need to save your changes manually",
40
+ timeout: "Request timeout: please retry the request later",
41
+ error: "Oops, your request failed. Please try again"
42
+ },
43
+ chat: {
44
+ notification: "Notification",
45
+ reply: "Reply",
46
+ unknown: "Unknown",
47
+ chats: "Chats",
48
+ channel: "Channel",
49
+ description: "Description",
50
+ newChannel: "New channel",
51
+ updateChannel: "Update channel",
52
+ noChats: "No chats",
53
+ unknownChannel: "Unknown Channel",
54
+ channelDescription: "Channel Description",
55
+ channelName: "Channel Name",
56
+ deleteChannel: "Delete Channel",
57
+ commentedYourPost: "commented on your post",
58
+ commentedPost: "commented on a post",
59
+ newPost: "create a new post",
60
+ mentionInComment: "mentioned you in a comment",
61
+ mentionInPost: "mentioned you in a post",
62
+ replyYourComment: "replied to your comment",
63
+ replyComment: "replied to a comment",
64
+ newMsg: "New message from",
65
+ deleteChannelTitle: "Delete this channel?",
66
+ deleteChannelDesc: "If you delete this channel, all messages in the channel will be deleted immediately.",
67
+ leaveChannel: "Leave channel",
68
+ joinChannel: "Join channel",
69
+ openTask: "opened a post",
70
+ closeTask: "closed a post",
71
+ assignTask: "assigned you to a post",
72
+ unassignTask: "unassigned you from a post",
73
+ points: "points",
74
+ point: "point",
75
+ pointUp: "\u{1F389} You got {points} {unit} {event}",
76
+ loadMore: "Load older messages",
77
+ notYetJoinedTheChannel: "Not yet joined the channel",
78
+ typeSomething: "Type here. Use Markdown, Drag or paste images",
79
+ send: "Send",
80
+ selectBoardTip: "Only board members can join board-specific channels"
81
+ },
82
+ userActionLog: {
83
+ editedCapital: "Edited",
84
+ times: "times",
85
+ mostRecent: "most recent",
86
+ edited: "edited",
87
+ created: "created"
88
+ },
89
+ pin: "Pin",
90
+ unpin: "Unpin",
91
+ pinned: "Pinned"
92
+ };
@@ -0,0 +1,3 @@
1
+ import en from "./en.mjs";
2
+ import zh from "./zh.mjs";
3
+ export const translations = { zh, en };
@@ -0,0 +1,94 @@
1
+ export default {
2
+ cancel: "\u53D6\u6D88",
3
+ confirm: "\u786E\u8BA4",
4
+ commentInputPlaceholder: "\u5199\u8BC4\u8BBA",
5
+ copyLink: "\u590D\u5236\u94FE\u63A5",
6
+ delete: "\u5220\u9664",
7
+ deleted: "\u8BE5\u8BC4\u8BBA\u5DF2\u88AB\u5220\u9664",
8
+ edit: "\u7F16\u8F91",
9
+ empty: "\u6210\u4E3A\u7B2C\u4E00\u4E2A\u7559\u4E0B\u8BC4\u8BBA\u7684\u4EBA.",
10
+ installDIDWallet: "\u70B9\u51FB\u62E5\u6709\u4F60\u7684 DID Wallet\u2192",
11
+ loadMore: "\u52A0\u8F7D\u66F4\u591A",
12
+ readMore: "\u66F4\u591A\u5185\u5BB9",
13
+ saveChanges: "\u4FDD\u5B58\u4FEE\u6539",
14
+ sendComment: "\u8BC4\u8BBA",
15
+ showMoreReplies: "\u663E\u793A\u66F4\u591A\u56DE\u590D",
16
+ all: "\u6240\u6709",
17
+ messages: "\u6D88\u606F",
18
+ deleteMessage: {
19
+ title: "\u5220\u9664\u6D88\u606F",
20
+ desc: "\u662F\u5426\u8981\u6C38\u4E45\u5220\u9664\u6B64\u6D88\u606F\uFF1F"
21
+ },
22
+ deleteComment: {
23
+ title: "\u5220\u9664\u8BC4\u8BBA",
24
+ desc: "\u662F\u5426\u8981\u5220\u9664\u6B64\u8BC4\u8BBA\uFF1F"
25
+ },
26
+ profile: {
27
+ empty: "\u6682\u65E0\u6570\u636E"
28
+ },
29
+ unsaved: {
30
+ title: "\u4E0D\u4FDD\u5B58\u79BB\u5F00",
31
+ desc: "\u60A8\u7684\u66F4\u6539\u5C1A\u672A\u4FDD\u5B58\u3002\u5982\u679C\u60A8\u73B0\u5728\u79BB\u5F00\uFF0C\u5C06\u4F1A\u4E22\u5931\u60A8\u7684\u66F4\u6539\u3002",
32
+ leave: "\u79BB\u5F00",
33
+ stay: "\u7559\u5728\u5F53\u524D\u9875\u9762"
34
+ },
35
+ apiError: {
36
+ 400: "\u8BF7\u6C42\u9519\u8BEF: \u8BF7\u7A0D\u540E\u91CD\u8BD5",
37
+ 401: "\u8BF7\u6C42\u672A\u7ECF\u6388\u6743\uFF1A\u9700\u8981\u8EAB\u4EFD\u9A8C\u8BC1",
38
+ 403: "\u8BF7\u6C42\u88AB\u7981\u6B62\uFF1A\u60A8\u53EF\u80FD\u6CA1\u6709\u6240\u8BF7\u6C42\u8D44\u6E90\u7684\u5FC5\u8981\u6743\u9650",
39
+ 409: "\u8BE5\u8BB0\u5F55\u5DF2\u88AB\u5176\u4ED6\u7528\u6237\u66F4\u65B0\u3002\u8BF7\u5237\u65B0\u9875\u9762\u4EE5\u8BBF\u95EE\u6700\u65B0\u7248\u672C\u3002",
40
+ staleTip: "\u60A8\u53EF\u80FD\u9700\u8981\u624B\u52A8\u5907\u4EFD\u4F60\u7684\u66F4\u6539",
41
+ timeout: "\u8BF7\u6C42\u8D85\u65F6: \u8BF7\u7A0D\u540E\u91CD\u8BD5",
42
+ error: "\u54CE\u5440\uFF0C\u60A8\u7684\u8BF7\u6C42\u5931\u8D25\u4E86\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"
43
+ },
44
+ chat: {
45
+ notification: "\u901A\u77E5",
46
+ reply: "\u56DE\u590D",
47
+ unknown: "\u672A\u547D\u540D",
48
+ chats: "\u804A\u5929",
49
+ create: "\u521B\u5EFA",
50
+ channel: "\u9891\u9053",
51
+ description: "\u63CF\u8FF0",
52
+ newChannel: "\u65B0\u7684\u9891\u9053",
53
+ updateChannel: "\u66F4\u65B0\u9891\u9053",
54
+ noChats: "\u6682\u65E0\u5BF9\u8BDD",
55
+ unknownChannel: "\u672A\u547D\u540D\u7684\u9891\u9053",
56
+ channelDescription: "\u9891\u9053\u63CF\u8FF0",
57
+ channelName: "\u9891\u9053\u540D\u79F0",
58
+ deleteChannel: "\u5220\u9664\u9891\u9053",
59
+ commentedYourPost: "\u8BC4\u8BBA\u4E86\u4F60\u7684\u5E16\u5B50",
60
+ commentedPost: "\u8BC4\u8BBA\u4E86\u5E16\u5B50",
61
+ newPost: "\u521B\u5EFA\u4E86\u4E00\u4E2A\u65B0\u7684\u5E16\u5B50:",
62
+ mentionInComment: "\u5728\u8BC4\u8BBA\u91CC\u63D0\u53CA\u4E86\u4F60",
63
+ mentionInPost: "\u5728\u5E16\u5B50\u91CC\u63D0\u53CA\u4E86\u4F60",
64
+ replyYourComment: "\u56DE\u590D\u4E86\u4F60\u7684\u8BC4\u8BBA",
65
+ replyComment: "\u56DE\u590D\u4E86\u8BC4\u8BBA",
66
+ newMsg: "\u65B0\u6D88\u606F\u6765\u81EA",
67
+ deleteChannelTitle: "\u786E\u8BA4\u5220\u9664\u8FD9\u4E2A\u9891\u9053\uFF1F",
68
+ deleteChannelDesc: "\u5982\u679C\u4F60\u8981\u5220\u9664\u8FD9\u4E2A\u9891\u9053, \u9891\u9053\u5185\u6240\u6709\u7684\u6D88\u606F\u90FD\u4F1A\u7ACB\u523B\u6D88\u9664\u3002",
69
+ leaveChannel: "\u79BB\u5F00\u9891\u9053",
70
+ joinChannel: "\u52A0\u5165\u9891\u9053",
71
+ openTask: "\u521B\u5EFA\u4E86\u4E00\u4E2A\u4EFB\u52A1",
72
+ closeTask: "\u5173\u95ED\u4E86\u4E00\u4E2A\u4EFB\u52A1",
73
+ assignTask: "\u5206\u914D\u7ED9\u4F60\u4E00\u4E2A\u4EFB\u52A1",
74
+ unassignTask: "\u53D6\u6D88\u7ED9\u4F60\u5206\u914D\u7684\u4E00\u4E2A\u4EFB\u52A1",
75
+ points: "\u5206",
76
+ point: "\u5206",
77
+ pointUp: "\u{1F389} \u60A8\u83B7\u5F97\u4E86 {points} {unit} {event}",
78
+ loadMore: "\u52A0\u8F7D\u66F4\u591A\u6D88\u606F",
79
+ notYetJoinedTheChannel: "\u6682\u672A\u52A0\u5165\u8FD9\u4E2A\u9891\u9053",
80
+ typeSomething: "\u5728\u8FD9\u91CC\u8F93\u5165\uFF0C\u9002\u7528 MarkDown\uFF0C\u62FD\u5165\u6216\u8005\u9ECF\u8D34\u56FE\u7247",
81
+ send: "\u53D1\u9001",
82
+ selectBoardTip: "\u53EA\u6709 board \u6210\u5458\u53EF\u4EE5\u52A0\u5165 board \u4E13\u5C5E\u9891\u9053"
83
+ },
84
+ userActionLog: {
85
+ editedCapital: "\u7F16\u8F91",
86
+ times: "\u6B21",
87
+ mostRecent: "\u6700\u8FD1",
88
+ edited: "\u7F16\u8F91",
89
+ created: "\u521B\u5EFA"
90
+ },
91
+ pin: "\u7F6E\u9876",
92
+ unpin: "\u53D6\u6D88\u7F6E\u9876",
93
+ pinned: "\u7F6E\u9876"
94
+ };
@@ -1,4 +1,5 @@
1
- import { SxProps } from '@mui/material/styles';
1
+ /// <reference types="react" />
2
+ import { type SxProps } from '@mui/material/styles';
2
3
  interface PaginationProps {
3
4
  page?: number;
4
5
  size?: number;
@@ -7,5 +8,5 @@ interface PaginationProps {
7
8
  routerMode?: boolean;
8
9
  sx?: SxProps;
9
10
  }
10
- export default function Pagination({ page, size, total, onChange, routerMode, sx, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
11
+ export default function Pagination({ page, size, total, onChange, routerMode, sx, ...rest }: PaginationProps): import("react").JSX.Element | null;
11
12
  export {};
@@ -0,0 +1,44 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useSearchParams } from "react-router-dom";
3
+ import useMediaQuery from "@mui/material/useMediaQuery";
4
+ import { useTheme } from "@mui/material/styles";
5
+ import MuiPagination from "@mui/material/Pagination";
6
+ export default function Pagination({
7
+ page,
8
+ size = 20,
9
+ total,
10
+ onChange,
11
+ routerMode = true,
12
+ sx,
13
+ ...rest
14
+ }) {
15
+ const theme = useTheme();
16
+ const downMd = useMediaQuery(theme.breakpoints.down("md"));
17
+ const [searchParams, setSearchParams] = useSearchParams();
18
+ const pageCount = Math.ceil(total / size);
19
+ const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
20
+ const handleOnChange = (e, page2) => {
21
+ if (routerMode) {
22
+ searchParams.set("page", `${page2}`);
23
+ setSearchParams(searchParams);
24
+ } else {
25
+ onChange?.(page2);
26
+ }
27
+ };
28
+ if (pageCount <= 1 || !total) {
29
+ return null;
30
+ }
31
+ return /* @__PURE__ */ jsx(
32
+ MuiPagination,
33
+ {
34
+ page,
35
+ count: pageCount,
36
+ onChange: handleOnChange,
37
+ variant: "outlined",
38
+ shape: "rounded",
39
+ size: downMd ? "small" : "medium",
40
+ sx: mergedSx,
41
+ ...rest
42
+ }
43
+ );
44
+ }
@@ -14,6 +14,6 @@ interface SubscriptionPaywallProps {
14
14
  children?: React.ReactNode;
15
15
  type: PaywallType;
16
16
  }
17
- export declare function Paywall({ children, cta, ...rest }: PaywallProps): import("react/jsx-runtime").JSX.Element;
18
- export declare function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }: SubscriptionPaywallProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function Paywall({ children, cta, ...rest }: PaywallProps): import("react").JSX.Element;
18
+ export declare function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }: SubscriptionPaywallProps): import("react").JSX.Element;
19
19
  export {};