@viswa-test/test-citation 0.0.390 → 0.0.391
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/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/cjs/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/cjs/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/features/PdfViewer/rotationManager.js +1 -1
- package/dist/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +0 -2
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +1 -8
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -12
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts +2 -9
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +1 -2
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/rotationManager.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts +1 -2
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts +21 -0
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("./PdfStyle.js"),r=require("../../assests/svg/PdfViewerIcons.js"),o=require("@mui/material/Tooltip"),i=require("lucide-react"),l=require("@mui/icons-material/RotateRight");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(t),d=s(o),c=s(l);exports.default=({highlightIndex:t,totalHighlights:o,controls:l,currentPosition:s,pdfName:p,onClose:x,pdfUrl:u,viewerRef:h,customStyles:g,customClasses:f,customIcons:y,headerAction:m,isZoomEnabled:j=!0,showHighlightsAction:b=!0,showFullScreenAction:w=!0,currentSegment:k,segmentTooltipText:v="Details of current segment",currentPage:S,totalPages:I,onPageNavigate:C,onRotatePage:F,currentPageRotation:T=0,showRotateButton:W=!0})=>{const{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("./PdfStyle.js"),r=require("../../assests/svg/PdfViewerIcons.js"),o=require("@mui/material/Tooltip"),i=require("lucide-react"),l=require("@mui/icons-material/RotateRight");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(t),d=s(o),c=s(l);exports.default=({highlightIndex:t,totalHighlights:o,controls:l,currentPosition:s,pdfName:p,onClose:x,pdfUrl:u,viewerRef:h,customStyles:g,customClasses:f,customIcons:y,headerAction:m,isZoomEnabled:j=!0,showHighlightsAction:b=!0,showFullScreenAction:w=!0,currentSegment:k,segmentTooltipText:v="Details of current segment",currentPage:S,totalPages:I,onPageNavigate:C,onRotatePage:F,currentPageRotation:T=0,showRotateButton:W=!0})=>{const{CurrentScale:D,ZoomPopover:E,zoomTo:R,goToPrevious:z,goToNext:P}=l,[L,M]=a.default.useState(String(S));a.default.useEffect(()=>{M(String(S))},[S]);const B={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},q=e=>String(e).padStart(2,"0");return e.jsxs("div",{style:{marginBottom:"12px",backgroundColor:"#F1F5F9",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",...n.pdfStyles.header,...g?.header,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0},children:[e.jsx("div",{style:{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box",...g?.pdfIconWrapper,flexShrink:0},children:y?.pdfIcon||e.jsx(r.DefaultPdfIcon,{})}),e.jsx(d.default,{title:p||"",arrow:!0,placement:"top",children:e.jsx("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:e.jsx("span",{style:{display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default",...g?.pdfName},className:f?.pdfName,children:p})})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},children:[I>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"},children:[e.jsx("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:L,onChange:e=>{const t=e.target.value.replace(/\D/g,"");M(t)},onBlur:()=>{const e=Number(L);if(!Number.isInteger(e)||e<1)return void M(String(S));const t=I?Math.min(e,I):e;C(t),M(String(t))},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(M(String(S)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#111827"},children:"/"}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#111827"},children:String(I)})]}),j&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(D,{children:({scale:t})=>e.jsx("button",{onClick:()=>R(Math.max(.1,t-.1)),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:e=>{e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:e=>{e.currentTarget&&(e.currentTarget.style.color="#475467")},title:"Zoom Out","aria-label":"Zoom out",children:e.jsx(i.Minus,{size:16,strokeWidth:2})})}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"},children:e.jsx(E,{})}),e.jsx(D,{children:({scale:t})=>e.jsx("button",{onClick:()=>R(t+.1),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:e=>{e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:e=>{e.currentTarget&&(e.currentTarget.style.color="#475467")},title:"Zoom In","aria-label":"Zoom in",children:e.jsx(i.Plus,{size:16,strokeWidth:2})})})]}),W&&F&&I>0&&e.jsx(d.default,{title:`Rotate page (${T}°)`,children:e.jsx("button",{onClick:()=>{F&&"function"==typeof F&&F()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:0!==T?"#1976d2":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:e=>{e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:e=>{e.currentTarget&&(e.currentTarget.style.color=0!==T?"#1976d2":"#475467")},"aria-label":"Rotate current page",children:e.jsx(c.default,{sx:{fontSize:"18px"}})})}),!!o&&b&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("span",{style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1},children:[s," of ",o]}),e.jsx("button",{style:{background:"none",border:"none",cursor:s<=1?"not-allowed":"pointer",padding:"2px 4px",color:s<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:z,disabled:s<=1,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("button",{style:{background:"none",border:"none",cursor:s===o?"not-allowed":"pointer",padding:"2px 4px",color:s===o?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:P,disabled:s===o,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"},children:[!1!==w&&(m?.icon&&m?.onClick?e.jsx(d.default,{title:m?.tooltip||"",arrow:!0,placement:"top",children:e.jsx("div",{onClick:m.onClick,style:{display:"flex",alignItems:"center",cursor:"pointer",...B},children:m.icon})}):e.jsx("button",{onClick:()=>{const e=h?.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(e=>{console.error(`Error attempting to enable fullscreen: ${e.message}`)}))},style:B,title:"Full Screen",children:y?.fullScreenIcon||e.jsx(i.Expand,{size:20,color:"#475467",strokeWidth:2})})),u&&e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:B,title:"Open in new tab",children:y?.downloadIcon||e.jsx(r.DefaultDownloadIcon,{})}),x&&e.jsx("button",{onClick:x,style:B,title:"Close",children:y?.closeIcon||e.jsx(r.DefaultCloseIcon,{})})]})]})]}),k&&e.jsxs("div",{style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.jsx(d.default,{title:v,arrow:!0,placement:"top",children:e.jsx(i.Info,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:e.jsx(d.default,{title:k.title,arrow:!0,placement:"top",children:e.jsxs("span",{children:["Viewing ",k.title," • Pages ",q(k.start_page),"-",q(k.end_page)]})})})]})]})};
|
|
2
2
|
//# sourceMappingURL=PdfToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfToolbar.js","sources":["../../../../src/features/PdfViewer/PdfToolbar.tsx"],"sourcesContent":["import React from \"react\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport type { CustomIconsType, CustomStylesType, CustomClassesType, PdfSegment } from \"./PdfViewer\";\nimport { DefaultCloseIcon, DefaultDownloadIcon, DefaultFullScreenIcon, DefaultPdfIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport Tooltip from '@mui/material/Tooltip';\nimport { Info, Plus, Minus, Expand } from \"lucide-react\";\nimport RotateRightIcon from '@mui/icons-material/RotateRight';\n\ntype Props = {\n highlightIndex: number;\n totalHighlights: number;\n controls: any;\n currentPosition: any;\n pdfName?: string;\n onClose?: () => void;\n pdfUrl?: string;\n viewerRef?: React.RefObject<HTMLDivElement>;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled: boolean\n showHighlightsAction: boolean,\n showFullScreenAction?: boolean\n currentSegment?: PdfSegment;\n segmentTooltipText?: string;\n currentPage: number;\n totalPages: number;\n onPageNavigate: (pageNumber: number) => void;\n onRotatePage?: () => void;\n currentPageRotation?: number;\n showRotateButton?: boolean;\n};\n\nconst PdfToolbar = ({\n highlightIndex,\n totalHighlights,\n controls,\n currentPosition,\n pdfName,\n onClose,\n pdfUrl,\n viewerRef,\n customStyles,\n customClasses,\n customIcons,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n showFullScreenAction = true,\n currentSegment,\n segmentTooltipText = \"Details of current segment\",\n currentPage,\n totalPages,\n onPageNavigate,\n onRotatePage,\n currentPageRotation = 0,\n showRotateButton = true,\n}: Props) => {\n const { ZoomPopover, goToPrevious, goToNext } = controls;\n const [pageInputValue, setPageInputValue] = React.useState(String(currentPage));\n\n React.useEffect(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleFullScreen = () => {\n const elem = viewerRef?.current;\n if (!elem) return;\n\n if (!document.fullscreenElement) {\n elem.requestFullscreen().catch((err) => {\n console.error(`Error attempting to enable fullscreen: ${err.message}`);\n });\n } else {\n document.exitFullscreen();\n }\n };\n const commitPageInput = () => {\n const pageNumber = Number(pageInputValue);\n\n if (!Number.isInteger(pageNumber) || pageNumber < 1) {\n setPageInputValue(String(currentPage));\n return;\n }\n\n const nextPage = totalPages ? Math.min(pageNumber, totalPages) : pageNumber;\n onPageNavigate(nextPage);\n setPageInputValue(String(nextPage));\n };\n\n const defaultPdfIconWrapperStyle: React.CSSProperties = {\n borderRadius: \"21px\",\n border: \"6px solid #E8F3FF\",\n background: \"#D5E8FF\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"32px\",\n height: \"32px\",\n boxSizing: \"content-box\",\n };\n\n const defaultActionButtonStyle: React.CSSProperties = {\n padding: \"4px\",\n borderRadius: \"6px\",\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n };\n\n const dividerStyle: React.CSSProperties = {\n width: \"1px\",\n height: \"20px\",\n background: \"#D1D5DB\",\n margin: \"0 4px\",\n flexShrink: 0,\n };\n const actionButtonsWrapperStyle: React.CSSProperties = {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n flexShrink: 0,\n whiteSpace: \"nowrap\",\n };\n const formatSegmentPage = (page: number) => String(page).padStart(2, \"0\");\n\n return (\n <div\n style={{\n marginBottom: \"12px\",\n backgroundColor: \"#F1F5F9\",\n borderBottom: \"1px solid #F3F4F6\",\n borderTopLeftRadius: \"12px\",\n borderTopRightRadius: \"12px\",\n ...pdfStyles.header,\n ...customStyles?.header,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n gap: \"12px\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n flexWrap: \"wrap\",\n columnGap: \"16px\",\n rowGap: \"12px\",\n minWidth: 0,\n }}\n >\n {/* --- LEFT SIDE: Document Name & Custom Icon --- */}\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"12px\",\n flex: \"1 1 180px\",\n minWidth: 0,\n }}\n >\n <div\n style={{\n ...defaultPdfIconWrapperStyle,\n ...customStyles?.pdfIconWrapper,\n flexShrink: 0,\n }}\n >\n {customIcons?.pdfIcon || <DefaultPdfIcon />}\n </div>\n\n <Tooltip\n title={pdfName || \"\"}\n arrow\n placement=\"top\"\n >\n <div\n style={{\n flex: 1,\n minWidth: 0,\n overflow: \"hidden\",\n }}\n >\n <span\n style={{\n display: \"block\",\n width: \"100%\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n fontWeight: 500,\n cursor: \"default\",\n ...customStyles?.pdfName,\n }}\n className={customClasses?.pdfName}\n >\n {pdfName}\n </span>\n </div>\n </Tooltip>\n </div>\n\n {/* --- RIGHT SIDE: Toolbar actions --- */}\n <div \n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: showHighlightsAction ? \"16px\" : \"2px\",\n color: \"#4B5563\",\n flex: \"0 1 auto\",\n marginLeft: \"auto\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n maxWidth: \"100%\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n scrollbarWidth: \"thin\",\n }}\n >\n {totalPages > 0 && (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"4px\",\n color: \"#475467\",\n flexShrink: 0,\n whiteSpace: \"nowrap\",\n }}\n >\n <input\n aria-label=\"Current page\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n value={pageInputValue}\n onChange={(e) => {\n const nextValue = e.target.value.replace(/\\D/g, \"\");\n setPageInputValue(nextValue);\n }}\n onBlur={commitPageInput}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.currentTarget.blur();\n }\n if (e.key === \"Escape\") {\n setPageInputValue(String(currentPage));\n e.currentTarget.blur();\n }\n }}\n style={{\n width: \"40px\",\n height: \"28px\",\n border: \"1px solid #E5E7EB\",\n borderRadius: \"4px\",\n background: \"#FFFFFF\",\n color: \"#111827\",\n fontSize: \"14px\",\n fontWeight: 500,\n textAlign: \"center\",\n outline: \"none\",\n boxSizing: \"border-box\",\n }}\n />\n <span style={{ fontSize: \"14px\", fontWeight: 500, color: \"#111827\" }}>/</span>\n <span style={{ fontSize: \"14px\", fontWeight: 500, color: \"#111827\" }}>\n {String(totalPages)}\n </span>\n </div>\n )}\n\n {/* Zoom Controls */}\n {isZoomEnabled && (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"4px\",\n }}\n >\n <button\n onClick={() => {\n if (controls && typeof controls.zoomTo === 'function') {\n controls.zoomTo((currentZoom: number) => currentZoom - 0.1);\n }\n }}\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: \"2px 4px\",\n color: \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n transition: \"color 0.2s ease\",\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#1976d2\";\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#475467\";\n }}\n title=\"Zoom Out\"\n aria-label=\"Zoom out\"\n >\n <Minus size={16} strokeWidth={2} />\n </button>\n <div\n style={{\n fontSize: \"14px\",\n fontWeight: 500,\n width: \"56px\",\n textAlign: \"center\",\n }}\n >\n <ZoomPopover />\n </div>\n <button\n onClick={() => {\n if (controls && typeof controls.zoomTo === 'function') {\n controls.zoomTo((currentZoom: number) => currentZoom + 0.1);\n }\n }}\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: \"2px 4px\",\n color: \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n transition: \"color 0.2s ease\",\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#1976d2\";\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#475467\";\n }}\n title=\"Zoom In\"\n aria-label=\"Zoom in\"\n >\n <Plus size={16} strokeWidth={2} />\n </button>\n </div>\n )}\n\n {/* Rotate Button */}\n {showRotateButton && onRotatePage && totalPages > 0 && (\n <Tooltip title={`Rotate page (${currentPageRotation}°)`}>\n <button\n onClick={() => {\n if (onRotatePage && typeof onRotatePage === 'function') {\n onRotatePage();\n }\n }}\n style={{\n background: 'none',\n border: 'none',\n cursor: 'pointer',\n padding: '2px 4px',\n color: currentPageRotation !== 0 ? '#1976d2' : '#475467',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n lineHeight: 1,\n height: '20px',\n width: '20px',\n transition: 'color 0.2s ease',\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = '#1976d2';\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = currentPageRotation !== 0 ? '#1976d2' : '#475467';\n }}\n aria-label=\"Rotate current page\"\n >\n <RotateRightIcon sx={{ fontSize: '18px' }} />\n </button>\n </Tooltip>\n )}\n\n {!!totalHighlights && showHighlightsAction && (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span style={{ fontSize: \"14px\", color: \"#475467\", fontWeight: 500, lineHeight: 1 }}>\n {currentPosition} of {totalHighlights}\n </span>\n\n {/* Up / Previous */}\n <button\n style={{\n background: \"none\",\n border: \"none\",\n cursor: currentPosition <= 1 ? \"not-allowed\" : \"pointer\",\n padding: \"2px 4px\",\n color: currentPosition <= 1 ? \"#D0D5DD\" : \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n }}\n onClick={goToPrevious}\n disabled={currentPosition <= 1}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\">\n <path d=\"M2 8L6 4L10 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </button>\n\n {/* Down / Next */}\n <button\n style={{\n background: \"none\",\n border: \"none\",\n cursor: currentPosition === totalHighlights ? \"not-allowed\" : \"pointer\",\n padding: \"2px 4px\",\n color: currentPosition === totalHighlights ? \"#D0D5DD\" : \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n }}\n onClick={goToNext}\n disabled={currentPosition === totalHighlights}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\">\n <path d=\"M2 4L6 8L10 4\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </button>\n </div>\n )}\n\n {/* Vertical Divider */}\n <div style={dividerStyle} />\n\n {/* Action Buttons */}\n <div style={actionButtonsWrapperStyle}>\n\n {/* Full Screen OR headerAction */}\n {showFullScreenAction !== false && (\n headerAction?.icon && headerAction?.onClick ? (\n <Tooltip title={headerAction?.tooltip || \"\"} arrow placement=\"top\">\n <div\n onClick={headerAction.onClick}\n style={{ display: \"flex\", alignItems: \"center\", cursor: \"pointer\", ...defaultActionButtonStyle }}\n >\n {headerAction.icon}\n </div>\n </Tooltip>\n ) : (\n <button onClick={handleFullScreen} style={defaultActionButtonStyle} title=\"Full Screen\">\n {customIcons?.fullScreenIcon || <Expand size={20} color=\"#475467\" strokeWidth={2} />}\n </button>\n )\n )}\n\n {/* Download Button */}\n {pdfUrl && (\n <a href={pdfUrl} target=\"_blank\" rel=\"noopener noreferrer\" style={defaultActionButtonStyle} title=\"Open in new tab\">\n {customIcons?.downloadIcon || <DefaultDownloadIcon />}\n </a>\n )}\n\n {/* Close Modal Button - always stays */}\n {onClose && (\n <button onClick={onClose} style={defaultActionButtonStyle} title=\"Close\">\n {customIcons?.closeIcon || <DefaultCloseIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n {/* Segment Details */}\n {currentSegment && (\n <div\n style={{\n background: \"#EEF2FF\",\n border: \"1px solid #A5B4FC\",\n borderRadius: \"8px\",\n color: \"#4F46E5\",\n display: \"flex\",\n alignItems: \"center\",\n gap: \"12px\",\n minWidth: 0,\n padding: \"10px 16px\",\n fontSize: \"12px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n }}\n >\n <Tooltip title={segmentTooltipText} arrow placement=\"top\">\n <Info size={16} color=\"#4F46E5\" strokeWidth={2} style={{ flexShrink: 0 }} />\n </Tooltip>\n <span style={{ overflow: \"hidden\", textOverflow: \"ellipsis\" }}>\n <Tooltip title={currentSegment.title} arrow placement=\"top\">\n <span>Viewing {currentSegment.title} • Pages {formatSegmentPage(currentSegment.start_page)}-{formatSegmentPage(currentSegment.end_page)}</span>\n </Tooltip>\n </span>\n </div>\n )}\n </div>\n );\n};\n\nexport default PdfToolbar;\n"],"names":["highlightIndex","totalHighlights","controls","currentPosition","pdfName","onClose","pdfUrl","viewerRef","customStyles","customClasses","customIcons","headerAction","isZoomEnabled","showHighlightsAction","showFullScreenAction","currentSegment","segmentTooltipText","currentPage","totalPages","onPageNavigate","onRotatePage","currentPageRotation","showRotateButton","ZoomPopover","goToPrevious","goToNext","pageInputValue","setPageInputValue","React","useState","String","useEffect","defaultActionButtonStyle","padding","borderRadius","background","border","cursor","display","alignItems","justifyContent","transition","flexShrink","formatSegmentPage","page","padStart","jsxs","style","marginBottom","backgroundColor","borderBottom","borderTopLeftRadius","borderTopRightRadius","pdfStyles","header","flexDirection","gap","children","flexWrap","columnGap","rowGap","minWidth","flex","jsx","width","height","boxSizing","pdfIconWrapper","pdfIcon","DefaultPdfIcon","Tooltip","title","arrow","placement","overflow","whiteSpace","textOverflow","fontWeight","className","color","marginLeft","maxWidth","overflowX","overflowY","scrollbarWidth","inputMode","pattern","value","onChange","e","nextValue","target","replace","onBlur","pageNumber","Number","isInteger","nextPage","Math","min","onKeyDown","key","currentTarget","blur","fontSize","textAlign","outline","onClick","zoomTo","currentZoom","lineHeight","onMouseEnter","onMouseLeave","Minus","size","strokeWidth","Plus","RotateRightIcon","sx","disabled","viewBox","fill","d","stroke","strokeLinecap","strokeLinejoin","margin","icon","tooltip","elem","current","document","fullscreenElement","exitFullscreen","requestFullscreen","catch","err","console","error","message","fullScreenIcon","Expand","href","rel","downloadIcon","DefaultDownloadIcon","closeIcon","DefaultCloseIcon","Info","start_page","end_page"],"mappings":"iaAsCmB,EACjBA,iBACAC,kBACAC,WACAC,kBACAC,UACAC,UACAC,SACAC,YACAC,eACAC,gBACAC,cACAC,eACAC,iBAAgB,EAChBC,wBAAuB,EACvBC,wBAAuB,EACvBC,iBACAC,qBAAqB,6BACrBC,cACAC,aACAC,iBACAC,eACAC,sBAAsB,EACtBC,oBAAmB,MAEnB,MAAMC,YAAEA,EAAAC,aAAaA,EAAcC,SAAAA,GAAavB,GACzCwB,EAAgBC,GAAqBC,EAAAA,QAAMC,SAASC,OAAOb,IAElEW,EAAA,QAAMG,UAAU,KACIJ,EAAAG,OAAOb,KACxB,CAACA,IAEJ,MAqCMe,EAAgD,CACpDC,QAAS,MACTC,aAAc,MACdC,WAAY,cACZC,OAAQ,OACRC,OAAQ,UACRC,QAAS,OACTC,WAAY,SACZC,eAAgB,SAChBC,WAAY,gBACZC,WAAY,GAiBRC,EAAqBC,GAAiBd,OAAO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ACEyD,EAAAA,IAAA,IAAA,CAAE+E,KAAMxI,EAAQqF,OAAO,SAASoD,IAAI,sBAAsBhG,MAAOf,EAA0BuC,MAAM,kBAC/Fd,YAAauF,cAAgBjF,MAACkF,EAAAA,qBAAoB,KAKtD5I,GACC0D,EAAAA,IAAC,SAAO,CAAA4C,QAAStG,EAAS0C,MAAOf,EAA0BuC,MAAM,QAC9Dd,SAAA/C,GAAawI,WAAanF,EAAAA,IAACoF,oBAAiB,cAOpDpI,GACC+B,EAAAA,KAAC,MAAA,CACCC,MAAO,CACLZ,WAAY,UACZC,OAAQ,oBACRF,aAAc,MACd6C,MAAO,UACPzC,QAAS,OACTC,WAAY,SACZiB,IAAK,OACLK,SAAU,EACV5B,QAAS,YACTuE,SAAU,OACV3B,WAAY,IACZF,WAAY,SACZD,SAAU,SACVE,aAAc,YAGhBnB,SAAA,CAACM,EAAAA,IAAAO,EAAA,QAAA,CAAQC,MAAOvD,EAAoBwD,OAAK,EAACC,UAAU,MAClDhB,eAAC2F,EAAKA,KAAA,CAAAlC,KAAM,GAAInC,MAAM,UAAUoC,YAAa,EAAGpE,MAAO,CAAEL,WAAY,aAEtE,OAAK,CAAAK,MAAO,CAAE2B,SAAU,SAAUE,aAAc,YAC/CnB,eAACa,EAAQ,QAAA,CAAAC,MAAOxD,EAAewD,MAAOC,OAAK,EAACC,UAAU,MACtDhB,gBAAC,OAAK,CAAAA,SAAA,CAAA,WAAS1C,EAAewD,MAAM,YAAe5B,EAAkB5B,EAAesI,YAAY,IAAE1G,EAAkB5B,EAAeuI"}
|
|
1
|
+
{"version":3,"file":"PdfToolbar.js","sources":["../../../../src/features/PdfViewer/PdfToolbar.tsx"],"sourcesContent":["import React from \"react\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport type { CustomIconsType, CustomStylesType, CustomClassesType, PdfSegment } from \"./PdfViewer\";\nimport { DefaultCloseIcon, DefaultDownloadIcon, DefaultFullScreenIcon, DefaultPdfIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport Tooltip from '@mui/material/Tooltip';\nimport { Info, Plus, Minus, Expand } from \"lucide-react\";\nimport RotateRightIcon from '@mui/icons-material/RotateRight';\n\ntype Props = {\n highlightIndex: number;\n totalHighlights: number;\n controls: any;\n currentPosition: any;\n pdfName?: string;\n onClose?: () => void;\n pdfUrl?: string;\n viewerRef?: React.RefObject<HTMLDivElement>;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled: boolean\n showHighlightsAction: boolean,\n showFullScreenAction?: boolean\n currentSegment?: PdfSegment;\n segmentTooltipText?: string;\n currentPage: number;\n totalPages: number;\n onPageNavigate: (pageNumber: number) => void;\n onRotatePage?: () => void;\n currentPageRotation?: number;\n showRotateButton?: boolean;\n};\n\nconst PdfToolbar = ({\n highlightIndex,\n totalHighlights,\n controls,\n currentPosition,\n pdfName,\n onClose,\n pdfUrl,\n viewerRef,\n customStyles,\n customClasses,\n customIcons,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n showFullScreenAction = true,\n currentSegment,\n segmentTooltipText = \"Details of current segment\",\n currentPage,\n totalPages,\n onPageNavigate,\n onRotatePage,\n currentPageRotation = 0,\n showRotateButton = true,\n}: Props) => {\n const {\n CurrentScale,\n ZoomPopover,\n zoomTo,\n goToPrevious,\n goToNext,\n } = controls;\n const [pageInputValue, setPageInputValue] = React.useState(String(currentPage));\n\n React.useEffect(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleFullScreen = () => {\n const elem = viewerRef?.current;\n if (!elem) return;\n\n if (!document.fullscreenElement) {\n elem.requestFullscreen().catch((err) => {\n console.error(`Error attempting to enable fullscreen: ${err.message}`);\n });\n } else {\n document.exitFullscreen();\n }\n };\n const commitPageInput = () => {\n const pageNumber = Number(pageInputValue);\n\n if (!Number.isInteger(pageNumber) || pageNumber < 1) {\n setPageInputValue(String(currentPage));\n return;\n }\n\n const nextPage = totalPages ? Math.min(pageNumber, totalPages) : pageNumber;\n onPageNavigate(nextPage);\n setPageInputValue(String(nextPage));\n };\n\n const defaultPdfIconWrapperStyle: React.CSSProperties = {\n borderRadius: \"21px\",\n border: \"6px solid #E8F3FF\",\n background: \"#D5E8FF\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"32px\",\n height: \"32px\",\n boxSizing: \"content-box\",\n };\n\n const defaultActionButtonStyle: React.CSSProperties = {\n padding: \"4px\",\n borderRadius: \"6px\",\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n };\n\n const dividerStyle: React.CSSProperties = {\n width: \"1px\",\n height: \"20px\",\n background: \"#D1D5DB\",\n margin: \"0 4px\",\n flexShrink: 0,\n };\n const actionButtonsWrapperStyle: React.CSSProperties = {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n flexShrink: 0,\n whiteSpace: \"nowrap\",\n };\n const formatSegmentPage = (page: number) => String(page).padStart(2, \"0\");\n\n return (\n <div\n style={{\n marginBottom: \"12px\",\n backgroundColor: \"#F1F5F9\",\n borderBottom: \"1px solid #F3F4F6\",\n borderTopLeftRadius: \"12px\",\n borderTopRightRadius: \"12px\",\n ...pdfStyles.header,\n ...customStyles?.header,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n gap: \"12px\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n flexWrap: \"wrap\",\n columnGap: \"16px\",\n rowGap: \"12px\",\n minWidth: 0,\n }}\n >\n {/* --- LEFT SIDE: Document Name & Custom Icon --- */}\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"12px\",\n flex: \"1 1 180px\",\n minWidth: 0,\n }}\n >\n <div\n style={{\n ...defaultPdfIconWrapperStyle,\n ...customStyles?.pdfIconWrapper,\n flexShrink: 0,\n }}\n >\n {customIcons?.pdfIcon || <DefaultPdfIcon />}\n </div>\n\n <Tooltip\n title={pdfName || \"\"}\n arrow\n placement=\"top\"\n >\n <div\n style={{\n flex: 1,\n minWidth: 0,\n overflow: \"hidden\",\n }}\n >\n <span\n style={{\n display: \"block\",\n width: \"100%\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n fontWeight: 500,\n cursor: \"default\",\n ...customStyles?.pdfName,\n }}\n className={customClasses?.pdfName}\n >\n {pdfName}\n </span>\n </div>\n </Tooltip>\n </div>\n\n {/* --- RIGHT SIDE: Toolbar actions --- */}\n <div \n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: showHighlightsAction ? \"16px\" : \"2px\",\n color: \"#4B5563\",\n flex: \"0 1 auto\",\n marginLeft: \"auto\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n maxWidth: \"100%\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n scrollbarWidth: \"thin\",\n }}\n >\n {totalPages > 0 && (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"4px\",\n color: \"#475467\",\n flexShrink: 0,\n whiteSpace: \"nowrap\",\n }}\n >\n <input\n aria-label=\"Current page\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n value={pageInputValue}\n onChange={(e) => {\n const nextValue = e.target.value.replace(/\\D/g, \"\");\n setPageInputValue(nextValue);\n }}\n onBlur={commitPageInput}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.currentTarget.blur();\n }\n if (e.key === \"Escape\") {\n setPageInputValue(String(currentPage));\n e.currentTarget.blur();\n }\n }}\n style={{\n width: \"40px\",\n height: \"28px\",\n border: \"1px solid #E5E7EB\",\n borderRadius: \"4px\",\n background: \"#FFFFFF\",\n color: \"#111827\",\n fontSize: \"14px\",\n fontWeight: 500,\n textAlign: \"center\",\n outline: \"none\",\n boxSizing: \"border-box\",\n }}\n />\n <span style={{ fontSize: \"14px\", fontWeight: 500, color: \"#111827\" }}>/</span>\n <span style={{ fontSize: \"14px\", fontWeight: 500, color: \"#111827\" }}>\n {String(totalPages)}\n </span>\n </div>\n )}\n\n {/* Zoom Controls */}\n {isZoomEnabled && (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"4px\",\n }}\n >\n <CurrentScale>\n {({ scale }: { scale: number }) => (\n <button\n onClick={() => zoomTo(Math.max(0.1, scale - 0.1))}\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: \"2px 4px\",\n color: \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n transition: \"color 0.2s ease\",\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#1976d2\";\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#475467\";\n }}\n title=\"Zoom Out\"\n aria-label=\"Zoom out\"\n >\n <Minus size={16} strokeWidth={2} />\n </button>\n )}\n </CurrentScale>\n <div\n style={{\n fontSize: \"14px\",\n fontWeight: 500,\n width: \"56px\",\n textAlign: \"center\",\n }}\n >\n <ZoomPopover />\n </div>\n <CurrentScale>\n {({ scale }: { scale: number }) => (\n <button\n onClick={() => zoomTo(scale + 0.1)}\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: \"2px 4px\",\n color: \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n transition: \"color 0.2s ease\",\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#1976d2\";\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = \"#475467\";\n }}\n title=\"Zoom In\"\n aria-label=\"Zoom in\"\n >\n <Plus size={16} strokeWidth={2} />\n </button>\n )}\n </CurrentScale>\n </div>\n )}\n\n {/* Rotate Button */}\n {showRotateButton && onRotatePage && totalPages > 0 && (\n <Tooltip title={`Rotate page (${currentPageRotation}°)`}>\n <button\n onClick={() => {\n if (onRotatePage && typeof onRotatePage === 'function') {\n onRotatePage();\n }\n }}\n style={{\n background: 'none',\n border: 'none',\n cursor: 'pointer',\n padding: '2px 4px',\n color: currentPageRotation !== 0 ? '#1976d2' : '#475467',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n lineHeight: 1,\n height: '20px',\n width: '20px',\n transition: 'color 0.2s ease',\n }}\n onMouseEnter={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = '#1976d2';\n }}\n onMouseLeave={(e) => {\n if (e.currentTarget) e.currentTarget.style.color = currentPageRotation !== 0 ? '#1976d2' : '#475467';\n }}\n aria-label=\"Rotate current page\"\n >\n <RotateRightIcon sx={{ fontSize: '18px' }} />\n </button>\n </Tooltip>\n )}\n\n {!!totalHighlights && showHighlightsAction && (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span style={{ fontSize: \"14px\", color: \"#475467\", fontWeight: 500, lineHeight: 1 }}>\n {currentPosition} of {totalHighlights}\n </span>\n\n {/* Up / Previous */}\n <button\n style={{\n background: \"none\",\n border: \"none\",\n cursor: currentPosition <= 1 ? \"not-allowed\" : \"pointer\",\n padding: \"2px 4px\",\n color: currentPosition <= 1 ? \"#D0D5DD\" : \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n }}\n onClick={goToPrevious}\n disabled={currentPosition <= 1}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\">\n <path d=\"M2 8L6 4L10 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </button>\n\n {/* Down / Next */}\n <button\n style={{\n background: \"none\",\n border: \"none\",\n cursor: currentPosition === totalHighlights ? \"not-allowed\" : \"pointer\",\n padding: \"2px 4px\",\n color: currentPosition === totalHighlights ? \"#D0D5DD\" : \"#475467\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n height: \"20px\",\n width: \"20px\",\n }}\n onClick={goToNext}\n disabled={currentPosition === totalHighlights}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\">\n <path d=\"M2 4L6 8L10 4\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </button>\n </div>\n )}\n\n {/* Vertical Divider */}\n <div style={dividerStyle} />\n\n {/* Action Buttons */}\n <div style={actionButtonsWrapperStyle}>\n\n {/* Full Screen OR headerAction */}\n {showFullScreenAction !== false && (\n headerAction?.icon && headerAction?.onClick ? (\n <Tooltip title={headerAction?.tooltip || \"\"} arrow placement=\"top\">\n <div\n onClick={headerAction.onClick}\n style={{ display: \"flex\", alignItems: \"center\", cursor: \"pointer\", ...defaultActionButtonStyle }}\n >\n {headerAction.icon}\n </div>\n </Tooltip>\n ) : (\n <button onClick={handleFullScreen} style={defaultActionButtonStyle} title=\"Full Screen\">\n {customIcons?.fullScreenIcon || <Expand size={20} color=\"#475467\" strokeWidth={2} />}\n </button>\n )\n )}\n\n {/* Download Button */}\n {pdfUrl && (\n <a href={pdfUrl} target=\"_blank\" rel=\"noopener noreferrer\" style={defaultActionButtonStyle} title=\"Open in new tab\">\n {customIcons?.downloadIcon || <DefaultDownloadIcon />}\n </a>\n )}\n\n {/* Close Modal Button - always stays */}\n {onClose && (\n <button onClick={onClose} style={defaultActionButtonStyle} title=\"Close\">\n {customIcons?.closeIcon || <DefaultCloseIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n {/* Segment Details */}\n {currentSegment && (\n <div\n style={{\n background: \"#EEF2FF\",\n border: \"1px solid #A5B4FC\",\n borderRadius: \"8px\",\n color: \"#4F46E5\",\n display: \"flex\",\n alignItems: \"center\",\n gap: \"12px\",\n minWidth: 0,\n padding: \"10px 16px\",\n fontSize: \"12px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n }}\n >\n <Tooltip title={segmentTooltipText} arrow placement=\"top\">\n <Info size={16} color=\"#4F46E5\" strokeWidth={2} style={{ flexShrink: 0 }} />\n </Tooltip>\n <span style={{ overflow: \"hidden\", textOverflow: \"ellipsis\" }}>\n <Tooltip title={currentSegment.title} arrow placement=\"top\">\n <span>Viewing {currentSegment.title} • Pages {formatSegmentPage(currentSegment.start_page)}-{formatSegmentPage(currentSegment.end_page)}</span>\n </Tooltip>\n </span>\n </div>\n )}\n </div>\n );\n};\n\nexport default PdfToolbar;\n"],"names":["highlightIndex","totalHighlights","controls","currentPosition","pdfName","onClose","pdfUrl","viewerRef","customStyles","customClasses","customIcons","headerAction","isZoomEnabled","showHighlightsAction","showFullScreenAction","currentSegment","segmentTooltipText","currentPage","totalPages","onPageNavigate","onRotatePage","currentPageRotation","showRotateButton","CurrentScale","ZoomPopover","zoomTo","goToPrevious","goToNext","pageInputValue","setPageInputValue","React","useState","String","useEffect","defaultActionButtonStyle","padding","borderRadius","background","border","cursor","display","alignItems","justifyContent","transition","flexShrink","formatSegmentPage","page","padStart","jsxs","style","marginBottom","backgroundColor","borderBottom","borderTopLeftRadius","borderTopRightRadius","pdfStyles","header","flexDirection","gap","children","flexWrap","columnGap","rowGap","minWidth","flex","jsx","width","height","boxSizing","pdfIconWrapper","pdfIcon","DefaultPdfIcon","Tooltip","title","arrow","placement","overflow","whiteSpace","textOverflow","fontWeight","className","color","marginLeft","maxWidth","overflowX","overflowY","scrollbarWidth","inputMode","pattern","value","onChange","e","nextValue","target","replace","onBlur","pageNumber","Number","isInteger","nextPage","Math","min","onKeyDown","key","currentTarget","blur","fontSize","textAlign","outline","scale","onClick","max","lineHeight","onMouseEnter","onMouseLeave","Minus","size","strokeWidth","Plus","RotateRightIcon","sx","disabled","viewBox","fill","d","stroke","strokeLinecap","strokeLinejoin","margin","icon","tooltip","elem","current","document","fullscreenElement","exitFullscreen","requestFullscreen","catch","err","console","error","message","fullScreenIcon","Expand","href","rel","downloadIcon","DefaultDownloadIcon","closeIcon","DefaultCloseIcon","Info","start_page","end_page"],"mappings":"iaAsCmB,EACjBA,iBACAC,kBACAC,WACAC,kBACAC,UACAC,UACAC,SACAC,YACAC,eACAC,gBACAC,cACAC,eACAC,iBAAgB,EAChBC,wBAAuB,EACvBC,wBAAuB,EACvBC,iBACAC,qBAAqB,6BACrBC,cACAC,aACAC,iBACAC,eACAC,sBAAsB,EACtBC,oBAAmB,MAEb,MAAAC,aACJA,EAAAC,YACAA,EAAAC,OACAA,EAAAC,aACAA,EAAAC,SACAA,GACEzB,GACG0B,EAAgBC,GAAqBC,EAAAA,QAAMC,SAASC,OAAOf,IAElEa,EAAA,QAAMG,UAAU,KACIJ,EAAAG,OAAOf,KACxB,CAACA,IAEJ,MAqCMiB,EAAgD,CACpDC,QAAS,MACTC,aAAc,MACdC,WAAY,cACZC,OAAQ,OACRC,OAAQ,UACRC,QAAS,OACTC,WAAY,SACZC,eAAgB,SAChBC,WAAY,gBACZC,WAAY,GAiBRC,EAAqBC,GAAiBd,OAAOc,GAAMC,SAAS,EAAG,KAGnE,OAAAC,EAAAA,KAAC,MAAA,CACCC,MAAO,CACPC,aAAc,OACdC,gBAAiB,UACjBC,aAAc,oBACdC,oBAAqB,OACrBC,qBAAsB,UACnBC,EAAUA,UAAAC,UACVhD,GAAcgD,OACjBhB,QAAS,OACTiB,cAAe,SACfhB,WAAY,UACZiB,IAAK,QAGLC,SAAA,CAAAX,EAAAA,KAAC,MAAA,CACCC,MAAO,CACLT,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBkB,SAAU,OACVC,UAAW,OACXC,OAAQ,OACRC,SAAU,GAIZJ,SAAA,CAAAX,EAAAA,KAAC,MAAA,CACCC,MAAO,CACLT,QAA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ACTC,WAAY,SACZiB,IAAK,OACLK,SAAU,EACV5B,QAAS,YACTuE,SAAU,OACV3B,WAAY,IACZF,WAAY,SACZD,SAAU,SACVE,aAAc,YAGhBnB,SAAA,CAACM,EAAAA,IAAAO,EAAA,QAAA,CAAQC,MAAOzD,EAAoB0D,OAAK,EAACC,UAAU,MAClDhB,eAAC2F,EAAKA,KAAA,CAAAlC,KAAM,GAAInC,MAAM,UAAUoC,YAAa,EAAGpE,MAAO,CAAEL,WAAY,aAEtE,OAAK,CAAAK,MAAO,CAAE2B,SAAU,SAAUE,aAAc,YAC/CnB,eAACa,EAAQ,QAAA,CAAAC,MAAO1D,EAAe0D,MAAOC,OAAK,EAACC,UAAU,MACtDhB,gBAAC,OAAK,CAAAA,SAAA,CAAA,WAAS5C,EAAe0D,MAAM,YAAe5B,EAAkB9B,EAAewI,YAAY,IAAE1G,EAAkB9B,EAAeyI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";require("../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js").default(".PdfViewer_rpv-search__highlight__VoK0R{mix-blend-mode:multiply;opacity:0!important;pointer-events:none}.PdfViewer_rpv-search__highlight__VoK0R.PdfViewer_verified-match__uLbHV{opacity:.9!important;pointer-events:auto}[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--link__PjTgh,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--popup__9Gy-f,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--text__a6yJd,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation-layer__VSu-j,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation-popup-wrapper__dYd-M{display:none!important;pointer-events:none!important}[data-pdf-page-fit=true] .PdfViewer_rpv-core__inner-pages__ybJXq{overflow-y:scroll;scrollbar-gutter:stable}");
|
|
1
|
+
"use strict";require("../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js").default(".PdfViewer_rpv-search__highlight__VoK0R{mix-blend-mode:multiply;opacity:0!important;pointer-events:none}.PdfViewer_rpv-search__highlight__VoK0R.PdfViewer_verified-match__uLbHV{opacity:.9!important;pointer-events:auto}[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--link__PjTgh,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--popup__9Gy-f,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation--text__a6yJd,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation-layer__VSu-j,[data-disable-pdf-annotations=true] .PdfViewer_rpv-core__annotation-popup-wrapper__dYd-M{display:none!important;pointer-events:none!important}[data-pdf-page-fit=true] .PdfViewer_rpv-core__inner-pages__ybJXq{overflow-y:scroll;scrollbar-gutter:stable}.PdfViewer_citation-pdf-viewer__q7tEK .PdfViewer_rpv-core__inner-pages__ybJXq{scrollbar-color:#cbd5e1 transparent;scrollbar-gutter:stable;scrollbar-width:thin}.PdfViewer_citation-pdf-viewer__q7tEK .PdfViewer_rpv-core__inner-pages__ybJXq::-webkit-scrollbar{width:12px}.PdfViewer_citation-pdf-viewer__q7tEK .PdfViewer_rpv-core__inner-pages__ybJXq::-webkit-scrollbar-track{background:transparent}.PdfViewer_citation-pdf-viewer__q7tEK .PdfViewer_rpv-core__inner-pages__ybJXq::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#cbd5e1;border:3px solid transparent;border-radius:999px}.PdfViewer_citation-pdf-viewer__q7tEK .PdfViewer_rpv-core__inner-pages__ybJXq::-webkit-scrollbar-thumb:hover{background-color:#94a3b8}");
|
|
2
2
|
//# sourceMappingURL=PdfViewer.css.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),r=require("./PdfContainer.js"),n=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),i=require("./usePdfHighlight.js"),a=require("./rotationManager.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 s=require("react"),c=require("../ScannedDocCitation/ScannedDocCitation.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./PdfViewer.css.js");var u=l(s);exports.default=({pdfUrl:l,highlightText:d,highlightPages:g,highlightCordinatePages:h,highlightColor:f="yellow",activeHighlightColor:p="#f7dc51",jumpToPageValue:m=0,pdfName:v,onClose:y,customStyles:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),r=require("./PdfContainer.js"),n=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),i=require("./usePdfHighlight.js"),a=require("./rotationManager.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 s=require("react"),c=require("../ScannedDocCitation/ScannedDocCitation.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./PdfViewer.css.js");var u=l(s);exports.default=({pdfUrl:l,highlightText:d,highlightPages:g,highlightCordinatePages:h,highlightColor:f="yellow",activeHighlightColor:p="#f7dc51",jumpToPageValue:m=0,pdfName:v,onClose:y,customStyles:w,customClasses:x,customIcons:P,useCoordinates:S,fallbackPages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q,isZoomEnabled:R=!0,showHighlightsAction:A=!0,defaultScale:_=t.SpecialZoomLevel.ActualSize,useRange:j=!1,rangeOfPages:I=null,showFullScreenAction:L=!0,showRotateButton:M=!1,segments:E=[{title:"Document 2",start_page:52,end_page:52,page_count:1}],segmentTooltipText:F,onCurrentPageChange:H,navigationRequest:N,onNavigationSettled:B,disablePdfAnnotations:Z=!1,disablePdfTextLayer:V=!1,renderPage:k,setRenderRange:z})=>{const D=s.useRef(null),O=(e=>{switch(e){case"ActualSize":return t.SpecialZoomLevel.ActualSize;case"PageFit":return t.SpecialZoomLevel.PageFit;case"PageWidth":return t.SpecialZoomLevel.PageWidth;default:return e??t.SpecialZoomLevel.PageWidth}})(_),[W,U]=s.useState(0),[$,J]=s.useState(0),[K,G]=s.useState(0),Q=s.useRef(null),X=s.useRef(null),Y=s.useRef(0),ee=s.useRef(null),te=s.useMemo(()=>{if(!l)return"";try{return new URL(l,window.location.origin).pathname.split("/").pop()||"default"}catch{return"default"}},[l]);s.useEffect(()=>{te&&a.rotationManager.setPdfIdentifier(te)},[te]);s.useEffect(()=>a.rotationManager.onRotationChange((e,t)=>{e===W+1&&G(t)}),[W]),s.useEffect(()=>{const e=new MutationObserver(()=>{const e=D.current?.querySelectorAll('[data-testid^="core__page-layer-"]'),t=new Set;e?.forEach(e=>{const r=e.getAttribute("data-testid")?.match(/core__page-layer-(\d+)/);if(r&&r.length>=2){const n=parseInt(r[1],10)+1;t.has(n)||(a.rotationManager.registerPageElement(n,e),t.add(n))}})});return D.current&&(e.observe(D.current,{childList:!0,subtree:!0,attributes:!1}),ee.current=e),()=>{e.disconnect(),ee.current=null}},[]),s.useEffect(()=>()=>{a.rotationManager.clearAll(),ee.current&&ee.current.disconnect()},[]),s.useEffect(()=>{const e=W+1;G(a.rotationManager.getRotation(e))},[W]);const re=s.useMemo(()=>Z||V?t=>{const r=V?e.jsx("div",{"aria-hidden":"true",style:{display:"none"},children:t.textLayer.children}):t.textLayer.children,n={...t,annotationLayer:{...t.annotationLayer,children:Z?null:t.annotationLayer.children},textLayer:{...t.textLayer,children:r}};return k?k(n):e.jsxs(e.Fragment,{children:[t.canvasLayer.children,r,!Z&&t.annotationLayer.children]})}:k,[Z,V,k]),ne=s.useMemo(()=>{if(S)return new Set(h.map(e=>e.pageIndex));{const e=new Set;return Object.values(g).forEach(t=>{t>0&&e.add(t-1)}),e}},[h,g,S]),oe=(ie=d)&&0!==ie.length?ie.filter(e=>!ie.some(t=>t!==e&&t.includes(e))):ie;var ie;const{highlightIndex:ae,setHighlightIndex:se,cursorIndex:ce,setCursorIndex:le,orderedKeys:ue,totalHighlights:de,getValidPosition:ge,tryJump:he,jumpToPage:fe,zoomTo:pe,plugins:me,controls:ve,hideNonTargetHighlights:ye,deduplicateHighlights:we,scrollToCoord:xe}=i.PdfHighlightControls(oe,S?{}:g,D,ne,S,S?h:[],f,p),Pe=ge(ce),Se=s.useMemo(()=>{const e=W+1;return E.find(t=>e>=t.start_page&&e<=t.end_page)},[W,E]);s.useEffect(()=>{void 0!==C&&C!==ce&&le(C)},[C]);const Te={...ve,goToNext:()=>{ce>=de-1||(ve.goToNext(),b&&b(ce+1))},goToPrevious:()=>{ce<=0||(ve.goToPrevious(),b&&b(ce-1))}},Ce=u.default.useCallback((e,t)=>{Y.current+=1;const r=Y.current;null!=X.current&&window.clearTimeout(X.current);let n=null,o=0,i=0;const a=()=>{if(Y.current!==r)return;i+=1;const s=D.current?.querySelector(".rpv-core__inner-pages"),c=D.current?.querySelector(`[data-testid="core__page-layer-${t-1}"]`);if(!s||!c)return i>=40?(X.current=null,void B?.({pageNumber:t,requestId:e.requestId})):void(X.current=window.setTimeout(a,50));n===s.scrollTop?o+=1:(n=s.scrollTop,o=0);const l=s.getBoundingClientRect(),u=c.getBoundingClientRect(),d=Boolean(l&&u&&u.bottom>l.top&&u.top<l.bottom);if(o>=2&&d||i>=40)return X.current=null,void B?.({pageNumber:t,requestId:e.requestId});X.current=window.setTimeout(a,50)};X.current=window.setTimeout(a,50)},[B]);if(s.useEffect(()=>()=>{Y.current+=1,null!=X.current&&window.clearTimeout(X.current)},[]),s.useEffect(()=>{if(!N||$<=0)return;const e=Math.min(Math.max(Math.trunc(N.pageNumber),1),$),t=`${N.requestId??e}:${e}`;Q.current!==t&&(Q.current=t,U(e-1),fe(e-1),Ce(N,e))},[fe,N,$,Ce]),!l)return e.jsx(c.default,{pages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q});return e.jsxs("div",{ref:D,className:["citation-pdf-viewer",x?.pdfViewerWrapper].filter(Boolean).join(" "),"data-disable-pdf-annotations":Z?"true":void 0,"data-pdf-page-fit":O===t.SpecialZoomLevel.PageFit?"true":void 0,style:{height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column",...o.pdfStyles.pdfViewer,display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA",...w?.pdfViewer,backgroundColor:"#F1F5F9"},children:[e.jsx(n.default,{highlightIndex:ae,totalHighlights:de,controls:Te,currentPosition:Pe,pdfName:v,onClose:y,pdfUrl:l,viewerRef:D,customStyles:w,customClasses:x,customIcons:P,headerAction:q,isZoomEnabled:R,showHighlightsAction:A,showFullScreenAction:L,currentSegment:Se,segmentTooltipText:F,currentPage:W+1,totalPages:$,onPageNavigate:e=>{const t=Math.min(Math.max(e,1),$||e);U(t-1),fe(t-1)},onRotatePage:()=>{const e=W+1;a.rotationManager.rotatePageBy90(e),G(a.rotationManager.getRotation(e))},currentPageRotation:K,showRotateButton:M}),e.jsx(r.default,{defaultScale:O,pdfUrl:l,plugins:me,customStyles:w,onLoad:e=>{J(e.doc.numPages);const t=!S&&!j&&m<=0;if(m>0&&!j){const e=m-1,t=ue[e],r=g[t],n=h[e];le(e),console.log(n,"cordinateTargetHighlight"),S&&n.pageIndex>0&&fe(n.pageIndex),r>0&&(setTimeout(()=>{ye(ne),we(r-1)},1e3),S||fe(r-1))}else if(j&&I&&2===I.length){(async()=>{const[e,t]=I;for(let r=e;r<=t;r++){const e=r-1;fe(e),await new Promise(e=>setTimeout(e,1e3)),ye(ne);const t=we(e);if(t&&t>0)break}})()}else if(!S&&g){const e=ue.find(e=>g[e]>0);if(void 0!==e){const t=g[e]-1;fe(t),setTimeout(()=>{ye(ne),we(t)},1e3)}}requestAnimationFrame(()=>{t&&he(),!S&&m>0&&!j&&(()=>{if(!D.current)return;const e=m-1,t=ue[e],r=g[t],n=r>0?r-1:0,o={};ue.forEach((e,t)=>{const r=g[e];r>0&&(o[r]||(o[r]=[]),o[r].push(t))});const i=(o[r]||[]).indexOf(e);let a=0;const s=()=>{if(a++,a>40)return;const e=D.current?.querySelector(".rpv-core__inner-pages");if(!e)return void setTimeout(s,100);const t=D.current?.querySelector(`[data-testid="core__page-layer-${n}"]`);if(!t)return void setTimeout(s,100);const r=e.getBoundingClientRect(),o=t.getBoundingClientRect();if(!(o.top<r.bottom&&o.bottom>r.top))return void setTimeout(s,100);const c=t.querySelectorAll(".rpv-search__highlight")[i];if(!c)return void setTimeout(s,100);const l=c.getBoundingClientRect(),u=e.scrollTop+(l.top-r.top)-e.clientHeight/2+l.height/2;e.scrollTo({top:u,behavior:"smooth"})};setTimeout(s,500)})()})},onPageChange:e=>{const t=e.currentPage;U(t),H?.(t+1),ne.has(t)?(we(t),ye(ne)):ye(ne)},renderPage:re,setRenderRange:z})]})};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewer.js","sources":["../../../../src/features/PdfViewer/PdfViewer.tsx"],"sourcesContent":["import { DocumentLoadEvent, PageChangeEvent, RenderPage, SetRenderRange, SpecialZoomLevel } from \"@react-pdf-viewer/core\";\nimport PdfContainer from \"./PdfContainer\";\nimport PdfToolbar from \"./PdfToolbar\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { PdfHighlightControls } from \"./usePdfHighlight\";\nimport { rotationManager } from \"./rotationManager\";\nimport \"@react-pdf-viewer/zoom/lib/styles/index.css\";\nimport \"@react-pdf-viewer/page-navigation/lib/styles/index.css\";\nimport \"@react-pdf-viewer/core/lib/styles/index.css\";\nimport \"@react-pdf-viewer/search/lib/styles/index.css\";\nimport React, { useMemo, useRef, useEffect, useState } from \"react\";\nimport ScannedDocCitation, { CitationPage } from \"../ScannedDocCitation/ScannedDocCitation\";\nimport \"./PdfViewer.css\";\n\nexport type CustomIconsType = {\n pdfIcon?: React.ReactNode;\n fullScreenIcon?: React.ReactNode;\n downloadIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n};\n\nexport type CustomStylesType = {\n pdfViewer?: React.CSSProperties;\n header?: React.CSSProperties;\n pdfIconWrapper?: React.CSSProperties;\n pdfName?: React.CSSProperties;\n pdfContainer?: React.CSSProperties;\n emptyState?: React.CSSProperties;\n};\n\nexport type CustomClassesType = {\n header?: string;\n pdfName?: string;\n actionButton?: string;\n pdfViewerWrapper?: string;\n};\n\nexport type PdfSegment = {\n title: string;\n start_page: number;\n end_page: number;\n page_count: number;\n};\n\ntype PdfScaleOption =\n | \"ActualSize\"\n | \"PageFit\"\n | \"PageWidth\"\n | number;\nexport interface PdfNavigationRequest {\n pageNumber: number;\n /** Change this value to navigate to the same page more than once. */\n requestId?: string | number;\n}\n\nexport interface PdfNavigationSettledEvent extends PdfNavigationRequest {\n pageNumber: number;\n}\n\nexport interface PdfViewerProps {\n pdfUrl?: string;\n highlightText: string[];\n highlightPages?: any;\n highlightCordinatePages: HighlightArea[];\n highlightColor?: string;\n activeHighlightColor?: string;\n jumpToPageValue?: number;\n pdfName?: string;\n onClose?: () => void;\n item?: any;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n useCoordinates: boolean;\n fallbackPages?: CitationPage[];\n activeCitationIndex?: number;\n onActiveCitationChange?: (index: number) => void;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled?: boolean;\n showHighlightsAction?: boolean;\n defaultScale?: PdfScaleOption;\n useRange?: boolean; //\n rangeOfPages?: number[] | null;\n showFullScreenAction?: boolean;\n showRotateButton?: boolean;\n segments?: PdfSegment[];\n segmentTooltipText?: string;\n onCurrentPageChange?: (pageNumber: number) => void;\n navigationRequest?: PdfNavigationRequest | null;\n onNavigationSettled?: (event: PdfNavigationSettledEvent) => void;\n disablePdfAnnotations?: boolean;\n disablePdfTextLayer?: boolean;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n}\n\nconst getResolvedScale = (\n scale?: PdfScaleOption\n): SpecialZoomLevel | number => {\n switch (scale) {\n case \"ActualSize\":\n return SpecialZoomLevel.ActualSize;\n\n case \"PageFit\":\n return SpecialZoomLevel.PageFit;\n\n case \"PageWidth\":\n return SpecialZoomLevel.PageWidth;\n\n default:\n return scale ?? SpecialZoomLevel.PageWidth;\n }\n};\n\nexport type HighlightArea = {\n pageIndex: number;\n left: number;\n top: number;\n width: number;\n height: number;\n pageNumber?: number;\n};\n\nconst PdfViewer = ({\n pdfUrl,\n highlightText,\n highlightPages,\n highlightCordinatePages,\n highlightColor = \"yellow\",\n activeHighlightColor = \"#f7dc51\",\n jumpToPageValue = 0,\n pdfName,\n onClose,\n customStyles,\n customClasses,\n customIcons,\n useCoordinates,\n fallbackPages,\n activeCitationIndex,\n onActiveCitationChange,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n defaultScale = SpecialZoomLevel.ActualSize,\n useRange = false,\n rangeOfPages = null,\n showFullScreenAction=true,\n showRotateButton = false,\n segments = [\n {\n title: \"Document 2\",\n start_page: 52,\n end_page: 52,\n page_count: 1,\n },\n ],\n segmentTooltipText,\n onCurrentPageChange,\n navigationRequest,\n onNavigationSettled,\n disablePdfAnnotations = false,\n disablePdfTextLayer = false,\n renderPage,\n setRenderRange,\n}: PdfViewerProps) => {\n\n const viewerRef = useRef<HTMLDivElement | null>(null);\n const resolvedDefaultScale = getResolvedScale(defaultScale);\n const [currentPage, setCurrentPage] = useState(0);\n const [totalPages, setTotalPages] = useState(0);\n const [currentPageRotation, setCurrentPageRotation] = useState(0);\n const lastNavigationRequestRef = useRef<string | null>(null);\n const navigationSettleTimerRef = useRef<number | null>(null);\n const navigationSettleSequenceRef = useRef(0);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n\n // Generate PDF identifier for localStorage from URL\n const pdfIdentifier = useMemo(() => {\n if (!pdfUrl) return '';\n // Use last part of URL or hash it\n try {\n const url = new URL(pdfUrl, window.location.origin);\n return url.pathname.split('/').pop() || 'default';\n } catch {\n return 'default';\n }\n }, [pdfUrl]);\n\n // Set up rotation manager with PDF identifier\n useEffect(() => {\n if (pdfIdentifier) {\n rotationManager.setPdfIdentifier(pdfIdentifier);\n }\n }, [pdfIdentifier]);\n\n // Handler for rotating current page (no state update)\n const handleRotatePage = () => {\n const pageNumber = currentPage + 1;\n rotationManager.rotatePageBy90(pageNumber);\n // Manually update state to reflect rotation in UI\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n };\n\n // Subscribe to rotation changes to sync UI state\n useEffect(() => {\n const unsubscribe = rotationManager.onRotationChange((pageNum, angle) => {\n // Only update state if current page rotated\n if (pageNum === currentPage + 1) {\n setCurrentPageRotation(angle);\n }\n });\n\n return unsubscribe;\n }, [currentPage]);\n\n // Register page elements with rotation manager\n useEffect(() => {\n const observer = new MutationObserver(() => {\n // Find all newly rendered page elements\n const pageElements = viewerRef.current?.querySelectorAll(\n '[data-testid^=\"core__page-layer-\"]'\n );\n\n const registeredPages = new Set<number>();\n\n pageElements?.forEach((pageElement) => {\n const match = (pageElement as HTMLElement)\n .getAttribute('data-testid')\n ?.match(/core__page-layer-(\\d+)/);\n if (match && match.length >= 2) {\n const pageIndex = parseInt(match[1], 10);\n const pageNumber = pageIndex + 1;\n\n // Only register once per page\n if (!registeredPages.has(pageNumber)) {\n rotationManager.registerPageElement(pageNumber, pageElement as HTMLElement);\n registeredPages.add(pageNumber);\n }\n }\n });\n });\n\n if (viewerRef.current) {\n observer.observe(viewerRef.current, {\n childList: true,\n subtree: true,\n attributes: false,\n });\n mutationObserverRef.current = observer;\n }\n\n return () => {\n observer.disconnect();\n mutationObserverRef.current = null;\n };\n }, []);\n\n // Clean up when unmounting\n useEffect(() => {\n return () => {\n rotationManager.clearAll();\n if (mutationObserverRef.current) {\n mutationObserverRef.current.disconnect();\n }\n };\n }, []);\n\n // Update current page rotation when page changes\n useEffect(() => {\n const pageNumber = currentPage + 1;\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n }, [currentPage]);\n const resolvedRenderPage = useMemo<RenderPage | undefined>(() => {\n if (!disablePdfAnnotations && !disablePdfTextLayer) return renderPage;\n\n return (props) => {\n const resolvedTextLayerChildren = disablePdfTextLayer ? (\n <div aria-hidden=\"true\" style={{ display: \"none\" }}>\n {props.textLayer.children}\n </div>\n ) : props.textLayer.children;\n const resolvedProps = {\n ...props,\n annotationLayer: {\n ...props.annotationLayer,\n children: disablePdfAnnotations ? null : props.annotationLayer.children,\n },\n textLayer: {\n ...props.textLayer,\n children: resolvedTextLayerChildren,\n },\n };\n\n const renderedPage = renderPage\n ? renderPage(resolvedProps)\n : (\n <>\n {props.canvasLayer.children}\n {resolvedTextLayerChildren}\n {!disablePdfAnnotations && props.annotationLayer.children}\n </>\n );\n\n return renderedPage;\n };\n }, [disablePdfAnnotations, disablePdfTextLayer, renderPage]);\n\n const cleanHighlightTexts = (texts: string[]): string[] => {\n if (!texts || texts.length === 0) return texts;\n return texts.filter((text) => {\n return !texts.some(\n (otherText) => otherText !== text && otherText.includes(text)\n );\n });\n };\n\n const highlightPageSet = useMemo(() => {\n if (useCoordinates) {\n return new Set(highlightCordinatePages.map((h: any) => h.pageIndex));\n } else {\n const set = new Set<number>();\n Object.values(highlightPages).forEach((p: any) => {\n if (p > 0) set.add(p - 1);\n });\n return set;\n }\n }, [highlightCordinatePages, highlightPages, useCoordinates]);\n\n const removeRedundantHighlightTexts = cleanHighlightTexts(highlightText);\n\n const {\n highlightIndex,\n setHighlightIndex,\n cursorIndex,\n setCursorIndex,\n orderedKeys,\n totalHighlights,\n getValidPosition,\n tryJump,\n jumpToPage,\n zoomTo,\n plugins,\n controls,\n hideNonTargetHighlights,\n deduplicateHighlights,\n scrollToCoord,\n } = PdfHighlightControls(\n removeRedundantHighlightTexts,\n !useCoordinates ? highlightPages : {},\n viewerRef,\n highlightPageSet,\n useCoordinates,\n useCoordinates ? highlightCordinatePages : [],\n highlightColor,\n activeHighlightColor\n );\n\n const currentPosition = getValidPosition(cursorIndex);\n const currentSegment = useMemo(() => {\n const pageNumber = currentPage + 1;\n return segments.find(\n (segment) =>\n pageNumber >= segment.start_page && pageNumber <= segment.end_page\n );\n }, [currentPage, segments]);\n\n // sync external activeCitationIndex → cursorIndex\n useEffect(() => {\n if (activeCitationIndex === undefined) return;\n if (activeCitationIndex === cursorIndex) return;\n setCursorIndex(activeCitationIndex);\n }, [activeCitationIndex]);\n\n // wrap controls to fire onActiveCitationChange\n const handleGoToNext = () => {\n if (cursorIndex >= totalHighlights - 1) return;\n controls.goToNext();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex + 1);\n };\n\n const handleGoToPrevious = () => {\n if (cursorIndex <= 0) return;\n controls.goToPrevious();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex - 1);\n };\n\n const modifiedControls = {\n ...controls,\n goToNext: handleGoToNext,\n goToPrevious: handleGoToPrevious,\n };\n\n const handlePageNavigate = (pageNumber: number) => {\n const nextPage = Math.min(Math.max(pageNumber, 1), totalPages || pageNumber);\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n };\n\n const waitForNavigationToSettle = React.useCallback((\n request: PdfNavigationRequest,\n pageNumber: number\n ) => {\n navigationSettleSequenceRef.current += 1;\n const settleSequence = navigationSettleSequenceRef.current;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n\n let previousScrollTop: number | null = null;\n let stableChecks = 0;\n let attempts = 0;\n\n const checkScrollPosition = () => {\n if (navigationSettleSequenceRef.current !== settleSequence) return;\n\n attempts += 1;\n\n const scrollContainer = viewerRef.current?.querySelector(\n '.rpv-core__inner-pages'\n ) as HTMLElement | null;\n const targetPage = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${pageNumber - 1}\"]`\n ) as HTMLElement | null;\n\n // Virtualized page layers are not guaranteed to be mounted on the first\n // check after jumpToPage. Keep polling so navigation completion is not\n // lost while React PDF Viewer is creating the target page DOM.\n if (!scrollContainer || !targetPage) {\n if (attempts >= 40) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n return;\n }\n\n if (previousScrollTop === scrollContainer.scrollTop) {\n stableChecks += 1;\n } else {\n previousScrollTop = scrollContainer.scrollTop;\n stableChecks = 0;\n }\n\n const scrollRect = scrollContainer.getBoundingClientRect();\n const pageRect = targetPage.getBoundingClientRect();\n const isTargetVisible = Boolean(\n scrollRect &&\n pageRect &&\n pageRect.bottom > scrollRect.top &&\n pageRect.top < scrollRect.bottom\n );\n const hasSettled = stableChecks >= 2 && isTargetVisible;\n const reachedTimeout = attempts >= 40;\n\n if (hasSettled || reachedTimeout) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n };\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n }, [onNavigationSettled]);\n\n useEffect(() => () => {\n navigationSettleSequenceRef.current += 1;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n }, []);\n\n useEffect(() => {\n if (!navigationRequest || totalPages <= 0) return;\n\n const nextPage = Math.min(\n Math.max(Math.trunc(navigationRequest.pageNumber), 1),\n totalPages\n );\n const requestKey = `${navigationRequest.requestId ?? nextPage}:${nextPage}`;\n if (lastNavigationRequestRef.current === requestKey) return;\n\n lastNavigationRequestRef.current = requestKey;\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n waitForNavigationToSettle(navigationRequest, nextPage);\n }, [jumpToPage, navigationRequest, totalPages, waitForNavigationToSettle]);\n\n if (!pdfUrl) {\n return (\n <ScannedDocCitation\n pages={fallbackPages}\n activeCitationIndex={activeCitationIndex}\n onActiveCitationChange={onActiveCitationChange}\n headerAction={headerAction}\n />\n );\n }\n\n const defaultViewerStyles: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n height: \"100%\",\n width: \"100%\",\n backgroundColor: \"#FAFAFA\",\n };\n\n const scrollToHighlight = () => {\n if (!viewerRef.current) return;\n\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const targetPage = page > 0 ? page - 1 : 0;\n\n const pageVisitMap: Record<number, number[]> = {};\n orderedKeys.forEach((k, i) => {\n const p = highlightPages[k];\n if (p > 0) {\n if (!pageVisitMap[p]) pageVisitMap[p] = [];\n pageVisitMap[p].push(i);\n }\n });\n const visits = pageVisitMap[page] || [];\n const occurrence = visits.indexOf(index);\n\n let attempts = 0;\n const maxAttempts = 40;\n\n const doScrollToHighlight = () => {\n attempts++;\n if (attempts > maxAttempts) return;\n\n const scrollContainer = viewerRef.current?.querySelector(\n \".rpv-core__inner-pages\"\n ) as HTMLElement;\n if (!scrollContainer) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const pageElement = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${targetPage}\"]`\n );\n if (!pageElement) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const scrollContainerRect = scrollContainer.getBoundingClientRect();\n const pageRect = pageElement.getBoundingClientRect();\n const isPageVisible =\n pageRect.top < scrollContainerRect.bottom &&\n pageRect.bottom > scrollContainerRect.top;\n\n if (!isPageVisible) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const allHighlights = pageElement.querySelectorAll(\".rpv-search__highlight\");\n const target = allHighlights[occurrence] as HTMLElement;\n\n if (!target) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const highlightRect = target.getBoundingClientRect();\n const scrollTop =\n scrollContainer.scrollTop +\n (highlightRect.top - scrollContainerRect.top) -\n scrollContainer.clientHeight / 2 +\n highlightRect.height / 2;\n\n scrollContainer.scrollTo({ top: scrollTop, behavior: \"smooth\" });\n };\n\n setTimeout(doScrollToHighlight, 500);\n };\n\n return (\n <div\n ref={viewerRef}\n className={customClasses?.pdfViewerWrapper || \"\"}\n data-disable-pdf-annotations={\n disablePdfAnnotations ? \"true\" : undefined\n }\n data-pdf-page-fit={\n resolvedDefaultScale === SpecialZoomLevel.PageFit ? \"true\" : undefined\n }\n style={{\n height: \"100%\",\n minHeight: 0,\n minWidth: 0,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n ...pdfStyles.pdfViewer,\n ...defaultViewerStyles,\n ...customStyles?.pdfViewer,\n backgroundColor: \"#F1F5F9\",\n }}\n >\n <PdfToolbar\n highlightIndex={highlightIndex}\n totalHighlights={totalHighlights}\n controls={modifiedControls}\n currentPosition={currentPosition}\n pdfName={pdfName}\n onClose={onClose}\n pdfUrl={pdfUrl}\n viewerRef={viewerRef}\n customStyles={customStyles}\n customClasses={customClasses}\n customIcons={customIcons}\n headerAction={headerAction}\n isZoomEnabled={isZoomEnabled}\n showHighlightsAction={showHighlightsAction}\n showFullScreenAction={showFullScreenAction} \n currentSegment={currentSegment}\n segmentTooltipText={segmentTooltipText}\n currentPage={currentPage + 1}\n totalPages={totalPages}\n onPageNavigate={handlePageNavigate}\n onRotatePage={handleRotatePage}\n currentPageRotation={currentPageRotation}\n showRotateButton={showRotateButton}\n />\n <PdfContainer\n defaultScale={resolvedDefaultScale}\n pdfUrl={pdfUrl}\n plugins={plugins}\n customStyles={customStyles}\n onLoad={(e: DocumentLoadEvent) => {\n setTotalPages(e.doc.numPages);\n\n const shouldAutoJumpToFirstMatch =\n !useCoordinates && !useRange && jumpToPageValue <= 0;\n\n if (jumpToPageValue > 0 && !useRange) {\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const cordinateTargetHighlight = highlightCordinatePages[index];\n setCursorIndex(index);\n\n console.log(cordinateTargetHighlight, \"cordinateTargetHighlight\");\n if (useCoordinates && cordinateTargetHighlight.pageIndex > 0)\n jumpToPage(cordinateTargetHighlight.pageIndex);\n\n if (page > 0) {\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(page - 1);\n }, 1000);\n if (!useCoordinates) {\n jumpToPage(page - 1);\n }\n }\n } else if (useRange && rangeOfPages && rangeOfPages.length === 2) {\n \n // Async function to handle sequential jumping and waiting\n const scanRangeSequence = async () => {\n const [startPage, endPage] = rangeOfPages;\n \n for (let p = startPage; p <= endPage; p++) {\n const targetPageIndex = p - 1;\n \n jumpToPage(targetPageIndex);\n \n // Pause execution for 1 second to let the DOM render the highlights\n await new Promise((resolve) => setTimeout(resolve, 1000));\n \n hideNonTargetHighlights(highlightPageSet);\n const matchSize = deduplicateHighlights(targetPageIndex);\n \n // If the returned size is greater than 0, a match was found. Stop the loop.\n if (matchSize && matchSize > 0) {\n break; \n }\n }\n };\n\n scanRangeSequence();\n\n } else if (!useCoordinates && highlightPages) {\n const firstKey = orderedKeys.find(k => highlightPages[k] > 0);\n if (firstKey !== undefined) {\n const firstPage = highlightPages[firstKey] - 1;\n jumpToPage(firstPage);\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(firstPage);\n }, 1000);\n }\n }\n\n requestAnimationFrame(() => {\n if (shouldAutoJumpToFirstMatch) {\n tryJump();\n }\n if (!useCoordinates && jumpToPageValue > 0 && !useRange) {\n scrollToHighlight();\n }\n });\n }}\n onPageChange={(e: PageChangeEvent) => {\n const currentPage = e.currentPage;\n setCurrentPage(currentPage);\n onCurrentPageChange?.(currentPage + 1);\n if (!highlightPageSet.has(currentPage)) {\n hideNonTargetHighlights(highlightPageSet);\n return;\n }\n deduplicateHighlights(currentPage);\n hideNonTargetHighlights(highlightPageSet);\n }}\n renderPage={resolvedRenderPage}\n setRenderRange={setRenderRange}\n />\n </div>\n );\n};\n\nexport default PdfViewer;\n"],"names":["pdfUrl","highlightText","highlightPages","highlightCordinatePages","highlightColor","activeHighlightColor","jumpToPageValue","pdfName","onClose","customStyles","customClasses","customIcons","useCoordinates","fallbackPages","activeCitationIndex","onActiveCitationChange","headerAction","isZoomEnabled","showHighlightsAction","defaultScale","SpecialZoomLevel","ActualSize","useRange","rangeOfPages","showFullScreenAction","showRotateButton","segments","title","start_page","end_page","page_count","segmentTooltipText","onCurrentPageChange","navigationRequest","onNavigationSettled","disablePdfAnnotations","disablePdfTextLayer","renderPage","setRenderRange","viewerRef","useRef","resolvedDefaultScale","scale","PageFit","PageWidth","getResolvedScale","currentPage","setCurrentPage","useState","totalPages","setTotalPages","currentPageRotation","setCurrentPageRotation","lastNavigationRequestRef","navigationSettleTimerRef","navigationSettleSequenceRef","mutationObserverRef","pdfIdentifier","useMemo","URL","window","location","origin","pathname","split","pop","useEffect","rotationManager","setPdfIdentifier","onRotationChange","pageNum","angle","observer","MutationObserver","pageElements","current","querySelectorAll","registeredPages","Set","forEach","pageElement","match","getAttribute","length","pageNumber","parseInt","has","registerPageElement","add","observe","childList","subtree","attributes","disconnect","clearAll","getRotation","resolvedRenderPage","props","resolvedTextLayerChildren","jsx","style","display","children","textLayer","resolvedProps","annotationLayer","jsxs","Fragment","canvasLayer","highlightPageSet","map","h","pageIndex","set","Object","values","p","removeRedundantHighlightTexts","texts","filter","text","some","otherText","includes","highlightIndex","setHighlightIndex","cursorIndex","setCursorIndex","orderedKeys","totalHighlights","getValidPosition","tryJump","jumpToPage","zoomTo","plugins","controls","hideNonTargetHighlights","deduplicateHighlights","scrollToCoord","PdfHighlightControls","currentPosition","currentSegment","find","segment","modifiedControls","goToNext","goToPrevious","waitForNavigationToSettle","React","useCallback","request","settleSequence","clearTimeout","previousScrollTop","stableChecks","attempts","checkScrollPosition","scrollContainer","querySelector","targetPage","requestId","setTimeout","scrollTop","scrollRect","getBoundingClientRect","pageRect","isTargetVisible","Boolean","bottom","top","nextPage","Math","min","max","trunc","requestKey","ScannedDocCitation","pages","ref","className","pdfViewerWrapper","height","minHeight","minWidth","overflow","flexDirection","pdfStyles","pdfViewer","width","backgroundColor","PdfToolbar","onPageNavigate","onRotatePage","rotatePageBy90","PdfContainer","onLoad","e","doc","numPages","shouldAutoJumpToFirstMatch","index","key","page","cordinateTargetHighlight","console","log","async","startPage","endPage","targetPageIndex","Promise","resolve","matchSize","scanRangeSequence","firstKey","k","firstPage","requestAnimationFrame","pageVisitMap","i","push","occurrence","indexOf","doScrollToHighlight","scrollContainerRect","target","highlightRect","clientHeight","scrollTo","behavior","scrollToHighlight","onPageChange"],"mappings":"guBA+HkB,EAChBA,SACAC,gBACAC,iBACAC,0BACAC,iBAAiB,SACjBC,uBAAuB,UACvBC,kBAAkB,EAClBC,UACAC,UACAC,eACAC,gBACAC,cACAC,iBACAC,gBACAC,sBACAC,yBACAC,eACAC,iBAAgB,EAChBC,wBAAuB,EACvBC,eAAeC,EAAiBA,iBAAAC,WAChCC,YAAW,EACXC,eAAe,KACfC,wBAAqB,EACrBC,oBAAmB,EACnBC,WAAW,CACT,CACEC,MAAO,aACPC,WAAY,GACZC,SAAU,GACVC,WAAY,IAGhBC,qBACAC,sBACAC,oBACAC,sBACAC,yBAAwB,EACxBC,uBAAsB,EACtBC,aACAC,qBAGM,MAAAC,EAAYC,SAA8B,MAC1CC,EAvEiB,CACvBC,IAEA,OAAQA,GACN,IAAK,aACH,OAAOtB,EAAAA,iBAAiBC,WAE1B,IAAK,UACH,OAAOD,EAAAA,iBAAiBuB,QAE1B,IAAK,YACH,OAAOvB,EAAAA,iBAAiBwB,UAE1B,QACE,OAAOF,GAAStB,EAAiBA,iBAAAwB,YAyDRC,CAAiB1B,IACvC2B,EAAaC,GAAkBC,WAAS,IACxCC,EAAYC,GAAiBF,WAAS,IACtCG,EAAqBC,GAA0BJ,WAAS,GACzDK,EAA2Bb,SAAsB,MACjDc,EAA2Bd,SAAsB,MACjDe,EAA8Bf,SAAO,GACrCgB,GAAsBhB,SAAgC,MAGtDiB,GAAgBC,EAAAA,QAAQ,KACxB,IAAC1D,EAAe,MAAA,GAEhB,IAEF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P,EAAWmE,SAAU,YAGvDpE,WAAW8D,EAAqB,MA6HJO,MAIxBC,aAAenC,IACb,MAAMtJ,EAAcsJ,EAAEtJ,YACtBC,EAAeD,GACfd,IAAsBc,EAAc,GAC/B+D,GAAiBvB,IAAIxC,IAI1B2F,GAAsB3F,GACtB0F,GAAwB3B,KAJtB2B,GAAwB3B,KAM5BxE,WAAY2D,GACZ1D"}
|
|
1
|
+
{"version":3,"file":"PdfViewer.js","sources":["../../../../src/features/PdfViewer/PdfViewer.tsx"],"sourcesContent":["import { DocumentLoadEvent, PageChangeEvent, RenderPage, SetRenderRange, SpecialZoomLevel } from \"@react-pdf-viewer/core\";\nimport PdfContainer from \"./PdfContainer\";\nimport PdfToolbar from \"./PdfToolbar\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { PdfHighlightControls } from \"./usePdfHighlight\";\nimport { rotationManager } from \"./rotationManager\";\nimport \"@react-pdf-viewer/zoom/lib/styles/index.css\";\nimport \"@react-pdf-viewer/page-navigation/lib/styles/index.css\";\nimport \"@react-pdf-viewer/core/lib/styles/index.css\";\nimport \"@react-pdf-viewer/search/lib/styles/index.css\";\nimport React, { useMemo, useRef, useEffect, useState } from \"react\";\nimport ScannedDocCitation, { CitationPage } from \"../ScannedDocCitation/ScannedDocCitation\";\nimport \"./PdfViewer.css\";\n\nexport type CustomIconsType = {\n pdfIcon?: React.ReactNode;\n fullScreenIcon?: React.ReactNode;\n downloadIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n};\n\nexport type CustomStylesType = {\n pdfViewer?: React.CSSProperties;\n header?: React.CSSProperties;\n pdfIconWrapper?: React.CSSProperties;\n pdfName?: React.CSSProperties;\n pdfContainer?: React.CSSProperties;\n emptyState?: React.CSSProperties;\n};\n\nexport type CustomClassesType = {\n header?: string;\n pdfName?: string;\n actionButton?: string;\n pdfViewerWrapper?: string;\n};\n\nexport type PdfSegment = {\n title: string;\n start_page: number;\n end_page: number;\n page_count: number;\n};\n\ntype PdfScaleOption =\n | \"ActualSize\"\n | \"PageFit\"\n | \"PageWidth\"\n | number;\nexport interface PdfNavigationRequest {\n pageNumber: number;\n /** Change this value to navigate to the same page more than once. */\n requestId?: string | number;\n}\n\nexport interface PdfNavigationSettledEvent extends PdfNavigationRequest {\n pageNumber: number;\n}\n\nexport interface PdfViewerProps {\n pdfUrl?: string;\n highlightText: string[];\n highlightPages?: any;\n highlightCordinatePages: HighlightArea[];\n highlightColor?: string;\n activeHighlightColor?: string;\n jumpToPageValue?: number;\n pdfName?: string;\n onClose?: () => void;\n item?: any;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n useCoordinates: boolean;\n fallbackPages?: CitationPage[];\n activeCitationIndex?: number;\n onActiveCitationChange?: (index: number) => void;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled?: boolean;\n showHighlightsAction?: boolean;\n defaultScale?: PdfScaleOption;\n useRange?: boolean; //\n rangeOfPages?: number[] | null;\n showFullScreenAction?: boolean;\n showRotateButton?: boolean;\n segments?: PdfSegment[];\n segmentTooltipText?: string;\n onCurrentPageChange?: (pageNumber: number) => void;\n navigationRequest?: PdfNavigationRequest | null;\n onNavigationSettled?: (event: PdfNavigationSettledEvent) => void;\n disablePdfAnnotations?: boolean;\n disablePdfTextLayer?: boolean;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n}\n\nconst getResolvedScale = (\n scale?: PdfScaleOption\n): SpecialZoomLevel | number => {\n switch (scale) {\n case \"ActualSize\":\n return SpecialZoomLevel.ActualSize;\n\n case \"PageFit\":\n return SpecialZoomLevel.PageFit;\n\n case \"PageWidth\":\n return SpecialZoomLevel.PageWidth;\n\n default:\n return scale ?? SpecialZoomLevel.PageWidth;\n }\n};\n\nexport type HighlightArea = {\n pageIndex: number;\n left: number;\n top: number;\n width: number;\n height: number;\n pageNumber?: number;\n};\n\nconst PdfViewer = ({\n pdfUrl,\n highlightText,\n highlightPages,\n highlightCordinatePages,\n highlightColor = \"yellow\",\n activeHighlightColor = \"#f7dc51\",\n jumpToPageValue = 0,\n pdfName,\n onClose,\n customStyles,\n customClasses,\n customIcons,\n useCoordinates,\n fallbackPages,\n activeCitationIndex,\n onActiveCitationChange,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n defaultScale = SpecialZoomLevel.ActualSize,\n useRange = false,\n rangeOfPages = null,\n showFullScreenAction=true,\n showRotateButton = false,\n segments = [\n {\n title: \"Document 2\",\n start_page: 52,\n end_page: 52,\n page_count: 1,\n },\n ],\n segmentTooltipText,\n onCurrentPageChange,\n navigationRequest,\n onNavigationSettled,\n disablePdfAnnotations = false,\n disablePdfTextLayer = false,\n renderPage,\n setRenderRange,\n}: PdfViewerProps) => {\n\n const viewerRef = useRef<HTMLDivElement | null>(null);\n const resolvedDefaultScale = getResolvedScale(defaultScale);\n const [currentPage, setCurrentPage] = useState(0);\n const [totalPages, setTotalPages] = useState(0);\n const [currentPageRotation, setCurrentPageRotation] = useState(0);\n const lastNavigationRequestRef = useRef<string | null>(null);\n const navigationSettleTimerRef = useRef<number | null>(null);\n const navigationSettleSequenceRef = useRef(0);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n\n // Generate PDF identifier for localStorage from URL\n const pdfIdentifier = useMemo(() => {\n if (!pdfUrl) return '';\n // Use last part of URL or hash it\n try {\n const url = new URL(pdfUrl, window.location.origin);\n return url.pathname.split('/').pop() || 'default';\n } catch {\n return 'default';\n }\n }, [pdfUrl]);\n\n // Set up rotation manager with PDF identifier\n useEffect(() => {\n if (pdfIdentifier) {\n rotationManager.setPdfIdentifier(pdfIdentifier);\n }\n }, [pdfIdentifier]);\n\n // Handler for rotating current page (no state update)\n const handleRotatePage = () => {\n const pageNumber = currentPage + 1;\n rotationManager.rotatePageBy90(pageNumber);\n // Manually update state to reflect rotation in UI\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n };\n\n // Subscribe to rotation changes to sync UI state\n useEffect(() => {\n const unsubscribe = rotationManager.onRotationChange((pageNum, angle) => {\n // Only update state if current page rotated\n if (pageNum === currentPage + 1) {\n setCurrentPageRotation(angle);\n }\n });\n\n return unsubscribe;\n }, [currentPage]);\n\n // Register page elements with rotation manager\n useEffect(() => {\n const observer = new MutationObserver(() => {\n // Find all newly rendered page elements\n const pageElements = viewerRef.current?.querySelectorAll(\n '[data-testid^=\"core__page-layer-\"]'\n );\n\n const registeredPages = new Set<number>();\n\n pageElements?.forEach((pageElement) => {\n const match = (pageElement as HTMLElement)\n .getAttribute('data-testid')\n ?.match(/core__page-layer-(\\d+)/);\n if (match && match.length >= 2) {\n const pageIndex = parseInt(match[1], 10);\n const pageNumber = pageIndex + 1;\n\n // Only register once per page\n if (!registeredPages.has(pageNumber)) {\n rotationManager.registerPageElement(pageNumber, pageElement as HTMLElement);\n registeredPages.add(pageNumber);\n }\n }\n });\n });\n\n if (viewerRef.current) {\n observer.observe(viewerRef.current, {\n childList: true,\n subtree: true,\n attributes: false,\n });\n mutationObserverRef.current = observer;\n }\n\n return () => {\n observer.disconnect();\n mutationObserverRef.current = null;\n };\n }, []);\n\n // Clean up when unmounting\n useEffect(() => {\n return () => {\n rotationManager.clearAll();\n if (mutationObserverRef.current) {\n mutationObserverRef.current.disconnect();\n }\n };\n }, []);\n\n // Update current page rotation when page changes\n useEffect(() => {\n const pageNumber = currentPage + 1;\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n }, [currentPage]);\n const resolvedRenderPage = useMemo<RenderPage | undefined>(() => {\n if (!disablePdfAnnotations && !disablePdfTextLayer) return renderPage;\n\n return (props) => {\n const resolvedTextLayerChildren = disablePdfTextLayer ? (\n <div aria-hidden=\"true\" style={{ display: \"none\" }}>\n {props.textLayer.children}\n </div>\n ) : props.textLayer.children;\n const resolvedProps = {\n ...props,\n annotationLayer: {\n ...props.annotationLayer,\n children: disablePdfAnnotations ? null : props.annotationLayer.children,\n },\n textLayer: {\n ...props.textLayer,\n children: resolvedTextLayerChildren,\n },\n };\n\n const renderedPage = renderPage\n ? renderPage(resolvedProps)\n : (\n <>\n {props.canvasLayer.children}\n {resolvedTextLayerChildren}\n {!disablePdfAnnotations && props.annotationLayer.children}\n </>\n );\n\n return renderedPage;\n };\n }, [disablePdfAnnotations, disablePdfTextLayer, renderPage]);\n\n const cleanHighlightTexts = (texts: string[]): string[] => {\n if (!texts || texts.length === 0) return texts;\n return texts.filter((text) => {\n return !texts.some(\n (otherText) => otherText !== text && otherText.includes(text)\n );\n });\n };\n\n const highlightPageSet = useMemo(() => {\n if (useCoordinates) {\n return new Set(highlightCordinatePages.map((h: any) => h.pageIndex));\n } else {\n const set = new Set<number>();\n Object.values(highlightPages).forEach((p: any) => {\n if (p > 0) set.add(p - 1);\n });\n return set;\n }\n }, [highlightCordinatePages, highlightPages, useCoordinates]);\n\n const removeRedundantHighlightTexts = cleanHighlightTexts(highlightText);\n\n const {\n highlightIndex,\n setHighlightIndex,\n cursorIndex,\n setCursorIndex,\n orderedKeys,\n totalHighlights,\n getValidPosition,\n tryJump,\n jumpToPage,\n zoomTo,\n plugins,\n controls,\n hideNonTargetHighlights,\n deduplicateHighlights,\n scrollToCoord,\n } = PdfHighlightControls(\n removeRedundantHighlightTexts,\n !useCoordinates ? highlightPages : {},\n viewerRef,\n highlightPageSet,\n useCoordinates,\n useCoordinates ? highlightCordinatePages : [],\n highlightColor,\n activeHighlightColor\n );\n\n const currentPosition = getValidPosition(cursorIndex);\n const currentSegment = useMemo(() => {\n const pageNumber = currentPage + 1;\n return segments.find(\n (segment) =>\n pageNumber >= segment.start_page && pageNumber <= segment.end_page\n );\n }, [currentPage, segments]);\n\n // sync external activeCitationIndex → cursorIndex\n useEffect(() => {\n if (activeCitationIndex === undefined) return;\n if (activeCitationIndex === cursorIndex) return;\n setCursorIndex(activeCitationIndex);\n }, [activeCitationIndex]);\n\n // wrap controls to fire onActiveCitationChange\n const handleGoToNext = () => {\n if (cursorIndex >= totalHighlights - 1) return;\n controls.goToNext();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex + 1);\n };\n\n const handleGoToPrevious = () => {\n if (cursorIndex <= 0) return;\n controls.goToPrevious();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex - 1);\n };\n\n const modifiedControls = {\n ...controls,\n goToNext: handleGoToNext,\n goToPrevious: handleGoToPrevious,\n };\n\n const handlePageNavigate = (pageNumber: number) => {\n const nextPage = Math.min(Math.max(pageNumber, 1), totalPages || pageNumber);\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n };\n\n const waitForNavigationToSettle = React.useCallback((\n request: PdfNavigationRequest,\n pageNumber: number\n ) => {\n navigationSettleSequenceRef.current += 1;\n const settleSequence = navigationSettleSequenceRef.current;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n\n let previousScrollTop: number | null = null;\n let stableChecks = 0;\n let attempts = 0;\n\n const checkScrollPosition = () => {\n if (navigationSettleSequenceRef.current !== settleSequence) return;\n\n attempts += 1;\n\n const scrollContainer = viewerRef.current?.querySelector(\n '.rpv-core__inner-pages'\n ) as HTMLElement | null;\n const targetPage = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${pageNumber - 1}\"]`\n ) as HTMLElement | null;\n\n // Virtualized page layers are not guaranteed to be mounted on the first\n // check after jumpToPage. Keep polling so navigation completion is not\n // lost while React PDF Viewer is creating the target page DOM.\n if (!scrollContainer || !targetPage) {\n if (attempts >= 40) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n return;\n }\n\n if (previousScrollTop === scrollContainer.scrollTop) {\n stableChecks += 1;\n } else {\n previousScrollTop = scrollContainer.scrollTop;\n stableChecks = 0;\n }\n\n const scrollRect = scrollContainer.getBoundingClientRect();\n const pageRect = targetPage.getBoundingClientRect();\n const isTargetVisible = Boolean(\n scrollRect &&\n pageRect &&\n pageRect.bottom > scrollRect.top &&\n pageRect.top < scrollRect.bottom\n );\n const hasSettled = stableChecks >= 2 && isTargetVisible;\n const reachedTimeout = attempts >= 40;\n\n if (hasSettled || reachedTimeout) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n };\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n }, [onNavigationSettled]);\n\n useEffect(() => () => {\n navigationSettleSequenceRef.current += 1;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n }, []);\n\n useEffect(() => {\n if (!navigationRequest || totalPages <= 0) return;\n\n const nextPage = Math.min(\n Math.max(Math.trunc(navigationRequest.pageNumber), 1),\n totalPages\n );\n const requestKey = `${navigationRequest.requestId ?? nextPage}:${nextPage}`;\n if (lastNavigationRequestRef.current === requestKey) return;\n\n lastNavigationRequestRef.current = requestKey;\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n waitForNavigationToSettle(navigationRequest, nextPage);\n }, [jumpToPage, navigationRequest, totalPages, waitForNavigationToSettle]);\n\n if (!pdfUrl) {\n return (\n <ScannedDocCitation\n pages={fallbackPages}\n activeCitationIndex={activeCitationIndex}\n onActiveCitationChange={onActiveCitationChange}\n headerAction={headerAction}\n />\n );\n }\n\n const defaultViewerStyles: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n height: \"100%\",\n width: \"100%\",\n backgroundColor: \"#FAFAFA\",\n };\n\n const scrollToHighlight = () => {\n if (!viewerRef.current) return;\n\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const targetPage = page > 0 ? page - 1 : 0;\n\n const pageVisitMap: Record<number, number[]> = {};\n orderedKeys.forEach((k, i) => {\n const p = highlightPages[k];\n if (p > 0) {\n if (!pageVisitMap[p]) pageVisitMap[p] = [];\n pageVisitMap[p].push(i);\n }\n });\n const visits = pageVisitMap[page] || [];\n const occurrence = visits.indexOf(index);\n\n let attempts = 0;\n const maxAttempts = 40;\n\n const doScrollToHighlight = () => {\n attempts++;\n if (attempts > maxAttempts) return;\n\n const scrollContainer = viewerRef.current?.querySelector(\n \".rpv-core__inner-pages\"\n ) as HTMLElement;\n if (!scrollContainer) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const pageElement = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${targetPage}\"]`\n );\n if (!pageElement) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const scrollContainerRect = scrollContainer.getBoundingClientRect();\n const pageRect = pageElement.getBoundingClientRect();\n const isPageVisible =\n pageRect.top < scrollContainerRect.bottom &&\n pageRect.bottom > scrollContainerRect.top;\n\n if (!isPageVisible) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const allHighlights = pageElement.querySelectorAll(\".rpv-search__highlight\");\n const target = allHighlights[occurrence] as HTMLElement;\n\n if (!target) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const highlightRect = target.getBoundingClientRect();\n const scrollTop =\n scrollContainer.scrollTop +\n (highlightRect.top - scrollContainerRect.top) -\n scrollContainer.clientHeight / 2 +\n highlightRect.height / 2;\n\n scrollContainer.scrollTo({ top: scrollTop, behavior: \"smooth\" });\n };\n\n setTimeout(doScrollToHighlight, 500);\n };\n\n return (\n <div\n ref={viewerRef}\n className={[\"citation-pdf-viewer\", customClasses?.pdfViewerWrapper]\n .filter(Boolean)\n .join(\" \")}\n data-disable-pdf-annotations={\n disablePdfAnnotations ? \"true\" : undefined\n }\n data-pdf-page-fit={\n resolvedDefaultScale === SpecialZoomLevel.PageFit ? \"true\" : undefined\n }\n style={{\n height: \"100%\",\n minHeight: 0,\n minWidth: 0,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n ...pdfStyles.pdfViewer,\n ...defaultViewerStyles,\n ...customStyles?.pdfViewer,\n backgroundColor: \"#F1F5F9\",\n }}\n >\n <PdfToolbar\n highlightIndex={highlightIndex}\n totalHighlights={totalHighlights}\n controls={modifiedControls}\n currentPosition={currentPosition}\n pdfName={pdfName}\n onClose={onClose}\n pdfUrl={pdfUrl}\n viewerRef={viewerRef}\n customStyles={customStyles}\n customClasses={customClasses}\n customIcons={customIcons}\n headerAction={headerAction}\n isZoomEnabled={isZoomEnabled}\n showHighlightsAction={showHighlightsAction}\n showFullScreenAction={showFullScreenAction} \n currentSegment={currentSegment}\n segmentTooltipText={segmentTooltipText}\n currentPage={currentPage + 1}\n totalPages={totalPages}\n onPageNavigate={handlePageNavigate}\n onRotatePage={handleRotatePage}\n currentPageRotation={currentPageRotation}\n showRotateButton={showRotateButton}\n />\n <PdfContainer\n defaultScale={resolvedDefaultScale}\n pdfUrl={pdfUrl}\n plugins={plugins}\n customStyles={customStyles}\n onLoad={(e: DocumentLoadEvent) => {\n setTotalPages(e.doc.numPages);\n\n const shouldAutoJumpToFirstMatch =\n !useCoordinates && !useRange && jumpToPageValue <= 0;\n\n if (jumpToPageValue > 0 && !useRange) {\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const cordinateTargetHighlight = highlightCordinatePages[index];\n setCursorIndex(index);\n\n console.log(cordinateTargetHighlight, \"cordinateTargetHighlight\");\n if (useCoordinates && cordinateTargetHighlight.pageIndex > 0)\n jumpToPage(cordinateTargetHighlight.pageIndex);\n\n if (page > 0) {\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(page - 1);\n }, 1000);\n if (!useCoordinates) {\n jumpToPage(page - 1);\n }\n }\n } else if (useRange && rangeOfPages && rangeOfPages.length === 2) {\n \n // Async function to handle sequential jumping and waiting\n const scanRangeSequence = async () => {\n const [startPage, endPage] = rangeOfPages;\n \n for (let p = startPage; p <= endPage; p++) {\n const targetPageIndex = p - 1;\n \n jumpToPage(targetPageIndex);\n \n // Pause execution for 1 second to let the DOM render the highlights\n await new Promise((resolve) => setTimeout(resolve, 1000));\n \n hideNonTargetHighlights(highlightPageSet);\n const matchSize = deduplicateHighlights(targetPageIndex);\n \n // If the returned size is greater than 0, a match was found. Stop the loop.\n if (matchSize && matchSize > 0) {\n break; \n }\n }\n };\n\n scanRangeSequence();\n\n } else if (!useCoordinates && highlightPages) {\n const firstKey = orderedKeys.find(k => highlightPages[k] > 0);\n if (firstKey !== undefined) {\n const firstPage = highlightPages[firstKey] - 1;\n jumpToPage(firstPage);\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(firstPage);\n }, 1000);\n }\n }\n\n requestAnimationFrame(() => {\n if (shouldAutoJumpToFirstMatch) {\n tryJump();\n }\n if (!useCoordinates && jumpToPageValue > 0 && !useRange) {\n scrollToHighlight();\n }\n });\n }}\n onPageChange={(e: PageChangeEvent) => {\n const currentPage = e.currentPage;\n setCurrentPage(currentPage);\n onCurrentPageChange?.(currentPage + 1);\n if (!highlightPageSet.has(currentPage)) {\n hideNonTargetHighlights(highlightPageSet);\n return;\n }\n deduplicateHighlights(currentPage);\n hideNonTargetHighlights(highlightPageSet);\n }}\n renderPage={resolvedRenderPage}\n setRenderRange={setRenderRange}\n />\n </div>\n );\n};\n\nexport default PdfViewer;\n"],"names":["pdfUrl","highlightText","highlightPages","highlightCordinatePages","highlightColor","activeHighlightColor","jumpToPageValue","pdfName","onClose","customStyles","customClasses","customIcons","useCoordinates","fallbackPages","activeCitationIndex","onActiveCitationChange","headerAction","isZoomEnabled","showHighlightsAction","defaultScale","SpecialZoomLevel","ActualSize","useRange","rangeOfPages","showFullScreenAction","showRotateButton","segments","title","start_page","end_page","page_count","segmentTooltipText","onCurrentPageChange","navigationRequest","onNavigationSettled","disablePdfAnnotations","disablePdfTextLayer","renderPage","setRenderRange","viewerRef","useRef","resolvedDefaultScale","scale","PageFit","PageWidth","getResolvedScale","currentPage","setCurrentPage","useState","totalPages","setTotalPages","currentPageRotation","setCurrentPageRotation","lastNavigationRequestRef","navigationSettleTimerRef","navigationSettleSequenceRef","mutationObserverRef","pdfIdentifier","useMemo","URL","window","location","origin","pathname","split","pop","useEffect","rotationManager","setPdfIdentifier","onRotationChange","pageNum","angle","observer","MutationObserver","pageElements","current","querySelectorAll","registeredPages","Set","forEach","pageElement","match","getAttribute","length","pageNumber","parseInt","has","registerPageElement","add","observe","childList","subtree","attributes","disconnect","clearAll","getRotation","resolvedRenderPage","props","resolvedTextLayerChildren","jsx","style","display","children","textLayer","resolvedProps","annotationLayer","jsxs","Fragment","canvasLayer","highlightPageSet","map","h","pageIndex","set","Object","values","p","removeRedundantHighlightTexts","texts","filter","text","some","otherText","includes","highlightIndex","setHighlightIndex","cursorIndex","setCursorIndex","orderedKeys","totalHighlights","getValidPosition","tryJump","jumpToPage","zoomTo","plugins","controls","hideNonTargetHighlights","deduplicateHighlights","scrollToCoord","PdfHighlightControls","currentPosition","currentSegment","find","segment","modifiedControls","goToNext","goToPrevious","waitForNavigationToSettle","React","useCallback","request","settleSequence","clearTimeout","previousScrollTop","stableChecks","attempts","checkScrollPosition","scrollContainer","querySelector","targetPage","requestId","setTimeout","scrollTop","scrollRect","getBoundingClientRect","pageRect","isTargetVisible","Boolean","bottom","top","nextPage","Math","min","max","trunc","requestKey","ScannedDocCitation","pages","ref","className","pdfViewerWrapper","join","height","minHeight","minWidth","overflow","flexDirection","pdfStyles","pdfViewer","width","backgroundColor","PdfToolbar","onPageNavigate","onRotatePage","rotatePageBy90","PdfContainer","onLoad","e","doc","numPages","shouldAutoJumpToFirstMatch","index","key","page","cordinateTargetHighlight","console","log","async","startPage","endPage","targetPageIndex","Promise","resolve","matchSize","scanRangeSequence","firstKey","k","firstPage","requestAnimationFrame","pageVisitMap","i","push","occurrence","indexOf","doScrollToHighlight","scrollContainerRect","target","highlightRect","clientHeight","scrollTo","behavior","scrollToHighlight","onPageChange"],"mappings":"guBA+HkB,EAChBA,SACAC,gBACAC,iBACAC,0BACAC,iBAAiB,SACjBC,uBAAuB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ineProperty(exports,"__esModule",{value:!0});var t=require("./zoomStateManager.js");class e{constructor(){this.rotations=new WeakMap,this.pageMap=new Map,this.rotationChangeListeners=new Set,this.pdfIdentifier=""}setPdfIdentifier(t){this.pdfIdentifier=t}registerPageElement(t,e){this.pageMap.get(t),this.pageMap.set(t,e);const o=this.getPersistedRotation(t);0!==o&&this.applyRotation(e,t,o)}unregisterPageElement(t){this.pageMap.delete(t)}getRotation(t){const e=this.pageMap.get(t);return e&&this.rotations.get(e)||0}rotatePageBy90(t){const e=this.pageMap.get(t);if(!e)return;const o=((this.rotations.get(e)||0)+90)%360;this.applyRotation(e,t,o)}setRotation(t,e){const o=(e%360+360)%360,i=this.pageMap.get(t);i&&this.applyRotation(i,t,o)}applyRotation(e,o,i){this.rotations.set(e,i);const n=e.closest(".rpv-core__page-layer");if(t.zoomStateManager.beginRotation(),n)if(0===i)n.style.transform="",n.style.transformOrigin="",n.style.transition="",n.style.pointerEvents="";else{n.style.transform=`rotate(${i}deg)`,n.style.transformOrigin="center center",n.style.transition="transform 0.2s ease",n.style.pointerEvents="auto";const e=()=>{n&&n instanceof HTMLElement&&(t.zoomStateManager.endRotation(),n.removeEventListener("transitionend",e))};n.addEventListener("transitionend",e,{once:!0})}this.notifyRotationChange(o,i),this.persistRotation(o,i)}onRotationChange(t){return this.rotationChangeListeners.add(t),()=>{this.rotationChangeListeners.delete(t)}}notifyRotationChange(t,e){this.rotationChangeListeners.forEach(o=>{try{o(t,e)}catch(t){console.error("Error in rotation change listener:",t)}})}getPersistedRotation(t){if(!this.pdfIdentifier)return 0;const e=`pdf-rotation-${this.pdfIdentifier}-${t}`,o=localStorage.getItem(e);if(null===o)return 0;if(!o)return 0;const i=parseInt(o,10);return Number.isFinite(i)?i:0}persistRotation(t,e){if(!this.pdfIdentifier)return;const o=`pdf-rotation-${this.pdfIdentifier}-${t}`;0===e?localStorage.removeItem(o):localStorage.setItem(o,e.toString())}loadPersistedRotations(t){this.pdfIdentifier&&t.forEach(t=>{const e=this.getPersistedRotation(t);if(0!==e){const o=this.pageMap.get(t);o&&this.applyRotation(o,t,e)}})}clearAll(){this.pageMap.forEach((t,e)=>{const o=t.closest(".rpv-core__page-layer");if(o&&(o.style.transform="",o.style.transformOrigin="",o.style.transition=""),this.pdfIdentifier){const t=`pdf-rotation-${this.pdfIdentifier}-${e}`;localStorage.removeItem(t)}}),this.pageMap.clear(),this.rotations=new WeakMap,t.zoomStateManager.reset()}resetPage(t){const e=this.pageMap.get(t);e&&this.applyRotation(e,t,0)}getRotatedPages(){const t=new Map;return this.pageMap.forEach((e,o)=>{const i=this.rotations.get(e);void 0!==i&&0!==i&&t.set(o,i)}),t}}const o=new e;exports.RotationManager=e,exports.rotationManager=o;
|
|
2
2
|
//# sourceMappingURL=rotationManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotationManager.js","sources":["../../../../src/features/PdfViewer/rotationManager.ts"],"sourcesContent":["\nexport class RotationManager {\n private rotations: WeakMap<HTMLElement, number> = new WeakMap();\n private pageMap: Map<number, HTMLElement> = new Map();\n private rotationChangeListeners: Set<(pageNum: number, angle: number) => void> = new Set();\n private pdfIdentifier: string = '';\n\n setPdfIdentifier(identifier: string) {\n this.pdfIdentifier = identifier;\n }\n\n registerPageElement(pageNumber: number, element: HTMLElement) {\n const oldElement = this.pageMap.get(pageNumber);\n if (oldElement && oldElement !== element) {\n // Old element will be garbage collected\n // WeakMap will auto-clean the entry\n }\n\n this.pageMap.set(pageNumber, element);\n\n // If rotation exists in localStorage, apply it immediately\n const persistedRotation = this.getPersistedRotation(pageNumber);\n if (persistedRotation !== 0) {\n this.applyRotation(element, pageNumber, persistedRotation);\n }\n }\n\n unregisterPageElement(pageNumber: number) {\n this.pageMap.delete(pageNumber);\n }\n\n getRotation(pageNumber: number): number {\n const element = this.pageMap.get(pageNumber);\n if (!element) return 0;\n return this.rotations.get(element) || 0;\n }\n\n rotatePageBy90(pageNumber: number) {\n const element = this.pageMap.get(pageNumber);\n if (!element) return;\n\n const currentRotation = this.rotations.get(element) || 0;\n const nextRotation = (currentRotation + 90) % 360;\n\n this.applyRotation(element, pageNumber, nextRotation);\n }\n\n setRotation(pageNumber: number, angle: number) {\n const normalizedAngle = ((angle % 360) + 360) % 360;\n const element = this.pageMap.get(pageNumber);\n if (!element) return;\n\n this.applyRotation(element, pageNumber, normalizedAngle);\n }\n\n private applyRotation(element: HTMLElement, pageNumber: number, angle: number) {\n this.rotations.set(element, angle);\n\n const pageWrapper = element.closest('.rpv-core__page-layer') as HTMLElement;\n\n if (pageWrapper) {\n if (angle === 0) {\n pageWrapper.style.transform = '';\n pageWrapper.style.transformOrigin = '';\n pageWrapper.style.transition = '';\n } else {\n pageWrapper.style.transform = `rotate(${angle}deg)`;\n pageWrapper.style.transformOrigin = 'center center';\n pageWrapper.style.transition = 'transform 0.2s ease';\n }\n }\n\n this.notifyRotationChange(pageNumber, angle);\n\n this.persistRotation(pageNumber, angle);\n }\n\n onRotationChange(callback: (pageNum: number, angle: number) => void): () => void {\n this.rotationChangeListeners.add(callback);\n return () => {\n this.rotationChangeListeners.delete(callback);\n };\n }\n\n private notifyRotationChange(pageNum: number, angle: number) {\n this.rotationChangeListeners.forEach(listener => {\n try {\n listener(pageNum, angle);\n } catch (error) {\n console.error('Error in rotation change listener:', error);\n }\n });\n }\n\n private getPersistedRotation(pageNumber: number): number {\n if (!this.pdfIdentifier) return 0;\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNumber}`;\n const stored = localStorage.getItem(key);\n if (stored === null) return 0;\n if (!stored) return 0;\n const angle = parseInt(stored, 10);\n return Number.isFinite(angle) ? angle : 0;\n }\n\n private persistRotation(pageNumber: number, angle: number) {\n if (!this.pdfIdentifier) return;\n\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNumber}`;\n if (angle === 0) {\n localStorage.removeItem(key);\n } else {\n localStorage.setItem(key, angle.toString());\n }\n }\n\n loadPersistedRotations(pageNumbers: number[]) {\n if (!this.pdfIdentifier) return;\n\n pageNumbers.forEach(pageNum => {\n const stored = this.getPersistedRotation(pageNum);\n if (stored !== 0) {\n const element = this.pageMap.get(pageNum);\n if (element) {\n this.applyRotation(element, pageNum, stored);\n }\n }\n });\n }\n\n clearAll() {\n this.pageMap.forEach((element, pageNum) => {\n const pageWrapper = element.closest('.rpv-core__page-layer') as HTMLElement;\n if (pageWrapper) {\n pageWrapper.style.transform = '';\n pageWrapper.style.transformOrigin = '';\n pageWrapper.style.transition = '';\n }\n if (this.pdfIdentifier) {\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNum}`;\n localStorage.removeItem(key);\n }\n });\n this.pageMap.clear();\n this.rotations = new WeakMap();\n }\n\n resetPage(pageNumber: number) {\n const element = this.pageMap.get(pageNumber);\n if (element) {\n this.applyRotation(element, pageNumber, 0);\n }\n }\n\n getRotatedPages(): Map<number, number> {\n const result = new Map<number, number>();\n this.pageMap.forEach((element, pageNum) => {\n const rotation = this.rotations.get(element);\n if (rotation !== undefined && rotation !== 0) {\n result.set(pageNum, rotation);\n }\n });\n return result;\n }\n}\n\nexport const rotationManager = new RotationManager();\n"],"names":["RotationManager","constructor","this","rotations","WeakMap","pageMap","Map","rotationChangeListeners","Set","pdfIdentifier","setPdfIdentifier","identifier","registerPageElement","pageNumber","element","get","set","persistedRotation","getPersistedRotation","applyRotation","unregisterPageElement","delete","getRotation","rotatePageBy90","nextRotation","setRotation","angle","normalizedAngle","pageWrapper","closest","style","transform","transformOrigin","transition","notifyRotationChange","persistRotation","onRotationChange","callback","add","pageNum","forEach","listener","error","console","key","stored","localStorage","getItem","parseInt","Number","isFinite","removeItem","setItem","toString","loadPersistedRotations","pageNumbers","clearAll","clear","resetPage","getRotatedPages","result","rotation","rotationManager"],"mappings":"oEACO,MAAMA,EAAN,WAAAC,GACGC,KAAAC,cAA8CC,QAC9CF,KAAAG,YAAwCC,IACxCJ,KAAAK,4BAA6EC,IACrFN,KAAQO,cAAwB,EAAA,CAEhC,gBAAAC,CAAiBC,GACfT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EAAUZ,KAAKG,QAAQU,IAAIF,GAC7BC,GACGZ,KAAAiB,cAAcL,EAASD,EAAY,EAE5C,CAEA,eAAA8C,GACQ,MAAAC,MAAatD,IAOZ,OANPJ,KAAKG,QAAQmC,QAAQ,CAAC1B,EAASyB,KAC7B,MAAMsB,EAAW3D,KAAKC,UAAUY,IAAID,QACN,IAA1B+C,GAAuC,IAAbA,GACrBD,EAAA5C,IAAIuB,EAASsB,KAGjBD,CACT,EAGW,MAAAE,EAAkB,IAAI9D"}
|
|
1
|
+
{"version":3,"file":"rotationManager.js","sources":["../../../../src/features/PdfViewer/rotationManager.ts"],"sourcesContent":["import {zoomStateManager} from \"./zoomStateManager\";\n\nexport class RotationManager {\n private rotations: WeakMap<HTMLElement, number> = new WeakMap();\n private pageMap: Map<number, HTMLElement> = new Map();\n private rotationChangeListeners: Set<(pageNum: number, angle: number) => void> = new Set();\n private pdfIdentifier: string = '';\n\n setPdfIdentifier(identifier: string) {\n this.pdfIdentifier = identifier;\n }\n\n registerPageElement(pageNumber: number, element: HTMLElement) {\n const oldElement = this.pageMap.get(pageNumber);\n if (oldElement && oldElement !== element) {\n // Old element will be garbage collected\n // WeakMap will auto-clean the entry\n }\n\n this.pageMap.set(pageNumber, element);\n\n // If rotation exists in localStorage, apply it immediately\n const persistedRotation = this.getPersistedRotation(pageNumber);\n if (persistedRotation !== 0) {\n this.applyRotation(element, pageNumber, persistedRotation);\n }\n }\n\n unregisterPageElement(pageNumber: number) {\n this.pageMap.delete(pageNumber);\n }\n\n getRotation(pageNumber: number): number {\n const element = this.pageMap.get(pageNumber);\n if (!element) return 0;\n return this.rotations.get(element) || 0;\n }\n\n rotatePageBy90(pageNumber: number) {\n const element = this.pageMap.get(pageNumber);\n if (!element) return;\n\n const currentRotation = this.rotations.get(element) || 0;\n const nextRotation = (currentRotation + 90) % 360;\n\n this.applyRotation(element, pageNumber, nextRotation);\n }\n\n setRotation(pageNumber: number, angle: number) {\n const normalizedAngle = ((angle % 360) + 360) % 360;\n const element = this.pageMap.get(pageNumber);\n if (!element) return;\n\n this.applyRotation(element, pageNumber, normalizedAngle);\n }\n\n private applyRotation(element: HTMLElement, pageNumber: number, angle: number) {\n this.rotations.set(element, angle);\n\n const pageWrapper = element.closest('.rpv-core__page-layer') as HTMLElement;\n\n // Notify zoom state manager that rotation is starting\n // This prevents zoom calculations during CSS transition\n zoomStateManager.beginRotation();\n\n if (pageWrapper) {\n if (angle === 0) {\n pageWrapper.style.transform = '';\n pageWrapper.style.transformOrigin = '';\n pageWrapper.style.transition = '';\n // Ensure pointer-events are enabled when no rotation\n pageWrapper.style.pointerEvents = '';\n } else {\n pageWrapper.style.transform = `rotate(${angle}deg)`;\n pageWrapper.style.transformOrigin = 'center center';\n pageWrapper.style.transition = 'transform 0.2s ease';\n // Maintain pointer events during rotation to prevent interaction issues\n pageWrapper.style.pointerEvents = 'auto';\n \n // Add transitionend listener as a fallback to ensure zoom display is unfrozen after CSS transition\n const handleTransitionEnd = () => {\n if (!pageWrapper || !(pageWrapper instanceof HTMLElement)) {\n return;\n }\n zoomStateManager.endRotation();\n pageWrapper.removeEventListener('transitionend', handleTransitionEnd);\n };\n pageWrapper.addEventListener('transitionend', handleTransitionEnd, { once: true });\n }\n }\n\n this.notifyRotationChange(pageNumber, angle);\n\n this.persistRotation(pageNumber, angle);\n }\n\n onRotationChange(callback: (pageNum: number, angle: number) => void): () => void {\n this.rotationChangeListeners.add(callback);\n return () => {\n this.rotationChangeListeners.delete(callback);\n };\n }\n\n private notifyRotationChange(pageNum: number, angle: number) {\n this.rotationChangeListeners.forEach(listener => {\n try {\n listener(pageNum, angle);\n } catch (error) {\n console.error('Error in rotation change listener:', error);\n }\n });\n }\n\n private getPersistedRotation(pageNumber: number): number {\n if (!this.pdfIdentifier) return 0;\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNumber}`;\n const stored = localStorage.getItem(key);\n if (stored === null) return 0;\n if (!stored) return 0;\n const angle = parseInt(stored, 10);\n return Number.isFinite(angle) ? angle : 0;\n }\n\n private persistRotation(pageNumber: number, angle: number) {\n if (!this.pdfIdentifier) return;\n\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNumber}`;\n if (angle === 0) {\n localStorage.removeItem(key);\n } else {\n localStorage.setItem(key, angle.toString());\n }\n }\n\n loadPersistedRotations(pageNumbers: number[]) {\n if (!this.pdfIdentifier) return;\n\n pageNumbers.forEach(pageNum => {\n const stored = this.getPersistedRotation(pageNum);\n if (stored !== 0) {\n const element = this.pageMap.get(pageNum);\n if (element) {\n this.applyRotation(element, pageNum, stored);\n }\n }\n });\n }\n\n clearAll() {\n this.pageMap.forEach((element, pageNum) => {\n const pageWrapper = element.closest('.rpv-core__page-layer') as HTMLElement;\n if (pageWrapper) {\n pageWrapper.style.transform = '';\n pageWrapper.style.transformOrigin = '';\n pageWrapper.style.transition = '';\n }\n if (this.pdfIdentifier) {\n const key = `pdf-rotation-${this.pdfIdentifier}-${pageNum}`;\n localStorage.removeItem(key);\n }\n });\n this.pageMap.clear();\n this.rotations = new WeakMap();\n // Reset zoom state when clearing all rotations\n zoomStateManager.reset();\n }\n\n resetPage(pageNumber: number) {\n const element = this.pageMap.get(pageNumber);\n if (element) {\n this.applyRotation(element, pageNumber, 0);\n }\n }\n\n getRotatedPages(): Map<number, number> {\n const result = new Map<number, number>();\n this.pageMap.forEach((element, pageNum) => {\n const rotation = this.rotations.get(element);\n if (rotation !== undefined && rotation !== 0) {\n result.set(pageNum, rotation);\n }\n });\n return result;\n }\n}\n\nexport const rotationManager = new RotationManager();\n"],"names":["RotationManager","constructor","this","rotations","WeakMap","pageMap","Map","rotationChangeListeners","Set","pdfIdentifier","setPdfIdentifier","identifier","registerPageElement","pageNumber","element","get","set","persistedRotation","getPersistedRotation","applyRotation","unregisterPageElement","delete","getRotation","rotatePageBy90","nextRotation","setRotation","angle","normalizedAngle","pageWrapper","closest","zoomStateManager","beginRotation","style","transform","transformOrigin","transition","pointerEvents","handleTransitionEnd","HTMLElement","endRotation","removeEventListener","addEventListener","once","notifyRotationChange","persistRotation","onRotationChange","callback","add","pageNum","forEach","listener","error","console","key","stored","localStorage","getItem","parseInt","Number","isFinite","removeItem","setItem","toString","loadPersistedRotations","pageNumbers","clearAll","clear","reset","resetPage","getRotatedPages","result","rotation","rotationManager"],"mappings":"2GAEO,MAAMA,EAAN,WAAAC,GACGC,KAAAC,cAA8CC,QAC9CF,KAAAG,YAAwCC,IACxCJ,KAAAK,4BAA6EC,IACrFN,KAAQO,cAAwB,EAAA,CAEhC,gBAAAC,CAAiBC,GACfT,KAAKO,cAAgBE,CACvB,CAEA,mBAAAC,CAAoBC,EAAoBC,GACnBZ,KAAKG,QAAQU,IAAIF,GAM/BX,KAAAG,QAAQW,IAAIH,EAAYC,GAGvB,MAAAG,EAAoBf,KAAKgB,qBAAqBL,GAC1B,IAAtBI,GACGf,KAAAiB,cAAcL,EAASD,EAAYI,EAE5C,CAEA,qBAAAG,CAAsBP,GACfX,KAAAG,QAAQgB,OAAOR,EACtB,CAEA,WAAAS,CAAYT,GACV,MAAMC,EAAUZ,KAAKG,QAAQU,IAAIF,GAC7B,OAACC,GACEZ,KAAKC,UAAUY,IAAID,IADL,CAEvB,CAEA,cAAAS,CAAeV,GACb,MAAMC,EAAUZ,KAAKG,QAAQU,IAAIF,GACjC,IAAKC,EAAS,OAEd,MACMU,IADkBtB,KAAKC,UAAUY,IAAID,IAAY,GACf,IAAM,IAEzCZ,KAAAiB,cAAcL,EAASD,EAAYW,EAC1C,CAEA,WAAAC,CAAYZ,EAAoBa,GACxB,MAAAC,GAAoBD,EAAQ,IAAO,KAAO,IAC1CZ,EAAUZ,KAAKG,QAAQU,IAAIF,GAC5BC,GAEAZ,KAAAiB,cAAcL,EAASD,EAAYc,EAC1C,CAEQ,aAAAR,CAAcL,EAAsBD,EAAoBa,GACzDxB,KAAAC,UAAUa,IAAIF,EAASY,GAEtB,MAAAE,EAAcd,EAAQe,QAAQ,yBAMpC,GAFAC,EAAAA,iBAAiBC,gBAE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,sBAAAC,CAAuBC,GAChB9D,KAAKO,eAEVuD,EAAYf,QAAmBD,IACvB,MAAAM,EAASpD,KAAKgB,qBAAqB8B,GACzC,GAAe,IAAXM,EAAc,CAChB,MAAMxC,EAAUZ,KAAKG,QAAQU,IAAIiC,GAC7BlC,GACGZ,KAAAiB,cAAcL,EAASkC,EAASM,EAEzC,GAEJ,CAEA,QAAAW,GACE/D,KAAKG,QAAQ4C,QAAQ,CAACnC,EAASkC,KACvB,MAAApB,EAAcd,EAAQe,QAAQ,yBAMpC,GALID,IACFA,EAAYI,MAAMC,UAAY,GAC9BL,EAAYI,MAAME,gBAAkB,GACpCN,EAAYI,MAAMG,WAAa,IAE7BjC,KAAKO,cAAe,CACtB,MAAM4C,EAAM,gBAAgBnD,KAAKO,iBAAiBuC,IAClDO,aAAaK,WAAWP,EAC1B,IAEFnD,KAAKG,QAAQ6D,QACRhE,KAAAC,cAAgBC,QAErB0B,EAAAA,iBAAiBqC,OACnB,CAEA,SAAAC,CAAUvD,GACR,MAAMC,EAAUZ,KAAKG,QAAQU,IAAIF,GAC7BC,GACGZ,KAAAiB,cAAcL,EAASD,EAAY,EAE5C,CAEA,eAAAwD,GACQ,MAAAC,MAAahE,IAOZ,OANPJ,KAAKG,QAAQ4C,QAAQ,CAACnC,EAASkC,KAC7B,MAAMuB,EAAWrE,KAAKC,UAAUY,IAAID,QACN,IAA1ByD,GAAuC,IAAbA,GACrBD,EAAAtD,IAAIgC,EAASuB,KAGjBD,CACT,EAGW,MAAAE,EAAkB,IAAIxE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@react-pdf-viewer/search"),n=require("@react-pdf-viewer/page-navigation"),o=require("@react-pdf-viewer/zoom"),l=require("@react-pdf-viewer/highlight");exports.PdfHighlightControls=(i,s,a,c,h,g,u="yellow",p="#F6D739")=>{const[f,d]=t.useState(0),m=t.useRef(!1),[x,v]=t.useState(0);t.useRef([]);const T=e=>e.replace(/[^\S\n]+/g," ").trim(),y=e=>(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim(),M=e=>{let t=e.trim();t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," "),t=t.replace(/^[-•]\s+/,"");const r=t.match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},w=e=>{const t=y(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},b=e=>e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,e=>(e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(e)).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1"),_=e=>{if(!e)return[];return b(e).split(/\n+/).map(M).flatMap(e=>{const t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(e=>e.trim()).filter(Boolean):[e]}).map(e=>T((e=>e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2"))(e))).filter(Boolean)},I=Object.keys(s).map(Number).sort((e,t)=>e-t),S=t.useMemo(()=>h?g.length:h?0:Object.values(s).filter(e=>e>0).length,[g,s]),$=e=>{if(!a.current)return;const t=a.current.querySelector(`[data-testid="search__highlights-${e}"]`);if(!t)return;const r=Array.from(t.querySelectorAll(".rpv-search__highlight"));if(0===r.length)return;const n=z.map(w),o=j.map(w);if(0===n.length&&0===o.length)return;const l=r.map(e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};const r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}})(e),r=(e.textContent||"").trim(),n=(e.getAttribute("title")||"").trim();return{el:e,text:r||n,...t}}).filter(e=>e.text.length>0).sort((e,t)=>e.top-t.top||e.left-t.left);if(0===l.length)return;const s=[];let c=null,h=[];const g=()=>{if(!c)return;const e=h.join(" ");c.title=y(e),c.title&&s.push(c),c=null,h=[]};if(l.forEach(e=>{if(!c)return c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(h=[e.text]);const t=Math.abs(e.top-c.lastTop)<=5,r=e.left<=c.lastRight+28;t&&r?(c.elements.push(e.el),c.lastTop=e.top,c.lastRight=Math.max(c.lastRight,e.right),h.push(e.text)):(g(),c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},h=[e.text])}),g(),0===s.length)return;const u=(e,t)=>{if(!e)return!1;if(t.has(e))return!0;const r=e.replace(/\s+/g,"");for(const n of Array.from(t)){if(!n)continue;const t=n.replace(/\s+/g,"");if(t===r)return!0;if(n.length>=8&&e.length>=5&&n.includes(e))return!0;if(t.length>=8&&r.length>=5&&t.includes(r))return!0;if(e.length>=10&&n.length>=8&&e.includes(n))return!0;if(r.length>=10&&t.length>=8&&r.includes(t))return!0}return!1};let p=0,f=new Set;const d=Array.from(new Set([...z,...j].map(y).filter(e=>e.length>=8))).sort((e,t)=>t.length-e.length),m=e=>{if(!e||e.length<8)return null;const t=e.replace(/\s+/g,"");for(let r=0;r<s.length;r++){let n="",o="";const l=new Set;for(let i=r;i<s.length&&i<r+20;i++){const r=s[i].title;if(n=n?`${n} ${r}`:r,o=o?`${o}${r.replace(/\s+/g,"")}`:r.replace(/\s+/g,""),l.add(i),n.includes(e)||o.includes(t))return l;if(n.length>=15&&(e.includes(n)||t.includes(o)))return l;if(n.length>e.length+150)break}}return null};for(const e of d){const t=m(e);t&&t.size>0&&(t.forEach(e=>f.add(e)),p=f.size)}if(0===p){const e=(e=>{if(0===e.length)return null;let t=null;for(const r of e)for(const e of Array.from(r)){if(!e||e.length<5)continue;const r=e.replace(/\s+/g,"");for(let n=0;n<s.length;n++){let o="",l="";const i=new Set;for(let a=n;a<s.length&&a<n+15;a++){const n=s[a].title;if(o=o?`${o} ${n}`:n,l=l?`${l}${n.replace(/\s+/g,"")}`:n.replace(/\s+/g,""),i.add(a),o.includes(e)||l.includes(r)){const r=Math.max(0,o.length-e.length);(!t||r<t.extra)&&(t={blocks:new Set(i),extra:r});break}if(o.length>e.length+120)break}}}return t?t.blocks:null})(n);e&&e.size>0&&(e.forEach(e=>f.add(e)),p=f.size)}const x=(e=>{if(e.length<2)return 40;const t=[];for(let r=1;r<e.length;r++){const n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort((e,t)=>e-t);const r=t[Math.floor(t.length/2)],n=Math.round(2.25*r);return Math.min(60,Math.max(24,n))})(s),v=j.map(y).filter(e=>e.length>=8),T=v.map(e=>e.split(/\s+/).filter(e=>e.length>=2));if(0===p){const e=o;for(let t=0;t<s.length;t++){const r=s[t].title;for(let n=0;n<e.length;n++){if(!u(r,e[n]))continue;let o=0;const l=new Set;let i=n,a=t-1;for(let r=t;r<s.length&&i<e.length;r++){if(u(s[r].title,e[i])){if(a>=0){const e=s[a].lastTop,t=s[r].lastTop;if(Math.abs(t-e)>x)break}o++,l.add(r),a=r,i++}else if(i>0&&u(s[r].title,e[i-1])){const e=s[a].lastTop,t=s[r].lastTop;Math.abs(t-e)<=3&&(l.add(r),a=r)}if(r-a>6)break}o>p&&(p=o,f=l)}}}if(p<Math.min(3,v.length)&&v.length>0){const e=new Set;s.forEach((t,r)=>{const n=t.title.split(/\s+/).filter(e=>e.length>=2);if(n.length<2)return;const o=new Set(n);for(const t of T){if(t.length<2)continue;let n=0;for(const e of t)o.has(e)&&n++;const l=n/t.length;if(n>=3||l>=.5){e.add(r);break}}}),e.size>0&&(f=e,p=Math.max(p,e.size))}const M=new Set;if(R.forEach(e=>{const t=y(e);t&&(M.add(t),M.add(t.replace(/\s+/g,"")))}),0===p){const e=new Set;if(s.forEach((t,r)=>{const n=t.title.replace(/\s+/g,"");if(M.has(t.title)||M.has(n))return void e.add(r);const o=Array.from(M);for(let n=0;n<o.length;n++){const l=o[n];if(l.length>=10&&l.includes(t.title)&&t.title.length>=5){e.add(r);break}}}),0===e.size)return 0;f=e}s.forEach((e,t)=>{const r=f.has(t);e.elements.forEach(e=>{r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});const b=[];return s.forEach((e,t)=>{f.has(t)&&e.elements.forEach(e=>b.push(e))}),requestAnimationFrame(()=>{const e=b.map(e=>({el:e,rect:e.getBoundingClientRect()})).filter(e=>e.rect.width>0&&e.rect.height>0).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height),t=[];e.forEach(({el:e,rect:r})=>{t.some(e=>((e,t)=>{const r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),n=Math.min(e.width*e.height,t.width*t.height);return n>0?r/n:0})(e.rect,r)>.5)?(e.style.display="none",e.classList.remove("verified-match")):t.push({el:e,rect:r})})}),console.groupCollapsed(`[debug: PDF ordered matching - Page ${e}]`),console.log("input->",i),console.log("processed sentences->",z),console.log("processed lines->",j),console.log("Expected sentence count:",n.length),console.log("Expected line count:",o.length),console.log("Matched sequence length:",p),console.log("blocksToKeep",f,"size",f.size),console.groupEnd(),f.size},q=e=>{if(!a.current)return;a.current.querySelectorAll(".rpv-search__highlights").forEach(t=>{const r=t.getAttribute("data-testid"),n=parseInt(r?.replace(/search__highlights-/g,"")||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(e=>{e.style.display="none"})})},E=i.map(e=>(e=>e?b(e).split(/\n{2,}/).map(e=>_(e).join(" ")).map(e=>T(e)).filter(Boolean):[])(e)).flat(),A=i.map(e=>_(e)).flat(),B=E.some(e=>e.length>=3)?3:1,z=E.filter(e=>e.length>=B),j=A.filter(e=>e.length>=B),k=j.flatMap(e=>((e,t=6,r=4)=>{const n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];const o=[];for(let e=0;e+t<=n.length;e+=r)o.push(n.slice(e,e+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&o.push(n.slice(n.length-t).join(" ")),o})(e)),R=Array.from(new Set([...z,...j,...k].flatMap(e=>{const t=T(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];const r=t.replace(/[\u2013\u2014]/g,"-"),n=T(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=T(r.replace(/-/g," ")),l=T(r.replace(/-/g,"")),i=T(t.replace(/[^\w\s]/g,"")),s=new Set([t,r,n,o,l,i]);return Array.from(s).filter(Boolean)}))).filter(e=>{const t=e.split(/\s+/).filter(Boolean);return!(e.length<B)&&(t.length>=3||e.length>=12)}),C=r.searchPlugin({keyword:R}),P=n.pageNavigationPlugin(),H=o.zoomPlugin(),{jumpToMatch:F}=C,{jumpToPage:N}=P,{zoomTo:O,ZoomInButton:Z,ZoomOutButton:L,ZoomPopover:D}=H,W=t.useMemo(()=>(e=>{if(0===e.length)return[];const t=new Map;e.forEach((e,r)=>{const n=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;t.has(n)||t.set(n,[]),t.get(n).push({...e,originalIndex:r})});const r=[];return t.forEach(e=>{const t=[...e].sort((e,t)=>e.top!==t.top?e.top-t.top:e.left-t.left),n=new Array(t.length).fill(!1);for(let e=0;e<t.length;e++){if(n[e])continue;let{left:o,top:l,width:i,height:s,pageIndex:a,pageNumber:c}=t[e],h=o+i,g=l+s;const u=[t[e].originalIndex];n[e]=!0;let p=!0;for(;p;){p=!1;for(let r=e+1;r<t.length;r++){if(n[r])continue;const e=t[r],a=e.left+e.width,c=e.top+e.height,f=Math.max(0,Math.min(h,a)-Math.max(o,e.left))*Math.max(0,Math.min(g,c)-Math.max(l,e.top)),d=Math.max(i*s,1e-4),m=Math.max(e.width*e.height,1e-4),x=Math.min(d,m);(x>0?f/x:0)>=.8&&(o=Math.min(o,e.left),l=Math.min(l,e.top),h=Math.max(h,a),g=Math.max(g,c),i=h-o,s=g-l,u.push(e.originalIndex),n[r]=!0,p=!0)}}r.push({pageIndex:a,pageNumber:c,left:o,top:l,width:i,height:s,originalIndexes:u})}}),r})(g),[g]),K=l.highlightPlugin({renderHighlights:t=>e.jsx(e.Fragment,{children:W.filter(e=>null!=e.pageNumber?e.pageNumber-1===t.pageIndex:e.pageIndex===t.pageIndex).map(t=>{const r=t.originalIndexes.includes(x);return e.jsx("div",{style:{position:"absolute",left:`${t.left}%`,top:`${t.top+.08*t.height}%`,width:`${t.width}%`,height:.95*t.height+"%",background:r?p:u,opacity:r?.7:.4,transition:"background 0.2s, opacity 0.2s",border:r?"1px solid red":"1px solid transparent"}},t.originalIndexes.join("-"))})})}),J=()=>{if(!m.current)try{F(0),m.current=!0;const e=g[0];e&&h&&G(e.pageIndex,e.top)}catch{requestAnimationFrame(J)}},V=(e,t)=>{if(!a.current)return;if(!a.current.querySelector(".rpv-core__viewer"))return;let r=-1;const n=()=>{const o=a.current?.querySelector(".rpv-core__inner-pages");if(!o)return;if(o.scrollTop!==r)return r=o.scrollTop,void setTimeout(n,100);const l=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!l)return;const i=l.querySelectorAll(".rpv-search__highlight")[t];if(!i)return;const s=o.getBoundingClientRect(),c=i.getBoundingClientRect(),h=o.scrollTop+(c.top-s.top)-o.clientHeight/2+c.height/2;o.scrollTo({top:h,behavior:"smooth"})};setTimeout(n,300)},G=(e,t,r=0)=>{if(!a.current)return;let n=0;const o=()=>{if(++n>60)return;const l=a.current?.querySelector(".rpv-core__inner-pages");if(!l)return void setTimeout(o,100);const i=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!i)return void setTimeout(o,100);const s=i.getBoundingClientRect();if(0===s.height)return void setTimeout(o,100);const c=l.getBoundingClientRect(),h=t/100*s.height,g=r/100*s.height,u=s.top-c.top+h,p=u+g;if(u>=80&&p<=l.clientHeight-80)return;const f=u<80?l.scrollTop+u-80:l.scrollTop+p-l.clientHeight+80;l.scrollTo({top:f,behavior:"smooth"})};setTimeout(o,100)},Q=t.useMemo(()=>{const e={};return I.forEach((t,r)=>{const n=s[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[I,s]),U=e=>{const t=s[I[e]];return(Q[t]||[]).indexOf(e)},X=(e,t,r=0)=>{if(!a.current)return;let n=-1,o=0;const l=()=>{if(++o>60)return;const i=a.current?.querySelector(".rpv-core__inner-pages");if(!i)return void setTimeout(l,100);if(i.scrollTop!==n)return n=i.scrollTop,void setTimeout(l,100);const s=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!s)return void setTimeout(l,100);const c=s.getBoundingClientRect();if(0===c.height)return void setTimeout(l,100);const h=i.getBoundingClientRect(),g=t/100*c.height,u=r/100*c.height,p=c.top-h.top+g,f=p+u;if(p>=80&&f<=i.clientHeight-80)return;const d=p<80?i.scrollTop+p-80:i.scrollTop+f-i.clientHeight+80;i.scrollTo({top:d,behavior:"instant"})};setTimeout(l,100)};return{setHighlightIndex:d,highlightIndex:f,cursorIndex:x,setCursorIndex:v,orderedKeys:I,totalHighlights:S,getValidPosition:e=>{if(h)return e+1;if(!s)return 0;let t=0;for(let r=0;r<=e;r++)s[I[r]]>0&&t++;return t},tryJump:J,jumpToPage:N,zoomTo:O,hideNonTargetHighlights:q,deduplicateHighlights:$,scrollToCoord:G,plugins:[h?K:C,P,H],controls:{ZoomInButton:Z,ZoomOutButton:L,ZoomPopover:D,zoomTo:O,goToNext:()=>{if(h&&g)for(let e=x+1;e<g.length;e++){const t=g[e],r=g[x];return v(e),void(t.pageIndex!==r.pageIndex?(N(t.pageIndex),X(t.pageIndex,t.top,t.height)):G(t.pageIndex,t.top,t.height))}else{for(let e=x+1;e<I.length;e++){const t=I[e];if(s[t]>0){const r=s[t]-1,n=U(e);return v(e),N(s[t]-1),V(r,n),setTimeout(()=>{$(r)},500),void(1===Object.keys(s).length&&q(c))}}}},goToPrevious:()=>{if(h&&g)for(let e=x-1;e>=0;e--){const t=g[e],r=g[x];return v(e),void(t.pageIndex!==r.pageIndex?(N(t.pageIndex),X(t.pageIndex,t.top,t.height)):G(t.pageIndex,t.top,t.height))}else{for(let e=x-1;e>=0;e--){const t=I[e];if(s[t]>0){const r=s[t]-1,n=U(e);return v(e),N(s[t]-1),V(r,n),setTimeout(()=>{$(r)},500),void(1===Object.keys(s).length&&q(c))}}}}}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@react-pdf-viewer/search"),n=require("@react-pdf-viewer/page-navigation"),o=require("@react-pdf-viewer/zoom"),l=require("@react-pdf-viewer/highlight");exports.PdfHighlightControls=(i,s,a,c,h,g,u="yellow",p="#F6D739")=>{const[f,d]=t.useState(0),m=t.useRef(!1),[x,v]=t.useState(0);t.useRef([]);const T=e=>e.replace(/[^\S\n]+/g," ").trim(),y=e=>(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim(),M=e=>{let t=e.trim();t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," "),t=t.replace(/^[-•]\s+/,"");const r=t.match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},w=e=>{const t=y(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},b=e=>e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,e=>(e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(e)).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1"),_=e=>{if(!e)return[];return b(e).split(/\n+/).map(M).flatMap(e=>{const t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(e=>e.trim()).filter(Boolean):[e]}).map(e=>T((e=>e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2"))(e))).filter(Boolean)},S=Object.keys(s).map(Number).sort((e,t)=>e-t),I=t.useMemo(()=>h?g.length:h?0:Object.values(s).filter(e=>e>0).length,[g,s]),$=e=>{if(!a.current)return;const t=a.current.querySelector(`[data-testid="search__highlights-${e}"]`);if(!t)return;const r=Array.from(t.querySelectorAll(".rpv-search__highlight"));if(0===r.length)return;const n=j.map(w),o=k.map(w);if(0===n.length&&0===o.length)return;const l=r.map(e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};const r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}})(e),r=(e.textContent||"").trim(),n=(e.getAttribute("title")||"").trim();return{el:e,text:r||n,...t}}).filter(e=>e.text.length>0).sort((e,t)=>e.top-t.top||e.left-t.left);if(0===l.length)return;const s=[];let c=null,h=[];const g=()=>{if(!c)return;const e=h.join(" ");c.title=y(e),c.title&&s.push(c),c=null,h=[]};if(l.forEach(e=>{if(!c)return c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(h=[e.text]);const t=Math.abs(e.top-c.lastTop)<=5,r=e.left<=c.lastRight+28;t&&r?(c.elements.push(e.el),c.lastTop=e.top,c.lastRight=Math.max(c.lastRight,e.right),h.push(e.text)):(g(),c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},h=[e.text])}),g(),0===s.length)return;const u=(e,t)=>{if(!e)return!1;if(t.has(e))return!0;const r=e.replace(/\s+/g,"");for(const n of Array.from(t)){if(!n)continue;const t=n.replace(/\s+/g,"");if(t===r)return!0;if(n.length>=8&&e.length>=5&&n.includes(e))return!0;if(t.length>=8&&r.length>=5&&t.includes(r))return!0;if(e.length>=10&&n.length>=8&&e.includes(n))return!0;if(r.length>=10&&t.length>=8&&r.includes(t))return!0}return!1};let p=0,f=new Set;const d=Array.from(new Set([...j,...k].map(y).filter(e=>e.length>=8))).sort((e,t)=>t.length-e.length),m=e=>{if(!e||e.length<8)return null;const t=e.replace(/\s+/g,"");for(let r=0;r<s.length;r++){let n="",o="";const l=new Set;for(let i=r;i<s.length&&i<r+20;i++){const r=s[i].title;if(n=n?`${n} ${r}`:r,o=o?`${o}${r.replace(/\s+/g,"")}`:r.replace(/\s+/g,""),l.add(i),n.includes(e)||o.includes(t))return l;if(n.length>=15&&(e.includes(n)||t.includes(o)))return l;if(n.length>e.length+150)break}}return null};for(const e of d){const t=m(e);t&&t.size>0&&(t.forEach(e=>f.add(e)),p=f.size)}if(0===p){const e=(e=>{if(0===e.length)return null;let t=null;for(const r of e)for(const e of Array.from(r)){if(!e||e.length<5)continue;const r=e.replace(/\s+/g,"");for(let n=0;n<s.length;n++){let o="",l="";const i=new Set;for(let a=n;a<s.length&&a<n+15;a++){const n=s[a].title;if(o=o?`${o} ${n}`:n,l=l?`${l}${n.replace(/\s+/g,"")}`:n.replace(/\s+/g,""),i.add(a),o.includes(e)||l.includes(r)){const r=Math.max(0,o.length-e.length);(!t||r<t.extra)&&(t={blocks:new Set(i),extra:r});break}if(o.length>e.length+120)break}}}return t?t.blocks:null})(n);e&&e.size>0&&(e.forEach(e=>f.add(e)),p=f.size)}const x=(e=>{if(e.length<2)return 40;const t=[];for(let r=1;r<e.length;r++){const n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort((e,t)=>e-t);const r=t[Math.floor(t.length/2)],n=Math.round(2.25*r);return Math.min(60,Math.max(24,n))})(s),v=k.map(y).filter(e=>e.length>=8),T=v.map(e=>e.split(/\s+/).filter(e=>e.length>=2));if(0===p){const e=o;for(let t=0;t<s.length;t++){const r=s[t].title;for(let n=0;n<e.length;n++){if(!u(r,e[n]))continue;let o=0;const l=new Set;let i=n,a=t-1;for(let r=t;r<s.length&&i<e.length;r++){if(u(s[r].title,e[i])){if(a>=0){const e=s[a].lastTop,t=s[r].lastTop;if(Math.abs(t-e)>x)break}o++,l.add(r),a=r,i++}else if(i>0&&u(s[r].title,e[i-1])){const e=s[a].lastTop,t=s[r].lastTop;Math.abs(t-e)<=3&&(l.add(r),a=r)}if(r-a>6)break}o>p&&(p=o,f=l)}}}if(p<Math.min(3,v.length)&&v.length>0){const e=new Set;s.forEach((t,r)=>{const n=t.title.split(/\s+/).filter(e=>e.length>=2);if(n.length<2)return;const o=new Set(n);for(const t of T){if(t.length<2)continue;let n=0;for(const e of t)o.has(e)&&n++;const l=n/t.length;if(n>=3||l>=.5){e.add(r);break}}}),e.size>0&&(f=e,p=Math.max(p,e.size))}const M=new Set;if(B.forEach(e=>{const t=y(e);t&&(M.add(t),M.add(t.replace(/\s+/g,"")))}),0===p){const e=new Set;if(s.forEach((t,r)=>{const n=t.title.replace(/\s+/g,"");if(M.has(t.title)||M.has(n))return void e.add(r);const o=Array.from(M);for(let n=0;n<o.length;n++){const l=o[n];if(l.length>=10&&l.includes(t.title)&&t.title.length>=5){e.add(r);break}}}),0===e.size)return 0;f=e}s.forEach((e,t)=>{const r=f.has(t);e.elements.forEach(e=>{r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});const b=[];return s.forEach((e,t)=>{f.has(t)&&e.elements.forEach(e=>b.push(e))}),requestAnimationFrame(()=>{const e=b.map(e=>({el:e,rect:e.getBoundingClientRect()})).filter(e=>e.rect.width>0&&e.rect.height>0).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height),t=[];e.forEach(({el:e,rect:r})=>{t.some(e=>((e,t)=>{const r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),n=Math.min(e.width*e.height,t.width*t.height);return n>0?r/n:0})(e.rect,r)>.5)?(e.style.display="none",e.classList.remove("verified-match")):t.push({el:e,rect:r})})}),console.groupCollapsed(`[debug: PDF ordered matching - Page ${e}]`),console.log("input->",i),console.log("processed sentences->",j),console.log("processed lines->",k),console.log("Expected sentence count:",n.length),console.log("Expected line count:",o.length),console.log("Matched sequence length:",p),console.log("blocksToKeep",f,"size",f.size),console.groupEnd(),f.size},q=e=>{if(!a.current)return;a.current.querySelectorAll(".rpv-search__highlights").forEach(t=>{const r=t.getAttribute("data-testid"),n=parseInt(r?.replace(/search__highlights-/g,"")||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(e=>{e.style.display="none"})})},E=i.map(e=>(e=>e?b(e).split(/\n{2,}/).map(e=>_(e).join(" ")).map(e=>T(e)).filter(Boolean):[])(e)).flat(),A=i.map(e=>_(e)).flat(),z=E.some(e=>e.length>=3)?3:1,j=E.filter(e=>e.length>=z),k=A.filter(e=>e.length>=z),C=k.flatMap(e=>((e,t=6,r=4)=>{const n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];const o=[];for(let e=0;e+t<=n.length;e+=r)o.push(n.slice(e,e+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&o.push(n.slice(n.length-t).join(" ")),o})(e)),B=Array.from(new Set([...j,...k,...C].flatMap(e=>{const t=T(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];const r=t.replace(/[\u2013\u2014]/g,"-"),n=T(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=T(r.replace(/-/g," ")),l=T(r.replace(/-/g,"")),i=T(t.replace(/[^\w\s]/g,"")),s=new Set([t,r,n,o,l,i]);return Array.from(s).filter(Boolean)}))).filter(e=>{const t=e.split(/\s+/).filter(Boolean);return!(e.length<z)&&(t.length>=3||e.length>=12)}),R=r.searchPlugin({keyword:B}),P=n.pageNavigationPlugin(),H=o.zoomPlugin(),{jumpToMatch:F}=R,{jumpToPage:N}=P,{zoomTo:L,CurrentScale:O,ZoomPopover:Z}=H,D=t.useMemo(()=>(e=>{if(0===e.length)return[];const t=new Map;e.forEach((e,r)=>{const n=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;t.has(n)||t.set(n,[]),t.get(n).push({...e,originalIndex:r})});const r=[];return t.forEach(e=>{const t=[...e].sort((e,t)=>e.top!==t.top?e.top-t.top:e.left-t.left),n=new Array(t.length).fill(!1);for(let e=0;e<t.length;e++){if(n[e])continue;let{left:o,top:l,width:i,height:s,pageIndex:a,pageNumber:c}=t[e],h=o+i,g=l+s;const u=[t[e].originalIndex];n[e]=!0;let p=!0;for(;p;){p=!1;for(let r=e+1;r<t.length;r++){if(n[r])continue;const e=t[r],a=e.left+e.width,c=e.top+e.height,f=Math.max(0,Math.min(h,a)-Math.max(o,e.left))*Math.max(0,Math.min(g,c)-Math.max(l,e.top)),d=Math.max(i*s,1e-4),m=Math.max(e.width*e.height,1e-4),x=Math.min(d,m);(x>0?f/x:0)>=.8&&(o=Math.min(o,e.left),l=Math.min(l,e.top),h=Math.max(h,a),g=Math.max(g,c),i=h-o,s=g-l,u.push(e.originalIndex),n[r]=!0,p=!0)}}r.push({pageIndex:a,pageNumber:c,left:o,top:l,width:i,height:s,originalIndexes:u})}}),r})(g),[g]),W=l.highlightPlugin({renderHighlights:t=>e.jsx(e.Fragment,{children:D.filter(e=>null!=e.pageNumber?e.pageNumber-1===t.pageIndex:e.pageIndex===t.pageIndex).map(t=>{const r=t.originalIndexes.includes(x);return e.jsx("div",{style:{position:"absolute",left:`${t.left}%`,top:`${t.top+.08*t.height}%`,width:`${t.width}%`,height:.95*t.height+"%",background:r?p:u,opacity:r?.7:.4,transition:"background 0.2s, opacity 0.2s",border:r?"1px solid red":"1px solid transparent"}},t.originalIndexes.join("-"))})})}),K=()=>{if(!m.current)try{F(0),m.current=!0;const e=g[0];e&&h&&V(e.pageIndex,e.top)}catch{requestAnimationFrame(K)}},J=(e,t)=>{if(!a.current)return;if(!a.current.querySelector(".rpv-core__viewer"))return;let r=-1;const n=()=>{const o=a.current?.querySelector(".rpv-core__inner-pages");if(!o)return;if(o.scrollTop!==r)return r=o.scrollTop,void setTimeout(n,100);const l=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!l)return;const i=l.querySelectorAll(".rpv-search__highlight")[t];if(!i)return;const s=o.getBoundingClientRect(),c=i.getBoundingClientRect(),h=o.scrollTop+(c.top-s.top)-o.clientHeight/2+c.height/2;o.scrollTo({top:h,behavior:"smooth"})};setTimeout(n,300)},V=(e,t,r=0)=>{if(!a.current)return;let n=0;const o=()=>{if(++n>60)return;const l=a.current?.querySelector(".rpv-core__inner-pages");if(!l)return void setTimeout(o,100);const i=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!i)return void setTimeout(o,100);const s=i.getBoundingClientRect();if(0===s.height)return void setTimeout(o,100);const c=l.getBoundingClientRect(),h=t/100*s.height,g=r/100*s.height,u=s.top-c.top+h,p=u+g;if(u>=80&&p<=l.clientHeight-80)return;const f=u<80?l.scrollTop+u-80:l.scrollTop+p-l.clientHeight+80;l.scrollTo({top:f,behavior:"smooth"})};setTimeout(o,100)},G=t.useMemo(()=>{const e={};return S.forEach((t,r)=>{const n=s[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[S,s]),Q=e=>{const t=s[S[e]];return(G[t]||[]).indexOf(e)},U=(e,t,r=0)=>{if(!a.current)return;let n=-1,o=0;const l=()=>{if(++o>60)return;const i=a.current?.querySelector(".rpv-core__inner-pages");if(!i)return void setTimeout(l,100);if(i.scrollTop!==n)return n=i.scrollTop,void setTimeout(l,100);const s=a.current?.querySelector(`[data-testid="core__page-layer-${e}"]`);if(!s)return void setTimeout(l,100);const c=s.getBoundingClientRect();if(0===c.height)return void setTimeout(l,100);const h=i.getBoundingClientRect(),g=t/100*c.height,u=r/100*c.height,p=c.top-h.top+g,f=p+u;if(p>=80&&f<=i.clientHeight-80)return;const d=p<80?i.scrollTop+p-80:i.scrollTop+f-i.clientHeight+80;i.scrollTo({top:d,behavior:"instant"})};setTimeout(l,100)};return{setHighlightIndex:d,highlightIndex:f,cursorIndex:x,setCursorIndex:v,orderedKeys:S,totalHighlights:I,getValidPosition:e=>{if(h)return e+1;if(!s)return 0;let t=0;for(let r=0;r<=e;r++)s[S[r]]>0&&t++;return t},tryJump:K,jumpToPage:N,zoomTo:L,hideNonTargetHighlights:q,deduplicateHighlights:$,scrollToCoord:V,plugins:[h?W:R,P,H],controls:{CurrentScale:O,ZoomPopover:Z,zoomTo:L,goToNext:()=>{if(h&&g)for(let e=x+1;e<g.length;e++){const t=g[e],r=g[x];return v(e),void(t.pageIndex!==r.pageIndex?(N(t.pageIndex),U(t.pageIndex,t.top,t.height)):V(t.pageIndex,t.top,t.height))}else{for(let e=x+1;e<S.length;e++){const t=S[e];if(s[t]>0){const r=s[t]-1,n=Q(e);return v(e),N(s[t]-1),J(r,n),setTimeout(()=>{$(r)},500),void(1===Object.keys(s).length&&q(c))}}}},goToPrevious:()=>{if(h&&g)for(let e=x-1;e>=0;e--){const t=g[e],r=g[x];return v(e),void(t.pageIndex!==r.pageIndex?(N(t.pageIndex),U(t.pageIndex,t.top,t.height)):V(t.pageIndex,t.top,t.height))}else{for(let e=x-1;e>=0;e--){const t=S[e];if(s[t]>0){const r=s[t]-1,n=Q(e);return v(e),N(s[t]-1),J(r,n),setTimeout(()=>{$(r)},500),void(1===Object.keys(s).length&&q(c))}}}}}}};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|