diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index 4ee3fec..52d2b55 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -14,7 +14,6 @@ import useAsyncEffect from "../useAsyncEffect.ts" import * as marked from 'marked' import DOMPurify from 'dompurify' import randomUUID from "../../randomUUID.ts" -import { time } from "node:console"; interface Args extends React.HTMLAttributes { target: string diff --git a/client/ui/chat/Message.tsx b/client/ui/chat/Message.tsx index d97bc64..6e4693b 100644 --- a/client/ui/chat/Message.tsx +++ b/client/ui/chat/Message.tsx @@ -1,4 +1,4 @@ -import { alert, Dropdown } from "mdui" +import { Dropdown, Dialog } from "mdui" import { $ } from "mdui/jq" import Client from "../../api/Client.ts" import Data_Message from "../../api/client_data/Message.ts" @@ -6,9 +6,11 @@ import DataCaches from "../../api/DataCaches.ts" import Avatar from "../Avatar.tsx" import copyToClipboard from "../copyToClipboard.ts" import useAsyncEffect from "../useAsyncEffect.ts" +import useEventListener from "../useEventListener.ts" import React from "react" import useEventListener from "../useEventListener.ts" import isMobileUI from "../isMobileUI.ts" +import ReactJson from 'react-json-view' interface Args extends React.HTMLAttributes { userId: string @@ -30,10 +32,23 @@ export default function Message({ userId, rawData, renderHTML, message, ...props }, [userId]) const dropDownRef = React.useRef(null) + const messageJsonDialogRef = React.useRef(null) + + const [isDropDownOpen, setDropDownOpen] = React.useState(false) return (
{ + if (isMobileUI()) return + e.preventDefault() + setDropDownOpen(!isDropDownOpen) + }} + onClick={(e) => { + if (!isMobileUI()) return + e.preventDefault() + setDropDownOpen(!isDropDownOpen) + }} style={{ width: "100%", display: "flex", @@ -88,7 +103,10 @@ export default function Message({ userId, rawData, renderHTML, message, ...props padding: "15px", alignSelf: isAtRight ? "flex-end" : "flex-start", }}> - + + + + - + e.stopPropagation()}> copyToClipboard($(dropDownRef.current as HTMLElement).find('#msg').text())}>複製文字 copyToClipboard(rawData)}>複製原文 - alert({ - headline: "消息详情", - description: JSON.stringify(message), - confirmText: "关闭", - onConfirm: () => { }, - })}>查看詳情 + messageJsonDialogRef.current.open = true}>查看詳情 diff --git a/client/ui/custom-elements/chat-image.ts b/client/ui/custom-elements/chat-image.ts index 9c28d06..0aae214 100644 --- a/client/ui/custom-elements/chat-image.ts +++ b/client/ui/custom-elements/chat-image.ts @@ -29,7 +29,8 @@ customElements.define('chat-image', class extends HTMLElement { }) } e.src = $(this).attr('src') as string - e.onclick = () => { + e.onclick = (event) => { + event.stopPropagation() openImageViewer($(this).attr('src') as string) } this.appendChild(e)