Skip to content

Commit 98da454

Browse files
committed
feat: add markdown support (**bold**, *italic*) in notification messages
1 parent 512ba34 commit 98da454

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

public/js/app.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ function hideError(form) {
344344
if (errorEl) errorEl.classList.remove('show');
345345
}
346346

347+
function renderMarkdown(text) {
348+
if (!text) return '';
349+
let html = escapeHtml(text);
350+
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
351+
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>');
352+
return html;
353+
}
354+
347355
const NOTIF_ICONS = {
348356
success: '<i data-lucide="check-circle" class="notif-icon"></i>',
349357
error: '<i data-lucide="x-circle" class="notif-icon"></i>',
@@ -394,7 +402,7 @@ function showNotifDetailModal(notif) {
394402
<i data-lucide="x" style="width:20px;height:20px"></i>
395403
</button>
396404
</div>
397-
<div class="notif-view-modal-body">${escapeHtml(notif.message)}</div>
405+
<div class="notif-view-modal-body">${renderMarkdown(notif.message)}</div>
398406
</div>
399407
`;
400408
document.body.appendChild(overlay);
@@ -428,7 +436,7 @@ function renderNotifications() {
428436
<div class="notif-item-icon notif-${n.type}">${NOTIF_ICONS[n.type] || NOTIF_ICONS.info}</div>
429437
<div class="notif-item-body">
430438
<div class="notif-item-title">${escapeHtml(n.title)}</div>
431-
<div class="notif-item-msg">${escapeHtml(n.message)}</div>
439+
<div class="notif-item-msg">${renderMarkdown(n.message)}</div>
432440
<div class="notif-item-time">${timeAgo(n.created_at)}</div>
433441
</div>
434442
${n.is_read ? '' : '<div class="notif-dot"></div>'}

0 commit comments

Comments
 (0)