2020-07-03 23:32:39 +02:00
|
|
|
import { CommandRuntime, CommandDeclaration } from '../../../lib/services/CommandService';
|
|
|
|
const { _ } = require('lib/locale');
|
|
|
|
|
|
|
|
export const declaration:CommandDeclaration = {
|
|
|
|
name: 'focusElementNoteList',
|
|
|
|
label: () => _('Note list'),
|
2020-09-13 18:21:11 +02:00
|
|
|
parentLabel: () => _('Focus'),
|
2020-07-03 23:32:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|