]> git.ardis.lu - function-extractor/commitdiff
Fix triple click over-selecting trailing node
authorArdis Lu <ardisglu@gmail.com>
Sat, 3 Aug 2024 06:31:03 +0000 (23:31 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 3 Aug 2024 06:31:03 +0000 (23:31 -0700)
Otherwise, triple clicking on a table row will copy a trailing newline or tab.

index.html

index a9c2e381d12aa3ea284cf2937311ca883e6fac1f..59e273050d13f560a22785b454128e5f1dde501b 100644 (file)
       }
     });
 
+    // Fix selecting trailing element on triple (or quad) click, resulting in a trailing tab or newline
+    // when copying text from the table.
+    addEventListener('click', e => {
+      if (e.detail >= 3 && tableBody.contains(e.target)) {
+        const selection = getSelection();
+        const range = selection.getRangeAt(0);
+        const textNode = e.target.firstChild;
+        range.setStart(textNode, 0);
+        range.setEnd(textNode, textNode.length);
+      };
+    });
+
     // Set initial bytecode from prepopulated contract
     contractInput.dispatchEvent(new Event('input'));
   </script>
This page took 0.033773 seconds and 4 git commands to generate.