1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ElectronClient/gui/NoteList/commands/focusElementNoteList.ts

28 lines
675 B
TypeScript
Raw Normal View History

import { CommandRuntime, CommandDeclaration } from 'lib/services/CommandService';
import { _ } from 'lib/locale';
export const declaration:CommandDeclaration = {
name: 'focusElementNoteList',
label: () => _('Note list'),
parentLabel: () => _('Focus'),
};
export const runtime = (comp:any):CommandRuntime => {
return {
execute: async ({ noteId }:any) => {
if (noteId) {
const ref = comp.itemAnchorRef(noteId);
if (ref) ref.focus();
}
},
isEnabled: (props:any):boolean => {
return !!props.noteId;
},
mapStateToProps: (state:any):any => {
return {
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
};
},
};
};