用途
本技能是 Velt Inline Reactions(内联表情反应)功能的实现指南。该功能用于为应用中的具体元素添加带上下文的表情反馈,例如文章、帖子、图片、图表以及自定义 UI。
主要能力与适用时机
当出现以下需求时可参考本准则:
- 为页面区块、帖子或任何具备稳定元素 id 的容器添加内联反应。
- 通过 targetReactionElementId 将
<VeltInlineReactionsSection>绑定到该容器。 - 配置自定义反应表情(图片 URL、替代 iconUrl,或 unicode emoji)。
- 在非 React 或运行时代码中调用
client.getReactionElement().setCustomReactions(...)。 - 通过 wireframe 标签构建自定义反应 UI(自定义 pin、自定义 emoji 选择器、自定义 tooltip)。
- 读取
componentConfig.annotation、componentConfig.isReactionSelectedByCurrentUser、componentConfig.tooltipVisible,或读取逐次迭代的 user / emoji / isSelected 上下文变量。 - 针对 ReactionAnnotation / ReactionPinType 编写类型定义。
规则分类与优先级
按优先级分为三类:
-
API(HIGH,前缀 api-):
- api-setup —
<VeltInlineReactionsSection targetReactionElementId="...">的放置位置(必须与容器 id 匹配);customReactions prop 与client.getReactionElement().setCustomReactions()运行时方法;三种自定义表情条目形态(url、iconUrl、emoji)。
- api-setup —
-
Wireframe 变量(MEDIUM,前缀 wireframe-variables-):
- wireframe-variables-reactions — 三个主要 wireframe 标签(tool / pin / inline-section);各作用域下完整的 componentConfig.* 参考;嵌套分解(reactions-panel items、pin tooltip 用户行);上下文相关的逐次迭代变量(user、emoji、isSelected);扁平配置访问模式。
-
类型(MEDIUM,前缀 types-):
- types-reaction-annotation — ReactionAnnotation 结构(annotationId、from、reactions、commentAnnotationId、targetElement、targetElementId、position、type='reaction' 等);ReactionPinType 枚举('comment' | 'inline' | ...);交叉链接到自托管相关 resolver-request 结构。
使用方式
可阅读各条规则文件获取详细说明与代码示例:
- rules/shared/api/api-setup.md
- rules/shared/wireframe-variables/wireframe-variables-reactions.md
- rules/shared/types/types-reaction-annotation.md
每条规则包含:重要性说明、React / Next.js 及其他框架的代码示例、常见陷阱、验证清单、指向官方文档的来源指针。
编译文档
- AGENTS.md — 所有规则的压缩索引,含文件路径(建议从这里开始)。
- AGENTS.full.md — 完整详尽的指南,所有规则内联展开。
相关 Velt 技能
- 评论反应(comment reactions)— 评论与反应共用同一套 setCustomReactions 配置;相同的自定义表情映射通过
commentElement.setCustomReactions(...)传递(参见 velt-comments-best-practices)。应在正确的范围配置一次,不要按功能重复配置。 - 自托管反应数据(self-hosting reaction data)— velt-self-hosting-data-best-practices 记录了自行持久化反应所需的 resolver-request 结构(SaveReactionResolverRequest、DeleteReactionResolverRequest 等)。应交叉引用,不要重复。
限制
本资料未提供具体收费、价格、平台支持范围或效果数据等信息,暂未提供。