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

27 lines
678 B
TypeScript
Raw Normal View History

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