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: restore copy button in tabs #1326

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Conversation

tolluset
Copy link
Contributor

@tolluset tolluset commented Jan 12, 2025

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

textToCopy = textToCopy.replace(/^[\$>\s]+/, "");
navigator?.clipboard?.writeText(textToCopy);
document.addEventListener("click", (event) => {
const btn = (event.target as HTMLElement).closest("button[data-copy]");
Copy link
Contributor Author

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 = `
Copy link
Contributor Author

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.

@tolluset tolluset marked this pull request as ready for review January 12, 2025 05:58
Comment on lines +14 to +16
if (!btn) {
return;
}
Copy link
Member

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

Copy link
Member

@kt3k kt3k left a 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!

@kt3k kt3k merged commit fd20f71 into denoland:main Jan 21, 2025
2 checks passed
@tolluset tolluset deleted the fix-markdown-copy branch January 23, 2025 09:06
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.

2 participants