Adjusted the bold button, added italics, and fixed the broken emoji box.

This commit is contained in:
2026-09-30 15:23:19 +03:30
parent 75b83b7f1b
commit e94600a02e
2 changed files with 71 additions and 18 deletions
+13 -2
View File
@@ -3,6 +3,7 @@ export type ChatTextSeg = {
mention?: boolean;
hit?: boolean;
bold?: boolean;
italic?: boolean;
link?: string;
/** deep CRM link */
crm?: { kind: 'person' | 'deal' | 'ticket'; id: string };
@@ -13,6 +14,7 @@ const URL_RE =
/https?:\/\/[^\s<>"'`]+|(?:www\.)[^\s<>"'`]+/gi;
const CRM_RE = /mento:\/\/(person|deal|ticket)\/([A-Za-z0-9_-]+)/gi;
const BOLD_RE = /\*([^*\n]+)\*/g;
const ITALIC_RE = /_([^_\n]+)_/g;
const LIST_LINE_RE = /^\s*[-•]\s+/;
function escapeRegExp(s: string) {
@@ -85,6 +87,15 @@ function parseInline(
});
}
for (const m of raw.matchAll(ITALIC_RE)) {
const start = m.index ?? 0;
marks.push({
start,
end: start + m[0].length,
seg: { text: m[1], italic: true },
});
}
marks.sort((a, b) => a.start - b.start || b.end - a.end);
const chosen: Mark[] = [];
let cursor = 0;
@@ -110,7 +121,7 @@ function applyHighlight(parts: ChatTextSeg[], q: string): ChatTextSeg[] {
if (!qLower) return parts;
const out: ChatTextSeg[] = [];
for (const part of parts) {
if (part.mention || part.link || part.crm || part.bold) {
if (part.mention || part.link || part.crm || part.bold || part.italic) {
out.push(part);
continue;
}
@@ -134,7 +145,7 @@ function applyHighlight(parts: ChatTextSeg[], q: string): ChatTextSeg[] {
}
/**
* فرمت سبک شبیه تلگرام: *پررنگ*، لیست با - ، لینک http، mento://person|deal|ticket/id
* فرمت سبک شبیه تلگرام: *پررنگ*، _ایتالیک_، لیست با - ، لینک http، mento://…
*/
export function parseChatMessageText(
content: string,