feat: Added "Import" option in the account menu that allows you to import from plaintext/markdown files, Evernote exports, Simplenote exports, Google Keep exports and also convert Aegis exports to TokenVault notes

This commit is contained in:
Aman Harwara
2022-12-30 01:22:59 +05:30
committed by GitHub
parent f1ae7a53ef
commit 6e4bf2417a
25 changed files with 755 additions and 207 deletions

View File

@@ -2,7 +2,6 @@ import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
import { ContentType } from '@standardnotes/common'
import { readFileAsText } from '../Utils'
import { WebApplicationInterface } from '@standardnotes/services'
import { Importer } from '../Importer'
type SimplenoteItem = {
creationDate: string
@@ -15,9 +14,28 @@ type SimplenoteData = {
trashedNotes: SimplenoteItem[]
}
export class SimplenoteConverter extends Importer {
constructor(protected override application: WebApplicationInterface) {
super(application)
const isSimplenoteEntry = (entry: any): boolean => entry.id && entry.content && entry.creationDate && entry.lastModified
export class SimplenoteConverter {
constructor(protected application: WebApplicationInterface) {}
static isValidSimplenoteJson(json: any): boolean {
return (
(json.activeNotes && json.activeNotes.every(isSimplenoteEntry)) ||
(json.trashedNotes && json.trashedNotes.every(isSimplenoteEntry))
)
}
async convertSimplenoteBackupFileToNotes(file: File): Promise<DecryptedTransferPayload<NoteContent>[]> {
const content = await readFileAsText(file)
const notes = this.parse(content)
if (!notes) {
throw new Error('Could not parse notes')
}
return notes
}
createNoteFromItem(item: SimplenoteItem, trashed: boolean): DecryptedTransferPayload<NoteContent> {
@@ -51,18 +69,6 @@ export class SimplenoteConverter extends Importer {
}
}
async convertSimplenoteBackupFileToNotes(file: File): Promise<DecryptedTransferPayload<NoteContent>[]> {
const content = await readFileAsText(file)
const notes = this.parse(content)
if (!notes) {
throw new Error('Could not parse notes')
}
return notes
}
parse(data: string) {
try {
const parsed = JSON.parse(data) as SimplenoteData