@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.
- package/dist/axios.d.ts +8 -0
- package/dist/blocklets.d.ts +1 -1
- package/dist/blocklets.mjs +17 -0
- package/dist/components/api-error-handler/api-error-handler.d.ts +1 -1
- package/dist/components/api-error-handler/api-error-handler.mjs +25 -0
- package/dist/components/api-error-handler/default-handler.mjs +69 -0
- package/dist/components/api-error-handler/index.mjs +2 -0
- package/dist/components/api-error-handler/json-validation-interceptor.d.ts +1 -1
- package/dist/components/api-error-handler/json-validation-interceptor.mjs +9 -0
- package/dist/components/arcsphere/index.mjs +51 -0
- package/dist/components/authz/access-control.d.ts +15 -1
- package/dist/components/authz/access-control.mjs +15 -0
- package/dist/components/authz/context.d.ts +2 -1
- package/dist/components/authz/context.mjs +30 -0
- package/dist/components/authz/index.d.ts +1 -1
- package/dist/components/authz/index.mjs +2 -0
- package/dist/components/auto-translate/api.d.ts +1 -1
- package/dist/components/auto-translate/api.mjs +23 -0
- package/dist/components/auto-translate/auto-translate-button.d.ts +2 -1
- package/dist/components/auto-translate/auto-translate-button.mjs +47 -0
- package/dist/components/auto-translate/editor-store-adaptor.mjs +14 -0
- package/dist/components/auto-translate/index.mjs +6 -0
- package/dist/components/auto-translate/languages.mjs +61 -0
- package/dist/components/auto-translate/post-auto-translate-plugin.d.ts +4 -3
- package/dist/components/auto-translate/post-auto-translate-plugin.mjs +32 -0
- package/dist/components/auto-translate/store.d.ts +3 -3
- package/dist/components/auto-translate/store.mjs +23 -0
- package/dist/components/auto-translate/translate.d.ts +3 -2
- package/dist/components/auto-translate/translate.mjs +103 -0
- package/dist/components/auto-translate/utils.d.ts +1 -1
- package/dist/components/auto-translate/utils.mjs +14 -0
- package/dist/components/auto-translate/with-availibility-check.d.ts +1 -1
- package/dist/components/auto-translate/with-availibility-check.mjs +10 -0
- package/dist/components/avatars/author-info.d.ts +3 -2
- package/dist/components/avatars/author-info.mjs +184 -0
- package/dist/components/avatars/avatar.d.ts +2 -1
- package/dist/components/avatars/avatar.mjs +9 -0
- package/dist/components/avatars/avatars.d.ts +4 -3
- package/dist/components/avatars/avatars.mjs +49 -0
- package/dist/components/avatars/badge.d.ts +2 -1
- package/dist/components/avatars/badge.mjs +178 -0
- package/dist/components/avatars/index.mjs +5 -0
- package/dist/components/avatars/system-user.d.ts +1 -1
- package/dist/components/avatars/system-user.mjs +58 -0
- package/dist/components/back.d.ts +2 -1
- package/dist/components/back.mjs +28 -0
- package/dist/components/blog/blog-link.mjs +16 -0
- package/dist/components/blog/blog-list.d.ts +4 -3
- package/dist/components/blog/blog-list.mjs +441 -0
- package/dist/components/blog/cover-image.d.ts +4 -3
- package/dist/components/blog/cover-image.mjs +160 -0
- package/dist/components/blog/index.mjs +4 -0
- package/dist/components/blog/permalink.d.ts +3 -2
- package/dist/components/blog/permalink.mjs +78 -0
- package/dist/components/blog/types.d.ts +1 -1
- package/dist/components/blog/types.mjs +0 -0
- package/dist/components/button-group/button-group.d.ts +2 -1
- package/dist/components/button-group/button-group.mjs +195 -0
- package/dist/components/button-group/index.mjs +1 -0
- package/dist/components/chat/channel-group.d.ts +3 -2
- package/dist/components/chat/channel-group.mjs +41 -0
- package/dist/components/chat/chat-client.d.ts +2 -2
- package/dist/components/chat/chat-client.mjs +33 -0
- package/dist/components/chat/chat-header-addon.d.ts +2 -1
- package/dist/components/chat/chat-header-addon.mjs +26 -0
- package/dist/components/chat/chat-in-wallet.d.ts +2 -1
- package/dist/components/chat/chat-in-wallet.mjs +67 -0
- package/dist/components/chat/chat-input.d.ts +3 -2
- package/dist/components/chat/chat-input.mjs +295 -0
- package/dist/components/chat/chat-list-in-wallet.d.ts +2 -1
- package/dist/components/chat/chat-list-in-wallet.mjs +113 -0
- package/dist/components/chat/chat-list.d.ts +2 -1
- package/dist/components/chat/chat-list.mjs +109 -0
- package/dist/components/chat/chat-room.d.ts +3 -2
- package/dist/components/chat/chat-room.mjs +225 -0
- package/dist/components/chat/chat.d.ts +2 -1
- package/dist/components/chat/chat.mjs +163 -0
- package/dist/components/chat/context.d.ts +4 -3
- package/dist/components/chat/context.mjs +303 -0
- package/dist/components/chat/hooks.d.ts +1 -1
- package/dist/components/chat/hooks.mjs +59 -0
- package/dist/components/chat/index.mjs +7 -0
- package/dist/components/chat/message-list.d.ts +3 -2
- package/dist/components/chat/message-list.mjs +151 -0
- package/dist/components/chat/message.d.ts +4 -3
- package/dist/components/chat/message.mjs +312 -0
- package/dist/components/chat/participants.d.ts +3 -2
- package/dist/components/chat/participants.mjs +60 -0
- package/dist/components/chat/time.d.ts +1 -1
- package/dist/components/chat/time.mjs +16 -0
- package/dist/components/chat/types.d.ts +1 -1
- package/dist/components/chat/types.mjs +0 -0
- package/dist/components/chat/unread-notification.d.ts +2 -2
- package/dist/components/chat/unread-notification.mjs +43 -0
- package/dist/components/chat/user-search.d.ts +2 -1
- package/dist/components/chat/user-search.mjs +143 -0
- package/dist/components/check-mark.d.ts +2 -1
- package/dist/components/check-mark.mjs +98 -0
- package/dist/components/confirm.d.ts +4 -4
- package/dist/components/confirm.mjs +103 -0
- package/dist/components/dayjs.d.ts +1 -1
- package/dist/components/dayjs.mjs +4 -0
- package/dist/components/default-editor-config-provider.d.ts +3 -2
- package/dist/components/default-editor-config-provider.mjs +107 -0
- package/dist/components/dirty-prompt.d.ts +3 -2
- package/dist/components/dirty-prompt.mjs +117 -0
- package/dist/components/editor/editor.d.ts +4 -3
- package/dist/{editor-BsHdgrDc.mjs → components/editor/editor.mjs} +7 -8
- package/dist/components/editor/index.mjs +2 -0
- package/dist/components/editor/lazy-editor.d.ts +3 -2
- package/dist/components/editor/lazy-editor.mjs +14 -0
- package/dist/components/editor/plugins/video-path-fixer-plugin.mjs +29 -0
- package/dist/components/editor/preview.d.ts +4 -3
- package/dist/components/editor/preview.mjs +32 -0
- package/dist/components/emoji-icon.d.ts +2 -1
- package/dist/components/emoji-icon.mjs +62 -0
- package/dist/components/empty-status/empty-status.d.ts +2 -1
- package/dist/components/empty-status/empty-status.mjs +24 -0
- package/dist/components/empty-status/index.mjs +1 -0
- package/dist/components/hooks/changed.mjs +34 -0
- package/dist/components/hooks/index.mjs +6 -0
- package/dist/components/hooks/interval.mjs +16 -0
- package/dist/components/hooks/locale-context.mjs +12 -0
- package/dist/components/hooks/measure.mjs +8 -0
- package/dist/components/hooks/now.mjs +10 -0
- package/dist/components/hooks/responsive.d.ts +1 -1
- package/dist/components/hooks/responsive.mjs +25 -0
- package/dist/components/hooks/session.d.ts +1 -0
- package/dist/components/hooks/session.mjs +41 -0
- package/dist/components/hooks/use-event-callback.mjs +14 -0
- package/dist/components/icon-button.d.ts +4 -3
- package/dist/components/icon-button.mjs +37 -0
- package/dist/components/input/auto-clear-plugin.mjs +26 -0
- package/dist/components/input/comment-input.d.ts +2 -1
- package/dist/components/input/comment-input.mjs +107 -0
- package/dist/components/input/image-path-fixer-plugin.mjs +29 -0
- package/dist/components/input/index.mjs +4 -0
- package/dist/components/input/input.d.ts +4 -4
- package/dist/components/input/input.mjs +152 -0
- package/dist/components/input/post-edit.d.ts +2 -1
- package/dist/components/input/post-edit.mjs +49 -0
- package/dist/components/input/scrollable-editor-wrapper.d.ts +2 -1
- package/dist/components/input/scrollable-editor-wrapper.mjs +18 -0
- package/dist/components/input/shortcut-plugin.mjs +28 -0
- package/dist/components/label-picker.d.ts +2 -1
- package/dist/components/label-picker.mjs +41 -0
- package/dist/components/lexical.mjs +69 -0
- package/dist/components/locale/en.mjs +92 -0
- package/dist/components/locale/index.mjs +3 -0
- package/dist/components/locale/zh.mjs +94 -0
- package/dist/components/pagination.d.ts +3 -2
- package/dist/components/pagination.mjs +44 -0
- package/dist/components/paywall.d.ts +2 -2
- package/dist/components/paywall.mjs +110 -0
- package/dist/components/point-up/{box-animation.json.d.ts → box-animation.json} +1 -4
- package/dist/components/point-up/index.d.ts +3 -2
- package/dist/components/point-up/index.mjs +153 -0
- package/dist/components/point-up/lottie-component.d.ts +2 -1
- package/dist/components/point-up/lottie-component.mjs +7 -0
- package/dist/components/posts/comment-list/comment-list.d.ts +2 -1
- package/dist/components/posts/comment-list/comment-list.mjs +163 -0
- package/dist/components/posts/comment-list/context.d.ts +4 -4
- package/dist/components/posts/comment-list/context.mjs +318 -0
- package/dist/components/posts/comment.d.ts +3 -2
- package/dist/components/posts/comment.mjs +184 -0
- package/dist/components/posts/index.mjs +6 -0
- package/dist/components/posts/menu.d.ts +3 -2
- package/dist/components/posts/menu.mjs +83 -0
- package/dist/components/posts/post-content.d.ts +2 -1
- package/dist/components/posts/post-content.mjs +86 -0
- package/dist/components/posts/post.d.ts +4 -4
- package/dist/components/posts/post.mjs +198 -0
- package/dist/components/profile-card/index.mjs +1 -0
- package/dist/components/profile-card/profile-card.d.ts +4 -3
- package/dist/components/profile-card/profile-card.mjs +162 -0
- package/dist/components/rating/binary-thumb.d.ts +4 -3
- package/dist/components/rating/binary-thumb.mjs +157 -0
- package/dist/components/rating/github-reaction-container.d.ts +2 -1
- package/dist/components/rating/github-reaction-container.mjs +46 -0
- package/dist/components/rating/github-reaction.d.ts +3 -2
- package/dist/components/rating/github-reaction.mjs +173 -0
- package/dist/components/rating/index.mjs +3 -0
- package/dist/components/rating/rater-list.d.ts +3 -2
- package/dist/components/rating/rater-list.mjs +33 -0
- package/dist/components/rating/rating.d.ts +1 -1
- package/dist/components/rating/rating.mjs +50 -0
- package/dist/components/routes.d.ts +1 -1
- package/dist/components/routes.mjs +27 -0
- package/dist/components/segmented-control.d.ts +3 -2
- package/dist/components/segmented-control.mjs +55 -0
- package/dist/components/shared/relative-time.d.ts +2 -1
- package/dist/components/shared/relative-time.mjs +21 -0
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toast.mjs +44 -0
- package/dist/components/uploader/index.d.ts +3 -3
- package/dist/components/uploader/index.mjs +70 -0
- package/dist/components/uploader/utils.mjs +16 -0
- package/dist/components/utils.d.ts +4 -4
- package/dist/components/utils.mjs +139 -0
- package/dist/components/view-more.d.ts +1 -1
- package/dist/components/view-more.mjs +50 -0
- package/dist/constants.mjs +14 -0
- package/dist/global.d.ts +1 -0
- package/dist/index.mjs +37 -0
- package/dist/preferences.mjs +9 -0
- package/dist/theme/index.d.ts +3 -3
- package/dist/theme/index.mjs +96 -0
- package/dist/theme/typography.d.ts +1 -1
- package/dist/theme/typography.mjs +66 -0
- package/dist/type-override.d.ts +7 -0
- package/dist/types.mjs +0 -0
- package/dist/vite-env.d.ts +1 -0
- package/dist/ws.d.ts +2 -2
- package/dist/ws.mjs +39 -0
- package/package.json +14 -21
- package/dist/components/avatars/Avatars.stories.d.ts +0 -5
- package/dist/components/posts/Post.stories.d.ts +0 -7
- package/dist/index-BZDpbkvV.mjs +0 -7631
- package/dist/index.es.js +0 -118
- package/dist/index.umd.js +0 -7589
- package/dist/test/fixtures/index.d.ts +0 -4
- package/dist/test/fixtures/mock-session.d.ts +0 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { joinURL, withQuery, withTrailingSlash } from "ufo";
|
|
2
|
+
export const repairBase64Avatar = (avatar) => {
|
|
3
|
+
if (avatar && avatar.startsWith("data:")) {
|
|
4
|
+
return avatar.replace(/\s/g, encodeURIComponent(" "));
|
|
5
|
+
}
|
|
6
|
+
return avatar;
|
|
7
|
+
};
|
|
8
|
+
export const getResizedAvatar = (avatar, size = 72) => {
|
|
9
|
+
if (!avatar) {
|
|
10
|
+
return avatar;
|
|
11
|
+
}
|
|
12
|
+
if (avatar.indexOf("/.well-known/service") >= 0) {
|
|
13
|
+
const tmp = new URL(avatar, window.location.origin);
|
|
14
|
+
tmp.searchParams.set("imageFilter", "resize");
|
|
15
|
+
tmp.searchParams.set("w", size.toString());
|
|
16
|
+
tmp.searchParams.set("h", size.toString());
|
|
17
|
+
tmp.searchParams.set("f", "webp");
|
|
18
|
+
return tmp.href;
|
|
19
|
+
}
|
|
20
|
+
return avatar;
|
|
21
|
+
};
|
|
22
|
+
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
|
+
export const minDelay = (promise, ms) => {
|
|
24
|
+
return Promise.all([promise, sleep(ms)]).then(([result]) => result);
|
|
25
|
+
};
|
|
26
|
+
export const protectLogin = (session, action) => {
|
|
27
|
+
if (session?.user) {
|
|
28
|
+
return action();
|
|
29
|
+
}
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
session.login(() => resolve(action()));
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const copyWithExecCommand = (text) => {
|
|
35
|
+
const tmp = document.createElement("TEXTAREA");
|
|
36
|
+
const active = document.activeElement;
|
|
37
|
+
tmp.style.position = "fixed";
|
|
38
|
+
tmp.style.opacity = "0";
|
|
39
|
+
tmp.style.left = "-9999px";
|
|
40
|
+
tmp.style.top = "0";
|
|
41
|
+
tmp.value = text;
|
|
42
|
+
document.body.appendChild(tmp);
|
|
43
|
+
tmp.select();
|
|
44
|
+
document.execCommand("copy");
|
|
45
|
+
document.body.removeChild(tmp);
|
|
46
|
+
active?.focus();
|
|
47
|
+
};
|
|
48
|
+
export const copy = (text) => {
|
|
49
|
+
if (navigator?.clipboard) {
|
|
50
|
+
try {
|
|
51
|
+
navigator.clipboard.writeText(text).catch(() => {
|
|
52
|
+
copyWithExecCommand(text);
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
copyWithExecCommand(text);
|
|
59
|
+
};
|
|
60
|
+
export const getLastItem = (arr) => arr?.length ? arr[arr.length - 1] : null;
|
|
61
|
+
export function tryParseJSONObject(str) {
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(str);
|
|
64
|
+
if (parsed && typeof parsed === "object") {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
export const getPreference = (key) => window.blocklet?.preferences?.[key];
|
|
73
|
+
export const getBlockletMountPointInfo = (name) => {
|
|
74
|
+
return window.blocklet?.componentMountPoints?.find((x) => x.name === name);
|
|
75
|
+
};
|
|
76
|
+
export const blockletExists = (name) => {
|
|
77
|
+
const info = getBlockletMountPointInfo(name);
|
|
78
|
+
return info?.status === "running";
|
|
79
|
+
};
|
|
80
|
+
function lexicalRootToText(data) {
|
|
81
|
+
let parsedRoot = data;
|
|
82
|
+
if (typeof data === "string") {
|
|
83
|
+
try {
|
|
84
|
+
parsedRoot = JSON.parse(data).root;
|
|
85
|
+
if (typeof parsedRoot !== "object") {
|
|
86
|
+
return data;
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
parsedRoot = {};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let text = "";
|
|
93
|
+
if (parsedRoot?.children) {
|
|
94
|
+
try {
|
|
95
|
+
parsedRoot.children.forEach((e) => {
|
|
96
|
+
if (e.text) {
|
|
97
|
+
text += e.text;
|
|
98
|
+
} else {
|
|
99
|
+
if (e.direction && text !== "") {
|
|
100
|
+
text += "\n";
|
|
101
|
+
}
|
|
102
|
+
text += lexicalRootToText(e);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.error(`lexicalRootToText ${err?.toString()}`);
|
|
107
|
+
console.error(err);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return text;
|
|
111
|
+
}
|
|
112
|
+
export const getExcerptFromLexicalContent = (content, size = 150) => {
|
|
113
|
+
const textContent = (lexicalRootToText(content) || "").trim();
|
|
114
|
+
return textContent.length > size ? `${textContent.slice(0, size)}` : textContent;
|
|
115
|
+
};
|
|
116
|
+
export const mergeSx = (initial, sx) => {
|
|
117
|
+
const mergedSx = [initial, ...Array.isArray(sx) ? sx : [sx]];
|
|
118
|
+
return mergedSx;
|
|
119
|
+
};
|
|
120
|
+
export const discussKitMountPoint = getBlockletMountPointInfo("did-comments")?.mountPoint;
|
|
121
|
+
export const discussKitApiBaseUrl = joinURL(window.location.origin, discussKitMountPoint || "", "api");
|
|
122
|
+
export const discussKitUploadsUrl = joinURL(discussKitMountPoint || "", "/uploads");
|
|
123
|
+
export const isInDiscussKitApp = discussKitMountPoint && withTrailingSlash(window.blocklet.prefix) === withTrailingSlash(discussKitMountPoint);
|
|
124
|
+
export const openProfile = (did, newTab) => {
|
|
125
|
+
if (did) {
|
|
126
|
+
window.open(withQuery(joinURL(discussKitMountPoint || "/", "profile"), { did }), newTab ? "_blank" : "_self");
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
export const randomId = () => crypto?.randomUUID?.() || Math.random().toString(36).substring(2);
|
|
130
|
+
export const getDiscussKitClientId = () => {
|
|
131
|
+
if (!window.__discuss_kit_client_id__) {
|
|
132
|
+
window.__discuss_kit_client_id__ = randomId();
|
|
133
|
+
}
|
|
134
|
+
return window.__discuss_kit_client_id__;
|
|
135
|
+
};
|
|
136
|
+
export const getPaymentKitMountPoint = () => {
|
|
137
|
+
const info = window.blocklet?.componentMountPoints?.find((x) => x.did === "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk");
|
|
138
|
+
return info?.mountPoint;
|
|
139
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import { styled } from "@arcblock/ux/lib/Theme";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import useMeasure from "./hooks/measure.mjs";
|
|
7
|
+
const MAX_HEIGHT = 200;
|
|
8
|
+
const Root = styled("div")`
|
|
9
|
+
&.markdown-viewer-collapsed .markdown-viewer-md-wrapper {
|
|
10
|
+
position: relative;
|
|
11
|
+
max-height: ${MAX_HEIGHT}px;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
|
|
14
|
+
.markdown-viewer-shadow {
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 80px;
|
|
20
|
+
background-image: ${({ theme }) => `linear-gradient(to bottom, transparent, ${theme.palette.background.paper})`};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
export function ViewMore({ children, ...rest }) {
|
|
25
|
+
const { t } = useLocaleContext();
|
|
26
|
+
const [collapsed, setCollapsed] = useState(true);
|
|
27
|
+
const [ref, { height }] = useMeasure();
|
|
28
|
+
const _collapsed = collapsed && height > MAX_HEIGHT;
|
|
29
|
+
return /* @__PURE__ */ jsxs(Root, { ...rest, className: `${rest.className || ""} ${_collapsed ? "markdown-viewer-collapsed" : ""}`, children: [
|
|
30
|
+
/* @__PURE__ */ jsxs("div", { className: "markdown-viewer-md-wrapper", children: [
|
|
31
|
+
/* @__PURE__ */ jsx("div", { ref, "data-color-mode": "light", children }),
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: "markdown-viewer-shadow" })
|
|
33
|
+
] }),
|
|
34
|
+
_collapsed && /* @__PURE__ */ jsx(
|
|
35
|
+
Box,
|
|
36
|
+
{
|
|
37
|
+
onClick: () => setCollapsed(false),
|
|
38
|
+
sx: {
|
|
39
|
+
display: "inline-block",
|
|
40
|
+
fontSize: 13,
|
|
41
|
+
fontWeight: "bold",
|
|
42
|
+
mt: 1,
|
|
43
|
+
color: "primary.light",
|
|
44
|
+
"&:hover": { color: "primary.dark", cursor: "pointer" }
|
|
45
|
+
},
|
|
46
|
+
children: t("readMore")
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
] });
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const AIGNE_RUNTIME_DID = "z2qaBP9SahqU2L2YA3ip7NecwKACMByTFuiJ2";
|
|
2
|
+
export const AIGNE_STUDIO_DID = "z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB";
|
|
3
|
+
export const DISCUSS_KIT_DID = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
|
|
4
|
+
const DEFAULT_MAX_DISCUSSION_LENGTH = 25e3;
|
|
5
|
+
const DEFAULT_MAX_COMMENT_LENGTH = 1e4;
|
|
6
|
+
const MAX_POST_LENGTH = 5e4;
|
|
7
|
+
export const MAX_DISCUSSION_LENGTH = Math.min(
|
|
8
|
+
Number(window.blocklet.DISCUSS_KIT_MAX_DISCUSSION_LENGTH || DEFAULT_MAX_DISCUSSION_LENGTH),
|
|
9
|
+
MAX_POST_LENGTH
|
|
10
|
+
);
|
|
11
|
+
export const MAX_COMMENT_LENGTH = Math.min(
|
|
12
|
+
Number(window.blocklet.DISCUSS_KIT_MAX_COMMENT_LENGTH || DEFAULT_MAX_COMMENT_LENGTH),
|
|
13
|
+
MAX_POST_LENGTH
|
|
14
|
+
);
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="../../../global.d.ts" />
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export * from "@blocklet/labels";
|
|
2
|
+
export * from "./theme/index.mjs";
|
|
3
|
+
export { Input, CommentInput, preloadInput, ScrollableEditorWrapper } from "./components/input/index.mjs";
|
|
4
|
+
export * from "./components/avatars/index.mjs";
|
|
5
|
+
export * from "./components/posts/index.mjs";
|
|
6
|
+
export * from "./components/rating/index.mjs";
|
|
7
|
+
export * from "./components/empty-status/index.mjs";
|
|
8
|
+
export * from "./components/blog/index.mjs";
|
|
9
|
+
export * from "./components/authz/index.mjs";
|
|
10
|
+
export * from "./components/chat/index.mjs";
|
|
11
|
+
export * from "./components/confirm.mjs";
|
|
12
|
+
export * from "./components/label-picker.mjs";
|
|
13
|
+
export * from "./components/api-error-handler/index.mjs";
|
|
14
|
+
export * from "./components/back.mjs";
|
|
15
|
+
export { default as DefaultEditorConfigProvider } from "./components/default-editor-config-provider.mjs";
|
|
16
|
+
export { default as Pagination } from "./components/pagination.mjs";
|
|
17
|
+
export * from "./components/editor/index.mjs";
|
|
18
|
+
export * as lexicalUtils from "./components/lexical.mjs";
|
|
19
|
+
export * from "./components/dirty-prompt.mjs";
|
|
20
|
+
export { translations } from "./components/locale/index.mjs";
|
|
21
|
+
export { useNow, useChanged, useSessionContext, useEventCallback } from "./components/hooks/index.mjs";
|
|
22
|
+
export * as utils from "./components/utils.mjs";
|
|
23
|
+
export * as routes from "./components/routes.mjs";
|
|
24
|
+
export { default as preferences } from "./preferences.mjs";
|
|
25
|
+
export * from "./components/uploader/index.mjs";
|
|
26
|
+
export * from "./components/point-up/index.mjs";
|
|
27
|
+
export * from "./components/button-group/index.mjs";
|
|
28
|
+
export * from "./components/segmented-control.mjs";
|
|
29
|
+
export * from "./ws.mjs";
|
|
30
|
+
export * from "./components/toast.mjs";
|
|
31
|
+
export * from "./components/arcsphere/index.mjs";
|
|
32
|
+
export { default as RelativeTime } from "./components/shared/relative-time.mjs";
|
|
33
|
+
export * from "./components/paywall.mjs";
|
|
34
|
+
export * from "./components/profile-card/index.mjs";
|
|
35
|
+
export * from "./components/icon-button.mjs";
|
|
36
|
+
export * from "./blocklets.mjs";
|
|
37
|
+
export * from "./components/auto-translate/index.mjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const prefs = window.blocklet.preferences;
|
|
2
|
+
const preferences = {
|
|
3
|
+
...prefs,
|
|
4
|
+
// 对 preferences 做一些格式化处理
|
|
5
|
+
maxPinLimit: parseInt(`${prefs.maxPinLimit}`, 10),
|
|
6
|
+
maxFeaturedLimit: parseInt(`${prefs.maxFeaturedLimit}`, 10),
|
|
7
|
+
assignmentAuthorizedPassports: prefs.assignmentAuthorizedPassports?.split(",").map((x) => x.trim())
|
|
8
|
+
};
|
|
9
|
+
export default preferences;
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ThemeOptions } from '@mui/material/styles';
|
|
2
|
-
import
|
|
1
|
+
import { type ThemeOptions } from '@mui/material/styles';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { typography } from './typography';
|
|
4
4
|
export { typography };
|
|
5
5
|
export declare const themeOverrides: Partial<ThemeOptions>;
|
|
6
6
|
export declare function InternalThemeProvider({ children }: {
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
-
}):
|
|
8
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider, useTheme } from "@mui/material/styles";
|
|
3
|
+
import { create } from "@arcblock/ux/lib/Theme";
|
|
4
|
+
import { typography } from "./typography.mjs";
|
|
5
|
+
export { typography };
|
|
6
|
+
export const themeOverrides = {
|
|
7
|
+
shape: {
|
|
8
|
+
borderRadius: 8
|
|
9
|
+
},
|
|
10
|
+
components: {
|
|
11
|
+
MuiInputBase: {
|
|
12
|
+
defaultProps: {
|
|
13
|
+
size: "small"
|
|
14
|
+
},
|
|
15
|
+
styleOverrides: {
|
|
16
|
+
root: ({ theme }) => ({
|
|
17
|
+
fontSize: "0.875rem",
|
|
18
|
+
// 调小输入框字体大小 (16px -> 14px)
|
|
19
|
+
backgroundColor: theme.palette.grey[50]
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
MuiButton: {
|
|
24
|
+
defaultProps: {
|
|
25
|
+
size: "small",
|
|
26
|
+
disableElevation: true
|
|
27
|
+
},
|
|
28
|
+
styleOverrides: {
|
|
29
|
+
root: {
|
|
30
|
+
fontWeight: 500,
|
|
31
|
+
textTransform: "none"
|
|
32
|
+
},
|
|
33
|
+
outlinedPrimary: ({ theme }) => ({
|
|
34
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
35
|
+
backgroundColor: theme.palette.background.default,
|
|
36
|
+
"&:hover": {
|
|
37
|
+
border: `1px solid ${theme.palette.divider}`
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
sizeSmall: {
|
|
41
|
+
height: 32
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
MuiIconButton: {
|
|
46
|
+
defaultProps: {
|
|
47
|
+
size: "small"
|
|
48
|
+
},
|
|
49
|
+
styleOverrides: {
|
|
50
|
+
root: {
|
|
51
|
+
textTransform: "none"
|
|
52
|
+
},
|
|
53
|
+
colorPrimary: ({ theme }) => ({
|
|
54
|
+
backgroundColor: theme.palette.background.default
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
MuiToggleButton: {
|
|
59
|
+
styleOverrides: {
|
|
60
|
+
root: {
|
|
61
|
+
textTransform: "none"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
MuiTab: {
|
|
66
|
+
styleOverrides: {
|
|
67
|
+
root: {
|
|
68
|
+
textTransform: "none"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
MuiTooltip: {
|
|
73
|
+
defaultProps: {
|
|
74
|
+
enterTouchDelay: 3e3,
|
|
75
|
+
leaveTouchDelay: 100
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
MuiPopover: {
|
|
79
|
+
styleOverrides: {
|
|
80
|
+
paper: ({ theme }) => ({
|
|
81
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
82
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export function InternalThemeProvider({ children }) {
|
|
89
|
+
const theme = useTheme();
|
|
90
|
+
const merged = create({
|
|
91
|
+
...theme,
|
|
92
|
+
typography: { ...theme.typography, ...typography },
|
|
93
|
+
...themeOverrides
|
|
94
|
+
});
|
|
95
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme: merged, children });
|
|
96
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypographyVariantsOptions } from '@mui/material/styles';
|
|
1
|
+
import type { TypographyVariantsOptions } from '@mui/material/styles';
|
|
2
2
|
export declare const typography: TypographyVariantsOptions;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const typography = {
|
|
2
|
+
h1: {
|
|
3
|
+
fontSize: "1.875rem",
|
|
4
|
+
lineHeight: 1.2,
|
|
5
|
+
fontWeight: 700
|
|
6
|
+
// letterSpacing: '-.025em',
|
|
7
|
+
},
|
|
8
|
+
h2: {
|
|
9
|
+
fontSize: "1.5rem",
|
|
10
|
+
lineHeight: 1.3333333,
|
|
11
|
+
fontWeight: 700
|
|
12
|
+
// letterSpacing: '-.025em',
|
|
13
|
+
},
|
|
14
|
+
h3: {
|
|
15
|
+
fontSize: "1.25rem",
|
|
16
|
+
lineHeight: 1.4,
|
|
17
|
+
fontWeight: 700
|
|
18
|
+
// letterSpacing: '-.025em',
|
|
19
|
+
},
|
|
20
|
+
h4: {
|
|
21
|
+
fontSize: "1.125rem",
|
|
22
|
+
lineHeight: 1.55,
|
|
23
|
+
fontWeight: 600
|
|
24
|
+
},
|
|
25
|
+
h5: {
|
|
26
|
+
fontSize: "1rem",
|
|
27
|
+
lineHeight: 1.5,
|
|
28
|
+
fontWeight: 700
|
|
29
|
+
},
|
|
30
|
+
h6: {
|
|
31
|
+
fontSize: "0.875rem",
|
|
32
|
+
lineHeight: 1.43,
|
|
33
|
+
fontWeight: 700
|
|
34
|
+
},
|
|
35
|
+
subtitle1: {
|
|
36
|
+
fontSize: "1rem",
|
|
37
|
+
lineHeight: 1.5,
|
|
38
|
+
fontWeight: 500
|
|
39
|
+
},
|
|
40
|
+
subtitle2: {
|
|
41
|
+
fontSize: "0.875rem",
|
|
42
|
+
lineHeight: 1.43,
|
|
43
|
+
fontWeight: 500
|
|
44
|
+
},
|
|
45
|
+
body1: {
|
|
46
|
+
fontSize: "1rem",
|
|
47
|
+
lineHeight: 1.75
|
|
48
|
+
},
|
|
49
|
+
body2: {
|
|
50
|
+
fontSize: "0.875rem",
|
|
51
|
+
lineHeight: 1.43
|
|
52
|
+
},
|
|
53
|
+
caption: {
|
|
54
|
+
fontSize: "0.75rem",
|
|
55
|
+
lineHeight: 1.33
|
|
56
|
+
},
|
|
57
|
+
overline: {
|
|
58
|
+
fontSize: "0.75rem",
|
|
59
|
+
lineHeight: 1.33,
|
|
60
|
+
fontWeight: 500
|
|
61
|
+
},
|
|
62
|
+
fontWeightLight: 300,
|
|
63
|
+
fontWeightRegular: 400,
|
|
64
|
+
fontWeightMedium: 500,
|
|
65
|
+
fontWeightBold: 700
|
|
66
|
+
};
|
package/dist/types.mjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/dist/ws.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function create(prefix: string): any;
|
|
2
|
-
export declare function getWsClient(prefix?:
|
|
3
|
-
export declare const useSubscription: (event: string, cb?: (...args: any[]) => void, deps?: any[], prefix?:
|
|
2
|
+
export declare function getWsClient(prefix?: any): any;
|
|
3
|
+
export declare const useSubscription: (event: string, cb?: (...args: any[]) => void, deps?: any[], prefix?: any) => void;
|
package/dist/ws.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import Cookie from "js-cookie";
|
|
3
|
+
import { WsClient } from "@arcblock/ws";
|
|
4
|
+
let client;
|
|
5
|
+
export function create(prefix) {
|
|
6
|
+
const pathPrefix = prefix;
|
|
7
|
+
const url = `//${window.location.host}${pathPrefix.replace(/\/$/, "")}`;
|
|
8
|
+
return new WsClient(url, {
|
|
9
|
+
heartbeatIntervalMs: 10 * 1e3,
|
|
10
|
+
reconnectAfterMs: (tries) => {
|
|
11
|
+
if (Cookie.get("login_token")) {
|
|
12
|
+
return Math.floor(Math.random() * 2 ** tries * 1e3);
|
|
13
|
+
}
|
|
14
|
+
return 2 ** tries * 1e3;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function getWsClient(prefix = window.blocklet?.prefix || "/") {
|
|
19
|
+
if (!client) {
|
|
20
|
+
client = create(prefix);
|
|
21
|
+
}
|
|
22
|
+
return client;
|
|
23
|
+
}
|
|
24
|
+
export const useSubscription = (event, cb = () => {
|
|
25
|
+
}, deps = [], prefix = window.blocklet?.prefix || "/") => {
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (event) {
|
|
28
|
+
if (!client) {
|
|
29
|
+
client = getWsClient(prefix);
|
|
30
|
+
}
|
|
31
|
+
client.on(event, cb);
|
|
32
|
+
return () => {
|
|
33
|
+
client.off(event, cb);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
};
|
|
38
|
+
}, [event, ...deps]);
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-ux",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.38",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
7
|
-
"main": "./dist/index.umd.js",
|
|
8
|
-
"module": "./dist/index.es.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
7
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
"import": "./dist/index.es.js",
|
|
13
|
-
"require": "./dist/index.umd.js"
|
|
14
|
-
},
|
|
15
|
-
"./src/*": "./src/*"
|
|
8
|
+
".": "./dist/index.mjs"
|
|
16
9
|
},
|
|
10
|
+
"main": "./dist/index.mjs",
|
|
11
|
+
"module": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"sideEffects": false,
|
|
17
14
|
"publishConfig": {
|
|
18
15
|
"access": "public"
|
|
19
16
|
},
|
|
20
17
|
"dependencies": {
|
|
21
|
-
"@arcblock/bridge": "^3.1.
|
|
22
|
-
"@arcblock/react-hooks": "^3.1.
|
|
18
|
+
"@arcblock/bridge": "^3.1.5",
|
|
19
|
+
"@arcblock/react-hooks": "^3.1.5",
|
|
23
20
|
"@arcblock/ws": "^1.21.2",
|
|
24
|
-
"@blocklet/js-sdk": "^1.16.
|
|
21
|
+
"@blocklet/js-sdk": "^1.16.48",
|
|
25
22
|
"@blocklet/uploader": "^0.2.6",
|
|
26
23
|
"@emotion/css": "^11.13.5",
|
|
27
24
|
"@emotion/react": "^11.14.0",
|
|
@@ -47,8 +44,8 @@
|
|
|
47
44
|
"unstated-next": "^1.1.0",
|
|
48
45
|
"url-join": "^4.0.1",
|
|
49
46
|
"zustand": "^4.5.5",
|
|
50
|
-
"@blocklet/editor": "2.4.
|
|
51
|
-
"@blocklet/labels": "2.4.
|
|
47
|
+
"@blocklet/editor": "2.4.38",
|
|
48
|
+
"@blocklet/labels": "2.4.38"
|
|
52
49
|
},
|
|
53
50
|
"peerDependencies": {
|
|
54
51
|
"@arcblock/did-connect-react": "^3.1.4",
|
|
@@ -65,7 +62,7 @@
|
|
|
65
62
|
"devDependencies": {
|
|
66
63
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
67
64
|
"@babel/core": "^7.25.2",
|
|
68
|
-
"@blocklet/sdk": "^1.16.
|
|
65
|
+
"@blocklet/sdk": "^1.16.48",
|
|
69
66
|
"@iconify-json/iconoir": "^1.2.1",
|
|
70
67
|
"@iconify-json/material-symbols": "^1.2.1",
|
|
71
68
|
"@iconify-json/mdi": "^1.2.0",
|
|
@@ -87,18 +84,14 @@
|
|
|
87
84
|
"react-dom": "^19.1.0",
|
|
88
85
|
"rollup-plugin-node-externals": "^7.1.3",
|
|
89
86
|
"typescript": "^4.9.5",
|
|
87
|
+
"unbuild": "^3.6.0",
|
|
90
88
|
"unplugin-icons": "^0.14.15",
|
|
91
89
|
"vite": "^7.0.0",
|
|
92
90
|
"vite-plugin-dts": "^4.5.4",
|
|
93
91
|
"vite-plugin-libcss": "^1.1.2"
|
|
94
92
|
},
|
|
95
93
|
"scripts": {
|
|
96
|
-
"
|
|
97
|
-
"build": "tsc && vite build",
|
|
98
|
-
"build:watch": "vite build --watch",
|
|
99
|
-
"preview": "vite preview",
|
|
100
|
-
"storybook": "start-storybook -p 6006",
|
|
101
|
-
"build-storybook": "build-storybook",
|
|
94
|
+
"build": "unbuild",
|
|
102
95
|
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
103
96
|
"lint:fix": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx --fix"
|
|
104
97
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
-
import { default as Post } from './post';
|
|
3
|
-
import { default as Comment } from './comment';
|
|
4
|
-
declare const _default: ComponentMeta<typeof Post>;
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Basic: ComponentStory<typeof Post>;
|
|
7
|
-
export declare const CommentStory: ComponentStory<typeof Comment>;
|