Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refer to
chatgpt-demo/src/components/MessageItem.tsx
, add a copy button to the rendered code block insrc/components/Markdown.tsx
, and the icon usesi-c Arbon-copy
, the emerald green will be displayed when the mouse is hovered, and it will become thei-carbon-checkmark
icon after clicking.The
code-copy-btn
andcode-copy-tips
styles have been added tounocss.config.ts
for the code copy button.package.json
has addedsolidjs-use
to implement the code copy function.By the way, the setting switch of Vercel Analytics has been added to
astro.config.mjs
.Linked Issues
#48
Additional context
BUG: Initially, the mouse hover to display tips was set for the code copy button, but the hover will be triggered to display tips when the mouse covers the text interface, instead of the expected mouse cover to display when copying the button.
And the code that implements code copy is all placed in
Markdown.tsx
, which makesMarkdown.tsx
look less beautiful.Demo
https://anse-tree.vercel.app
![截屏2023-09-13 17 05 54](https://private-user-images.githubusercontent.com/37926645/267644560-029e5fae-fc9c-4adb-8ad6-00bb04ac5f78.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwNjUxNTYsIm5iZiI6MTcyMDA2NDg1NiwicGF0aCI6Ii8zNzkyNjY0NS8yNjc2NDQ1NjAtMDI5ZTVmYWUtZmM5Yy00YWRiLThhZDYtMDBiYjA0YWM1Zjc4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDAzNDczNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkxMDg3MGU5MmZkMDU5ZjhkOTUzMGE4MTU2NWVhNDA4ZmEzZGMzOTAzNGU0MjNmOWNmNmIyODQwZjA1ZWVmOTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MX_VYGU1zrzjcc4Iv8lQxg1d1t4I3lCz1Z-FvOs4u3E)