mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +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;
|