@prose-reader/core 1.202.0 → 1.203.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/index.js
CHANGED
|
@@ -677,6 +677,17 @@ const observeMutation = (target, options) => {
|
|
|
677
677
|
return () => observer.disconnect();
|
|
678
678
|
});
|
|
679
679
|
};
|
|
680
|
+
function observeIntersection(element, options) {
|
|
681
|
+
return new Observable((observer) => {
|
|
682
|
+
const intersectionObserver = new IntersectionObserver((entries) => {
|
|
683
|
+
observer.next(entries);
|
|
684
|
+
}, options);
|
|
685
|
+
intersectionObserver.observe(element);
|
|
686
|
+
return () => {
|
|
687
|
+
intersectionObserver.disconnect();
|
|
688
|
+
};
|
|
689
|
+
});
|
|
690
|
+
}
|
|
680
691
|
class SettingsManagerOverload {
|
|
681
692
|
constructor(initialSettings, settingsManager) {
|
|
682
693
|
this.settingsManager = settingsManager;
|
|
@@ -934,7 +945,7 @@ class DestroyableClass {
|
|
|
934
945
|
this.destroySubject.complete();
|
|
935
946
|
}
|
|
936
947
|
}
|
|
937
|
-
class
|
|
948
|
+
const _DocumentRenderer = class _DocumentRenderer extends DestroyableClass {
|
|
938
949
|
constructor(params) {
|
|
939
950
|
super();
|
|
940
951
|
this.triggerSubject = new Subject();
|
|
@@ -1024,6 +1035,12 @@ class DocumentRenderer extends DestroyableClass {
|
|
|
1024
1035
|
);
|
|
1025
1036
|
merge(unload$).pipe(takeUntil(this.destroy$)).subscribe();
|
|
1026
1037
|
}
|
|
1038
|
+
setDocumentContainer(element) {
|
|
1039
|
+
this._documentContainer = element;
|
|
1040
|
+
this._documentContainer.classList.add(
|
|
1041
|
+
_DocumentRenderer.DOCUMENT_CONTAINER_CLASS_NAME
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1027
1044
|
attach() {
|
|
1028
1045
|
if (this.documentContainer) {
|
|
1029
1046
|
this.containerElement.appendChild(this.documentContainer);
|
|
@@ -1031,8 +1048,8 @@ class DocumentRenderer extends DestroyableClass {
|
|
|
1031
1048
|
}
|
|
1032
1049
|
detach() {
|
|
1033
1050
|
var _a;
|
|
1034
|
-
(_a = this.
|
|
1035
|
-
this.
|
|
1051
|
+
(_a = this._documentContainer) == null ? void 0 : _a.remove();
|
|
1052
|
+
this._documentContainer = void 0;
|
|
1036
1053
|
}
|
|
1037
1054
|
get state$() {
|
|
1038
1055
|
return this.stateSubject;
|
|
@@ -1077,6 +1094,9 @@ class DocumentRenderer extends DestroyableClass {
|
|
|
1077
1094
|
this.stateSubject.complete();
|
|
1078
1095
|
super.destroy();
|
|
1079
1096
|
}
|
|
1097
|
+
get documentContainer() {
|
|
1098
|
+
return this._documentContainer;
|
|
1099
|
+
}
|
|
1080
1100
|
get writingMode() {
|
|
1081
1101
|
return void 0;
|
|
1082
1102
|
}
|
|
@@ -1094,7 +1114,9 @@ class DocumentRenderer extends DestroyableClass {
|
|
|
1094
1114
|
}
|
|
1095
1115
|
return ((_a = this.context.manifest) == null ? void 0 : _a.renditionLayout) ?? "reflowable";
|
|
1096
1116
|
}
|
|
1097
|
-
}
|
|
1117
|
+
};
|
|
1118
|
+
_DocumentRenderer.DOCUMENT_CONTAINER_CLASS_NAME = `prose-reader-document-container`;
|
|
1119
|
+
let DocumentRenderer = _DocumentRenderer;
|
|
1098
1120
|
const defaultGetResource = (item) => new URL(item.href);
|
|
1099
1121
|
class ResourceHandler {
|
|
1100
1122
|
constructor(item, settings) {
|
|
@@ -1887,7 +1909,7 @@ class HtmlRenderer extends DocumentRenderer {
|
|
|
1887
1909
|
}
|
|
1888
1910
|
onCreateDocument() {
|
|
1889
1911
|
const frameElement = createFrameElement();
|
|
1890
|
-
this.
|
|
1912
|
+
this.setDocumentContainer(frameElement);
|
|
1891
1913
|
return of(frameElement);
|
|
1892
1914
|
}
|
|
1893
1915
|
onLoadDocument() {
|
|
@@ -2554,7 +2576,7 @@ class ImageRenderer extends DocumentRenderer {
|
|
|
2554
2576
|
const imgElement = this.containerElement.ownerDocument.createElement(`img`);
|
|
2555
2577
|
return from(this.resourcesHandler.getResource()).pipe(
|
|
2556
2578
|
switchMap((responseOrUrl) => {
|
|
2557
|
-
this.
|
|
2579
|
+
this.setDocumentContainer(imgElement);
|
|
2558
2580
|
imgElement.style.objectFit = `contain`;
|
|
2559
2581
|
imgElement.style.userSelect = `none`;
|
|
2560
2582
|
if (responseOrUrl instanceof URL) {
|
|
@@ -9293,6 +9315,7 @@ export {
|
|
|
9293
9315
|
isHtmlTagElement,
|
|
9294
9316
|
isShallowEqual2 as isShallowEqual,
|
|
9295
9317
|
mapKeysTo,
|
|
9318
|
+
observeIntersection,
|
|
9296
9319
|
observeMutation,
|
|
9297
9320
|
observeResize,
|
|
9298
9321
|
removeCSS,
|