fix: linkify URLs in private messages
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
URLs in message content were rendered as plain text. Added linkifyContent() that converts URLs to clickable links while preserving existing <a> tags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcea91fb2a
commit
975087c52e
@ -135,6 +135,30 @@
|
||||
return tmp.textContent || tmp.innerText || '';
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// UTIL: linkify URLs in HTML content
|
||||
// ============================================================
|
||||
|
||||
function linkifyContent(html) {
|
||||
if (!html) return html;
|
||||
var tmp = document.createElement('div');
|
||||
tmp.innerHTML = html;
|
||||
var walker = document.createTreeWalker(tmp, NodeFilter.SHOW_TEXT, null, false);
|
||||
var textNodes = [];
|
||||
while (walker.nextNode()) textNodes.push(walker.currentNode);
|
||||
var urlRegex = /(https?:\/\/[^\s<>"']+)/g;
|
||||
textNodes.forEach(function(node) {
|
||||
if (node.parentNode && node.parentNode.tagName === 'A') return;
|
||||
if (urlRegex.test(node.nodeValue)) {
|
||||
var span = document.createElement('span');
|
||||
span.innerHTML = node.nodeValue.replace(urlRegex, '<a href="$1" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline;">$1</a>');
|
||||
node.parentNode.replaceChild(span, node);
|
||||
}
|
||||
urlRegex.lastIndex = 0;
|
||||
});
|
||||
return tmp.innerHTML;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// UTIL: avatar color from name hash
|
||||
// ============================================================
|
||||
@ -547,7 +571,7 @@
|
||||
|
||||
// Content
|
||||
var content = el('div', 'message-content');
|
||||
content.innerHTML = msg.content || '';
|
||||
content.innerHTML = linkifyContent(msg.content || '');
|
||||
|
||||
// Highlight search term if active
|
||||
if (state.searchHighlight) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user