mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
feat: send links as [URL]...[/URL] like the native clients
Native TeamSpeak clients wrap links in [URL] tags when sending and only link tagged ones, so a bare URL typed in the web client stayed plain text for them. Chat and offline messages now wrap bare http(s) URLs; links that are already tagged are left alone. Also stops the collected-URLs list from picking up "[/URL]" as part of a link, by sharing the renderer's URL pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
e37e090ab2
commit
839e26e4a3
2 files changed
+12
-7
No files matched your search
+4
-6
@@ -143,7 +143,7 @@ import {
|
||||
GreenteaSpeakChrome,
|
||||
isGreenteaSpeakTheme,
|
||||
} from "./themes/greenteaspeak";
|
||||
import { renderBbcode } from "./lib/bbcode";
|
||||
import { BARE_URL_REGEX, renderBbcode, wrapUrls } from "./lib/bbcode";
|
||||
import { parseChannelName, spacerDisplayName } from "./lib/spacer";
|
||||
import {
|
||||
applyParkedGatewayEvent,
|
||||
@@ -575,8 +575,6 @@ function loadCollectedUrls(): CollectedUrl[] {
|
||||
}
|
||||
}
|
||||
|
||||
const URL_REGEX = /https?:\/\/[^\s<>"]+/g;
|
||||
|
||||
type LogLevel = "critical" | "error" | "warning" | "info" | "debug";
|
||||
|
||||
interface ClientLogEntry {
|
||||
@@ -6962,7 +6960,7 @@ function AppInner() {
|
||||
};
|
||||
|
||||
const recordUrlsFromMessage = (message: string, sender: string) => {
|
||||
const found = message.match(URL_REGEX);
|
||||
const found = message.match(BARE_URL_REGEX);
|
||||
if (!found) return;
|
||||
const now = Date.now();
|
||||
setCollectedUrls((prev) => {
|
||||
@@ -8991,7 +8989,7 @@ function AppInner() {
|
||||
}, [chatInput, designTheme, connected]);
|
||||
|
||||
const handleSendChat = () => {
|
||||
const message = chatInput.trim();
|
||||
const message = wrapUrls(chatInput.trim());
|
||||
if (!message) return;
|
||||
if (activeTab === "channel") {
|
||||
socketRef.current?.send(JSON.stringify({ type: "sendChatMessage", message }));
|
||||
@@ -9408,7 +9406,7 @@ function AppInner() {
|
||||
};
|
||||
|
||||
const handleSendOfflineMessage = (clientUid: string, subject: string, message: string) => {
|
||||
socketRef.current?.send(JSON.stringify({ type: "sendOfflineMessage", clientUid, subject, message }));
|
||||
socketRef.current?.send(JSON.stringify({ type: "sendOfflineMessage", clientUid, subject, message: wrapUrls(message) }));
|
||||
};
|
||||
|
||||
const handleClientContextMenu = (
|
||||
|
||||
Reference in new issue
Block a user