diff --git a/apps/web/src/lib/chatMessageFormat.ts b/apps/web/src/lib/chatMessageFormat.ts index 837163f..1e03306 100644 --- a/apps/web/src/lib/chatMessageFormat.ts +++ b/apps/web/src/lib/chatMessageFormat.ts @@ -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, diff --git a/apps/web/src/views/ConversationsView.vue b/apps/web/src/views/ConversationsView.vue index 4f515f5..a14f338 100644 --- a/apps/web/src/views/ConversationsView.vue +++ b/apps/web/src/views/ConversationsView.vue @@ -712,6 +712,10 @@ function formatDraftBold() { wrapDraftSelection('*', '*'); } +function formatDraftItalic() { + wrapDraftSelection('_', '_'); +} + function formatDraftList() { const el = draftInputEl.value; const value = draft.value; @@ -2141,10 +2145,12 @@ onUnmounted(() => { :class="{ crm: Boolean(seg.crm) }" @click.stop="openCrmSeg(seg)" > - {{ seg.text }} + {{ seg.text }}{{ seg.text }} + {{ seg.text }} {{ seg.text }} {{ seg.text }} + {{ seg.text }} {{ seg.text }}
@@ -2246,8 +2252,11 @@ onUnmounted(() => {