1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-19 20:12:52 +02:00

cheat-sheet: Allow click to copy on hex value

[why]
We removed the functionality with the previous commit and replaced it
with 'copy the UTF16 code' (needed for codepoints > u_FFFF).

But people might want to have the possibility to easily (by click) copy
the codepoint hex number.

[how]
Add highlighting on the hex number and allow clicking to copy the value.

[note]
The tooltip will be added in the cheat-sheet generator.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-01-25 19:43:59 +01:00
parent bae34d36a1
commit 6e361d40ca
2 changed files with 9 additions and 2 deletions

View File

@ -150,6 +150,11 @@ a.nerd-font-button:before {
border-color: #0fbfcf; border-color: #0fbfcf;
} }
#main .nerd-font-cheat-sheet .column .codepoint:hover {
background: #767260;
text-decoration: underline;
}
#main .nerd-font-cheat-sheet .column:hover .class-name { #main .nerd-font-cheat-sheet .column:hover .class-name {
color: #0fbfcf; color: #0fbfcf;
} }

View File

@ -318,8 +318,6 @@ document.addEventListener('DOMContentLoaded', function () {
if (parent.className === 'glyph-popout-copy-clipboard') { if (parent.className === 'glyph-popout-copy-clipboard') {
if (target.className === 'copy-class') { if (target.className === 'copy-class') {
textToCopy = parent.parentNode.querySelector('.class-name').innerText; textToCopy = parent.parentNode.querySelector('.class-name').innerText;
} else if (target.className === 'copy-hex') {
textToCopy = parent.parentNode.querySelector('.codepoint').innerText;
} else if (target.className === 'copy-glyph') { } else if (target.className === 'copy-glyph') {
textToCopy = window textToCopy = window
.getComputedStyle(document.querySelector(`.${parent.parentNode.querySelector('.class-name').innerText}`), ':before') .getComputedStyle(document.querySelector(`.${parent.parentNode.querySelector('.class-name').innerText}`), ':before')
@ -340,6 +338,10 @@ document.addEventListener('DOMContentLoaded', function () {
textToCopy += glyph.charCodeAt(i++).toString(16); textToCopy += glyph.charCodeAt(i++).toString(16);
} }
} }
} else if (parent.className.startsWith('column') && target.className === 'codepoint') {
textToCopy = parent.parentNode.querySelector('.codepoint').innerText;
}
if (textToCopy.length > 0) {
gtag('event', event.target.className, { gtag('event', event.target.className, {
event_category: 'clipboard-copy', event_category: 'clipboard-copy',
event_label: 'Copy To Clipboard : ' + textToCopy, event_label: 'Copy To Clipboard : ' + textToCopy,