-
Notifications
You must be signed in to change notification settings - Fork 231
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: restore copy button in tabs #1326
Conversation
textToCopy = textToCopy.replace(/^[\$>\s]+/, ""); | ||
navigator?.clipboard?.writeText(textToCopy); | ||
document.addEventListener("click", (event) => { | ||
const btn = (event.target as HTMLElement).closest("button[data-copy]"); |
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.
The button has svg icons, so use closest
to prevent missing copies.
@@ -30,28 +30,6 @@ export default function codeblockCopyPlugin(md: any) { | |||
</button> | |||
`; | |||
|
|||
const script = ` |
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.
Moved to the copy.client.ts
file.
if (!btn) { | ||
return; | ||
} |
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.
nit: I don't think this can be null or undefined even if the button was removed at this point
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.
Confirmed this fixes the issue locally. Thanks for the important fix!
ref: #1292
I fixed the copy button in the tabs.
The reason the copy button in the tabs didn't work was because of the render order issue. So I moved the binding delegate to the document.
tested in local:
2025-01-12.2.53.22.mov