@quirekit/ui 0.0.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/{catalog-AqWLE58Z.mjs → catalog-Dn7izrV5.mjs} +859 -290
- package/dist/catalog-Dn7izrV5.mjs.map +1 -0
- package/dist/{chat-BSVF78Hu.mjs → chat-1THPEdHw.mjs} +224 -143
- package/dist/chat-1THPEdHw.mjs.map +1 -0
- package/dist/chat.d.mts +2 -2
- package/dist/chat.mjs +1 -1
- package/dist/{code-block-pXaSN9eY.mjs → code-block-BLzjRjTb.mjs} +2 -2
- package/dist/{code-block-pXaSN9eY.mjs.map → code-block-BLzjRjTb.mjs.map} +1 -1
- package/dist/{html-sandbox-CMsenGYi.mjs → html-sandbox-D9a7iXbU.mjs} +2 -2
- package/dist/{html-sandbox-CMsenGYi.mjs.map → html-sandbox-D9a7iXbU.mjs.map} +1 -1
- package/dist/html-sandbox.mjs +1 -1
- package/dist/{index-Bf9CudSF.d.mts → index-BkzB7Lb6.d.mts} +487 -144
- package/dist/index-BkzB7Lb6.d.mts.map +1 -0
- package/dist/{index-DZc5z5s2.d.mts → index-DVBEYJNY.d.mts} +3 -2
- package/dist/index-DVBEYJNY.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +21 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{model-D4-FbKXY.mjs → model-BjGYjpa9.mjs} +3 -3
- package/dist/{model-D4-FbKXY.mjs.map → model-BjGYjpa9.mjs.map} +1 -1
- package/dist/{resolve-BwTfY4PS.mjs → resolve-nFmJOtS9.mjs} +2 -2
- package/dist/{resolve-BwTfY4PS.mjs.map → resolve-nFmJOtS9.mjs.map} +1 -1
- package/dist/vue.d.mts +546 -487
- package/dist/vue.d.mts.map +1 -1
- package/dist/vue.mjs +3379 -2828
- package/dist/vue.mjs.map +1 -1
- package/package.json +11 -4
- package/src/components/chat/composer/types.ts +2 -0
- package/src/components/chat/message-part/types.ts +3 -1
- package/src/components/chat/reasoning/types.ts +1 -1
- package/src/components/chat/tool/types.ts +1 -1
- package/src/components/dialog/index.ts +1 -1
- package/src/components/dialog/types.ts +5 -2
- package/src/components/edit-bar/index.ts +1 -0
- package/src/components/edit-bar/types.ts +24 -0
- package/src/components/icon/custom/formatting.ts +3 -0
- package/src/components/icon/custom/indicators.ts +1 -0
- package/src/components/icon/custom/insert.ts +33 -1
- package/src/components/icon/custom/mind-map.ts +28 -0
- package/src/components/icon/custom.ts +3 -1
- package/src/components/icon/lucide.ts +21 -1
- package/src/components/icon/metadata.ts +289 -0
- package/src/components/index.ts +1 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/kbd/platform.test.ts +16 -0
- package/src/components/kbd/platform.ts +16 -0
- package/src/components/toolbar/index.ts +1 -0
- package/src/components/toolbar/types.ts +8 -0
- package/src/locale/components/chat.ts +9 -7
- package/src/locale/components/edit-bar.ts +15 -0
- package/src/locale/components/icon-catalog/en.ts +89 -2
- package/src/locale/components/icon-catalog/zh-hans.ts +89 -2
- package/src/locale/packs/en.ts +2 -0
- package/src/locale/packs/zh-cn.ts +2 -0
- package/src/locale/types.ts +3 -0
- package/src/vue/action-menu/directory.vue +0 -7
- package/src/vue/block-handle/block-handle.test.ts +5 -0
- package/src/vue/block-handle/block-handle.vue +4 -11
- package/src/vue/block-handle/index.ts +1 -1
- package/src/vue/block-handle/presentation.ts +4 -0
- package/src/vue/chat/composer/composer.test.ts +11 -2
- package/src/vue/chat/composer/composer.vue +15 -3
- package/src/vue/chat/composer-submit/composer-submit.test.ts +5 -1
- package/src/vue/chat/composer-submit/composer-submit.vue +1 -1
- package/src/vue/chat/confirmation/confirmation.vue +3 -2
- package/src/vue/chat/locale.test.ts +2 -2
- package/src/vue/chat/message/message.test.ts +1 -1
- package/src/vue/chat/message/message.vue +8 -3
- package/src/vue/chat/message-actions/message-actions.vue +1 -1
- package/src/vue/chat/message-list/message-list.test.ts +2 -2
- package/src/vue/chat/message-list/message-list.vue +2 -2
- package/src/vue/chat/message-list/types.ts +2 -0
- package/src/vue/chat/message-list/use-scroll.test.ts +7 -1
- package/src/vue/chat/message-list/use-scroll.ts +12 -9
- package/src/vue/chat/message-part/message-part.test.ts +1 -1
- package/src/vue/chat/message-part/message-part.vue +2 -3
- package/src/vue/chat/shared/disclosure.vue +1 -1
- package/src/vue/chat/shared/part-actions.ts +1 -1
- package/src/vue/chat/shared/state-icon.ts +2 -1
- package/src/vue/combobox/async-value.test.ts +49 -0
- package/src/vue/combobox/use-combobox-model.ts +3 -1
- package/src/vue/component-styles.test.ts +17 -0
- package/src/vue/dialog/content.vue +29 -5
- package/src/vue/dialog/size.test.ts +61 -0
- package/src/vue/edit-bar/edit-bar.test.ts +125 -0
- package/src/vue/edit-bar/edit-bar.vue +108 -0
- package/src/vue/edit-bar/index.ts +2 -0
- package/src/vue/edit-bar/types.ts +21 -0
- package/src/vue/index.ts +1 -0
- package/src/vue/menu/items/disabled-submenu.test.ts +24 -0
- package/src/vue/menu/items/items.test.ts +29 -0
- package/src/vue/menu/items/items.vue +6 -0
- package/src/vue/menu/menu-group.vue +11 -2
- package/src/vue/scroll-area/scroll-area.test.ts +10 -0
- package/src/vue/scroll-area/scroll-area.vue +1 -1
- package/src/vue/select/select.test.ts +18 -0
- package/src/vue/select/select.vue +3 -0
- package/src/vue/slider/slider.test.ts +13 -0
- package/src/vue/slider/slider.vue +4 -2
- package/src/vue/splitter/splitter.test.ts +18 -0
- package/src/vue/splitter/splitter.vue +5 -2
- package/src/vue/task-panel/root.vue +0 -8
- package/src/vue/toolbar/context.ts +5 -2
- package/src/vue/toolbar/items/body.vue +5 -3
- package/src/vue/toolbar/items/control.vue +9 -1
- package/src/vue/toolbar/items/memo.test.ts +49 -0
- package/src/vue/toolbar/items/memo.ts +24 -0
- package/src/vue/toolbar/items/sheet-entries.ts +52 -0
- package/src/vue/toolbar/items/sheet.test.ts +61 -0
- package/src/vue/toolbar/items/sheet.vue +78 -0
- package/src/vue/toolbar/presentation/mobile.test.ts +14 -0
- package/src/vue/toolbar/presentation/visibility.ts +38 -0
- package/src/vue/toolbar/toolbar-split-button.test.ts +2 -0
- package/src/vue/toolbar/toolbar-split-button.vue +1 -0
- package/src/vue/toolbar/toolbar.vue +8 -3
- package/src/vue/toolbar/types.ts +3 -1
- package/dist/catalog-AqWLE58Z.mjs.map +0 -1
- package/dist/chat-BSVF78Hu.mjs.map +0 -1
- package/dist/index-Bf9CudSF.d.mts.map +0 -1
- package/dist/index-DZc5z5s2.d.mts.map +0 -1
- package/dist/style.css +0 -37
|
@@ -23,9 +23,24 @@ export const zhCN: Messages = {
|
|
|
23
23
|
"table-structure": "表格 · 结构",
|
|
24
24
|
"table-style": "表格 · 边框与排列",
|
|
25
25
|
review: "修订与批注",
|
|
26
|
-
page: "页面与对象"
|
|
26
|
+
page: "页面与对象",
|
|
27
|
+
"object-tools": "对象工具",
|
|
28
|
+
presentation: "演示",
|
|
29
|
+
"mind-map": "思维导图"
|
|
27
30
|
},
|
|
28
31
|
icons: {
|
|
32
|
+
marqueeSelect: "框选",
|
|
33
|
+
mindTopic: "同级主题",
|
|
34
|
+
mindSubtopic: "子主题",
|
|
35
|
+
mindParentTopic: "父主题",
|
|
36
|
+
mindFloatingTopic: "自由主题",
|
|
37
|
+
mindRelation: "联系",
|
|
38
|
+
mindSummary: "概要",
|
|
39
|
+
mindBoundary: "外框",
|
|
40
|
+
mindLayout: "导图结构",
|
|
41
|
+
mindStyle: "主题样式",
|
|
42
|
+
mindExpandBranch: "展开分支",
|
|
43
|
+
mindCollapseBranch: "折叠分支",
|
|
29
44
|
gitBranch: "分支连接",
|
|
30
45
|
outlineColor: "轮廓颜色",
|
|
31
46
|
tableOfContents: "目录",
|
|
@@ -34,7 +49,15 @@ export const zhCN: Messages = {
|
|
|
34
49
|
shapes: "形状",
|
|
35
50
|
pencilRuler: "绘图工具",
|
|
36
51
|
whiteboard: "白板",
|
|
52
|
+
animation: "动画",
|
|
53
|
+
animationEntrance: "进入动画",
|
|
54
|
+
animationEmphasis: "强调动画",
|
|
55
|
+
animationExit: "退出动画",
|
|
56
|
+
slideTransition: "幻灯片切换",
|
|
57
|
+
freehand: "自由曲线",
|
|
58
|
+
editPoints: "编辑顶点",
|
|
37
59
|
textDiagram: "文本绘图",
|
|
60
|
+
documentOutline: "大纲",
|
|
38
61
|
mindMap: "思维导图",
|
|
39
62
|
sectionBreak: "分节符",
|
|
40
63
|
footnote: "脚注",
|
|
@@ -105,6 +128,7 @@ export const zhCN: Messages = {
|
|
|
105
128
|
menu: "菜单",
|
|
106
129
|
file: "文件",
|
|
107
130
|
fileText: "文本文档",
|
|
131
|
+
markdown: "Markdown 文档",
|
|
108
132
|
files: "多个文件",
|
|
109
133
|
filePlus: "新建文件",
|
|
110
134
|
fileMinus: "移除文件",
|
|
@@ -281,6 +305,9 @@ export const zhCN: Messages = {
|
|
|
281
305
|
chartColumn: "柱状图",
|
|
282
306
|
chartLine: "折线图",
|
|
283
307
|
chartPie: "饼图",
|
|
308
|
+
chartScatter: "散点图",
|
|
309
|
+
chartRadar: "雷达图",
|
|
310
|
+
qrCode: "二维码",
|
|
284
311
|
chartBar: "条形图",
|
|
285
312
|
keyboard: "键盘",
|
|
286
313
|
command: "快捷命令",
|
|
@@ -300,6 +327,7 @@ export const zhCN: Messages = {
|
|
|
300
327
|
sendToBack: "置于底层",
|
|
301
328
|
group: "组合",
|
|
302
329
|
ungroup: "取消组合",
|
|
330
|
+
stop: "停止",
|
|
303
331
|
triangleUp: "向上步进",
|
|
304
332
|
triangleDown: "向下步进",
|
|
305
333
|
bold: "加粗",
|
|
@@ -346,14 +374,56 @@ export const zhCN: Messages = {
|
|
|
346
374
|
listTodo: "待办列表",
|
|
347
375
|
listTree: "多级列表",
|
|
348
376
|
lineSpacing: "行距",
|
|
377
|
+
lineNumbers: "行号",
|
|
349
378
|
paragraph: "段落标记",
|
|
350
379
|
paragraphSettings: "段落设置",
|
|
351
380
|
textDirectionLtr: "从左向右",
|
|
352
381
|
textDirectionRtl: "从右向左",
|
|
382
|
+
textDirectionVertical: "竖排文字",
|
|
353
383
|
textWrap: "自动换行",
|
|
354
384
|
wrapText: "折行",
|
|
355
385
|
insert: "插入内容",
|
|
356
386
|
textBox: "文本框",
|
|
387
|
+
textBoxVertical: "竖向文本框",
|
|
388
|
+
designTheme: "设计主题",
|
|
389
|
+
shapeStyles: "形状样式",
|
|
390
|
+
shapeEffects: "形状效果",
|
|
391
|
+
changeShape: "更改形状",
|
|
392
|
+
gradientFill: "渐变填充",
|
|
393
|
+
lineDash: "线条样式",
|
|
394
|
+
lineWeight: "线条粗细",
|
|
395
|
+
replaceImage: "替换图片",
|
|
396
|
+
resetImage: "重设图片",
|
|
397
|
+
cropToShape: "裁剪为形状",
|
|
398
|
+
pictureStyles: "图片样式",
|
|
399
|
+
pictureEffects: "图片效果",
|
|
400
|
+
brightness: "亮度",
|
|
401
|
+
contrast: "对比度",
|
|
402
|
+
recolor: "重新着色",
|
|
403
|
+
transparency: "透明度",
|
|
404
|
+
compressImage: "压缩图片",
|
|
405
|
+
wordArtStyles: "艺术字样式",
|
|
406
|
+
textEffects: "文本效果",
|
|
407
|
+
characterSpacing: "字符间距",
|
|
408
|
+
textAutoFit: "自动调整",
|
|
409
|
+
tableCellMargins: "单元格边距",
|
|
410
|
+
chartElements: "图表元素",
|
|
411
|
+
chartQuickLayout: "快速布局",
|
|
412
|
+
chartColors: "更改颜色",
|
|
413
|
+
chartSwitchRowColumn: "切换行列",
|
|
414
|
+
colorScheme: "配色方案",
|
|
415
|
+
backgroundStyle: "背景样式",
|
|
416
|
+
slideSize: "幻灯片大小",
|
|
417
|
+
slideSorter: "幻灯片浏览",
|
|
418
|
+
notesPage: "备注页",
|
|
419
|
+
gridlines: "网格线",
|
|
420
|
+
guides: "参考线",
|
|
421
|
+
presenterView: "演讲者视图",
|
|
422
|
+
laserPointer: "激光笔",
|
|
423
|
+
inkPen: "画笔",
|
|
424
|
+
inkHighlighter: "荧光笔",
|
|
425
|
+
eraser: "橡皮擦",
|
|
426
|
+
exportFile: "导出",
|
|
357
427
|
textCursor: "文本光标",
|
|
358
428
|
textCursorInput: "文本输入",
|
|
359
429
|
blockContentControl: "块内容控件",
|
|
@@ -452,6 +522,23 @@ export const zhCN: Messages = {
|
|
|
452
522
|
pipette: ["吸管"],
|
|
453
523
|
fontScript: ["中文与西文"],
|
|
454
524
|
textDirectionLtr: ["文字方向"],
|
|
455
|
-
textDirectionRtl: ["文字方向"]
|
|
525
|
+
textDirectionRtl: ["文字方向"],
|
|
526
|
+
textDirectionVertical: ["文字方向", "竖排"],
|
|
527
|
+
textBoxVertical: ["竖排文本框"],
|
|
528
|
+
textAutoFit: ["根据文字调整形状大小", "缩排文字"],
|
|
529
|
+
designTheme: ["主题", "模板"],
|
|
530
|
+
colorScheme: ["主题颜色", "配色"],
|
|
531
|
+
backgroundStyle: ["背景"],
|
|
532
|
+
slideSize: ["页面比例", "宽屏"],
|
|
533
|
+
slideSorter: ["缩略图视图"],
|
|
534
|
+
notesPage: ["演讲者备注"],
|
|
535
|
+
gridlines: ["网格"],
|
|
536
|
+
guides: ["辅助线"],
|
|
537
|
+
presenterView: ["放映"],
|
|
538
|
+
laserPointer: ["指示"],
|
|
539
|
+
inkPen: ["墨迹", "标注"],
|
|
540
|
+
inkHighlighter: ["墨迹", "标注"],
|
|
541
|
+
eraser: ["擦除"],
|
|
542
|
+
exportFile: ["导出为 PDF", "导出为图片"]
|
|
456
543
|
}
|
|
457
544
|
};
|
package/src/locale/packs/en.ts
CHANGED
|
@@ -64,6 +64,7 @@ import * as steps from "../components/steps";
|
|
|
64
64
|
import * as timeline from "../components/timeline";
|
|
65
65
|
import * as tag from "../components/tag";
|
|
66
66
|
import * as toolbar from "../components/toolbar";
|
|
67
|
+
import * as editBar from "../components/edit-bar";
|
|
67
68
|
import * as splitter from "../components/splitter";
|
|
68
69
|
import * as statistic from "../components/statistic";
|
|
69
70
|
import * as progress from "../components/progress";
|
|
@@ -144,6 +145,7 @@ export const quireKitEn: QuireKitLocale = {
|
|
|
144
145
|
timeline: timeline.en,
|
|
145
146
|
tag: tag.en,
|
|
146
147
|
toolbar: toolbar.en,
|
|
148
|
+
editBar: editBar.en,
|
|
147
149
|
splitter: splitter.en,
|
|
148
150
|
statistic: statistic.en,
|
|
149
151
|
progress: progress.en,
|
|
@@ -64,6 +64,7 @@ import * as steps from "../components/steps";
|
|
|
64
64
|
import * as timeline from "../components/timeline";
|
|
65
65
|
import * as tag from "../components/tag";
|
|
66
66
|
import * as toolbar from "../components/toolbar";
|
|
67
|
+
import * as editBar from "../components/edit-bar";
|
|
67
68
|
import * as splitter from "../components/splitter";
|
|
68
69
|
import * as statistic from "../components/statistic";
|
|
69
70
|
import * as progress from "../components/progress";
|
|
@@ -144,6 +145,7 @@ export const quireKitZhCN: QuireKitLocale = {
|
|
|
144
145
|
timeline: timeline.zhCN,
|
|
145
146
|
tag: tag.zhCN,
|
|
146
147
|
toolbar: toolbar.zhCN,
|
|
148
|
+
editBar: editBar.zhCN,
|
|
147
149
|
splitter: splitter.zhCN,
|
|
148
150
|
statistic: statistic.zhCN,
|
|
149
151
|
progress: progress.zhCN,
|
package/src/locale/types.ts
CHANGED
|
@@ -63,6 +63,7 @@ import type { Messages as StepsMessages } from "./components/steps";
|
|
|
63
63
|
import type { Messages as TimelineMessages } from "./components/timeline";
|
|
64
64
|
import type { Messages as TagMessages } from "./components/tag";
|
|
65
65
|
import type { Messages as ToolbarMessages } from "./components/toolbar";
|
|
66
|
+
import type { Messages as EditBarMessages } from "./components/edit-bar";
|
|
66
67
|
import type { Messages as SplitterMessages } from "./components/splitter";
|
|
67
68
|
import type { Messages as StatisticMessages } from "./components/statistic";
|
|
68
69
|
import type { Messages as ProgressMessages } from "./components/progress";
|
|
@@ -204,6 +205,8 @@ export interface QuireKitMessages {
|
|
|
204
205
|
readonly tag: TagMessages;
|
|
205
206
|
/** Toolbar. */
|
|
206
207
|
readonly toolbar: ToolbarMessages;
|
|
208
|
+
/** EditBar. */
|
|
209
|
+
readonly editBar: EditBarMessages;
|
|
207
210
|
/** Splitter. */
|
|
208
211
|
readonly splitter: SplitterMessages;
|
|
209
212
|
/** Statistic. */
|
|
@@ -36,10 +36,3 @@ function activate(value: string): void { if (!props.busy && props.actions.some(a
|
|
|
36
36
|
<p v-if="!groups.length" class="qk-action-sheet__empty" role="status">{{ text.empty }}</p>
|
|
37
37
|
</div>
|
|
38
38
|
</template>
|
|
39
|
-
<style scoped>
|
|
40
|
-
.qk-action-directory { display: grid; gap: var(--qk-space-surface-compact); }
|
|
41
|
-
.qk-action-directory__search { display: grid; }
|
|
42
|
-
.qk-action-directory__search-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
43
|
-
.qk-action-directory__actions--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--qk-space-inline); }
|
|
44
|
-
.qk-action-directory__actions--grid > button { min-width: 0; min-height: 48px; border-radius: var(--qk-radius-control); background: var(--qk-color-surface-subtle); }
|
|
45
|
-
</style>
|
|
@@ -27,4 +27,9 @@ describe("QuireBlockHandle", () => {
|
|
|
27
27
|
it("falls back to a neutral mark", async () => {
|
|
28
28
|
expect(await render({ label: "拖动", icon: "layers" })).toContain(quireBlockToneColor("neutral"));
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
it("keeps a fixed box instead of following the theme's control height and surface radius", async () => {
|
|
32
|
+
const html = await render({ label: "拖动", icon: "type" });
|
|
33
|
+
expect(html).toMatch(/<button[^>]*style="[^"]*width:42px;[^"]*height:24px;[^"]*border-radius:6px;/);
|
|
34
|
+
});
|
|
30
35
|
});
|
|
@@ -2,26 +2,19 @@
|
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import QuireButton from "../button/button.vue";
|
|
4
4
|
import QuireIcon from "../icon/icon.vue";
|
|
5
|
-
import { quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
|
|
5
|
+
import { quireBlockHandleHeight, quireBlockHandleRadius, quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
|
|
6
6
|
import type { QuireBlockHandleProps } from "./types";
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<QuireBlockHandleProps>(), { tone: "neutral" });
|
|
9
9
|
const typeStyle = computed(() => ({ color: quireBlockToneColor(props.tone) }));
|
|
10
|
+
// Fixed box: neither the theme's control height nor its surface radius reshapes the handle.
|
|
11
|
+
const boxStyle = { width: `${quireBlockHandleWidth}px`, height: `${quireBlockHandleHeight}px`, minHeight: `${quireBlockHandleHeight}px`, borderRadius: `${quireBlockHandleRadius}px` };
|
|
10
12
|
</script>
|
|
11
13
|
<template>
|
|
12
|
-
<QuireButton size="xs" color="neutral" variant="outline" class="qk-block-handle" :aria-label="label" :style="
|
|
14
|
+
<QuireButton size="xs" color="neutral" variant="outline" class="qk-block-handle" :aria-label="label" :style="boxStyle">
|
|
13
15
|
<span class="qk-block-handle__content" aria-hidden="true">
|
|
14
16
|
<span class="qk-block-handle__type" :style="typeStyle"><span v-if="badge" class="qk-type-helper">{{ badge }}</span><QuireIcon v-else-if="icon" :name="icon" :size="16" /></span>
|
|
15
17
|
<QuireIcon name="gripVertical" :size="16" class="qk-block-handle__grip" />
|
|
16
18
|
</span>
|
|
17
19
|
</QuireButton>
|
|
18
20
|
</template>
|
|
19
|
-
<style scoped>
|
|
20
|
-
/* A quiet chip on the page: hairline edge, no fill until hover; the block type carries the color, the grip stays muted. */
|
|
21
|
-
.qk-block-handle { cursor: grab; touch-action: none; padding-inline: 1px 2px; border-radius: var(--qk-radius-group);
|
|
22
|
-
border-color: var(--qk-color-border-subtle); background: var(--qk-color-surface-page); box-shadow: none; }
|
|
23
|
-
.qk-block-handle:hover, .qk-block-handle[aria-expanded="true"] { background: var(--qk-color-surface-hover); }
|
|
24
|
-
.qk-block-handle__content { display: flex; align-items: center; justify-content: center; gap: 1px; }
|
|
25
|
-
.qk-block-handle__type { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; font-weight: var(--qk-type-heading-font-weight); }
|
|
26
|
-
.qk-block-handle__grip { color: var(--qk-color-text-placeholder); }
|
|
27
|
-
</style>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as QuireBlockHandle } from "./block-handle.vue";
|
|
2
|
-
export { quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
|
|
2
|
+
export { quireBlockHandleHeight, quireBlockHandleRadius, quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
|
|
3
3
|
export type * from "./types";
|
|
@@ -2,6 +2,10 @@ import type { QuireBlockTone } from "./types";
|
|
|
2
2
|
|
|
3
3
|
/** Fixed handle width, so hosts can reserve its gutter before it mounts. */
|
|
4
4
|
export const quireBlockHandleWidth = 42;
|
|
5
|
+
/** Fixed handle height of one compact row, so hosts can center it on a text line under any theme. */
|
|
6
|
+
export const quireBlockHandleHeight = 24;
|
|
7
|
+
/** Fixed corner radius; the handle and its adjacent rail buttons are document marks that keep their shape when a theme enlarges surface corners. */
|
|
8
|
+
export const quireBlockHandleRadius = 6;
|
|
5
9
|
|
|
6
10
|
/** Each tone derives from semantic feedback colors, so both schemes stay readable. */
|
|
7
11
|
const colors: Readonly<Record<QuireBlockTone, string>> = {
|
|
@@ -33,16 +33,25 @@ it('emits literal drafts without clearing them, protects IME and exposes stop se
|
|
|
33
33
|
expect(enter().defaultPrevented).toBe(true);
|
|
34
34
|
expect(submit).toHaveBeenCalledExactlyOnceWith({ text: ' 你好\nworld ' });
|
|
35
35
|
expect(host.querySelector('textarea')!.value).toBe(state.text);
|
|
36
|
-
state.busy = true; await nextTick();
|
|
36
|
+
state.busy = true; await nextTick();
|
|
37
|
+
expect(enter().defaultPrevented).toBe(false);
|
|
38
|
+
expect(submit).toHaveBeenCalledTimes(1);
|
|
37
39
|
expect(host.querySelector('textarea')!.disabled).toBe(false);
|
|
40
|
+
for (const modifiers of [{ isComposing: true }, { keyCode: 229 }, { shiftKey: true }, { repeat: true }]) {
|
|
41
|
+
expect(enter({ key: 'Escape', ...modifiers }).defaultPrevented).toBe(false);
|
|
42
|
+
}
|
|
43
|
+
expect(stop).not.toHaveBeenCalled();
|
|
38
44
|
host.querySelector<HTMLButtonElement>('button')!.click(); expect(stop).toHaveBeenCalledOnce();
|
|
45
|
+
expect(enter({ key: 'Escape' }).defaultPrevented).toBe(true);
|
|
46
|
+
expect(stop).toHaveBeenCalledTimes(2);
|
|
39
47
|
state.busy = false; state.readOnly = true; await nextTick(); enter();
|
|
48
|
+
expect(enter({ key: 'Escape' }).defaultPrevented).toBe(false);
|
|
40
49
|
expect(submit).toHaveBeenCalledTimes(1);
|
|
41
50
|
state.readOnly = false; state.text = ' \n '; await nextTick(); enter();
|
|
42
51
|
expect(submit).toHaveBeenCalledTimes(1);
|
|
43
52
|
state.disabled = true; state.busy = true; await nextTick();
|
|
44
53
|
expect(host.querySelector('.qk-chat-composer')!.hasAttribute('data-disabled')).toBe(true);
|
|
45
|
-
host.querySelector<HTMLButtonElement>('button')!.click(); expect(stop).
|
|
54
|
+
host.querySelector<HTMLButtonElement>('button')!.click(); expect(stop).toHaveBeenCalledTimes(2);
|
|
46
55
|
} finally { app.unmount(); host.remove(); }
|
|
47
56
|
});
|
|
48
57
|
|
|
@@ -27,11 +27,12 @@ const input = ref<QuireKitChatComposerInputInstance>();
|
|
|
27
27
|
const fileDragging = ref(false);
|
|
28
28
|
const footerId = `qk-composer-footer-${useId()}`;
|
|
29
29
|
const minRows = computed(() => props.rows ?? (props.layout === 'inline' ? 1 : 2));
|
|
30
|
+
const inputSubmitMode = computed(() => props.busy || props.submitDisabled ? 'button' : props.submitMode);
|
|
30
31
|
const canSubmit = computed(() => !props.disabled && !props.readOnly && !props.busy && !props.submitDisabled
|
|
31
32
|
&& (props.modelValue.trim().length > 0 || props.hasContent));
|
|
32
33
|
const context = computed<QuireKitChatComposerContext>(() => ({
|
|
33
34
|
value: props.modelValue, label: label.value, busy: props.busy, disabled: props.disabled,
|
|
34
|
-
readOnly: props.readOnly, canSubmit: canSubmit.value, updateValue, submit, stop
|
|
35
|
+
readOnly: props.readOnly, submitMode: inputSubmitMode.value, canSubmit: canSubmit.value, updateValue, submit, stop
|
|
35
36
|
}));
|
|
36
37
|
|
|
37
38
|
/** Notify the controlled draft owner.
|
|
@@ -51,6 +52,17 @@ function stop(): void {
|
|
|
51
52
|
if (props.busy && !props.disabled) emit('stop');
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
/** Cancel from the default draft field while leaving IME, menus and custom input adapters their own Escape.
|
|
56
|
+
* @param event - Native field key event.
|
|
57
|
+
*/
|
|
58
|
+
function onInputEscape(event: KeyboardEvent): void {
|
|
59
|
+
if (!props.busy || props.disabled || event.defaultPrevented || event.isComposing || event.keyCode === 229
|
|
60
|
+
|| event.repeat || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
stop();
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
/** Forward default-input focus without querying a child component's DOM.
|
|
55
67
|
* @param options - Native focus scrolling options.
|
|
56
68
|
*/
|
|
@@ -136,8 +148,8 @@ watch([() => props.disabled, () => props.readOnly, () => props.addTransferFiles]
|
|
|
136
148
|
<div class="qk-chat-composer__input">
|
|
137
149
|
<slot name="input" v-bind="context">
|
|
138
150
|
<ComposerInput ref="input" :model-value="modelValue" :label="label" :placeholder="placeholder ?? text.composer.placeholder" :size="size" variant="embedded"
|
|
139
|
-
:aria-describedby="$slots.footer ? footerId : undefined" :submit-mode="
|
|
140
|
-
:rows="minRows" :max-rows="maxRows" @update:model-value="updateValue" @submit="submit" />
|
|
151
|
+
:aria-describedby="$slots.footer ? footerId : undefined" :submit-mode="inputSubmitMode" :disabled="disabled" :read-only="readOnly"
|
|
152
|
+
:rows="minRows" :max-rows="maxRows" @update:model-value="updateValue" @submit="submit" @keydown.esc="onInputEscape" />
|
|
141
153
|
</slot>
|
|
142
154
|
</div>
|
|
143
155
|
</div>
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import { createApp, h, nextTick, reactive } from 'vue';
|
|
3
3
|
import { expect, it, vi } from 'vitest';
|
|
4
4
|
import Submit from './composer-submit.vue';
|
|
5
|
+
import IconProvider from '../../icon/icon-provider.vue';
|
|
6
|
+
import { quireIconRegistry } from '../../../components/icon/catalog';
|
|
5
7
|
|
|
6
8
|
it.each(['icon', 'text'] as const)('retains the %s button while switching between submit and stop', async (appearance) => {
|
|
7
9
|
const state = reactive({ busy: false, canSubmit: false, disabled: false });
|
|
8
10
|
const submit = vi.fn(); const stop = vi.fn();
|
|
9
11
|
const host = document.createElement('div'); document.body.append(host);
|
|
10
|
-
const app = createApp({ render: () => h(
|
|
12
|
+
const app = createApp({ render: () => h(IconProvider, { registry: quireIconRegistry }, () =>
|
|
13
|
+
h(Submit, { ...state, appearance, onSubmit: submit, onStop: stop })) });
|
|
11
14
|
app.mount(host);
|
|
12
15
|
try {
|
|
13
16
|
const button = host.querySelector('button')!;
|
|
@@ -16,6 +19,7 @@ it.each(['icon', 'text'] as const)('retains the %s button while switching betwee
|
|
|
16
19
|
state.canSubmit = true; await nextTick(); button.click(); expect(submit).toHaveBeenCalledOnce();
|
|
17
20
|
button.focus(); state.busy = true; state.canSubmit = false; await nextTick();
|
|
18
21
|
expect(host.querySelector('button')).toBe(button); expect(document.activeElement).toBe(button);
|
|
22
|
+
if (appearance === 'icon') expect(button.querySelector('svg rect')?.getAttribute('fill')).toBe('currentColor');
|
|
19
23
|
expect(button.disabled).toBe(false); button.click(); expect(stop).toHaveBeenCalledOnce();
|
|
20
24
|
state.disabled = true; await nextTick(); button.click(); expect(stop).toHaveBeenCalledOnce();
|
|
21
25
|
} finally { app.unmount(); host.remove(); }
|
|
@@ -28,7 +28,7 @@ function activate(): void {
|
|
|
28
28
|
<template>
|
|
29
29
|
<QuireIconButton v-if="appearance === 'icon'" :label="label" :title="label" shape="circle" variant="solid"
|
|
30
30
|
:color="color" :size="size" :disabled="unavailable" :data-mode="busy ? 'stop' : 'submit'" @click="activate">
|
|
31
|
-
<QuireIcon :name="busy ? '
|
|
31
|
+
<QuireIcon :name="busy ? 'stop' : 'arrowUp'" :size="16" />
|
|
32
32
|
</QuireIconButton>
|
|
33
33
|
<QuireButton v-else variant="solid" :color="color" :size="size" :disabled="unavailable"
|
|
34
34
|
:data-mode="busy ? 'stop' : 'submit'" @click="activate">{{ label }}</QuireButton>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed } from 'vue';
|
|
3
3
|
import type { QuireKitChatConfirmationDecision, QuireKitChatConfirmationProps, QuireKitChatConfirmationSlots } from '../../../components/chat';
|
|
4
4
|
import QuireButton from '../../button/button.vue';
|
|
5
|
+
import QuireIcon from '../../icon/icon.vue';
|
|
5
6
|
import { vChatFocusRecovery } from '../shared/focus-recovery';
|
|
6
7
|
import { useQuireKitMessages } from '../../locale-provider/context';
|
|
7
8
|
|
|
@@ -20,9 +21,9 @@ function decide(decision: QuireKitChatConfirmationDecision['decision']): void {
|
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<template>
|
|
23
|
-
<section v-chat-focus-recovery class="qk-chat-decision qk-chat-confirmation" :data-state="state" :aria-label="title" tabindex="-1">
|
|
24
|
+
<section v-chat-focus-recovery class="qk-chat-decision qk-chat-confirmation" :data-intent="intent ?? 'permission'" :data-state="state" :aria-label="title" tabindex="-1">
|
|
24
25
|
<div class="qk-chat-decision__heading">
|
|
25
|
-
<strong class="qk-chat-decision__title"
|
|
26
|
+
<strong class="qk-chat-decision__title"><QuireIcon v-if="intent === 'review'" name="fileCheck" :size="16" />{{ title }}</strong>
|
|
26
27
|
<span class="qk-chat-decision__state" :data-state="state" role="status">{{ labels[state] }}</span>
|
|
27
28
|
</div>
|
|
28
29
|
<p v-if="description" class="qk-chat-decision__description">{{ description }}</p>
|
|
@@ -38,11 +38,11 @@ it('renders composer, message and part chrome in English', async () => {
|
|
|
38
38
|
expect(host.querySelector('[data-mode="submit"]')?.getAttribute('aria-label')).toBe('Send');
|
|
39
39
|
expect(host.textContent).toContain('Reasoning');
|
|
40
40
|
expect(host.textContent).toContain('Running');
|
|
41
|
-
expect(host.textContent).
|
|
41
|
+
expect(host.querySelector('[data-part-id="p"] .qk-chat-part__text')?.textContent).toBe('# Title');
|
|
42
42
|
expect(host.textContent).toContain('Generation stopped');
|
|
43
43
|
expect(host.textContent).toContain('1 / 2');
|
|
44
44
|
expect(host.querySelector('[data-action-id="previous"]')?.getAttribute('aria-label')).toBe('Previous version');
|
|
45
|
-
expect(host.querySelector('[data-action-id="copy"]')?.getAttribute('aria-label')).toBe('Copy
|
|
45
|
+
expect(host.querySelector('[data-action-id="copy"]')?.getAttribute('aria-label')).toBe('Copy message');
|
|
46
46
|
expect(host.querySelector('[data-action-id="more"]')?.getAttribute('aria-label')).toBe('More actions');
|
|
47
47
|
expect(host.textContent).not.toMatch(han);
|
|
48
48
|
});
|
|
@@ -65,7 +65,7 @@ it('keeps time and actions in one historical footer', () => {
|
|
|
65
65
|
const footer = host.querySelector('.qk-chat-message__footer[data-reveal]');
|
|
66
66
|
expect(footer).not.toBeNull();
|
|
67
67
|
expect(footer?.textContent).toContain('09:30');
|
|
68
|
-
expect(footer?.querySelector('button[aria-label="
|
|
68
|
+
expect(footer?.querySelector('button[aria-label="复制消息"]')).not.toBeNull();
|
|
69
69
|
} finally { app.unmount(); }
|
|
70
70
|
});
|
|
71
71
|
|
|
@@ -42,8 +42,12 @@ const text = useQuireKitMessages('chat');
|
|
|
42
42
|
const identity = computed(() => JSON.stringify([props.messageId, props.branch?.selectedId]));
|
|
43
43
|
const status = computed(() => props.statusText ?? (props.state === 'complete' ? '' : text.value.status[props.state]));
|
|
44
44
|
const active = computed(() => props.state === 'pending' || props.state === 'streaming');
|
|
45
|
-
const hasActions = computed(() => !!slots.actions || (!active.value && props.copyText
|
|
45
|
+
const hasActions = computed(() => !!slots.actions || (!active.value && !!props.copyText) || props.actions?.some(action => action.when === 'always' || (action.when === 'active' ? active.value : !active.value)));
|
|
46
46
|
const hasFooter = computed(() => hasActions.value || props.meta || (props.branch?.ids.length ?? 0) > 1);
|
|
47
|
+
// A lone copy button fits beside a sent text bubble; richer action groups keep a row of their own.
|
|
48
|
+
const sideCopy = computed(() => props.align === 'end' && props.variant === 'soft' && props.copyText &&
|
|
49
|
+
props.parts?.length === 1 && props.parts[0]?.kind === 'text' &&
|
|
50
|
+
!props.meta && !props.branch && !props.actions?.length && !slots.actions && !slots.default && !active.value);
|
|
47
51
|
/** Reveal the whole footer together, preserving emergency actions and its layout slot.
|
|
48
52
|
* @returns Whether this message footer waits for pointer or keyboard focus.
|
|
49
53
|
*/
|
|
@@ -61,14 +65,15 @@ watch(identity, () => { announcement.value = ''; });
|
|
|
61
65
|
<LocaleScope v-slot="{ dir }">
|
|
62
66
|
<article ref="root" v-chat-focus-recovery v-bind="$attrs" class="qk-chat-message" :dir="dir" :data-align="align" :data-variant="variant" :data-state="state"
|
|
63
67
|
:data-message-id="messageId" :data-actions-visibility="actionsVisibility" :aria-label="author" tabindex="-1">
|
|
64
|
-
<div class="qk-chat-message__body">
|
|
68
|
+
<div class="qk-chat-message__body" :data-side-copy="sideCopy || undefined">
|
|
65
69
|
<div v-if="showHeader" class="qk-chat-message__header">
|
|
66
70
|
<span v-if="$slots.avatar" class="qk-chat-message__avatar"><slot name="avatar" /></span>
|
|
67
71
|
<slot name="header"><span>{{ author }}</span></slot>
|
|
68
72
|
</div>
|
|
69
73
|
<div v-if="$slots.default || parts?.length" :key="identity" class="qk-chat-message__content" :data-mode="$slots.default ? 'slot' : 'parts'">
|
|
70
74
|
<slot>
|
|
71
|
-
<QuireChatMessagePart v-for="part in parts" :key="part.id" :part="part" :message-id="messageId"
|
|
75
|
+
<QuireChatMessagePart v-for="part in parts" :key="part.id" :part="part" :message-id="messageId" :show-text-status="part.kind !== 'text' || part.state !== state || (!status && !$slots.status)"
|
|
76
|
+
@action="emit('action', $event)" @attachment-action="emit('attachmentAction', $event)" @source-navigate="emit('sourceNavigate', $event)" @confirmation-decision="emit('confirmationDecision', $event)" @question-draft-change="emit('questionDraftChange', $event)" @question-open="emit('questionOpen', $event)" @question-submit="emit('questionSubmit', $event)">
|
|
72
77
|
<template v-if="$slots.text" #text="context"><slot name="text" v-bind="context" /></template>
|
|
73
78
|
<template v-if="$slots.reasoning" #reasoning="context"><slot name="reasoning" v-bind="context" /></template>
|
|
74
79
|
<template v-if="$slots['tool-input']" #tool-input="context"><slot name="tool-input" v-bind="context" /></template>
|
|
@@ -53,7 +53,7 @@ function dispatchMore(value: string): void {
|
|
|
53
53
|
<template>
|
|
54
54
|
<LocaleScope v-slot="{ dir }">
|
|
55
55
|
<div ref="root" v-chat-focus-recovery v-bind="$attrs" class="qk-chat-actions" :dir="dir" :data-reveal="reveal || undefined" tabindex="-1">
|
|
56
|
-
<QuireClipboard v-if="copyText
|
|
56
|
+
<QuireClipboard v-if="copyText && !active" :value="copyText" mode="icon" variant="text"
|
|
57
57
|
@status-change="emit('copy')" @copy-error="emit('copyError', $event)">
|
|
58
58
|
<template #control="control"><QuireChatMessageAction
|
|
59
59
|
:action="{ id: 'copy', label: control.error ? labels.copyError : control.copied ? labels.copied : labels.copy, icon: control.copied ? 'check' : 'copy', disabled: control.disabled }"
|
|
@@ -100,12 +100,12 @@ it('forwards clipboard success and failure with the originating message id', asy
|
|
|
100
100
|
const app = createApp({ render: () => h(MessageList, { messages: [{ messageId: 'copy-me', author: '助手', copyText: state.text }], onCopy: copied, onCopyError: failed }) });
|
|
101
101
|
app.mount(host);
|
|
102
102
|
try {
|
|
103
|
-
host.querySelector<HTMLButtonElement>('button[aria-label="
|
|
103
|
+
host.querySelector<HTMLButtonElement>('button[aria-label="复制消息"]')!.click();
|
|
104
104
|
await vi.waitFor(() => expect(copied).toHaveBeenCalledWith({ messageId: 'copy-me' }));
|
|
105
105
|
expect(write).toHaveBeenCalledWith('权威原文');
|
|
106
106
|
state.text = '另一段'; await nextTick();
|
|
107
107
|
const error = new Error('permission denied'); write.mockRejectedValue(error);
|
|
108
|
-
host.querySelector<HTMLButtonElement>('button[aria-label="
|
|
108
|
+
host.querySelector<HTMLButtonElement>('button[aria-label="复制消息"]')!.click();
|
|
109
109
|
await vi.waitFor(() => expect(failed).toHaveBeenCalledWith({ messageId: 'copy-me', value: '另一段', error }));
|
|
110
110
|
} finally { app.unmount(); host.remove(); vi.restoreAllMocks(); }
|
|
111
111
|
});
|
|
@@ -43,7 +43,7 @@ const text = useQuireKitMessages('chat');
|
|
|
43
43
|
const area = ref<InstanceType<typeof QuireScrollArea>>();
|
|
44
44
|
const content = ref<HTMLElement>();
|
|
45
45
|
const keys = computed(() => props.messages.map(message => message.messageId));
|
|
46
|
-
const { following, nodes, onScroll, scrollToLatest, scrollToMessage } = useMessageListScroll({
|
|
46
|
+
const { following, latestBelow, nodes, onScroll, scrollToLatest, scrollToMessage } = useMessageListScroll({
|
|
47
47
|
viewport: () => area.value?.getViewportElement() ?? null, content,
|
|
48
48
|
keys: () => keys.value, session: () => props.conversationId,
|
|
49
49
|
onFollowingChange: value => emit('followingChange', value)
|
|
@@ -110,7 +110,7 @@ defineExpose<QuireKitChatMessageListHandle>({ scrollToLatest, scrollToMessage })
|
|
|
110
110
|
</div>
|
|
111
111
|
</div>
|
|
112
112
|
</QuireScrollArea>
|
|
113
|
-
<div v-if="!following" class="qk-chat-message-list__latest">
|
|
113
|
+
<div v-if="!following && latestBelow" class="qk-chat-message-list__latest">
|
|
114
114
|
<QuireButton variant="soft" @click="jumpToLatest">{{ text.list.latest }}</QuireButton>
|
|
115
115
|
</div>
|
|
116
116
|
</div>
|
|
@@ -27,6 +27,8 @@ export interface MessageListScrollOptions {
|
|
|
27
27
|
export interface MessageListScrollController extends QuireKitChatMessageListHandle {
|
|
28
28
|
/** Whether new geometry should keep the viewport at its end. */
|
|
29
29
|
readonly following: Ref<boolean>;
|
|
30
|
+
/** Whether the latest content is below the viewport, beyond the follow threshold. */
|
|
31
|
+
readonly latestBelow: Ref<boolean>;
|
|
30
32
|
/** Item elements updated by Vue template refs. */
|
|
31
33
|
readonly nodes: Map<string, HTMLElement>;
|
|
32
34
|
/** Native viewport scroll handler. */
|
|
@@ -63,7 +63,8 @@ it('does not recapture changed media geometry from the scroll event of its own c
|
|
|
63
63
|
const viewport = document.createElement('div');
|
|
64
64
|
const item = document.createElement('div');
|
|
65
65
|
const host = document.createElement('div');
|
|
66
|
-
|
|
66
|
+
let scrollHeight = 2000;
|
|
67
|
+
Object.defineProperties(viewport, { scrollHeight: { get: () => scrollHeight }, clientHeight: { value: 200 } });
|
|
67
68
|
vi.spyOn(viewport, 'getBoundingClientRect').mockImplementation(() => new DOMRect(0, 0, 300, 200));
|
|
68
69
|
let mediaGrowth = 0;
|
|
69
70
|
const measure = vi.spyOn(item, 'getBoundingClientRect').mockImplementation(() => new DOMRect(0, 200 + mediaGrowth - viewport.scrollTop, 300, 100));
|
|
@@ -90,6 +91,11 @@ it('does not recapture changed media geometry from the scroll event of its own c
|
|
|
90
91
|
mediaGrowth += 30; resize(); frames.shift()!(0);
|
|
91
92
|
expect(viewport.scrollTop).toBe(680);
|
|
92
93
|
expect(item.getBoundingClientRect().top).toBe(42);
|
|
94
|
+
expect(api.latestBelow.value).toBe(true);
|
|
95
|
+
// Closing a disclosure can fit the whole conversation without a native scroll event.
|
|
96
|
+
scrollHeight = 200; viewport.scrollTop = 0; resize(); frames.shift()!(0);
|
|
97
|
+
expect(api.latestBelow.value).toBe(false);
|
|
98
|
+
expect(api.following.value).toBe(false);
|
|
93
99
|
} finally {
|
|
94
100
|
app.unmount(); vi.restoreAllMocks(); vi.unstubAllGlobals();
|
|
95
101
|
}
|
|
@@ -8,6 +8,7 @@ import type { MessageListScrollController, MessageListScrollOptions, ReadingAnch
|
|
|
8
8
|
*/
|
|
9
9
|
export function useMessageListScroll(options: MessageListScrollOptions): MessageListScrollController {
|
|
10
10
|
const following = ref(true);
|
|
11
|
+
const latestBelow = ref(false);
|
|
11
12
|
const nodes = new Map<string, HTMLElement>();
|
|
12
13
|
let anchors: ReadingAnchor[] = [];
|
|
13
14
|
let observer: ResizeObserver | undefined;
|
|
@@ -23,10 +24,12 @@ export function useMessageListScroll(options: MessageListScrollOptions): Message
|
|
|
23
24
|
following.value = value; options.onFollowingChange(value);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/** Record the actual reading position after scrolling or a content resize.
|
|
28
|
+
* @param viewport - The same native viewport used for anchor corrections.
|
|
29
|
+
*/
|
|
30
|
+
function capture(viewport: HTMLElement): void {
|
|
31
|
+
latestBelow.value = viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop > 24;
|
|
32
|
+
anchors = captureAnchors(options.keys(), nodes, viewport);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/** Process real user/native scrolling without interpreting our own correction as intent. */
|
|
@@ -38,8 +41,8 @@ export function useMessageListScroll(options: MessageListScrollOptions): Message
|
|
|
38
41
|
// Reconcile already captured this correction. A delayed scroll event may arrive after
|
|
39
42
|
// another image resize; recapturing here would accept its displacement as user intent.
|
|
40
43
|
if (corrected) return;
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
capture(viewport);
|
|
45
|
+
setFollowing(!latestBelow.value);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/** Apply one geometry correction per frame, then refresh the surviving anchor. */
|
|
@@ -51,7 +54,7 @@ export function useMessageListScroll(options: MessageListScrollOptions): Message
|
|
|
51
54
|
if (following.value) viewport.scrollTop = viewport.scrollHeight;
|
|
52
55
|
else restoreAnchor(anchors, nodes, viewport);
|
|
53
56
|
if (viewport.scrollTop !== before) writtenTop = viewport.scrollTop;
|
|
54
|
-
capture();
|
|
57
|
+
capture(viewport);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/** Coalesce content, viewport and key updates into the same layout pass. */
|
|
@@ -76,7 +79,7 @@ export function useMessageListScroll(options: MessageListScrollOptions): Message
|
|
|
76
79
|
setFollowing(false);
|
|
77
80
|
viewport.scrollTop += node.getBoundingClientRect().top - viewport.getBoundingClientRect().top;
|
|
78
81
|
writtenTop = viewport.scrollTop;
|
|
79
|
-
capture(); return true;
|
|
82
|
+
capture(viewport); return true;
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
onMounted(() => {
|
|
@@ -98,5 +101,5 @@ export function useMessageListScroll(options: MessageListScrollOptions): Message
|
|
|
98
101
|
if (frame !== undefined) view?.cancelAnimationFrame(frame);
|
|
99
102
|
nodes.clear();
|
|
100
103
|
});
|
|
101
|
-
return { following, nodes, onScroll, scrollToLatest, scrollToMessage };
|
|
104
|
+
return { following, latestBelow, nodes, onScroll, scrollToLatest, scrollToMessage };
|
|
102
105
|
}
|
|
@@ -95,7 +95,7 @@ it('escapes unsupported markdown, never dumps custom data and blocks copying a t
|
|
|
95
95
|
]) }); app.mount(host);
|
|
96
96
|
try {
|
|
97
97
|
expect(host.querySelector('img')).toBeNull();
|
|
98
|
-
expect(host.textContent).
|
|
98
|
+
expect(host.querySelector('[data-part-id="md"]')?.textContent).toBe('<img src=x onerror=alert(1)>');
|
|
99
99
|
expect(host.textContent).toContain('图表暂不可用');
|
|
100
100
|
expect(host.textContent).not.toContain('must-not-render');
|
|
101
101
|
expect(host.textContent).toContain('暂不支持此内容类型');
|