Skip to content

Commit 7f47edd

Browse files
committed
backport changes to copy to clipboard from upstream
1 parent f04a30f commit 7f47edd

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/css/doc.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@
787787
max-width: 375px;
788788
}
789789

790-
.doc pre.highlight {
790+
.doc .listingblock > .content {
791791
position: relative;
792792
}
793793

@@ -799,8 +799,9 @@
799799
right: 0.5rem;
800800
color: var(--pre-annotation-font-color);
801801
font-family: var(--body-font-family);
802-
font-size: calc(13.5 / var(--rem-base) * 1rem);
802+
font-size: calc(13 / var(--rem-base) * 1rem);
803803
line-height: 1;
804+
white-space: nowrap;
804805
}
805806

806807
.doc .listingblock:hover .source-toolbox {
@@ -810,8 +811,6 @@
810811
.doc .source-toolbox .source-lang {
811812
text-transform: uppercase;
812813
letter-spacing: 0.075em;
813-
font-size: 0.96em;
814-
line-height: 1.0425;
815814
}
816815

817816
.doc .source-toolbox > :not(:last-child)::after {
@@ -824,7 +823,7 @@
824823
display: flex;
825824
flex-direction: column;
826825
align-items: center;
827-
background: transparent;
826+
background: none;
828827
border: none;
829828
color: inherit;
830829
outline: none;
@@ -861,7 +860,7 @@
861860
color: var(--color-white);
862861
cursor: auto;
863862
opacity: 0;
864-
transition: opacity 0.5s ease 0.75s;
863+
transition: opacity 0.5s ease 0.5s;
865864
}
866865

867866
.doc .source-toolbox .copy-toast::after {

src/js/06-copy-to-clipboard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
var TRAILING_SPACE_RX = / +$/gm
77

88
var config = (document.getElementById('site-script') || { dataset: {} }).dataset
9-
var uiRootPath = config.uiRootPath
9+
var uiRootPath = config.uiRootPath == null ? '.' : config.uiRootPath
1010
var svgAs = config.svgAs
11-
var supportsCopy = window.navigator.clipboard && uiRootPath != null
11+
var supportsCopy = window.navigator.clipboard
1212

1313
;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) {
1414
var code, language, lang, copy, toast, toolbox
@@ -54,7 +54,7 @@
5454
copy.appendChild(toast)
5555
toolbox.appendChild(copy)
5656
}
57-
pre.appendChild(toolbox)
57+
pre.parentNode.appendChild(toolbox)
5858
if (copy) copy.addEventListener('click', writeToClipboard.bind(copy, code))
5959
})
6060

0 commit comments

Comments
 (0)