Skip to content

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
}

PrismCodeBlock

Code block to add the copy button to.

(codeBlock) => string

Function used to get the copied code. Can be used to e.g. omit deleted lines.

string = "Copy"

aria-label for the button. Defaults to "Copy".

string = "Copied!"

Temporary aria-label for the button after it has been clicked. Defaults to "Copied!".

void