master #35
@@ -1160,17 +1160,13 @@ class CommentSystem {
|
|||||||
const author = openerEl.dataset.display || openerEl.dataset.username || 'System';
|
const author = openerEl.dataset.display || openerEl.dataset.username || 'System';
|
||||||
const contentEl = body.querySelector('.comment-content');
|
const contentEl = body.querySelector('.comment-content');
|
||||||
if (contentEl) {
|
if (contentEl) {
|
||||||
const LINE_MAX = 200;
|
|
||||||
let rawText = (contentEl.dataset.raw || '').trim();
|
let rawText = (contentEl.dataset.raw || '').trim();
|
||||||
if (rawText.includes('>') || rawText.includes('<') || rawText.includes('&')) {
|
if (rawText.includes('>') || rawText.includes('<') || rawText.includes('&')) {
|
||||||
const txt = document.createElement('textarea');
|
const txt = document.createElement('textarea');
|
||||||
txt.innerHTML = rawText;
|
txt.innerHTML = rawText;
|
||||||
rawText = txt.value;
|
rawText = txt.value;
|
||||||
}
|
}
|
||||||
// Preserve all lines but cap any single line exceeding LINE_MAX chars
|
const lines = rawText.split('\n');
|
||||||
const lines = rawText.split('\n').map(line =>
|
|
||||||
line.length > LINE_MAX ? line.substring(0, LINE_MAX) + '\u2026' : line
|
|
||||||
);
|
|
||||||
const quote = `>>${id} \n>${author}\n${lines.map(line => `>${line}`).join('\n')}\n`;
|
const quote = `>>${id} \n>${author}\n${lines.map(line => `>${line}`).join('\n')}\n`;
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
@@ -1634,7 +1630,7 @@ class CommentSystem {
|
|||||||
// Truncate extremely long comments before any processing
|
// Truncate extremely long comments before any processing
|
||||||
let truncated = false;
|
let truncated = false;
|
||||||
if (!bypassTruncation && content.length > CommentSystem.ITEM_VIEW_MAX_CHARS) {
|
if (!bypassTruncation && content.length > CommentSystem.ITEM_VIEW_MAX_CHARS) {
|
||||||
content = content.substring(0, CommentSystem.ITEM_VIEW_MAX_CHARS) + '\u2026';
|
content = content.substring(0, CommentSystem.ITEM_VIEW_MAX_CHARS);
|
||||||
truncated = true;
|
truncated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,12 +153,6 @@
|
|||||||
const renderCommentContent = (content, commentId = null, itemId = null) => {
|
const renderCommentContent = (content, commentId = null, itemId = null) => {
|
||||||
if (!content) return '';
|
if (!content) return '';
|
||||||
|
|
||||||
// Truncate extremely long comments before any processing to keep the sidebar
|
|
||||||
// fast and the DOM lean, regardless of markdown / regex complexity.
|
|
||||||
if (content.length > SIDEBAR_CONTENT_TRUNCATE) {
|
|
||||||
content = content.substring(0, SIDEBAR_CONTENT_TRUNCATE) + '\u2026';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof marked === 'undefined') {
|
if (typeof marked === 'undefined') {
|
||||||
return escapeHtml(content)
|
return escapeHtml(content)
|
||||||
.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n));
|
.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n));
|
||||||
|
|||||||
Reference in New Issue
Block a user