diff --git a/package-lock.json b/package-lock.json index 7a72770c..fcd6cfbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "1.6.3", + "version": "1.6.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 21d42b33..c990c4da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "1.6.3", + "version": "1.6.4", "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/highlight/TextHighlighter.ts b/src/modules/highlight/TextHighlighter.ts index cbc1aac4..286ceb88 100644 --- a/src/modules/highlight/TextHighlighter.ts +++ b/src/modules/highlight/TextHighlighter.ts @@ -849,9 +849,15 @@ export default class TextHighlighter { underlineIcon.addEventListener("click", commentEvent); } } else { - highlightIcon.style.setProperty('display', "none") - underlineIcon.style.setProperty('display', "none") - colorIcon.style.setProperty('display', "none") + if (highlightIcon) { + highlightIcon.style.setProperty('display', "none") + } + if (underlineIcon) { + underlineIcon.style.setProperty('display', "none") + } + if (colorIcon) { + colorIcon.style.setProperty('display', "none") + } } if (this.delegate.rights.enableTTS) { if (speakIcon) { @@ -862,7 +868,9 @@ export default class TextHighlighter { speakIcon.addEventListener("click", speakEvent); } } else { - speakIcon.style.setProperty('display', "none") + if (speakIcon) { + speakIcon.style.setProperty('display', "none") + } } if (oc(this.config).selectionMenuItems([])) { diff --git a/src/navigator/IFrameNavigator.ts b/src/navigator/IFrameNavigator.ts index 6722f6ba..9e895fac 100644 --- a/src/navigator/IFrameNavigator.ts +++ b/src/navigator/IFrameNavigator.ts @@ -24,7 +24,7 @@ import EventHandler, { addEventListenerOptional, removeEventListenerOptional } f import * as BrowserUtilities from "../utils/BrowserUtilities"; import * as HTMLUtilities from "../utils/HTMLUtilities"; import { defaultUpLinkTemplate, simpleUpLinkTemplate, readerLoading, readerError } from "../utils/HTMLTemplates"; -import { Locator, ReadingPosition, Locations } from "../model/Locator"; +import { Locator, ReadingPosition, Locations, Annotation } from "../model/Locator"; import { Sidenav, Collapsible, Dropdown, Tabs } from "materialize-css"; import { UserSettingsUIConfig, UserSettings } from "../model/user-settings/UserSettings"; import BookmarkModule from "../modules/BookmarkModule"; @@ -885,17 +885,13 @@ export default class IFrameNavigator implements Navigator { this.reflowable.goToPosition(bookViewPosition); }, 200); + let currentLocation = this.currentChapterLink.href setTimeout(() => { if (this.newElementId) { const element = (this.iframe.contentDocument as any).getElementById(this.newElementId); this.reflowable.goToElement(element); this.newElementId = null; } - }, 100); - - let currentLocation = this.currentChapterLink.href - - setTimeout(() => { this.updatePositionInfo(); }, 200); @@ -1623,6 +1619,9 @@ export default class IFrameNavigator implements Navigator { if (this.chapterPosition) this.chapterPosition.innerHTML = ""; if (this.remainingPositions) this.remainingPositions.innerHTML = ""; } + if (this.annotator) { + this.saveCurrentReadingPosition(); + } } private handlePreviousChapterClick(event: MouseEvent): void { @@ -1720,11 +1719,12 @@ export default class IFrameNavigator implements Navigator { console.log("is currently loaded") console.log(locator.href) console.log(this.currentChapterLink.href) - const elementId = locator.href.slice(locator.href.indexOf("#") + 1); - locator.locations = { - fragment: elementId + if (locator.href.indexOf("#") !== -1) { + const elementId = locator.href.slice(locator.href.indexOf("#") + 1); + locator.locations = { + fragment: elementId + } } - this.newPosition = locator; this.currentTOCRawLink = locator.href if (locator.locations.fragment === undefined) { @@ -1738,6 +1738,9 @@ export default class IFrameNavigator implements Navigator { const element = (this.iframe.contentDocument as any).getElementById(this.newElementId); this.reflowable.goToElement(element); this.newElementId = null; + } else { + this.reflowable.goToCssSelector((locator as Annotation).highlight.selectionInfo.rangeInfo.startContainerElementCssSelector) + this.updatePositionInfo() } let currentLocation = this.currentChapterLink.href