Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions packages/core/__tests__/__snapshots__/evernote-packed.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
"a56fb883367d9e17f99d7e08abf159a1/note.json",
"e41d0c9f67ce852ede9eca2b08476569/note.json",
"59916dfa0eb3b998fa6626f818de40cf/note.json",
"60d8a13ec39e6f366a9d044072acbf2c/note.json",
"9524b82174608a2be9b9dd060aefa058/note.json",
"d6fde948b2dbb49f1e77a776459bc79b/note.json",
"ca2f4531a54dca1758ea06358c55b77d/note.json",
"95ae2a96d490a14ec7ad7134c598c89a/attachments/986a32ca93f8fb6e",
"95ae2a96d490a14ec7ad7134c598c89a/note.json",
"06b10f9036659b004d16701ac2712482/note.json",
"ebbb91950abed014fc63d2eba302a71d/note.json",
"326f28615a46fcafb097728989250b29/note.json",
"f2ff542541cefcf355cb953d28640344/attachments/3fe04cccf9201f76",
"f2ff542541cefcf355cb953d28640344/note.json",
"232df33a75e7db2b969b4f6935668265/attachments/539f86d6261aac41",
"232df33a75e7db2b969b4f6935668265/note.json",
"37ba884c686020ece6bfc0672b818d04/note.json",
"c49fcb548d33b02728047c098953bffe/attachments/4f6544c889080dec",
"c49fcb548d33b02728047c098953bffe/attachments/90c8f0b0b6f9fb53",
"c49fcb548d33b02728047c098953bffe/note.json",
"e0dbf7b37d4099b03955fac1ccb52844/note.json",
"4280dccb893438fa55dcbd9e7ada44ee/note.json",
"e72ae29573aba7f5574f0bc2729e65e6/note.json",
"affc502fb0b3ad70a245907d60887c03/note.json",
"9e97efd3f48604a3c2f4dad4f2b1ddea/note.json",
"a34b68e5b643be6fa63e47906d59fc28/note.json",
Expand All @@ -35,19 +38,19 @@
"817cc80fc7752cdb010b1cf2c670d0eb/note.json",
"6451f164dcf01f5556c0139a60b5caba/note.json",
"78a49fd1877e49770d11fb1df23f1f9a/note.json",
"782e449d8216e79eacef4a7e5976b7c6/attachments/61d44e78afd2b2f5",
"782e449d8216e79eacef4a7e5976b7c6/note.json",
"56645f26d8e6aa111bd3e992cf7d6335/attachments/1f243764c8e2e51b",
"56645f26d8e6aa111bd3e992cf7d6335/note.json",
"6e841b24ea520f9f183641568850ba69/attachments/2c7f6bd70a3507e3",
"6e841b24ea520f9f183641568850ba69/note.json",
"c5670c876f5fe0dab7283231305e70ac/note.json",
"6b7a06aeecebd9f467caaf547c768b54/note.json",
"bedfd5d8d546b139aa8bf27679efaa1a/note.json",
"ebc8c54fab7f8d2b6e1071f308618c1c/note.json",
"831c544ce7da199e71f2b9f1ee0a419e/note.json",
"08618db2d862c719b5e44afcedf0c5d7/note.json",
"2c06ec89ddb187a85a2f4459c5048900/note.json",
"39d7faeb28d23909bdc4484b4b993110/note.json",
"a0de9a5a7f242027a63796c5ef336376/note.json",
"fab1942c4151af537c5655638584c37c/note.json",
"9ad113190958fb107aceb2b674bcdbeb/note.json",
"a6759fd87b5cdc2417ccbb8dd0178adf/note.json",
"be43fc8dca707b17d78eab4e3e8ecbaf/note.json",
"a7b462d4f50fba9a38794b3661cdd01d/note.json",
Expand Down Expand Up @@ -75,7 +78,7 @@
"d06956206a846052e0e85ff8f237d3c7/note.json",
"7320703a2552e221913055038070b143/note.json",
"7923dcd8b3bc8123aa4d9717db324745/note.json",
"329f038758845bfa567924313d89dd05/note.json",
"ddb9afbdff944846f8f61a8d75646b9b/note.json",
"a21a5eb462235f961e8e7f3a2f69e860/note.json",
"2dc9155222b35832daf5c18cc1af292a/note.json",
"ad76f1012d48c8b0976d4bb2e6a68da3/note.json",
Expand All @@ -95,8 +98,8 @@
"0f7f5006689a3e221ecb299f5f37d37d/note.json",
"bb98c89a7c72c52d9a1a51386bfe7387/attachments/12d4f87f996331cb",
"bb98c89a7c72c52d9a1a51386bfe7387/note.json",
"f1af80fc8bde9911380a8c64e140a1df/attachments/76f389b0ffe10810",
"f1af80fc8bde9911380a8c64e140a1df/note.json",
"c3bb2e30ae2d8ce27aa6ccd04af4ea2b/attachments/22ddf88e6047839a",
"c3bb2e30ae2d8ce27aa6ccd04af4ea2b/note.json",
"83ce6b7de1a84208e874c9bf60321074/note.json",
"a6363c93bece9402270b46c22008d12a/attachments/1c887a34c1e59f54",
"a6363c93bece9402270b46c22008d12a/note.json",
Expand All @@ -106,7 +109,7 @@
"dae497abb291b356f18ac010cf2ccb16/note.json",
"454ba612a5f60e90851e65cd35e8290a/attachments/7d94ea3bf94ddece",
"454ba612a5f60e90851e65cd35e8290a/note.json",
"468aaa6ec25a50fafe175220d4ba1030/note.json",
"9cd497c8ba69422ba349713edd0227c3/note.json",
"583dbe271b9a26b237da0205e3c34137/attachments/90dd89a7389b511a",
"583dbe271b9a26b237da0205e3c34137/attachments/4e418f0d69cf49fa",
"583dbe271b9a26b237da0205e3c34137/attachments/95fba3b27c0ce1a1",
Expand Down
115 changes: 105 additions & 10 deletions packages/core/__tests__/__snapshots__/evernote.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}
],
"content": {
"data": "<pre>klkmklmk<br>;mkmk<br>#include <Servo.h><br><br><br>#include <LiquidCrystal.h><br><br><br>kmkmkl</pre>",
"data": "<pre>klkmklmk<br>;mkmk<br>#include <Servo.h><br><br>#include <LiquidCrystal.h><br><br>kmkmkl</pre>",
"type": "html"
},
"compatibilityVersion": 2,
Expand Down Expand Up @@ -227,8 +227,8 @@
"attachments": [
{
"filename": "-http---www.theguardian.com-world-2015-jul-27-dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe-.clip",
"size": 1460469,
"hash": "3fe04cccf9201f76",
"size": 1456702,
"hash": "539f86d6261aac41",
"hashType": "xxh64",
"mime": "application/vnd.notesnook.web-clip"
}
Expand All @@ -240,7 +240,7 @@
}
],
"content": {
"data": "<iframe class=\"web-clip\"\n data-filename=\"-http---www.theguardian.com-world-2015-jul-27-dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe-.clip\"\n data-size=\"1460469\" data-hash=\"3fe04cccf9201f76\"\n data-mime=\"application/vnd.notesnook.web-clip\" src=\"\r\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\r\n \" title=\"\r\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\r\n \"> </iframe><hr><p>Clipped from: <a href=\"\r\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\r\n \">\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\n </a></p>",
"data": "<iframe class=\"web-clip\"\n data-filename=\"-http---www.theguardian.com-world-2015-jul-27-dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe-.clip\"\n data-size=\"1456702\" data-hash=\"539f86d6261aac41\"\n data-mime=\"application/vnd.notesnook.web-clip\" src=\"\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\n \" title=\"\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\n \"> </iframe><hr><p>Clipped from: <a href=\"\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\n \">\n http://www.theguardian.com/world/2015/jul/27/dying-for-christianity-millions-at-risk-amid-rise-in-persecution-across-the-globe\n </a></p>",
"type": "html"
},
"compatibilityVersion": 2,
Expand Down Expand Up @@ -306,6 +306,101 @@
"compatibilityVersion": 2,
"source": "evernote"
},
{
"title": "anote",
"tags": [
"diary"
],
"dateCreated": 1764919982000,
"dateEdited": 1766053679000,
"attachments": [],
"notebooks": [
{
"title": "nestedtagstonotebooks",
"children": []
},
{
"title": "toplevel",
"children": [
{
"title": "leaf",
"children": []
}
],
"skipApplyingToNote": true
}
],
"content": {
"data": "<p> </p><p>a note</p><p><a\n href=\"nn://note/000000000000000000000000\">link</a></p>",
"type": "html"
},
"compatibilityVersion": 2,
"source": "evernote"
},
{
"title": "coding xyz",
"tags": [],
"dateCreated": 1764929036000,
"dateEdited": 1764929045000,
"attachments": [],
"notebooks": [
{
"title": "nestedtagstonotebooks",
"children": []
},
{
"title": "coding",
"children": [
{
"title": "javascript",
"children": [
{
"title": "variables",
"children": []
}
],
"skipApplyingToNote": true
}
],
"skipApplyingToNote": true
}
],
"content": {
"data": "<p> </p><p><br></p>",
"type": "html"
},
"compatibilityVersion": 2,
"source": "evernote"
},
{
"title": "this is javascript",
"tags": [],
"dateCreated": 1764929010000,
"dateEdited": 1764929022000,
"attachments": [],
"notebooks": [
{
"title": "nestedtagstonotebooks",
"children": []
},
{
"title": "coding",
"children": [
{
"title": "javascript",
"children": []
}
],
"skipApplyingToNote": true
}
],
"content": {
"data": "<p> </p><p>best language of all time</p>",
"type": "html"
},
"compatibilityVersion": 2,
"source": "evernote"
},
{
"title": "I am a note",
"tags": [
Expand Down Expand Up @@ -632,8 +727,8 @@
"attachments": [
{
"filename": "https---unsplash.com-photos-3ym6i13y9lu.clip",
"size": 11318,
"hash": "61d44e78afd2b2f5",
"size": 11304,
"hash": "1f243764c8e2e51b",
"hashType": "xxh64",
"mime": "application/vnd.notesnook.web-clip"
}
Expand All @@ -645,7 +740,7 @@
}
],
"content": {
"data": "<iframe class=\"web-clip\"\n data-filename=\"https---unsplash.com-photos-3ym6i13y9lu.clip\"\n data-size=\"11318\" data-hash=\"61d44e78afd2b2f5\"\n data-mime=\"application/vnd.notesnook.web-clip\"\n src=\"https://unsplash.com/photos/3ym6i13Y9LU\"\n title=\"https://unsplash.com/photos/3ym6i13Y9LU\"> </iframe><hr><p>Clipped\n from: <a href=\"https://unsplash.com/photos/3ym6i13Y9LU\">https://unsplash.com/photos/3ym6i13Y9LU</a></p>",
"data": "<iframe class=\"web-clip\"\n data-filename=\"https---unsplash.com-photos-3ym6i13y9lu.clip\"\n data-size=\"11304\" data-hash=\"1f243764c8e2e51b\"\n data-mime=\"application/vnd.notesnook.web-clip\"\n src=\"https://unsplash.com/photos/3ym6i13Y9LU\"\n title=\"https://unsplash.com/photos/3ym6i13Y9LU\"> </iframe><hr><p>Clipped\n from: <a href=\"https://unsplash.com/photos/3ym6i13Y9LU\">https://unsplash.com/photos/3ym6i13Y9LU</a></p>",
"type": "html"
},
"compatibilityVersion": 2,
Expand Down Expand Up @@ -1654,8 +1749,8 @@
"attachments": [
{
"filename": "yarle-evernote.clip",
"size": 41104,
"hash": "76f389b0ffe10810",
"size": 41102,
"hash": "22ddf88e6047839a",
"hashType": "xxh64",
"mime": "application/vnd.notesnook.web-clip"
}
Expand All @@ -1667,7 +1762,7 @@
}
],
"content": {
"data": "<iframe class=\"web-clip\" data-filename=\"yarle-evernote.clip\"\n data-size=\"41104\" data-hash=\"76f389b0ffe10810\"\n data-mime=\"application/vnd.notesnook.web-clip\"\n src=\"https://www.google.com/search?sxsrf=ALeKk03bpXQ9mBvZPr4siq9b90rD9F_scA%253A1603005812287&ei=dO2LX9qUEcX1qwGn5brgBQ&q=yarle+evernote&oq=yarle+evernote&gs_lcp=CgZwc3ktYWIQAzIECCMQJzoHCCMQsAMQJzoHCAAQsAMQQzoHCC4QsAMQQzoJCAAQsAMQBxAeOgcIABCwAxAKOgUIABDJAzoCCAA6BAgAEAo6BAguEAo6BwguEMkDEA06BggAEA0QCjoGCAAQDRAeOggIABANEAoQHjoICAAQDRAFEB46CAgAEBYQChAeOgUIIRCgAToHCAAQyQMQDToECAAQDVDdEViJKmD_MGgDcAB4AYAB7gSIAf0RkgEJMC45LjEuNS0xmAEAoAEBqgEHZ3dzLXdpesgBCsABAQ&sclient=psy-ab&ved=0ahUKEwjano6Azr3sAhXF-ioKHaeyDlwQ4dUDCA0&uact=5\"\n title=\"yarle evernote\"> </iframe><hr><p>Clipped from: <a\n href=\"https://www.google.com/search?sxsrf=ALeKk03bpXQ9mBvZPr4siq9b90rD9F_scA%253A1603005812287&ei=dO2LX9qUEcX1qwGn5brgBQ&q=yarle+evernote&oq=yarle+evernote&gs_lcp=CgZwc3ktYWIQAzIECCMQJzoHCCMQsAMQJzoHCAAQsAMQQzoHCC4QsAMQQzoJCAAQsAMQBxAeOgcIABCwAxAKOgUIABDJAzoCCAA6BAgAEAo6BAguEAo6BwguEMkDEA06BggAEA0QCjoGCAAQDRAeOggIABANEAoQHjoICAAQDRAFEB46CAgAEBYQChAeOgUIIRCgAToHCAAQyQMQDToECAAQDVDdEViJKmD_MGgDcAB4AYAB7gSIAf0RkgEJMC45LjEuNS0xmAEAoAEBqgEHZ3dzLXdpesgBCsABAQ&sclient=psy-ab&ved=0ahUKEwjano6Azr3sAhXF-ioKHaeyDlwQ4dUDCA0&uact=5\">yarle\n evernote</a></p>",
"data": "<iframe class=\"web-clip\" data-filename=\"yarle-evernote.clip\"\n data-size=\"41102\" data-hash=\"22ddf88e6047839a\"\n data-mime=\"application/vnd.notesnook.web-clip\"\n src=\"https://www.google.com/search?sxsrf=ALeKk03bpXQ9mBvZPr4siq9b90rD9F_scA%253A1603005812287&ei=dO2LX9qUEcX1qwGn5brgBQ&q=yarle+evernote&oq=yarle+evernote&gs_lcp=CgZwc3ktYWIQAzIECCMQJzoHCCMQsAMQJzoHCAAQsAMQQzoHCC4QsAMQQzoJCAAQsAMQBxAeOgcIABCwAxAKOgUIABDJAzoCCAA6BAgAEAo6BAguEAo6BwguEMkDEA06BggAEA0QCjoGCAAQDRAeOggIABANEAoQHjoICAAQDRAFEB46CAgAEBYQChAeOgUIIRCgAToHCAAQyQMQDToECAAQDVDdEViJKmD_MGgDcAB4AYAB7gSIAf0RkgEJMC45LjEuNS0xmAEAoAEBqgEHZ3dzLXdpesgBCsABAQ&sclient=psy-ab&ved=0ahUKEwjano6Azr3sAhXF-ioKHaeyDlwQ4dUDCA0&uact=5\"\n title=\"yarle evernote\"> </iframe><hr><p>Clipped from: <a\n href=\"https://www.google.com/search?sxsrf=ALeKk03bpXQ9mBvZPr4siq9b90rD9F_scA%253A1603005812287&ei=dO2LX9qUEcX1qwGn5brgBQ&q=yarle+evernote&oq=yarle+evernote&gs_lcp=CgZwc3ktYWIQAzIECCMQJzoHCCMQsAMQJzoHCAAQsAMQQzoHCC4QsAMQQzoJCAAQsAMQBxAeOgcIABCwAxAKOgUIABDJAzoCCAA6BAgAEAo6BAguEAo6BwguEMkDEA06BggAEA0QCjoGCAAQDRAeOggIABANEAoQHjoICAAQDRAFEB46CAgAEBYQChAeOgUIIRCgAToHCAAQyQMQDToECAAQDVDdEViJKmD_MGgDcAB4AYAB7gSIAf0RkgEJMC45LjEuNS0xmAEAoAEBqgEHZ3dzLXdpesgBCsABAQ&sclient=psy-ab&ved=0ahUKEwjano6Azr3sAhXF-ioKHaeyDlwQ4dUDCA0&uact=5\">yarle\n evernote</a></p>",
"type": "html"
},
"compatibilityVersion": 2,
Expand Down
10 changes: 8 additions & 2 deletions packages/core/__tests__/fileproviders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ for (const providerName of ProviderFactory.getAvailableProviders()) {
hasher,
clientType: "node",
reporter() {},
storage
storage,
options: {
nestedTagToNotebookSeparator: "/"
}
};

