Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
megatops committed Jan 11, 2025
2 parents 1ddca5d + 1bf6723 commit d47283c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions PatchViewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,30 @@ <h2>Side-by-Side Patch Viewer v0.6.1</h2>
});
</script>

<script>
document.addEventListener("copy", (e) => {
const selection = window.getSelection();
if (!selection.rangeCount) return;

const range = selection.getRangeAt(0);
const selectableCells = Array.from(range.commonAncestorContainer.querySelectorAll("td.selectable, th.selectable"));
const selectedCells = selectableCells.filter(cell => range.intersectsNode(cell));

if (selectedCells.length > 0) {
const copiedText = selectedCells.map(
cell => {
const preElement = cell.querySelector("pre");
return preElement && preElement.textContent + "\n";
}
).join("");

// Override the clipboard content
e.clipboardData.setData("text/plain", copiedText);
e.preventDefault();
}
});
</script>

</body>

</html>

0 comments on commit d47283c

Please sign in to comment.