mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
clipboard: make copy button reachable by keyboard #983
This commit is contained in:
parent
ee07f8ff7d
commit
64ffb39f35
3 changed files with 20 additions and 1 deletions
|
@ -1443,12 +1443,17 @@ div.highlight .copy-to-clipboard-button {
|
|||
display: block;
|
||||
}
|
||||
}
|
||||
div.highlight:focus-within .copy-to-clipboard-button,
|
||||
div.highlight .copy-to-clipboard-button:active,
|
||||
div.highlight:hover .copy-to-clipboard-button {
|
||||
display: block;
|
||||
}
|
||||
.disableHoverBlockCopyToClipBoard div.highlight .copy-to-clipboard-button {
|
||||
display: block;
|
||||
}
|
||||
.force-display {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
div.highlight > div table + .copy-to-clipboard-button > i,
|
||||
div.highlight pre:not(.mermaid) + .copy-to-clipboard-button > i,
|
||||
|
|
|
@ -1 +1 @@
|
|||
7.2.1+8c403f2aadf03c87f7741ead8e4c5425cbe30ed1
|
||||
7.2.1+ee07f8ff7d48f12d35f6b843225d6ecb3af157ba
|
|
@ -688,6 +688,20 @@ function initCodeClipboard() {
|
|||
pre.parentNode.replaceChild(div, pre);
|
||||
pre = clone;
|
||||
}
|
||||
// we have to make sure, the button is visible while
|
||||
// Clipboard.js is doing its magic
|
||||
button.addEventListener('focus', function (ev) {
|
||||
setTimeout(function () {
|
||||
ev.target.classList.add('force-display');
|
||||
}, 0);
|
||||
});
|
||||
button.addEventListener('blur', function (ev) {
|
||||
this.removeAttribute('aria-label');
|
||||
this.classList.remove('tooltipped', 'tooltipped-w', 'tooltipped-se', 'tooltipped-sw');
|
||||
setTimeout(function () {
|
||||
ev.target.classList.remove('force-display');
|
||||
}, 0);
|
||||
});
|
||||
pre.parentNode.insertBefore(button, pre.nextSibling);
|
||||
} else {
|
||||
code.dataset.code = text;
|
||||
|
|
Loading…
Reference in a new issue