2021-06-09 13:25:28 +00:00
|
|
|
function usePreventSelect() {
|
2021-06-17 01:30:06 +00:00
|
|
|
function clearSelection() {
|
2021-07-16 06:58:14 +00:00
|
|
|
window?.getSelection()?.removeAllRanges();
|
|
|
|
// @ts-ignore
|
|
|
|
document?.selection?.empty();
|
2021-06-17 01:30:06 +00:00
|
|
|
}
|
2021-06-09 13:25:28 +00:00
|
|
|
function preventSelect() {
|
2021-06-17 01:30:06 +00:00
|
|
|
clearSelection();
|
2021-06-09 13:25:28 +00:00
|
|
|
document.body.classList.add("no-select");
|
|
|
|
}
|
|
|
|
|
|
|
|
function resumeSelect() {
|
|
|
|
document.body.classList.remove("no-select");
|
|
|
|
}
|
|
|
|
|
|
|
|
return [preventSelect, resumeSelect];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default usePreventSelect;
|