@blocklet/discuss-kit-ux 1.6.188 → 1.6.191
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/components/hooks/session.d.ts +8 -3
- package/dist/components/posts/post-content.d.ts +1 -2
- package/dist/{editor-1S0suIcX.mjs → editor-E23ceKmd.mjs} +1 -1
- package/dist/{index-q1fCyaqz.mjs → index-OmtAwPz3.mjs} +214 -130
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +59 -58
- package/dist/index.umd.js +154 -70
- package/package.json +4 -4
|
@@ -8,7 +8,7 @@ var _a, _b;
|
|
|
8
8
|
import { Labels2, LabelPicker } from "@blocklet/labels";
|
|
9
9
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { useTheme, ThemeProvider, styled } from "@mui/material/styles";
|
|
11
|
-
import { useEffect, useRef, lazy, useState, createElement, useContext, isValidElement, Suspense,
|
|
11
|
+
import { useEffect, useRef, lazy, useState, createElement, useContext, useMemo, isValidElement, Suspense, createContext, Fragment as Fragment$1, forwardRef, useCallback } from "react";
|
|
12
12
|
import Box from "@mui/material/Box";
|
|
13
13
|
import isNil from "lodash/isNil";
|
|
14
14
|
import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
|
|
@@ -20,7 +20,7 @@ import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
|
|
|
20
20
|
import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
|
|
21
21
|
import { useSize, useInViewport, useSetState, useGetState, useReactive } from "ahooks";
|
|
22
22
|
import LoadingButton from "@mui/lab/LoadingButton";
|
|
23
|
-
import { Send, Save, ChatBubbleOutlineOutlined, MoreVert,
|
|
23
|
+
import { Send, Save, ChatBubbleOutlineOutlined, MoreVert, NavigateNext, DeleteOutlineOutlined, ContentCopy, ArrowUpward, ArrowDownward, ArrowBackIos, Add, BorderColorOutlined } from "@mui/icons-material";
|
|
24
24
|
import { LocaleContext, useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
25
25
|
import Alert from "@mui/material/Alert";
|
|
26
26
|
import isBoolean from "lodash/isBoolean";
|
|
@@ -45,7 +45,7 @@ import BrokenImageIcon from "@mui/icons-material/BrokenImage";
|
|
|
45
45
|
import { Icon } from "@iconify/react";
|
|
46
46
|
import Empty$1 from "@arcblock/ux/lib/Empty";
|
|
47
47
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
48
|
-
import { useTheme as useTheme$1, useMediaQuery, Box as Box$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
48
|
+
import { useTheme as useTheme$1, useMediaQuery, Box as Box$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Divider, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
49
49
|
import NotificationsActiveOutlinedIcon from "@mui/icons-material/NotificationsActiveOutlined";
|
|
50
50
|
import CheckboxPlugin from "@blocklet/editor/lib/ext/CheckboxPlugin";
|
|
51
51
|
import DIDAddress from "@arcblock/did-connect/lib/Address";
|
|
@@ -518,7 +518,7 @@ const Input = ({
|
|
|
518
518
|
...editorConfig,
|
|
519
519
|
...inSmallView && {
|
|
520
520
|
toolbar: {
|
|
521
|
-
items: ["block", "italic", "bold", "underline", "media", ...((_a2 = editorConfig == null ? void 0 : editorConfig.toolbar) == null ? void 0 : _a2.items) || []]
|
|
521
|
+
items: ["component", "block", "italic", "bold", "underline", "media", ...((_a2 = editorConfig == null ? void 0 : editorConfig.toolbar) == null ? void 0 : _a2.items) || []]
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
};
|
|
@@ -916,9 +916,13 @@ function Badge({
|
|
|
916
916
|
] }) : null;
|
|
917
917
|
}
|
|
918
918
|
const useSessionContext = () => {
|
|
919
|
-
var _a2, _b2;
|
|
919
|
+
var _a2, _b2, _c, _d;
|
|
920
920
|
const ctx = useContext(SessionContext) || {};
|
|
921
921
|
const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
|
|
922
|
+
const permissionSet = useMemo(() => {
|
|
923
|
+
var _a3, _b3;
|
|
924
|
+
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
925
|
+
}, [(_d = (_c = ctx.session) == null ? void 0 : _c.user) == null ? void 0 : _d.permissions]);
|
|
922
926
|
return {
|
|
923
927
|
...ctx,
|
|
924
928
|
isAdmin: ["admin", "owner"].includes(loginRole),
|
|
@@ -928,6 +932,13 @@ const useSessionContext = () => {
|
|
|
928
932
|
}
|
|
929
933
|
const passportsArr = Array.isArray(passports) ? passports : [passports];
|
|
930
934
|
return passportsArr.includes(loginRole);
|
|
935
|
+
},
|
|
936
|
+
hasAnyPermission: (perms) => {
|
|
937
|
+
if (!perms || perms.length === 0) {
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
const permsArr = Array.isArray(perms) ? perms : [perms];
|
|
941
|
+
return permsArr.some((item) => permissionSet.has(item));
|
|
931
942
|
}
|
|
932
943
|
};
|
|
933
944
|
};
|
|
@@ -1078,7 +1089,16 @@ function ProfileCard({ user, click, ...rest }) {
|
|
|
1078
1089
|
}
|
|
1079
1090
|
);
|
|
1080
1091
|
}
|
|
1081
|
-
const HtmlTooltip$1 = styled(({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
1092
|
+
const HtmlTooltip$1 = styled(({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
1093
|
+
Tooltip,
|
|
1094
|
+
{
|
|
1095
|
+
PopperProps: {
|
|
1096
|
+
disablePortal: true
|
|
1097
|
+
},
|
|
1098
|
+
...props,
|
|
1099
|
+
classes: { popper: className }
|
|
1100
|
+
}
|
|
1101
|
+
))(() => ({
|
|
1082
1102
|
[`& .${tooltipClasses.tooltip}`]: {
|
|
1083
1103
|
backgroundColor: "transparent",
|
|
1084
1104
|
maxWidth: "initial"
|
|
@@ -1180,10 +1200,11 @@ function AuthorInfo({
|
|
|
1180
1200
|
);
|
|
1181
1201
|
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1, fontSize }, ...rest, children: [
|
|
1182
1202
|
renderAvatar(),
|
|
1183
|
-
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column" }, children: [
|
|
1203
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
1184
1204
|
/* @__PURE__ */ jsxs(
|
|
1185
1205
|
Box,
|
|
1186
1206
|
{
|
|
1207
|
+
className: "author-info-title",
|
|
1187
1208
|
sx: { display: "flex", alignItems: "center", minHeight: 20, flexWrap: "wrap", lineHeight: 1.5 },
|
|
1188
1209
|
lineHeight: 1,
|
|
1189
1210
|
children: [
|
|
@@ -1303,7 +1324,6 @@ function PostContent({
|
|
|
1303
1324
|
content,
|
|
1304
1325
|
editing = false,
|
|
1305
1326
|
onExitEditing,
|
|
1306
|
-
onCancel,
|
|
1307
1327
|
onSubmit,
|
|
1308
1328
|
autoCollapse,
|
|
1309
1329
|
enableHeadingsIdPlugin,
|
|
@@ -1317,7 +1337,7 @@ function PostContent({
|
|
|
1317
1337
|
sx: {
|
|
1318
1338
|
".be-editable": { maxHeight: 768, overflow: "auto", minHeight: `${Math.max(innerHeight, 200)}px !important` }
|
|
1319
1339
|
},
|
|
1320
|
-
children: /* @__PURE__ */ jsx(PostEdit, { content, onCancel, send: onSubmit, onSuccess: onExitEditing })
|
|
1340
|
+
children: /* @__PURE__ */ jsx(PostEdit, { content, onCancel: onExitEditing, send: onSubmit, onSuccess: onExitEditing })
|
|
1321
1341
|
}
|
|
1322
1342
|
);
|
|
1323
1343
|
}
|
|
@@ -1499,7 +1519,7 @@ function PostComponent({
|
|
|
1499
1519
|
return /* @__PURE__ */ jsxs(Root$1, { sx: { position: "relative", mt: 2, py: 1 }, ...rest, children: [
|
|
1500
1520
|
/* @__PURE__ */ jsxs(Box, { id: post.id, flex: "1", className: clsx({ "post-highlighted": isTargetPost && hasEnteredViewport }), children: [
|
|
1501
1521
|
/* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [
|
|
1502
|
-
/* @__PURE__ */ jsx(AuthorInfo, { user: post.author, createdAt: renderTime(), showProfileCard }),
|
|
1522
|
+
/* @__PURE__ */ jsx(AuthorInfo, { size: "sm", user: post.author, createdAt: renderTime(), showProfileCard }),
|
|
1503
1523
|
/* @__PURE__ */ jsx(Menu, { items: menuItems, style: { position: "absolute", right: 0, top: 0 } })
|
|
1504
1524
|
] }),
|
|
1505
1525
|
/* @__PURE__ */ jsxs(Box, { sx: { ml: 5.5 }, children: [
|
|
@@ -1551,6 +1571,7 @@ function PostComponent({
|
|
|
1551
1571
|
renderExtraContent && renderExtraContent(postContext)
|
|
1552
1572
|
] });
|
|
1553
1573
|
}
|
|
1574
|
+
const tablerMessageCircle = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m3 20l1.3-3.9C1.976 12.663 2.874 8.228 6.4 5.726c3.526-2.501 8.59-2.296 11.845.48c3.255 2.777 3.695 7.266 1.029 10.501C16.608 19.942 11.659 20.922 7.7 19z" }) });
|
|
1554
1575
|
const iconoirThumbsUp = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.5, children: [
|
|
1555
1576
|
/* @__PURE__ */ jsx("path", { d: "M16.472 20H4.1a.6.6 0 0 1-.6-.6V9.6a.6.6 0 0 1 .6-.6h2.768a2 2 0 0 0 1.715-.971l2.71-4.517a1.631 1.631 0 0 1 2.961 1.308l-1.022 3.408a.6.6 0 0 0 .574.772h4.575a2 2 0 0 1 1.93 2.526l-1.91 7A2 2 0 0 1 16.473 20Z" }),
|
|
1556
1577
|
/* @__PURE__ */ jsx("path", { strokeLinejoin: "round", d: "M7 20V9" })
|
|
@@ -1783,6 +1804,10 @@ const IconButtonRoot = styled$1("div")`
|
|
|
1783
1804
|
}
|
|
1784
1805
|
}
|
|
1785
1806
|
`;
|
|
1807
|
+
const tablerMoodPlus = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, children: [
|
|
1808
|
+
/* @__PURE__ */ jsx("path", { d: "M20.985 12.528a9 9 0 1 0-8.45 8.456M16 19h6m-3-3v6M9 10h.01M15 10h.01" }),
|
|
1809
|
+
/* @__PURE__ */ jsx("path", { d: "M9.5 15c.658.64 1.56 1 2.5 1s1.842-.36 2.5-1" })
|
|
1810
|
+
] }) });
|
|
1786
1811
|
const emojiFont = {
|
|
1787
1812
|
fontFamily: '"Twemoji Mozilla", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color"'
|
|
1788
1813
|
};
|
|
@@ -1890,10 +1915,11 @@ function GithubReaction({
|
|
|
1890
1915
|
sx: {
|
|
1891
1916
|
lineHeight: "24px",
|
|
1892
1917
|
fontSize: 13,
|
|
1918
|
+
border: 1,
|
|
1919
|
+
borderColor: "divider",
|
|
1893
1920
|
borderRadius: 1,
|
|
1894
1921
|
cursor: "pointer",
|
|
1895
1922
|
...selected && {
|
|
1896
|
-
border: 1,
|
|
1897
1923
|
borderColor: "primary.light",
|
|
1898
1924
|
bgcolor: (theme) => alpha(theme.palette.primary.light, 0.2)
|
|
1899
1925
|
}
|
|
@@ -1913,14 +1939,21 @@ function GithubReaction({
|
|
|
1913
1939
|
display: "flex",
|
|
1914
1940
|
justifyContent: "center",
|
|
1915
1941
|
alignItems: "center",
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1942
|
+
gap: 0.75,
|
|
1943
|
+
ml: -0.25,
|
|
1944
|
+
cursor: "pointer",
|
|
1945
|
+
fontWeight: "medium",
|
|
1946
|
+
".github-reaction-text": {
|
|
1947
|
+
color: "text.secondary"
|
|
1948
|
+
},
|
|
1949
|
+
"&:hover .github-reaction-text": {
|
|
1950
|
+
color: "secondary.main"
|
|
1951
|
+
}
|
|
1921
1952
|
},
|
|
1953
|
+
onClick: handleOpen,
|
|
1922
1954
|
children: [
|
|
1923
|
-
/* @__PURE__ */ jsx(
|
|
1955
|
+
/* @__PURE__ */ jsx(Box$1, { className: "github-reaction-text", component: tablerMoodPlus, sx: { fontSize: 18 } }),
|
|
1956
|
+
/* @__PURE__ */ jsx(Box$1, { className: "github-reaction-text", component: "span", sx: { fontSize: 13 }, children: "Sticker" }),
|
|
1924
1957
|
open && /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => setOpen(false), children: /* @__PURE__ */ jsx(
|
|
1925
1958
|
Box$1,
|
|
1926
1959
|
{
|
|
@@ -2104,23 +2137,36 @@ function Comment({
|
|
|
2104
2137
|
};
|
|
2105
2138
|
const render = ({ post, interactive }) => {
|
|
2106
2139
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2107
|
-
/* @__PURE__ */
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2140
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 3, mt: 1 }, children: [
|
|
2141
|
+
/* @__PURE__ */ jsx(
|
|
2142
|
+
GithubReaction,
|
|
2143
|
+
{
|
|
2144
|
+
data: (post == null ? void 0 : post.rating) || [],
|
|
2145
|
+
onRate: ({ value, ratingType }) => onRate(post, value, ratingType),
|
|
2146
|
+
onUnrate: () => onUnrate(post),
|
|
2147
|
+
interactive
|
|
2148
|
+
}
|
|
2149
|
+
),
|
|
2150
|
+
(!!(session == null ? void 0 : session.user) || preferences.displayReplyButtonForAnonymousUsers) && interactive && /* @__PURE__ */ jsxs(
|
|
2151
|
+
Box,
|
|
2152
|
+
{
|
|
2153
|
+
onClick: () => protectLogin(session, () => setInputVisible(!inputVisible)),
|
|
2154
|
+
sx: {
|
|
2155
|
+
display: "flex",
|
|
2156
|
+
alignItems: "center",
|
|
2157
|
+
gap: 0.75,
|
|
2158
|
+
fontSize: 13,
|
|
2159
|
+
color: "text.secondary",
|
|
2160
|
+
lineHeight: 1,
|
|
2161
|
+
"&:hover": { cursor: "pointer" }
|
|
2162
|
+
},
|
|
2163
|
+
children: [
|
|
2164
|
+
/* @__PURE__ */ jsx(Box, { component: tablerMessageCircle, sx: { fontSize: 18, color: "text.secondary" } }),
|
|
2165
|
+
/* @__PURE__ */ jsx(Box, { component: "span", children: "Reply" })
|
|
2166
|
+
]
|
|
2167
|
+
}
|
|
2168
|
+
)
|
|
2169
|
+
] }),
|
|
2124
2170
|
inputVisible && /* @__PURE__ */ jsx(Box, { my: 2, children: /* @__PURE__ */ jsx(
|
|
2125
2171
|
CommentInput,
|
|
2126
2172
|
{
|
|
@@ -2128,7 +2174,8 @@ function Comment({
|
|
|
2128
2174
|
onSuccess: () => setInputVisible(false),
|
|
2129
2175
|
draftKey: `post-${post.id}`
|
|
2130
2176
|
}
|
|
2131
|
-
) })
|
|
2177
|
+
) }),
|
|
2178
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mt: 3 } })
|
|
2132
2179
|
] });
|
|
2133
2180
|
};
|
|
2134
2181
|
const renderExtraContent = ({ post }) => {
|
|
@@ -2708,7 +2755,7 @@ function CoverImage({
|
|
|
2708
2755
|
pt: `${100 / aspectRatio}%`,
|
|
2709
2756
|
overflow: "hidden",
|
|
2710
2757
|
position: "relative",
|
|
2711
|
-
borderRadius:
|
|
2758
|
+
borderRadius: 1,
|
|
2712
2759
|
...shadow && { boxShadow: "rgb(0 0 0 / 12%) 0px 8px 30px" },
|
|
2713
2760
|
// https://stackoverflow.com/questions/49066011/overflow-hidden-with-border-radius-not-working-on-safari
|
|
2714
2761
|
transform: "translateZ(0)"
|
|
@@ -2789,7 +2836,7 @@ function CoverImageUpload({ url, onChange, ...rest }) {
|
|
|
2789
2836
|
height: 0,
|
|
2790
2837
|
pt: "56%",
|
|
2791
2838
|
overflow: "hidden",
|
|
2792
|
-
borderRadius:
|
|
2839
|
+
borderRadius: 1,
|
|
2793
2840
|
bgcolor: "grey.300",
|
|
2794
2841
|
cursor: "pointer"
|
|
2795
2842
|
},
|
|
@@ -3276,7 +3323,7 @@ function BlogPermaLink({ slug, onChange, ...rest }) {
|
|
|
3276
3323
|
alignItems: "center",
|
|
3277
3324
|
border: "1px solid #bbb",
|
|
3278
3325
|
borderRadius: 1,
|
|
3279
|
-
|
|
3326
|
+
overflow: "hidden"
|
|
3280
3327
|
},
|
|
3281
3328
|
children: [
|
|
3282
3329
|
/* @__PURE__ */ jsx(
|
|
@@ -3285,10 +3332,10 @@ function BlogPermaLink({ slug, onChange, ...rest }) {
|
|
|
3285
3332
|
sx: {
|
|
3286
3333
|
display: "flex",
|
|
3287
3334
|
alignItems: "center",
|
|
3288
|
-
width:
|
|
3335
|
+
width: 180,
|
|
3289
3336
|
alignSelf: "stretch",
|
|
3290
|
-
px:
|
|
3291
|
-
bgcolor: "grey.
|
|
3337
|
+
px: 1.25,
|
|
3338
|
+
bgcolor: "grey.200"
|
|
3292
3339
|
},
|
|
3293
3340
|
children: /* @__PURE__ */ jsx(
|
|
3294
3341
|
Box$1,
|
|
@@ -3300,10 +3347,11 @@ function BlogPermaLink({ slug, onChange, ...rest }) {
|
|
|
3300
3347
|
width: 1,
|
|
3301
3348
|
overflow: "hidden",
|
|
3302
3349
|
whiteSpace: "nowrap",
|
|
3303
|
-
fontSize: 14,
|
|
3304
3350
|
border: 0,
|
|
3305
3351
|
bgcolor: "inherit",
|
|
3306
|
-
outline: "none"
|
|
3352
|
+
outline: "none",
|
|
3353
|
+
fontSize: 14,
|
|
3354
|
+
color: "text.secondary"
|
|
3307
3355
|
}
|
|
3308
3356
|
}
|
|
3309
3357
|
)
|
|
@@ -3312,20 +3360,19 @@ function BlogPermaLink({ slug, onChange, ...rest }) {
|
|
|
3312
3360
|
/* @__PURE__ */ jsx(
|
|
3313
3361
|
InputBase,
|
|
3314
3362
|
{
|
|
3315
|
-
className: "blog-link",
|
|
3316
3363
|
value: slug,
|
|
3317
3364
|
onChange: (e) => onChange(e.target.value),
|
|
3318
|
-
sx: { ml:
|
|
3365
|
+
sx: { ml: 0.5, flex: 1, bgcolor: "transparent", input: { py: 1, fontSize: 14 } }
|
|
3319
3366
|
}
|
|
3320
3367
|
),
|
|
3321
3368
|
/* @__PURE__ */ jsx(
|
|
3322
3369
|
IconButton$2,
|
|
3323
3370
|
{
|
|
3324
|
-
sx: {
|
|
3371
|
+
sx: { px: 1 },
|
|
3325
3372
|
onClick: () => {
|
|
3326
3373
|
copy(joinUrl(prefix, slug));
|
|
3327
3374
|
},
|
|
3328
|
-
children: /* @__PURE__ */ jsx(ContentCopy, { sx: { fontSize:
|
|
3375
|
+
children: /* @__PURE__ */ jsx(ContentCopy, { sx: { fontSize: 18 } })
|
|
3329
3376
|
}
|
|
3330
3377
|
)
|
|
3331
3378
|
]
|
|
@@ -3836,6 +3883,9 @@ function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
|
3836
3883
|
}
|
|
3837
3884
|
}
|
|
3838
3885
|
};
|
|
3886
|
+
const renderPostContent = () => {
|
|
3887
|
+
return /* @__PURE__ */ jsx(Box, { className: "author-chat-item", children: /* @__PURE__ */ jsx(PostContent, { content: message.content }) });
|
|
3888
|
+
};
|
|
3839
3889
|
const menuItems = [];
|
|
3840
3890
|
const isSender = message.sender.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
3841
3891
|
const messageDate = new Date(message.createdAt);
|
|
@@ -3863,10 +3913,18 @@ function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
|
3863
3913
|
display: "flex !important"
|
|
3864
3914
|
}
|
|
3865
3915
|
},
|
|
3916
|
+
".author-info-title": {
|
|
3917
|
+
fontSize: 14,
|
|
3918
|
+
fontWeight: 500
|
|
3919
|
+
},
|
|
3920
|
+
".author-chat-item": {
|
|
3921
|
+
ml: compactMessage ? 6 : 0,
|
|
3922
|
+
width: "90%"
|
|
3923
|
+
},
|
|
3866
3924
|
...{
|
|
3867
3925
|
".be-editable": {
|
|
3868
3926
|
"& > *:last-child": {
|
|
3869
|
-
|
|
3927
|
+
mb: "0 !important"
|
|
3870
3928
|
}
|
|
3871
3929
|
}
|
|
3872
3930
|
}
|
|
@@ -3887,17 +3945,21 @@ function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
|
3887
3945
|
}
|
|
3888
3946
|
}
|
|
3889
3947
|
),
|
|
3890
|
-
!compactMessage
|
|
3948
|
+
!compactMessage ? /* @__PURE__ */ jsx(
|
|
3891
3949
|
AuthorInfo,
|
|
3892
3950
|
{
|
|
3893
3951
|
showBadge: false,
|
|
3894
3952
|
showProfileCard: true,
|
|
3953
|
+
showDID: false,
|
|
3895
3954
|
user: message.sender,
|
|
3896
3955
|
createdAt: showTime ? message.createdAt : void 0,
|
|
3897
|
-
size: "sm"
|
|
3956
|
+
size: "sm",
|
|
3957
|
+
style: {
|
|
3958
|
+
alignItems: "flex-start"
|
|
3959
|
+
},
|
|
3960
|
+
children: renderPostContent()
|
|
3898
3961
|
}
|
|
3899
|
-
)
|
|
3900
|
-
/* @__PURE__ */ jsx(Box, { sx: { ml: 6, width: "90%" }, children: /* @__PURE__ */ jsx(PostContent, { content: message.content }) })
|
|
3962
|
+
) : renderPostContent()
|
|
3901
3963
|
]
|
|
3902
3964
|
}
|
|
3903
3965
|
);
|
|
@@ -4189,6 +4251,7 @@ function MessageList({ chat, ...rest }) {
|
|
|
4189
4251
|
const isActive = isActiveChat(chat.id);
|
|
4190
4252
|
const containerRef = useRef(null);
|
|
4191
4253
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
4254
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
4192
4255
|
const scrollToBottom = () => {
|
|
4193
4256
|
var _a3, _b3;
|
|
4194
4257
|
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0, behavior: "smooth" });
|
|
@@ -4226,7 +4289,23 @@ function MessageList({ chat, ...rest }) {
|
|
|
4226
4289
|
py: 2.5,
|
|
4227
4290
|
px: 1.25,
|
|
4228
4291
|
gap: 1,
|
|
4229
|
-
background: "rgba(249, 250, 251, 1)"
|
|
4292
|
+
background: "rgba(249, 250, 251, 1)",
|
|
4293
|
+
// 闪烁
|
|
4294
|
+
"@keyframes blinking": {
|
|
4295
|
+
"0%": { opacity: 0 },
|
|
4296
|
+
"50%": { opacity: 1 },
|
|
4297
|
+
"100%": { opacity: 0 }
|
|
4298
|
+
},
|
|
4299
|
+
// 渐变显示
|
|
4300
|
+
"@keyframes fade-in": {
|
|
4301
|
+
"0%": { opacity: 0 },
|
|
4302
|
+
"100%": { opacity: 1 }
|
|
4303
|
+
},
|
|
4304
|
+
// 用于弱化消息渲染闪烁
|
|
4305
|
+
".message-item": {
|
|
4306
|
+
animation: "fade-in 0.2s linear",
|
|
4307
|
+
animationIterationCount: 1
|
|
4308
|
+
}
|
|
4230
4309
|
},
|
|
4231
4310
|
ref: containerRef,
|
|
4232
4311
|
children: [
|
|
@@ -4238,32 +4317,37 @@ function MessageList({ chat, ...rest }) {
|
|
|
4238
4317
|
display: "flex",
|
|
4239
4318
|
justifyContent: "center",
|
|
4240
4319
|
py: 0.5,
|
|
4241
|
-
|
|
4242
|
-
"@keyframes fade-in": {
|
|
4243
|
-
"0%": { opacity: 0 },
|
|
4244
|
-
"50%": { opacity: 1 },
|
|
4245
|
-
"100%": { opacity: 0 }
|
|
4246
|
-
}
|
|
4320
|
+
height: 40
|
|
4247
4321
|
},
|
|
4248
4322
|
children: /* @__PURE__ */ jsx(
|
|
4249
|
-
|
|
4323
|
+
LoadingButton,
|
|
4250
4324
|
{
|
|
4251
4325
|
variant: "text",
|
|
4252
4326
|
color: "inherit",
|
|
4327
|
+
loadingPosition: "start",
|
|
4328
|
+
loading: isLoadingMore,
|
|
4253
4329
|
onClick: async () => {
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4330
|
+
var _a3, _b3;
|
|
4331
|
+
try {
|
|
4332
|
+
setIsLoadingMore(true);
|
|
4333
|
+
const firstChatId = (_b3 = (_a3 = chat.messages) == null ? void 0 : _a3[0]) == null ? void 0 : _b3.id;
|
|
4334
|
+
const firstChatMessage = document.getElementById(firstChatId);
|
|
4257
4335
|
const divider = document.createElement("div");
|
|
4258
|
-
divider.style.animation = "
|
|
4336
|
+
divider.style.animation = "blinking 1s linear";
|
|
4259
4337
|
divider.style.animationIterationCount = "5";
|
|
4260
4338
|
divider.style.borderTop = "1px solid #e5e5e5";
|
|
4261
4339
|
divider.style.opacity = "0";
|
|
4262
4340
|
divider.style.height = "0";
|
|
4263
|
-
|
|
4264
|
-
(
|
|
4265
|
-
|
|
4266
|
-
|
|
4341
|
+
await loadMessages(chat.id, chat.nextCursor);
|
|
4342
|
+
setTimeout(() => {
|
|
4343
|
+
var _a4, _b4;
|
|
4344
|
+
(_a4 = containerRef.current) == null ? void 0 : _a4.insertBefore(divider, firstChatMessage);
|
|
4345
|
+
(_b4 = containerRef.current) == null ? void 0 : _b4.scrollTo({ top: divider.offsetTop - 40 - 16 - 1 });
|
|
4346
|
+
}, 20);
|
|
4347
|
+
} catch (error) {
|
|
4348
|
+
} finally {
|
|
4349
|
+
setIsLoadingMore(false);
|
|
4350
|
+
}
|
|
4267
4351
|
},
|
|
4268
4352
|
startIcon: /* @__PURE__ */ jsx(ArrowUpward, {}),
|
|
4269
4353
|
children: t("chat.loadMore")
|
|
@@ -4274,12 +4358,12 @@ function MessageList({ chat, ...rest }) {
|
|
|
4274
4358
|
chat.type !== "notification" && ((_a2 = chat.messages) == null ? void 0 : _a2.map((message, index) => {
|
|
4275
4359
|
var _a3;
|
|
4276
4360
|
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4277
|
-
return /* @__PURE__ */ jsx(Box, { id: message.id, children: /* @__PURE__ */ jsx(Message, { message, prevMessage: prev }) }, message.id);
|
|
4361
|
+
return /* @__PURE__ */ jsx(Box, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsx(Message, { message, prevMessage: prev }) }, message.id);
|
|
4278
4362
|
})),
|
|
4279
4363
|
chat.type === "notification" && ((_b2 = chat.messages) == null ? void 0 : _b2.map((message, index) => {
|
|
4280
4364
|
var _a3;
|
|
4281
4365
|
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4282
|
-
return /* @__PURE__ */ jsx(Box, { id: message.id, children: /* @__PURE__ */ jsx(
|
|
4366
|
+
return /* @__PURE__ */ jsx(Box, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsx(
|
|
4283
4367
|
NotificationMessage,
|
|
4284
4368
|
{
|
|
4285
4369
|
chat,
|
|
@@ -4366,7 +4450,7 @@ const PreviousLocationRecorder = () => {
|
|
|
4366
4450
|
};
|
|
4367
4451
|
function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
4368
4452
|
const navigate = useNavigate();
|
|
4369
|
-
const mergedSx = [{
|
|
4453
|
+
const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
|
|
4370
4454
|
const handleClick = () => {
|
|
4371
4455
|
if (url) {
|
|
4372
4456
|
navigate(url, { replace: true });
|
|
@@ -4385,8 +4469,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
|
4385
4469
|
{
|
|
4386
4470
|
onClick: handleClick,
|
|
4387
4471
|
variant: "outlined",
|
|
4388
|
-
color: "
|
|
4389
|
-
size: "small",
|
|
4472
|
+
color: "primary",
|
|
4390
4473
|
startIcon: /* @__PURE__ */ jsx(ArrowBackIos, { style: { fontSize: 13 } }),
|
|
4391
4474
|
sx: mergedSx,
|
|
4392
4475
|
...rest,
|
|
@@ -5093,7 +5176,7 @@ function Pagination({
|
|
|
5093
5176
|
}
|
|
5094
5177
|
);
|
|
5095
5178
|
}
|
|
5096
|
-
const Editor = lazy(() => import("./editor-
|
|
5179
|
+
const Editor = lazy(() => import("./editor-E23ceKmd.mjs"));
|
|
5097
5180
|
function LazyEditor(props) {
|
|
5098
5181
|
const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5099
5182
|
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
@@ -11259,83 +11342,84 @@ function SegmentedControl({ value, options, onChange, sx, ...rest }) {
|
|
|
11259
11342
|
) });
|
|
11260
11343
|
}
|
|
11261
11344
|
export {
|
|
11262
|
-
|
|
11345
|
+
useUnreadNotification as $,
|
|
11263
11346
|
Avatar as A,
|
|
11264
11347
|
Badge as B,
|
|
11265
11348
|
CommentInput as C,
|
|
11266
11349
|
DefaultEditorConfigProvider as D,
|
|
11267
11350
|
EmptyStatus as E,
|
|
11268
|
-
|
|
11351
|
+
BlogListWrapper as F,
|
|
11269
11352
|
GithubReaction as G,
|
|
11270
|
-
|
|
11353
|
+
BlogCard as H,
|
|
11271
11354
|
ImagePathFixerPlugin as I,
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11355
|
+
BlogPermaLink as J,
|
|
11356
|
+
getBlogLink as K,
|
|
11357
|
+
CoverImage as L,
|
|
11275
11358
|
Menu as M,
|
|
11276
|
-
|
|
11277
|
-
|
|
11359
|
+
CoverImageUpload as N,
|
|
11360
|
+
AccessControl as O,
|
|
11278
11361
|
Pagination as P,
|
|
11279
|
-
|
|
11362
|
+
useAuthzContext as Q,
|
|
11280
11363
|
RelativeTime as R,
|
|
11281
11364
|
ScrollableEditorWrapper as S,
|
|
11282
|
-
|
|
11283
|
-
|
|
11365
|
+
AuthzProvider as T,
|
|
11366
|
+
ChatClient as U,
|
|
11284
11367
|
VideoPathFixerPlugin as V,
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11368
|
+
Chat as W,
|
|
11369
|
+
ChatHeaderAddon as X,
|
|
11370
|
+
useChatContext as Y,
|
|
11371
|
+
ChatProvider as Z,
|
|
11372
|
+
UnreadNotificationContext as _,
|
|
11290
11373
|
isEmptyContent as a,
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11374
|
+
UnreadNotificationProvider as a0,
|
|
11375
|
+
Confirm as a1,
|
|
11376
|
+
ConfirmContext as a2,
|
|
11377
|
+
useConfirm as a3,
|
|
11378
|
+
ConfirmProvider as a4,
|
|
11379
|
+
SecureLabelPicker as a5,
|
|
11380
|
+
useApiErrorHandler as a6,
|
|
11381
|
+
useDefaultApiErrorHandler as a7,
|
|
11382
|
+
PreviousLocationRecorder as a8,
|
|
11383
|
+
Back as a9,
|
|
11384
|
+
LazyEditor as aa,
|
|
11385
|
+
EditorPreview as ab,
|
|
11386
|
+
DirtyPromptContainer as ac,
|
|
11387
|
+
ConfirmNavigation as ad,
|
|
11388
|
+
UploaderContext as ae,
|
|
11389
|
+
useUploader as af,
|
|
11390
|
+
UploaderTrigger as ag,
|
|
11391
|
+
UploaderProvider as ah,
|
|
11392
|
+
composeImageUrl as ai,
|
|
11393
|
+
usePointUpContext as aj,
|
|
11394
|
+
PointUpProvider as ak,
|
|
11395
|
+
ButtonGroup as al,
|
|
11396
|
+
SegmentedControl as am,
|
|
11397
|
+
create as an,
|
|
11398
|
+
getWsClient as ao,
|
|
11399
|
+
useSubscription as ap,
|
|
11316
11400
|
Input as b,
|
|
11317
11401
|
useChanged as c,
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11402
|
+
useSessionContext as d,
|
|
11403
|
+
utils as e,
|
|
11404
|
+
themeOverrides as f,
|
|
11321
11405
|
getExcerptSync as g,
|
|
11322
|
-
|
|
11406
|
+
InternalThemeProvider as h,
|
|
11323
11407
|
inferInitialEditorState as i,
|
|
11324
|
-
|
|
11325
|
-
|
|
11408
|
+
Avatars as j,
|
|
11409
|
+
AuthorInfo as k,
|
|
11326
11410
|
lexical as l,
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11411
|
+
SystemUser as m,
|
|
11412
|
+
PostContent as n,
|
|
11413
|
+
PostComponent as o,
|
|
11330
11414
|
preferences as p,
|
|
11331
|
-
|
|
11415
|
+
Comment as q,
|
|
11332
11416
|
routes as r,
|
|
11333
11417
|
stringify as s,
|
|
11334
11418
|
translations as t,
|
|
11335
11419
|
useNow as u,
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11420
|
+
CommentList as v,
|
|
11421
|
+
CommentsContext as w,
|
|
11422
|
+
useCommentsContext as x,
|
|
11423
|
+
CommentsProvider as y,
|
|
11424
|
+
BinaryThumb as z
|
|
11341
11425
|
};
|
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 } 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';
|