You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-06 23:56:13 +02:00
25 lines
635 B
TypeScript
25 lines
635 B
TypeScript
![]() |
import CommandService from '@joplin/lib/services/CommandService';
|
||
|
import { useEffect } from 'react';
|
||
|
|
||
|
import commands from '../commands';
|
||
|
import { SidebarCommandRuntimeProps } from '../types';
|
||
|
|
||
|
interface Props {
|
||
|
focusSidebar: ()=> void;
|
||
|
}
|
||
|
const useSidebarCommandHandler = ({ focusSidebar }: Props) => {
|
||
|
useEffect(() => {
|
||
|
const runtimeProps: SidebarCommandRuntimeProps = {
|
||
|
focusSidebar,
|
||
|
};
|
||
|
|
||
|
CommandService.instance().componentRegisterCommands(runtimeProps, commands);
|
||
|
|
||
|
return () => {
|
||
|
CommandService.instance().componentUnregisterCommands(commands);
|
||
|
};
|
||
|
}, [focusSidebar]);
|
||
|
};
|
||
|
|
||
|
export default useSidebarCommandHandler;
|