diff --git a/openspec/changes/sidepanel-ux-improvements/tasks.md b/openspec/changes/sidepanel-ux-improvements/tasks.md index f806011..8ef35d5 100644 --- a/openspec/changes/sidepanel-ux-improvements/tasks.md +++ b/openspec/changes/sidepanel-ux-improvements/tasks.md @@ -22,7 +22,7 @@ - [x] 4.1 Add `A-` and `A+` buttons to the header in `sidepanel/sidepanel.html` before the `☰` button; style them like `#open-list` in `sidepanel/sidepanel.css` - [x] 4.2 In `sidepanel/sidepanel.js`, implement font-size state: default 16px, range 10–24px, step 1px; apply via `editor.style.fontSize`; load from `localStorage` (`side-notes:fontSize`) at init and persist on every change - [x] 4.3 Wire the two buttons to decrease/increase with clamping -- [ ] 4.4 Add keyboard shortcuts in the existing keydown handler: `Ctrl/Cmd+=` (and `+` variant) increase, `Ctrl/Cmd+-` decrease, `Ctrl/Cmd+0` reset to 16px, all with `preventDefault()` +- [x] 4.4 Add keyboard shortcuts in the existing keydown handler: `Ctrl/Cmd+=` (and `+` variant) increase, `Ctrl/Cmd+-` decrease, `Ctrl/Cmd+0` reset to 16px, all with `preventDefault()` - [ ] 4.5 Verify the find match scrolling (`selectMatch`) still scrolls correctly at min and max font sizes ## 5. Validation diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js index 662633c..753f808 100644 --- a/sidepanel/sidepanel.js +++ b/sidepanel/sidepanel.js @@ -414,6 +414,19 @@ document.addEventListener('keydown', (e) => { e.stopPropagation(); openFind(); } + // Font size: Ctrl/Cmd+= (or +) increase, Ctrl/Cmd+- decrease, Ctrl/Cmd+0 reset + if ((e.ctrlKey || e.metaKey) && (e.key === '=' || e.key === '+')) { + e.preventDefault(); + fontSize = applyFontSize(fontSize + FONT_SIZE_STEP); + } + if ((e.ctrlKey || e.metaKey) && e.key === '-') { + e.preventDefault(); + fontSize = applyFontSize(fontSize - FONT_SIZE_STEP); + } + if ((e.ctrlKey || e.metaKey) && e.key === '0') { + e.preventDefault(); + fontSize = applyFontSize(FONT_SIZE_DEFAULT); + } // Escape → close find bar if (e.key === 'Escape' && !findBar.hidden) { e.preventDefault();