@prose-reader/core 1.14.0 → 1.15.0
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/context.d.ts +1 -1
- package/dist/createReaderWithEnhancer.d.ts +5467 -4
- package/dist/enhancers/accessibility.d.ts +5464 -1
- package/dist/enhancers/chrome.d.ts +5464 -1
- package/dist/enhancers/fonts.d.ts +5464 -1
- package/dist/enhancers/hotkeys.d.ts +5464 -1
- package/dist/enhancers/layoutEnhancer/layoutEnhancer.d.ts +5464 -1
- package/dist/enhancers/links.d.ts +5465 -2
- package/dist/enhancers/loadingEnhancer.d.ts +5465 -1
- package/dist/enhancers/media.d.ts +5464 -1
- package/dist/enhancers/navigation.d.ts +5464 -1
- package/dist/enhancers/pagination.d.ts +5464 -2
- package/dist/enhancers/progression.d.ts +5464 -2
- package/dist/enhancers/resources/index.d.ts +5464 -1
- package/dist/enhancers/theme.d.ts +5464 -1
- package/dist/enhancers/types/enhancer.d.ts +5464 -1
- package/dist/enhancers/utils.d.ts +5464 -1
- package/dist/enhancers/webkit.d.ts +5464 -1
- package/dist/enhancers/zoom/index.d.ts +5464 -2
- package/dist/prose.js +17 -11
- package/dist/prose.js.map +1 -1
- package/dist/prose.umd.cjs +17 -11
- package/dist/prose.umd.cjs.map +1 -1
- package/dist/reader.d.ts +5474 -4
- package/dist/types/index.d.ts +0 -1
- package/package.json +5 -3
- package/dist/types/Reader.d.ts +0 -68
package/dist/prose.umd.cjs
CHANGED
|
@@ -2762,28 +2762,34 @@
|
|
|
2762
2762
|
const buildChapterInfoFromSpineItem = (manifest, item) => {
|
|
2763
2763
|
var _a;
|
|
2764
2764
|
const { href } = item;
|
|
2765
|
-
return getChapterInfo(href, ((_a = manifest.nav) == null ? void 0 : _a.toc) ?? []);
|
|
2765
|
+
return getChapterInfo(href, ((_a = manifest.nav) == null ? void 0 : _a.toc) ?? [], manifest);
|
|
2766
2766
|
};
|
|
2767
|
-
const getChapterInfo = (href,
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
const
|
|
2767
|
+
const getChapterInfo = (href, tocItem, manifest) => {
|
|
2768
|
+
const spineItemIndex = manifest.spineItems.findIndex((item) => item.href === href);
|
|
2769
|
+
return tocItem.reduce((acc, tocItem2) => {
|
|
2770
|
+
const indexOfHash = tocItem2.href.indexOf(`#`);
|
|
2771
|
+
const tocItemPathWithoutAnchor = indexOfHash > 0 ? tocItem2.href.substr(0, indexOfHash) : tocItem2.href;
|
|
2771
2772
|
const tocItemHrefWithoutFilename = tocItemPathWithoutAnchor.substring(0, tocItemPathWithoutAnchor.lastIndexOf("/"));
|
|
2772
2773
|
const hrefWithoutFilename = href.substring(0, href.lastIndexOf("/"));
|
|
2773
2774
|
const hrefIsChapterHref = href.endsWith(tocItemPathWithoutAnchor);
|
|
2774
2775
|
const hrefIsWithinChapter = hrefWithoutFilename !== "" && hrefWithoutFilename.endsWith(tocItemHrefWithoutFilename);
|
|
2775
|
-
|
|
2776
|
+
const isPossibleTocItemCandidate = hrefIsChapterHref || hrefIsWithinChapter;
|
|
2777
|
+
if (isPossibleTocItemCandidate) {
|
|
2778
|
+
const spineItemIndexOfPossibleCandidate = manifest.spineItems.findIndex((item) => item.href === tocItem2.href);
|
|
2779
|
+
const spineItemIsBeforeThisTocItem = spineItemIndex < spineItemIndexOfPossibleCandidate;
|
|
2780
|
+
if (spineItemIsBeforeThisTocItem)
|
|
2781
|
+
return acc;
|
|
2776
2782
|
return {
|
|
2777
|
-
title:
|
|
2778
|
-
path:
|
|
2783
|
+
title: tocItem2.title,
|
|
2784
|
+
path: tocItem2.path
|
|
2779
2785
|
};
|
|
2780
2786
|
}
|
|
2781
|
-
const subInfo = getChapterInfo(href,
|
|
2787
|
+
const subInfo = getChapterInfo(href, tocItem2.contents, manifest);
|
|
2782
2788
|
if (subInfo) {
|
|
2783
2789
|
return {
|
|
2784
2790
|
subChapter: subInfo,
|
|
2785
|
-
title:
|
|
2786
|
-
path:
|
|
2791
|
+
title: tocItem2.title,
|
|
2792
|
+
path: tocItem2.path
|
|
2787
2793
|
};
|
|
2788
2794
|
}
|
|
2789
2795
|
return acc;
|