Add oneClickSelect
Add oneClickSelect
This commit is contained in:
@@ -59,7 +59,21 @@ const showMessage = (m, s) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const oneClickSelect = (e, t = e.currentTarget) => {
|
||||
// In here, "this" is the element
|
||||
var range, selection;
|
||||
if (window.getSelection) {
|
||||
selection = window.getSelection();
|
||||
range = document.createRange();
|
||||
range.selectNodeContents(t);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
} else if (document.body.createTextRange) {
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText(t);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
|
||||
const getURLVars = () => {
|
||||
var oResult = {};
|
||||
@@ -182,15 +196,21 @@ module.exports = {
|
||||
break;
|
||||
}
|
||||
a.querySelectorAll("code").forEach((c)=> {
|
||||
c.innerHTML = c.innerHTML.replace(/</g, "<");
|
||||
c.classList.add("line-numbers");
|
||||
c.innerHTML = c.innerHTML.replace(/</g, "<");
|
||||
c.classList.add("copy-to-clipboard-button");
|
||||
// add oneclickselect
|
||||
})
|
||||
if (typeof args.success == "function") args.success(a);
|
||||
|
||||
Prism.highlightAll();
|
||||
|
||||
a.querySelectorAll("code").forEach((c)=> {
|
||||
c.onclick = (e) => {
|
||||
oneClickSelect(e);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
module.exports.colour.positionTooltip();
|
||||
window.onresize = () => {
|
||||
module.exports.colour.positionTooltip();
|
||||
|
@@ -129,6 +129,10 @@ body {
|
||||
pre {
|
||||
background-color: var(--colour-black-5);
|
||||
font-size: .8rem;
|
||||
code:not(.inline) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
};
|
||||
p.switch {
|
||||
|
Reference in New Issue
Block a user