@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.js
CHANGED
|
@@ -2760,28 +2760,34 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
2760
2760
|
const buildChapterInfoFromSpineItem = (manifest, item) => {
|
|
2761
2761
|
var _a;
|
|
2762
2762
|
const { href } = item;
|
|
2763
|
-
return getChapterInfo(href, ((_a = manifest.nav) == null ? void 0 : _a.toc) ?? []);
|
|
2763
|
+
return getChapterInfo(href, ((_a = manifest.nav) == null ? void 0 : _a.toc) ?? [], manifest);
|
|
2764
2764
|
};
|
|
2765
|
-
const getChapterInfo = (href,
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
const
|
|
2765
|
+
const getChapterInfo = (href, tocItem, manifest) => {
|
|
2766
|
+
const spineItemIndex = manifest.spineItems.findIndex((item) => item.href === href);
|
|
2767
|
+
return tocItem.reduce((acc, tocItem2) => {
|
|
2768
|
+
const indexOfHash = tocItem2.href.indexOf(`#`);
|
|
2769
|
+
const tocItemPathWithoutAnchor = indexOfHash > 0 ? tocItem2.href.substr(0, indexOfHash) : tocItem2.href;
|
|
2769
2770
|
const tocItemHrefWithoutFilename = tocItemPathWithoutAnchor.substring(0, tocItemPathWithoutAnchor.lastIndexOf("/"));
|
|
2770
2771
|
const hrefWithoutFilename = href.substring(0, href.lastIndexOf("/"));
|
|
2771
2772
|
const hrefIsChapterHref = href.endsWith(tocItemPathWithoutAnchor);
|
|
2772
2773
|
const hrefIsWithinChapter = hrefWithoutFilename !== "" && hrefWithoutFilename.endsWith(tocItemHrefWithoutFilename);
|
|
2773
|
-
|
|
2774
|
+
const isPossibleTocItemCandidate = hrefIsChapterHref || hrefIsWithinChapter;
|
|
2775
|
+
if (isPossibleTocItemCandidate) {
|
|
2776
|
+
const spineItemIndexOfPossibleCandidate = manifest.spineItems.findIndex((item) => item.href === tocItem2.href);
|
|
2777
|
+
const spineItemIsBeforeThisTocItem = spineItemIndex < spineItemIndexOfPossibleCandidate;
|
|
2778
|
+
if (spineItemIsBeforeThisTocItem)
|
|
2779
|
+
return acc;
|
|
2774
2780
|
return {
|
|
2775
|
-
title:
|
|
2776
|
-
path:
|
|
2781
|
+
title: tocItem2.title,
|
|
2782
|
+
path: tocItem2.path
|
|
2777
2783
|
};
|
|
2778
2784
|
}
|
|
2779
|
-
const subInfo = getChapterInfo(href,
|
|
2785
|
+
const subInfo = getChapterInfo(href, tocItem2.contents, manifest);
|
|
2780
2786
|
if (subInfo) {
|
|
2781
2787
|
return {
|
|
2782
2788
|
subChapter: subInfo,
|
|
2783
|
-
title:
|
|
2784
|
-
path:
|
|
2789
|
+
title: tocItem2.title,
|
|
2790
|
+
path: tocItem2.path
|
|
2785
2791
|
};
|
|
2786
2792
|
}
|
|
2787
2793
|
return acc;
|