mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-28 09:43:42 +03:00
feat: shortcut for expand/collapse of sidebar (#1797)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
parent
b1618e9ce1
commit
cd089ed64a
@ -86,6 +86,18 @@ export const WorkSpaceSliderBar: React.FC<WorkSpaceSliderBarProps> = ({
|
||||
useEffect(() => {
|
||||
window.apis?.onSidebarVisibilityChange(sidebarOpen);
|
||||
}, [sidebarOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
const keydown = (e: KeyboardEvent) => {
|
||||
if ((e.key === '/' && e.metaKey) || (e.key === '/' && e.ctrlKey)) {
|
||||
setSidebarOpen(!sidebarOpen);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', keydown, { capture: true });
|
||||
return () =>
|
||||
document.removeEventListener('keydown', keydown, { capture: true });
|
||||
}, [sidebarOpen, setSidebarOpen]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledSliderBarWrapper
|
||||
|
Loading…
Reference in New Issue
Block a user