From 6e361d40ca6ed477f5f32d968dabd2219c411e21 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 25 Jan 2023 19:43:59 +0100 Subject: [PATCH] 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 --- _includes/css/nerd-font-tweaks.scss | 5 +++++ site.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/_includes/css/nerd-font-tweaks.scss b/_includes/css/nerd-font-tweaks.scss index d1e54f1cd..0e18a4d6a 100644 --- a/_includes/css/nerd-font-tweaks.scss +++ b/_includes/css/nerd-font-tweaks.scss @@ -150,6 +150,11 @@ a.nerd-font-button:before { 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 { color: #0fbfcf; } diff --git a/site.js b/site.js index aac757973..135036940 100644 --- a/site.js +++ b/site.js @@ -318,8 +318,6 @@ document.addEventListener('DOMContentLoaded', function () { if (parent.className === 'glyph-popout-copy-clipboard') { if (target.className === 'copy-class') { 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') { textToCopy = window .getComputedStyle(document.querySelector(`.${parent.parentNode.querySelector('.class-name').innerText}`), ':before') @@ -340,6 +338,10 @@ document.addEventListener('DOMContentLoaded', function () { 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, { event_category: 'clipboard-copy', event_label: 'Copy To Clipboard : ' + textToCopy,