Skip to content

Commit ba8028d

Browse files
committed
Fix copy button copying line numbers, fix selection color causing code to be poorly readable when selecting, fix selection height for code blocks, fix duplicate underline effect for tabs
1 parent de00657 commit ba8028d

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

themes/trafiklab-2024/assets/sass/shortcodes/_highlight.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
span {
44
// Default color when no highlighting is used
55
color: $color-white;
6+
display: inline-block;
7+
line-height: 16px;
8+
height: 16px;
69
}
710

811
&:not(.code-tabs .highlight-wrapper) {
@@ -28,7 +31,7 @@
2831
.copy-code-button {
2932
position: absolute;
3033
z-index: 2;
31-
right: 18px;
34+
right: 0;
3235
top: 0;
3336
font-size: 13px;
3437
font-weight: 700;
@@ -60,4 +63,8 @@
6063
z-index: -1;
6164
opacity: .01;
6265
}
66+
67+
::selection {
68+
background-color: $color-purple-extra-dark;
69+
}
6370
}

themes/trafiklab-2024/assets/sass/shortcodes/_tabs.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
.nav-tabs {
1616
position: unset;
1717
width: unset;
18-
color: #0f0f0f;
1918
background: $color-black;
2019
list-style-type: none;
2120
margin: 0;
@@ -32,13 +31,14 @@
3231
color: #717171 !important;
3332
font-weight: bold;
3433
display: block;
35-
padding: 1rem;
34+
padding: 12px 16px;
3635
text-decoration: none;
3736
border-bottom: none !important;
3837

3938
&:hover {
4039
--show-active-line: 1;
4140
color: $color-white !important;
41+
box-shadow: none !important;
4242

4343
&::after {
4444
width: 100%;
@@ -71,5 +71,4 @@
7171
.code-tabs {
7272
margin: 1rem 0;
7373
}
74-
7574
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{{ $opts := merge .Options (dict "linenos" true "lineNumbersInTable" false) }}
1+
{{ $opts := merge .Options (dict "linenos" "inline") }}
22
{{ $result := transform.HighlightCodeBlock . $opts }}
33
{{ $result.Wrapped }}

themes/trafiklab-2024/layouts/partials/js/code-blocks.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
}
3535

3636
async function copyCodeToClipboard(button, highlightDiv) {
37-
const codeToCopy = highlightDiv.querySelector(":last-child > pre > code").innerText;
37+
let codeToCopy = ""
38+
// Copy multiple lines without line numbers by explicitly selecting the code from each line
39+
highlightDiv
40+
.querySelectorAll(":last-child > pre > code > span > span:last-child")
41+
.forEach((row) => {codeToCopy += row.innerText;});
3842
try {
3943
result = await navigator.permissions.query({ name: "clipboard-write" });
4044
if (result.state == "granted" || result.state == "prompt") {

0 commit comments

Comments
 (0)