mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
feat: make note.export accept raw content
This commit is contained in:
@@ -50,8 +50,9 @@ export default class Note {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {"html"|"md"|"txt"} format - Format to export into
|
* @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 = {
|
const templateData = {
|
||||||
metadata: this.data,
|
metadata: this.data,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
@@ -66,13 +67,13 @@ export default class Note {
|
|||||||
|
|
||||||
switch (to) {
|
switch (to) {
|
||||||
case "html":
|
case "html":
|
||||||
templateData.content = content.toHTML();
|
templateData.content = rawContent || content.toHTML();
|
||||||
return HTMLBuilder.buildHTML(templateData);
|
return HTMLBuilder.buildHTML(templateData);
|
||||||
case "txt":
|
case "txt":
|
||||||
templateData.content = content.toTXT();
|
templateData.content = rawContent || content.toTXT();
|
||||||
return TextBuilder.buildText(templateData);
|
return TextBuilder.buildText(templateData);
|
||||||
case "md":
|
case "md":
|
||||||
templateData.content = content.toMD();
|
templateData.content = rawContent || content.toMD();
|
||||||
return MarkdownBuilder.buildMarkdown(templateData);
|
return MarkdownBuilder.buildMarkdown(templateData);
|
||||||
default:
|
default:
|
||||||
throw new Error("Export format not supported.");
|
throw new Error("Export format not supported.");
|
||||||
|
|||||||
Reference in New Issue
Block a user