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

Fix for ctrl+c on examples copies the whole text, not just the selection #73

Closed
wants to merge 2 commits into from

Conversation

AkshataABhat
Copy link

Code fix for ctrl+c on examples copies the whole text, not just the selection
Closes #53

@@ -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
Copy link
Member

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:",
Copy link
Member

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?

Comment on lines -41 to -47
<div
className={styles.codeSnippetContainer}
onCopy={(e) => {
e.preventDefault();
e.clipboardData.setData("text/plain", children);
}}
>
Copy link
Member

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
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.

@AkshataABhat
Copy link
Author

thank you for the review. will address these.

@AkshataABhat AkshataABhat closed this by deleting the head repository Sep 14, 2024
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.

ctrl+c on examples copies the whole text, not just the selection
2 participants