web: add support for colornote importer

* add colornote password input field
* add support for importing reminders
* fix archived notes import

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2026-02-02 15:17:42 +05:00
parent 79284cb886
commit 84cf1246ad
2 changed files with 47 additions and 3 deletions

View File

@@ -53,6 +53,9 @@ export function FileProviderHandler(props: FileProviderHandlerProps) {
});
const [totalNoteCount, setTotalNoteCount] = useState(0);
const [_, setCounter] = useState<number>(0);
const [colornotePassword, setColornotePassword] = useState<
string | undefined
>(undefined);
const logs = useRef<string[]>([]);
const onDrop = useCallback((acceptedFiles: File[]) => {
@@ -103,6 +106,9 @@ export function FileProviderHandler(props: FileProviderHandlerProps) {
},
reporter: () => {
setTotalNoteCount(++totalNotes);
},
options: {
colornote: { password: colornotePassword }
}
};
@@ -224,6 +230,25 @@ export function FileProviderHandler(props: FileProviderHandlerProps) {
</Text>
</Text>
</Flex>
{files.length > 0 && provider.id === "colornote" && (
<Flex
sx={{
alignItems: "center",
justifyContent: "space-between",
mt: 1
}}
>
<Text variant="body">Colornote password</Text>
<Input
placeholder="Backup password e.g '0000'"
type={"text"}
sx={{ width: 200, padding: 2, height: 25 }}
onChange={(e) => setColornotePassword(e.target.value)}
/>
</Flex>
)}
{files.length > 0 ? (
<Accordion
isClosed

View File

@@ -48,9 +48,6 @@ const colorMap: Record<string, string | undefined> = {
yellow: "#FFC107"
};
/**
* TODO: add support for trashed notes and reminders
*/
export async function importNote(note: Note) {
const encryptedAttachmentFieldsMap = await processAttachments(
note.attachments
@@ -117,6 +114,10 @@ async function processNote(
if (!noteId) return;
if (note.archived) {
await db.notes.archive(true, noteId);
}
for (const tag of note.tags || []) {
const tagId =
(await db.tags.find(tag))?.id ||
@@ -165,6 +166,24 @@ async function processNote(
for (const notebookId of notebookIds)
await db.notes.addToNotebook(notebookId, noteId);
}
if (note.reminder) {
const reminderId = await db.reminders.add({
recurringMode: note.reminder.recurringMode,
mode: note.reminder.mode,
selectedDays: note.reminder.selectedDays,
date: note.reminder.date,
title: note.reminder.title,
description: note.reminder.description
});
if (reminderId) {
await db.relations.add(
{ id: noteId, type: "note" },
{ id: reminderId, type: "reminder" }
);
}
}
}
async function importNotebook(