@e-llm-studio/citation 0.0.151 → 0.0.153
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/README.md +21 -6
- package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PdfViewer/PdfStyle.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -992,9 +992,9 @@ ScannedDocCitation is a React component for displaying scanned document pages wi
|
|
|
992
992
|
- **Highlight navigation** — Jump between highlights using ↑↓ arrows, auto-scrolls to active highlight
|
|
993
993
|
- **Fullscreen modal** — Expand to a larger view for detailed examination
|
|
994
994
|
- **Customizable highlight colors** — Control highlight color, active color, and border color
|
|
995
|
+
- **Lazy highlight rendering** — Highlights only appear after the image has fully loaded, preventing bounding boxes from showing on blank pages
|
|
995
996
|
|
|
996
997
|
### Usage
|
|
997
|
-
|
|
998
998
|
```tsx
|
|
999
999
|
import ScannedDocCitation from '@e-llm-studio/citation/ScannedDocCitation'
|
|
1000
1000
|
|
|
@@ -1033,9 +1033,9 @@ const BACKEND_CITATIONS = [
|
|
|
1033
1033
|
// Each citation = one page. citation_number is 1-based, pageIndex is 0-based.
|
|
1034
1034
|
const images = BACKEND_CITATIONS.map((c) => c.customMetaData.gs_url)
|
|
1035
1035
|
|
|
1036
|
-
const highlights = BACKEND_CITATIONS.flatMap((c
|
|
1036
|
+
const highlights = BACKEND_CITATIONS.flatMap((c) =>
|
|
1037
1037
|
c.customMetaData.highlighted_coordinates.map((coord) => ({
|
|
1038
|
-
pageIndex,
|
|
1038
|
+
pageIndex: c.customMetaData.citation_number - 1,
|
|
1039
1039
|
bboxes: [coord],
|
|
1040
1040
|
}))
|
|
1041
1041
|
)
|
|
@@ -1058,6 +1058,23 @@ const highlights = BACKEND_CITATIONS.flatMap((c, pageIndex) =>
|
|
|
1058
1058
|
/>
|
|
1059
1059
|
```
|
|
1060
1060
|
|
|
1061
|
+
**Single citation at a time:**
|
|
1062
|
+
|
|
1063
|
+
If rendering one citation at a time with a single image, always use `pageIndex: 0` regardless of `citation_number`.
|
|
1064
|
+
```tsx
|
|
1065
|
+
const images = citation?.customMetaData?.gs_url
|
|
1066
|
+
? [citation.customMetaData.gs_url]
|
|
1067
|
+
: [];
|
|
1068
|
+
|
|
1069
|
+
const highlights =
|
|
1070
|
+
citation?.customMetaData?.highlighted_coordinates?.map((coord) => ({
|
|
1071
|
+
pageIndex: 0, // always 0 since images array has only 1 image
|
|
1072
|
+
bboxes: [coord],
|
|
1073
|
+
})) ?? [];
|
|
1074
|
+
|
|
1075
|
+
return <ScannedDocCitation images={images} highlights={highlights} />;
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1061
1078
|
### Props
|
|
1062
1079
|
|
|
1063
1080
|
| Prop | Type | Required | Default | Description |
|
|
@@ -1067,10 +1084,9 @@ const highlights = BACKEND_CITATIONS.flatMap((c, pageIndex) =>
|
|
|
1067
1084
|
| `highlightColor` | `string` | ❌ | `rgba(255, 220, 0, 0.15)` | Background color of inactive highlights |
|
|
1068
1085
|
| `highlightActiveColor` | `string` | ❌ | `rgba(255, 220, 0, 0.35)` | Background color of the currently active highlight |
|
|
1069
1086
|
| `highlightBorderColor` | `string` | ❌ | `rgba(200, 160, 0, 0.4)` | Border color of the active highlight |
|
|
1070
|
-
| `height` | `string \| number` | ❌ | `"700px"` |
|
|
1087
|
+
| `height` | `string \| number` | ❌ | `"700px"` | Maximum height of the scrollable container. Shrinks to fit content if content is shorter. |
|
|
1071
1088
|
|
|
1072
1089
|
### Type Definitions
|
|
1073
|
-
|
|
1074
1090
|
```typescript
|
|
1075
1091
|
interface BBox {
|
|
1076
1092
|
xmin: number; // normalized 0–1 (provided directly by backend)
|
|
@@ -1096,7 +1112,6 @@ interface ScannedDocCitationProps {
|
|
|
1096
1112
|
|
|
1097
1113
|
> **Note:** Coordinates in `highlighted_coordinates` are already normalized (0–1) by the backend. No pixel conversion needed before passing them to the component.
|
|
1098
1114
|
|
|
1099
|
-
|
|
1100
1115
|
# Other Components
|
|
1101
1116
|
## Bookemon
|
|
1102
1117
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.pdfStyles={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.pdfStyles={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{height:"100%",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center"}};
|
|
2
2
|
//# sourceMappingURL=PdfStyle.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),n=require("./PdfStyle.js"),t=require("../../assests/svg/PdfViewerIcons.js");exports.default=function(l){l.highlightIndex
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),n=require("./PdfStyle.js"),t=require("../../assests/svg/PdfViewerIcons.js");exports.default=function(l){l.highlightIndex;var i=l.totalHighlights,o=l.controls,r=l.currentPosition,a=l.pdfName,c=l.onClose,d=l.pdfUrl,u=l.viewerRef,_=l.customStyles,g=l.customClasses,x=l.customIcons,f=o.ZoomInButton,m=o.ZoomOutButton,p=o.ZoomPopover,h=o.goToPrevious,b=o.goToNext,j=(null==g?void 0:g.actionButton)||"p-1 hover:bg-gray-200 rounded-md transition-colors";return s.jsxs("div",e.__assign({className:(null==g?void 0:g.header)||"flex items-center justify-between mb-3 bg-[#FAFAFA] border-b border-gray-100 rounded-t-xl",style:e.__assign(e.__assign({},n.pdfStyles.header),null==_?void 0:_.header)},{children:[s.jsxs("div",e.__assign({className:"flex items-center gap-3 min-w-0 flex-1"},{children:[s.jsx("div",e.__assign({style:e.__assign(e.__assign({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==_?void 0:_.pdfIconWrapper)},{children:(null==x?void 0:x.pdfIcon)||s.jsx(t.DefaultPdfIcon,{})})),s.jsx("span",e.__assign({className:(null==g?void 0:g.pdfName)||"text-gray-800 text-sm truncate",style:e.__assign({fontWeight:500},null==_?void 0:_.pdfName)},{children:a}))]})),s.jsxs("div",e.__assign({className:"flex items-center gap-4 text-gray-600 flex-shrink-0"},{children:[s.jsxs("div",e.__assign({className:"flex items-center gap-1"},{children:[s.jsx(m,{}),s.jsx("div",e.__assign({className:"text-sm font-medium w-14 text-center"},{children:s.jsx(p,{})})),s.jsx(f,{})]})),!!i&&s.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center"}},{children:[s.jsx("button",e.__assign({style:e.__assign(e.__assign(e.__assign({},n.pdfStyles.button),{color:"#475467"}),0===r||1===r?n.pdfStyles.buttonDisabled:{}),onClick:h,disabled:0===r||1===r},{children:"◀"})),s.jsxs("span",e.__assign({style:n.pdfStyles.counter},{children:[r," / ",i]})),s.jsx("button",e.__assign({style:e.__assign(e.__assign(e.__assign({},n.pdfStyles.button),{color:"#475467"}),r===i?n.pdfStyles.buttonDisabled:{}),onClick:b,disabled:r===i},{children:"▶"}))]})),s.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),s.jsxs("div",e.__assign({className:"flex items-center gap-2"},{children:[s.jsx("button",e.__assign({onClick:function(){var e=null==u?void 0:u.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},className:j,title:"Full Screen"},{children:(null==x?void 0:x.fullScreenIcon)||s.jsx(t.DefaultFullScreenIcon,{})})),d&&s.jsx("a",e.__assign({href:d,target:"_blank",rel:"noopener noreferrer",className:j,title:"Open in new tab"},{children:(null==x?void 0:x.downloadIcon)||s.jsx(t.DefaultDownloadIcon,{})})),c&&s.jsx("button",e.__assign({onClick:c,className:"".concat(j," ml-1"),title:"Close"},{children:(null==x?void 0:x.closeIcon)||s.jsx(t.DefaultCloseIcon,{})}))]}))]}))]}))};
|
|
2
2
|
//# sourceMappingURL=PdfToolbar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),i=require("@react-pdf-viewer/core"),s=require("./PdfContainer.js"),t=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),l=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var n=require("react");exports.default=function(a){var u=a.pdfUrl,c=a.highlightText,d=a.highlightPages,f=a.jumpToPageValue,g=void 0===f?0:f,h=a.pdfName,p=a.onClose,v=a.customStyles,m=a.customClasses,y=a.customIcons,_=l.PdfHighlightControls(c,d),x
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),i=require("@react-pdf-viewer/core"),s=require("./PdfContainer.js"),t=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),l=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var n=require("react");exports.default=function(a){var u=a.pdfUrl,c=a.highlightText,d=a.highlightPages,f=a.jumpToPageValue,g=void 0===f?0:f,h=a.pdfName,p=a.onClose,v=a.customStyles,m=a.customClasses,y=a.customIcons,_=n.useRef(null),x=l.PdfHighlightControls(c,d,_),q=x.highlightIndex,b=x.cursorIndex,w=x.setCursorIndex,j=x.orderedKeys,P=x.totalHighlights,S=x.getValidPosition,C=x.tryJump,I=x.jumpToPage,V=x.zoomTo,A=x.plugins,F=x.controls,T=S(b);if(!u)return r.jsx("div",e.__assign({style:e.__assign(e.__assign({},o.pdfStyles.emptyState),null==v?void 0:v.emptyState)},{children:"PDF is not available for this selection"}));return r.jsxs("div",e.__assign({ref:_,className:(null==m?void 0:m.pdfViewerWrapper)||"",style:e.__assign(e.__assign(e.__assign({},o.pdfStyles.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==v?void 0:v.pdfViewer)},{children:[r.jsx(t.default,{highlightIndex:q,totalHighlights:P,controls:F,currentPosition:T,pdfName:h,onClose:p,pdfUrl:u,viewerRef:_,customStyles:v,customClasses:m,customIcons:y}),r.jsx(s.default,{pdfUrl:u,plugins:A,customStyles:v,onLoad:function(){if(V(i.SpecialZoomLevel.ActualSize),g>0){var e=g-1,r=j[e],s=d[r];w(e),s>0&&I(s-1)}requestAnimationFrame(function(){C(),function(){if(_.current){var e=_.current.querySelector(".rpv-core__viewer");if(e){var r=new MutationObserver(function(){var e,i=null===(e=_.current)||void 0===e?void 0:e.querySelector(".rpv-search__highlight");i&&(i.scrollIntoView({behavior:"smooth",block:"center"}),r.disconnect())});r.observe(e,{childList:!0,subtree:!0})}}}()})}})]}))};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-pdf-viewer/search"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-pdf-viewer/search"),o=require("@react-pdf-viewer/page-navigation"),t=require("@react-pdf-viewer/zoom");exports.PdfHighlightControls=function(n,i,u){var a=e.useState(0),c=a[0],l=a[1],v=e.useRef(!1),s=e.useState(0),g=s[0],f=s[1],p=Object.keys(i).map(Number).sort(function(e,r){return e-r}),d=Object.values(i).filter(function(e){return e>0}).length,h=r.searchPlugin({keyword:n}),m=o.pageNavigationPlugin(),T=t.zoomPlugin(),y=h.jumpToMatch,P=m.jumpToPage,_=T.zoomTo,q=T.ZoomInButton,x=T.ZoomOutButton,j=T.ZoomPopover,B=function(){if(!v.current)try{y(0),v.current=!0}catch(e){requestAnimationFrame(B)}},I=function(e,r){if(u.current&&u.current.querySelector(".rpv-core__viewer")){var o=-1,t=function(){var n,i,a=null===(n=u.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==o)return o=a.scrollTop,void setTimeout(t,100);var c=null===(i=u.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var l=c.querySelectorAll(".rpv-search__highlight")[r];if(l){var v=a.getBoundingClientRect(),s=l.getBoundingClientRect(),g=a.scrollTop+(s.top-v.top)-a.clientHeight/2+s.height/2;a.scrollTo({top:g,behavior:"smooth"})}}}};setTimeout(t,300)}},O=e.useMemo(function(){var e={};return p.forEach(function(r,o){var t=i[r];t>0&&(e[t]||(e[t]=[]),e[t].push(o))}),e},[p,i]),S=function(e){var r=i[p[e]];return(O[r]||[]).indexOf(e)};return{setHighlightIndex:l,highlightIndex:c,cursorIndex:g,setCursorIndex:f,orderedKeys:p,totalHighlights:d,getValidPosition:function(e){for(var r=0,o=0;o<=e;o++){var t=p[o];i[t]>0&&r++}return r},tryJump:B,jumpToPage:P,zoomTo:_,plugins:[h,m,T],controls:{ZoomInButton:q,ZoomOutButton:x,ZoomPopover:j,goToNext:function(){for(var e=g+1;e<p.length;e++){var r=p[e];if(i[r]>0){var o=i[r]-1,t=S(e);return f(e),P(i[r]-1),void I(o,t)}}},goToPrevious:function(){for(var e=g-1;e>=0;e--){var r=p[e];if(i[r]>0){var o=i[r]-1,t=S(e);return f(e),P(i[r]-1),void I(o,t)}}}}}};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"
|
|
1
|
+
var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{height:"100%",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center"}};export{e as pdfStyles};
|
|
2
2
|
//# sourceMappingURL=PdfStyle.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as t,jsx as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,jsx as l}from"react/jsx-runtime";import{pdfStyles as n}from"./PdfStyle.js";import{DefaultPdfIcon as o,DefaultFullScreenIcon as r,DefaultDownloadIcon as i,DefaultCloseIcon as s}from"../../assests/svg/PdfViewerIcons.js";var c=function(c){c.highlightIndex;var d=c.totalHighlights,a=c.controls,u=c.currentPosition,m=c.pdfName,f=c.onClose,h=c.pdfUrl,p=c.viewerRef,b=c.customStyles,g=c.customClasses,v=c.customIcons,x=a.ZoomInButton,y=a.ZoomOutButton,N=a.ZoomPopover,F=a.goToPrevious,I=a.goToNext,w=(null==g?void 0:g.actionButton)||"p-1 hover:bg-gray-200 rounded-md transition-colors";return t("div",e({className:(null==g?void 0:g.header)||"flex items-center justify-between mb-3 bg-[#FAFAFA] border-b border-gray-100 rounded-t-xl",style:e(e({},n.header),null==b?void 0:b.header)},{children:[t("div",e({className:"flex items-center gap-3 min-w-0 flex-1"},{children:[l("div",e({style:e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==b?void 0:b.pdfIconWrapper)},{children:(null==v?void 0:v.pdfIcon)||l(o,{})})),l("span",e({className:(null==g?void 0:g.pdfName)||"text-gray-800 text-sm truncate",style:e({fontWeight:500},null==b?void 0:b.pdfName)},{children:m}))]})),t("div",e({className:"flex items-center gap-4 text-gray-600 flex-shrink-0"},{children:[t("div",e({className:"flex items-center gap-1"},{children:[l(y,{}),l("div",e({className:"text-sm font-medium w-14 text-center"},{children:l(N,{})})),l(x,{})]})),!!d&&t("div",e({style:{display:"flex",alignItems:"center"}},{children:[l("button",e({style:e(e(e({},n.button),{color:"#475467"}),0===u||1===u?n.buttonDisabled:{}),onClick:F,disabled:0===u||1===u},{children:"◀"})),t("span",e({style:n.counter},{children:[u," / ",d]})),l("button",e({style:e(e(e({},n.button),{color:"#475467"}),u===d?n.buttonDisabled:{}),onClick:I,disabled:u===d},{children:"▶"}))]})),l("div",{className:"w-px h-5 bg-gray-300 mx-1"}),t("div",e({className:"flex items-center gap-2"},{children:[l("button",e({onClick:function(){var e=null==p?void 0:p.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},className:w,title:"Full Screen"},{children:(null==v?void 0:v.fullScreenIcon)||l(r,{})})),h&&l("a",e({href:h,target:"_blank",rel:"noopener noreferrer",className:w,title:"Open in new tab"},{children:(null==v?void 0:v.downloadIcon)||l(i,{})})),f&&l("button",e({onClick:f,className:"".concat(w," ml-1"),title:"Close"},{children:(null==v?void 0:v.closeIcon)||l(s,{})}))]}))]}))]}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=PdfToolbar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as r,jsxs as t}from"react/jsx-runtime";import{SpecialZoomLevel as i}from"@react-pdf-viewer/core";import o from"./PdfContainer.js";import s from"./PdfToolbar.js";import{pdfStyles as l}from"./PdfStyle.js";import{PdfHighlightControls as n}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as c}from"react";var a=function(a){var d=a.pdfUrl,m=a.highlightText,u=a.highlightPages,f=a.jumpToPageValue,p=void 0===f?0:f,h=a.pdfName,v=a.onClose,g=a.customStyles,y=a.customClasses,b=a.customIcons,w=n(m,u),x
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as r,jsxs as t}from"react/jsx-runtime";import{SpecialZoomLevel as i}from"@react-pdf-viewer/core";import o from"./PdfContainer.js";import s from"./PdfToolbar.js";import{pdfStyles as l}from"./PdfStyle.js";import{PdfHighlightControls as n}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as c}from"react";var a=function(a){var d=a.pdfUrl,m=a.highlightText,u=a.highlightPages,f=a.jumpToPageValue,p=void 0===f?0:f,h=a.pdfName,v=a.onClose,g=a.customStyles,y=a.customClasses,b=a.customIcons,w=c(null),x=n(m,u,w),P=x.highlightIndex,S=x.cursorIndex,j=x.setCursorIndex,C=x.orderedKeys,I=x.totalHighlights,V=x.getValidPosition,A=x.tryJump,F=x.jumpToPage,T=x.zoomTo,_=x.plugins,q=x.controls,z=V(S);if(!d)return r("div",e({style:e(e({},l.emptyState),null==g?void 0:g.emptyState)},{children:"PDF is not available for this selection"}));return t("div",e({ref:w,className:(null==y?void 0:y.pdfViewerWrapper)||"",style:e(e(e({},l.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==g?void 0:g.pdfViewer)},{children:[r(s,{highlightIndex:P,totalHighlights:I,controls:q,currentPosition:z,pdfName:h,onClose:v,pdfUrl:d,viewerRef:w,customStyles:g,customClasses:y,customIcons:b}),r(o,{pdfUrl:d,plugins:_,customStyles:g,onLoad:function(){if(T(i.ActualSize),p>0){var e=p-1,r=C[e],t=u[r];j(e),t>0&&F(t-1)}requestAnimationFrame(function(){A(),function(){if(w.current){var e=w.current.querySelector(".rpv-core__viewer");if(e){var r=new MutationObserver(function(){var e,t=null===(e=w.current)||void 0===e?void 0:e.querySelector(".rpv-search__highlight");t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),r.disconnect())});r.observe(e,{childList:!0,subtree:!0})}}}()})}})]}))};export{a as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as r,useRef as o,useMemo as t}from"react";import{searchPlugin as e}from"@react-pdf-viewer/search";import{pageNavigationPlugin as n}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as i}from"@react-pdf-viewer/zoom";var u=function(u,c,a){var v=r(0),l=v[0],f=v[1],p=o(!1),m=r(0),g=m[0],s=m[1],d=Object.keys(c).map(Number).sort(function(r,o){return r-o}),h=Object.values(c).filter(function(r){return r>0}).length,T=e({keyword:u}),y=n(),_=i(),x=T.jumpToMatch,B=y.jumpToPage,I=_.zoomTo,P=_.ZoomInButton,Z=_.ZoomOutButton,j=_.ZoomPopover,q=function(){if(!p.current)try{x(0),p.current=!0}catch(r){requestAnimationFrame(q)}},w=function(r,o){if(a.current&&a.current.querySelector(".rpv-core__viewer")){var t=-1,e=function(){var n,i,u=null===(n=a.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(u){if(u.scrollTop!==t)return t=u.scrollTop,void setTimeout(e,100);var c=null===(i=a.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(r,'"]'));if(c){var v=c.querySelectorAll(".rpv-search__highlight")[o];if(v){var l=u.getBoundingClientRect(),f=v.getBoundingClientRect(),p=u.scrollTop+(f.top-l.top)-u.clientHeight/2+f.height/2;u.scrollTo({top:p,behavior:"smooth"})}}}};setTimeout(e,300)}},O=t(function(){var r={};return d.forEach(function(o,t){var e=c[o];e>0&&(r[e]||(r[e]=[]),r[e].push(t))}),r},[d,c]),b=function(r){var o=c[d[r]];return(O[o]||[]).indexOf(r)};return{setHighlightIndex:f,highlightIndex:l,cursorIndex:g,setCursorIndex:s,orderedKeys:d,totalHighlights:h,getValidPosition:function(r){for(var o=0,t=0;t<=r;t++){var e=d[t];c[e]>0&&o++}return o},tryJump:q,jumpToPage:B,zoomTo:I,plugins:[T,y,_],controls:{ZoomInButton:P,ZoomOutButton:Z,ZoomPopover:j,goToNext:function(){for(var r=g+1;r<d.length;r++){var o=d[r];if(c[o]>0){var t=c[o]-1,e=b(r);return s(r),B(c[o]-1),void w(t,e)}}},goToPrevious:function(){for(var r=g-1;r>=0;r--){var o=d[r];if(c[o]>0){var t=c[o]-1,e=b(r);return s(r),B(c[o]-1),void w(t,e)}}}}}};export{u as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfToolbar.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/PdfToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGnF,KAAK,KAAK,GAAG;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5C,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAEF,QAAA,MAAM,UAAU,kJAYb,KAAK,
|
|
1
|
+
{"version":3,"file":"PdfToolbar.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/PdfToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGnF,KAAK,KAAK,GAAG;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;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AAK,CAAC,aAAa,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,QAAA,MAAM,SAAS,4HAUZ,cAAc,4CAsHhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const PdfHighlightControls: (highlightText: string[], highlightPages: Record<number, number>) => {
|
|
2
|
+
export declare const PdfHighlightControls: (highlightText: string[], highlightPages: Record<number, number>, viewerRef: React.RefObject<HTMLDivElement | null>) => {
|
|
3
3
|
setHighlightIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
4
4
|
highlightIndex: number;
|
|
5
5
|
cursorIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/usePdfHighlight.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,oBAAoB,kBAChB,MAAM,EAAE,kBACP,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;;;+
|
|
1
|
+
{"version":3,"file":"usePdfHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/usePdfHighlight.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,oBAAoB,kBAChB,MAAM,EAAE,kBACP,OAAO,MAAM,EAAE,MAAM,CAAC,aAC3B,MAAM,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC;;;;;;;+BAgBf,MAAM;;;;;;;;;;;;CA4JzC,CAAC"}
|