1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/ElectronClient/commands/stopExternalEditing.ts

29 lines
822 B
TypeScript
Raw Normal View History

import { CommandRuntime, CommandDeclaration } from '../lib/services/CommandService';
const { _ } = require('lib/locale');
const ExternalEditWatcher = require('lib/services/ExternalEditWatcher');
interface Props {
noteId: string
}
export const declaration:CommandDeclaration = {
name: 'stopExternalEditing',
label: () => _('Stop external editing'),
iconName: 'fa-stop',
};
export const runtime = ():CommandRuntime => {
return {
execute: async (props:Props) => {
ExternalEditWatcher.instance().stopWatching(props.noteId);
},
isEnabled: (props:any) => {
if (props.routeName !== 'Main') return false;
return !!props.noteId;
},
mapStateToProps: (state:any) => {
return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, routeName: state.route.routeName };
},
};
};