You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-12 22:57:38 +02:00
Desktop: Fixes #1443: Allow opening external editor on new notes
This commit is contained in:
@ -19,7 +19,11 @@ shared.noteExists = async function(noteId) {
|
||||
return !!existingNote;
|
||||
}
|
||||
|
||||
shared.saveNoteButton_press = async function(comp, folderId = null) {
|
||||
shared.saveNoteButton_press = async function(comp, folderId = null, options = null) {
|
||||
options = Object.assign({}, {
|
||||
autoTitle: true,
|
||||
}, options);
|
||||
|
||||
const releaseMutex = await saveNoteMutex_.acquire();
|
||||
|
||||
let note = Object.assign({}, comp.state.note);
|
||||
@ -40,18 +44,18 @@ shared.saveNoteButton_press = async function(comp, folderId = null) {
|
||||
|
||||
let isNew = !note.id;
|
||||
|
||||
let options = { userSideValidation: true };
|
||||
let saveOptions = { userSideValidation: true };
|
||||
if (!isNew) {
|
||||
options.fields = BaseModel.diffObjectsFields(comp.state.lastSavedNote, note);
|
||||
saveOptions.fields = BaseModel.diffObjectsFields(comp.state.lastSavedNote, note);
|
||||
}
|
||||
|
||||
const hasAutoTitle = comp.state.newAndNoTitleChangeNoteId || (isNew && !note.title);
|
||||
if (hasAutoTitle) {
|
||||
if (hasAutoTitle && options.autoTitle) {
|
||||
note.title = Note.defaultTitle(note);
|
||||
if (options.fields && options.fields.indexOf('title') < 0) options.fields.push('title');
|
||||
if (saveOptions.fields && saveOptions.fields.indexOf('title') < 0) saveOptions.fields.push('title');
|
||||
}
|
||||
|
||||
const savedNote = ('fields' in options) && !options.fields.length ? Object.assign({}, note) : await Note.save(note, options);
|
||||
const savedNote = ('fields' in saveOptions) && !saveOptions.fields.length ? Object.assign({}, note) : await Note.save(note, saveOptions);
|
||||
|
||||
const stateNote = comp.state.note;
|
||||
|
||||
@ -80,6 +84,8 @@ shared.saveNoteButton_press = async function(comp, folderId = null) {
|
||||
|
||||
if (isNew && hasAutoTitle) newState.newAndNoTitleChangeNoteId = note.id;
|
||||
|
||||
if (!options.autoTitle) newState.newAndNoTitleChangeNoteId = null;
|
||||
|
||||
comp.setState(newState);
|
||||
|
||||
// await shared.refreshAttachedResources(comp, newState.note.body);
|
||||
|
Reference in New Issue
Block a user