core: set default title if note has no title

This commit is contained in:
Abdullah Atta
2023-12-23 15:34:52 +05:00
parent 56d230191f
commit 0da883b40a

View File

@@ -102,8 +102,16 @@ export class Notes implements ICollection {
}
if (item.title) {
item.title = this.getNoteTitle(item.title, headline);
item.title = item.title.replace(NEWLINE_STRIP_REGEX, " ");
dateEdited = Date.now();
} else if (!isUpdating) {
item.title = formatTitle(
this.db.settings.getTitleFormat(),
this.db.settings.getDateFormat(),
this.db.settings.getTimeFormat(),
headline.split(" ").splice(0, 10).join(" "),
this.totalNotes
);
}
if (isUpdating) {
@@ -390,20 +398,6 @@ export class Notes implements ICollection {
}
});
}
private getNoteTitle(title: string, headline?: string) {
if (title.trim().length > 0) {
return title.replace(NEWLINE_STRIP_REGEX, " ");
}
return formatTitle(
this.db.settings.getTitleFormat(),
this.db.settings.getDateFormat(),
this.db.settings.getTimeFormat(),
headline?.split(" ").splice(0, 10).join(" "),
this.totalNotes
);
}
}
function getNoteHeadline(content: Tiptap) {