Allow copying sidenote text when explicitly selected

If the selection is entirely within a sidenote or marginnote,
allow normal copy behavior. Only strip sidenotes from copied
text when selecting verse content that includes sidenotes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-02 20:17:02 -05:00
parent 6d7f2b5fdb
commit 74e2ef2870
+11 -9
View File
@@ -47,14 +47,6 @@
cursor: pointer;
transition: all 0.3s ease;
position: relative;
user-select: none;
}
.sidenote::selection,
.marginnote::selection,
.sidenote *::selection,
.marginnote *::selection {
background: transparent;
}
label.sidenote-number {
@@ -741,12 +733,22 @@ document.addEventListener('DOMContentLoaded', function() {
});
// Clean copied text to exclude sidenotes, verse numbers, and margin elements
// But allow copying if selection is entirely within a sidenote
document.addEventListener('copy', function(e) {
const selection = window.getSelection();
if (!selection.rangeCount) return;
// Create a document fragment from the selection
const range = selection.getRangeAt(0);
// Check if selection is entirely within a sidenote or marginnote
const container = range.commonAncestorContainer;
const parentEl = container.nodeType === Node.TEXT_NODE ? container.parentElement : container;
if (parentEl && parentEl.closest('.sidenote, .marginnote')) {
// Allow normal copy behavior for sidenote content
return;
}
// Create a document fragment from the selection
const fragment = range.cloneContents();
// Create a temporary container