@blocklet/discuss-kit-ux 2.0.1 → 2.0.3
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/chat-input.d.ts +9 -0
- package/dist/components/chat/hooks.d.ts +1 -0
- package/dist/components/editor/editor.d.ts +3 -1
- package/dist/components/editor/index.d.ts +1 -1
- package/dist/components/locale/en.d.ts +1 -0
- package/dist/components/locale/index.d.ts +2 -0
- package/dist/components/locale/zh.d.ts +1 -0
- package/dist/{editor-D3RAcw2N.mjs → editor-BkMaHMub.mjs} +12 -4
- package/dist/{index-KLdzJyDb.mjs → index-CEuSe9YY.mjs} +390 -113
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +400 -117
- package/package.json +4 -4
|
@@ -14,13 +14,13 @@ import { Box, useTheme as useTheme$1, useMediaQuery, Tooltip as Tooltip$1, Chip
|
|
|
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 } from "lexical";
|
|
17
|
+
import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, COMMAND_PRIORITY_CRITICAL } from "lexical";
|
|
18
18
|
import { $isRootTextContentEmpty } from "@lexical/text";
|
|
19
19
|
import joinUrl from "url-join";
|
|
20
20
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
21
21
|
import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
|
|
22
22
|
import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
|
|
23
|
-
import { useSize, useInViewport, useSetState, useRequest, useGetState, useReactive } from "ahooks";
|
|
23
|
+
import { useSize, useInViewport, useSetState, useLocalStorageState, useRequest, useGetState, useReactive } from "ahooks";
|
|
24
24
|
import Box$1 from "@mui/material/Box";
|
|
25
25
|
import LoadingButton from "@mui/lab/LoadingButton";
|
|
26
26
|
import { Send, Save, ChatBubbleOutlineOutlined, MoreVert, NavigateNext, DeleteOutlineOutlined, ContentCopy, ArrowUpward, ArrowDownward, ArrowBackIos, Add, BorderColorOutlined } from "@mui/icons-material";
|
|
@@ -71,8 +71,10 @@ import bridge from "@arcblock/bridge";
|
|
|
71
71
|
import { useBrowser } from "@arcblock/react-hooks";
|
|
72
72
|
import Fab from "@mui/material/Fab";
|
|
73
73
|
import debounce from "lodash/debounce";
|
|
74
|
+
import { useIsFocused } from "@blocklet/editor/lib/main/hooks/useIsFocused";
|
|
74
75
|
import TextField from "@mui/material/TextField";
|
|
75
76
|
import AddIcon from "@mui/icons-material/Add";
|
|
77
|
+
import SessionManager from "@arcblock/did-connect/lib/SessionManager";
|
|
76
78
|
import { AxiosError } from "axios";
|
|
77
79
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
78
80
|
import MuiPagination from "@mui/material/Pagination";
|
|
@@ -507,7 +509,7 @@ function VideoPathFixerPlugin() {
|
|
|
507
509
|
}, [editor]);
|
|
508
510
|
return null;
|
|
509
511
|
}
|
|
510
|
-
function AutoClearPlugin({ value, isChanged }) {
|
|
512
|
+
function AutoClearPlugin$1({ value, isChanged }) {
|
|
511
513
|
const [editor] = useLexicalComposerContext();
|
|
512
514
|
useEffect(() => {
|
|
513
515
|
try {
|
|
@@ -655,7 +657,7 @@ const Input = ({
|
|
|
655
657
|
/* @__PURE__ */ jsx(CmdEnterShortcutPlugin, { shortcut, callback: handleCmdEnterPressed }),
|
|
656
658
|
/* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
|
|
657
659
|
/* @__PURE__ */ jsx(VideoPathFixerPlugin, {}),
|
|
658
|
-
/* @__PURE__ */ jsx(AutoClearPlugin, { value: content, isChanged: isChanged.current }),
|
|
660
|
+
/* @__PURE__ */ jsx(AutoClearPlugin$1, { value: content, isChanged: isChanged.current }),
|
|
659
661
|
children
|
|
660
662
|
]
|
|
661
663
|
}
|
|
@@ -3933,6 +3935,15 @@ const useChatInWallet = () => {
|
|
|
3933
3935
|
return false;
|
|
3934
3936
|
}
|
|
3935
3937
|
}, [walletVersion, mobile]);
|
|
3938
|
+
const isWebNavbar = useMemo(() => {
|
|
3939
|
+
try {
|
|
3940
|
+
const targetVersion = mobile.apple.device ? "5.4.6" : "5.4.4";
|
|
3941
|
+
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
3942
|
+
} catch (e) {
|
|
3943
|
+
console.error(e);
|
|
3944
|
+
return false;
|
|
3945
|
+
}
|
|
3946
|
+
}, [walletVersion, mobile]);
|
|
3936
3947
|
const navigateToChat = ({ id: id2, title }) => {
|
|
3937
3948
|
if (isChatInWalletV2) {
|
|
3938
3949
|
navigate(`/chat-in-wallet/${id2}`);
|
|
@@ -3946,7 +3957,7 @@ const useChatInWallet = () => {
|
|
|
3946
3957
|
const updateUnreadState = useCallback((unread) => {
|
|
3947
3958
|
bridge.call("updateUnreadState", { unread, appId: window.blocklet.appPid, timestamp: /* @__PURE__ */ new Date() });
|
|
3948
3959
|
}, []);
|
|
3949
|
-
return { navigateToChat, navigateToChatList, isChatInWalletV2, updateUnreadState };
|
|
3960
|
+
return { navigateToChat, navigateToChatList, isChatInWalletV2, isWebNavbar, updateUnreadState };
|
|
3950
3961
|
};
|
|
3951
3962
|
function ChatList({ inWallet, ...rest }) {
|
|
3952
3963
|
const { t } = useLocaleContext();
|
|
@@ -3991,6 +4002,7 @@ function ChatList({ inWallet, ...rest }) {
|
|
|
3991
4002
|
sx: {
|
|
3992
4003
|
position: "relative",
|
|
3993
4004
|
m: 1,
|
|
4005
|
+
mx: { xs: 0, sm: 1 },
|
|
3994
4006
|
py: 1.5,
|
|
3995
4007
|
px: 2,
|
|
3996
4008
|
fontWeight: "bold",
|
|
@@ -4062,7 +4074,6 @@ const Time = ({ createdAt }) => {
|
|
|
4062
4074
|
};
|
|
4063
4075
|
const baseItemSx = {
|
|
4064
4076
|
px: 1.25,
|
|
4065
|
-
py: 1,
|
|
4066
4077
|
transition: "all 120ms linear"
|
|
4067
4078
|
};
|
|
4068
4079
|
function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
@@ -4115,7 +4126,9 @@ function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
|
4115
4126
|
},
|
|
4116
4127
|
".author-info-title": {
|
|
4117
4128
|
fontSize: 14,
|
|
4118
|
-
fontWeight: 500
|
|
4129
|
+
fontWeight: 500,
|
|
4130
|
+
// username 下方首条消息的 margin-top
|
|
4131
|
+
"+ div": { mt: 1 }
|
|
4119
4132
|
},
|
|
4120
4133
|
".author-chat-item": {
|
|
4121
4134
|
ml: compactMessage ? 6 : 0,
|
|
@@ -4210,7 +4223,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
|
|
|
4210
4223
|
const baseCardSx = {
|
|
4211
4224
|
py: 1.5,
|
|
4212
4225
|
px: 2,
|
|
4213
|
-
|
|
4226
|
+
bgcolor: "grey.50",
|
|
4214
4227
|
width: "fit-content",
|
|
4215
4228
|
maxWidth: "calc(100% - 16px)",
|
|
4216
4229
|
wordWrap: "break-word",
|
|
@@ -4440,7 +4453,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
|
|
|
4440
4453
|
}
|
|
4441
4454
|
return /* @__PURE__ */ jsx(Message, { message, showTime: false });
|
|
4442
4455
|
};
|
|
4443
|
-
return /* @__PURE__ */ jsx(Box$1, { sx: { ...baseItemSx, fontSize: 14 }, children: render() });
|
|
4456
|
+
return /* @__PURE__ */ jsx(Box$1, { sx: { ...baseItemSx, py: 0.5, fontSize: 14 }, children: render() });
|
|
4444
4457
|
}
|
|
4445
4458
|
const checkIsAtBottom = (element) => {
|
|
4446
4459
|
return element && (element.scrollHeight === 0 || element.scrollHeight - element.scrollTop < element.clientHeight + 60);
|
|
@@ -4455,7 +4468,7 @@ function MessageList({ chat, ...rest }) {
|
|
|
4455
4468
|
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
4456
4469
|
const scrollToBottom = () => {
|
|
4457
4470
|
var _a3, _b3;
|
|
4458
|
-
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0
|
|
4471
|
+
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0 });
|
|
4459
4472
|
setIsAtBottom(true);
|
|
4460
4473
|
};
|
|
4461
4474
|
useEffect(() => {
|
|
@@ -4490,7 +4503,6 @@ function MessageList({ chat, ...rest }) {
|
|
|
4490
4503
|
py: 2.5,
|
|
4491
4504
|
px: 1.25,
|
|
4492
4505
|
gap: 1,
|
|
4493
|
-
background: "rgba(249, 250, 251, 1)",
|
|
4494
4506
|
// 闪烁
|
|
4495
4507
|
"@keyframes blinking": {
|
|
4496
4508
|
"0%": { opacity: 0 },
|
|
@@ -4665,6 +4677,270 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
|
4665
4677
|
}
|
|
4666
4678
|
);
|
|
4667
4679
|
}
|
|
4680
|
+
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" }) });
|
|
4681
|
+
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" }) });
|
|
4682
|
+
const Editor = lazy(() => import("./editor-BkMaHMub.mjs"));
|
|
4683
|
+
function LazyEditor(props) {
|
|
4684
|
+
const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
|
|
4685
|
+
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
4686
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "80%" }),
|
|
4687
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "60%" }),
|
|
4688
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "40%" })
|
|
4689
|
+
] });
|
|
4690
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: fallback2, children: /* @__PURE__ */ jsx(Editor, { ...props }) });
|
|
4691
|
+
}
|
|
4692
|
+
const BlockletEditor = lazy(() => import("@blocklet/editor"));
|
|
4693
|
+
const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4694
|
+
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
4695
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "80%" }),
|
|
4696
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "60%" }),
|
|
4697
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "40%" })
|
|
4698
|
+
] });
|
|
4699
|
+
function EditorPreview({ content, children, ...rest }) {
|
|
4700
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsxs(
|
|
4701
|
+
BlockletEditor,
|
|
4702
|
+
{
|
|
4703
|
+
editorState: inferInitialEditorState(content),
|
|
4704
|
+
editable: false,
|
|
4705
|
+
enableHeadingsIdPlugin: true,
|
|
4706
|
+
...rest,
|
|
4707
|
+
children: [
|
|
4708
|
+
/* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
|
|
4709
|
+
/* @__PURE__ */ jsx(VideoPathFixerPlugin, {}),
|
|
4710
|
+
children
|
|
4711
|
+
]
|
|
4712
|
+
}
|
|
4713
|
+
) });
|
|
4714
|
+
}
|
|
4715
|
+
EditorPreview.fallback = fallback;
|
|
4716
|
+
function AutoClearPlugin({ clearKey }) {
|
|
4717
|
+
const [editor] = useLexicalComposerContext();
|
|
4718
|
+
useEffect(() => {
|
|
4719
|
+
if (editor && clearKey) {
|
|
4720
|
+
editor.update(() => {
|
|
4721
|
+
const root = $getRoot();
|
|
4722
|
+
root.clear();
|
|
4723
|
+
});
|
|
4724
|
+
}
|
|
4725
|
+
}, [editor, clearKey]);
|
|
4726
|
+
return null;
|
|
4727
|
+
}
|
|
4728
|
+
function FocusPlugin({ callback }) {
|
|
4729
|
+
const hasFocus = useIsFocused();
|
|
4730
|
+
useEffect(() => {
|
|
4731
|
+
callback(hasFocus);
|
|
4732
|
+
}, [callback, hasFocus]);
|
|
4733
|
+
return null;
|
|
4734
|
+
}
|
|
4735
|
+
function DraggerPlugin() {
|
|
4736
|
+
const [editor] = useLexicalComposerContext();
|
|
4737
|
+
const { mobile } = useBrowser();
|
|
4738
|
+
const hasFocus = useIsFocused();
|
|
4739
|
+
const selection = editor.getEditorState().read($getSelection);
|
|
4740
|
+
const enabled = mobile.any && hasFocus && selection;
|
|
4741
|
+
if (enabled) {
|
|
4742
|
+
return /* @__PURE__ */ jsx(
|
|
4743
|
+
Box,
|
|
4744
|
+
{
|
|
4745
|
+
sx: {
|
|
4746
|
+
position: "absolute",
|
|
4747
|
+
left: "50%",
|
|
4748
|
+
top: 4,
|
|
4749
|
+
width: 64,
|
|
4750
|
+
marginLeft: "-32px",
|
|
4751
|
+
height: 4,
|
|
4752
|
+
bgcolor: "grey.300",
|
|
4753
|
+
borderRadius: 0.1
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
);
|
|
4757
|
+
}
|
|
4758
|
+
return null;
|
|
4759
|
+
}
|
|
4760
|
+
function ShortcutPlugin({ callback }) {
|
|
4761
|
+
const [editor] = useLexicalComposerContext();
|
|
4762
|
+
const { mobile } = useBrowser();
|
|
4763
|
+
useEffect(() => {
|
|
4764
|
+
let dispatching = false;
|
|
4765
|
+
return editor.registerCommand(
|
|
4766
|
+
KEY_ENTER_COMMAND,
|
|
4767
|
+
(e) => {
|
|
4768
|
+
if (dispatching || mobile.any) {
|
|
4769
|
+
dispatching = false;
|
|
4770
|
+
return false;
|
|
4771
|
+
}
|
|
4772
|
+
if (e.shiftKey) {
|
|
4773
|
+
dispatching = true;
|
|
4774
|
+
const keyboardEvent = new KeyboardEvent("keydown", {
|
|
4775
|
+
code: "Enter",
|
|
4776
|
+
key: "Enter",
|
|
4777
|
+
charCode: 13,
|
|
4778
|
+
keyCode: 13,
|
|
4779
|
+
view: window,
|
|
4780
|
+
bubbles: true
|
|
4781
|
+
});
|
|
4782
|
+
e.preventDefault();
|
|
4783
|
+
editor.dispatchCommand(KEY_ENTER_COMMAND, keyboardEvent);
|
|
4784
|
+
return true;
|
|
4785
|
+
}
|
|
4786
|
+
callback();
|
|
4787
|
+
return true;
|
|
4788
|
+
},
|
|
4789
|
+
COMMAND_PRIORITY_CRITICAL
|
|
4790
|
+
);
|
|
4791
|
+
}, [editor, callback, mobile.any]);
|
|
4792
|
+
return null;
|
|
4793
|
+
}
|
|
4794
|
+
function ChatInput({ initialContent, send, onContentChange }) {
|
|
4795
|
+
const { t } = useLocaleContext();
|
|
4796
|
+
const [content, setContent] = useState("");
|
|
4797
|
+
const [lastSent, setLastSent] = useState(0);
|
|
4798
|
+
const [toolbarVisible, setToolbarVisible] = useLocalStorageState("chat-input-toolbar-visible", {
|
|
4799
|
+
defaultValue: false
|
|
4800
|
+
});
|
|
4801
|
+
const { mobile } = useBrowser();
|
|
4802
|
+
const [focused, setFocused] = useState(false);
|
|
4803
|
+
const compactView = mobile.any && !focused;
|
|
4804
|
+
const handleSend = () => {
|
|
4805
|
+
send(content);
|
|
4806
|
+
setContent("");
|
|
4807
|
+
setLastSent(Date.now());
|
|
4808
|
+
};
|
|
4809
|
+
return /* @__PURE__ */ jsxs(
|
|
4810
|
+
Box,
|
|
4811
|
+
{
|
|
4812
|
+
sx: {
|
|
4813
|
+
position: "relative",
|
|
4814
|
+
pb: 5,
|
|
4815
|
+
border: 1,
|
|
4816
|
+
borderColor: "divider",
|
|
4817
|
+
borderRadius: 1,
|
|
4818
|
+
overflow: "hidden",
|
|
4819
|
+
".be-shell": { borderTop: "0 !important" },
|
|
4820
|
+
".be-shell .toolbar": { bgcolor: "grey.50", ...!toolbarVisible && { display: "none" } },
|
|
4821
|
+
".be-shell .be-editable": { px: "16px !important" },
|
|
4822
|
+
".be-shell .be-placeholder": { left: 16 },
|
|
4823
|
+
".be-shell .be-editable, .be-shell .be-content": { minHeight: "20px !important" },
|
|
4824
|
+
".be-shell .be-editable p": { my: 0 },
|
|
4825
|
+
".draggable-block-menu": { display: "none" },
|
|
4826
|
+
...compactView && {
|
|
4827
|
+
pb: 0,
|
|
4828
|
+
borderRadius: 2,
|
|
4829
|
+
borderBottomLeftRadius: 0,
|
|
4830
|
+
borderBottomRightRadius: 0
|
|
4831
|
+
}
|
|
4832
|
+
},
|
|
4833
|
+
children: [
|
|
4834
|
+
/* @__PURE__ */ jsxs(
|
|
4835
|
+
Box,
|
|
4836
|
+
{
|
|
4837
|
+
sx: {
|
|
4838
|
+
maxHeight: 400,
|
|
4839
|
+
overflowY: "auto",
|
|
4840
|
+
...compactView && {
|
|
4841
|
+
height: 44 + (toolbarVisible ? 44 : 0),
|
|
4842
|
+
pt: toolbarVisible ? 0 : 0.5,
|
|
4843
|
+
pb: 0.5,
|
|
4844
|
+
overflow: "hidden",
|
|
4845
|
+
".be-shell .be-editable": { pr: "44px !important" }
|
|
4846
|
+
}
|
|
4847
|
+
},
|
|
4848
|
+
children: [
|
|
4849
|
+
compactView && !toolbarVisible && /* @__PURE__ */ jsx(
|
|
4850
|
+
Box,
|
|
4851
|
+
{
|
|
4852
|
+
sx: {
|
|
4853
|
+
position: "absolute",
|
|
4854
|
+
right: 12,
|
|
4855
|
+
top: 12,
|
|
4856
|
+
display: "flex",
|
|
4857
|
+
justifyContent: "center",
|
|
4858
|
+
alignItems: "center",
|
|
4859
|
+
width: 28,
|
|
4860
|
+
height: 28,
|
|
4861
|
+
bgcolor: "grey.300",
|
|
4862
|
+
borderRadius: "100%"
|
|
4863
|
+
},
|
|
4864
|
+
children: /* @__PURE__ */ jsx(Box, { component: tablerSend, sx: { fontSize: 13, color: "text.secondary" } })
|
|
4865
|
+
}
|
|
4866
|
+
),
|
|
4867
|
+
/* @__PURE__ */ jsxs(
|
|
4868
|
+
LazyEditor,
|
|
4869
|
+
{
|
|
4870
|
+
enableSaveAreaPlugin: false,
|
|
4871
|
+
initialContent: initialContent || "",
|
|
4872
|
+
onChange: ({ content: contentStr, isEmpty }) => {
|
|
4873
|
+
const value = isEmpty ? "" : contentStr;
|
|
4874
|
+
setContent(value);
|
|
4875
|
+
onContentChange == null ? void 0 : onContentChange(value);
|
|
4876
|
+
},
|
|
4877
|
+
autoFocus: false,
|
|
4878
|
+
ignoreInitialChange: false,
|
|
4879
|
+
placeholder: "Jot something down",
|
|
4880
|
+
children: [
|
|
4881
|
+
/* @__PURE__ */ jsx(AutoClearPlugin, { clearKey: lastSent }),
|
|
4882
|
+
/* @__PURE__ */ jsx(ShortcutPlugin, { callback: handleSend }),
|
|
4883
|
+
/* @__PURE__ */ jsx(DraggerPlugin, {}),
|
|
4884
|
+
/* @__PURE__ */ jsx(FocusPlugin, { callback: (v2) => setFocused(v2) })
|
|
4885
|
+
]
|
|
4886
|
+
}
|
|
4887
|
+
)
|
|
4888
|
+
]
|
|
4889
|
+
}
|
|
4890
|
+
),
|
|
4891
|
+
/* @__PURE__ */ jsxs(
|
|
4892
|
+
Box,
|
|
4893
|
+
{
|
|
4894
|
+
sx: {
|
|
4895
|
+
display: "flex",
|
|
4896
|
+
justifyContent: "space-between",
|
|
4897
|
+
alignItems: "center",
|
|
4898
|
+
position: "absolute",
|
|
4899
|
+
left: 0,
|
|
4900
|
+
right: 0,
|
|
4901
|
+
bottom: 0,
|
|
4902
|
+
height: 40,
|
|
4903
|
+
p: 1,
|
|
4904
|
+
...compactView && { display: "none" }
|
|
4905
|
+
},
|
|
4906
|
+
children: [
|
|
4907
|
+
/* @__PURE__ */ jsx(
|
|
4908
|
+
Button$1,
|
|
4909
|
+
{
|
|
4910
|
+
size: "small",
|
|
4911
|
+
color: "primary",
|
|
4912
|
+
variant: "text",
|
|
4913
|
+
onClick: () => setToolbarVisible((x) => !x),
|
|
4914
|
+
startIcon: /* @__PURE__ */ jsx(Box, { component: tablerLetterCase, sx: { fontSize: "14px !important" } }),
|
|
4915
|
+
sx: {
|
|
4916
|
+
width: 32,
|
|
4917
|
+
height: 28,
|
|
4918
|
+
minWidth: 0,
|
|
4919
|
+
".MuiButton-startIcon": { m: 0, color: "text.secondary" },
|
|
4920
|
+
...toolbarVisible && { bgcolor: "grey.200" }
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
),
|
|
4924
|
+
/* @__PURE__ */ jsx(
|
|
4925
|
+
Button$1,
|
|
4926
|
+
{
|
|
4927
|
+
size: "small",
|
|
4928
|
+
color: "primary",
|
|
4929
|
+
variant: "contained",
|
|
4930
|
+
disabled: !content,
|
|
4931
|
+
onClick: handleSend,
|
|
4932
|
+
startIcon: /* @__PURE__ */ jsx(Box, { component: tablerSend, sx: { fontSize: "14px !important" } }),
|
|
4933
|
+
sx: { height: 28 },
|
|
4934
|
+
children: t("chat.send")
|
|
4935
|
+
}
|
|
4936
|
+
)
|
|
4937
|
+
]
|
|
4938
|
+
}
|
|
4939
|
+
)
|
|
4940
|
+
]
|
|
4941
|
+
}
|
|
4942
|
+
);
|
|
4943
|
+
}
|
|
4668
4944
|
function getLineClamp(count) {
|
|
4669
4945
|
return {
|
|
4670
4946
|
display: "-webkit-box",
|
|
@@ -4688,7 +4964,7 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
4688
4964
|
const isActive = isActiveChat(chat.id);
|
|
4689
4965
|
const { session, isAdmin } = useSessionContext();
|
|
4690
4966
|
const isCreator = chat.creator.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
4691
|
-
const [input, setInput] =
|
|
4967
|
+
const [input, setInput] = useLocalStorageState(`chat-input-${chat.id}`, { defaultValue: "" });
|
|
4692
4968
|
useEffect(() => {
|
|
4693
4969
|
if (chat.isActivated) {
|
|
4694
4970
|
initChatRoom(chat.id);
|
|
@@ -4710,7 +4986,10 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
4710
4986
|
}
|
|
4711
4987
|
if (chat.type === "dm") {
|
|
4712
4988
|
const oppositeUser = getOppositeUser(chat);
|
|
4713
|
-
return /* @__PURE__ */
|
|
4989
|
+
return /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
4990
|
+
/* @__PURE__ */ jsx(Avatar, { did: oppositeUser == null ? void 0 : oppositeUser.did, src: oppositeUser == null ? void 0 : oppositeUser.avatar, size: 24, shape: "circle", variant: "rounded" }),
|
|
4991
|
+
/* @__PURE__ */ jsx(RoomTitle, { title: oppositeUser.fullName })
|
|
4992
|
+
] });
|
|
4714
4993
|
}
|
|
4715
4994
|
if (chat.type === "channel") {
|
|
4716
4995
|
const menuItems = [];
|
|
@@ -4795,66 +5074,41 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
4795
5074
|
]
|
|
4796
5075
|
}
|
|
4797
5076
|
),
|
|
4798
|
-
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden"
|
|
4799
|
-
/* @__PURE__ */
|
|
4800
|
-
Box$1,
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
{
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
bottom: 0,
|
|
4834
|
-
bgcolor: "rgba(255, 255, 255, 0.7)",
|
|
4835
|
-
display: "flex",
|
|
4836
|
-
flexDirection: "column",
|
|
4837
|
-
alignItems: "center",
|
|
4838
|
-
justifyContent: "center",
|
|
4839
|
-
color: "#fff"
|
|
4840
|
-
},
|
|
4841
|
-
children: [
|
|
4842
|
-
/* @__PURE__ */ jsx(Box$1, { sx: { mb: 0.5, fontSize: 18 }, children: "🚪" }),
|
|
4843
|
-
/* @__PURE__ */ jsx(Box$1, { sx: { color: "primary.main", mb: 0.5, fontSize: 13, fontWeight: 500 }, children: t("chat.notYetJoinedTheChannel") }),
|
|
4844
|
-
/* @__PURE__ */ jsx(
|
|
4845
|
-
Box$1,
|
|
4846
|
-
{
|
|
4847
|
-
sx: { color: "secondary.main", cursor: "pointer", fontSize: 13 },
|
|
4848
|
-
onClick: () => joinChannel(chat.id),
|
|
4849
|
-
children: t("chat.joinChannel")
|
|
4850
|
-
}
|
|
4851
|
-
)
|
|
4852
|
-
]
|
|
4853
|
-
}
|
|
4854
|
-
)
|
|
4855
|
-
] })
|
|
4856
|
-
}
|
|
4857
|
-
)
|
|
5077
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(MessageList, { chat }) }),
|
|
5078
|
+
/* @__PURE__ */ jsxs(Box$1, { sx: { position: "relative" }, children: [
|
|
5079
|
+
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(
|
|
5080
|
+
ChatInput,
|
|
5081
|
+
{
|
|
5082
|
+
initialContent: input,
|
|
5083
|
+
onContentChange: (v2) => setInput(v2),
|
|
5084
|
+
send: (content) => sendMessage(chat.id, content)
|
|
5085
|
+
}
|
|
5086
|
+
) }),
|
|
5087
|
+
chat.type === "channel" && !chat.hasJoined && /* @__PURE__ */ jsxs(
|
|
5088
|
+
Box$1,
|
|
5089
|
+
{
|
|
5090
|
+
sx: {
|
|
5091
|
+
position: "absolute",
|
|
5092
|
+
zIndex: 9999999,
|
|
5093
|
+
top: 0,
|
|
5094
|
+
left: 0,
|
|
5095
|
+
right: 0,
|
|
5096
|
+
bottom: 0,
|
|
5097
|
+
bgcolor: "rgba(255, 255, 255, 0.7)",
|
|
5098
|
+
display: "flex",
|
|
5099
|
+
flexDirection: "column",
|
|
5100
|
+
alignItems: "center",
|
|
5101
|
+
justifyContent: "center",
|
|
5102
|
+
color: "#fff"
|
|
5103
|
+
},
|
|
5104
|
+
children: [
|
|
5105
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { mb: 0.5, fontSize: 18 }, children: "🚪" }),
|
|
5106
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { color: "primary.main", mb: 0.5, fontSize: 13, fontWeight: 500 }, children: t("chat.notYetJoinedTheChannel") }),
|
|
5107
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { color: "secondary.main", cursor: "pointer", fontSize: 13 }, onClick: () => joinChannel(chat.id), children: t("chat.joinChannel") })
|
|
5108
|
+
]
|
|
5109
|
+
}
|
|
5110
|
+
)
|
|
5111
|
+
] })
|
|
4858
5112
|
] });
|
|
4859
5113
|
}
|
|
4860
5114
|
function NewChannelDialog({ open, onSubmit, onClose, ...rest }) {
|
|
@@ -5255,6 +5509,7 @@ function ChatInWallet({ sx, ...rest }) {
|
|
|
5255
5509
|
!activeChatId && /* @__PURE__ */ jsx(Empty$1, { sx: { height: 1 } })
|
|
5256
5510
|
] }) });
|
|
5257
5511
|
}
|
|
5512
|
+
const tablerSwitchHorizontal = (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: "m16 3l4 4l-4 4m-6-4h10M8 13l-4 4l4 4m-4-4h9" }) });
|
|
5258
5513
|
function Empty({ sx }) {
|
|
5259
5514
|
const { t } = useLocaleContext();
|
|
5260
5515
|
const mergedSx = [
|
|
@@ -5274,16 +5529,28 @@ function Empty({ sx }) {
|
|
|
5274
5529
|
] });
|
|
5275
5530
|
}
|
|
5276
5531
|
function ChatListInWallet({ sx, ...rest }) {
|
|
5532
|
+
var _a2, _b2;
|
|
5533
|
+
const { session } = useSessionContext();
|
|
5277
5534
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
5278
5535
|
const { unread } = useUnreadNotification();
|
|
5279
|
-
const { navigateToChatList, updateUnreadState } = useChatInWallet();
|
|
5536
|
+
const { navigateToChatList, updateUnreadState, isWebNavbar } = useChatInWallet();
|
|
5280
5537
|
useEffect(() => {
|
|
5281
5538
|
updateUnreadState(unread);
|
|
5282
5539
|
}, [unread, updateUnreadState]);
|
|
5283
5540
|
if (!initialized) {
|
|
5284
5541
|
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
5285
5542
|
}
|
|
5286
|
-
const mergedSx = [
|
|
5543
|
+
const mergedSx = [
|
|
5544
|
+
{
|
|
5545
|
+
display: "flex",
|
|
5546
|
+
height: "100%",
|
|
5547
|
+
bgcolor: "#fff",
|
|
5548
|
+
...((_a2 = window.chatInWallet) == null ? void 0 : _a2.safeAreaInsetTop) && {
|
|
5549
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5550
|
+
}
|
|
5551
|
+
},
|
|
5552
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
5553
|
+
];
|
|
5287
5554
|
return /* @__PURE__ */ jsx(Box$1, { ...rest, sx: mergedSx, children: /* @__PURE__ */ jsxs(
|
|
5288
5555
|
Box$1,
|
|
5289
5556
|
{
|
|
@@ -5294,7 +5561,37 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5294
5561
|
borderRight: { sm: "1px solid #e5e5e5" }
|
|
5295
5562
|
},
|
|
5296
5563
|
children: [
|
|
5297
|
-
/* @__PURE__ */
|
|
5564
|
+
/* @__PURE__ */ jsxs(Box$1, { sx: { flex: "0 0 auto", py: 1, px: 2 }, children: [
|
|
5565
|
+
isWebNavbar && /* @__PURE__ */ jsxs(
|
|
5566
|
+
Box$1,
|
|
5567
|
+
{
|
|
5568
|
+
sx: {
|
|
5569
|
+
display: "flex",
|
|
5570
|
+
justifyContent: "space-between",
|
|
5571
|
+
mr: -1,
|
|
5572
|
+
mb: 1
|
|
5573
|
+
},
|
|
5574
|
+
children: [
|
|
5575
|
+
/* @__PURE__ */ jsxs(
|
|
5576
|
+
Box$1,
|
|
5577
|
+
{
|
|
5578
|
+
onClick: () => {
|
|
5579
|
+
bridge.call("switchApp");
|
|
5580
|
+
},
|
|
5581
|
+
sx: { display: "flex", alignItems: "center", gap: 1 },
|
|
5582
|
+
children: [
|
|
5583
|
+
/* @__PURE__ */ jsx(Box$1, { component: "img", src: window.blocklet.appLogo, alt: "", sx: { width: 20, height: 20 } }),
|
|
5584
|
+
/* @__PURE__ */ jsx(Box$1, { component: "span", sx: { typography: "h5", fontWeight: "medium" }, children: window.blocklet.appName }),
|
|
5585
|
+
/* @__PURE__ */ jsx(Box$1, { component: tablerSwitchHorizontal, sx: { fontSize: 15, color: "grey.600" } })
|
|
5586
|
+
]
|
|
5587
|
+
}
|
|
5588
|
+
),
|
|
5589
|
+
/* @__PURE__ */ jsx(SessionManager, { style: { padding: 0 }, showText: true, showRole: true, session })
|
|
5590
|
+
]
|
|
5591
|
+
}
|
|
5592
|
+
),
|
|
5593
|
+
/* @__PURE__ */ jsx(UserSearch, {})
|
|
5594
|
+
] }),
|
|
5298
5595
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
5299
5596
|
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
|
5300
5597
|
!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(Empty, { sx: { flex: 1 } }),
|
|
@@ -5308,7 +5605,19 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5308
5605
|
onClose: () => navigateToChatList(),
|
|
5309
5606
|
onOpen: () => {
|
|
5310
5607
|
},
|
|
5311
|
-
children: /* @__PURE__ */ jsx(
|
|
5608
|
+
children: /* @__PURE__ */ jsx(
|
|
5609
|
+
Box$1,
|
|
5610
|
+
{
|
|
5611
|
+
sx: {
|
|
5612
|
+
width: 1,
|
|
5613
|
+
height: 1,
|
|
5614
|
+
...((_b2 = window.chatInWallet) == null ? void 0 : _b2.safeAreaInsetTop) && {
|
|
5615
|
+
pt: `${window.chatInWallet.safeAreaInsetTop}px`
|
|
5616
|
+
}
|
|
5617
|
+
},
|
|
5618
|
+
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
5619
|
+
}
|
|
5620
|
+
)
|
|
5312
5621
|
}
|
|
5313
5622
|
)
|
|
5314
5623
|
]
|
|
@@ -5607,40 +5916,6 @@ function Pagination({
|
|
|
5607
5916
|
}
|
|
5608
5917
|
);
|
|
5609
5918
|
}
|
|
5610
|
-
const Editor = lazy(() => import("./editor-D3RAcw2N.mjs"));
|
|
5611
|
-
function LazyEditor(props) {
|
|
5612
|
-
const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
|
|
5613
|
-
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
5614
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "80%" }),
|
|
5615
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "60%" }),
|
|
5616
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "40%" })
|
|
5617
|
-
] });
|
|
5618
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: fallback2, children: /* @__PURE__ */ jsx(Editor, { ...props }) });
|
|
5619
|
-
}
|
|
5620
|
-
const BlockletEditor = lazy(() => import("@blocklet/editor"));
|
|
5621
|
-
const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5622
|
-
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
5623
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "80%" }),
|
|
5624
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "60%" }),
|
|
5625
|
-
/* @__PURE__ */ jsx(Skeleton, { width: "40%" })
|
|
5626
|
-
] });
|
|
5627
|
-
function EditorPreview({ content, children, ...rest }) {
|
|
5628
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsxs(
|
|
5629
|
-
BlockletEditor,
|
|
5630
|
-
{
|
|
5631
|
-
editorState: inferInitialEditorState(content),
|
|
5632
|
-
editable: false,
|
|
5633
|
-
enableHeadingsIdPlugin: true,
|
|
5634
|
-
...rest,
|
|
5635
|
-
children: [
|
|
5636
|
-
/* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
|
|
5637
|
-
/* @__PURE__ */ jsx(VideoPathFixerPlugin, {}),
|
|
5638
|
-
children
|
|
5639
|
-
]
|
|
5640
|
-
}
|
|
5641
|
-
) });
|
|
5642
|
-
}
|
|
5643
|
-
EditorPreview.fallback = fallback;
|
|
5644
5919
|
const useBeforeUnloadPrompt = (dirty) => {
|
|
5645
5920
|
useEffect(() => {
|
|
5646
5921
|
const showPrompt = (e) => {
|
|
@@ -5806,7 +6081,8 @@ const en = {
|
|
|
5806
6081
|
pointUp: "🎉 You got {points} {unit} {event}",
|
|
5807
6082
|
loadMore: "Load older messages",
|
|
5808
6083
|
notYetJoinedTheChannel: "Not yet joined the channel",
|
|
5809
|
-
typeSomething: "Type here. Use Markdown, Drag or paste images"
|
|
6084
|
+
typeSomething: "Type here. Use Markdown, Drag or paste images",
|
|
6085
|
+
send: "Send"
|
|
5810
6086
|
}
|
|
5811
6087
|
};
|
|
5812
6088
|
const zh = {
|
|
@@ -5886,7 +6162,8 @@ const zh = {
|
|
|
5886
6162
|
pointUp: "🎉 您获得了 {points} {unit} {event}",
|
|
5887
6163
|
loadMore: "加载更多消息",
|
|
5888
6164
|
notYetJoinedTheChannel: "暂未加入这个频道",
|
|
5889
|
-
typeSomething: "在这里输入,适用 MarkDown,拽入或者黏贴图片"
|
|
6165
|
+
typeSomething: "在这里输入,适用 MarkDown,拽入或者黏贴图片",
|
|
6166
|
+
send: "发送"
|
|
5890
6167
|
}
|
|
5891
6168
|
};
|
|
5892
6169
|
const translations = { zh, en };
|