Skip to content

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

web: allow exporting all notes as html, md or txt

Abdullah Atta36f3701b4f29
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 751ed70ef..4d33da188 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -64,6 +64,7 @@ import { openPath } from "../commands/open";
import { getAllAccents } from "@notesnook/theme";
import { debounce } from "../utils/debounce";
import { clearLogs, downloadLogs } from "../utils/logger";
+import { exportNotes } from "../common/export";
function subscriptionStatusToString(user) {
const status = user?.subscription?.type;
@@ -507,6 +508,27 @@ function Settings() {
tip="Create a backup file of all your data"
/>
</Button>
+ <OptionsItem
+ title={"Export all your notes"}
+ tip={
+ "Create a zip file containing all your notes as TXT, MD or HTML files"
+ }
+ options={["Text", "Markdown", "HTML"]}
+ selectedOption={-1}
+ onSelectionChanged={async (option) => {
+ await db.notes.init();
+ const format =
+ option === "Text"
+ ? "txt"
+ : option === "Markdown"
+ ? "md"
+ : "html";
+ await exportNotes(
+ format,
+ db.notes.all.map((n) => n.id)
+ );
+ }}
+ />
{isLoggedIn && (
<>
<Button
@@ -865,7 +887,7 @@ function OptionsItem(props) {
":hover": { color: selectedOption === index ? "static" : "text" },
flex: 1,
textAlign: "center",
- color: selectedOption === index ? "static" : "gray"
+ color: selectedOption === index ? "static" : "bgSecondaryText"
}}
>
{option}
diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js
index a8ac7a42f..e3690ff51 100644
--- a/packages/core/collections/notes.js
+++ b/packages/core/collections/notes.js
@@ -152,6 +152,9 @@ export default class Notes extends Collection {
return this._collection.getRaw();
}
+ /**
+ * @returns {any[]}
+ */
get all() {
const items = this._collection.getItems();
return items;