From d057c58c5d1065770990f4b7923672bce6670037 Mon Sep 17 00:00:00 2001 From: Aferdita Muriqi Date: Thu, 2 Apr 2020 15:47:46 -0400 Subject: [PATCH] added last navigated href --- package-lock.json | 2 +- package.json | 2 +- src/index.ts | 7 +++++++ src/modules/TTSModule.ts | 3 +++ src/modules/highlight/TextHighlighter.ts | 3 +++ src/navigator/IFrameNavigator.ts | 5 +++++ viewer/index_api.html | 1 + 7 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9824690..69fe362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9daaaa0..f88b49f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "1.0.7", + "version": "1.0.8", "description": "A viewer application for EPUB files.", "repository": "https://github.com/d-i-t-a/R2D2BC", "main": "src/index.js", diff --git a/src/index.ts b/src/index.ts index 218fc51..8eecc5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -59,6 +59,10 @@ export function currentResource() { if (IS_DEV) { console.log("currentResource") } return R2Navigator.currentResource() } +export function currentTocHref() { + if (IS_DEV) { console.log("currentTocHref") } + return R2Navigator.currentTocHref() +} export function totalResources() { if (IS_DEV) { console.log("totalResources") } return R2Navigator.totalResources() @@ -262,6 +266,9 @@ exports.annotations = function () { exports.currentResource = function() { return currentResource() } +exports.currentTocHref = function() { + return currentTocHref() +} exports.totalResources = function() { return totalResources() } diff --git a/src/modules/TTSModule.ts b/src/modules/TTSModule.ts index 9cb8629..340ef8d 100644 --- a/src/modules/TTSModule.ts +++ b/src/modules/TTSModule.ts @@ -25,6 +25,9 @@ export default class TTSModule implements ReaderModule { initialize() { this.annotationModule.highlighter.ttsDelegate = this } + cancel() { + this.synth.cancel() + } speak(selectionInfo: ISelectionInfo | undefined ): any { console.log(selectionInfo.cleanText) diff --git a/src/modules/highlight/TextHighlighter.ts b/src/modules/highlight/TextHighlighter.ts index 234ae45..4a5eb64 100644 --- a/src/modules/highlight/TextHighlighter.ts +++ b/src/modules/highlight/TextHighlighter.ts @@ -472,6 +472,7 @@ export default class TextHighlighter { toolbox.style.display = "none"; var backdrop = document.getElementById("toolbox-backdrop"); backdrop.style.display = "none"; + self.ttsDelegate.cancel() }, /** @@ -1321,6 +1322,8 @@ export default class TextHighlighter { backdropButton.removeEventListener("click", backdropEvent); backdropButton.removeEventListener("mousedown", backdropEvent); backdropButton.removeEventListener("mouseup", backdropEvent); + + } backdropButton.addEventListener("click", backdropEvent); diff --git a/src/navigator/IFrameNavigator.ts b/src/navigator/IFrameNavigator.ts index f2e9a7b..c58e86e 100644 --- a/src/navigator/IFrameNavigator.ts +++ b/src/navigator/IFrameNavigator.ts @@ -100,6 +100,7 @@ export default class IFrameNavigator implements Navigator { mSidenav: any; currentChapterLink: Link = {}; + currentTOCRawLink: string; private nextChapterLink: Link; private previousChapterLink: Link; private settings: UserSettings; @@ -999,6 +1000,9 @@ export default class IFrameNavigator implements Navigator { totalResources(): number { return this.publication.readingOrder.length } + currentTocHref(): string { + return this.currentTOCRawLink + } currentResource(): number { let currentLocation = this.currentChapterLink.href return this.publication.getSpineIndex(currentLocation) @@ -1320,6 +1324,7 @@ export default class IFrameNavigator implements Navigator { } } this.newPosition = locator; + this.currentTOCRawLink = locator.href if (locator.href.indexOf("#") !== -1) { const newResource = locator.href.slice(0, locator.href.indexOf("#")) diff --git a/viewer/index_api.html b/viewer/index_api.html index 686f9c0..759472a 100644 --- a/viewer/index_api.html +++ b/viewer/index_api.html @@ -36,6 +36,7 @@

+