From e92bea200aecd2bf44dc5d8c8e6c1e8b64a19cb3 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sat, 20 Feb 2021 12:32:41 +0500 Subject: [PATCH] feat: make note.export accept raw content --- packages/core/models/note.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/models/note.js b/packages/core/models/note.js index 7b869ded6..c6a59649a 100644 --- a/packages/core/models/note.js +++ b/packages/core/models/note.js @@ -50,8 +50,9 @@ export default class Note { /** * * @param {"html"|"md"|"txt"} format - Format to export into + * @param {string?} rawContent - Use this raw content instead of generating itself */ - async export(to = "html") { + async export(to = "html", rawContent) { const templateData = { metadata: this.data, title: this.title, @@ -66,13 +67,13 @@ export default class Note { switch (to) { case "html": - templateData.content = content.toHTML(); + templateData.content = rawContent || content.toHTML(); return HTMLBuilder.buildHTML(templateData); case "txt": - templateData.content = content.toTXT(); + templateData.content = rawContent || content.toTXT(); return TextBuilder.buildText(templateData); case "md": - templateData.content = content.toMD(); + templateData.content = rawContent || content.toMD(); return MarkdownBuilder.buildMarkdown(templateData); default: throw new Error("Export format not supported.");