Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix empty note cannot be exported

Abdullah Atta3f1761a540a9
diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.ts
index 565a2de13..d161d3754 100644
--- a/packages/core/src/collections/notes.ts
+++ b/packages/core/src/collections/notes.ts
@@ -285,31 +285,32 @@ export class Notes implements ICollection {
const { format, rawContent } = options;
const contentString =
- rawContent ||
- (await (async () => {
- let contentItem = options.contentItem;
- if (!contentItem) {
- const rawContent = await this.db.content.findByNoteId(note.id);
- if (rawContent && rawContent.locked) return false;
- contentItem = rawContent || EMPTY_CONTENT(note.id);
- }
-
- const { data, type } =
- options?.embedMedia && format !== "txt"
- ? await this.db.content.downloadMedia(
- `export-${note.id}`,
- contentItem,
- false
- )
- : contentItem;
- const content = await getContentFromData(type, data);
- return format === "html"
- ? content.toHTML()
- : format === "md"
- ? content.toMD()
- : content.toTXT();
- })());
- if (!contentString) return false;
+ rawContent === undefined
+ ? await (async () => {
+ let contentItem = options.contentItem;
+ if (!contentItem) {
+ const rawContent = await this.db.content.findByNoteId(note.id);
+ if (rawContent && rawContent.locked) return false;
+ contentItem = rawContent || EMPTY_CONTENT(note.id);
+ }
+
+ const { data, type } =
+ options?.embedMedia && format !== "txt"
+ ? await this.db.content.downloadMedia(
+ `export-${note.id}`,
+ contentItem,
+ false
+ )
+ : contentItem;
+ const content = await getContentFromData(type, data);
+ return format === "html"
+ ? content.toHTML()
+ : format === "md"
+ ? content.toMD()
+ : content.toTXT();
+ })()
+ : rawContent;
+ if (contentString === false) return false;
const tags = (await this.db.relations.to(note, "tag").resolve()).map(
(tag) => tag.title