Skip to content

Commit

Permalink
mobile: add support for markdown + frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed authored and thecodrr committed Nov 25, 2023
1 parent 134904b commit d71b9ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 13 additions & 1 deletion apps/mobile/app/components/sheets/export-notes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ const ExportNotesSheet = ({ notes, update }) => {
id: notesnook.ids.dialogs.export.md,
pro: premium
},
{
title: "Markdown + Frontmatter",
func: async () => {
await save("md-frontmatter");
},
icon: "language-markdown",
desc: "View in any text or markdown editor",
id: notesnook.ids.dialogs.export.md,
pro: premium
},
{
title: "Plain Text",
func: async () => {
Expand Down Expand Up @@ -178,7 +188,9 @@ const ExportNotesSheet = ({ notes, update }) => {
>
<Icon
name={item.icon}
color={item.pro ? colors.primary.accent : colors.primary.icon}
color={
item.pro ? colors.primary.accent : colors.primary.icon
}
size={SIZE.xxxl + 10}
/>
</View>
Expand Down
11 changes: 7 additions & 4 deletions apps/mobile/app/services/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function makeHtml(note) {

/**
*
* @param {"txt" | "pdf" | "md" | "html"} type
* @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function exportAs(type, note, bulk) {
let data;
Expand All @@ -122,6 +122,9 @@ async function exportAs(type, note, bulk) {
case "md":
data = await db.notes.note(note.id).export("md");
break;
case "md-frontmatter":
data = await db.notes.note(note.id).export("md-frontmatter");
break;
case "pdf":
{
let html = await makeHtml(note);
Expand Down Expand Up @@ -159,7 +162,7 @@ async function exportAs(type, note, bulk) {

/**
*
* @param {"txt" | "pdf" | "md" | "html"} type
* @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function exportNote(note, type) {
let path = await getPath(FolderNames[type]);
Expand All @@ -180,7 +183,7 @@ async function exportNote(note, type) {
filePath: path,
type: "text/plain",
name: "Text",
fileName: fileName + `.${type}`
fileName: fileName + `.${type === "md-frontmatter" ? "md" : type}`
};
}

Expand Down Expand Up @@ -212,7 +215,7 @@ function getUniqueFileName(fileName, results) {

/**
*
* @param {"txt" | "pdf" | "md" | "html"} type
* @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function bulkExport(notes, type, callback) {
let path = await getPath(FolderNames[type]);
Expand Down

0 comments on commit d71b9ed

Please sign in to comment.