-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix for ctrl+c on examples copies the whole text, not just the selection #73
Conversation
@@ -31,20 +31,13 @@ export default function CodeSnippet({ | |||
return <span className={styles.inlineCode}>{children}</span>; | |||
} | |||
if (children[children.length - 1] === "\n") children = children.slice(0, -1); | |||
// remove the last \n from children |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove this comment? Please keep as it is.
@@ -35,6 +35,7 @@ | |||
"framer-motion": "^11.1.9", | |||
"geist": "^1.3.0", | |||
"gray-matter": "^4.0.3", | |||
"my-app": "file:", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this change relevant?
<div | ||
className={styles.codeSnippetContainer} | ||
onCopy={(e) => { | ||
e.preventDefault(); | ||
e.clipboardData.setData("text/plain", children); | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works! but have you seen the pasted code after this change? The code is not formatted correctly. It looks something like the below image
We also need to keep the code formatted as it is in the codeblock. This formatting issue is primarily from the react-syntax-highlighter library. You can look online and find out how other projects are using this library and find some solution for the issue.
thank you for the review. will address these. |
Code fix for ctrl+c on examples copies the whole text, not just the selection
Closes #53