@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
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import n from"react";import{pdfStyles as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import n from"react";import{pdfStyles as r}from"./PdfStyle.js";import{DefaultPdfIcon as o,DefaultDownloadIcon as i,DefaultCloseIcon as l}from"../../assests/svg/PdfViewerIcons.js";import a from"@mui/material/Tooltip";import{Minus as s,Plus as c,Expand as d,Info as p}from"lucide-react";import h from"@mui/icons-material/RotateRight";const g=({highlightIndex:g,totalHighlights:u,controls:x,currentPosition:f,pdfName:m,onClose:y,pdfUrl:b,viewerRef:w,customStyles:k,customClasses:v,customIcons:S,headerAction:C,isZoomEnabled:F=!0,showHighlightsAction:I=!0,showFullScreenAction:T=!0,currentSegment:W,segmentTooltipText:E="Details of current segment",currentPage:D,totalPages:R,onPageNavigate:z,onRotatePage:j,currentPageRotation:L=0,showRotateButton:M=!0})=>{const{CurrentScale:P,ZoomPopover:B,zoomTo:H,goToPrevious:N,goToNext:A}=x,[Z,O]=n.useState(String(D));n.useEffect(()=>{O(String(D))},[D]);const _={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},G=e=>String(e).padStart(2,"0");return e("div",{style:{marginBottom:"12px",backgroundColor:"#F1F5F9",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",...r.header,...k?.header,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"},children:[e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0},children:[t("div",{style:{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box",...k?.pdfIconWrapper,flexShrink:0},children:S?.pdfIcon||t(o,{})}),t(a,{title:m||"",arrow:!0,placement:"top",children:t("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:t("span",{style:{display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default",...k?.pdfName},className:v?.pdfName,children:m})})})]}),e("div",{style:{display:"flex",alignItems:"center",gap:I?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},children:[R>0&&e("div",{style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"},children:[t("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:Z,onChange:e=>{const t=e.target.value.replace(/\D/g,"");O(t)},onBlur:()=>{const e=Number(Z);if(!Number.isInteger(e)||e<1)return void O(String(D));const t=R?Math.min(e,R):e;z(t),O(String(t))},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(O(String(D)),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"}}),t("span",{style:{fontSize:"14px",fontWeight:500,color:"#111827"},children:"/"}),t("span",{style:{fontSize:"14px",fontWeight:500,color:"#111827"},children:String(R)})]}),F&&e("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t(P,{children:({scale:e})=>t("button",{onClick:()=>H(Math.max(.1,e-.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:t(s,{size:16,strokeWidth:2})})}),t("div",{style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"},children:t(B,{})}),t(P,{children:({scale:e})=>t("button",{onClick:()=>H(e+.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:t(c,{size:16,strokeWidth:2})})})]}),M&&j&&R>0&&t(a,{title:`Rotate page (${L}°)`,children:t("button",{onClick:()=>{j&&"function"==typeof j&&j()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:0!==L?"#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!==L?"#1976d2":"#475467")},"aria-label":"Rotate current page",children:t(h,{sx:{fontSize:"18px"}})})}),!!u&&I&&e("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e("span",{style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1},children:[f," of ",u]}),t("button",{style:{background:"none",border:"none",cursor:f<=1?"not-allowed":"pointer",padding:"2px 4px",color:f<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:N,disabled:f<=1,children:t("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:t("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t("button",{style:{background:"none",border:"none",cursor:f===u?"not-allowed":"pointer",padding:"2px 4px",color:f===u?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:A,disabled:f===u,children:t("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:t("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),t("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),e("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"},children:[!1!==T&&(C?.icon&&C?.onClick?t(a,{title:C?.tooltip||"",arrow:!0,placement:"top",children:t("div",{onClick:C.onClick,style:{display:"flex",alignItems:"center",cursor:"pointer",..._},children:C.icon})}):t("button",{onClick:()=>{const e=w?.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(e=>{console.error(`Error attempting to enable fullscreen: ${e.message}`)}))},style:_,title:"Full Screen",children:S?.fullScreenIcon||t(d,{size:20,color:"#475467",strokeWidth:2})})),b&&t("a",{href:b,target:"_blank",rel:"noopener noreferrer",style:_,title:"Open in new tab",children:S?.downloadIcon||t(i,{})}),y&&t("button",{onClick:y,style:_,title:"Close",children:S?.closeIcon||t(l,{})})]})]})]}),W&&e("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:[t(a,{title:E,arrow:!0,placement:"top",children:t(p,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})}),t("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t(a,{title:W.title,arrow:!0,placement:"top",children:e("span",{children:["Viewing ",W.title," • Pages ",G(W.start_page),"-",G(W.end_page)]})})})]})]})};export{g as default};
|
|
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":["PdfToolbar","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":"8XAsCA,MAAMA,EAAa,EACjBC,iBACAC,kBACAC,WACAC,kBACAC,UACAC,UACAC,SACAC,YACAC,eACAC,gBACAC,cACAC,eACAC,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,iBAJTJ,EAAKK,oBAAoBC,MAAOC,IAC9BC,QAAQC,MAAM,0CAA0CF,EAAIG,eA8YnB5F,MAAOf,EAA0BuC,MAAM,cACvEd,YAAamF,gBAAkB7E,EAAC8E,GAAO3B,KAAM,GAAInC,MAAM,UAAUoC,YAAa,OAMpF7G,GACEyD,EAAA,IAAA,CAAE+E,KAAMxI,EAAQqF,OAAO,SAASoD,IAAI,sBAAsBhG,MAAOf,EAA0BuC,MAAM,kBAC/Fd,YAAauF,cAAgBjF,EAACkF,GAAoB,KAKtD5I,GACC0D,EAAC,SAAO,CAAA4C,QAAStG,EAAS0C,MAAOf,EAA0BuC,MAAM,QAC9Dd,SAAA/C,GAAawI,WAAanF,EAACoF,GAAiB,cAOpDpI,GACC+B,EAAC,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,EAAAO,EAAA,CAAQC,MAAOvD,EAAoBwD,OAAK,EAACC,UAAU,MAClDhB,WAAC2F,EAAK,CAAAlC,KAAM,GAAInC,MAAM,UAAUoC,YAAa,EAAGpE,MAAO,CAAEL,WAAY,SAEtE,OAAK,CAAAK,MAAO,CAAE2B,SAAU,SAAUE,aAAc,YAC/CnB,WAACa,EAAQ,CAAAC,MAAOxD,EAAewD,MAAOC,OAAK,EAACC,UAAU,MACtDhB,WAAC,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":["PdfToolbar","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":"8XAsCA,MAAMA,EAAa,EACjBC,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,EAAMC,SAASC,OAAOf,IAElEa,EAAMG,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,EAAC,MAAA,CACCC,MAAO,CACPC,aAAc,OACdC,gBAAiB,UACjBC,aAAc,oBACdC,oBAAqB,OACrBC,qBAAsB,UACnBC,EAAUC,UACVhD,GAAcgD,OACjBhB,QAAS,OACTiB,cAAe,SACfhB,WAAY,UACZiB,IAAK,QAGLC,SAAA,CAAAX,EAAC,MAAA,CACCC,MAAO,CACLT,QAAS,OACTC,WAAY,SACZC,eAAgB,gB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,UAAU,MAClDhB,WAAC2F,EAAK,CAAAlC,KAAM,GAAInC,MAAM,UAAUoC,YAAa,EAAGpE,MAAO,CAAEL,WAAY,SAEtE,OAAK,CAAAK,MAAO,CAAE2B,SAAU,SAAUE,aAAc,YAC/CnB,WAACa,EAAQ,CAAAC,MAAO1D,EAAe0D,MAAOC,OAAK,EAACC,UAAU,MACtDhB,WAAC,OAAK,CAAAA,SAAA,CAAA,WAAS5C,EAAe0D,MAAM,YAAe5B,EAAkB9B,EAAewI,YAAY,IAAE1G,EAAkB9B,EAAeyI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js";e(".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
|
+
import e from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js";e(".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
|
-
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import{SpecialZoomLevel as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import{SpecialZoomLevel as n}from"@react-pdf-viewer/core";import r from"./PdfContainer.js";import i from"./PdfToolbar.js";import{pdfStyles as a}from"./PdfStyle.js";import{PdfHighlightControls as s}from"./usePdfHighlight.js";import{rotationManager as c}from"./rotationManager.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import l,{useRef as u,useState as d,useMemo as g,useEffect as h}from"react";import m from"../ScannedDocCitation/ScannedDocCitation.js";import"./PdfViewer.css.js";const p=({pdfUrl:p,highlightText:f,highlightPages:v,highlightCordinatePages:w,highlightColor:y="yellow",activeHighlightColor:P="#f7dc51",jumpToPageValue:T=0,pdfName:x,onClose:C,customStyles:b,customClasses:S,customIcons:A,useCoordinates:R,fallbackPages:I,activeCitationIndex:_,onActiveCitationChange:q,headerAction:L,isZoomEnabled:j=!0,showHighlightsAction:F=!0,defaultScale:H=n.ActualSize,useRange:N=!1,rangeOfPages:B=null,showFullScreenAction:M=!0,showRotateButton:E=!1,segments:V=[{title:"Document 2",start_page:52,end_page:52,page_count:1}],segmentTooltipText:k,onCurrentPageChange:z,navigationRequest:D,onNavigationSettled:W,disablePdfAnnotations:O=!1,disablePdfTextLayer:U=!1,renderPage:$,setRenderRange:Z})=>{const J=u(null),K=(e=>{switch(e){case"ActualSize":return n.ActualSize;case"PageFit":return n.PageFit;case"PageWidth":return n.PageWidth;default:return e??n.PageWidth}})(H),[G,Q]=d(0),[X,Y]=d(0),[ee,te]=d(0),oe=u(null),ne=u(null),re=u(0),ie=u(null),ae=g(()=>{if(!p)return"";try{return new URL(p,window.location.origin).pathname.split("/").pop()||"default"}catch{return"default"}},[p]);h(()=>{ae&&c.setPdfIdentifier(ae)},[ae]);h(()=>c.onRotationChange((e,t)=>{e===G+1&&te(t)}),[G]),h(()=>{const e=new MutationObserver(()=>{const e=J.current?.querySelectorAll('[data-testid^="core__page-layer-"]'),t=new Set;e?.forEach(e=>{const o=e.getAttribute("data-testid")?.match(/core__page-layer-(\d+)/);if(o&&o.length>=2){const n=parseInt(o[1],10)+1;t.has(n)||(c.registerPageElement(n,e),t.add(n))}})});return J.current&&(e.observe(J.current,{childList:!0,subtree:!0,attributes:!1}),ie.current=e),()=>{e.disconnect(),ie.current=null}},[]),h(()=>()=>{c.clearAll(),ie.current&&ie.current.disconnect()},[]),h(()=>{const e=G+1;te(c.getRotation(e))},[G]);const se=g(()=>O||U?n=>{const r=U?e("div",{"aria-hidden":"true",style:{display:"none"},children:n.textLayer.children}):n.textLayer.children,i={...n,annotationLayer:{...n.annotationLayer,children:O?null:n.annotationLayer.children},textLayer:{...n.textLayer,children:r}};return $?$(i):t(o,{children:[n.canvasLayer.children,r,!O&&n.annotationLayer.children]})}:$,[O,U,$]),ce=g(()=>{if(R)return new Set(w.map(e=>e.pageIndex));{const e=new Set;return Object.values(v).forEach(t=>{t>0&&e.add(t-1)}),e}},[w,v,R]),le=(ue=f)&&0!==ue.length?ue.filter(e=>!ue.some(t=>t!==e&&t.includes(e))):ue;var ue;const{highlightIndex:de,setHighlightIndex:ge,cursorIndex:he,setCursorIndex:me,orderedKeys:pe,totalHighlights:fe,getValidPosition:ve,tryJump:we,jumpToPage:ye,zoomTo:Pe,plugins:Te,controls:xe,hideNonTargetHighlights:Ce,deduplicateHighlights:be,scrollToCoord:Se}=s(le,R?{}:v,J,ce,R,R?w:[],y,P),Ae=ve(he),Re=g(()=>{const e=G+1;return V.find(t=>e>=t.start_page&&e<=t.end_page)},[G,V]);h(()=>{void 0!==_&&_!==he&&me(_)},[_]);const Ie={...xe,goToNext:()=>{he>=fe-1||(xe.goToNext(),q&&q(he+1))},goToPrevious:()=>{he<=0||(xe.goToPrevious(),q&&q(he-1))}},_e=l.useCallback((e,t)=>{re.current+=1;const o=re.current;null!=ne.current&&window.clearTimeout(ne.current);let n=null,r=0,i=0;const a=()=>{if(re.current!==o)return;i+=1;const s=J.current?.querySelector(".rpv-core__inner-pages"),c=J.current?.querySelector(`[data-testid="core__page-layer-${t-1}"]`);if(!s||!c)return i>=40?(ne.current=null,void W?.({pageNumber:t,requestId:e.requestId})):void(ne.current=window.setTimeout(a,50));n===s.scrollTop?r+=1:(n=s.scrollTop,r=0);const l=s.getBoundingClientRect(),u=c.getBoundingClientRect(),d=Boolean(l&&u&&u.bottom>l.top&&u.top<l.bottom);if(r>=2&&d||i>=40)return ne.current=null,void W?.({pageNumber:t,requestId:e.requestId});ne.current=window.setTimeout(a,50)};ne.current=window.setTimeout(a,50)},[W]);if(h(()=>()=>{re.current+=1,null!=ne.current&&window.clearTimeout(ne.current)},[]),h(()=>{if(!D||X<=0)return;const e=Math.min(Math.max(Math.trunc(D.pageNumber),1),X),t=`${D.requestId??e}:${e}`;oe.current!==t&&(oe.current=t,Q(e-1),ye(e-1),_e(D,e))},[ye,D,X,_e]),!p)return e(m,{pages:I,activeCitationIndex:_,onActiveCitationChange:q,headerAction:L});return t("div",{ref:J,className:["citation-pdf-viewer",S?.pdfViewerWrapper].filter(Boolean).join(" "),"data-disable-pdf-annotations":O?"true":void 0,"data-pdf-page-fit":K===n.PageFit?"true":void 0,style:{height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column",...a.pdfViewer,display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA",...b?.pdfViewer,backgroundColor:"#F1F5F9"},children:[e(i,{highlightIndex:de,totalHighlights:fe,controls:Ie,currentPosition:Ae,pdfName:x,onClose:C,pdfUrl:p,viewerRef:J,customStyles:b,customClasses:S,customIcons:A,headerAction:L,isZoomEnabled:j,showHighlightsAction:F,showFullScreenAction:M,currentSegment:Re,segmentTooltipText:k,currentPage:G+1,totalPages:X,onPageNavigate:e=>{const t=Math.min(Math.max(e,1),X||e);Q(t-1),ye(t-1)},onRotatePage:()=>{const e=G+1;c.rotatePageBy90(e),te(c.getRotation(e))},currentPageRotation:ee,showRotateButton:E}),e(r,{defaultScale:K,pdfUrl:p,plugins:Te,customStyles:b,onLoad:e=>{Y(e.doc.numPages);const t=!R&&!N&&T<=0;if(T>0&&!N){const e=T-1,t=pe[e],o=v[t],n=w[e];me(e),console.log(n,"cordinateTargetHighlight"),R&&n.pageIndex>0&&ye(n.pageIndex),o>0&&(setTimeout(()=>{Ce(ce),be(o-1)},1e3),R||ye(o-1))}else if(N&&B&&2===B.length){(async()=>{const[e,t]=B;for(let o=e;o<=t;o++){const e=o-1;ye(e),await new Promise(e=>setTimeout(e,1e3)),Ce(ce);const t=be(e);if(t&&t>0)break}})()}else if(!R&&v){const e=pe.find(e=>v[e]>0);if(void 0!==e){const t=v[e]-1;ye(t),setTimeout(()=>{Ce(ce),be(t)},1e3)}}requestAnimationFrame(()=>{t&&we(),!R&&T>0&&!N&&(()=>{if(!J.current)return;const e=T-1,t=pe[e],o=v[t],n=o>0?o-1:0,r={};pe.forEach((e,t)=>{const o=v[e];o>0&&(r[o]||(r[o]=[]),r[o].push(t))});const i=(r[o]||[]).indexOf(e);let a=0;const s=()=>{if(a++,a>40)return;const e=J.current?.querySelector(".rpv-core__inner-pages");if(!e)return void setTimeout(s,100);const t=J.current?.querySelector(`[data-testid="core__page-layer-${n}"]`);if(!t)return void setTimeout(s,100);const o=e.getBoundingClientRect(),r=t.getBoundingClientRect();if(!(r.top<o.bottom&&r.bottom>o.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-o.top)-e.clientHeight/2+l.height/2;e.scrollTo({top:u,behavior:"smooth"})};setTimeout(s,500)})()})},onPageChange:e=>{const t=e.currentPage;Q(t),z?.(t+1),ce.has(t)?(be(t),Ce(ce)):Ce(ce)},renderPage:se,setRenderRange:Z})]})};export{p as default};
|
|
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":["PdfViewer","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":"stBAoGA,MA2BMA,EAAY,EAChBC,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,EAAiBC,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,EAA8B,MAC1CC,EAvEiB,CACvBC,IAEA,OAAQA,GACN,IAAK,aACH,OAAOtB,EAAiBC,WAE1B,IAAK,UACH,OAAOD,EAAiBuB,QAE1B,IAAK,YACH,OAAOvB,EAAiBwB,UAE1B,QACE,OAAOF,GAAStB,EAAiBwB,YAyDRC,CAAiB1B,IACvC2B,EA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B,EAAgBuE,SAAS,CAAE3D,IAAKP,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":["PdfViewer","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":"stBAoGA,MA2BMA,EAAY,EAChBC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ElC,IAAI9C,EAAW,EACf,MAEMqE,EAAsB,KAE1B,GADArE,IACIA,EAJc,GAIU,OAEtB,MAAAE,EAAkBtH,EAAUoC,SAASmF,cACzC,0BAEF,IAAKD,EAEH,YADAI,WAAW+D,EAAqB,KAI5B,MAAAhJ,EAAczC,EAAUoC,SAASmF,cACrC,kCAAkCC,OAEpC,IAAK/E,EAEH,YADAiF,WAAW+D,EAAqB,KAI5B,MAAAC,EAAsBpE,EAAgBO,wBACtCC,EAAWrF,EAAYoF,wBAK7B,KAHEC,EAASI,IAAMwD,EAAoBzD,QACnCH,EAASG,OAASyD,EAAoBxD,KAItC,YADAR,WAAW+D,EAAqB,KAI5B,MACAE,EADgBlJ,EAAYJ,iBAAiB,0BACtBkJ,GAE7B,IAAKI,EAEH,YADAjE,WAAW+D,EAAqB,KAI5B,MAAAG,EAAgBD,EAAO9D,wBACvBF,EACJL,EAAgBK,WACfiE,EAAc1D,IAAMwD,EAAoBxD,KACzCZ,EAAgBuE,aAAe,EAC/BD,EAAc7C,OAAS,EAEzBzB,EAAgBwE,SAAS,CAAE5D,IAAKP,EAAWoE,SAAU,YAGvDrE,WAAW+D,EAAqB,MA+HJO,MAIxBC,aAAenC,IACb,MAAMvJ,EAAcuJ,EAAEvJ,YACtBC,EAAeD,GACfd,IAAsBc,EAAc,GAC/B+D,GAAiBvB,IAAIxC,IAI1B2F,GAAsB3F,GACtB0F,GAAwB3B,KAJtB2B,GAAwB3B,KAM5BxE,WAAY2D,GACZ1D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class
|
|
1
|
+
import{zoomStateManager as t}from"./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 i=this.getPersistedRotation(t);0!==i&&this.applyRotation(e,t,i)}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 i=((this.rotations.get(e)||0)+90)%360;this.applyRotation(e,t,i)}setRotation(t,e){const i=(e%360+360)%360,n=this.pageMap.get(t);n&&this.applyRotation(n,t,i)}applyRotation(e,i,n){this.rotations.set(e,n);const o=e.closest(".rpv-core__page-layer");if(t.beginRotation(),o)if(0===n)o.style.transform="",o.style.transformOrigin="",o.style.transition="",o.style.pointerEvents="";else{o.style.transform=`rotate(${n}deg)`,o.style.transformOrigin="center center",o.style.transition="transform 0.2s ease",o.style.pointerEvents="auto";const e=()=>{o&&o instanceof HTMLElement&&(t.endRotation(),o.removeEventListener("transitionend",e))};o.addEventListener("transitionend",e,{once:!0})}this.notifyRotationChange(i,n),this.persistRotation(i,n)}onRotationChange(t){return this.rotationChangeListeners.add(t),()=>{this.rotationChangeListeners.delete(t)}}notifyRotationChange(t,e){this.rotationChangeListeners.forEach(i=>{try{i(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}`,i=localStorage.getItem(e);if(null===i)return 0;if(!i)return 0;const n=parseInt(i,10);return Number.isFinite(n)?n:0}persistRotation(t,e){if(!this.pdfIdentifier)return;const i=`pdf-rotation-${this.pdfIdentifier}-${t}`;0===e?localStorage.removeItem(i):localStorage.setItem(i,e.toString())}loadPersistedRotations(t){this.pdfIdentifier&&t.forEach(t=>{const e=this.getPersistedRotation(t);if(0!==e){const i=this.pageMap.get(t);i&&this.applyRotation(i,t,e)}})}clearAll(){this.pageMap.forEach((t,e)=>{const i=t.closest(".rpv-core__page-layer");if(i&&(i.style.transform="",i.style.transformOrigin="",i.style.transition=""),this.pdfIdentifier){const t=`pdf-rotation-${this.pdfIdentifier}-${e}`;localStorage.removeItem(t)}}),this.pageMap.clear(),this.rotations=new WeakMap,t.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,i)=>{const n=this.rotations.get(e);void 0!==n&&0!==n&&t.set(i,n)}),t}}const i=new e;export{e as RotationManager,i as rotationManager};
|
|
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":"AACO,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,GAC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AAkB,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":"yDAEO,MAAMA,EAAN,WAAAC,GACGC,KAAAC,cAA8CC,QAC9CF,KAAAG,YAAwCC,IACxCJ,KAAAK,4BAA6EC,IACrFN,KAAQO,cA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Q,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,EAAiBqC,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
|
-
import{jsx as e,Fragment as t}from"react/jsx-runtime";import{useState as r,useRef as n,useMemo as o}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as i}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as s}from"@react-pdf-viewer/zoom";import{highlightPlugin as c}from"@react-pdf-viewer/highlight";const a=(a,h,g,u,p,f,d="yellow",m="#F6D739")=>{const[x,T]=r(0),v=n(!1),[y,w]=r(0);n([]);const M=e=>e.replace(/[^\S\n]+/g," ").trim(),b=e=>(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim(),I=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},_=e=>{const t=b(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},S=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 S(e).split(/\n+/).map(I).flatMap(e=>{const t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(e=>e.trim()).filter(Boolean):[e]}).map(e=>M((e=>e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2"))(e))).filter(Boolean)},E=Object.keys(h).map(Number).sort((e,t)=>e-t),A=o(()=>p?f.length:p?0:Object.values(h).filter(e=>e>0).length,[f,h]),B=e=>{if(!g.current)return;const t=g.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=C.map(_),o=R.map(_);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 i=[];let s=null,c=[];const h=()=>{if(!s)return;const e=c.join(" ");s.title=b(e),s.title&&i.push(s),s=null,c=[]};if(l.forEach(e=>{if(!s)return s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(c=[e.text]);const t=Math.abs(e.top-s.lastTop)<=5,r=e.left<=s.lastRight+28;t&&r?(s.elements.push(e.el),s.lastTop=e.top,s.lastRight=Math.max(s.lastRight,e.right),c.push(e.text)):(h(),s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},c=[e.text])}),h(),0===i.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([...C,...R].map(b).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<i.length;r++){let n="",o="";const l=new Set;for(let s=r;s<i.length&&s<r+20;s++){const r=i[s].title;if(n=n?`${n} ${r}`:r,o=o?`${o}${r.replace(/\s+/g,"")}`:r.replace(/\s+/g,""),l.add(s),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<i.length;n++){let o="",l="";const s=new Set;for(let c=n;c<i.length&&c<n+15;c++){const n=i[c].title;if(o=o?`${o} ${n}`:n,l=l?`${l}${n.replace(/\s+/g,"")}`:n.replace(/\s+/g,""),s.add(c),o.includes(e)||l.includes(r)){const r=Math.max(0,o.length-e.length);(!t||r<t.extra)&&(t={blocks:new Set(s),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))})(i),T=R.map(b).filter(e=>e.length>=8),v=T.map(e=>e.split(/\s+/).filter(e=>e.length>=2));if(0===p){const e=o;for(let t=0;t<i.length;t++){const r=i[t].title;for(let n=0;n<e.length;n++){if(!u(r,e[n]))continue;let o=0;const l=new Set;let s=n,c=t-1;for(let r=t;r<i.length&&s<e.length;r++){if(u(i[r].title,e[s])){if(c>=0){const e=i[c].lastTop,t=i[r].lastTop;if(Math.abs(t-e)>x)break}o++,l.add(r),c=r,s++}else if(s>0&&u(i[r].title,e[s-1])){const e=i[c].lastTop,t=i[r].lastTop;Math.abs(t-e)<=3&&(l.add(r),c=r)}if(r-c>6)break}o>p&&(p=o,f=l)}}}if(p<Math.min(3,T.length)&&T.length>0){const e=new Set;i.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 v){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 y=new Set;if(F.forEach(e=>{const t=b(e);t&&(y.add(t),y.add(t.replace(/\s+/g,"")))}),0===p){const e=new Set;if(i.forEach((t,r)=>{const n=t.title.replace(/\s+/g,"");if(y.has(t.title)||y.has(n))return void e.add(r);const o=Array.from(y);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}i.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 w=[];return i.forEach((e,t)=>{f.has(t)&&e.elements.forEach(e=>w.push(e))}),requestAnimationFrame(()=>{const e=w.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->",a),console.log("processed sentences->",C),console.log("processed lines->",R),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},k=e=>{if(!g.current)return;g.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"})})},z=a.map(e=>(e=>e?S(e).split(/\n{2,}/).map(e=>$(e).join(" ")).map(e=>M(e)).filter(Boolean):[])(e)).flat(),q=a.map(e=>$(e)).flat(),j=z.some(e=>e.length>=3)?3:1,C=z.filter(e=>e.length>=j),R=q.filter(e=>e.length>=j),H=R.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)),F=Array.from(new Set([...C,...R,...H].flatMap(e=>{const t=M(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];const r=t.replace(/[\u2013\u2014]/g,"-"),n=M(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=M(r.replace(/-/g," ")),l=M(r.replace(/-/g,"")),i=M(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<j)&&(t.length>=3||e.length>=12)}),N=l({keyword:F}),P=i(),Z=s(),{jumpToMatch:O}=N,{jumpToPage:L}=P,{zoomTo:D,ZoomInButton:W,ZoomOutButton:K,ZoomPopover:J}=Z,V=o(()=>(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:c,pageNumber:a}=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],c=e.left+e.width,a=e.top+e.height,f=Math.max(0,Math.min(h,c)-Math.max(o,e.left))*Math.max(0,Math.min(g,a)-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,c),g=Math.max(g,a),i=h-o,s=g-l,u.push(e.originalIndex),n[r]=!0,p=!0)}}r.push({pageIndex:c,pageNumber:a,left:o,top:l,width:i,height:s,originalIndexes:u})}}),r})(f),[f]),G=c({renderHighlights:r=>e(t,{children:V.filter(e=>null!=e.pageNumber?e.pageNumber-1===r.pageIndex:e.pageIndex===r.pageIndex).map(t=>{const r=t.originalIndexes.includes(y);return e("div",{style:{position:"absolute",left:`${t.left}%`,top:`${t.top+.08*t.height}%`,width:`${t.width}%`,height:.95*t.height+"%",background:r?m:d,opacity:r?.7:.4,transition:"background 0.2s, opacity 0.2s",border:r?"1px solid red":"1px solid transparent"}},t.originalIndexes.join("-"))})})}),Q=()=>{if(!v.current)try{O(0),v.current=!0;const e=f[0];e&&p&&X(e.pageIndex,e.top)}catch{requestAnimationFrame(Q)}},U=(e,t)=>{if(!g.current)return;if(!g.current.querySelector(".rpv-core__viewer"))return;let r=-1;const n=()=>{const o=g.current?.querySelector(".rpv-core__inner-pages");if(!o)return;if(o.scrollTop!==r)return r=o.scrollTop,void setTimeout(n,100);const l=g.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(),a=o.scrollTop+(c.top-s.top)-o.clientHeight/2+c.height/2;o.scrollTo({top:a,behavior:"smooth"})};setTimeout(n,300)},X=(e,t,r=0)=>{if(!g.current)return;let n=0;const o=()=>{if(++n>60)return;const l=g.current?.querySelector(".rpv-core__inner-pages");if(!l)return void setTimeout(o,100);const i=g.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(),a=t/100*s.height,h=r/100*s.height,u=s.top-c.top+a,p=u+h;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)},Y=o(()=>{const e={};return E.forEach((t,r)=>{const n=h[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[E,h]),ee=e=>{const t=h[E[e]];return(Y[t]||[]).indexOf(e)},te=(e,t,r=0)=>{if(!g.current)return;let n=-1,o=0;const l=()=>{if(++o>60)return;const i=g.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=g.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 a=i.getBoundingClientRect(),h=t/100*c.height,u=r/100*c.height,p=c.top-a.top+h,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:T,highlightIndex:x,cursorIndex:y,setCursorIndex:w,orderedKeys:E,totalHighlights:A,getValidPosition:e=>{if(p)return e+1;if(!h)return 0;let t=0;for(let r=0;r<=e;r++)h[E[r]]>0&&t++;return t},tryJump:Q,jumpToPage:L,zoomTo:D,hideNonTargetHighlights:k,deduplicateHighlights:B,scrollToCoord:X,plugins:[p?G:N,P,Z],controls:{ZoomInButton:W,ZoomOutButton:K,ZoomPopover:J,zoomTo:D,goToNext:()=>{if(p&&f)for(let e=y+1;e<f.length;e++){const t=f[e],r=f[y];return w(e),void(t.pageIndex!==r.pageIndex?(L(t.pageIndex),te(t.pageIndex,t.top,t.height)):X(t.pageIndex,t.top,t.height))}else{for(let e=y+1;e<E.length;e++){const t=E[e];if(h[t]>0){const r=h[t]-1,n=ee(e);return w(e),L(h[t]-1),U(r,n),setTimeout(()=>{B(r)},500),void(1===Object.keys(h).length&&k(u))}}}},goToPrevious:()=>{if(p&&f)for(let e=y-1;e>=0;e--){const t=f[e],r=f[y];return w(e),void(t.pageIndex!==r.pageIndex?(L(t.pageIndex),te(t.pageIndex,t.top,t.height)):X(t.pageIndex,t.top,t.height))}else{for(let e=y-1;e>=0;e--){const t=E[e];if(h[t]>0){const r=h[t]-1,n=ee(e);return w(e),L(h[t]-1),U(r,n),setTimeout(()=>{B(r)},500),void(1===Object.keys(h).length&&k(u))}}}}}}};export{a as PdfHighlightControls};
|
|
1
|
+
import{jsx as e,Fragment as t}from"react/jsx-runtime";import{useState as r,useRef as n,useMemo as o}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as i}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as s}from"@react-pdf-viewer/zoom";import{highlightPlugin as c}from"@react-pdf-viewer/highlight";const a=(a,h,g,u,p,f,d="yellow",m="#F6D739")=>{const[x,T]=r(0),v=n(!1),[y,w]=r(0);n([]);const M=e=>e.replace(/[^\S\n]+/g," ").trim(),b=e=>(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim(),_=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},I=e=>{const t=b(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},S=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 S(e).split(/\n+/).map(_).flatMap(e=>{const t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(e=>e.trim()).filter(Boolean):[e]}).map(e=>M((e=>e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2"))(e))).filter(Boolean)},E=Object.keys(h).map(Number).sort((e,t)=>e-t),A=o(()=>p?f.length:p?0:Object.values(h).filter(e=>e>0).length,[f,h]),k=e=>{if(!g.current)return;const t=g.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(I),o=R.map(I);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 i=[];let s=null,c=[];const h=()=>{if(!s)return;const e=c.join(" ");s.title=b(e),s.title&&i.push(s),s=null,c=[]};if(l.forEach(e=>{if(!s)return s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(c=[e.text]);const t=Math.abs(e.top-s.lastTop)<=5,r=e.left<=s.lastRight+28;t&&r?(s.elements.push(e.el),s.lastTop=e.top,s.lastRight=Math.max(s.lastRight,e.right),c.push(e.text)):(h(),s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},c=[e.text])}),h(),0===i.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,...R].map(b).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<i.length;r++){let n="",o="";const l=new Set;for(let s=r;s<i.length&&s<r+20;s++){const r=i[s].title;if(n=n?`${n} ${r}`:r,o=o?`${o}${r.replace(/\s+/g,"")}`:r.replace(/\s+/g,""),l.add(s),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<i.length;n++){let o="",l="";const s=new Set;for(let c=n;c<i.length&&c<n+15;c++){const n=i[c].title;if(o=o?`${o} ${n}`:n,l=l?`${l}${n.replace(/\s+/g,"")}`:n.replace(/\s+/g,""),s.add(c),o.includes(e)||l.includes(r)){const r=Math.max(0,o.length-e.length);(!t||r<t.extra)&&(t={blocks:new Set(s),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))})(i),T=R.map(b).filter(e=>e.length>=8),v=T.map(e=>e.split(/\s+/).filter(e=>e.length>=2));if(0===p){const e=o;for(let t=0;t<i.length;t++){const r=i[t].title;for(let n=0;n<e.length;n++){if(!u(r,e[n]))continue;let o=0;const l=new Set;let s=n,c=t-1;for(let r=t;r<i.length&&s<e.length;r++){if(u(i[r].title,e[s])){if(c>=0){const e=i[c].lastTop,t=i[r].lastTop;if(Math.abs(t-e)>x)break}o++,l.add(r),c=r,s++}else if(s>0&&u(i[r].title,e[s-1])){const e=i[c].lastTop,t=i[r].lastTop;Math.abs(t-e)<=3&&(l.add(r),c=r)}if(r-c>6)break}o>p&&(p=o,f=l)}}}if(p<Math.min(3,T.length)&&T.length>0){const e=new Set;i.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 v){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 y=new Set;if(F.forEach(e=>{const t=b(e);t&&(y.add(t),y.add(t.replace(/\s+/g,"")))}),0===p){const e=new Set;if(i.forEach((t,r)=>{const n=t.title.replace(/\s+/g,"");if(y.has(t.title)||y.has(n))return void e.add(r);const o=Array.from(y);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}i.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 w=[];return i.forEach((e,t)=>{f.has(t)&&e.elements.forEach(e=>w.push(e))}),requestAnimationFrame(()=>{const e=w.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->",a),console.log("processed sentences->",j),console.log("processed lines->",R),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},z=e=>{if(!g.current)return;g.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"})})},q=a.map(e=>(e=>e?S(e).split(/\n{2,}/).map(e=>$(e).join(" ")).map(e=>M(e)).filter(Boolean):[])(e)).flat(),B=a.map(e=>$(e)).flat(),C=q.some(e=>e.length>=3)?3:1,j=q.filter(e=>e.length>=C),R=B.filter(e=>e.length>=C),H=R.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)),F=Array.from(new Set([...j,...R,...H].flatMap(e=>{const t=M(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];const r=t.replace(/[\u2013\u2014]/g,"-"),n=M(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=M(r.replace(/-/g," ")),l=M(r.replace(/-/g,"")),i=M(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<C)&&(t.length>=3||e.length>=12)}),N=l({keyword:F}),P=i(),L=s(),{jumpToMatch:O}=N,{jumpToPage:Z}=P,{zoomTo:D,CurrentScale:W,ZoomPopover:K}=L,J=o(()=>(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:c,pageNumber:a}=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],c=e.left+e.width,a=e.top+e.height,f=Math.max(0,Math.min(h,c)-Math.max(o,e.left))*Math.max(0,Math.min(g,a)-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,c),g=Math.max(g,a),i=h-o,s=g-l,u.push(e.originalIndex),n[r]=!0,p=!0)}}r.push({pageIndex:c,pageNumber:a,left:o,top:l,width:i,height:s,originalIndexes:u})}}),r})(f),[f]),V=c({renderHighlights:r=>e(t,{children:J.filter(e=>null!=e.pageNumber?e.pageNumber-1===r.pageIndex:e.pageIndex===r.pageIndex).map(t=>{const r=t.originalIndexes.includes(y);return e("div",{style:{position:"absolute",left:`${t.left}%`,top:`${t.top+.08*t.height}%`,width:`${t.width}%`,height:.95*t.height+"%",background:r?m:d,opacity:r?.7:.4,transition:"background 0.2s, opacity 0.2s",border:r?"1px solid red":"1px solid transparent"}},t.originalIndexes.join("-"))})})}),G=()=>{if(!v.current)try{O(0),v.current=!0;const e=f[0];e&&p&&U(e.pageIndex,e.top)}catch{requestAnimationFrame(G)}},Q=(e,t)=>{if(!g.current)return;if(!g.current.querySelector(".rpv-core__viewer"))return;let r=-1;const n=()=>{const o=g.current?.querySelector(".rpv-core__inner-pages");if(!o)return;if(o.scrollTop!==r)return r=o.scrollTop,void setTimeout(n,100);const l=g.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(),a=o.scrollTop+(c.top-s.top)-o.clientHeight/2+c.height/2;o.scrollTo({top:a,behavior:"smooth"})};setTimeout(n,300)},U=(e,t,r=0)=>{if(!g.current)return;let n=0;const o=()=>{if(++n>60)return;const l=g.current?.querySelector(".rpv-core__inner-pages");if(!l)return void setTimeout(o,100);const i=g.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(),a=t/100*s.height,h=r/100*s.height,u=s.top-c.top+a,p=u+h;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)},X=o(()=>{const e={};return E.forEach((t,r)=>{const n=h[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[E,h]),Y=e=>{const t=h[E[e]];return(X[t]||[]).indexOf(e)},ee=(e,t,r=0)=>{if(!g.current)return;let n=-1,o=0;const l=()=>{if(++o>60)return;const i=g.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=g.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 a=i.getBoundingClientRect(),h=t/100*c.height,u=r/100*c.height,p=c.top-a.top+h,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:T,highlightIndex:x,cursorIndex:y,setCursorIndex:w,orderedKeys:E,totalHighlights:A,getValidPosition:e=>{if(p)return e+1;if(!h)return 0;let t=0;for(let r=0;r<=e;r++)h[E[r]]>0&&t++;return t},tryJump:G,jumpToPage:Z,zoomTo:D,hideNonTargetHighlights:z,deduplicateHighlights:k,scrollToCoord:U,plugins:[p?V:N,P,L],controls:{CurrentScale:W,ZoomPopover:K,zoomTo:D,goToNext:()=>{if(p&&f)for(let e=y+1;e<f.length;e++){const t=f[e],r=f[y];return w(e),void(t.pageIndex!==r.pageIndex?(Z(t.pageIndex),ee(t.pageIndex,t.top,t.height)):U(t.pageIndex,t.top,t.height))}else{for(let e=y+1;e<E.length;e++){const t=E[e];if(h[t]>0){const r=h[t]-1,n=Y(e);return w(e),Z(h[t]-1),Q(r,n),setTimeout(()=>{k(r)},500),void(1===Object.keys(h).length&&z(u))}}}},goToPrevious:()=>{if(p&&f)for(let e=y-1;e>=0;e--){const t=f[e],r=f[y];return w(e),void(t.pageIndex!==r.pageIndex?(Z(t.pageIndex),ee(t.pageIndex,t.top,t.height)):U(t.pageIndex,t.top,t.height))}else{for(let e=y-1;e>=0;e--){const t=E[e];if(h[t]>0){const r=h[t]-1,n=Y(e);return w(e),Z(h[t]-1),Q(r,n),setTimeout(()=>{k(r)},500),void(1===Object.keys(h).length&&z(u))}}}}}}};export{a as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|