Skip to content

Conversation

@simonguo
Copy link
Owner

@simonguo simonguo commented Jul 3, 2025

This pull request introduces enhancements to the CodeView and MarkdownRenderer components, focusing on adding support for customizable copy button properties and improving the test coverage for these components. The changes ensure that the copy button functionality is more flexible and thoroughly tested.

Enhancements to CodeView Component:

  • Added a new copyButtonProps prop to the CodeViewProps interface, allowing customization of the copy button's attributes. (src/CodeView.tsx, src/CodeView.tsxR12-R14)
  • Updated the CodeView component to pass the copyButtonProps to the MarkdownRenderer when rendering HTML fragments. (src/CodeView.tsx, src/CodeView.tsxL60-R67)

Enhancements to MarkdownRenderer Component:

  • Modified the appendCopyButton function to accept and apply custom button properties (copyButtonProps) when creating the copy button. (src/MarkdownRenderer.tsx, src/MarkdownRenderer.tsxR40-R59)
  • Updated the MarkdownRendererProps interface to include the copyButtonProps property. (src/MarkdownRenderer.tsx, src/MarkdownRenderer.tsxR10-R25)

Testing Improvements:

  • Added comprehensive tests for the CodeView component, including tests for rendering, passing copyButtonProps, and ensuring the sourceCode is passed correctly. (__tests__/CodeView-test.js, tests/CodeView-test.jsR1-R53)
  • Added comprehensive tests for the MarkdownRenderer component, covering rendering, handling multiple code blocks, and verifying the copy button's functionality and customization. (__tests__/MarkdownRenderer-test.js, tests/MarkdownRenderer-test.jsR1-R152)

@simonguo simonguo merged commit 9df0726 into main Jul 3, 2025
1 of 2 checks passed
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