fix: allow copying message stream text

This commit is contained in:
TerryM
2026-05-26 18:03:07 +08:00
parent 625d9fbb42
commit e0629c9df7
8 changed files with 24 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ export function AlbumBubble({ post }: { post: Post }) {
</button> </button>
))} ))}
{text ? ( {text ? (
<div className="whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100"> <div className="message-stream-copyable-text select-text whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100">
{autolink(text)} {autolink(text)}
</div> </div>
) : null} ) : null}
@@ -80,7 +80,7 @@ export function AlbumBubble({ post }: { post: Post }) {
})} })}
</div> </div>
{text ? ( {text ? (
<div className="whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100"> <div className="message-stream-copyable-text select-text whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100">
{autolink(text)} {autolink(text)}
</div> </div>
) : null} ) : null}

View File

@@ -63,7 +63,7 @@ export function FileDocBubble({ post }: { post: Post }) {
<AttachmentRow key={att.id} postId={post.id} att={att} /> <AttachmentRow key={att.id} postId={post.id} att={att} />
))} ))}
{text ? ( {text ? (
<div className="mt-1 whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100"> <div className="message-stream-copyable-text mt-1 select-text whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100">
{text} {text}
</div> </div>
) : null} ) : null}

View File

@@ -31,7 +31,7 @@ export function ImageWithTextBubble({ post }: { post: Post }) {
</button> </button>
{text ? ( {text ? (
<div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/85 via-black/55 to-transparent px-4 pb-4 pt-16 text-[14px] leading-snug text-neutral-100"> <div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/85 via-black/55 to-transparent px-4 pb-4 pt-16 text-[14px] leading-snug text-neutral-100">
<div className="whitespace-pre-wrap break-words"> <div className="message-stream-copyable-text select-text whitespace-pre-wrap break-words">
{autolink(text)} {autolink(text)}
</div> </div>
</div> </div>

View File

@@ -6,7 +6,7 @@ import { postDisplayText } from "../utils/postText";
export function TextBubble({ post }: { post: Post }) { export function TextBubble({ post }: { post: Post }) {
const { lang } = useI18n(); const { lang } = useI18n();
return ( return (
<div className="whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100"> <div className="message-stream-copyable-text select-text whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100">
{autolink(postDisplayText(post, lang))} {autolink(postDisplayText(post, lang))}
</div> </div>
); );

View File

@@ -112,7 +112,7 @@ export function VideoBubble({ post }: { post: Post }) {
)} )}
</div> </div>
{text ? ( {text ? (
<div className="whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100"> <div className="message-stream-copyable-text select-text whitespace-pre-wrap break-words text-[14px] leading-snug text-neutral-100">
{autolink(text)} {autolink(text)}
</div> </div>
) : null} ) : null}

View File

@@ -210,7 +210,7 @@ function LightboxView({
/> />
{caption ? ( {caption ? (
<div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/90 via-black/60 to-transparent px-4 pb-4 pt-12 text-sm leading-snug text-white sm:px-5 sm:pb-5"> <div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/90 via-black/60 to-transparent px-4 pb-4 pt-12 text-sm leading-snug text-white sm:px-5 sm:pb-5">
<div className="max-h-[32vh] overflow-y-auto whitespace-pre-wrap break-words"> <div className="message-stream-copyable-text max-h-[32vh] overflow-y-auto whitespace-pre-wrap break-words">
{autolink(caption)} {autolink(caption)}
</div> </div>
</div> </div>

View File

@@ -24,7 +24,7 @@ export function autolink(text: string): ReactNode[] {
href={url} href={url}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="text-ark-gold underline underline-offset-2 break-all hover:text-ark-gold2" className="message-stream-copyable-text select-text break-all text-ark-gold underline underline-offset-2 hover:text-ark-gold2"
> >
{url} {url}
</a>, </a>,

View File

@@ -41,3 +41,19 @@ header button {
.gold-underline { .gold-underline {
box-shadow: inset 0 -2px 0 #eeb726; box-shadow: inset 0 -2px 0 #eeb726;
} }
.message-stream-copyable-text,
.message-stream-copyable-text * {
-webkit-user-select: text;
user-select: text;
}
.message-stream-copyable-text {
-webkit-touch-callout: default;
cursor: text;
}
.message-stream-copyable-text::selection,
.message-stream-copyable-text *::selection {
background: rgba(238, 183, 38, 0.35);
}