feat(frontend): polish chat suggestions, citations, and drawers

- unify suggested-question styling across chat entry points
- keep citation markers inline with their preceding list content
- prevent manual editor viewport shifts and synchronize drawer motion
- align embedded preview and editor drawers in the body stacking context
This commit is contained in:
wizardchen
2026-06-17 22:38:07 +08:00
committed by lyingbug
parent e0d3c1dafd
commit 4e2d568149
9 changed files with 305 additions and 313 deletions
@@ -1,6 +1,6 @@
<template>
<t-drawer :visible="visible" :header="title || $t('embedPublish.preview')" size="720px" :footer="false"
:z-index="2600" class="embed-preview-drawer" @close="emit('update:visible', false)">
:z-index="2600" attach="body" class="embed-preview-drawer" @close="emit('update:visible', false)">
<div class="preview-body">
<template v-if="mode === 'iframe'">
<p class="preview-hint">{{ $t('embedPublish.previewIframeHint') }}</p>
@@ -0,0 +1,197 @@
@suggested-ease: cubic-bezier(0.16, 1, 0.3, 1);
.suggested-questions-container {
display: flex;
flex-direction: column;
align-items: center;
padding: 12px 16px 12px;
max-width: 720px;
margin: 0 auto;
width: 100%;
min-height: 0;
&.has-questions {
min-height: 64px;
}
}
.suggested-questions-inner {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
.suggested-questions-title-row {
margin-bottom: 8px;
}
.suggested-questions-caption {
display: inline-flex;
align-items: center;
gap: 4px;
margin: 0;
padding: 0;
line-height: 1;
}
.suggested-questions-title {
font-size: 12px;
color: var(--td-text-color-placeholder);
font-weight: 400;
letter-spacing: 0.02em;
}
.suggested-questions-refresh {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 18px;
height: 18px;
padding: 0;
border: none;
border-radius: 4px;
background: transparent;
color: var(--td-text-color-placeholder);
cursor: pointer;
transition: color 0.2s @suggested-ease, background 0.2s @suggested-ease;
:deep(.t-icon) {
font-size: 12px;
}
&:hover:not(:disabled) {
color: var(--td-text-color-secondary);
background: var(--td-bg-color-secondarycontainer);
}
&:active:not(:disabled) {
transform: scale(0.94);
}
&:disabled {
cursor: default;
opacity: 0.7;
}
}
.sq-refresh-spin {
animation: sq-refresh-rotate 0.8s linear infinite;
}
@keyframes sq-refresh-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.suggested-questions-grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
width: 100%;
}
.suggested-question-card {
display: inline-flex;
align-items: center;
gap: 6px;
max-width: 100%;
padding: 6px 12px;
border-radius: 8px;
border: 1px solid var(--td-component-stroke);
background: transparent;
cursor: pointer;
transition:
background 0.2s @suggested-ease,
border-color 0.2s @suggested-ease,
transform 0.15s @suggested-ease;
&:not(.sq-card-skeleton):hover {
background: var(--td-bg-color-secondarycontainer);
border-color: var(--td-component-border);
}
&:not(.sq-card-skeleton):active {
transform: scale(0.98);
background: var(--td-bg-color-secondarycontainer-active);
}
&.sq-card-skeleton {
pointer-events: none;
cursor: default;
flex-shrink: 0;
border-color: transparent;
background: var(--td-bg-color-secondarycontainer);
:deep(.t-skeleton) {
width: 100%;
}
:deep(.t-skeleton__row) {
margin: 0;
}
:deep(.t-skeleton__col) {
border-radius: 3px;
}
&:nth-child(1) {
width: 132px;
}
&:nth-child(2) {
width: 168px;
}
&:nth-child(3) {
width: 116px;
}
&:nth-child(4) {
width: 152px;
}
&:nth-child(5) {
width: 124px;
}
&:nth-child(6) {
width: 144px;
}
}
}
.suggested-question-text {
font-size: 13px;
line-height: 1.5;
color: var(--td-text-color-secondary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
transition: color 0.2s @suggested-ease;
}
.suggested-question-card:not(.sq-card-skeleton):hover .suggested-question-text {
color: var(--td-text-color-primary);
}
.suggested-question-badge {
flex-shrink: 0;
padding: 0 4px;
border-radius: 3px;
border: 1px solid var(--td-component-stroke);
background: transparent;
font-size: 10px;
font-weight: 500;
line-height: 1.6;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--td-text-color-placeholder);
}
@@ -150,7 +150,11 @@ const setSelectionRange = (start: number, end: number) => {
if (!textarea || activeTab.value !== 'edit') {
return
}
textarea.focus()
// Initialization can finish while the drawer is still sliding in. A plain
// focus() makes the browser scroll the transformed textarea into view,
// which intermittently shifts the drawer away from the right edge for a
// frame. Keep keyboard focus without letting it move the viewport.
textarea.focus({ preventScroll: true })
textarea.setSelectionRange(start, end)
})
}
@@ -735,7 +739,6 @@ onBeforeUnmount(() => {
:min-width="560"
:max-width="1280"
storage-key="setting-drawer:width:manual-markdown-editor"
:destroy-on-close="false"
:hide-footer="!initialLoaded"
:confirm-loading="saving && savingAction === 'publish'"
:confirm-text="$t('manualEditor.actions.publish')"
@@ -1111,5 +1114,3 @@ onBeforeUnmount(() => {
color: var(--td-text-color-placeholder);
}
</style>
@@ -1,14 +1,14 @@
<template>
<teleport to="body">
<div v-if="drawerVisible && resizable" class="setting-drawer-resize-handle"
:class="{ 'setting-drawer-resize-handle--active': drawerResizing }" :style="{ right: `${drawerWidthPx}px` }"
:class="{ 'setting-drawer-resize-handle--active': drawerResizing }"
:style="{ right: `${drawerWidthPx}px`, '--setting-drawer-travel': `${drawerWidthPx}px` }"
role="separator" aria-orientation="vertical" @mousedown.prevent="onResizeStart">
<div class="setting-drawer-resize-line" />
</div>
</teleport>
<t-drawer v-model:visible="drawerVisible" :size="effectiveWidth" :z-index="2500" placement="right"
:attach="attach"
:destroy-on-close="destroyOnClose"
attach="body" destroy-on-close
:class="['setting-drawer', { 'setting-drawer--resizing': drawerResizing }]">
<!--
Custom header. We replace TDesign's default header so we can put a leading
@@ -88,23 +88,6 @@ interface Props {
confirmText?: string
cancelText?: string
hideFooter?: boolean
/**
* Whether to destroy the drawer body content on close. Defaults to true to
* match historical behavior. Heavy editors (e.g. the markdown knowledge
* editor) pass false so the drawer panel persists across opens — this avoids
* the panel being removed/re-inserted on every open, which can cause a
* one-frame layout flicker as it slides in.
*/
destroyOnClose?: boolean
/**
* Where to render the drawer. Defaults to 'body' so the drawer escapes the
* app root, which carries `transform: translateZ(0)` for GPU compositing.
* A transformed ancestor becomes the containing block for `position: fixed`,
* which mis-anchors the overlay (it briefly appears mid-screen then snaps to
* the edge). Teleporting to <body> keeps it fixed to the viewport, matching
* the resize handle that is already teleported to body.
*/
attach?: string
}
const props = withDefaults(defineProps<Props>(), {
@@ -119,9 +102,7 @@ const props = withDefaults(defineProps<Props>(), {
confirmDisabled: false,
confirmText: '',
cancelText: '',
hideFooter: false,
destroyOnClose: true,
attach: 'body'
hideFooter: false
})
const emit = defineEmits<{
@@ -441,6 +422,20 @@ const handleCancel = () => {
display: flex;
align-items: center;
justify-content: center;
/* The handle is teleported separately from TDesign's sliding panel. Move it
along the same path instead of letting it flash at the panel's final left
edge while the drawer is still entering from the right. */
animation: setting-drawer-resize-handle-in 0.28s cubic-bezier(0.38, 0, 0.24, 1) both;
}
@keyframes setting-drawer-resize-handle-in {
from {
transform: translateX(var(--setting-drawer-travel));
}
to {
transform: translateX(0);
}
}
.setting-drawer-resize-line {