Skip to content

Commit

Permalink
rendered_markdown: Fix code getting copied when visiting playground.
Browse files Browse the repository at this point in the history
Fixes #29844.
  • Loading branch information
nimishmedatwal committed Apr 26, 2024
1 parent 5c0cccc commit 117bca2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions web/src/rendered_markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,17 @@ export const update_elements = ($content: JQuery): void => {
$view_in_playground_button.attr("data-tippy-content", title);
$view_in_playground_button.attr("aria-label", title);
}

const clipboard = new ClipboardJS($buttonContainer[0], {
const $copy_button = $buttonContainer.find(".copy_codeblock");
const clipboard = new ClipboardJS($copy_button[0], {
text(copy_element) {
return $(copy_element).siblings("code").text();
const $code = $(copy_element)
.closest("div.code-buttons-container")
.siblings("code");
return $code.text();
},
});

clipboard.on("success", () => {
const $copy_button = $buttonContainer.find(".copy_codeblock");
show_copied_confirmation($copy_button[0]);
});
$codehilite.addClass("zulip-code-block");
Expand Down

0 comments on commit 117bca2

Please sign in to comment.