@d-i-t-a/reader 2.0.0-beta.15 → 2.0.0-beta.18

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
@@ -49069,6 +49069,10 @@ var iconTemplate = (id2, title, path, classAttr = `icon`) => `<svg xmlns="http:/
49069
49069
  <title id="${id2}">${title}</title>
49070
49070
  ${path}
49071
49071
  </svg>`;
49072
+ var iconTemplateWithViewBox = (id2, title, path, viewBox, classAttr = `icon`) => `<svg xmlns="http://www.w3.org/2000/svg" width="${WIDTH_ATTR}" height="${WIDTH_ATTR}" viewBox="${viewBox}" preserveAspectRatio="xMidYMid meet" role="img" class="${classAttr}" aria-labelledBy="${id2}">
49073
+ <title id="${id2}">${title}</title>
49074
+ ${path}
49075
+ </svg>`;
49072
49076
  var iconTemplateColored = (id2, title, path, classAttr = `icon`, size, fill) => `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="${VIEWBOX_ATTR}" style="fill:${fill}" preserveAspectRatio="xMidYMid meet" role="img" class="${classAttr}" aria-labelledBy="${id2}">
49073
49077
  <title id="${id2}">${title}</title>
49074
49078
  ${path}
@@ -49077,7 +49081,7 @@ var icons = {
49077
49081
  error: iconTemplate(`error-icon`, `Warning`, `<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>`),
49078
49082
  home: `<path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z"/>`,
49079
49083
  expand: iconTemplate(`expand-icon`, `Enter fullscreen`, `<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>`, `icon active-icon`),
49080
- loading: iconTemplate(`loading-icon`, `Loading`, `<path d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"/>`),
49084
+ loading: iconTemplateWithViewBox(`loading-icon`, `Loading`, `<path fill="#BBBBBB" d="M145,241.6c-53.3,0-96.6-43.2-96.6-96.6c0-53.3,43.2-96.6,96.6-96.6c53.3,0,96.6,43.2,96.6,96.6 c0,26.7-10.8,50.9-28.3,68.3l7.6,7.6c19.4-19.4,31.5-46.3,31.5-75.9c0-59.3-48-107.3-107.3-107.3S37.7,85.7,37.7,145 c0,59.3,48,107.3,107.3,107.3V241.6z"/>`, "0 0 290 290"),
49081
49085
  next: iconTemplate(`next-icon`, `Next Chapter`, `<path d="M6.49 20.13l1.77 1.77 9.9-9.9-9.9-9.9-1.77 1.77L14.62 12l-8.13 8.13z"/>`),
49082
49086
  previous: iconTemplate(`previous-icon`, `Previous Chapter`, `<path d="M17.51 3.87L15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z"/>`),
49083
49087
  settings: iconTemplate(`settings-icon`, `Settings`, `<path d="M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7.14 1.13zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/>`, `icon open`),
