@d-i-t-a/reader 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -48061,16 +48061,29 @@ var Popup = class {
48061
48061
  absolute = absolute.substring(0, absolute.indexOf("#"));
48062
48062
  event.preventDefault();
48063
48063
  event.stopPropagation();
48064
- await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
48065
- const parser = new DOMParser();
48066
- const doc = parser.parseFromString(data, "text/html");
48067
- const element = doc.querySelector("#" + id2);
48068
- if (element) {
48069
- event.preventDefault();
48070
- event.stopPropagation();
48071
- this.showPopup(element, event);
48072
- }
48073
- });
48064
+ if (this.navigator.api?.getContent) {
48065
+ await this.navigator.api?.getContent(href).then((content) => {
48066
+ const parser = new DOMParser();
48067
+ const doc = parser.parseFromString(content, "text/html");
48068
+ const element = doc.querySelector("#" + id2);
48069
+ if (element) {
48070
+ event.preventDefault();
48071
+ event.stopPropagation();
48072
+ this.showPopup(element, event);
48073
+ }
48074
+ });
48075
+ } else {
48076
+ await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
48077
+ const parser = new DOMParser();
48078
+ const doc = parser.parseFromString(data, "text/html");
48079
+ const element = doc.querySelector("#" + id2);
48080
+ if (element) {
48081
+ event.preventDefault();
48082
+ event.stopPropagation();
48083
+ this.showPopup(element, event);
48084
+ }
48085
+ });
48086
+ }
48074
48087
  }
48075
48088
  }
48076
48089
  }
@@ -48111,13 +48124,23 @@ var Popup = class {
48111
48124
  const d2content = document.createElement("div");
48112
48125
  d2content.className = "d2-popover-content";
48113
48126
  d2wrapper.appendChild(d2content);
48114
- await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
48115
- d2content.innerHTML = data;
48116
- let doc = this.navigator.iframes[0].contentDocument;
48117
- if (doc) {
48118
- doc.body.appendChild(d2popover);
48119
- }
48120
- });
48127
+ if (this.navigator.api?.getContent) {
48128
+ await this.navigator.api?.getContent(href).then((content) => {
48129
+ d2content.innerHTML = content;
48130
+ let doc = this.navigator.iframes[0].contentDocument;
48131
+ if (doc) {
48132
+ doc.body.appendChild(d2popover);
48133
+ }
48134
+ });
48135
+ } else {
48136
+ await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
48137
+ d2content.innerHTML = data;
48138
+ let doc = this.navigator.iframes[0].contentDocument;
48139
+ if (doc) {
48140
+ doc.body.appendChild(d2popover);
48141
+ }
48142
+ });
48143
+ }
48121
48144
  let win = this.navigator.iframes[0].contentWindow;
48122
48145
  if (!win) {
48123
48146
  return;
@@ -58910,16 +58933,14 @@ var HistoryModule = class {
58910
58933
  let lastInHistory;
58911
58934
  if (history && this.annotator) {
58912
58935
  let lastReadingPosition = await this.annotator.getLastReadingPosition();
58913
- if (lastReadingPosition && lastReadingPosition?.locations.progression && lastReadingPosition?.locations.progression > 0) {
58936
+ if (lastReadingPosition) {
58937
+ const linkHref = this.publication.getAbsoluteHref(lastReadingPosition.href);
58938
+ lastReadingPosition.href = linkHref;
58914
58939
  if (this.historyCurrentIndex < this.history.length - 1) {
58915
58940
  this.history = this.history.slice(0, this.historyCurrentIndex);
58916
- }
58917
- lastInHistory = this.history[this.history.length - 1];
58918
- if (lastInHistory && lastInHistory.href !== lastReadingPosition.href || lastInHistory === void 0) {
58919
- const linkHref = this.publication.getAbsoluteHref(lastReadingPosition.href);
58920
- import_loglevel21.default.log(lastReadingPosition.href);
58921
- import_loglevel21.default.log(linkHref);
58922
- lastReadingPosition.href = linkHref;
58941
+ this.history.push(lastReadingPosition);
58942
+ this.historyCurrentIndex = this.history.length - 1;
58943
+ } else if (lastReadingPosition?.locations.progression && lastReadingPosition?.locations.progression > 0) {
58923
58944
  this.history.push(lastReadingPosition);
58924
58945
  this.historyCurrentIndex = this.history.length - 1;
58925
58946
  }