diff --git a/README.md b/README.md
index 5cf9acf..461d047 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,7 @@ The plugin uses Handlebars and Markdown to customize the output of your highligh
- If you highlight parts of two adjacent sentences, the `contextualText` will contain both sentences.
- `{{{highlight}}}` - The highlighted text.
- `{{{note}}}` - A note you added for the highlight.
+ - `{{{highlightLocation}}}` - The EPUB CFI of the highlighted text. It is used to create a link to the highlighted text in Apple Books: `[Apple Books Highlight Link](ibooks://assetid/{{bookId}}#{{highlightLocation}})`.
- `{{highlightStyle}}` - The style of the highlight. It can be one of the following values:
- `0` (underline)
- `1` (green)
@@ -132,6 +133,7 @@ Number of annotations:: {{annotations.length}}
{{#if (eq highlightStyle "4")}}- 🎯 Highlight:: {{{highlight}}}{{/if}}
{{#if (eq highlightStyle "5")}}- 🎯 Highlight:: {{{highlight}}}{{/if}}
- 📝 Note:: {{#if note}}{{{note}}}{{else}}N/A{{/if}}
+- 📙 Highlight Link:: {{#if highlightLocation}}[Apple Books Highlight Link](ibooks://assetid/{{../bookId}}#{{highlightLocation}}){{else}}N/A{{/if}}
- 📅 Highlight taken on:: {{dateFormat highlightCreationDate "YYYY-MM-DD hh:mm:ss A Z"}}
- 📅 Highlight modified on:: {{dateFormat highlightModificationDate "YYYY-MM-DD hh:mm:ss A Z"}}
diff --git a/migrations/0001_misty_silver_centurion.sql b/migrations/0001_misty_silver_centurion.sql
new file mode 100644
index 0000000..890215a
--- /dev/null
+++ b/migrations/0001_misty_silver_centurion.sql
@@ -0,0 +1 @@
+ALTER TABLE ZAEANNOTATION ADD `ZANNOTATIONLOCATION` text;
\ No newline at end of file
diff --git a/migrations/meta/0001_snapshot.json b/migrations/meta/0001_snapshot.json
new file mode 100644
index 0000000..c6b3f07
--- /dev/null
+++ b/migrations/meta/0001_snapshot.json
@@ -0,0 +1,151 @@
+{
+ "version": "5",
+ "dialect": "sqlite",
+ "id": "7be16a02-e20b-4725-898a-4f88e7a3bf1a",
+ "prevId": "9ab8f1f7-710a-4b2c-9ba7-b286cb403847",
+ "tables": {
+ "ZAEANNOTATION": {
+ "name": "ZAEANNOTATION",
+ "columns": {
+ "ZANNOTATIONASSETID": {
+ "name": "ZANNOTATIONASSETID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZFUTUREPROOFING5": {
+ "name": "ZFUTUREPROOFING5",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONREPRESENTATIVETEXT": {
+ "name": "ZANNOTATIONREPRESENTATIVETEXT",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONSELECTEDTEXT": {
+ "name": "ZANNOTATIONSELECTEDTEXT",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ZANNOTATIONLOCATION": {
+ "name": "ZANNOTATIONLOCATION",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONNOTE": {
+ "name": "ZANNOTATIONNOTE",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONCREATIONDATE": {
+ "name": "ZANNOTATIONCREATIONDATE",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONMODIFICATIONDATE": {
+ "name": "ZANNOTATIONMODIFICATIONDATE",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONSTYLE": {
+ "name": "ZANNOTATIONSTYLE",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZANNOTATIONDELETED": {
+ "name": "ZANNOTATIONDELETED",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "ZBKLIBRARYASSET": {
+ "name": "ZBKLIBRARYASSET",
+ "columns": {
+ "ZASSETID": {
+ "name": "ZASSETID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZTITLE": {
+ "name": "ZTITLE",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZAUTHOR": {
+ "name": "ZAUTHOR",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZGENRE": {
+ "name": "ZGENRE",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZLANGUAGE": {
+ "name": "ZLANGUAGE",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZLASTOPENDATE": {
+ "name": "ZLASTOPENDATE",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ZCOVERURL": {
+ "name": "ZCOVERURL",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ }
+ },
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ }
+}
\ No newline at end of file
diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json
index c00c08f..df495eb 100644
--- a/migrations/meta/_journal.json
+++ b/migrations/meta/_journal.json
@@ -8,6 +8,13 @@
"when": 1713726520358,
"tag": "0000_outstanding_wolf_cub",
"breakpoints": true
+ },
+ {
+ "idx": 1,
+ "version": "5",
+ "when": 1720316159179,
+ "tag": "0001_misty_silver_centurion",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/preview.png b/preview.png
index be57c44..eb55059 100644
Binary files a/preview.png and b/preview.png differ
diff --git a/src/db/constants.ts b/src/db/constants.ts
index 9764d28..324476b 100644
--- a/src/db/constants.ts
+++ b/src/db/constants.ts
@@ -19,6 +19,7 @@ export const HIGHLIGHTS_LIBRARY_COLUMNS = [
'ZFUTUREPROOFING5',
'ZANNOTATIONREPRESENTATIVETEXT',
'ZANNOTATIONSELECTEDTEXT',
+ 'ZANNOTATIONLOCATION',
'ZANNOTATIONNOTE',
'ZANNOTATIONCREATIONDATE',
'ZANNOTATIONMODIFICATIONDATE',
diff --git a/src/db/schemas.ts b/src/db/schemas.ts
index 49596e8..a800810 100644
--- a/src/db/schemas.ts
+++ b/src/db/schemas.ts
@@ -17,6 +17,7 @@ export const annotations = sqliteTable(HIGHLIGHTS_LIBRARY_NAME, {
ZFUTUREPROOFING5: text('ZFUTUREPROOFING5'),
ZANNOTATIONREPRESENTATIVETEXT: text('ZANNOTATIONREPRESENTATIVETEXT'),
ZANNOTATIONSELECTEDTEXT: text('ZANNOTATIONSELECTEDTEXT').notNull(),
+ ZANNOTATIONLOCATION: text('ZANNOTATIONLOCATION'),
ZANNOTATIONNOTE: text('ZANNOTATIONNOTE'),
ZANNOTATIONCREATIONDATE: integer('ZANNOTATIONCREATIONDATE'),
ZANNOTATIONMODIFICATIONDATE: integer('ZANNOTATIONMODIFICATIONDATE'),
diff --git a/src/db/seedData.ts b/src/db/seedData.ts
index 90d3085..1fa3bda 100644
--- a/src/db/seedData.ts
+++ b/src/db/seedData.ts
@@ -35,9 +35,10 @@ export const defaultBooks = [{
export const defaultAnnotations = [{
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE1",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the iPhone User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the iPhone User Guide",
- "ZANNOTATIONNOTE": "Test note for the hightlight from the iPhone User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the iPhone User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the iPhone User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-iphone-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the highlight from the iPhone User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -45,9 +46,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE2",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the iPad User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the iPad User Guide",
- "ZANNOTATIONNOTE": "Test note for the hightlight from the iPad User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the iPad User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the iPad User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-ipad-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the highlight from the iPad User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -55,9 +57,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE3",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the Mac User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the Mac User Guide",
- "ZANNOTATIONNOTE": "Test note for the hightlight from the Mac User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the Mac User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the Mac User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-mac-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the highlight from the Mac User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -65,9 +68,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE4",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the Apple Watch User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the Apple Watch User Guide",
- "ZANNOTATIONNOTE": "Test note for the hightlight from the Apple Watch User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the Apple Watch User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the Apple Watch User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-apple-watch-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the highlight from the Apple Watch User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -75,9 +79,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE1",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the iPhone User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the iPhone User Guide",
- "ZANNOTATIONNOTE": "Test note for the deleted hightlight from the iPhone User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the iPhone User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the iPhone User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-iphone-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the deleted highlight from the iPhone User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -85,9 +90,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE2",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the iPad User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the iPad User Guide",
- "ZANNOTATIONNOTE": "Test note for the deleted hightlight from the iPad User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the iPad User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the iPad User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-ipad-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the deleted highlight from the iPad User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -95,9 +101,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE3",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the Mac User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the Mac User Guide",
- "ZANNOTATIONNOTE": "Test note for the deleted hightlight from the Mac User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the Mac User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the Mac User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-mac-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the deleted highlight from the Mac User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
@@ -105,9 +112,10 @@ export const defaultAnnotations = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE4",
"ZFUTUREPROOFING5": "Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the hightlight from the Apple Watch User Guide",
- "ZANNOTATIONSELECTEDTEXT": "hightlight from the Apple Watch User Guide",
- "ZANNOTATIONNOTE": "Test note for the deleted hightlight from the Apple Watch User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the highlight from the Apple Watch User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "highlight from the Apple Watch User Guide",
+ "ZANNOTATIONLOCATION": "test-highlight-link-from-the-apple-watch-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the deleted highlight from the Apple Watch User Guide",
"ZANNOTATIONCREATIONDATE": 685151385.91602,
"ZANNOTATIONMODIFICATIONDATE": 685151385.91602,
"ZANNOTATIONSTYLE": 3,
diff --git a/src/methods/aggregateDetails.ts b/src/methods/aggregateDetails.ts
index bc584e8..6cab3fa 100644
--- a/src/methods/aggregateDetails.ts
+++ b/src/methods/aggregateDetails.ts
@@ -30,9 +30,10 @@ export const aggregateBookAndHighlightDetails = async (): Promise {
return stringWithNewLines.test(textBlock) ? textBlock.replace(stringWithNewLines, '\n') : textBlock;
}
+
+// Handler of all new line characters (\n) at the end of text blocks to prevent new lines appearing at the end of text blocks
+const removeAllLastNewlines = (textBlock: string): string => {
+ const stringAllLastNewLines = /\n+$/;
+
+ return stringAllLastNewLines.test(textBlock) ? textBlock.replace(stringAllLastNewLines, "") : textBlock;
+}
diff --git a/src/methods/renderHighlightsTemplate.ts b/src/methods/renderHighlightsTemplate.ts
index a8ea572..161a971 100644
--- a/src/methods/renderHighlightsTemplate.ts
+++ b/src/methods/renderHighlightsTemplate.ts
@@ -1,5 +1,6 @@
import * as Handlebars from 'handlebars';
import { ICombinedBooksAndHighlights } from '../types';
+import 'src/utils/helpers'
export const renderHighlightsTemplate = async (highlight: ICombinedBooksAndHighlights, template: string) => {
const compiledTemplate = Handlebars.compile(template);
const renderedTemplate = compiledTemplate(highlight);
diff --git a/src/settings.ts b/src/settings.ts
index 5527959..a508f1d 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -43,7 +43,7 @@ export class IBookHighlightsSettingTab extends PluginSettingTab {
new Setting(containerEl)
.setName('Import highlights on start')
- .setDesc('Import all hightlights from all your books when Obsidian starts')
+ .setDesc('Import all highlights from all your books when Obsidian starts')
.addToggle((toggle) => {
toggle.setValue(this.plugin.settings.importOnStart)
.onChange(async (value) => {
diff --git a/src/template.ts b/src/template.ts
index 91df0b6..0c22e39 100644
--- a/src/template.ts
+++ b/src/template.ts
@@ -13,6 +13,7 @@ Number of annotations:: {{annotations.length}}
- 🔖 Context:: {{#if contextualText}}{{{contextualText}}}{{else}}N/A{{/if}}
- 🎯 Highlight:: {{{highlight}}}
- 📝 Note:: {{#if note}}{{{note}}}{{else}}N/A{{/if}}
+- 📙 Highlight Link:: {{#if highlightLocation}}[Apple Books Highlight Link](ibooks://assetid/{{../bookId}}#{{highlightLocation}}){{else}}N/A{{/if}}
{{/each}}
`;
diff --git a/src/types.ts b/src/types.ts
index 08f8d8c..b071311 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -13,6 +13,7 @@ export interface IBookAnnotation {
ZFUTUREPROOFING5: string;
ZANNOTATIONREPRESENTATIVETEXT: string;
ZANNOTATIONSELECTEDTEXT: string;
+ ZANNOTATIONLOCATION: string;
ZANNOTATIONNOTE: string;
ZANNOTATIONCREATIONDATE: number;
ZANNOTATIONMODIFICATIONDATE: number;
@@ -23,6 +24,7 @@ export interface IHighlight {
chapter: string;
contextualText: string;
highlight: string;
+ highlightLocation: string;
note: string;
}
export interface ICombinedBooksAndHighlights {
diff --git a/template-colors.png b/template-colors.png
index bf9bace..e4c1d9c 100644
Binary files a/template-colors.png and b/template-colors.png differ
diff --git a/test/db.spec.ts b/test/db.spec.ts
index 289117b..6e9d18d 100644
--- a/test/db.spec.ts
+++ b/test/db.spec.ts
@@ -60,8 +60,21 @@ describe('Database operations', () => {
const highlights = await annotationsRequest(dbPath, `SELECT * FROM ${HIGHLIGHTS_LIBRARY_NAME} WHERE ZANNOTATIONDELETED = 0`);
expect(highlights.length).toEqual(4);
- expect(highlights[0].ZANNOTATIONNOTE).toEqual('Test note for the hightlight from the iPhone User Guide');
- expect(highlights[3].ZANNOTATIONREPRESENTATIVETEXT).toEqual('This is a contextual text for the hightlight from the Apple Watch User Guide');
+ expect(highlights[0].ZANNOTATIONNOTE).toEqual('Test note for the highlight from the iPhone User Guide');
+ expect(highlights[3].ZANNOTATIONREPRESENTATIVETEXT).toEqual('This is a contextual text for the highlight from the Apple Watch User Guide');
+ });
+
+ test('Should return a highlight link for each highlight when highlights library is not empty', async () => {
+ await seedDatabase(annotations, defaultAnnotations);
+
+ const dbPath = path.join(process.cwd(), TEST_DATABASE_PATH);
+ const highlights = await annotationsRequest(dbPath, `SELECT * FROM ${HIGHLIGHTS_LIBRARY_NAME} WHERE ZANNOTATIONDELETED = 0`);
+
+ expect(highlights.length).toEqual(4);
+ expect(highlights[0].ZANNOTATIONLOCATION).toEqual('test-highlight-link-from-the-iphone-user-guide');
+ expect(highlights[1].ZANNOTATIONLOCATION).toEqual('test-highlight-link-from-the-ipad-user-guide');
+ expect(highlights[2].ZANNOTATIONLOCATION).toEqual('test-highlight-link-from-the-mac-user-guide');
+ expect(highlights[3].ZANNOTATIONLOCATION).toEqual('test-highlight-link-from-the-apple-watch-user-guide');
});
});
@@ -87,9 +100,10 @@ describe('Database load testing', () => {
threeThousandsAnnotations.push({
ZANNOTATIONASSETID: `THBFYNJKTGFTTVCGSAE${i}`,
ZFUTUREPROOFING5: `Introduction ${j}`,
- ZANNOTATIONREPRESENTATIVETEXT: `This is a contextual text for the hightlight from the Book ${i}`,
- ZANNOTATIONSELECTEDTEXT: `hightlight from the Book ${i}`,
- ZANNOTATIONNOTE: `Test note for the hightlight from the Book ${i}`,
+ ZANNOTATIONREPRESENTATIVETEXT: `This is a contextual text for the highlight from the Book ${i}`,
+ ZANNOTATIONSELECTEDTEXT: `highlight from the Book ${i}`,
+ ZANNOTATIONLOCATION: `test-highlight-link-from-the-book-${i}`,
+ ZANNOTATIONNOTE: `Test note for the highlight from the Book ${i}`,
ZANNOTATIONCREATIONDATE: 685151385.91602,
ZANNOTATIONMODIFICATIONDATE: 685151385.91602,
ZANNOTATIONSTYLE: 3,
@@ -110,6 +124,9 @@ describe('Database load testing', () => {
expect(dbBooks.length).toEqual(1000);
expect(dbAnnotations.length).toEqual(3000);
+ const dbAnnotationLocations = dbAnnotations.filter(({ZANNOTATIONLOCATION}) => ZANNOTATIONLOCATION !== null && ZANNOTATIONLOCATION !== undefined);
+ expect(dbAnnotationLocations.length).toEqual(3000);
+
expect(endTime - startTime).toBeLessThan(500);
});
});
diff --git a/test/mocks/aggregatedDetailsData.ts b/test/mocks/aggregatedDetailsData.ts
index 8459df7..e652dae 100644
--- a/test/mocks/aggregatedDetailsData.ts
+++ b/test/mocks/aggregatedDetailsData.ts
@@ -11,9 +11,10 @@ export const booksToAggregate = [{
export const annotationsToAggregate = [{
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE5",
"ZFUTUREPROOFING5": "Aggregated Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide",
- "ZANNOTATIONSELECTEDTEXT": "aggregated hightlight from the Apple iPhone User Guide",
- "ZANNOTATIONNOTE": "Test note for the aggregated hightlight from the Apple iPhone User Guide",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the aggregated highlight from the Apple iPhone User Guide",
+ "ZANNOTATIONSELECTEDTEXT": "aggregated highlight from the Apple iPhone User Guide",
+ "ZANNOTATIONLOCATION": "aggregated-highlight-link-from-the-apple-iphone-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the aggregated highlight from the Apple iPhone User Guide",
"ZANNOTATIONCREATIONDATE": 731876693.002279,
"ZANNOTATIONMODIFICATIONDATE": 731876693.002279,
"ZANNOTATIONSTYLE": 3,
@@ -21,9 +22,10 @@ export const annotationsToAggregate = [{
}, {
"ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE5",
"ZFUTUREPROOFING5": "Another aggregated Introduction",
- "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation",
- "ZANNOTATIONSELECTEDTEXT": "aggregated hightlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation",
- "ZANNOTATIONNOTE": "Test note for the aggregated hightlight from the Apple iPhone User Guide\n\nalong with a new line to test the preservation of indentation",
+ "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the aggregated highlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation",
+ "ZANNOTATIONSELECTEDTEXT": "aggregated highlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation",
+ "ZANNOTATIONLOCATION": "aggregated-highlight-link-from-the-apple-iphone-user-guide",
+ "ZANNOTATIONNOTE": "Test note for the aggregated highlight from the Apple iPhone User Guide\n\nalong with a new line to test the preservation of indentation",
"ZANNOTATIONCREATIONDATE": 731876693.002279,
"ZANNOTATIONMODIFICATIONDATE": 731876693.002279,
"ZANNOTATIONSTYLE": 3,
@@ -40,17 +42,19 @@ export const aggregatedHighlights = [{
"bookCoverUrl": '',
"annotations": [{
"chapter": "Aggregated Introduction",
- "contextualText": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide",
- "highlight": "aggregated hightlight from the Apple iPhone User Guide",
- "note": "Test note for the aggregated hightlight from the Apple iPhone User Guide",
+ "contextualText": "This is a contextual text for the aggregated highlight from the Apple iPhone User Guide",
+ "highlight": "aggregated highlight from the Apple iPhone User Guide",
+ "note": "Test note for the aggregated highlight from the Apple iPhone User Guide",
+ "highlightLocation": "aggregated-highlight-link-from-the-apple-iphone-user-guide",
"highlightStyle": 3,
"highlightCreationDate": 731876693.002279,
"highlightModificationDate": 731876693.002279
}, {
"chapter": "Another aggregated Introduction",
- "contextualText": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide\ncontaining a new line to test the preservation of indentation",
- "highlight": "aggregated hightlight from the Apple iPhone User Guide\ncontaining a new line to test the preservation of indentation",
- "note": "Test note for the aggregated hightlight from the Apple iPhone User Guide\nalong with a new line to test the preservation of indentation",
+ "contextualText": "This is a contextual text for the aggregated highlight from the Apple iPhone User Guide\ncontaining a new line to test the preservation of indentation",
+ "highlight": "aggregated highlight from the Apple iPhone User Guide\ncontaining a new line to test the preservation of indentation",
+ "note": "Test note for the aggregated highlight from the Apple iPhone User Guide\nalong with a new line to test the preservation of indentation",
+ "highlightLocation": "aggregated-highlight-link-from-the-apple-iphone-user-guide",
"highlightStyle": 3,
"highlightCreationDate": 731876693.002279,
"highlightModificationDate": 731876693.002279
diff --git a/test/mocks/rawTemplates.ts b/test/mocks/rawTemplates.ts
index 4884507..bec0a86 100644
--- a/test/mocks/rawTemplates.ts
+++ b/test/mocks/rawTemplates.ts
@@ -24,6 +24,7 @@ Number of annotations:: {{annotations.length}}
{{else if (eq highlightStyle "5")}}- 🎯 Highlight:: {{{highlight}}}
{{/if}}
- 📝 Note:: {{#if note}}{{{note}}}{{else}}N/A{{/if}}
+- 📙 Highlight Link:: {{#if highlightLocation}}[Apple Books Highlight Link](ibooks://assetid/{{../bookId}}#{{highlightLocation}}){{else}}N/A{{/if}}
- 📅 Highlight taken on:: {{dateFormat highlightCreationDate "YYYY-MM-DD hh:mm:ss A Z"}}
- 📅 Highlight modified on:: {{dateFormat highlightModificationDate "YYYY-MM-DD hh:mm:ss A Z"}}
diff --git a/test/mocks/renderedTemplate.ts b/test/mocks/renderedTemplate.ts
index 2d0622b..239b317 100644
--- a/test/mocks/renderedTemplate.ts
+++ b/test/mocks/renderedTemplate.ts
@@ -9,19 +9,21 @@ Number of annotations:: 2
----
- 📖 Chapter:: Aggregated Introduction
-- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
-- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
-- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+- 🔖 Context:: This is a contextual text for the aggregated highlight from the Apple iPhone User Guide
+- 🎯 Highlight:: aggregated highlight from the Apple iPhone User Guide
+- 📝 Note:: Test note for the aggregated highlight from the Apple iPhone User Guide
+- 📙 Highlight Link:: [Apple Books Highlight Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5#aggregated-highlight-link-from-the-apple-iphone-user-guide)
----
- 📖 Chapter:: Another aggregated Introduction
-- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
+- 🔖 Context:: This is a contextual text for the aggregated highlight from the Apple iPhone User Guide
containing a new line to test the preservation of indentation
-- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
+- 🎯 Highlight:: aggregated highlight from the Apple iPhone User Guide
containing a new line to test the preservation of indentation
-- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+- 📝 Note:: Test note for the aggregated highlight from the Apple iPhone User Guide
along with a new line to test the preservation of indentation
+- 📙 Highlight Link:: [Apple Books Highlight Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5#aggregated-highlight-link-from-the-apple-iphone-user-guide)
`;
@@ -41,21 +43,23 @@ Number of annotations:: 2
----
- 📖 Chapter:: Aggregated Introduction
-- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
-- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
-- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+- 🔖 Context:: This is a contextual text for the aggregated highlight from the Apple iPhone User Guide
+- 🎯 Highlight:: aggregated highlight from the Apple iPhone User Guide
+- 📝 Note:: Test note for the aggregated highlight from the Apple iPhone User Guide
+- 📙 Highlight Link:: [Apple Books Highlight Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5#aggregated-highlight-link-from-the-apple-iphone-user-guide)
- 📅 Highlight taken on:: 2024-03-11 03:04:53 PM -04:00
- 📅 Highlight modified on:: 2024-03-11 03:04:53 PM -04:00
----
- 📖 Chapter:: Another aggregated Introduction
-- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
+- 🔖 Context:: This is a contextual text for the aggregated highlight from the Apple iPhone User Guide
containing a new line to test the preservation of indentation
-- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
+- 🎯 Highlight:: aggregated highlight from the Apple iPhone User Guide
containing a new line to test the preservation of indentation
-- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+- 📝 Note:: Test note for the aggregated highlight from the Apple iPhone User Guide
along with a new line to test the preservation of indentation
+- 📙 Highlight Link:: [Apple Books Highlight Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5#aggregated-highlight-link-from-the-apple-iphone-user-guide)
- 📅 Highlight taken on:: 2024-03-11 03:04:53 PM -04:00
- 📅 Highlight modified on:: 2024-03-11 03:04:53 PM -04:00
diff --git a/test/pluginDocs.spec.ts b/test/pluginDocs.spec.ts
index 293845f..338a1e6 100644
--- a/test/pluginDocs.spec.ts
+++ b/test/pluginDocs.spec.ts
@@ -23,6 +23,7 @@ describe('Plugin documentation', () => {
expect(readme).toContain('{{{contextualText}}}');
expect(readme).toContain('{{{highlight}}}');
expect(readme).toContain('{{{note}}}');
+ expect(readme).toContain('{{{highlightLocation}}}');
expect(readme).toContain('{{highlightStyle}}');
expect(readme).toContain('{{highlightCreationDate}}');
expect(readme).toContain('{{highlightModificationDate}}');
diff --git a/test/pluginInfo.spec.ts b/test/pluginInfo.spec.ts
index f2c8ae4..4d3a781 100644
--- a/test/pluginInfo.spec.ts
+++ b/test/pluginInfo.spec.ts
@@ -78,6 +78,7 @@ describe('Plugin constants', () => {
'ZFUTUREPROOFING5',
'ZANNOTATIONREPRESENTATIVETEXT',
'ZANNOTATIONSELECTEDTEXT',
+ 'ZANNOTATIONLOCATION',
'ZANNOTATIONNOTE',
'ZANNOTATIONCREATIONDATE',
'ZANNOTATIONMODIFICATIONDATE',
diff --git a/tsconfig.json b/tsconfig.json
index b904126..7d5e245 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -13,6 +13,7 @@
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
+ "skipLibCheck": true,
"lib": [
"DOM",
"ES5",
@@ -21,6 +22,9 @@
]
},
"include": [
- "**/*.ts"
+ "src/**/*",
+ ],
+ "exclude": [
+ "node_modules"
]
}