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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tolluset
Copy link

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

1 participant