You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-06 17:09:30 +02:00
ef7acdd55e
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
32 lines
806 B
TypeScript
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;
|