@@ -55643,6 +55647,14 @@ var IFrameNavigator = class extends import_events.default {
55643
55647
  this.nextChapterBottomAnchorElement.style.display = "none";
55644
55648
  if (this.previousChapterTopAnchorElement)
55645
55649
  this.previousChapterTopAnchorElement.style.display = "none";
55650
+ if (this.keyboardEventHandler) {
55651
+ this.keyboardEventHandler.onBackwardSwipe = this.handlePreviousChapterClick.bind(this);
55652
+ this.keyboardEventHandler.onForwardSwipe = this.handleNextChapterClick.bind(this);
55653
+ }
55654
+ if (this.touchEventHandler) {
55655
+ this.touchEventHandler.onBackwardSwipe = this.handlePreviousPageClick.bind(this);
55656
+ this.touchEventHandler.onForwardSwipe = this.handleNextPageClick.bind(this);
55657
+ }
55646
55658
  } else {
55647
55659
  this.settings.isPaginated().then((paginated) => {
55648
55660
  if (paginated) {
@@ -59707,6 +59719,7 @@ init_polyfills();
59707
59719
  var DEFAULT_BACKGROUND_COLOR_OPACITY2 = 0.5;
59708
59720
  var LineFocusModule = class {
59709
59721
  constructor(delegate, properties, highlighter, api) {
59722
+ this.hasEventListener = false;
59710
59723
  this.lines = [];
59711
59724
  this.index = 0;
59712
59725
  this.isActive = false;
@@ -59730,19 +59743,59 @@ var LineFocusModule = class {
59730
59743
  if (IS_DEV) {
59731
59744
  console.log("Definitions module stop");
59732
59745
  }
59746
+ this.hasEventListener = false;
59747
+ removeEventListenerOptional(document, "keydown", this.keydown.bind(this));
59748
+ removeEventListenerOptional(document, "keyup", this.keyup.bind(this));
59749
+ removeEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.keydown.bind(this));
59750
+ removeEventListenerOptional(this.delegate.iframes[0].contentDocument, "keyup", this.keyup.bind(this));
59733
59751
  }
59734
59752
  async start() {
59735
59753
  this.delegate.lineFocusModule = this;
59736
59754
  const wrapper = findRequiredElement(document, "#iframe-wrapper");
59737
59755
  if (wrapper.style.height.length > 0) {
59738
59756
  this.wrapperHeight = wrapper.style.height;
59739
- if (this.lineFocusContainer)
59757
+ if (this.lineFocusContainer && this.lineFocusContainer.style.height.length == 0)
59740
59758
  this.lineFocusContainer.style.height = this.wrapperHeight;
59741
- if (this.readerContainer) {
59759
+ if (this.readerContainer && this.readerContainer.style.height.length == 0) {
59742
59760
  this.readerContainer.style.height = this.wrapperHeight;
59761
+ }
59762
+ if (this.readerContainer) {
59743
59763
  this.readerContainer.style.overflow = "hidden";
59744
59764
  }
59745
59765
  }
59766
+ if (!this.hasEventListener) {
59767
+ this.hasEventListener = true;
59768
+ addEventListenerOptional(document, "keydown", this.keydown.bind(this));
59769
+ addEventListenerOptional(document, "keyup", this.keyup.bind(this));
59770
+ addEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.keydown.bind(this));
59771
+ addEventListenerOptional(this.delegate.iframes[0].contentDocument, "keyup", this.keyup.bind(this));
59772
+ }
59773
+ }
59774
+ keydown(event) {
59775
+ if (event instanceof KeyboardEvent && this.isActive) {
59776
+ const key = event.key;
59777
+ switch (key) {
59778
+ case "ArrowUp":
59779
+ event.stopPropagation();
59780
+ break;
59781
+ case "ArrowDown":
59782
+ event.stopPropagation();
59783
+ break;
59784
+ }
59785
+ }
59786
+ }
59787
+ keyup(event) {
59788
+ if (event instanceof KeyboardEvent && this.isActive) {
59789
+ const key = event.key;
59790
+ switch (key) {
59791
+ case "ArrowUp":
59792
+ this.lineUp();
59793
+ break;
59794
+ case "ArrowDown":
59795
+ this.lineDown();
59796
+ break;
59797
+ }
59798
+ }
59746
59799
  }
59747
59800
  handleResize() {
59748
59801
  if (this.isActive) {
@@ -59750,13 +59803,6 @@ var LineFocusModule = class {
59750
59803
  }
59751
59804
  }
59752
59805
  async enableLineFocus() {
59753
- if (!this.isActive) {
59754
- const wrapper = findRequiredElement(document, "#iframe-wrapper");
59755
- if (wrapper.style.height.length > 0) {
59756
- this.wrapperHeight = wrapper.style.height;
59757
- }
59758
- wrapper.style.height = "100vh";
59759
- }
59760
59806
  this.isActive = true;
59761
59807
  await this.delegate.settings.scroll(true);
59762
59808
  this.lineFocus();
@@ -59766,8 +59812,9 @@ var LineFocusModule = class {
59766
59812
  const wrapper = findRequiredElement(document, "#iframe-wrapper");
59767
59813
  if (this.wrapperHeight) {
59768
59814
  wrapper.style.height = this.wrapperHeight;
59769
- } else if (resetHeight) {
59770
- wrapper.style.removeProperty("height");
59815
+ }
59816
+ if (!resetHeight) {
59817
+ this.index = 0;
59771
59818
  }
59772
59819
  const doc = this.delegate.iframes[0].contentDocument;
59773
59820
  const html = findIframeElement(doc, "html");
@@ -59999,7 +60046,6 @@ var LineFocusModule = class {
59999
60046
  if (this.lineFocusBottomBlinder)
60000
60047
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60001
60048
  }
60002
- current.focus();
60003
60049
  current.scrollIntoView({
60004
60050
  block: "center",
60005
60051
  behavior: "smooth"
@@ -60023,7 +60069,6 @@ var LineFocusModule = class {
60023
60069
  if (this.lineFocusBottomBlinder)
60024
60070
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60025
60071
  }
60026
- current.focus();
60027
60072
  current.scrollIntoView({
60028
60073
  block: "center",
60029
60074
  behavior: "smooth"
@@ -60048,7 +60093,6 @@ var LineFocusModule = class {
60048
60093
  if (this.lineFocusBottomBlinder)
60049
60094
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60050
60095
  }
60051
- current.focus();
60052
60096
  current.scrollIntoView({
60053
60097
  block: "center",
60054
60098
  behavior: "smooth"