mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
feat(ui): add R/F/D action shortcuts and unify keycap hint style
- Bind R=refresh, F=fetch metadata, D=download in PageControls via eventManager (plain letters only, skipped while typing or when a modal is open); triggers reuse the buttons' existing click handlers - Show key-hint chips on the refresh/fetch/download/bulk toolbar buttons; convert the bulk chip to a semantic <kbd> - Redesign shortcut hints as a neutral theme-adaptive keycap: --shortcut-* variables in base.css now derive from --text-muted with a bottom-edge shadow, shared by the toolbar chips, the header search cue, the help-modal cheat sheet, and onboarding key hints - Add shared isTypingContext() helper to uiHelpers - Add an Actions group (R/F/D) to the Shortcuts cheat-sheet tab Verified with vitest (926 passing, incl. 6 new shortcut cases) and a sandboxed E2E run in real Chrome (light/dark rendering, hover state, '?' opening the Shortcuts tab, clean console)
This commit is contained in:
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "Keyboard & Mouse Shortcuts",
|
"title": "Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "General",
|
"general": "General",
|
||||||
|
"actions": "Actions",
|
||||||
"selection": "Selection & Bulk Mode",
|
"selection": "Selection & Bulk Mode",
|
||||||
"navigation": "Navigation",
|
"navigation": "Navigation",
|
||||||
"modelModal": "Model / Recipe Modal",
|
"modelModal": "Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "Focus search",
|
"focusSearch": "Focus search",
|
||||||
"closeModal": "Close modal / panel",
|
"closeModal": "Close modal / panel",
|
||||||
"openShortcuts": "Open this shortcuts panel",
|
"openShortcuts": "Open this shortcuts panel",
|
||||||
|
"refresh": "Refresh model list",
|
||||||
|
"fetchMetadata": "Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "Download a model (model pages only)",
|
||||||
"toggleBulkMode": "Toggle bulk mode",
|
"toggleBulkMode": "Toggle bulk mode",
|
||||||
"selectAll": "Select all visible models",
|
"selectAll": "Select all visible models",
|
||||||
"rangeSelect": "Range select",
|
"rangeSelect": "Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
@@ -1977,6 +1977,7 @@
|
|||||||
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
"title": "[TODO: Translate] Keyboard & Mouse Shortcuts",
|
||||||
"groups": {
|
"groups": {
|
||||||
"general": "[TODO: Translate] General",
|
"general": "[TODO: Translate] General",
|
||||||
|
"actions": "[TODO: Translate] Actions",
|
||||||
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
"selection": "[TODO: Translate] Selection & Bulk Mode",
|
||||||
"navigation": "[TODO: Translate] Navigation",
|
"navigation": "[TODO: Translate] Navigation",
|
||||||
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
"modelModal": "[TODO: Translate] Model / Recipe Modal",
|
||||||
@@ -1993,6 +1994,9 @@
|
|||||||
"focusSearch": "[TODO: Translate] Focus search",
|
"focusSearch": "[TODO: Translate] Focus search",
|
||||||
"closeModal": "[TODO: Translate] Close modal / panel",
|
"closeModal": "[TODO: Translate] Close modal / panel",
|
||||||
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
"openShortcuts": "[TODO: Translate] Open this shortcuts panel",
|
||||||
|
"refresh": "[TODO: Translate] Refresh model list",
|
||||||
|
"fetchMetadata": "[TODO: Translate] Fetch metadata from CivitAI (model pages only)",
|
||||||
|
"downloadModel": "[TODO: Translate] Download a model (model pages only)",
|
||||||
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
"toggleBulkMode": "[TODO: Translate] Toggle bulk mode",
|
||||||
"selectAll": "[TODO: Translate] Select all visible models",
|
"selectAll": "[TODO: Translate] Select all visible models",
|
||||||
"rangeSelect": "[TODO: Translate] Range select",
|
"rangeSelect": "[TODO: Translate] Range select",
|
||||||
|
|||||||
+8
-3
@@ -31,9 +31,14 @@ body {
|
|||||||
--header-height: 48px;
|
--header-height: 48px;
|
||||||
--scrollbar-width: 8px;
|
--scrollbar-width: 8px;
|
||||||
|
|
||||||
--shortcut-bg: var(--color-accent-subtle);
|
/* Neutral "keycap" style for keyboard shortcut hints (GitHub/Linear-like).
|
||||||
--shortcut-border: var(--color-accent-border);
|
Derived from --text-muted so it adapts to every theme/preset. */
|
||||||
--shortcut-text: var(--text-primary);
|
--shortcut-bg: color-mix(in oklch, var(--text-muted) 10%, transparent);
|
||||||
|
--shortcut-bg-hover: color-mix(in oklch, var(--text-muted) 16%, transparent);
|
||||||
|
--shortcut-border: color-mix(in oklch, var(--text-muted) 30%, transparent);
|
||||||
|
--shortcut-border-hover: color-mix(in oklch, var(--text-muted) 45%, transparent);
|
||||||
|
--shortcut-text: var(--text-muted);
|
||||||
|
--shortcut-shadow: 0 1.5px 0 color-mix(in oklch, var(--text-muted) 30%, transparent);
|
||||||
|
|
||||||
--lora-accent-transparent: var(--color-accent-transparent);
|
--lora-accent-transparent: var(--color-accent-transparent);
|
||||||
|
|
||||||
|
|||||||
@@ -249,10 +249,10 @@
|
|||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--text-muted);
|
color: var(--shortcut-text);
|
||||||
/* Subtle tint derived from text color so it adapts to both light & dark themes */
|
background: var(--shortcut-bg);
|
||||||
background: color-mix(in oklch, var(--text-muted) 12%, transparent);
|
border: 1px solid var(--shortcut-border);
|
||||||
border: 1px solid color-mix(in oklch, var(--text-muted) 25%, transparent);
|
box-shadow: var(--shortcut-shadow);
|
||||||
border-radius: var(--border-radius-xs, 3px);
|
border-radius: var(--border-radius-xs, 3px);
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,10 +376,10 @@
|
|||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--text-muted);
|
color: var(--shortcut-text);
|
||||||
/* Subtle tint derived from text color so it adapts to both light & dark themes */
|
background: var(--shortcut-bg);
|
||||||
background: color-mix(in oklch, var(--text-muted) 12%, transparent);
|
border: 1px solid var(--shortcut-border);
|
||||||
border: 1px solid color-mix(in oklch, var(--text-muted) 25%, transparent);
|
box-shadow: var(--shortcut-shadow);
|
||||||
border-radius: var(--border-radius-xs, 3px);
|
border-radius: var(--border-radius-xs, 3px);
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,15 +202,17 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
min-width: 16px;
|
min-width: 18px;
|
||||||
height: 16px;
|
height: 18px;
|
||||||
padding: 0 3px;
|
padding: 0 5px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
text-transform: uppercase;
|
||||||
border-radius: var(--border-radius-xs);
|
border-radius: var(--border-radius-xs);
|
||||||
background-color: var(--shortcut-bg);
|
background-color: var(--shortcut-bg);
|
||||||
border: 1px solid var(--shortcut-border);
|
border: 1px solid var(--shortcut-border);
|
||||||
|
box-shadow: var(--shortcut-shadow);
|
||||||
color: var(--shortcut-text);
|
color: var(--shortcut-text);
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
@@ -219,12 +221,8 @@
|
|||||||
|
|
||||||
.control-group button:hover .shortcut-key {
|
.control-group button:hover .shortcut-key {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
background-color: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.2);
|
background-color: var(--shortcut-bg-hover);
|
||||||
}
|
border-color: var(--shortcut-border-hover);
|
||||||
|
|
||||||
[data-theme="dark"] .shortcut-key {
|
|
||||||
--shortcut-bg: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.15);
|
|
||||||
--shortcut-border: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure correct vertical alignment for text+shortcut */
|
/* Ensure correct vertical alignment for text+shortcut */
|
||||||
|
|||||||
@@ -205,6 +205,7 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
background: var(--shortcut-bg);
|
background: var(--shortcut-bg);
|
||||||
border: 1px solid var(--shortcut-border);
|
border: 1px solid var(--shortcut-border);
|
||||||
|
box-shadow: var(--shortcut-shadow);
|
||||||
border-radius: var(--border-radius-xs);
|
border-radius: var(--border-radius-xs);
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// PageControls.js - Manages controls for both LoRAs and Checkpoints pages
|
// PageControls.js - Manages controls for both LoRAs and Checkpoints pages
|
||||||
import { state, getCurrentPageState, setCurrentPageType } from '../../state/index.js';
|
import { state, getCurrentPageState, setCurrentPageType } from '../../state/index.js';
|
||||||
import { getStorageItem, setStorageItem, removeStorageItem, getSessionItem, setSessionItem, removeSessionItem } from '../../utils/storageHelpers.js';
|
import { getStorageItem, setStorageItem, removeStorageItem, getSessionItem, setSessionItem, removeSessionItem } from '../../utils/storageHelpers.js';
|
||||||
import { showToast, openCivitaiByMetadata } from '../../utils/uiHelpers.js';
|
import { showToast, openCivitaiByMetadata, isTypingContext } from '../../utils/uiHelpers.js';
|
||||||
|
import { eventManager } from '../../utils/EventManager.js';
|
||||||
import { performModelUpdateCheck } from '../../utils/updateCheckHelpers.js';
|
import { performModelUpdateCheck } from '../../utils/updateCheckHelpers.js';
|
||||||
import { sidebarManager } from '../SidebarManager.js';
|
import { sidebarManager } from '../SidebarManager.js';
|
||||||
import { initSortDropdown, applySortToSelect, randomizeSortValue } from './SortDropdown.js';
|
import { initSortDropdown, applySortToSelect, randomizeSortValue } from './SortDropdown.js';
|
||||||
@@ -146,6 +147,62 @@ export class PageControls {
|
|||||||
|
|
||||||
// Page-specific event listeners
|
// Page-specific event listeners
|
||||||
this.initPageSpecificListeners();
|
this.initPageSpecificListeners();
|
||||||
|
|
||||||
|
// Keyboard shortcuts for the actions toolbar (R / F / D)
|
||||||
|
this.registerKeyboardShortcuts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register keyboard shortcuts for the actions toolbar buttons
|
||||||
|
* (R = refresh, F = fetch metadata, D = download)
|
||||||
|
*/
|
||||||
|
registerKeyboardShortcuts() {
|
||||||
|
eventManager.addHandler('keydown', 'pageControls-actions', (e) => {
|
||||||
|
return this.handleActionShortcut(e);
|
||||||
|
}, {
|
||||||
|
priority: 90,
|
||||||
|
skipWhenModalOpen: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a keydown event for the actions toolbar shortcuts
|
||||||
|
* @param {KeyboardEvent} e
|
||||||
|
* @returns {boolean} True when the event was handled and propagation should stop
|
||||||
|
*/
|
||||||
|
handleActionShortcut(e) {
|
||||||
|
// Plain letters only — leave modified combos (Ctrl/Cmd/Alt) alone
|
||||||
|
if (e.ctrlKey || e.metaKey || e.altKey) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't hijack keys while typing in a text entry context
|
||||||
|
if (isTypingContext(e.target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionByKey = {
|
||||||
|
r: 'refresh',
|
||||||
|
f: 'fetch',
|
||||||
|
d: 'download'
|
||||||
|
};
|
||||||
|
const action = actionByKey[e.key.toLowerCase()];
|
||||||
|
if (!action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The button may not exist on this page (e.g. recipes has no
|
||||||
|
// fetch/download) — let other handlers run in that case
|
||||||
|
const button = document.querySelector(`[data-action="${action}"]`);
|
||||||
|
if (!button) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
// Native disabled buttons ignore .click(), so an in-progress
|
||||||
|
// refresh is safe
|
||||||
|
button.click();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
initExcludedViewControls() {
|
initExcludedViewControls() {
|
||||||
|
|||||||
@@ -311,6 +311,20 @@ export function showActionToast(key, params = {}, type = 'info', options = {}) {
|
|||||||
toast.append(closeBtn);
|
toast.append(closeBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the event target is a text-entry context (input, textarea,
|
||||||
|
* select, or contenteditable) where single-letter shortcuts should be treated
|
||||||
|
* as literal input.
|
||||||
|
* @param {EventTarget|null} target - The DOM event target
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function isTypingContext(target) {
|
||||||
|
if (!(target instanceof Element)) return false;
|
||||||
|
|
||||||
|
const tagName = target.tagName?.toLowerCase();
|
||||||
|
return target.isContentEditable || tagName === 'input' || tagName === 'textarea' || tagName === 'select';
|
||||||
|
}
|
||||||
|
|
||||||
export function restoreFolderFilter() {
|
export function restoreFolderFilter() {
|
||||||
const activeFolder = getStorageItem('activeFolder');
|
const activeFolder = getStorageItem('activeFolder');
|
||||||
const folderTag = activeFolder && document.querySelector(`.tag[data-folder="${activeFolder}"]`);
|
const folderTag = activeFolder && document.querySelector(`.tag[data-folder="${activeFolder}"]`);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div title="{% if page_id == 'recipes' %}{{ t('recipes.controls.refresh.title') }}{% else %}{{ t('loras.controls.refresh.title') }}{% endif %}" class="control-group dropdown-group">
|
<div title="{% if page_id == 'recipes' %}{{ t('recipes.controls.refresh.title') }}{% else %}{{ t('loras.controls.refresh.title') }}{% endif %}" class="control-group dropdown-group">
|
||||||
<button data-action="refresh" class="dropdown-main"><i class="fas fa-sync"></i> <span>{{ t('common.actions.refresh') }}</span></button>
|
<button data-action="refresh" class="dropdown-main"><i class="fas fa-sync"></i> <span><span>{{ t('common.actions.refresh') }}</span> <kbd class="shortcut-key">R</kbd></span></button>
|
||||||
<button class="dropdown-toggle" aria-label="Show refresh options">
|
<button class="dropdown-toggle" aria-label="Show refresh options">
|
||||||
<i class="fas fa-caret-down"></i>
|
<i class="fas fa-caret-down"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -78,11 +78,11 @@
|
|||||||
|
|
||||||
{% if page_id != 'recipes' %}
|
{% if page_id != 'recipes' %}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<button data-action="fetch" title="{{ t('loras.controls.fetch.title') }}"><i class="fas fa-download"></i> <span>{{ t('loras.controls.fetch.action') }}</span></button>
|
<button data-action="fetch" title="{{ t('loras.controls.fetch.title') }}"><i class="fas fa-download"></i> <span><span>{{ t('loras.controls.fetch.action') }}</span> <kbd class="shortcut-key">F</kbd></span></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<button data-action="download" title="{{ t('loras.controls.download.title') }}">
|
<button data-action="download" title="{{ t('loras.controls.download.title') }}">
|
||||||
<i class="fas fa-cloud-download-alt"></i> <span>{{ t('loras.controls.download.action') }}</span>
|
<i class="fas fa-cloud-download-alt"></i> <span><span>{{ t('loras.controls.download.action') }}</span> <kbd class="shortcut-key">D</kbd></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<button id="bulkOperationsBtn" data-action="bulk" title="{{ t('loras.controls.bulk.title') }}">
|
<button id="bulkOperationsBtn" data-action="bulk" title="{{ t('loras.controls.bulk.title') }}">
|
||||||
<i class="fas fa-th-large"></i> <span><span>{{ t('loras.controls.bulk.action') }}</span> <div class="shortcut-key">B</div></span>
|
<i class="fas fa-th-large"></i> <span><span>{{ t('loras.controls.bulk.action') }}</span> <kbd class="shortcut-key">B</kbd></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|||||||
@@ -165,6 +165,24 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="shortcuts-section">
|
||||||
|
<h4><i class="fas fa-bolt"></i> {{ t('help.shortcuts.groups.actions') }}</h4>
|
||||||
|
<ul class="shortcuts-list">
|
||||||
|
<li>
|
||||||
|
<span class="shortcut-keys"><kbd>R</kbd></span>
|
||||||
|
<span class="shortcut-description">{{ t('help.shortcuts.entries.refresh') }}</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="shortcut-keys"><kbd>F</kbd></span>
|
||||||
|
<span class="shortcut-description">{{ t('help.shortcuts.entries.fetchMetadata') }}</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="shortcut-keys"><kbd>D</kbd></span>
|
||||||
|
<span class="shortcut-description">{{ t('help.shortcuts.entries.downloadModel') }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="shortcuts-section">
|
<div class="shortcuts-section">
|
||||||
<h4><i class="fas fa-object-group"></i> {{ t('help.shortcuts.groups.selection') }}</h4>
|
<h4><i class="fas fa-object-group"></i> {{ t('help.shortcuts.groups.selection') }}</h4>
|
||||||
<ul class="shortcuts-list">
|
<ul class="shortcuts-list">
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ vi.mock('../../../static/js/utils/uiHelpers.js', () => ({
|
|||||||
showToast: showToastMock,
|
showToast: showToastMock,
|
||||||
openCivitaiByMetadata: openCivitaiByMetadataMock,
|
openCivitaiByMetadata: openCivitaiByMetadataMock,
|
||||||
updatePanelPositions: updatePanelPositionsMock,
|
updatePanelPositions: updatePanelPositionsMock,
|
||||||
|
// Faithful stand-in for the real helper in uiHelpers.js
|
||||||
|
isTypingContext: (target) => {
|
||||||
|
if (!(target instanceof Element)) return false;
|
||||||
|
const tagName = target.tagName?.toLowerCase();
|
||||||
|
return target.isContentEditable || tagName === 'input' || tagName === 'textarea' || tagName === 'select';
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('../../../static/js/managers/DownloadManager.js', () => ({
|
vi.mock('../../../static/js/managers/DownloadManager.js', () => ({
|
||||||
@@ -1200,4 +1206,87 @@ describe('PageControls favorites, sorting, and duplicates scenarios', () => {
|
|||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PageControls action keyboard shortcuts', () => {
|
||||||
|
async function setupLorasControls() {
|
||||||
|
renderControlsDom('loras');
|
||||||
|
const stateModule = await import('../../../static/js/state/index.js');
|
||||||
|
stateModule.initPageState('loras');
|
||||||
|
const { LorasControls } = await import('../../../static/js/components/controls/LorasControls.js');
|
||||||
|
return new LorasControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
function keydownEvent(key, { target = document.body, ...init } = {}) {
|
||||||
|
const event = new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true, ...init });
|
||||||
|
Object.defineProperty(event, 'target', { value: target });
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
it('registers a pageControls-actions keydown handler with the event manager', async () => {
|
||||||
|
await setupLorasControls();
|
||||||
|
|
||||||
|
const { eventManager } = await import('../../../static/js/utils/EventManager.js');
|
||||||
|
const keydownHandlers = eventManager.handlers.get('keydown') || [];
|
||||||
|
expect(keydownHandlers.some((h) => h.source === 'pageControls-actions')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('triggers refresh, fetch, and download via the R / F / D keys', async () => {
|
||||||
|
const controls = await setupLorasControls();
|
||||||
|
|
||||||
|
expect(controls.handleActionShortcut(keydownEvent('r'))).toBe(true);
|
||||||
|
expect(refreshModelsMock).toHaveBeenCalledWith(false);
|
||||||
|
|
||||||
|
expect(controls.handleActionShortcut(keydownEvent('f'))).toBe(true);
|
||||||
|
expect(fetchCivitaiMetadataMock).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
expect(controls.handleActionShortcut(keydownEvent('d'))).toBe(true);
|
||||||
|
expect(downloadManagerMock.showDownloadModal).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles a real keydown dispatched on the document', async () => {
|
||||||
|
await setupLorasControls();
|
||||||
|
|
||||||
|
const event = new KeyboardEvent('keydown', { key: 'r', bubbles: true, cancelable: true });
|
||||||
|
document.dispatchEvent(event);
|
||||||
|
|
||||||
|
expect(event.defaultPrevented).toBe(true);
|
||||||
|
expect(refreshModelsMock).toHaveBeenCalledWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores R / F / D while typing in an input', async () => {
|
||||||
|
const controls = await setupLorasControls();
|
||||||
|
|
||||||
|
const input = document.getElementById('searchInput');
|
||||||
|
for (const key of ['r', 'f', 'd']) {
|
||||||
|
const event = keydownEvent(key, { target: input });
|
||||||
|
expect(controls.handleActionShortcut(event)).toBe(false);
|
||||||
|
expect(event.defaultPrevented).toBe(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(refreshModelsMock).not.toHaveBeenCalled();
|
||||||
|
expect(fetchCivitaiMetadataMock).not.toHaveBeenCalled();
|
||||||
|
expect(downloadManagerMock.showDownloadModal).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores R / F / D when combined with modifier keys', async () => {
|
||||||
|
const controls = await setupLorasControls();
|
||||||
|
|
||||||
|
const event = keydownEvent('r', { ctrlKey: true });
|
||||||
|
expect(controls.handleActionShortcut(event)).toBe(false);
|
||||||
|
expect(event.defaultPrevented).toBe(false);
|
||||||
|
expect(refreshModelsMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('passes the event through when the action button does not exist', async () => {
|
||||||
|
const controls = await setupLorasControls();
|
||||||
|
|
||||||
|
// Recipes page has no fetch/download buttons
|
||||||
|
document.querySelector('[data-action="fetch"]').closest('.control-group').remove();
|
||||||
|
|
||||||
|
const event = keydownEvent('f');
|
||||||
|
expect(controls.handleActionShortcut(event)).toBe(false);
|
||||||
|
expect(event.defaultPrevented).toBe(false);
|
||||||
|
expect(fetchCivitaiMetadataMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -13,6 +13,12 @@ vi.mock('../../../static/js/utils/uiHelpers.js', () => ({
|
|||||||
showToast: vi.fn(),
|
showToast: vi.fn(),
|
||||||
openCivitaiByMetadata: vi.fn(),
|
openCivitaiByMetadata: vi.fn(),
|
||||||
updatePanelPositions: vi.fn(),
|
updatePanelPositions: vi.fn(),
|
||||||
|
// Faithful stand-in for the real helper in uiHelpers.js
|
||||||
|
isTypingContext: (target) => {
|
||||||
|
if (!(target instanceof Element)) return false;
|
||||||
|
const tagName = target.tagName?.toLowerCase();
|
||||||
|
return target.isContentEditable || tagName === 'input' || tagName === 'textarea' || tagName === 'select';
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('../../../static/js/managers/DownloadManager.js', () => ({
|
vi.mock('../../../static/js/managers/DownloadManager.js', () => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user