From: Ardis Lu Date: Thu, 10 Sep 2026 05:49:35 +0000 (-0700) Subject: Fix trailing newline when triple/quad clicking output X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=b0652e6eab4d905743686fdaa05a80a57619e40d;p=minimal-srihash Fix trailing newline when triple/quad clicking output --- diff --git a/index.html b/index.html index 175720b..b644368 100644 --- a/index.html +++ b/index.html @@ -277,6 +277,20 @@ // Update code output on option checkbox or hash selection change document.querySelectorAll('input[type="checkbox"],select').forEach(e => e.addEventListener('change', () => form.requestSubmit())); + + // Fix trailing newline on triple (or quad) click + const output = document.querySelector('output'); + addEventListener('click', e => { + if (e.detail >= 3 && output.contains(e.target)) { + const range = document.createRange(); + const textNode = output.firstChild.firstChild; // Assuming markup looks like TEXT_NODE + range.setStart(textNode, 0); + range.setEnd(textNode, textNode.length); + const selection = getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + }; + });