feat(chat): add citation popover and chunk caching
Introduce ChatCitationFloat hover UI, session-scoped citation chunk cache, and unified citation markdown handling for main chat and embed views.
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
.chat-citation-pills() {
|
||||
:deep(.citation) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
vertical-align: baseline;
|
||||
box-sizing: border-box;
|
||||
border-radius: 999px;
|
||||
padding: 0 5px;
|
||||
font-size: 0.72em;
|
||||
line-height: 1.45;
|
||||
margin: 0 0.06em;
|
||||
background-clip: padding-box;
|
||||
transform: translateY(-0.04em);
|
||||
}
|
||||
|
||||
:deep(.citation-icon) {
|
||||
display: inline-block;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
flex-shrink: 0;
|
||||
background-color: currentColor;
|
||||
opacity: 0.68;
|
||||
mask-size: contain;
|
||||
mask-repeat: no-repeat;
|
||||
mask-position: center;
|
||||
-webkit-mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-position: center;
|
||||
}
|
||||
|
||||
:deep(.citation-icon--book) {
|
||||
mask-image: url('@/assets/img/ziliao.svg');
|
||||
-webkit-mask-image: url('@/assets/img/ziliao.svg');
|
||||
}
|
||||
|
||||
:deep(.citation-icon--web) {
|
||||
mask-image: url('@/assets/img/websearch-globe.svg');
|
||||
-webkit-mask-image: url('@/assets/img/websearch-globe.svg');
|
||||
}
|
||||
|
||||
:deep(.citation-text),
|
||||
:deep(.citation-domain) {
|
||||
line-height: 1.45;
|
||||
max-width: 180px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
:deep(.citation-kb) {
|
||||
background: color-mix(in srgb, var(--td-text-color-primary) 4%, transparent);
|
||||
color: color-mix(in srgb, var(--td-text-color-secondary) 86%, var(--td-text-color-primary));
|
||||
border: 0;
|
||||
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-text-color-primary) 10%, transparent);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
:deep(.citation-kb:hover) {
|
||||
background: color-mix(in srgb, var(--td-text-color-primary) 7%, transparent);
|
||||
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-text-color-primary) 18%, transparent);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
:deep(.citation-web) {
|
||||
background: color-mix(in srgb, var(--td-brand-color) 6%, transparent);
|
||||
color: color-mix(in srgb, var(--td-brand-color) 72%, var(--td-text-color-secondary));
|
||||
border: 0;
|
||||
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-brand-color) 17%, transparent);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
text-decoration: none;
|
||||
transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
:deep(.citation-web:hover) {
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-brand-color) 28%, transparent);
|
||||
color: color-mix(in srgb, var(--td-brand-color) 82%, var(--td-text-color-primary));
|
||||
}
|
||||
|
||||
:deep(.citation-web:focus-visible),
|
||||
:deep(.citation-kb:focus-visible) {
|
||||
outline: 2px solid var(--td-component-border);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
:deep(.citation-tip) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(a.wiki-content-link) {
|
||||
color: var(--td-brand-color);
|
||||
border-bottom: 1px dashed var(--td-brand-color);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: border-bottom-style 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-bottom-style: solid;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--td-brand-color);
|
||||
outline-offset: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chat-citation-float {
|
||||
position: absolute;
|
||||
z-index: 10000;
|
||||
max-width: 320px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-container);
|
||||
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
&__title {
|
||||
font-weight: 600;
|
||||
color: var(--td-brand-color);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
&__link {
|
||||
color: var(--td-brand-color);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&__body {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
&__muted,
|
||||
&__error {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&__error {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const css = readFileSync(join(here, 'chat-citations.less'), 'utf8')
|
||||
|
||||
test('citation pills use compact baseline-aligned source styling', () => {
|
||||
assert.match(css, /border-radius:\s*999px/)
|
||||
assert.match(css, /font-size:\s*0\.72em/)
|
||||
assert.match(css, /box-shadow:\s*inset 0 0 0 1px/)
|
||||
})
|
||||
Reference in New Issue
Block a user