From b0652e6eab4d905743686fdaa05a80a57619e40d Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 9 Sep 2026 22:49:35 -0700 Subject: [PATCH] Fix trailing newline when triple/quad clicking output --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); + }; + }); -- 2.47.3