Skip to content

Add copy button to code blocks - #14

Merged
winghoima merged 1 commit into
mainfrom
copy-button
Oct 19, 2025
Merged

winghoima merged 1 commit into
mainfrom
copy-button

Conversation

@winghoima

Copy link
Copy Markdown
Owner

Added a copy button that appears when hovering over code blocks in chat messages. This improves developer experience by allowing one-click copying of code snippets.

Features:

  • Copy button appears on hover over code blocks
  • One-click copying to clipboard
  • Visual feedback shows "Copied!" with green background for 2 seconds
  • Smooth fade-in/fade-out transitions

Changes:

  • Modified markdown-it highlight function to wrap code blocks with copy button (Block.tsx:42-52)
  • Added useEffect hook to handle clipboard copy functionality (Block.tsx:89-123)
  • Added CSS styling for copy button with hover effects (App.css:5-52)
  • Added contentRef to Box component for DOM manipulation (Block.tsx:201)

Added a copy button that appears when hovering over code blocks in chat messages.
This improves developer experience by allowing one-click copying of code snippets.

Features:
- Copy button appears on hover over code blocks
- One-click copying to clipboard
- Visual feedback shows "Copied!" with green background for 2 seconds
- Smooth fade-in/fade-out transitions

Changes:
- Modified markdown-it highlight function to wrap code blocks with copy button (Block.tsx:42-52)
- Added useEffect hook to handle clipboard copy functionality (Block.tsx:89-123)
- Added CSS styling for copy button with hover effects (App.css:5-52)
- Added contentRef to Box component for DOM manipulation (Block.tsx:201)
@winghoima
winghoima merged commit 40d8376 into main Oct 19, 2025
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.

1 participant