====== Double-click code block selection ====== Adding double-click code block selection((Double-click one of the code blocks below to see what this means!)) to DokuWiki requires some modification to the core engine. Because you're modifying core engine code, you need to **reinstate** this change any time you upgrade your install. -- Define a function that takes an element as an argument, then selects all of that element's text. You need to do this somewhere in a script file loaded by default (e.g. /lib/scripts/script.js): .. /** * Function to select code blocks on double-click */ function firefive_selectCode(codeBlock) { var range; if (document.body.createTextRange) { range = document.body.createTextRange(); range.moveToElementText(codeBlock); range.select(); } else if (window.getSelection) { range = document.createRange(); range.selectNodeContents(codeBlock); var selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); } } -- Call the function when a code block is double-clicked, by adding an ''ondblclick'' attribute to the ''
'' tag that opens a code block. These tags are prepared in the ''_highlight()'' function, found in [[https://xref.dokuwiki.org/reference/dokuwiki/inc/parser/xhtml.php.html|/inc/parser/xhtml.php]].
  .. Extend the start of the ''
===== Where to find it =====

The line of code appears in different places for different wiki versions:

^Version   ^File   ^Line number   ^
|Igor    |inc/parser/xhtml.php  | ~702   |
|Greebo  |inc/parser/xhtml.php  | 697, 702   |


{{tag> dokuwiki javascript}}