Add copy button for code

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2023-03-25 22:04:43 +05:30
parent af305620b6
commit 35ab348ab4
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
3 changed files with 179 additions and 0 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,8 @@
{
"id": "code-block-copy",
"name": "Copy button for code blocks",
"author": "Daniel Brandenburg",
"description": "Copy button for code blocks",
"isDesktopOnly": false,
"version": "0.1.0"
}

View file

@ -0,0 +1,41 @@
.copy-code-button {
color: var(--background-primary);
background-color: var(--text-faint);
border-radius: 1px 1px 0px 0px;
/* right-align */
display: block;
margin-left: auto;
margin-right: 0;
margin-bottom: -2px;
padding: 3px 8px;
font-size: 0.8em;
position: absolute;
top: 0px;
right: 0px;
}
.copy-code-button:hover {
cursor: pointer;
background-color: var(--text-normal);
}
.copy-code-button:focus {
/* Avoid an ugly focus outline on click in Chrome,
but darken the button for accessibility.
See https://stackoverflow.com/a/25298082/1481479 */
background-color: var(--text-normal);
outline: 0;
}
.copy-code-button:active {
background-color: var(--text-normal);
}
.highlight pre {
/* Avoid pushing up the copy buttons. */
margin: 0;
}
.has-copy-button {
position: relative;
}