await transform(provider, files, settings);
Expand All @@ -85,7 +88,10 @@ for (const providerName of ProviderFactory.getAvailableProviders()) {
hasher,
clientType: "node",
reporter() {},
storage
storage,
options: {
nestedTagToNotebookSeparator: "/"
}
};

await transform(provider, files, settings);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ export enum ContentType {
export type Notebook = {
title: string;
children: Notebook[];
skipApplyingToNote?: boolean;
};
53 changes: 51 additions & 2 deletions packages/core/src/providers/evernote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@ export class Evernote implements IFileProvider {
"https://help.notesnook.com/importing-notes/import-notes-from-evernote";
private ids: Record<string, string> = {};

private parseNestedTags(
tags: string[],
separator?: string
): { notebooks: Notebook[]; filteredTags: string[] } {
const notebooks: Notebook[] = [];
const filteredTags: string[] = [];

if (!separator) {
return { notebooks, filteredTags: tags };
}

for (const tag of tags) {
if (!tag.includes(separator)) {
filteredTags.push(tag);
continue;
}

const parts = tag.split(separator).filter((part) => part.trim());
if (parts.length <= 1) {
filteredTags.push(tag);
continue;
}

let rootNotebook: Notebook | undefined = undefined;
for (let i = parts.length - 1; i >= 0; i--) {
const isLeafNotebook = i === parts.length - 1;
rootNotebook = {
title: parts[i].trim(),
children: rootNotebook ? [rootNotebook] : [],
skipApplyingToNote: isLeafNotebook ? undefined : true
};
}

if (rootNotebook) {
notebooks.push(rootNotebook);
}
}

return { notebooks, filteredTags };
}

filter(file: File) {
return this.supportedExtensions.includes(file.extension);
}
Expand All @@ -60,14 +101,22 @@ export class Evernote implements IFileProvider {
for (const enNote of chunk) {
yield log(`Found ${enNote.title}...`);

const { notebooks: tagBasedNotebooks, filteredTags } =
this.parseNestedTags(
enNote.tags || [],
settings.options?.nestedTagToNotebookSeparator
);

const allNotebooks = [notebook, ...tagBasedNotebooks];

const note: Note = {
id: this.ids[enNote.title || ""],
title: enNote.title || "",
tags: enNote.tags,
tags: filteredTags,
dateCreated: enNote.created?.getTime(),
dateEdited: enNote.updated?.getTime(),
attachments: [],
notebooks: [notebook]
notebooks: allNotebooks
};
if (enNote.content) {
const elementHandler = new ElementHandler(
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export interface ProviderSettings {
storage: IStorage<Note>;
log?: (message: ProviderLogMessage) => void;
reporter: (current: number, total?: number) => void;
options?: {
nestedTagToNotebookSeparator?: string;
};
}

export type ProviderResult = {
Expand Down
Loading