Add oneClickSelect
Add oneClickSelect
This commit is contained in:
parent
bdca8b7c3b
commit
fe985ec2f6
2
public/assets/scaffolding-min.js
vendored
2
public/assets/scaffolding-min.js
vendored
File diff suppressed because one or more lines are too long
@ -893,6 +893,10 @@ body .container main article tabset [role=tabpanel] pre, body .container main ar
|
||||
background-color: var(--colour-black-5);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
body .container main article tabset [role=tabpanel] pre code:not(.inline), body .container main article .tab-group [role=tabpanel] pre code:not(.inline) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
body .container main article p.switch {
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user