This commit is contained in:
Timothy Jaeryang Baek
2025-11-19 14:14:53 -05:00
parent 17389e1b66
commit aad23e2e53
6 changed files with 36 additions and 31 deletions
+27
View File
@@ -1,4 +1,7 @@
import DOMPurify from 'dompurify';
import { toast } from 'svelte-sonner';
import { createNewNote } from '$lib/apis/notes';
export const downloadPdf = async (note) => {
const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([
@@ -103,3 +106,27 @@ export const downloadPdf = async (note) => {
pdf.save(`${note.title}.pdf`);
};
export const createNoteHandler = async (title: string, content?: string) => {
// $i18n.t('New Note'),
const res = await createNewNote(localStorage.token, {
// YYYY-MM-DD
title: title,
data: {
content: {
json: null,
html: content ?? '',
md: content ?? ''
}
},
meta: null,
access_control: {}
}).catch((error) => {
toast.error(`${error}`);
return null;
});
if (res) {
return res;
}
};