@blocklet/discuss-kit-ux 2.0.2 → 2.0.4
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/chat/hooks.d.ts +2 -0
- package/dist/components/utils.d.ts +2 -0
- package/dist/{editor-KBV5TMjF.mjs → editor-Ccgzqz7e.mjs} +1 -1
- package/dist/{index-bnv41bga.mjs → index-C0GjTcgJ.mjs} +205 -93
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +198 -87
- package/package.json +5 -4
|
@@ -5,5 +5,7 @@ export declare const useChatInWallet: () => {
|
|
|
5
5
|
}) => void;
|
|
6
6
|
navigateToChatList: () => void;
|
|
7
7
|
isChatInWalletV2: boolean;
|
|
8
|
+
isWebNavbar: boolean;
|
|
8
9
|
updateUnreadState: (unread: boolean) => void;
|
|
10
|
+
chatInWallet: import('react-router-dom').PathMatch<"chatId"> | null;
|
|
9
11
|
};
|
|
@@ -16,3 +16,5 @@ export declare const inferDiscussKitApiPrefix: () => any;
|
|
|
16
16
|
export declare const getDraftSessionKeyPrefix: () => string;
|
|
17
17
|
export declare const getExcerptFromLexicalContent: (content: any, size?: number) => string;
|
|
18
18
|
export declare const mergeSx: (initial: SystemStyleObject<Theme>, sx?: SxProps<Theme>) => any[];
|
|
19
|
+
export declare const discussKitMountPoint: string | undefined;
|
|
20
|
+
export declare const openProfileInNewTab: (did: string) => void;
|
|
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
|
|
|
4
4
|
import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
|
|
5
5
|
import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
|
|
6
6
|
import { lazy } from "react";
|
|
7
|
-
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-
|
|
7
|
+
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-C0GjTcgJ.mjs";
|
|
8
8
|
const BlockletEditor = lazy(() => import("@blocklet/editor"));
|
|
9
9
|
const Root = styled(Box)`
|
|
10
10
|
.be-editable,
|
|
@@ -4,18 +4,20 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
var _a, _b;
|
|
7
|
+
var _a, _b, _c;
|
|
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
11
|
import { create as create$1, styled as styled$1 } from "@arcblock/ux/lib/Theme";
|
|
12
|
-
import { useEffect, useRef, useState, createElement, useContext, useMemo, isValidElement, lazy, Suspense, createContext, Fragment as Fragment$1, forwardRef
|
|
12
|
+
import { useEffect, useRef, useState, createElement, useContext, useMemo, useCallback, isValidElement, lazy, Suspense, createContext, Fragment as Fragment$1, forwardRef } from "react";
|
|
13
13
|
import { Box, useTheme as useTheme$1, useMediaQuery, 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, Backdrop, Autocomplete, Typography as Typography$1, TextField as TextField$1, InputAdornment, SwipeableDrawer, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
14
14
|
import isNil from "lodash/isNil";
|
|
15
15
|
import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
|
|
16
16
|
import { lazyWithPreload } from "react-lazy-with-preload";
|
|
17
|
-
import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection
|
|
17
|
+
import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection } from "lexical";
|
|
18
18
|
import { $isRootTextContentEmpty } from "@lexical/text";
|
|
19
|
+
import { resolvePath, Link, useNavigate, useMatch, useLocation, useParams, Outlet, useSearchParams, useBlocker } from "react-router-dom";
|
|
20
|
+
import { joinURL } from "ufo";
|
|
19
21
|
import joinUrl from "url-join";
|
|
20
22
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
21
23
|
import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
|
|
@@ -34,7 +36,7 @@ import { grey, green, amber } from "@mui/material/colors";
|
|
|
34
36
|
import useMediaQuery$1 from "@mui/material/useMediaQuery";
|
|
35
37
|
import DID from "@arcblock/ux/lib/DID";
|
|
36
38
|
import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
|
|
37
|
-
import {
|
|
39
|
+
import { useBrowser } from "@arcblock/react-hooks";
|
|
38
40
|
import UxRelativeTime from "@arcblock/ux/lib/RelativeTime";
|
|
39
41
|
import Chip from "@mui/material/Chip";
|
|
40
42
|
import Stack from "@mui/material/Stack";
|
|
@@ -47,6 +49,8 @@ import BrokenImageIcon from "@mui/icons-material/BrokenImage";
|
|
|
47
49
|
import { Icon } from "@iconify/react";
|
|
48
50
|
import Empty$3 from "@arcblock/ux/lib/Empty";
|
|
49
51
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
52
|
+
import cmp from "semver-compare";
|
|
53
|
+
import bridge from "@arcblock/bridge";
|
|
50
54
|
import NotificationsActiveOutlinedIcon from "@mui/icons-material/NotificationsActiveOutlined";
|
|
51
55
|
import CheckboxPlugin from "@blocklet/editor/lib/ext/CheckboxPlugin";
|
|
52
56
|
import DIDAddress from "@arcblock/did-connect/lib/Address";
|
|
@@ -66,15 +70,12 @@ import CircularProgress from "@mui/material/CircularProgress";
|
|
|
66
70
|
import { Helmet } from "react-helmet";
|
|
67
71
|
import { Flipper, Flipped } from "react-flip-toolkit";
|
|
68
72
|
import grey$1 from "@mui/material/colors/grey";
|
|
69
|
-
import
|
|
70
|
-
import bridge from "@arcblock/bridge";
|
|
71
|
-
import { useBrowser } from "@arcblock/react-hooks";
|
|
73
|
+
import { EditorConfigProvider as EditorConfigProvider$1 } from "@blocklet/editor";
|
|
72
74
|
import Fab from "@mui/material/Fab";
|
|
73
75
|
import debounce from "lodash/debounce";
|
|
74
76
|
import { useIsFocused } from "@blocklet/editor/lib/main/hooks/useIsFocused";
|
|
75
77
|
import TextField from "@mui/material/TextField";
|
|
76
78
|
import AddIcon from "@mui/icons-material/Add";
|
|
77
|
-
import SessionManager from "@arcblock/did-connect/lib/SessionManager";
|
|
78
79
|
import { AxiosError } from "axios";
|
|
79
80
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
80
81
|
import MuiPagination from "@mui/material/Pagination";
|
|
@@ -341,10 +342,18 @@ const mergeSx = (initial, sx) => {
|
|
|
341
342
|
const mergedSx = [initial, ...Array.isArray(sx) ? sx : [sx]];
|
|
342
343
|
return mergedSx;
|
|
343
344
|
};
|
|
345
|
+
const discussKitMountPoint = (_a = getBlockletMountPointInfo("did-comments")) == null ? void 0 : _a.mountPoint;
|
|
346
|
+
const openProfileInNewTab = (did) => {
|
|
347
|
+
if (did) {
|
|
348
|
+
const { pathname } = resolvePath(`/profile/${did}`);
|
|
349
|
+
window.open(joinURL(discussKitMountPoint || "/", pathname), "_blank");
|
|
350
|
+
}
|
|
351
|
+
};
|
|
344
352
|
const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
345
353
|
__proto__: null,
|
|
346
354
|
blockletExists,
|
|
347
355
|
copy,
|
|
356
|
+
discussKitMountPoint,
|
|
348
357
|
getBlockletMountPointInfo,
|
|
349
358
|
getDraftSessionKeyPrefix,
|
|
350
359
|
getExcerptFromLexicalContent,
|
|
@@ -354,6 +363,7 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
354
363
|
inferDiscussKitApiPrefix,
|
|
355
364
|
mergeSx,
|
|
356
365
|
minDelay,
|
|
366
|
+
openProfileInNewTab,
|
|
357
367
|
protectLogin,
|
|
358
368
|
repairBase64Avatar,
|
|
359
369
|
sleep,
|
|
@@ -889,7 +899,7 @@ const formatKey = (key) => {
|
|
|
889
899
|
return "";
|
|
890
900
|
};
|
|
891
901
|
const badgeList = flatMap(
|
|
892
|
-
(((
|
|
902
|
+
(((_c = (_b = window == null ? void 0 : window.blocklet) == null ? void 0 : _b.preferences) == null ? void 0 : _c.badgeList) || []).filter((item) => [true, "true"].includes(item.enabled)).map((item) => {
|
|
893
903
|
var _a2;
|
|
894
904
|
return {
|
|
895
905
|
...item,
|
|
@@ -1034,13 +1044,13 @@ function Badge({
|
|
|
1034
1044
|
] }) : null;
|
|
1035
1045
|
}
|
|
1036
1046
|
const useSessionContext = () => {
|
|
1037
|
-
var _a2, _b2,
|
|
1047
|
+
var _a2, _b2, _c2, _d;
|
|
1038
1048
|
const ctx = useContext(SessionContext) || {};
|
|
1039
1049
|
const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
|
|
1040
1050
|
const permissionSet = useMemo(() => {
|
|
1041
1051
|
var _a3, _b3;
|
|
1042
1052
|
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
1043
|
-
}, [(_d = (
|
|
1053
|
+
}, [(_d = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d.permissions]);
|
|
1044
1054
|
return {
|
|
1045
1055
|
...ctx,
|
|
1046
1056
|
isAdmin: ["admin", "owner"].includes(loginRole),
|
|
@@ -1120,7 +1130,7 @@ const useResponsiveValue = (values2) => {
|
|
|
1120
1130
|
return r(values2);
|
|
1121
1131
|
};
|
|
1122
1132
|
function ProfileCard({ user, click, ...rest }) {
|
|
1123
|
-
var _a2, _b2,
|
|
1133
|
+
var _a2, _b2, _c2;
|
|
1124
1134
|
const { session } = useSessionContext();
|
|
1125
1135
|
const { t } = useLocaleContext();
|
|
1126
1136
|
let chatUrl = (user == null ? void 0 : user.did) && `/chat/dm/${user == null ? void 0 : user.did}`;
|
|
@@ -1189,7 +1199,7 @@ function ProfileCard({ user, click, ...rest }) {
|
|
|
1189
1199
|
/* @__PURE__ */ jsx(Box$1, { sx: { mt: 1 }, children: /* @__PURE__ */ jsx(Badge, { passports: (user == null ? void 0 : user.passports) || [], pointInfo: (user == null ? void 0 : user.pointInfo) || {}, did: user == null ? void 0 : user.did }) })
|
|
1190
1200
|
] })
|
|
1191
1201
|
] }),
|
|
1192
|
-
chatUrl && ((_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did) && ((
|
|
1202
|
+
chatUrl && ((_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did) && ((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.did) !== user.did && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1193
1203
|
/* @__PURE__ */ jsx(Box$1, { sx: { my: 2, borderTop: "1px solid #eee" } }),
|
|
1194
1204
|
/* @__PURE__ */ jsx(Box$1, { children: /* @__PURE__ */ jsx(
|
|
1195
1205
|
Button,
|
|
@@ -1208,6 +1218,50 @@ function ProfileCard({ user, click, ...rest }) {
|
|
|
1208
1218
|
}
|
|
1209
1219
|
);
|
|
1210
1220
|
}
|
|
1221
|
+
const useChatInWallet = () => {
|
|
1222
|
+
const navigate = useNavigate();
|
|
1223
|
+
const { walletVersion, mobile } = useBrowser();
|
|
1224
|
+
const chatInWallet = useMatch("/chat-in-wallet/:chatId?");
|
|
1225
|
+
const isChatInWalletV2 = useMemo(() => {
|
|
1226
|
+
try {
|
|
1227
|
+
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
1228
|
+
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1229
|
+
} catch (e) {
|
|
1230
|
+
console.error(e);
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
}, [walletVersion, mobile]);
|
|
1234
|
+
const isWebNavbar = useMemo(() => {
|
|
1235
|
+
try {
|
|
1236
|
+
const targetVersion = mobile.apple.device ? "5.4.6" : "5.4.4";
|
|
1237
|
+
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1238
|
+
} catch (e) {
|
|
1239
|
+
console.error(e);
|
|
1240
|
+
return false;
|
|
1241
|
+
}
|
|
1242
|
+
}, [walletVersion, mobile]);
|
|
1243
|
+
const navigateToChat = ({ id: id2, title }) => {
|
|
1244
|
+
if (isChatInWalletV2) {
|
|
1245
|
+
navigate(`/chat-in-wallet/${id2}`);
|
|
1246
|
+
} else {
|
|
1247
|
+
bridge.call("clickChat", { id: id2, title });
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
const navigateToChatList = () => {
|
|
1251
|
+
navigate("/chat-in-wallet");
|
|
1252
|
+
};
|
|
1253
|
+
const updateUnreadState = useCallback((unread) => {
|
|
1254
|
+
bridge.call("updateUnreadState", { unread, appId: window.blocklet.appPid, timestamp: /* @__PURE__ */ new Date() });
|
|
1255
|
+
}, []);
|
|
1256
|
+
return {
|
|
1257
|
+
navigateToChat,
|
|
1258
|
+
navigateToChatList,
|
|
1259
|
+
isChatInWalletV2,
|
|
1260
|
+
isWebNavbar,
|
|
1261
|
+
updateUnreadState,
|
|
1262
|
+
chatInWallet
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1211
1265
|
const HtmlTooltip$1 = styled(({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
1212
1266
|
Tooltip,
|
|
1213
1267
|
{
|
|
@@ -1242,6 +1296,8 @@ function AuthorInfo({
|
|
|
1242
1296
|
const downMd = useMediaQuery$1(theme.breakpoints.down("md"));
|
|
1243
1297
|
const navigate = useNavigate();
|
|
1244
1298
|
const [open, setOpen] = useState(false);
|
|
1299
|
+
const { mobile } = useBrowser();
|
|
1300
|
+
const { chatInWallet } = useChatInWallet();
|
|
1245
1301
|
const sm = size === "sm";
|
|
1246
1302
|
let fontSize = sm ? 12 : 14;
|
|
1247
1303
|
let avatarSize = profileUse ? 24 : sm ? 40 : 48;
|
|
@@ -1267,12 +1323,16 @@ function AuthorInfo({
|
|
|
1267
1323
|
(_a2 = e == null ? void 0 : e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
1268
1324
|
(_b2 = e == null ? void 0 : e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
1269
1325
|
setOpen(false);
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
}
|
|
1326
|
+
if (chatInWallet) {
|
|
1327
|
+
openProfileInNewTab(user == null ? void 0 : user.did);
|
|
1328
|
+
} else {
|
|
1329
|
+
setTimeout(() => {
|
|
1330
|
+
navigate(`/profile/${user == null ? void 0 : user.did}`);
|
|
1331
|
+
}, 100);
|
|
1332
|
+
}
|
|
1273
1333
|
};
|
|
1274
1334
|
const renderAvatar = () => {
|
|
1275
|
-
if (showProfileCard) {
|
|
1335
|
+
if (showProfileCard && !mobile.any) {
|
|
1276
1336
|
return /* @__PURE__ */ jsx(
|
|
1277
1337
|
HtmlTooltip$1,
|
|
1278
1338
|
{
|
|
@@ -3923,33 +3983,6 @@ function ChannelGroup({ size = "normal", chat, children, ...rest }) {
|
|
|
3923
3983
|
] })
|
|
3924
3984
|
] });
|
|
3925
3985
|
}
|
|
3926
|
-
const useChatInWallet = () => {
|
|
3927
|
-
const navigate = useNavigate();
|
|
3928
|
-
const { walletVersion, mobile } = useBrowser();
|
|
3929
|
-
const isChatInWalletV2 = useMemo(() => {
|
|
3930
|
-
try {
|
|
3931
|
-
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
3932
|
-
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
3933
|
-
} catch (e) {
|
|
3934
|
-
console.error(e);
|
|
3935
|
-
return false;
|
|
3936
|
-
}
|
|
3937
|
-
}, [walletVersion, mobile]);
|
|
3938
|
-
const navigateToChat = ({ id: id2, title }) => {
|
|
3939
|
-
if (isChatInWalletV2) {
|
|
3940
|
-
navigate(`/chat-in-wallet/${id2}`);
|
|
3941
|
-
} else {
|
|
3942
|
-
bridge.call("clickChat", { id: id2, title });
|
|
3943
|
-
}
|
|
3944
|
-
};
|
|
3945
|
-
const navigateToChatList = () => {
|
|
3946
|
-
navigate("/chat-in-wallet");
|
|
3947
|
-
};
|
|
3948
|
-
const updateUnreadState = useCallback((unread) => {
|
|
3949
|
-
bridge.call("updateUnreadState", { unread, appId: window.blocklet.appPid, timestamp: /* @__PURE__ */ new Date() });
|
|
3950
|
-
}, []);
|
|
3951
|
-
return { navigateToChat, navigateToChatList, isChatInWalletV2, updateUnreadState };
|
|
3952
|
-
};
|
|
3953
3986
|
function ChatList({ inWallet, ...rest }) {
|
|
3954
3987
|
const { t } = useLocaleContext();
|
|
3955
3988
|
const { orderedChats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages, getLastMessageText } = useChatContext();
|
|
@@ -4210,7 +4243,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
|
|
|
4210
4243
|
return null;
|
|
4211
4244
|
};
|
|
4212
4245
|
const render = () => {
|
|
4213
|
-
var _a2, _b2,
|
|
4246
|
+
var _a2, _b2, _c2, _d;
|
|
4214
4247
|
const baseCardSx = {
|
|
4215
4248
|
py: 1.5,
|
|
4216
4249
|
px: 2,
|
|
@@ -4353,7 +4386,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
|
|
|
4353
4386
|
]
|
|
4354
4387
|
}
|
|
4355
4388
|
),
|
|
4356
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((
|
|
4389
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
|
|
4357
4390
|
renderQuote(message.post)
|
|
4358
4391
|
]
|
|
4359
4392
|
}
|
|
@@ -4670,7 +4703,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
|
4670
4703
|
}
|
|
4671
4704
|
const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
|
|
4672
4705
|
const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
|
|
4673
|
-
const Editor = lazy(() => import("./editor-
|
|
4706
|
+
const Editor = lazy(() => import("./editor-Ccgzqz7e.mjs"));
|
|
4674
4707
|
function LazyEditor(props) {
|
|
4675
4708
|
const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
|
|
4676
4709
|
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
@@ -4710,7 +4743,12 @@ function AutoClearPlugin({ clearKey }) {
|
|
|
4710
4743
|
if (editor && clearKey) {
|
|
4711
4744
|
editor.update(() => {
|
|
4712
4745
|
const root = $getRoot();
|
|
4746
|
+
const paragraph = $createParagraphNode();
|
|
4713
4747
|
root.clear();
|
|
4748
|
+
root.append(paragraph);
|
|
4749
|
+
if ($getSelection() !== null) {
|
|
4750
|
+
paragraph.select();
|
|
4751
|
+
}
|
|
4714
4752
|
});
|
|
4715
4753
|
}
|
|
4716
4754
|
}, [editor, clearKey]);
|
|
@@ -4729,6 +4767,39 @@ function DraggerPlugin() {
|
|
|
4729
4767
|
const hasFocus = useIsFocused();
|
|
4730
4768
|
const selection = editor.getEditorState().read($getSelection);
|
|
4731
4769
|
const enabled = mobile.any && hasFocus && selection;
|
|
4770
|
+
const detectSwipe = (node, callback) => {
|
|
4771
|
+
let touchstartY = 0;
|
|
4772
|
+
let touchendY = 0;
|
|
4773
|
+
function handleSwipe() {
|
|
4774
|
+
if (touchstartY - touchendY > 10 || touchendY - touchstartY > 10) {
|
|
4775
|
+
callback();
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
const onTouchStart = (event) => {
|
|
4779
|
+
touchstartY = event.changedTouches[0].screenY;
|
|
4780
|
+
};
|
|
4781
|
+
const onTouchEnd = (event) => {
|
|
4782
|
+
touchendY = event.changedTouches[0].screenY;
|
|
4783
|
+
handleSwipe();
|
|
4784
|
+
};
|
|
4785
|
+
node.addEventListener("touchstart", onTouchStart, false);
|
|
4786
|
+
node.addEventListener("touchend", onTouchEnd, false);
|
|
4787
|
+
return () => {
|
|
4788
|
+
node.removeEventListener("touchstart", onTouchStart, false);
|
|
4789
|
+
node.removeEventListener("touchend", onTouchEnd, false);
|
|
4790
|
+
};
|
|
4791
|
+
};
|
|
4792
|
+
useEffect(() => {
|
|
4793
|
+
const root = editor.getRootElement();
|
|
4794
|
+
if (enabled && root) {
|
|
4795
|
+
const cleanup = [detectSwipe(document.body, () => editor.blur()), detectSwipe(root, () => editor.blur())];
|
|
4796
|
+
return () => {
|
|
4797
|
+
cleanup.forEach((fn) => fn());
|
|
4798
|
+
};
|
|
4799
|
+
}
|
|
4800
|
+
return () => {
|
|
4801
|
+
};
|
|
4802
|
+
}, [editor, enabled]);
|
|
4732
4803
|
if (enabled) {
|
|
4733
4804
|
return /* @__PURE__ */ jsx(
|
|
4734
4805
|
Box,
|
|
@@ -4752,32 +4823,17 @@ function ShortcutPlugin({ callback }) {
|
|
|
4752
4823
|
const [editor] = useLexicalComposerContext();
|
|
4753
4824
|
const { mobile } = useBrowser();
|
|
4754
4825
|
useEffect(() => {
|
|
4755
|
-
let dispatching = false;
|
|
4756
4826
|
return editor.registerCommand(
|
|
4757
4827
|
KEY_ENTER_COMMAND,
|
|
4758
4828
|
(e) => {
|
|
4759
|
-
if (
|
|
4760
|
-
dispatching = false;
|
|
4829
|
+
if (mobile.any || e.shiftKey) {
|
|
4761
4830
|
return false;
|
|
4762
4831
|
}
|
|
4763
|
-
if (e.shiftKey) {
|
|
4764
|
-
dispatching = true;
|
|
4765
|
-
const keyboardEvent = new KeyboardEvent("keydown", {
|
|
4766
|
-
code: "Enter",
|
|
4767
|
-
key: "Enter",
|
|
4768
|
-
charCode: 13,
|
|
4769
|
-
keyCode: 13,
|
|
4770
|
-
view: window,
|
|
4771
|
-
bubbles: true
|
|
4772
|
-
});
|
|
4773
|
-
e.preventDefault();
|
|
4774
|
-
editor.dispatchCommand(KEY_ENTER_COMMAND, keyboardEvent);
|
|
4775
|
-
return true;
|
|
4776
|
-
}
|
|
4777
4832
|
callback();
|
|
4833
|
+
e.preventDefault();
|
|
4778
4834
|
return true;
|
|
4779
4835
|
},
|
|
4780
|
-
|
|
4836
|
+
COMMAND_PRIORITY_LOW
|
|
4781
4837
|
);
|
|
4782
4838
|
}, [editor, callback, mobile.any]);
|
|
4783
4839
|
return null;
|
|
@@ -4793,6 +4849,9 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4793
4849
|
const [focused, setFocused] = useState(false);
|
|
4794
4850
|
const compactView = mobile.any && !focused;
|
|
4795
4851
|
const handleSend = () => {
|
|
4852
|
+
if (!content) {
|
|
4853
|
+
return;
|
|
4854
|
+
}
|
|
4796
4855
|
send(content);
|
|
4797
4856
|
setContent("");
|
|
4798
4857
|
setLastSent(Date.now());
|
|
@@ -4855,7 +4914,7 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4855
4914
|
children: /* @__PURE__ */ jsx(Box, { component: tablerSend, sx: { fontSize: 13, color: "text.secondary" } })
|
|
4856
4915
|
}
|
|
4857
4916
|
),
|
|
4858
|
-
/* @__PURE__ */ jsxs(
|
|
4917
|
+
/* @__PURE__ */ jsx(EditorConfigProvider$1, { value: { minimalMode: true }, children: /* @__PURE__ */ jsxs(
|
|
4859
4918
|
LazyEditor,
|
|
4860
4919
|
{
|
|
4861
4920
|
enableSaveAreaPlugin: false,
|
|
@@ -4875,7 +4934,7 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4875
4934
|
/* @__PURE__ */ jsx(FocusPlugin, { callback: (v2) => setFocused(v2) })
|
|
4876
4935
|
]
|
|
4877
4936
|
}
|
|
4878
|
-
)
|
|
4937
|
+
) })
|
|
4879
4938
|
]
|
|
4880
4939
|
}
|
|
4881
4940
|
),
|
|
@@ -5065,7 +5124,7 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
5065
5124
|
]
|
|
5066
5125
|
}
|
|
5067
5126
|
),
|
|
5068
|
-
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(MessageList, { chat }) }),
|
|
5127
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(EditorConfigProvider$1, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsx(MessageList, { chat }) }) }),
|
|
5069
5128
|
/* @__PURE__ */ jsxs(Box$1, { sx: { position: "relative" }, children: [
|
|
5070
5129
|
chat.isActivated && chat.type !== "notification" && /* @__PURE__ */ jsx(Box$1, { sx: { px: { xs: 0, sm: 2.5 }, pb: { xs: 0, sm: 2.5 } }, children: /* @__PURE__ */ jsx(
|
|
5071
5130
|
ChatInput,
|
|
@@ -5520,17 +5579,28 @@ function Empty({ sx }) {
|
|
|
5520
5579
|
] });
|
|
5521
5580
|
}
|
|
5522
5581
|
function ChatListInWallet({ sx, ...rest }) {
|
|
5582
|
+
var _a2, _b2, _c2, _d;
|
|
5523
5583
|
const { session } = useSessionContext();
|
|
5524
5584
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
5525
5585
|
const { unread } = useUnreadNotification();
|
|
5526
|
-
const { navigateToChatList, updateUnreadState } = useChatInWallet();
|
|
5586
|
+
const { navigateToChatList, updateUnreadState, isWebNavbar } = useChatInWallet();
|
|
5527
5587
|
useEffect(() => {
|
|
5528
5588
|
updateUnreadState(unread);
|
|
5529
5589
|
}, [unread, updateUnreadState]);
|
|
5530
5590
|
if (!initialized) {
|
|
5531
5591
|
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
5532
5592
|
}
|
|
5533
|
-
const mergedSx = [
|
|
5593
|
+
const mergedSx = [
|
|
5594
|
+
{
|
|
5595
|
+
display: "flex",
|
|
5596
|
+
height: "100%",
|
|
5597
|
+
bgcolor: "#fff",
|
|
5598
|
+
...((_a2 = window.chatInWallet) == null ? void 0 : _a2.safeAreaInsetTop) && {
|
|
5599
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5600
|
+
}
|
|
5601
|
+
},
|
|
5602
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
5603
|
+
];
|
|
5534
5604
|
return /* @__PURE__ */ jsx(Box$1, { ...rest, sx: mergedSx, children: /* @__PURE__ */ jsxs(
|
|
5535
5605
|
Box$1,
|
|
5536
5606
|
{
|
|
@@ -5542,24 +5612,54 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5542
5612
|
},
|
|
5543
5613
|
children: [
|
|
5544
5614
|
/* @__PURE__ */ jsxs(Box$1, { sx: { flex: "0 0 auto", py: 1, px: 2 }, children: [
|
|
5545
|
-
/* @__PURE__ */ jsxs(
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
{
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5615
|
+
!isWebNavbar && /* @__PURE__ */ jsxs(
|
|
5616
|
+
Box$1,
|
|
5617
|
+
{
|
|
5618
|
+
sx: {
|
|
5619
|
+
display: "flex",
|
|
5620
|
+
justifyContent: "space-between",
|
|
5621
|
+
alignItems: "center",
|
|
5622
|
+
mb: 1
|
|
5623
|
+
},
|
|
5624
|
+
children: [
|
|
5625
|
+
/* @__PURE__ */ jsxs(
|
|
5626
|
+
Box$1,
|
|
5627
|
+
{
|
|
5628
|
+
onClick: () => {
|
|
5629
|
+
bridge.call("switchApp");
|
|
5630
|
+
},
|
|
5631
|
+
sx: { display: "flex", alignItems: "center", gap: 1 },
|
|
5632
|
+
children: [
|
|
5633
|
+
/* @__PURE__ */ jsx(Box$1, { component: "img", src: window.blocklet.appLogo, alt: "", sx: { width: 20, height: 20 } }),
|
|
5634
|
+
/* @__PURE__ */ jsx(Box$1, { component: "span", sx: { typography: "h5", fontWeight: "bold" }, children: window.blocklet.appName }),
|
|
5635
|
+
/* @__PURE__ */ jsx(
|
|
5636
|
+
Box$1,
|
|
5637
|
+
{
|
|
5638
|
+
component: tablerSwitchHorizontal,
|
|
5639
|
+
sx: { fontSize: 15, color: "grey.600", "& [stroke-width='2']": { strokeWidth: "2!important" } }
|
|
5640
|
+
}
|
|
5641
|
+
)
|
|
5642
|
+
]
|
|
5643
|
+
}
|
|
5644
|
+
),
|
|
5645
|
+
/* @__PURE__ */ jsx(
|
|
5646
|
+
Avatar,
|
|
5647
|
+
{
|
|
5648
|
+
did: (_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did,
|
|
5649
|
+
src: (_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.avatar,
|
|
5650
|
+
size: 20,
|
|
5651
|
+
shape: "circle",
|
|
5652
|
+
variant: "circle",
|
|
5653
|
+
onClick: () => {
|
|
5654
|
+
var _a3;
|
|
5655
|
+
return openProfileInNewTab((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did);
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
)
|
|
5659
|
+
]
|
|
5660
|
+
}
|
|
5661
|
+
),
|
|
5662
|
+
/* @__PURE__ */ jsx(UserSearch, {})
|
|
5563
5663
|
] }),
|
|
5564
5664
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
5565
5665
|
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
|
@@ -5574,7 +5674,19 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5574
5674
|
onClose: () => navigateToChatList(),
|
|
5575
5675
|
onOpen: () => {
|
|
5576
5676
|
},
|
|
5577
|
-
children: /* @__PURE__ */ jsx(
|
|
5677
|
+
children: /* @__PURE__ */ jsx(
|
|
5678
|
+
Box$1,
|
|
5679
|
+
{
|
|
5680
|
+
sx: {
|
|
5681
|
+
width: 1,
|
|
5682
|
+
height: 1,
|
|
5683
|
+
...((_d = window.chatInWallet) == null ? void 0 : _d.safeAreaInsetTop) && {
|
|
5684
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5685
|
+
}
|
|
5686
|
+
},
|
|
5687
|
+
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
5688
|
+
}
|
|
5689
|
+
)
|
|
5578
5690
|
}
|
|
5579
5691
|
)
|
|
5580
5692
|
]
|
|
@@ -11631,14 +11743,14 @@ function create(prefix2) {
|
|
|
11631
11743
|
}
|
|
11632
11744
|
});
|
|
11633
11745
|
}
|
|
11634
|
-
function getWsClient(prefix2 = ((
|
|
11746
|
+
function getWsClient(prefix2 = ((_d) => (_d = window.blocklet) == null ? void 0 : _d.prefix)() || "/") {
|
|
11635
11747
|
if (!client) {
|
|
11636
11748
|
client = create(prefix2);
|
|
11637
11749
|
}
|
|
11638
11750
|
return client;
|
|
11639
11751
|
}
|
|
11640
11752
|
const useSubscription = (event, cb = () => {
|
|
11641
|
-
}, deps = [], prefix2 = ((
|
|
11753
|
+
}, deps = [], prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") => {
|
|
11642
11754
|
useEffect(() => {
|
|
11643
11755
|
if (event) {
|
|
11644
11756
|
if (!client) {
|
|
@@ -11705,7 +11817,7 @@ function PointUp({ points }) {
|
|
|
11705
11817
|
);
|
|
11706
11818
|
}
|
|
11707
11819
|
function PointUpProvider({ children }) {
|
|
11708
|
-
var _a2, _b2,
|
|
11820
|
+
var _a2, _b2, _c2, _d;
|
|
11709
11821
|
const state = useReactive({
|
|
11710
11822
|
pointsList: [],
|
|
11711
11823
|
visible: false,
|
|
@@ -11716,7 +11828,7 @@ function PointUpProvider({ children }) {
|
|
|
11716
11828
|
const pointUp = useCallback(({ points }) => {
|
|
11717
11829
|
state.pointsList.push(points);
|
|
11718
11830
|
}, []);
|
|
11719
|
-
const pointUpComponent = (
|
|
11831
|
+
const pointUpComponent = (_c2 = (_b2 = (_a2 = window.blocklet) == null ? void 0 : _a2.componentMountPoints) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(
|
|
11720
11832
|
_b2,
|
|
11721
11833
|
(item) => item.did === "z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA"
|
|
11722
11834
|
);
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "@blocklet/labels";
|
|
2
|
-
import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-
|
|
2
|
+
import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-C0GjTcgJ.mjs";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
import "@mui/material/Box";
|
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("
|
|
3
|
-
})(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/react-hooks"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("react-dom"), require("url-join"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("@blocklet/editor"), require("@mui/material/Fab"), require("lodash/debounce"), require("@blocklet/editor/lib/main/hooks/useIsFocused"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("ufo"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/react-hooks", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "semver-compare", "@arcblock/bridge", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "react-dom", "url-join", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "@blocklet/editor", "@mui/material/Fab", "lodash/debounce", "@blocklet/editor/lib/main/hooks/useIsFocused", "@mui/material/TextField", "@mui/icons-material/Add", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "ufo", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.reactHooks, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.cmp, global.bridge, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.ReactDOM, global.joinUrl, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.editor$1, global.Fab, global.debounce, global.useIsFocused, global.TextField, global.AddIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin$1, global.SafeAreaPlugin, global.text, global.ufo, global.ImageNode, global.VideoNode));
|
|
3
|
+
})(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, reactHooks, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, cmp, bridge, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, ReactDOM, joinUrl, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, TextField, AddIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin$1, SafeAreaPlugin, text, ufo, ImageNode, VideoNode) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => {
|
|
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8
8
|
return value;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const typography = {
|
|
13
13
|
h1: {
|
|
14
14
|
fontSize: "1.875rem",
|
|
@@ -268,10 +268,18 @@ var __publicField = (obj, key, value) => {
|
|
|
268
268
|
const mergedSx = [initial, ...Array.isArray(sx) ? sx : [sx]];
|
|
269
269
|
return mergedSx;
|
|
270
270
|
};
|
|
271
|
+
const discussKitMountPoint = (_a = getBlockletMountPointInfo("did-comments")) == null ? void 0 : _a.mountPoint;
|
|
272
|
+
const openProfileInNewTab = (did) => {
|
|
273
|
+
if (did) {
|
|
274
|
+
const { pathname } = reactRouterDom.resolvePath(`/profile/${did}`);
|
|
275
|
+
window.open(ufo.joinURL(discussKitMountPoint || "/", pathname), "_blank");
|
|
276
|
+
}
|
|
277
|
+
};
|
|
271
278
|
const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
272
279
|
__proto__: null,
|
|
273
280
|
blockletExists,
|
|
274
281
|
copy,
|
|
282
|
+
discussKitMountPoint,
|
|
275
283
|
getBlockletMountPointInfo,
|
|
276
284
|
getDraftSessionKeyPrefix,
|
|
277
285
|
getExcerptFromLexicalContent,
|
|
@@ -281,6 +289,7 @@ var __publicField = (obj, key, value) => {
|
|
|
281
289
|
inferDiscussKitApiPrefix,
|
|
282
290
|
mergeSx,
|
|
283
291
|
minDelay,
|
|
292
|
+
openProfileInNewTab,
|
|
284
293
|
protectLogin,
|
|
285
294
|
repairBase64Avatar,
|
|
286
295
|
sleep,
|
|
@@ -816,7 +825,7 @@ var __publicField = (obj, key, value) => {
|
|
|
816
825
|
return "";
|
|
817
826
|
};
|
|
818
827
|
const badgeList = flatMap(
|
|
819
|
-
(((
|
|
828
|
+
(((_c = (_b = window == null ? void 0 : window.blocklet) == null ? void 0 : _b.preferences) == null ? void 0 : _c.badgeList) || []).filter((item) => [true, "true"].includes(item.enabled)).map((item) => {
|
|
820
829
|
var _a2;
|
|
821
830
|
return {
|
|
822
831
|
...item,
|
|
@@ -961,13 +970,13 @@ var __publicField = (obj, key, value) => {
|
|
|
961
970
|
] }) : null;
|
|
962
971
|
}
|
|
963
972
|
const useSessionContext = () => {
|
|
964
|
-
var _a2, _b2,
|
|
973
|
+
var _a2, _b2, _c2, _d;
|
|
965
974
|
const ctx = react.useContext(Session.SessionContext) || {};
|
|
966
975
|
const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
|
|
967
976
|
const permissionSet = react.useMemo(() => {
|
|
968
977
|
var _a3, _b3;
|
|
969
978
|
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
970
|
-
}, [(_d = (
|
|
979
|
+
}, [(_d = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d.permissions]);
|
|
971
980
|
return {
|
|
972
981
|
...ctx,
|
|
973
982
|
isAdmin: ["admin", "owner"].includes(loginRole),
|
|
@@ -1047,7 +1056,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1047
1056
|
return r(values2);
|
|
1048
1057
|
};
|
|
1049
1058
|
function ProfileCard({ user, click, ...rest }) {
|
|
1050
|
-
var _a2, _b2,
|
|
1059
|
+
var _a2, _b2, _c2;
|
|
1051
1060
|
const { session } = useSessionContext();
|
|
1052
1061
|
const { t } = context.useLocaleContext();
|
|
1053
1062
|
let chatUrl = (user == null ? void 0 : user.did) && `/chat/dm/${user == null ? void 0 : user.did}`;
|
|
@@ -1116,7 +1125,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1116
1125
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { passports: (user == null ? void 0 : user.passports) || [], pointInfo: (user == null ? void 0 : user.pointInfo) || {}, did: user == null ? void 0 : user.did }) })
|
|
1117
1126
|
] })
|
|
1118
1127
|
] }),
|
|
1119
|
-
chatUrl && ((_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did) && ((
|
|
1128
|
+
chatUrl && ((_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did) && ((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.did) !== user.did && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1120
1129
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { my: 2, borderTop: "1px solid #eee" } }),
|
|
1121
1130
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1122
1131
|
Button,
|
|
@@ -1135,6 +1144,50 @@ var __publicField = (obj, key, value) => {
|
|
|
1135
1144
|
}
|
|
1136
1145
|
);
|
|
1137
1146
|
}
|
|
1147
|
+
const useChatInWallet = () => {
|
|
1148
|
+
const navigate = reactRouterDom.useNavigate();
|
|
1149
|
+
const { walletVersion, mobile } = reactHooks.useBrowser();
|
|
1150
|
+
const chatInWallet = reactRouterDom.useMatch("/chat-in-wallet/:chatId?");
|
|
1151
|
+
const isChatInWalletV2 = react.useMemo(() => {
|
|
1152
|
+
try {
|
|
1153
|
+
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
1154
|
+
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1155
|
+
} catch (e) {
|
|
1156
|
+
console.error(e);
|
|
1157
|
+
return false;
|
|
1158
|
+
}
|
|
1159
|
+
}, [walletVersion, mobile]);
|
|
1160
|
+
const isWebNavbar = react.useMemo(() => {
|
|
1161
|
+
try {
|
|
1162
|
+
const targetVersion = mobile.apple.device ? "5.4.6" : "5.4.4";
|
|
1163
|
+
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1164
|
+
} catch (e) {
|
|
1165
|
+
console.error(e);
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
}, [walletVersion, mobile]);
|
|
1169
|
+
const navigateToChat = ({ id: id2, title }) => {
|
|
1170
|
+
if (isChatInWalletV2) {
|
|
1171
|
+
navigate(`/chat-in-wallet/${id2}`);
|
|
1172
|
+
} else {
|
|
1173
|
+
bridge.call("clickChat", { id: id2, title });
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
const navigateToChatList = () => {
|
|
1177
|
+
navigate("/chat-in-wallet");
|
|
1178
|
+
};
|
|
1179
|
+
const updateUnreadState = react.useCallback((unread) => {
|
|
1180
|
+
bridge.call("updateUnreadState", { unread, appId: window.blocklet.appPid, timestamp: /* @__PURE__ */ new Date() });
|
|
1181
|
+
}, []);
|
|
1182
|
+
return {
|
|
1183
|
+
navigateToChat,
|
|
1184
|
+
navigateToChatList,
|
|
1185
|
+
isChatInWalletV2,
|
|
1186
|
+
isWebNavbar,
|
|
1187
|
+
updateUnreadState,
|
|
1188
|
+
chatInWallet
|
|
1189
|
+
};
|
|
1190
|
+
};
|
|
1138
1191
|
const HtmlTooltip$1 = styles.styled(({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1139
1192
|
Tooltip,
|
|
1140
1193
|
{
|
|
@@ -1169,6 +1222,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1169
1222
|
const downMd = useMediaQuery(theme.breakpoints.down("md"));
|
|
1170
1223
|
const navigate = reactRouterDom.useNavigate();
|
|
1171
1224
|
const [open, setOpen] = react.useState(false);
|
|
1225
|
+
const { mobile } = reactHooks.useBrowser();
|
|
1226
|
+
const { chatInWallet } = useChatInWallet();
|
|
1172
1227
|
const sm = size === "sm";
|
|
1173
1228
|
let fontSize = sm ? 12 : 14;
|
|
1174
1229
|
let avatarSize = profileUse ? 24 : sm ? 40 : 48;
|
|
@@ -1194,12 +1249,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1194
1249
|
(_a2 = e == null ? void 0 : e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
1195
1250
|
(_b2 = e == null ? void 0 : e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
1196
1251
|
setOpen(false);
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1252
|
+
if (chatInWallet) {
|
|
1253
|
+
openProfileInNewTab(user == null ? void 0 : user.did);
|
|
1254
|
+
} else {
|
|
1255
|
+
setTimeout(() => {
|
|
1256
|
+
navigate(`/profile/${user == null ? void 0 : user.did}`);
|
|
1257
|
+
}, 100);
|
|
1258
|
+
}
|
|
1200
1259
|
};
|
|
1201
1260
|
const renderAvatar = () => {
|
|
1202
|
-
if (showProfileCard) {
|
|
1261
|
+
if (showProfileCard && !mobile.any) {
|
|
1203
1262
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1204
1263
|
HtmlTooltip$1,
|
|
1205
1264
|
{
|
|
@@ -3850,33 +3909,6 @@ var __publicField = (obj, key, value) => {
|
|
|
3850
3909
|
] })
|
|
3851
3910
|
] });
|
|
3852
3911
|
}
|
|
3853
|
-
const useChatInWallet = () => {
|
|
3854
|
-
const navigate = reactRouterDom.useNavigate();
|
|
3855
|
-
const { walletVersion, mobile } = reactHooks.useBrowser();
|
|
3856
|
-
const isChatInWalletV2 = react.useMemo(() => {
|
|
3857
|
-
try {
|
|
3858
|
-
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
3859
|
-
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
3860
|
-
} catch (e) {
|
|
3861
|
-
console.error(e);
|
|
3862
|
-
return false;
|
|
3863
|
-
}
|
|
3864
|
-
}, [walletVersion, mobile]);
|
|
3865
|
-
const navigateToChat = ({ id: id2, title }) => {
|
|
3866
|
-
if (isChatInWalletV2) {
|
|
3867
|
-
navigate(`/chat-in-wallet/${id2}`);
|
|
3868
|
-
} else {
|
|
3869
|
-
bridge.call("clickChat", { id: id2, title });
|
|
3870
|
-
}
|
|
3871
|
-
};
|
|
3872
|
-
const navigateToChatList = () => {
|
|
3873
|
-
navigate("/chat-in-wallet");
|
|
3874
|
-
};
|
|
3875
|
-
const updateUnreadState = react.useCallback((unread) => {
|
|
3876
|
-
bridge.call("updateUnreadState", { unread, appId: window.blocklet.appPid, timestamp: /* @__PURE__ */ new Date() });
|
|
3877
|
-
}, []);
|
|
3878
|
-
return { navigateToChat, navigateToChatList, isChatInWalletV2, updateUnreadState };
|
|
3879
|
-
};
|
|
3880
3912
|
function ChatList({ inWallet, ...rest }) {
|
|
3881
3913
|
const { t } = context.useLocaleContext();
|
|
3882
3914
|
const { orderedChats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages, getLastMessageText } = useChatContext();
|
|
@@ -4137,7 +4169,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4137
4169
|
return null;
|
|
4138
4170
|
};
|
|
4139
4171
|
const render = () => {
|
|
4140
|
-
var _a2, _b2,
|
|
4172
|
+
var _a2, _b2, _c2, _d;
|
|
4141
4173
|
const baseCardSx = {
|
|
4142
4174
|
py: 1.5,
|
|
4143
4175
|
px: 2,
|
|
@@ -4280,7 +4312,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4280
4312
|
]
|
|
4281
4313
|
}
|
|
4282
4314
|
),
|
|
4283
|
-
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((
|
|
4315
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
|
|
4284
4316
|
renderQuote(message.post)
|
|
4285
4317
|
]
|
|
4286
4318
|
}
|
|
@@ -4637,7 +4669,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4637
4669
|
if (editor2 && clearKey) {
|
|
4638
4670
|
editor2.update(() => {
|
|
4639
4671
|
const root = lexical$1.$getRoot();
|
|
4672
|
+
const paragraph = lexical$1.$createParagraphNode();
|
|
4640
4673
|
root.clear();
|
|
4674
|
+
root.append(paragraph);
|
|
4675
|
+
if (lexical$1.$getSelection() !== null) {
|
|
4676
|
+
paragraph.select();
|
|
4677
|
+
}
|
|
4641
4678
|
});
|
|
4642
4679
|
}
|
|
4643
4680
|
}, [editor2, clearKey]);
|
|
@@ -4656,6 +4693,39 @@ var __publicField = (obj, key, value) => {
|
|
|
4656
4693
|
const hasFocus = useIsFocused.useIsFocused();
|
|
4657
4694
|
const selection = editor2.getEditorState().read(lexical$1.$getSelection);
|
|
4658
4695
|
const enabled = mobile.any && hasFocus && selection;
|
|
4696
|
+
const detectSwipe = (node, callback) => {
|
|
4697
|
+
let touchstartY = 0;
|
|
4698
|
+
let touchendY = 0;
|
|
4699
|
+
function handleSwipe() {
|
|
4700
|
+
if (touchstartY - touchendY > 10 || touchendY - touchstartY > 10) {
|
|
4701
|
+
callback();
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
const onTouchStart = (event) => {
|
|
4705
|
+
touchstartY = event.changedTouches[0].screenY;
|
|
4706
|
+
};
|
|
4707
|
+
const onTouchEnd = (event) => {
|
|
4708
|
+
touchendY = event.changedTouches[0].screenY;
|
|
4709
|
+
handleSwipe();
|
|
4710
|
+
};
|
|
4711
|
+
node.addEventListener("touchstart", onTouchStart, false);
|
|
4712
|
+
node.addEventListener("touchend", onTouchEnd, false);
|
|
4713
|
+
return () => {
|
|
4714
|
+
node.removeEventListener("touchstart", onTouchStart, false);
|
|
4715
|
+
node.removeEventListener("touchend", onTouchEnd, false);
|
|
4716
|
+
};
|
|
4717
|
+
};
|
|
4718
|
+
react.useEffect(() => {
|
|
4719
|
+
const root = editor2.getRootElement();
|
|
4720
|
+
if (enabled && root) {
|
|
4721
|
+
const cleanup = [detectSwipe(document.body, () => editor2.blur()), detectSwipe(root, () => editor2.blur())];
|
|
4722
|
+
return () => {
|
|
4723
|
+
cleanup.forEach((fn) => fn());
|
|
4724
|
+
};
|
|
4725
|
+
}
|
|
4726
|
+
return () => {
|
|
4727
|
+
};
|
|
4728
|
+
}, [editor2, enabled]);
|
|
4659
4729
|
if (enabled) {
|
|
4660
4730
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4661
4731
|
material.Box,
|
|
@@ -4679,32 +4749,17 @@ var __publicField = (obj, key, value) => {
|
|
|
4679
4749
|
const [editor2] = LexicalComposerContext.useLexicalComposerContext();
|
|
4680
4750
|
const { mobile } = reactHooks.useBrowser();
|
|
4681
4751
|
react.useEffect(() => {
|
|
4682
|
-
let dispatching = false;
|
|
4683
4752
|
return editor2.registerCommand(
|
|
4684
4753
|
lexical$1.KEY_ENTER_COMMAND,
|
|
4685
4754
|
(e) => {
|
|
4686
|
-
if (
|
|
4687
|
-
dispatching = false;
|
|
4755
|
+
if (mobile.any || e.shiftKey) {
|
|
4688
4756
|
return false;
|
|
4689
4757
|
}
|
|
4690
|
-
if (e.shiftKey) {
|
|
4691
|
-
dispatching = true;
|
|
4692
|
-
const keyboardEvent = new KeyboardEvent("keydown", {
|
|
4693
|
-
code: "Enter",
|
|
4694
|
-
key: "Enter",
|
|
4695
|
-
charCode: 13,
|
|
4696
|
-
keyCode: 13,
|
|
4697
|
-
view: window,
|
|
4698
|
-
bubbles: true
|
|
4699
|
-
});
|
|
4700
|
-
e.preventDefault();
|
|
4701
|
-
editor2.dispatchCommand(lexical$1.KEY_ENTER_COMMAND, keyboardEvent);
|
|
4702
|
-
return true;
|
|
4703
|
-
}
|
|
4704
4758
|
callback();
|
|
4759
|
+
e.preventDefault();
|
|
4705
4760
|
return true;
|
|
4706
4761
|
},
|
|
4707
|
-
lexical$1.
|
|
4762
|
+
lexical$1.COMMAND_PRIORITY_LOW
|
|
4708
4763
|
);
|
|
4709
4764
|
}, [editor2, callback, mobile.any]);
|
|
4710
4765
|
return null;
|
|
@@ -4720,6 +4775,9 @@ var __publicField = (obj, key, value) => {
|
|
|
4720
4775
|
const [focused, setFocused] = react.useState(false);
|
|
4721
4776
|
const compactView = mobile.any && !focused;
|
|
4722
4777
|
const handleSend = () => {
|
|
4778
|
+
if (!content) {
|
|
4779
|
+
return;
|
|
4780
|
+
}
|
|
4723
4781
|
send(content);
|
|
4724
4782
|
setContent("");
|
|
4725
4783
|
setLastSent(Date.now());
|
|
@@ -4782,7 +4840,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4782
4840
|
children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: tablerSend, sx: { fontSize: 13, color: "text.secondary" } })
|
|
4783
4841
|
}
|
|
4784
4842
|
),
|
|
4785
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4843
|
+
/* @__PURE__ */ jsxRuntime.jsx(editor$1.EditorConfigProvider, { value: { minimalMode: true }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4786
4844
|
LazyEditor,
|
|
4787
4845
|
{
|
|
4788
4846
|
enableSaveAreaPlugin: false,
|
|
@@ -4802,7 +4860,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4802
4860
|
/* @__PURE__ */ jsxRuntime.jsx(FocusPlugin, { callback: (v2) => setFocused(v2) })
|
|
4803
4861
|
]
|
|
4804
4862
|
}
|
|
4805
|
-
)
|
|
4863
|
+
) })
|
|
4806
4864
|
]
|
|
4807
4865
|
}
|
|
4808
4866
|
),
|
|
@@ -4992,7 +5050,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4992
5050
|
]
|
|
4993
5051
|
}
|
|
4994
5052
|
),
|
|
4995
|
-
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(MessageList, { chat }) }),
|
|
5053
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(editor$1.EditorConfigProvider, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsxRuntime.jsx(MessageList, { chat }) }) }),
|
|
4996
5054
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { position: "relative" }, children: [
|
|
4997
5055
|
chat.isActivated && chat.type !== "notification" && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { px: { xs: 0, sm: 2.5 }, pb: { xs: 0, sm: 2.5 } }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4998
5056
|
ChatInput,
|
|
@@ -5447,17 +5505,28 @@ var __publicField = (obj, key, value) => {
|
|
|
5447
5505
|
] });
|
|
5448
5506
|
}
|
|
5449
5507
|
function ChatListInWallet({ sx, ...rest }) {
|
|
5508
|
+
var _a2, _b2, _c2, _d;
|
|
5450
5509
|
const { session } = useSessionContext();
|
|
5451
5510
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
5452
5511
|
const { unread } = useUnreadNotification();
|
|
5453
|
-
const { navigateToChatList, updateUnreadState } = useChatInWallet();
|
|
5512
|
+
const { navigateToChatList, updateUnreadState, isWebNavbar } = useChatInWallet();
|
|
5454
5513
|
react.useEffect(() => {
|
|
5455
5514
|
updateUnreadState(unread);
|
|
5456
5515
|
}, [unread, updateUnreadState]);
|
|
5457
5516
|
if (!initialized) {
|
|
5458
5517
|
return /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {});
|
|
5459
5518
|
}
|
|
5460
|
-
const mergedSx = [
|
|
5519
|
+
const mergedSx = [
|
|
5520
|
+
{
|
|
5521
|
+
display: "flex",
|
|
5522
|
+
height: "100%",
|
|
5523
|
+
bgcolor: "#fff",
|
|
5524
|
+
...((_a2 = window.chatInWallet) == null ? void 0 : _a2.safeAreaInsetTop) && {
|
|
5525
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5526
|
+
}
|
|
5527
|
+
},
|
|
5528
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
5529
|
+
];
|
|
5461
5530
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { ...rest, sx: mergedSx, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5462
5531
|
Box,
|
|
5463
5532
|
{
|
|
@@ -5469,24 +5538,54 @@ var __publicField = (obj, key, value) => {
|
|
|
5469
5538
|
},
|
|
5470
5539
|
children: [
|
|
5471
5540
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { flex: "0 0 auto", py: 1, px: 2 }, children: [
|
|
5472
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
{
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5541
|
+
!isWebNavbar && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5542
|
+
Box,
|
|
5543
|
+
{
|
|
5544
|
+
sx: {
|
|
5545
|
+
display: "flex",
|
|
5546
|
+
justifyContent: "space-between",
|
|
5547
|
+
alignItems: "center",
|
|
5548
|
+
mb: 1
|
|
5549
|
+
},
|
|
5550
|
+
children: [
|
|
5551
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5552
|
+
Box,
|
|
5553
|
+
{
|
|
5554
|
+
onClick: () => {
|
|
5555
|
+
bridge.call("switchApp");
|
|
5556
|
+
},
|
|
5557
|
+
sx: { display: "flex", alignItems: "center", gap: 1 },
|
|
5558
|
+
children: [
|
|
5559
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "img", src: window.blocklet.appLogo, alt: "", sx: { width: 20, height: 20 } }),
|
|
5560
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { typography: "h5", fontWeight: "bold" }, children: window.blocklet.appName }),
|
|
5561
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5562
|
+
Box,
|
|
5563
|
+
{
|
|
5564
|
+
component: tablerSwitchHorizontal,
|
|
5565
|
+
sx: { fontSize: 15, color: "grey.600", "& [stroke-width='2']": { strokeWidth: "2!important" } }
|
|
5566
|
+
}
|
|
5567
|
+
)
|
|
5568
|
+
]
|
|
5569
|
+
}
|
|
5570
|
+
),
|
|
5571
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5572
|
+
Avatar,
|
|
5573
|
+
{
|
|
5574
|
+
did: (_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did,
|
|
5575
|
+
src: (_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.avatar,
|
|
5576
|
+
size: 20,
|
|
5577
|
+
shape: "circle",
|
|
5578
|
+
variant: "circle",
|
|
5579
|
+
onClick: () => {
|
|
5580
|
+
var _a3;
|
|
5581
|
+
return openProfileInNewTab((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did);
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5584
|
+
)
|
|
5585
|
+
]
|
|
5586
|
+
}
|
|
5587
|
+
),
|
|
5588
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserSearch, {})
|
|
5490
5589
|
] }),
|
|
5491
5590
|
/* @__PURE__ */ jsxRuntime.jsx(material.Divider, {}),
|
|
5492
5591
|
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsxRuntime.jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
|
@@ -5501,7 +5600,19 @@ var __publicField = (obj, key, value) => {
|
|
|
5501
5600
|
onClose: () => navigateToChatList(),
|
|
5502
5601
|
onOpen: () => {
|
|
5503
5602
|
},
|
|
5504
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5603
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5604
|
+
Box,
|
|
5605
|
+
{
|
|
5606
|
+
sx: {
|
|
5607
|
+
width: 1,
|
|
5608
|
+
height: 1,
|
|
5609
|
+
...((_d = window.chatInWallet) == null ? void 0 : _d.safeAreaInsetTop) && {
|
|
5610
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5611
|
+
}
|
|
5612
|
+
},
|
|
5613
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
5614
|
+
}
|
|
5615
|
+
)
|
|
5505
5616
|
}
|
|
5506
5617
|
)
|
|
5507
5618
|
]
|
|
@@ -11558,14 +11669,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11558
11669
|
}
|
|
11559
11670
|
});
|
|
11560
11671
|
}
|
|
11561
|
-
function getWsClient(prefix2 = ((
|
|
11672
|
+
function getWsClient(prefix2 = ((_d) => (_d = window.blocklet) == null ? void 0 : _d.prefix)() || "/") {
|
|
11562
11673
|
if (!client) {
|
|
11563
11674
|
client = create(prefix2);
|
|
11564
11675
|
}
|
|
11565
11676
|
return client;
|
|
11566
11677
|
}
|
|
11567
11678
|
const useSubscription = (event, cb = () => {
|
|
11568
|
-
}, deps = [], prefix2 = ((
|
|
11679
|
+
}, deps = [], prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") => {
|
|
11569
11680
|
react.useEffect(() => {
|
|
11570
11681
|
if (event) {
|
|
11571
11682
|
if (!client) {
|
|
@@ -11632,7 +11743,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11632
11743
|
);
|
|
11633
11744
|
}
|
|
11634
11745
|
function PointUpProvider({ children }) {
|
|
11635
|
-
var _a2, _b2,
|
|
11746
|
+
var _a2, _b2, _c2, _d;
|
|
11636
11747
|
const state = ahooks.useReactive({
|
|
11637
11748
|
pointsList: [],
|
|
11638
11749
|
visible: false,
|
|
@@ -11643,7 +11754,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11643
11754
|
const pointUp = react.useCallback(({ points }) => {
|
|
11644
11755
|
state.pointsList.push(points);
|
|
11645
11756
|
}, []);
|
|
11646
|
-
const pointUpComponent = (
|
|
11757
|
+
const pointUpComponent = (_c2 = (_b2 = (_a2 = window.blocklet) == null ? void 0 : _a2.componentMountPoints) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(
|
|
11647
11758
|
_b2,
|
|
11648
11759
|
(item) => item.did === "z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA"
|
|
11649
11760
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-ux",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@arcblock/bridge": "^2.9.77",
|
|
32
32
|
"@arcblock/react-hooks": "^2.9.80",
|
|
33
33
|
"@arcblock/ws": "^1.18.116",
|
|
34
|
-
"@blocklet/editor": "2.0.
|
|
35
|
-
"@blocklet/labels": "2.0.
|
|
34
|
+
"@blocklet/editor": "2.0.4",
|
|
35
|
+
"@blocklet/labels": "2.0.4",
|
|
36
36
|
"@blocklet/uploader": "^0.1.2",
|
|
37
37
|
"@emotion/css": "^11.10.5",
|
|
38
38
|
"@emotion/react": "^11.10.5",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"react-lazy-with-preload": "^2.2.1",
|
|
53
53
|
"react-select": "^5.6.0",
|
|
54
54
|
"semver-compare": "^1.0.0",
|
|
55
|
+
"ufo": "^1.3.1",
|
|
55
56
|
"unstated-next": "^1.1.0",
|
|
56
57
|
"url-join": "^4.0.1"
|
|
57
58
|
},
|
|
@@ -99,5 +100,5 @@
|
|
|
99
100
|
"resolutions": {
|
|
100
101
|
"react": "^18.2.0"
|
|
101
102
|
},
|
|
102
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "6cf0a1ddf0aa7bfaadbf5b1b2ce85eceb3706841"
|
|
103
104
|
}
|