CommentThread 呈现一条评论会话,CommentDraft 用于新建评论,CommentRail 把卡片排列在所评论原文的高度上。三者只负责呈现与交互,评论数据、权限和保存由使用方提供。
评论会话
messages 的第一条是发起评论,其余是回复;quote 是被评论的原文。active 时展开全部回复并显示回复框;resolvable、replyable 决定是否提供解决与回复。可编辑、可删除由每条消息的 editable、deletable 决定,删除第一条即删除整条评论。传入 position({ index, total })时,选中的卡片在标题栏显示上一条 / 下一条按钮和“2 / 5”这样的位置,分别触发 previous、next;只有一条时不显示。⌘/Ctrl + Enter 发送,Esc 取消。
状态
未激活时只显示第一条和回复数量。resolved 使用浅底并标记已解决。quote-state 区分位置评论(point)、原文已删除(deleted)与找不到原文(unavailable)。
由宿主保存草稿与编辑
绑定 v-model:reply-draft 与 v-model:reply-open 后,回复草稿由宿主保存,切换线程再回来仍能恢复;发送后由宿主清空。绑定 editing-id 并提供 #editor 插槽可换成自己的编辑器,例如富文本编辑;保存和取消都通过修改 editing-id 完成。quote-label 改写无原文时的标签,以匹配产品用词。
actions 插槽把宿主自己的按钮放进卡片头部,排在“解决”之前。用 QuireCommentAction 传入 label 和 icon,样式与内置按钮一致,并自带 Tooltip。
新建评论
CommentDraft 打开时聚焦输入框,submit 返回正文,cancel 放弃。
页边排列
items 按文档顺序给出每张卡片锚点的高度。卡片落在锚点处;与上一张重叠时向下推开,间距由 gap 设置。height 通常传文档高度,卡片超出时栏高随之增加。
API
QuireCommentThread Props
Slots 内容位置
bodyFormatted message content; defaults to plain text with preserved line breaks.
{ message: { /** Stable identity within the thread. */ id: string; /** Message author. */ author: { /** Display name; also the source of the avatar initials. */ name: string; /** Optional avatar image URL. */ avatar?: string | undefined; /** Short label shown after the name, such as "AI" for an assistant. */ badge?: string | undefined; }; /** ISO 8601 time, shown compactly with the full value as a tooltip. */ time: string; /** Message text; render formatted content through the `body` slot. */ body: string; /** Whether the message was edited after posting. */ edited?: boolean | undefined; /** Whether the current user may edit this message. */ editable?: boolean | undefined; /** Whether the current user may delete this message; deleting the root deletes the thread. */ deletable?: boolean | undefined; /** Mentions in `body`, kept when the message is edited. */ mentions?: undefined | readonly ({ /** Stable host identity. */ id: string; /** Display name without the leading */ label: string; /** Destination written in the link. */ url: string; /** Secondary text in the suggestion list. */ description?: string | undefined; })[]; }; }editorReplaces the built-in plain-text editor, e.g. with a rich editor; the host saves and cancels through `editingId`.
{ message: { /** Stable identity within the thread. */ id: string; /** Message author. */ author: { /** Display name; also the source of the avatar initials. */ name: string; /** Optional avatar image URL. */ avatar?: string | undefined; /** Short label shown after the name, such as "AI" for an assistant. */ badge?: string | undefined; }; /** ISO 8601 time, shown compactly with the full value as a tooltip. */ time: string; /** Message text; render formatted content through the `body` slot. */ body: string; /** Whether the message was edited after posting. */ edited?: boolean | undefined; /** Whether the current user may edit this message. */ editable?: boolean | undefined; /** Whether the current user may delete this message; deleting the root deletes the thread. */ deletable?: boolean | undefined; /** Mentions in `body`, kept when the message is edited. */ mentions?: undefined | readonly ({ /** Stable host identity. */ id: string; /** Display name without the leading */ label: string; /** Destination written in the link. */ url: string; /** Secondary text in the suggestion list. */ description?: string | undefined; })[]; }; }actionsHost controls placed before resolve in the card header, usually small icon buttons.
any
Events 组件事件
update:editingId更新
editingId,可通过对应 v-model 绑定。[value: string | null]update:replyDraft更新
replyDraft,可通过对应 v-model 绑定。[value: string]update:replyOpen更新
replyOpen,可通过对应 v-model 绑定。[value: boolean]activate[]resolve[]reopen[]reply[body: string, mentions: readonly QuireKitCommentMention[]]edit[messageId: string, body: string, mentions: readonly QuireKitCommentMention[]]delete[messageId: string]previous[]next[]
QuireCommentDraft Props
Slots 内容位置
无公开插槽。
Events 组件事件
submit[body: string, mentions: readonly QuireKitCommentMention[]]cancel[]
QuireCommentRail Props
Slots 内容位置
itemOne card; positioned by the rail at its anchor or just below the previous card.
{ item: { /** Stable identity, also the slot key. */ id: string; /** Anchor top relative to the rail origin, in CSS pixels. */ anchorTop: number; }; }
Events 组件事件
无自定义事件。