Add copy button for code
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
af305620b6
commit
35ab348ab4
3 changed files with 179 additions and 0 deletions
130
.obsidian/plugins/code-block-copy/main.js
vendored
Normal file
130
.obsidian/plugins/code-block-copy/main.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
.obsidian/plugins/code-block-copy/manifest.json
vendored
Normal file
8
.obsidian/plugins/code-block-copy/manifest.json
vendored
Normal 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"
|
||||||
|
}
|
41
.obsidian/plugins/code-block-copy/styles.css
vendored
Normal file
41
.obsidian/plugins/code-block-copy/styles.css
vendored
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue