fix(admin-web): preserve paragraph breaks when sanitizing answer body

Keep blank lines while filtering non-answer noise instead of collapsing
every line, so multi-paragraph answers render with their structure
intact. Also reformat long box-shadow declarations and inline template
attributes for readability.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 14:17:36 +08:00
parent 16e73438c4
commit 177087b41b
@@ -781,14 +781,9 @@ function sanitizeAnswerBody(answerText: string | null | undefined): string | nul
return normalized return normalized
} }
const lines = normalized const lines = normalized.split(/\r?\n/)
.split(/\r?\n+/) const keptLines = lines.filter((line) => !line.trim() || !looksLikeNonAnswerNoise(line.trim()))
.map((line) => line.trim()) const sanitized = (keptLines.some((line) => line.trim()) ? keptLines.join('\n') : normalized)
.filter(Boolean)
const keptLines = lines.filter((line) => !looksLikeNonAnswerNoise(line))
const sanitized = (keptLines.length ? keptLines.join('\n') : normalized)
.replace(/[ \t]+([,.;:!?,。!?;:])/g, '$1')
.replace(/[ \t]{2,}/g, ' ')
.replace(/\n{3,}/g, '\n\n') .replace(/\n{3,}/g, '\n\n')
.trim() .trim()
@@ -1518,7 +1513,9 @@ const contentCitationColumns = computed(() => [
{{ index + 1 }} {{ index + 1 }}
</span> </span>
</div> </div>
<strong class="tracking-question-source-card__site-name">{{ citation.site_name }}</strong> <strong class="tracking-question-source-card__site-name">
{{ citation.site_name }}
</strong>
<a-tag <a-tag
v-if="isMediaSupplySubmissionCitation(citation)" v-if="isMediaSupplySubmissionCitation(citation)"
color="cyan" color="cyan"
@@ -1619,10 +1616,7 @@ const contentCitationColumns = computed(() => [
<strong class="table-text" :title="record.site_name"> <strong class="table-text" :title="record.site_name">
{{ record.site_name }} {{ record.site_name }}
</strong> </strong>
<small <small v-if="record.content_citation_count > 0" class="meta-subtext">
v-if="record.content_citation_count > 0"
class="meta-subtext"
>
{{ {{
t('tracking.contentCitationMeta', { t('tracking.contentCitationMeta', {
count: record.content_citation_count, count: record.content_citation_count,
@@ -1898,7 +1892,10 @@ const contentCitationColumns = computed(() => [
border: 1px solid rgba(226, 232, 240, 0.8); border: 1px solid rgba(226, 232, 240, 0.8);
border-radius: 16px; border-radius: 16px;
background: #ffffff; background: #ffffff;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 10px 15px -3px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(0, 0, 0, 0.01); box-shadow:
0 4px 6px -1px rgba(0, 0, 0, 0.02),
0 10px 15px -3px rgba(0, 0, 0, 0.03),
0 0 0 1px rgba(0, 0, 0, 0.01);
} }
.tracking-question-card--answer { .tracking-question-card--answer {
@@ -2123,7 +2120,9 @@ const contentCitationColumns = computed(() => [
border-color: #3b82f6; border-color: #3b82f6;
background: #f8fafc; background: #f8fafc;
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 12px 20px -8px rgba(59, 130, 246, 0.08), 0 4px 6px -2px rgba(59, 130, 246, 0.02); box-shadow:
0 12px 20px -8px rgba(59, 130, 246, 0.08),
0 4px 6px -2px rgba(59, 130, 246, 0.02);
} }
.tracking-question-source-card.is-linked { .tracking-question-source-card.is-linked {