-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
::deep th { | ||
padding: 0 5px 0 5px; | ||
border-width: 1px; | ||
} | ||
|
||
::deep td { | ||
padding: 0 5px 0 5px; | ||
border-width: 1px; | ||
} | ||
|
||
::deep .snippet { | ||
margin-bottom: 0.5rem; | ||
border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-rest); | ||
border-radius: calc(var(--control-corner-radius) * 1px); | ||
overflow-y: auto; | ||
} | ||
|
||
::deep .hljs { | ||
background-color: var(--neutral-layer-2); | ||
tab-size: 2em; | ||
} | ||
|
||
::deep .hljs-copy-button { | ||
border-color: var(--neutral-fill-strong-rest); | ||
color: var(--accent-fill-rest); | ||
top: 0.4rem; | ||
/*background-color: var(--neutral-layer-2) !important;*/ | ||
/*background-image: url('data:image/svg+xml;utf-8,<svg style="fill: none; width: 16px; height: 16px;" width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 5C5.73478 5 5.48043 5.10536 5.29289 5.29289C5.10536 5.48043 5 5.73478 5 6V20C5 20.2652 5.10536 20.5196 5.29289 20.7071C5.48043 20.8946 5.73478 21 6 21H18C18.2652 21 18.5196 20.8946 18.7071 20.7071C18.8946 20.5196 19 20.2652 19 20V6C19 5.73478 18.8946 5.48043 18.7071 5.29289C18.5196 5.10536 18.2652 5 18 5H16C15.4477 5 15 4.55228 15 4C15 3.44772 15.4477 3 16 3H18C18.7956 3 19.5587 3.31607 20.1213 3.87868C20.6839 4.44129 21 5.20435 21 6V20C21 20.7957 20.6839 21.5587 20.1213 22.1213C19.5587 22.6839 18.7957 23 18 23H6C5.20435 23 4.44129 22.6839 3.87868 22.1213C3.31607 21.5587 3 20.7957 3 20V6C3 5.20435 3.31607 4.44129 3.87868 3.87868C4.44129 3.31607 5.20435 3 6 3H8C8.55228 3 9 3.44772 9 4C9 4.55228 8.55228 5 8 5H6Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3C7 1.89543 7.89543 1 9 1H15C16.1046 1 17 1.89543 17 3V5C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5V3ZM15 3H9V5H15V3Z" fill="black" /></svg>');*/ | ||
} | ||
|
||
::deep .hljs-copy-button:hover { | ||
border-color: var(--neutral-fill-strong-hover); | ||
} | ||
|
||
::deep .hljs-copy-button:active { | ||
border-color: var(--neutral-fill-strong-active); | ||
} | ||
|
||
::deep .hljs-copy { | ||
cursor: pointer; | ||
border-color: var(--neutral-stroke-rest); | ||
border-radius: calc(var(--control-corner-radius) * 1px); | ||
color: var(--accent-fill-rest); | ||
background-color: var(--neutral-layer-2); | ||
top: 0.4rem; | ||
} | ||
|
||
::deep .hljs-copy { | ||
position: absolute; | ||
transform: translateX(calc(100% + 1.125em)); | ||
right: 1em; | ||
transition: background-color 200ms ease, transform 200ms ease-out; | ||
} | ||
|
||
::deep .hljs-copy-wrapper { | ||
position: relative; | ||
overflow: hidden | ||
} | ||
|
||
::deep .hljs-copy-wrapper:hover .hljs-copy, .hljs-copy:focus { | ||
transform: translateX(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export function highlight() { | ||
var preTagList = document.getElementsByTagName('pre'); | ||
var numberOfPreTags = preTagList.length; | ||
for (var i = 0; i < numberOfPreTags; i++) { | ||
var codeTag = preTagList[i].getElementsByTagName('code'); | ||
hljs.highlightElement(codeTag[0]); | ||
} | ||
} | ||
|
||
export function addCopyButton() { | ||
var snippets = document.querySelectorAll('.snippet'); | ||
var numberOfSnippets = snippets.length; | ||
for (var i = 0; i < numberOfSnippets; i++) { | ||
let copyButton = snippets[i].getElementsByClassName("hljs-copy") | ||
if (copyButton.length === 0) { | ||
let code = snippets[i].getElementsByTagName('code')[0].innerText; | ||
snippets[i].innerHTML = snippets[i].innerHTML + '<button class="hljs-copy">Copy</button>'; // append copy button | ||
|
||
copyButton[0].addEventListener("click", function () { | ||
navigator.clipboard.writeText(code); | ||
|
||
this.innerText = 'Copied!'; | ||
let button = this; | ||
setTimeout(function () { | ||
button.innerText = 'Copy'; | ||
}, 1000) | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters