feat: Refactor wiki citation handling in chat bubbles for improved consistency
- Simplified the rendering of wiki citations in chat bubbles by removing truncation and inline pill styles, replacing them with a standard link format. - Updated CSS styles to reflect the new inline link design, featuring a brand-blue dashed underline for better visual integration with surrounding text. - Enhanced accessibility by maintaining the use of the `data-slug` attribute for interaction handling. These changes streamline the presentation of wiki citations, improving user experience and visual consistency across the chat interface.
This commit is contained in:
@@ -1647,27 +1647,9 @@ const preprocessMarkdown = (contentStr: string): string => {
|
|||||||
// as such, so the chat bubble must match.
|
// as such, so the chat bubble must match.
|
||||||
if (!slug) return match;
|
if (!slug) return match;
|
||||||
|
|
||||||
// Truncate long wiki labels the same way KB citations do, so both
|
|
||||||
// kinds of citation pills stay visually consistent in narrow bubbles.
|
|
||||||
const truncateMiddle = (text: string, maxLength = 13): string => {
|
|
||||||
if (!text) return '';
|
|
||||||
if (text.length <= maxLength) return text;
|
|
||||||
const half = Math.floor((maxLength - 3) / 2);
|
|
||||||
const start = text.slice(0, half + ((maxLength - 3) % 2));
|
|
||||||
const end = text.slice(-half);
|
|
||||||
return `${start}...${end}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const safeSlug = escapeHtml(slug);
|
const safeSlug = escapeHtml(slug);
|
||||||
const safeDisplay = escapeHtml(truncateMiddle(display));
|
const safeDisplay = escapeHtml(display);
|
||||||
const tipSlug = escapeHtml(slug);
|
return `<a href="#" class="wiki-content-link citation-wiki" data-slug="${safeSlug}">${safeDisplay}</a>`;
|
||||||
const tipDisplay = escapeHtml(display);
|
|
||||||
// Render as the same pill shape the KB citation uses (class
|
|
||||||
// `citation citation-wiki`) so the two retrieval sources share a
|
|
||||||
// single visual language. Anchor tag is kept for accessibility
|
|
||||||
// and keyboard handling; `data-slug` is preserved for the
|
|
||||||
// existing click/keyboard handlers above.
|
|
||||||
return `<a href="#" class="citation citation-wiki" data-slug="${safeSlug}" role="button" tabindex="0" title="${tipDisplay}"><span class="citation-icon wiki"></span><span class="citation-text">${safeDisplay}</span><span class="citation-tip"><span class="tip-title">${tipDisplay}</span><span class="tip-meta">${tipSlug}</span></span></a>`;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -3065,13 +3047,6 @@ const handleAddToKnowledge = (answerEvent: any) => {
|
|||||||
background-image: url("../../../assets/img/zhishiku-thin.svg");
|
background-image: url("../../../assets/img/zhishiku-thin.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wiki page icon — inline open-book SVG tinted brand blue (matches
|
|
||||||
.citation-wiki text color). Inlined as a data URI so no new asset
|
|
||||||
file is required. */
|
|
||||||
:deep(.citation .citation-icon.wiki) {
|
|
||||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230052d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 4.5h6a4 4 0 0 1 4 4v12a3 3 0 0 0-3-3H2z'/><path d='M22 4.5h-6a4 4 0 0 0-4 4v12a3 3 0 0 1 3-3h7z'/></svg>");
|
|
||||||
}
|
|
||||||
|
|
||||||
.kb-float-popup {
|
.kb-float-popup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 10000;
|
z-index: 10000;
|
||||||
@@ -3165,38 +3140,27 @@ const handleAddToKnowledge = (answerEvent: any) => {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wiki citation pill — same shape as KB / web citations but in brand blue
|
/* Inline wiki link style for chat bubbles — brand-blue dashed underline,
|
||||||
so the reader can tell at a glance whether evidence came from a
|
matching the style used inside the wiki drawer. Rendered inline with
|
||||||
wiki-synthesized page or from a raw source chunk. */
|
the surrounding text, NOT as a pill, so it reads like a regular link. */
|
||||||
:deep(.citation.citation-wiki) {
|
:deep(a.wiki-content-link) {
|
||||||
background: var(--td-brand-color-light);
|
|
||||||
color: var(--td-brand-color);
|
color: var(--td-brand-color);
|
||||||
border: 1px solid var(--td-brand-color-focus);
|
text-decoration: none;
|
||||||
|
border-bottom: 1px dashed var(--td-brand-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
white-space: nowrap;
|
font-weight: 500;
|
||||||
position: relative;
|
transition: border-bottom-style 0.15s ease;
|
||||||
text-decoration: none;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.citation.citation-wiki:hover) {
|
:deep(a.wiki-content-link:hover) {
|
||||||
background: var(--td-brand-color-light);
|
border-bottom-style: solid;
|
||||||
border-color: var(--td-brand-color);
|
text-decoration: none !important;
|
||||||
color: var(--td-brand-color);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.citation.citation-wiki:focus-visible) {
|
:deep(a.wiki-content-link:focus-visible) {
|
||||||
outline: 2px solid var(--td-brand-color);
|
outline: 2px solid var(--td-brand-color);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
border-radius: 2px;
|
||||||
|
|
||||||
/* Embedded tooltip bubble — hidden; relies on browser-native `title`
|
|
||||||
attribute for hover preview. Keeps parity with citation-kb, which
|
|
||||||
also hides its inline tip in favor of the floatPopup. */
|
|
||||||
:deep(.citation.citation-wiki .citation-tip) {
|
|
||||||
display: none !important;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tool-arguments-wrapper {
|
.tool-arguments-wrapper {
|
||||||
|
|||||||
Reference in New Issue
Block a user