mirror of https://github.com/zulip/zulip.git
rendered_markdown: Fix code getting copied when visiting playground.
Fixes #29844.
This commit is contained in:
parent
178d4f364b
commit
acf13e49cf
|
@ -307,14 +307,15 @@ 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).parent().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");
|
||||
|
|
|
@ -529,6 +529,7 @@ function assert_clipboard_setup() {
|
|||
assert.equal(clipboard_args[0], "copy-code-stub");
|
||||
const text = clipboard_args[1].text({
|
||||
to_$: () => ({
|
||||
parent: () => ({
|
||||
siblings(arg) {
|
||||
assert.equal(arg, "code");
|
||||
return {
|
||||
|
@ -536,6 +537,7 @@ function assert_clipboard_setup() {
|
|||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
assert.equal(text, "text");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue