简体中文
某一条目上的评论:带一级回复的评论线程、表情回应、编辑历史、行内引用和动态事件,以及用于发布新评论的输入框。宿主拥有数据和每一次变更;面板负责呈现、选中和焦点。
这是 Meta Astryx 实验室 Comments 的 Vue 移植,对齐 v0.7.13。每个线程复用 CommentThread / CommentRow,新评论、回复和编辑复用 CommentComposerBase,其中的表情按钮复用独立的 EmojiPicker。CommentPin 还不在这一刀里。
Comments
CommentThread
CommentRow
CommentComposerBase
EmojiPicker
CommentPin
此组件在 @astryx-vue/lab 中发布,只通过 canary 标签发布。
@astryx-vue/lab
canary
import { Comments, DEFAULT_COMMENT_REACTIONS } from '@astryx-vue/lab'
comments
readonly CommentThreadData[]
events
readonly CommentActivityEvent[]
[]
label
string
composerPosition
'top' | 'bottom' | 'none'
'bottom'
density
'compact' | 'balanced'
'balanced'
layout
'pane' | 'embedded'
'pane'
pane
embedded
selectedThreadId
string | null
currentUser
CommentUser
mode
'interactive' | 'non-editable' | 'read-only'
'interactive'
container
'section' | 'card'
'section'
composerAnchor
CommentAnchor
onComposerAnchorDismiss
() => void
isLoading
boolean
false
loadError
onRetryLoad
hasOlderComments
isLoadingOlder
onLoadOlder
onSubmit
(content: string, parentCommentId?: string) => void | Promise<void>
onSaveEdit
onDelete
onReact
onResolveThread
onReopenThread
onRetryComment
(commentId: string) => void | Promise<void>
status
error
loadVersions
(commentId: string) => Promise<readonly CommentVersion[]>
onUploadImages
CommentImageUploader
composerError
emptyState
VNode
renderEvent
(event: CommentActivityEvent) => VNode
event
isSubmitting
composerPlaceholder
highlightColor
CommentHighlightColor
'yellow'
reactionOptions
readonly CommentReactionOption[]
DEFAULT_COMMENT_REACTIONS
hasEmojiPicker
true
与线程共享的回调(onComposerDraftChange、getReplyMention、agentCommands、composerTriggers 以及各 render* 属性)含义与 CommentThread 相同。
onComposerDraftChange
getReplyMention
agentCommands
composerTriggers
render*
selected-thread-change
threadId: string | null
composer
renderComposer
composerControls
为 pane 提供明确的高度;面板会填满该容器,列表滚动,底部输入框停靠在下方。embedded 面板和线程、输入框一样高,适合放在 Card 或 Popover 里。在卡片父级中,第一条和最后一条线程会去掉外侧分隔线,避免卡片再套一层卡片。
Comments
某一条目上的评论:带一级回复的评论线程、表情回应、编辑历史、行内引用和动态事件,以及用于发布新评论的输入框。宿主拥有数据和每一次变更;面板负责呈现、选中和焦点。
这是 Meta Astryx 实验室
Comments的 Vue 移植,对齐 v0.7.13。每个线程复用CommentThread/CommentRow,新评论、回复和编辑复用CommentComposerBase,其中的表情按钮复用独立的EmojiPicker。CommentPin还不在这一刀里。此组件在
@astryx-vue/lab中发布,只通过canary标签发布。导入
属性
commentsreadonly CommentThreadData[]events按时间交错显示;默认从早到晚,只有当列表本身是从晚到早时才倒序。eventsreadonly CommentActivityEvent[][]labelstringcomposerPosition'top' | 'bottom' | 'none''bottom'density'compact' | 'balanced''balanced'layout'pane' | 'embedded''pane'pane填满容器并滚动,输入框停靠在底部。embedded按内容高度嵌入宿主的 Card 或 Popover:没有滚动区或停靠区;在卡片父级中,第一条线程上方和最后一条线程下方不绘制分隔线。selectedThreadIdstring | nullcurrentUserCommentUsermode'interactive' | 'non-editable' | 'read-only''interactive'container'section' | 'card''section'composerAnchorCommentAnchoronComposerAnchorDismiss() => voidisLoadingbooleanfalseloadErrorstringonRetryLoad时带有重试操作。通过共享播报通道断言式播报一次;Banner 本身没有 live 角色。hasOlderComments/isLoadingOlder/onLoadOlderfalse/false/ —onSubmit(content: string, parentCommentId?: string) => void | Promise<void>onSaveEdit/onDelete/onReactonResolveThread/onReopenThreadonRetryComment(commentId: string) => void | Promise<void>status为error的评论。loadVersions(commentId: string) => Promise<readonly CommentVersion[]>onUploadImagesCommentImageUploadercomposerErrorstringemptyStateVNodeemptyState插槽。renderEvent(event: CommentActivityEvent) => VNodeevent插槽。isSubmittingbooleanfalsecomposerPlaceholderstringhighlightColorCommentHighlightColor'yellow'reactionOptionsreadonly CommentReactionOption[]DEFAULT_COMMENT_REACTIONShasEmojiPickerbooleantrue与线程共享的回调(
onComposerDraftChange、getReplyMention、agentCommands、composerTriggers以及各render*属性)含义与CommentThread相同。事件
selected-thread-changethreadId: string | null插槽
emptyStateeventcomposerrenderComposer相同。composerControls布局
为
pane提供明确的高度;面板会填满该容器,列表滚动,底部输入框停靠在下方。embedded面板和线程、输入框一样高,适合放在 Card 或 Popover 里。在卡片父级中,第一条和最后一条线程会去掉外侧分隔线,避免卡片再套一层卡片。