addCopyButton
addCopyButton(
codeBlock,getCode?,label?,copiedLabel?):void
Defined in: client/code-block.ts:102
Adds a copy button to a code block. Requires styles from
prism-code-editor/copy-button.css.
By default, the copy button is only shown when the code block is hovered. To always show it, change the default opacity with the following CSS:
button.pce-copy { opacity: 1; // or a lower value for a semi-transparent button}Parameters
Section titled “Parameters”codeBlock
Section titled “codeBlock”Code block to add the copy button to.
getCode?
Section titled “getCode?”(codeBlock) => string
Function used to get the copied code. Can be used to e.g. omit deleted lines.
label?
Section titled “label?”string = "Copy"
aria-label for the button. Defaults to "Copy".
copiedLabel?
Section titled “copiedLabel?”string = "Copied!"
Temporary aria-label for the button after it has been clicked.
Defaults to "Copied!".
Returns
Section titled “Returns”void