Skip to content

[sync] fix(sender): support formatResult for content slots (#1986) - #163

Merged
cc-hearts merged 1 commit into
mainfrom
sync/ant-design-x-1986
Aug 4, 2026
Merged

[sync] fix(sender): support formatResult for content slots (#1986)#163
cc-hearts merged 1 commit into
mainfrom
sync/ant-design-x-1986

Conversation

@cc-hearts

Copy link
Copy Markdown
Member

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

Closes #146

Upstream PR: ant-design/x#1986
Upstream merge commit: be739c5653ae14a3349f467222989fae6178edbd

💡 Background and Solution

Sender's content slots returned their live DOM text before reaching the shared formatResult pipeline. This made editable content slots inconsistent with input, select, tag, and custom slots.

This change reads the current DOM text for content slots and then applies formatResult, while preserving the raw-text fallback when no formatter is configured. It also adds coverage for edited content, unformatted content, and mixed slot types, plus a Vue demo and API documentation updates.

Validation:

  • vp check (0 errors; 8 existing warnings outside changed files)
  • vp test --run (45 files, 450 tests passed)
  • vp run docs:build

📝 Change Log

Language Changelog
🇺🇸 English Sender content slots now apply formatResult to the latest edited text.
🇨🇳 Chinese Sender 的 content 词槽现在会对用户编辑后的最新文本应用 formatResult

@cc-hearts

Copy link
Copy Markdown
Member Author

Review:✅ 修复合理,建议合并

改动准确命中了 issue 描述的问题:config.type === "content"rawValue 改为取 element.innerText(实时 DOM 文本),再统一走 config.formatResult?.(rawValue),未配置 formatter 时 formatted ?? stringifyValue(rawValue) 原样返回。其他词槽类型仍从 slotValues 读取,无回归。

关于测试里 contentSlot.element.innerText = "Edited Value":jsdom 不实现 innerText,这行实际只是挂了个自有属性。但组件自身写入侧(SlotTextArea.tsx:403slotDom.innerText =)用的也是同一个属性,读写对称,因此断言成立 —— 这与既有的「backspacing inside the slot」测试是同一套路,符合本仓库现状。

文档表格同步说明了 formatResult 对所有词槽类型生效,demo 也补了。无阻塞问题。

@cc-hearts
cc-hearts merged commit f319c1d into main Aug 4, 2026
1 check passed
@cc-hearts
cc-hearts deleted the sync/ant-design-x-1986 branch August 4, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sync][P2] Sender: content 词槽支持 formatResult (#1986)

1 participant