custom select all only for the code
This commit is contained in:
parent
3c4f5089ef
commit
4a2d3d4fb7
@ -30,5 +30,24 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script>hljs.highlightAll();</script>
|
<script>
|
||||||
|
// Highlight the code block
|
||||||
|
hljs.highlightAll();
|
||||||
|
|
||||||
|
// Custom select all behavior to select all the content inside the <pre> block
|
||||||
|
document.addEventListener('keydown', function(event) {
|
||||||
|
if (event.ctrlKey && event.key === 'a') {
|
||||||
|
event.preventDefault(); // Prevent the default select all behavior
|
||||||
|
|
||||||
|
// Select all the content inside the <pre> block
|
||||||
|
const preBlock = document.querySelector('pre');
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(preBlock);
|
||||||
|
|
||||||
|
const selection = window.getSelection();
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user