@prose-reader/enhancer-gallery 1.201.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.
@@ -0,0 +1,8 @@
1
+ import { Reader, SpineItem } from '@prose-reader/core';
2
+ import { Observable } from 'rxjs';
3
+ export declare class Snapshot extends Observable<HTMLElement> {
4
+ constructor(reader: Reader, item: SpineItem, options: {
5
+ height: number;
6
+ width: number;
7
+ });
8
+ }
@@ -0,0 +1,4 @@
1
+ import { Reader } from '@prose-reader/core';
2
+ import { GalleryEnhancerAPI } from './types';
3
+ export type { GalleryEnhancerAPI };
4
+ export declare const galleryEnhancer: <InheritOptions, InheritOutput extends Reader>(next: (options: InheritOptions) => InheritOutput) => (options: InheritOptions) => InheritOutput & GalleryEnhancerAPI;
package/dist/index.js ADDED
@@ -0,0 +1,132 @@
1
+ import { DocumentRenderer as E } from "@prose-reader/core";
2
+ import { Observable as S, filter as C, first as A, switchMap as D, of as x, tap as I } from "rxjs";
3
+ function L(l) {
4
+ const s = l.cloneNode(!0), n = l.querySelectorAll("iframe"), c = s.querySelectorAll("iframe");
5
+ n.forEach((t, r) => {
6
+ var y;
7
+ const e = c[r];
8
+ if (!e) return;
9
+ const o = () => {
10
+ try {
11
+ if (!t.contentDocument || !e.contentDocument) {
12
+ console.warn(
13
+ "Cannot access iframe content document - possible cross-origin restriction"
14
+ );
15
+ return;
16
+ }
17
+ t.contentDocument.querySelectorAll(
18
+ 'link[rel="stylesheet"], style'
19
+ ).forEach((u) => {
20
+ var a;
21
+ const m = u.cloneNode(!0);
22
+ (a = e.contentDocument) == null || a.head.appendChild(m);
23
+ });
24
+ } catch (h) {
25
+ console.error("Error copying iframe styles:", h);
26
+ }
27
+ }, d = () => {
28
+ o(), e.removeEventListener("load", d);
29
+ };
30
+ e.addEventListener("load", d), ((y = t.contentDocument) == null ? void 0 : y.readyState) === "complete" && o();
31
+ });
32
+ const p = l.querySelectorAll("canvas"), v = s.querySelectorAll("canvas");
33
+ return p.forEach((t, r) => {
34
+ if (r < v.length) {
35
+ const e = v[r];
36
+ try {
37
+ e.width = t.width, e.height = t.height;
38
+ const o = e.getContext("2d");
39
+ o && o.drawImage(t, 0, 0);
40
+ } catch (o) {
41
+ console.warn(
42
+ "Could not copy canvas content - possible tainted canvas or cross-origin issue",
43
+ o
44
+ );
45
+ }
46
+ }
47
+ }), n.forEach((t, r) => {
48
+ var y;
49
+ const e = c[r];
50
+ if (!e) return;
51
+ const o = () => {
52
+ try {
53
+ if (!t.contentDocument || !e.contentDocument)
54
+ return;
55
+ const h = t.contentDocument.querySelectorAll("canvas"), u = e.contentDocument.querySelectorAll("canvas");
56
+ h.forEach((m, a) => {
57
+ if (a < u.length) {
58
+ const i = u[a];
59
+ try {
60
+ i.width = m.width, i.height = m.height;
61
+ const f = i.getContext("2d");
62
+ f && f.drawImage(m, 0, 0);
63
+ } catch (f) {
64
+ console.warn("Could not copy iframe canvas content", f);
65
+ }
66
+ }
67
+ });
68
+ } catch (h) {
69
+ console.error("Error copying iframe canvases:", h);
70
+ }
71
+ }, d = () => {
72
+ o(), e.removeEventListener("load", d);
73
+ };
74
+ e.addEventListener("load", d), ((y = t.contentDocument) == null ? void 0 : y.readyState) === "complete" && o();
75
+ }), s;
76
+ }
77
+ const N = (l) => {
78
+ const s = document.createElement("div");
79
+ s.style.width = `${l.width}px`, s.style.height = `${l.height}px`, s.style.position = "relative";
80
+ const n = document.createElement("div");
81
+ n.style.width = "100%", n.style.height = "100%", n.style.position = "relative", n.style.overflow = "hidden";
82
+ const c = document.createElement("div");
83
+ return c.style.width = "100%", c.style.height = "100%", c.style.position = "absolute", c.style.top = "0", c.style.left = "0", c.style.overflow = "hidden", n.appendChild(c), n;
84
+ };
85
+ class R extends S {
86
+ constructor(s, n, c) {
87
+ super((p) => {
88
+ const v = N(c);
89
+ return n.isReady$.pipe(
90
+ C((t) => t),
91
+ A(),
92
+ D(() => {
93
+ const t = s.viewport.value.pageSize, r = v, e = r == null ? void 0 : r.children[0];
94
+ if (!r || !e)
95
+ throw new Error("No item element or content mask");
96
+ e.style.top = "0", e.style.left = "0";
97
+ const o = c, { height: d, width: y } = n.layout.layoutInfo, h = n.numberOfPages, u = o.width / y * h, m = o.height / d, a = Math.min(u, m), i = L(n.element);
98
+ Array.from(i.children).forEach((g) => {
99
+ g.classList.contains(E.DOCUMENT_CONTAINER_CLASS_NAME) || g.remove();
100
+ }), i.style.left = "0", i.style.top = "0", i.style.position = "relative";
101
+ const f = t.width * a, w = t.height * a;
102
+ if (e.style.width = `${t.width}px`, e.style.height = `${t.height}px`, e.style.transformOrigin = "0 0", e.style.transform = `scale(${a})`, f < o.width) {
103
+ const g = (o.width - f) / 2;
104
+ e.style.left = `${g}px`;
105
+ }
106
+ if (w < o.height) {
107
+ const g = (o.height - w) / 2;
108
+ e.style.top = `${g}px`;
109
+ }
110
+ return e.innerHTML = "", e.appendChild(i), x(v);
111
+ }),
112
+ I((t) => {
113
+ p.next(t), p.complete();
114
+ })
115
+ ).subscribe();
116
+ });
117
+ }
118
+ }
119
+ const b = (l) => (s) => {
120
+ const n = l(s);
121
+ return {
122
+ ...n,
123
+ __PROSE_READER_ENHANCER_GALLERY: !0,
124
+ gallery: {
125
+ snapshot: (c, p) => new R(n, c, p)
126
+ }
127
+ };
128
+ };
129
+ export {
130
+ b as galleryEnhancer
131
+ };
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/utils/deepCloneElement.ts","../src/Snapshot.ts","../src/index.ts"],"sourcesContent":["export function deepCloneElement(sourceElement: HTMLElement) {\n // Create a deep clone of the source element\n const clone = sourceElement.cloneNode(true) as HTMLElement\n\n // Find all iframes in the original element\n const originalIframes = sourceElement.querySelectorAll(\"iframe\")\n // Find all iframes in the cloned element\n const clonedIframes = clone.querySelectorAll(\"iframe\")\n\n // Process each iframe\n originalIframes.forEach((originalIframe, index) => {\n const clonedIframe = clonedIframes[index]\n\n if (!clonedIframe) return\n\n const copyStyles = () => {\n try {\n // Check for cross-origin restrictions\n if (!originalIframe.contentDocument || !clonedIframe.contentDocument) {\n console.warn(\n \"Cannot access iframe content document - possible cross-origin restriction\",\n )\n return\n }\n\n // Copy all stylesheets from original iframe to cloned iframe\n const originalStylesheets =\n originalIframe.contentDocument.querySelectorAll(\n 'link[rel=\"stylesheet\"], style',\n )\n\n originalStylesheets.forEach((stylesheet) => {\n const stylesheetClone = stylesheet.cloneNode(true)\n clonedIframe.contentDocument?.head.appendChild(stylesheetClone)\n })\n } catch (e) {\n console.error(\"Error copying iframe styles:\", e)\n }\n }\n\n // Store reference to the handler so we can remove it later\n const loadHandler = () => {\n copyStyles()\n // Remove the event listener after it's been called to prevent memory leaks\n clonedIframe.removeEventListener(\"load\", loadHandler)\n }\n\n // Add load event listener to the cloned iframe\n clonedIframe.addEventListener(\"load\", loadHandler)\n\n // If the original iframe is already loaded, trigger the handler\n if (originalIframe.contentDocument?.readyState === \"complete\") {\n copyStyles()\n }\n })\n\n // Handle canvases in the main document\n const originalCanvases = sourceElement.querySelectorAll(\"canvas\")\n const clonedCanvases = clone.querySelectorAll(\"canvas\")\n\n originalCanvases.forEach((originalCanvas, index) => {\n if (index < clonedCanvases.length) {\n const clonedCanvas = clonedCanvases[index] as HTMLCanvasElement\n\n try {\n // Copy canvas dimensions\n clonedCanvas.width = originalCanvas.width\n clonedCanvas.height = originalCanvas.height\n\n // Copy canvas content\n const context = clonedCanvas.getContext(\"2d\")\n if (context) {\n context.drawImage(originalCanvas, 0, 0)\n }\n } catch (e) {\n console.warn(\n \"Could not copy canvas content - possible tainted canvas or cross-origin issue\",\n e,\n )\n }\n }\n })\n\n // Also handle canvases inside iframes\n originalIframes.forEach((originalIframe, index) => {\n const clonedIframe = clonedIframes[index]\n\n if (!clonedIframe) return\n\n const copyCanvases = () => {\n try {\n if (!originalIframe.contentDocument || !clonedIframe.contentDocument) {\n return\n }\n\n const originalCanvasesInIframe =\n originalIframe.contentDocument.querySelectorAll(\"canvas\")\n const clonedCanvasesInIframe =\n clonedIframe.contentDocument.querySelectorAll(\"canvas\")\n\n originalCanvasesInIframe.forEach((originalCanvas, canvasIndex) => {\n if (canvasIndex < clonedCanvasesInIframe.length) {\n const clonedCanvas = clonedCanvasesInIframe[\n canvasIndex\n ] as HTMLCanvasElement\n\n try {\n // Copy canvas dimensions\n clonedCanvas.width = originalCanvas.width\n clonedCanvas.height = originalCanvas.height\n\n // Copy canvas content\n const context = clonedCanvas.getContext(\"2d\")\n if (context) {\n context.drawImage(originalCanvas, 0, 0)\n }\n } catch (canvasError) {\n console.warn(\"Could not copy iframe canvas content\", canvasError)\n }\n }\n })\n } catch (e) {\n console.error(\"Error copying iframe canvases:\", e)\n }\n }\n\n // Store reference to the handler so we can remove it later\n const canvasLoadHandler = () => {\n copyCanvases()\n // Remove the event listener after it's been called to prevent memory leaks\n clonedIframe.removeEventListener(\"load\", canvasLoadHandler)\n }\n\n // Add load event listener to copy canvases after iframe loads\n clonedIframe.addEventListener(\"load\", canvasLoadHandler)\n\n // If the original iframe is already loaded, trigger the handler\n if (originalIframe.contentDocument?.readyState === \"complete\") {\n copyCanvases()\n }\n })\n\n return clone\n}\n","import { DocumentRenderer, type Reader, type SpineItem } from \"@prose-reader/core\"\nimport { Observable, filter, first, of, switchMap, tap } from \"rxjs\"\nimport { deepCloneElement } from \"./utils/deepCloneElement\"\n\nconst createGridItem = (options: {\n height: number\n width: number\n}) => {\n const gridItemElement = document.createElement(\"div\")\n gridItemElement.style.width = `${options.width}px`\n gridItemElement.style.height = `${options.height}px`\n gridItemElement.style.position = \"relative\"\n\n const spineItemContainerElement = document.createElement(\"div\")\n spineItemContainerElement.style.width = `100%`\n spineItemContainerElement.style.height = `100%`\n spineItemContainerElement.style.position = \"relative\"\n spineItemContainerElement.style.overflow = \"hidden\"\n\n const contentMask = document.createElement(\"div\")\n\n contentMask.style.width = \"100%\"\n contentMask.style.height = \"100%\"\n contentMask.style.position = \"absolute\"\n contentMask.style.top = \"0\"\n contentMask.style.left = \"0\"\n contentMask.style.overflow = \"hidden\"\n\n spineItemContainerElement.appendChild(contentMask)\n // gridItemElement.appendChild(spineItemContainerElement)\n\n return spineItemContainerElement\n}\n\nexport class Snapshot extends Observable<HTMLElement> {\n constructor(\n reader: Reader,\n item: SpineItem,\n options: {\n height: number\n width: number\n },\n ) {\n super((subscriber) => {\n const gridItem = createGridItem(options)\n\n return item.isReady$\n .pipe(\n filter((isReady) => isReady),\n first(),\n switchMap(() => {\n const pageSize = reader.viewport.value.pageSize\n const itemElement = gridItem\n const contentMask = itemElement?.children[0] as\n | HTMLElement\n | undefined\n\n if (!itemElement || !contentMask)\n throw new Error(\"No item element or content mask\")\n\n // mask reset\n contentMask.style.top = \"0\"\n contentMask.style.left = \"0\"\n\n // itemElement.style.aspectRatio = `${pageSize.width / pageSize.height}`\n\n const measure = options\n const { height, width } = item.layout.layoutInfo\n const numberOfPages = item.numberOfPages\n const widthScaleFullFrame = (measure.width / width) * numberOfPages\n const heightScale = measure.height / height\n\n // Use the minimum scale to ensure the element fits within both dimensions\n const scale = Math.min(widthScaleFullFrame, heightScale)\n\n const clonedElement = deepCloneElement(item.element)\n\n // cleanup unwanted elements from the spine\n Array.from(clonedElement.children).forEach((child) => {\n if (!child.classList.contains(DocumentRenderer.DOCUMENT_CONTAINER_CLASS_NAME)) {\n child.remove()\n }\n })\n\n clonedElement.style.left = \"0\"\n clonedElement.style.top = \"0\"\n clonedElement.style.position = \"relative\"\n // clonedElement.style.transformOrigin = \"0 0\"\n // clonedElement.style.transform = `scale(${scale})`\n\n /**\n * Now we adjust the mask to make it fit in the center and cover\n * only the required part of the spine item (hidding) the overflowing\n * pages for example.\n */\n const pageWidthAfterScale = pageSize.width * scale\n const pageHeightAfterScale = pageSize.height * scale\n\n // contentMask.style.width = `${pageWidthAfterScale}px`\n contentMask.style.width = `${pageSize.width}px`\n // contentMask.style.height = `${pageHeightAfterScale}px`\n contentMask.style.height = `${pageSize.height}px`\n contentMask.style.transformOrigin = \"0 0\"\n contentMask.style.transform = `scale(${scale})`\n\n if (pageWidthAfterScale < measure.width) {\n const gap = (measure.width - pageWidthAfterScale) / 2\n\n contentMask.style.left = `${gap}px`\n }\n\n if (pageHeightAfterScale < measure.height) {\n const gap = (measure.height - pageHeightAfterScale) / 2\n\n contentMask.style.top = `${gap}px`\n }\n\n contentMask.innerHTML = \"\"\n contentMask.appendChild(clonedElement)\n\n return of(gridItem)\n }),\n tap((gridItem) => {\n subscriber.next(gridItem)\n subscriber.complete()\n }),\n )\n .subscribe()\n })\n }\n}\n","import type { Reader } from \"@prose-reader/core\"\nimport type { GalleryEnhancerAPI } from \"./types\"\nimport { Snapshot } from \"./Snapshot\"\n\nexport type { GalleryEnhancerAPI }\n\nexport const galleryEnhancer =\n <InheritOptions, InheritOutput extends Reader>(\n next: (options: InheritOptions) => InheritOutput,\n ) =>\n (options: InheritOptions): InheritOutput & GalleryEnhancerAPI => {\n const reader = next(options)\n\n return {\n ...reader,\n __PROSE_READER_ENHANCER_GALLERY: true,\n gallery: {\n snapshot: (spineItem, options) =>\n new Snapshot(reader, spineItem, options),\n },\n }\n }\n"],"names":["deepCloneElement","sourceElement","clone","originalIframes","clonedIframes","originalIframe","index","clonedIframe","copyStyles","stylesheet","stylesheetClone","_a","e","loadHandler","originalCanvases","clonedCanvases","originalCanvas","clonedCanvas","context","copyCanvases","originalCanvasesInIframe","clonedCanvasesInIframe","canvasIndex","canvasError","canvasLoadHandler","createGridItem","options","gridItemElement","spineItemContainerElement","contentMask","Snapshot","Observable","reader","item","subscriber","gridItem","filter","isReady","first","switchMap","pageSize","itemElement","measure","height","width","numberOfPages","widthScaleFullFrame","heightScale","scale","clonedElement","child","DocumentRenderer","pageWidthAfterScale","pageHeightAfterScale","gap","of","tap","galleryEnhancer","next","spineItem"],"mappings":";;AAAO,SAASA,EAAiBC,GAA4B;AAErD,QAAAC,IAAQD,EAAc,UAAU,EAAI,GAGpCE,IAAkBF,EAAc,iBAAiB,QAAQ,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AAM,MAAM,KAC1BA,EAAc,MAAM,WAAW;AASzB,gBAAAG,IAAsBZ,EAAS,QAAQQ,GACvCK,IAAuBb,EAAS,SAASQ;AAS3C,cANJnB,EAAY,MAAM,QAAQ,GAAGW,EAAS,KAAK,MAE3CX,EAAY,MAAM,SAAS,GAAGW,EAAS,MAAM,MAC7CX,EAAY,MAAM,kBAAkB,OACxBA,EAAA,MAAM,YAAY,SAASmB,CAAK,KAExCI,IAAsBV,EAAQ,OAAO;AACjC,kBAAAY,KAAOZ,EAAQ,QAAQU,KAAuB;AAExC,YAAAvB,EAAA,MAAM,OAAO,GAAGyB,CAAG;AAAA,UAAA;AAG7B,cAAAD,IAAuBX,EAAQ,QAAQ;AACnC,kBAAAY,KAAOZ,EAAQ,SAASW,KAAwB;AAE1C,YAAAxB,EAAA,MAAM,MAAM,GAAGyB,CAAG;AAAA,UAAA;AAGhC,iBAAAzB,EAAY,YAAY,IACxBA,EAAY,YAAYoB,CAAa,GAE9BM,EAAGpB,CAAQ;AAAA,QAAA,CACnB;AAAA,QACDqB,EAAI,CAACrB,MAAa;AAChB,UAAAD,EAAW,KAAKC,CAAQ,GACxBD,EAAW,SAAS;AAAA,QACrB,CAAA;AAAA,QAEF,UAAU;AAAA,IAAA,CACd;AAAA,EAAA;AAEL;AC5HO,MAAMuB,IACX,CACEC,MAEF,CAAChC,MAAgE;AACzD,QAAAM,IAAS0B,EAAKhC,CAAO;AAEpB,SAAA;AAAA,IACL,GAAGM;AAAA,IACH,iCAAiC;AAAA,IACjC,SAAS;AAAA,MACP,UAAU,CAAC2B,GAAWjC,MACpB,IAAII,EAASE,GAAQ2B,GAAWjC,CAAO;AAAA,IAAA;AAAA,EAE7C;AACF;"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@prose-reader/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@prose-reader/core","rxjs"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d["prose-reader-enhancer-gallery"]={},d.core,d.rxjs))})(this,function(d,w,m){"use strict";function A(l){const r=l.cloneNode(!0),n=l.querySelectorAll("iframe"),c=r.querySelectorAll("iframe");n.forEach((t,s)=>{var f;const e=c[s];if(!e)return;const o=()=>{try{if(!t.contentDocument||!e.contentDocument){console.warn("Cannot access iframe content document - possible cross-origin restriction");return}t.contentDocument.querySelectorAll('link[rel="stylesheet"], style').forEach(v=>{var a;const u=v.cloneNode(!0);(a=e.contentDocument)==null||a.head.appendChild(u)})}catch(h){console.error("Error copying iframe styles:",h)}},y=()=>{o(),e.removeEventListener("load",y)};e.addEventListener("load",y),((f=t.contentDocument)==null?void 0:f.readyState)==="complete"&&o()});const g=l.querySelectorAll("canvas"),S=r.querySelectorAll("canvas");return g.forEach((t,s)=>{if(s<S.length){const e=S[s];try{e.width=t.width,e.height=t.height;const o=e.getContext("2d");o&&o.drawImage(t,0,0)}catch(o){console.warn("Could not copy canvas content - possible tainted canvas or cross-origin issue",o)}}}),n.forEach((t,s)=>{var f;const e=c[s];if(!e)return;const o=()=>{try{if(!t.contentDocument||!e.contentDocument)return;const h=t.contentDocument.querySelectorAll("canvas"),v=e.contentDocument.querySelectorAll("canvas");h.forEach((u,a)=>{if(a<v.length){const i=v[a];try{i.width=u.width,i.height=u.height;const p=i.getContext("2d");p&&p.drawImage(u,0,0)}catch(p){console.warn("Could not copy iframe canvas content",p)}}})}catch(h){console.error("Error copying iframe canvases:",h)}},y=()=>{o(),e.removeEventListener("load",y)};e.addEventListener("load",y),((f=t.contentDocument)==null?void 0:f.readyState)==="complete"&&o()}),r}const D=l=>{const r=document.createElement("div");r.style.width=`${l.width}px`,r.style.height=`${l.height}px`,r.style.position="relative";const n=document.createElement("div");n.style.width="100%",n.style.height="100%",n.style.position="relative",n.style.overflow="hidden";const c=document.createElement("div");return c.style.width="100%",c.style.height="100%",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.overflow="hidden",n.appendChild(c),n};class I extends m.Observable{constructor(r,n,c){super(g=>{const S=D(c);return n.isReady$.pipe(m.filter(t=>t),m.first(),m.switchMap(()=>{const t=r.viewport.value.pageSize,s=S,e=s==null?void 0:s.children[0];if(!s||!e)throw new Error("No item element or content mask");e.style.top="0",e.style.left="0";const o=c,{height:y,width:f}=n.layout.layoutInfo,h=n.numberOfPages,v=o.width/f*h,u=o.height/y,a=Math.min(v,u),i=A(n.element);Array.from(i.children).forEach(E=>{E.classList.contains(w.DocumentRenderer.DOCUMENT_CONTAINER_CLASS_NAME)||E.remove()}),i.style.left="0",i.style.top="0",i.style.position="relative";const p=t.width*a,C=t.height*a;if(e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.transformOrigin="0 0",e.style.transform=`scale(${a})`,p<o.width){const E=(o.width-p)/2;e.style.left=`${E}px`}if(C<o.height){const E=(o.height-C)/2;e.style.top=`${E}px`}return e.innerHTML="",e.appendChild(i),m.of(S)}),m.tap(t=>{g.next(t),g.complete()})).subscribe()})}}const x=l=>r=>{const n=l(r);return{...n,__PROSE_READER_ENHANCER_GALLERY:!0,gallery:{snapshot:(c,g)=>new I(n,c,g)}}};d.galleryEnhancer=x,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
2
+ //# sourceMappingURL=index.umd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.cjs","sources":["../src/utils/deepCloneElement.ts","../src/Snapshot.ts","../src/index.ts"],"sourcesContent":["export function deepCloneElement(sourceElement: HTMLElement) {\n // Create a deep clone of the source element\n const clone = sourceElement.cloneNode(true) as HTMLElement\n\n // Find all iframes in the original element\n const originalIframes = sourceElement.querySelectorAll(\"iframe\")\n // Find all iframes in the cloned element\n const clonedIframes = clone.querySelectorAll(\"iframe\")\n\n // Process each iframe\n originalIframes.forEach((originalIframe, index) => {\n const clonedIframe = clonedIframes[index]\n\n if (!clonedIframe) return\n\n const copyStyles = () => {\n try {\n // Check for cross-origin restrictions\n if (!originalIframe.contentDocument || !clonedIframe.contentDocument) {\n console.warn(\n \"Cannot access iframe content document - possible cross-origin restriction\",\n )\n return\n }\n\n // Copy all stylesheets from original iframe to cloned iframe\n const originalStylesheets =\n originalIframe.contentDocument.querySelectorAll(\n 'link[rel=\"stylesheet\"], style',\n )\n\n originalStylesheets.forEach((stylesheet) => {\n const stylesheetClone = stylesheet.cloneNode(true)\n clonedIframe.contentDocument?.head.appendChild(stylesheetClone)\n })\n } catch (e) {\n console.error(\"Error copying iframe styles:\", e)\n }\n }\n\n // Store reference to the handler so we can remove it later\n const loadHandler = () => {\n copyStyles()\n // Remove the event listener after it's been called to prevent memory leaks\n clonedIframe.removeEventListener(\"load\", loadHandler)\n }\n\n // Add load event listener to the cloned iframe\n clonedIframe.addEventListener(\"load\", loadHandler)\n\n // If the original iframe is already loaded, trigger the handler\n if (originalIframe.contentDocument?.readyState === \"complete\") {\n copyStyles()\n }\n })\n\n // Handle canvases in the main document\n const originalCanvases = sourceElement.querySelectorAll(\"canvas\")\n const clonedCanvases = clone.querySelectorAll(\"canvas\")\n\n originalCanvases.forEach((originalCanvas, index) => {\n if (index < clonedCanvases.length) {\n const clonedCanvas = clonedCanvases[index] as HTMLCanvasElement\n\n try {\n // Copy canvas dimensions\n clonedCanvas.width = originalCanvas.width\n clonedCanvas.height = originalCanvas.height\n\n // Copy canvas content\n const context = clonedCanvas.getContext(\"2d\")\n if (context) {\n context.drawImage(originalCanvas, 0, 0)\n }\n } catch (e) {\n console.warn(\n \"Could not copy canvas content - possible tainted canvas or cross-origin issue\",\n e,\n )\n }\n }\n })\n\n // Also handle canvases inside iframes\n originalIframes.forEach((originalIframe, index) => {\n const clonedIframe = clonedIframes[index]\n\n if (!clonedIframe) return\n\n const copyCanvases = () => {\n try {\n if (!originalIframe.contentDocument || !clonedIframe.contentDocument) {\n return\n }\n\n const originalCanvasesInIframe =\n originalIframe.contentDocument.querySelectorAll(\"canvas\")\n const clonedCanvasesInIframe =\n clonedIframe.contentDocument.querySelectorAll(\"canvas\")\n\n originalCanvasesInIframe.forEach((originalCanvas, canvasIndex) => {\n if (canvasIndex < clonedCanvasesInIframe.length) {\n const clonedCanvas = clonedCanvasesInIframe[\n canvasIndex\n ] as HTMLCanvasElement\n\n try {\n // Copy canvas dimensions\n clonedCanvas.width = originalCanvas.width\n clonedCanvas.height = originalCanvas.height\n\n // Copy canvas content\n const context = clonedCanvas.getContext(\"2d\")\n if (context) {\n context.drawImage(originalCanvas, 0, 0)\n }\n } catch (canvasError) {\n console.warn(\"Could not copy iframe canvas content\", canvasError)\n }\n }\n })\n } catch (e) {\n console.error(\"Error copying iframe canvases:\", e)\n }\n }\n\n // Store reference to the handler so we can remove it later\n const canvasLoadHandler = () => {\n copyCanvases()\n // Remove the event listener after it's been called to prevent memory leaks\n clonedIframe.removeEventListener(\"load\", canvasLoadHandler)\n }\n\n // Add load event listener to copy canvases after iframe loads\n clonedIframe.addEventListener(\"load\", canvasLoadHandler)\n\n // If the original iframe is already loaded, trigger the handler\n if (originalIframe.contentDocument?.readyState === \"complete\") {\n copyCanvases()\n }\n })\n\n return clone\n}\n","import { DocumentRenderer, type Reader, type SpineItem } from \"@prose-reader/core\"\nimport { Observable, filter, first, of, switchMap, tap } from \"rxjs\"\nimport { deepCloneElement } from \"./utils/deepCloneElement\"\n\nconst createGridItem = (options: {\n height: number\n width: number\n}) => {\n const gridItemElement = document.createElement(\"div\")\n gridItemElement.style.width = `${options.width}px`\n gridItemElement.style.height = `${options.height}px`\n gridItemElement.style.position = \"relative\"\n\n const spineItemContainerElement = document.createElement(\"div\")\n spineItemContainerElement.style.width = `100%`\n spineItemContainerElement.style.height = `100%`\n spineItemContainerElement.style.position = \"relative\"\n spineItemContainerElement.style.overflow = \"hidden\"\n\n const contentMask = document.createElement(\"div\")\n\n contentMask.style.width = \"100%\"\n contentMask.style.height = \"100%\"\n contentMask.style.position = \"absolute\"\n contentMask.style.top = \"0\"\n contentMask.style.left = \"0\"\n contentMask.style.overflow = \"hidden\"\n\n spineItemContainerElement.appendChild(contentMask)\n // gridItemElement.appendChild(spineItemContainerElement)\n\n return spineItemContainerElement\n}\n\nexport class Snapshot extends Observable<HTMLElement> {\n constructor(\n reader: Reader,\n item: SpineItem,\n options: {\n height: number\n width: number\n },\n ) {\n super((subscriber) => {\n const gridItem = createGridItem(options)\n\n return item.isReady$\n .pipe(\n filter((isReady) => isReady),\n first(),\n switchMap(() => {\n const pageSize = reader.viewport.value.pageSize\n const itemElement = gridItem\n const contentMask = itemElement?.children[0] as\n | HTMLElement\n | undefined\n\n if (!itemElement || !contentMask)\n throw new Error(\"No item element or content mask\")\n\n // mask reset\n contentMask.style.top = \"0\"\n contentMask.style.left = \"0\"\n\n // itemElement.style.aspectRatio = `${pageSize.width / pageSize.height}`\n\n const measure = options\n const { height, width } = item.layout.layoutInfo\n const numberOfPages = item.numberOfPages\n const widthScaleFullFrame = (measure.width / width) * numberOfPages\n const heightScale = measure.height / height\n\n // Use the minimum scale to ensure the element fits within both dimensions\n const scale = Math.min(widthScaleFullFrame, heightScale)\n\n const clonedElement = deepCloneElement(item.element)\n\n // cleanup unwanted elements from the spine\n Array.from(clonedElement.children).forEach((child) => {\n if (!child.classList.contains(DocumentRenderer.DOCUMENT_CONTAINER_CLASS_NAME)) {\n child.remove()\n }\n })\n\n clonedElement.style.left = \"0\"\n clonedElement.style.top = \"0\"\n clonedElement.style.position = \"relative\"\n // clonedElement.style.transformOrigin = \"0 0\"\n // clonedElement.style.transform = `scale(${scale})`\n\n /**\n * Now we adjust the mask to make it fit in the center and cover\n * only the required part of the spine item (hidding) the overflowing\n * pages for example.\n */\n const pageWidthAfterScale = pageSize.width * scale\n const pageHeightAfterScale = pageSize.height * scale\n\n // contentMask.style.width = `${pageWidthAfterScale}px`\n contentMask.style.width = `${pageSize.width}px`\n // contentMask.style.height = `${pageHeightAfterScale}px`\n contentMask.style.height = `${pageSize.height}px`\n contentMask.style.transformOrigin = \"0 0\"\n contentMask.style.transform = `scale(${scale})`\n\n if (pageWidthAfterScale < measure.width) {\n const gap = (measure.width - pageWidthAfterScale) / 2\n\n contentMask.style.left = `${gap}px`\n }\n\n if (pageHeightAfterScale < measure.height) {\n const gap = (measure.height - pageHeightAfterScale) / 2\n\n contentMask.style.top = `${gap}px`\n }\n\n contentMask.innerHTML = \"\"\n contentMask.appendChild(clonedElement)\n\n return of(gridItem)\n }),\n tap((gridItem) => {\n subscriber.next(gridItem)\n subscriber.complete()\n }),\n )\n .subscribe()\n })\n }\n}\n","import type { Reader } from \"@prose-reader/core\"\nimport type { GalleryEnhancerAPI } from \"./types\"\nimport { Snapshot } from \"./Snapshot\"\n\nexport type { GalleryEnhancerAPI }\n\nexport const galleryEnhancer =\n <InheritOptions, InheritOutput extends Reader>(\n next: (options: InheritOptions) => InheritOutput,\n ) =>\n (options: InheritOptions): InheritOutput & GalleryEnhancerAPI => {\n const reader = next(options)\n\n return {\n ...reader,\n __PROSE_READER_ENHANCER_GALLERY: true,\n gallery: {\n snapshot: (spineItem, options) =>\n new Snapshot(reader, spineItem, options),\n },\n }\n }\n"],"names":["deepCloneElement","sourceElement","clone","originalIframes","clonedIframes","originalIframe","index","clonedIframe","copyStyles","stylesheet","stylesheetClone","_a","e","loadHandler","originalCanvases","clonedCanvases","originalCanvas","clonedCanvas","context","copyCanvases","originalCanvasesInIframe","clonedCanvasesInIframe","canvasIndex","canvasError","canvasLoadHandler","createGridItem","options","gridItemElement","spineItemContainerElement","contentMask","Snapshot","Observable","reader","item","subscriber","gridItem","filter","isReady","first","switchMap","pageSize","itemElement","measure","height","width","numberOfPages","widthScaleFullFrame","heightScale","scale","clonedElement","child","DocumentRenderer","pageWidthAfterScale","pageHeightAfterScale","gap","of","tap","galleryEnhancer","next","spineItem"],"mappings":"oVAAO,SAASA,EAAiBC,EAA4B,CAErD,MAAAC,EAAQD,EAAc,UAAU,EAAI,EAGpCE,EAAkBF,EAAc,iBAAiB,QAAQ,EAEzDG,EAAgBF,EAAM,iBAAiB,QAAQ,EAGrCC,EAAA,QAAQ,CA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,IAAA,CAG7B,GAAAD,EAAuBX,EAAQ,OAAQ,CACnC,MAAAY,GAAOZ,EAAQ,OAASW,GAAwB,EAE1CxB,EAAA,MAAM,IAAM,GAAGyB,CAAG,IAAA,CAGhC,OAAAzB,EAAY,UAAY,GACxBA,EAAY,YAAYoB,CAAa,EAE9BM,EAAAA,GAAGpB,CAAQ,CAAA,CACnB,EACDqB,EAAA,IAAKrB,GAAa,CAChBD,EAAW,KAAKC,CAAQ,EACxBD,EAAW,SAAS,CACrB,CAAA,GAEF,UAAU,CAAA,CACd,CAAA,CAEL,CC5HO,MAAMuB,EAETC,GAEDhC,GAAgE,CACzD,MAAAM,EAAS0B,EAAKhC,CAAO,EAEpB,MAAA,CACL,GAAGM,EACH,gCAAiC,GACjC,QAAS,CACP,SAAU,CAAC2B,EAAWjC,IACpB,IAAII,EAASE,EAAQ2B,EAAWjC,CAAO,CAAA,CAE7C,CACF"}
@@ -0,0 +1,11 @@
1
+ import { SpineItem } from '@prose-reader/core';
2
+ import { Observable } from 'rxjs';
3
+ export type GalleryEnhancerAPI = {
4
+ readonly __PROSE_READER_ENHANCER_GALLERY: boolean;
5
+ gallery: {
6
+ snapshot: (spineItem: SpineItem, options: {
7
+ height: number;
8
+ width: number;
9
+ }) => Observable<HTMLElement>;
10
+ };
11
+ };
@@ -0,0 +1 @@
1
+ export declare function deepCloneElement(sourceElement: HTMLElement): HTMLElement;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@prose-reader/enhancer-gallery",
3
+ "version": "1.201.0",
4
+ "type": "module",
5
+ "main": "./dist/index.umd.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.umd.cjs"
12
+ }
13
+ },
14
+ "files": ["/dist"],
15
+ "scripts": {
16
+ "start": "vite build --watch --mode development",
17
+ "build": "tsc && vite build",
18
+ "test": "vitest run --coverage"
19
+ },
20
+ "dependencies": {
21
+ "@prose-reader/core": "^1.201.0"
22
+ },
23
+ "peerDependencies": {
24
+ "rxjs": "*"
25
+ },
26
+ "devDependencies": {
27
+ "rxjs": "*"
28
+ }
29
+ }