Skip to content

Commit

Permalink
Update code-copy.js Track3/hermit#137
Browse files Browse the repository at this point in the history
  • Loading branch information
1bl4z3r committed Oct 21, 2023
1 parent 6d37941 commit f71ae18
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/js/code-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
var codeEl = containerEl.firstElementChild;
copyBtn.addEventListener('click', function() {
try {
var selection = selectText(codeEl);
if(codeEl.firstElementChild instanceof HTMLTableElement) {
var selection = selectText(codeEl.firstElementChild.firstElementChild.firstElementChild.lastElementChild);
} else {
var selection = selectText(codeEl);
}
document.execCommand('copy');
selection.removeAllRanges();

Expand Down

0 comments on commit f71ae18

Please sign in to comment.