Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(sender): add onPasteFile callback #495

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

ztkuaikuai
Copy link
Contributor

@ztkuaikuai ztkuaikuai commented Jan 23, 2025

Sender 组件文档 粘贴图片 Demo 中使用了 onPasteFile 回调,但缺少该回调的说明,故补上

另外
发现缺少 onPaste 回调的说明,在一些场景下可能需要该回调,例如:

用户在输入框粘贴一段网址,希望能够解析地址。

image

image

是否可以将 onPaste 回调暴露给组件使用者?

Summary by CodeRabbit

  • 新功能
    • 为发送组件添加了文件粘贴事件处理能力
    • 新增 onPasteFile 属性,支持在组件中处理文件粘贴操作

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

📝 Walkthrough

概览

遍历

此拉取请求为 Sender 组件的文档(英文和中文版本)添加了一个新的属性 onPasteFile。这个回调函数允许组件处理文件粘贴事件,接受一个 File 对象作为参数。文档的其他部分保持不变,新属性扩展了组件的功能。

变更

文件 变更摘要
components/sender/index.en-US.md 添加 onPasteFile 属性到 SenderProps 接口
components/sender/index.zh-CN.md 添加 onPasteFile 属性到 SenderProps 接口

可能相关的 PR

诗歌

🐰 代码兔子轻轻跳,
粘贴文件新技能,
组件功能更强大,
用户体验添翅膀!
文档更新,兔子笑 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jan 23, 2025

Preview is ready

Copy link

Walkthrough

此PR更新了Sender组件文档,添加了onPasteFile回调的说明。该回调用于在粘贴文件时触发。此外,PR中还提到onPaste回调的潜在需求。

Changes

文件 概要
components/sender/index.en-US.md 添加了onPasteFile回调的说明,描述了其在粘贴文件时的作用。
components/sender/index.zh-CN.md 添加了onPasteFile回调的说明,描述了其在粘贴文件时的作用。

@@ -52,6 +52,7 @@ Common props ref:[Common props](/docs/react/common-props)
| onSubmit | Callback when click send button | (message: string) => void | - | - |
| onChange | Callback when input value changes | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | Callback when click cancel button | () => void | - | - |
| onPasteFile | Callback when paste file | (file: File) => void | - | - |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the onPasteFile callback is properly implemented in the component logic to handle file pasting events effectively.

@@ -53,6 +53,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
| onSubmit | 点击发送按钮的回调 | (message: string) => void | - | - |
| onChange | 输入框值改变的回调 | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | 点击取消按钮的回调 | () => void | - | - |
| onPasteFile | 黏贴文件的回调 | (file: File) => void | - | - |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确保在组件逻辑中正确实现onPasteFile回调,以有效处理文件粘贴事件。

Copy link

codecov bot commented Jan 23, 2025

Bundle Report

Bundle size has no change ✅

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 119f992 and 67bc0bd.

📒 Files selected for processing (2)
  • components/sender/index.en-US.md (1 hunks)
  • components/sender/index.zh-CN.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / react component workflow
  • GitHub Check: build preview
  • GitHub Check: size
🔇 Additional comments (1)
components/sender/index.en-US.md (1)

55-55: 建议完善英文文档中 onPasteFile 回调的说明

英文文档中的说明同样需要补充。建议与中文文档保持一致,更新为:

-| onPasteFile | Callback when paste file | (file: File) => void | - | - |
+| onPasteFile | Callback triggered when a file (e.g., image) is pasted from clipboard. See `paste-image.tsx` demo for usage example. Note: For regular text paste events, use `onPaste` instead. | (file: File) => void | - | - |

@@ -53,6 +53,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
| onSubmit | 点击发送按钮的回调 | (message: string) => void | - | - |
| onChange | 输入框值改变的回调 | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | 点击取消按钮的回调 | () => void | - | - |
| onPasteFile | 黏贴文件的回调 | (file: File) => void | - | - |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议完善 onPasteFile 回调的文档说明

当前文档对 onPasteFile 回调的说明过于简单。建议补充以下内容:

  1. 支持的文件类型说明
  2. paste-image.tsx 示例的关联说明
  3. 与普通的 onPaste 事件的区别
  4. 使用场景和最佳实践

建议更新为:

-| onPasteFile | 黏贴文件的回调 | (file: File) => void | - | - |
+| onPasteFile | 黏贴文件的回调,用于处理用户通过剪贴板粘贴的文件(如图片)。可以配合 `paste-image.tsx` 示例了解具体用法。注意:普通文本的粘贴事件请使用 `onPaste` 处理。 | (file: File) => void | - | - |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| onPasteFile | 黏贴文件的回调 | (file: File) => void | - | - |
| onPasteFile | 黏贴文件的回调,用于处理用户通过剪贴板粘贴的文件(如图片)。可以配合 `paste-image.tsx` 示例了解具体用法。注意:普通文本的粘贴事件请使用 `onPaste` 处理。 | (file: File) => void | - | - |

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.45%. Comparing base (88aeb24) to head (6a14b43).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #495   +/-   ##
=======================================
  Coverage   91.45%   91.45%           
=======================================
  Files          67       67           
  Lines        1462     1462           
  Branches      370      370           
=======================================
  Hits         1337     1337           
  Misses        125      125           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@YumoImer YumoImer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献!

@YumoImer YumoImer merged commit 9c6b0cc into ant-design:main Jan 24, 2025
11 checks passed
@ztkuaikuai ztkuaikuai deleted the docs/sender branch January 24, 2025 06:56
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.

2 participants