feat(bulk): add shift+click range selection in bulk mode

This commit is contained in:
Will Miao
2026-08-26 10:09:35 +08:00
parent 0b08ad283a
commit 4ed9f775f6
4 changed files with 255 additions and 6 deletions
+5 -2
View File
@@ -240,9 +240,12 @@ class RecipeCard {
// Recipe card click event - only attach if not in duplicates mode
if (!isDuplicatesMode) {
card.addEventListener('click', () => {
card.addEventListener('click', (e) => {
if (state.bulkMode) {
bulkManager.toggleCardSelection(card);
if (e.shiftKey) {
e.preventDefault();
}
bulkManager.toggleCardSelection(card, e.shiftKey);
return;
}
this.clickHandler(this.recipe);
+6 -3
View File
@@ -108,7 +108,10 @@ function handleModelCardEvent_internal(event, modelType) {
}
// If no specific element was clicked, handle the card click (show modal or toggle selection)
handleCardClick(card, modelType);
if (state.bulkMode && event.shiftKey) {
event.preventDefault(); // keep shift+click from extending a text selection
}
handleCardClick(card, modelType, event.shiftKey);
return false; // Continue with other handlers (e.g., bulk selection)
}
@@ -288,12 +291,12 @@ function handleViewLocalVersionsFromCard(card, modelType) {
}
}
function handleCardClick(card, modelType) {
function handleCardClick(card, modelType, extendSelection = false) {
const pageState = getCurrentPageState();
if (state.bulkMode) {
// Toggle selection using the bulk manager
bulkManager.toggleCardSelection(card);
bulkManager.toggleCardSelection(card, extendSelection);
} else if (pageState && pageState.duplicatesMode) {
// In duplicates mode, don't open modal when clicking cards
return;