From cd4236b310d75dcdcd2678d7959b74cf25a62171 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 22 Oct 2025 22:20:45 +0800 Subject: [PATCH] fix: improve source tag priority handling in HighlightSource --- src/components/Note/Highlight.tsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/Note/Highlight.tsx b/src/components/Note/Highlight.tsx index 09def09..6b9ef30 100644 --- a/src/components/Note/Highlight.tsx +++ b/src/components/Note/Highlight.tsx @@ -40,22 +40,27 @@ function HighlightSource({ event }: { event: Event }) { const sourceTag = useMemo(() => { let sourceTag: string[] | undefined for (const tag of event.tags) { + // Highest priority: 'source' tag if (tag[2] === 'source') { sourceTag = tag break } - if (tag[0] === 'r') { + + // Give 'e' tags highest priority + if (tag[0] === 'e') { sourceTag = tag continue - } else if (tag[0] === 'a') { - if (!sourceTag || sourceTag[0] !== 'r') { - sourceTag = tag - } + } + + // Give 'a' tags second priority over 'e' tags + if (tag[0] === 'a' && (!sourceTag || sourceTag[0] !== 'e')) { + sourceTag = tag continue - } else if (tag[0] === 'e') { - if (!sourceTag || sourceTag[0] === 'e') { - sourceTag = tag - } + } + + // Give 'r' tags lowest priority + if (tag[0] === 'r' && (!sourceTag || sourceTag[0] === 'r')) { + sourceTag = tag continue } }