diff --git a/chrome/content/zotero/import/citavi.js b/chrome/content/zotero/import/citavi.js index 16e1f19970..f54f05a84f 100644 --- a/chrome/content/zotero/import/citavi.js +++ b/chrome/content/zotero/import/citavi.js @@ -52,7 +52,6 @@ const ImportCitaviAnnotatons = async (translation) => { const createdOn = xpathTextOrNull(knowledgeItem, './CreatedOn'); const modifiedOn = xpathTextOrNull(knowledgeItem, './ModifiedOn'); const coreStatement = xpathTextOrNull(knowledgeItem, './CoreStatement'); - const pageRange = xpathTextOrNull(knowledgeItem, './PageRange'); const quotationType = xpathTextOrNull(knowledgeItem, './QuotationType'); const text = xpathTextOrNull(knowledgeItem, './Text'); const itemID = IDMap[referenceID]; @@ -95,7 +94,6 @@ const ImportCitaviAnnotatons = async (translation) => { comment: isFirstPage ? coreStatement : '', text: isFirstPage ? text : '', position: { pageIndex, rects: pageRects }, - pageLabel: pageRange || '', dateAdded: createdOn, dateModified: modifiedOn, tags: keywords.map(keyword => ({ name: keyword })) diff --git a/test/tests/data/citavi-test-project.ctv6 b/test/tests/data/citavi-test-project.ctv6 index 80fa5b04bf..f5c3ce630e 100644 --- a/test/tests/data/citavi-test-project.ctv6 +++ b/test/tests/data/citavi-test-project.ctv6 @@ -1,5 +1,5 @@  - + @@ -61,10 +61,10 @@ true - 18/02/2022 18:26:19 + 30/03/2022 12:23:58 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9 true @@ -112,7 +112,7 @@ - + _Vexli 2022-02-18T17:25:29 _Vexli @@ -122,7 +122,7 @@ blue 9b736a9739934a4acd0d222f5edab3ab0209f008 - + _Vexli 2022-02-18T17:26:03 _Vexli @@ -132,7 +132,7 @@ comment 60fcdfd0c330a0636db449998f8c8f58c7522826 - + _Vexli 2022-02-18T17:24:22 _Vexli @@ -144,7 +144,7 @@ - + _Vexli 2022-02-18T17:24:05 _Vexli @@ -157,11 +157,11 @@ - + _Vexli 2022-02-18T17:15:05 _Vexli - 2022-02-18T17:24:05 + 2022-03-30T10:16:42 0 0 0 @@ -186,60 +186,69 @@ - 26ab57d9-2082-4978-bdd2-323e1889381e;840dd435-d9e6-4d49-84a8-be953b018194 + e54210c0-4909-4113-b0fe-2a3eddb41cb9;3a7b2137-cfb8-4613-adf0-1762eba33929 - + _Vexli 2022-02-18T17:17:22 _Vexli - 2022-02-18T17:17:22 + 2022-03-30T10:16:42
{"$id":"1","$type":"SwissAcademic.Citavi.LinkedResource, SwissAcademic.Citavi","LinkedResourceType":1,"UriString":"recognizePDF_test_title.pdf","LinkedResourceStatus":8}
0 0 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9
- - _Vexli - 2022-02-18T17:24:15 - _Vexli - 2022-02-18T17:24:15 - 06737ac8-3637-4534-9cb2-a1e551901ce7 - [{"IsContainer":false,"PageIndex":1,"X1":230.20219999999998,"X2":275.47790585937497,"Y1":578.879472,"Y2":585.816528},{"IsContainer":true,"PageIndex":1,"X1":230.20219999999998,"X2":275.47790585937497,"Y1":578.879472,"Y2":585.816528}] - false - - - _Vexli - 2022-02-18T17:25:17 - _Vexli - 2022-02-18T17:25:17 - 06737ac8-3637-4534-9cb2-a1e551901ce7 - [{"IsContainer":false,"PageIndex":1,"X1":228.3353,"X2":461.75599999999912,"Y1":475.340598,"Y2":482.178702},{"IsContainer":false,"PageIndex":1,"X1":146.3,"X2":437.5108999999992,"Y1":463.840598,"Y2":470.678702},{"IsContainer":true,"PageIndex":1,"X1":146.3,"X2":461.75599999999912,"Y1":463.840598,"Y2":482.178702}] - false - - + _Vexli 2022-02-18T17:25:35 _Vexli 2022-02-18T17:25:35 - 06737ac8-3637-4534-9cb2-a1e551901ce7 + 724c9b68-c466-4c5f-a349-4d52d6b61419 [{"IsContainer":false,"PageIndex":1,"X1":254.51480000000004,"X2":316.46209999999974,"Y1":532.840598,"Y2":539.67870199999993},{"IsContainer":true,"PageIndex":1,"X1":254.51480000000004,"X2":316.46209999999974,"Y1":532.840598,"Y2":539.67870199999993}] false - + + _Vexli + 2022-02-18T17:24:15 + _Vexli + 2022-02-18T17:24:15 + 724c9b68-c466-4c5f-a349-4d52d6b61419 + [{"IsContainer":false,"PageIndex":1,"X1":230.20219999999998,"X2":275.47790585937497,"Y1":578.879472,"Y2":585.816528},{"IsContainer":true,"PageIndex":1,"X1":230.20219999999998,"X2":275.47790585937497,"Y1":578.879472,"Y2":585.816528}] + false + + _Vexli 2022-02-18T17:25:56 _Vexli 2022-02-18T17:25:56 - 06737ac8-3637-4534-9cb2-a1e551901ce7 + 724c9b68-c466-4c5f-a349-4d52d6b61419 [{"IsContainer":false,"PageIndex":1,"X1":146.3,"X2":199.49469218750005,"Y1":429.340598,"Y2":436.178702},{"IsContainer":true,"PageIndex":1,"X1":146.3,"X2":199.49469218750005,"Y1":429.340598,"Y2":436.178702}] false + + _Vexli + 2022-02-18T17:25:17 + _Vexli + 2022-02-18T17:25:17 + 724c9b68-c466-4c5f-a349-4d52d6b61419 + [{"IsContainer":false,"PageIndex":1,"X1":228.3353,"X2":461.75599999999912,"Y1":475.340598,"Y2":482.178702},{"IsContainer":false,"PageIndex":1,"X1":146.3,"X2":437.5108999999992,"Y1":463.840598,"Y2":470.678702},{"IsContainer":true,"PageIndex":1,"X1":146.3,"X2":461.75599999999912,"Y1":463.840598,"Y2":482.178702}] + false + + + _Vexli + 2022-03-30T10:15:37 + _Vexli + 2022-03-30T10:15:37 + 724c9b68-c466-4c5f-a349-4d52d6b61419 + [{"IsContainer":false,"PageIndex":3,"X1":133.3,"X2":185.2685,"Y1":330.92415,"Y2":340.29434999999995},{"IsContainer":true,"PageIndex":3,"X1":133.3,"X2":185.2685,"Y1":330.92415,"Y2":340.29434999999995}] + false + - + _Vexli 2022-02-18T17:24:15 _Vexli @@ -250,14 +259,14 @@ -1 0 6 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9 0 peer-to-peer ["52cbbd8c-80d2-4848-9374-6b435d4719bf"] 0 0 - + _Vexli 2022-02-18T17:25:17 _Vexli @@ -268,7 +277,7 @@ -1 1 1 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9 0 cpu power is controlled by nodes that are … ["427b6a09-a648-4453-8317-d7735ec2e83e"] @@ -276,7 +285,7 @@ CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. 0 - + _Vexli 2022-02-18T17:25:35 _Vexli @@ -286,14 +295,14 @@ -1 2 5 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9 0 _ ["77efd7da-f246-44dd-80a2-82e9c372b267"] 0 0 - + _Vexli 2022-02-18T17:25:56 _Vexli @@ -304,7 +313,7 @@ -1 3 4 - 26ab57d9-2082-4978-bdd2-323e1889381e + e54210c0-4909-4113-b0fe-2a3eddb41cb9 0 proof-of-work ["fab8e0a8-f7a6-4785-ad47-5da0d03d64b6"] @@ -312,59 +321,97 @@ This is a comment 0 + + _Vexli + 2022-03-30T10:15:37 + _Vexli + 2022-03-30T10:23:56 + Network + 1 + 0 + + Omit + gibberish + gibberish + +gibberish]]> + 2147483647 + 100 + 4 + 3 + e54210c0-4909-4113-b0fe-2a3eddb41cb9 + 0 + network + ["154047bb-c681-4ba3-898d-d39335ea8b8e"] + 0 + This is a green highlight on page 3 + 0 + - 6c72f24c-43dc-43d5-9e14-3a192fc9325c;c36f7ee8-02d1-49f2-9cd7-6c96e441542f:0 - e5b80a60-344c-4b29-b888-e97205753567;b07dfd83-135c-4cb6-977b-864c0f59856d:0 - a113a66b-2c16-43e2-968c-e530ed9ac5eb;669dc1b6-694b-4eb8-95b2-2c4e8e2f9055:0 + b96887ad-e3cd-4861-b502-6bb002a91a0e;2db290bf-52e6-4475-95ea-077161c8e2d0:0 + de2dc289-fa66-4614-9ede-2c8abcb850d8;7a9841cc-5800-4444-8e0a-b4bda7282fa5:0 + d14b7f83-8cda-4d70-a89f-95a9eca94903;8e2887cd-7124-4278-b285-58bd0637a2ee:0 - - _Vexli - 2022-02-18T17:24:15 - _Vexli - 2022-02-18T17:24:15 - PdfKnowledgeItem - 0 - 6c72f24c-43dc-43d5-9e14-3a192fc9325c - KnowledgeItem - f08dbaec-6e7e-41f6-b46b-5f9855cd93ac - Annotation - - - _Vexli - 2022-02-18T17:25:17 - _Vexli - 2022-02-18T17:25:17 - PdfKnowledgeItem - 0 - e5b80a60-344c-4b29-b888-e97205753567 - KnowledgeItem - 7a8c8a33-5902-48f7-8f6d-03e91d852434 - Annotation - - + _Vexli 2022-02-18T17:25:35 _Vexli 2022-02-18T17:25:35 PdfKnowledgeItem 0 - 32954e21-0303-4365-9f17-ca967e9bb0c7 + e319aee8-104b-4480-89ac-e4adf0407fb1 KnowledgeItem - 9d09af5e-a2bc-4188-a5be-8051cafa348c + b1b35e86-1ba7-410a-a7ed-474526d6a5bb Annotation - + + _Vexli + 2022-02-18T17:24:15 + _Vexli + 2022-02-18T17:24:15 + PdfKnowledgeItem + 0 + b96887ad-e3cd-4861-b502-6bb002a91a0e + KnowledgeItem + 3dc77d5e-ad7f-4f28-a666-39e610027e36 + Annotation + + _Vexli 2022-02-18T17:25:56 _Vexli 2022-02-18T17:25:56 PdfKnowledgeItem 0 - a113a66b-2c16-43e2-968c-e530ed9ac5eb + d14b7f83-8cda-4d70-a89f-95a9eca94903 KnowledgeItem - 73b76ed5-b1ec-433c-afdd-2f1a08168dd5 + 7125732b-bf3f-4195-85ee-945cd2a0457c + Annotation + + + _Vexli + 2022-02-18T17:25:17 + _Vexli + 2022-02-18T17:25:17 + PdfKnowledgeItem + 0 + de2dc289-fa66-4614-9ede-2c8abcb850d8 + KnowledgeItem + e23cf096-d249-4607-a16e-13885d42e44a + Annotation + + + _Vexli + 2022-03-30T10:15:37 + _Vexli + 2022-03-30T10:15:37 + PdfKnowledgeItem + 0 + 87b7745e-4156-410a-83b5-678f1d22f7a4 + KnowledgeItem + 53af7081-5ae2-4a91-bee7-fd6f7e094413 Annotation diff --git a/test/tests/fileInterfaceTest.js b/test/tests/fileInterfaceTest.js index 9cebdba02b..f941a5ab9e 100644 --- a/test/tests/fileInterfaceTest.js +++ b/test/tests/fileInterfaceTest.js @@ -233,35 +233,56 @@ describe("Zotero_File_Interface", function() { assert.equal(importedItem.getField('title'), 'Bitcoin: A Peer-to-Peer Electronic Cash System'); const importedPDF = await Zotero.Items.getAsync(importedItem.getAttachments()[0]); const annotations = importedPDF.getAnnotations(); - assert.lengthOf(annotations, 4); - const annotationTexts = importedPDF.getAnnotations().map(a => a.annotationText); - const annotationPositions = importedPDF.getAnnotations().map(a => JSON.parse(a.annotationPosition)); - const annotationSortIndexes = importedPDF.getAnnotations().map(a => a.annotationSortIndex); - const annotationTags = importedPDF.getAnnotations().map(a => a.getTags()); - - assert.sameMembers(annotationTexts, [ - 'peer-to-peer', - 'CPU power is controlled by nodes that are not cooperating to attack the network, they\'ll generate the longest chain and outpace attackers.', - 'double-spending', - 'This is a comment' - ]); - assert.sameMembers(annotationSortIndexes, [ - '00000|000103|00206', - '00000|000723|00309', - '00000|000390|00252', - '00000|000981|00355' - ]); + assert.lengthOf(annotations, 5); - assert.sameDeepMembers(annotationPositions, [ - { pageIndex: 0, rects: [[230.202, 578.879, 275.478, 585.817], [230.202, 578.879, 275.478, 585.817]] }, - { pageIndex: 0, rects: [[254.515, 532.841, 316.462, 539.679], [254.515, 532.841, 316.462, 539.679]] }, + const annotation1 = annotations.find(a => a.annotationText === 'peer-to-peer'); + const annotation2 = annotations.find(a => a.annotationText === 'CPU power is controlled by nodes that are not cooperating to attack the network, they\'ll generate the longest chain and outpace attackers.'); + const annotation3 = annotations.find(a => a.annotationText === 'double-spending'); + const annotation4 = annotations.find(a => a.annotationText === 'This is a comment'); + const annotation5 = annotations.find(a => a.annotationText === 'This is a green highlight on page 3'); + + assert.deepEqual( + JSON.parse(annotation1.annotationPosition), + { pageIndex: 0, rects: [[230.202, 578.879, 275.478, 585.817], [230.202, 578.879, 275.478, 585.817]] } + ); + + assert.deepEqual( + JSON.parse(annotation2.annotationPosition), { pageIndex: 0, rects: [[228.335, 475.341, 461.756, 482.179], [146.3, 463.841, 437.511, 470.679], [146.3, 463.841, 461.756, 482.179]] }, - { pageIndex: 0, rects: [[146.3, 429.341, 199.495, 436.179], [146.3, 429.341, 199.495, 436.179]] } - ]); + ); - assert.sameDeepMembers(annotationTags, [ - [{ tag: 'red' }], [], [{ tag: 'blue' }], [{ tag: 'comment' }] - ]); + assert.deepEqual( + JSON.parse(annotation3.annotationPosition), + { pageIndex: 0, rects: [[254.515, 532.841, 316.462, 539.679], [254.515, 532.841, 316.462, 539.679]] }, + ); + + assert.deepEqual( + JSON.parse(annotation4.annotationPosition), + { pageIndex: 0, rects: [[146.3, 429.341, 199.495, 436.179], [146.3, 429.341, 199.495, 436.179]] } + ); + + assert.deepEqual( + JSON.parse(annotation5.annotationPosition), + { pageIndex: 2, rects: [[133.3, 330.924, 185.269, 340.294], [133.3, 330.924, 185.269, 340.294]] } + ); + + assert.equal(annotation1.annotationSortIndex, '00000|000103|00206'); + assert.equal(annotation2.annotationSortIndex, '00000|000723|00309'); + assert.equal(annotation3.annotationSortIndex, '00000|000390|00252'); + assert.equal(annotation4.annotationSortIndex, '00000|000981|00355'); + assert.equal(annotation5.annotationSortIndex, '00002|001638|00451'); + + assert.deepEqual(annotation1.getTags(), [{ tag: 'red' }]); + assert.deepEqual(annotation2.getTags(), [{ tag: 'blue' }]); + assert.deepEqual(annotation3.getTags(), []); + assert.deepEqual(annotation4.getTags(), [{ tag: 'comment' }]); + assert.deepEqual(annotation5.getTags(), []); + + assert.equal(annotation1.annotationPageLabel, '1'); + assert.equal(annotation2.annotationPageLabel, '1'); + assert.equal(annotation3.annotationPageLabel, '1'); + assert.equal(annotation4.annotationPageLabel, '1'); + assert.equal(annotation5.annotationPageLabel, '3'); }); }); });