diff --git a/package-lock.json b/package-lock.json index e373ab6c..e8e1ad2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@d-i-t-a/reader", - "version": "2.1.9", + "version": "2.1.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@d-i-t-a/reader", - "version": "2.1.9", + "version": "2.1.10", "license": "Apache-2.0", "dependencies": { "@types/sass": "^1.43.1", diff --git a/package.json b/package.json index de6f2b72..83e0449b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "2.1.9", + "version": "2.1.10", "description": "A viewer application for EPUB files.", "repository": "https://github.com/d-i-t-a/R2D2BC", "license": "Apache-2.0", diff --git a/src/modules/history/HistoryModule.ts b/src/modules/history/HistoryModule.ts index 887cadd2..963fbc90 100644 --- a/src/modules/history/HistoryModule.ts +++ b/src/modules/history/HistoryModule.ts @@ -49,8 +49,8 @@ export class HistoryModule implements ReaderModule { private historyForwardAnchorElement: HTMLAnchorElement; private historyBackAnchorElement: HTMLAnchorElement; - private historyCurrentIndex: number; - private history: Array = []; + historyCurrentIndex: number; + history: Array = []; private constructor( annotator: Annotator, @@ -200,7 +200,13 @@ export class HistoryModule implements ReaderModule { ); } - private async handleHistoryForwardClick(event: MouseEvent) { + async handleHistoryForwardClick(event: MouseEvent) { + await this.historyForward(); + event.preventDefault(); + event.stopPropagation(); + } + + async historyForward() { if (this.history.length > 0) { if (this.historyCurrentIndex + 1 < this.history.length) { this.historyCurrentIndex = this.historyCurrentIndex + 1; @@ -210,11 +216,15 @@ export class HistoryModule implements ReaderModule { ); } } + } + + private async handleHistoryBackClick(event: MouseEvent) { + await this.historyBack(); event.preventDefault(); event.stopPropagation(); } - private async handleHistoryBackClick(event: MouseEvent) { + async historyBack() { if (this.history.length > 0) { if (this.historyCurrentIndex > 0) { this.historyCurrentIndex = this.historyCurrentIndex - 1; @@ -224,7 +234,5 @@ export class HistoryModule implements ReaderModule { ); } } - event.preventDefault(); - event.stopPropagation(); } } diff --git a/src/reader.ts b/src/reader.ts index 256729b2..7a25fa3b 100644 --- a/src/reader.ts +++ b/src/reader.ts @@ -523,6 +523,23 @@ export default class D2Reader { return this.annotationModule?.getAnnotations(); } + /** History */ + get history() { + return this.historyModule?.history; + } + /** Current index of history */ + get historyCurrentIndex() { + return this.historyModule?.historyCurrentIndex; + } + /** History Back */ + historyBack = async () => { + return this.historyModule?.historyBack(); + }; + /** History Forward */ + historyForward = async () => { + return this.historyModule?.historyForward(); + }; + /** * Search */