1
0
mirror of https://github.com/laurent22/joplin.git synced 2026-06-06 17:09:30 +02:00
Files
2026-05-25 22:03:21 +01:00

32 lines
806 B
TypeScript

import BaseCommand from './base-command';
import app from './app';
import { _ } from '@joplin/lib/locale';
import Note from '@joplin/lib/models/Note';
import { NoteEntity } from '@joplin/lib/services/database/types';
class Command extends BaseCommand {
public override usage() {
return 'mknote <new-note>';
}
public override description() {
return _('Creates a new note.');
}
public override async action(args: { 'new-note': string }) {
if (!app().currentFolder()) throw new Error(_('Notes can only be created within a notebook.'));
let note: NoteEntity = {
title: args['new-note'],
parent_id: app().currentFolder().id,
};
note = await Note.save(note);
void Note.updateGeolocation(note.id);
app().switchCurrentFolder(app().currentFolder());
}
}
module.exports = Command;