@e-llm-studio/citation 0.0.156 → 0.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/features/ScannedDocCitation/ScannedDocCitation.js +1 -1
- package/dist/features/ScannedDocCitation/ScannedDocCitation.js +1 -1
- package/dist/types/src/features/ScannedDocCitation/ScannedDocCitation.d.ts +3 -1
- package/dist/types/src/features/ScannedDocCitation/ScannedDocCitation.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1150,6 +1150,8 @@ return <ScannedDocCitation images={images} highlights={highlights} />;
|
|
|
1150
1150
|
| `highlights` | `PageHighlight[]` | ✅ | — | Array of highlight groups with bounding boxes per page |
|
|
1151
1151
|
| `highlightColor` | `string` | ❌ | `rgba(255, 220, 0, 0.15)` | Background color of inactive highlights |
|
|
1152
1152
|
| `citationLabelColor` | `string` | ❌ | `#FFFF2E` | Background color of the citation label. |
|
|
1153
|
+
| `subHeadingText` | `string` | ❌ | `""` | Gives you option to add a heading to ScannedDocCitation. |
|
|
1154
|
+
| `showFullScreenMode` | `boolean` | ❌ | `true` | Gives you option to toggle fullscreen tool in renderNav. |
|
|
1153
1155
|
| `showCitationLabelOnHover` | `boolean` | ❌ | `true` | Show label only on hover (if `false` → always visible). |
|
|
1154
1156
|
| `highlightActiveColor` | `string` | ❌ | `rgba(255, 220, 0, 0.35)` | Background color of the currently active highlight |
|
|
1155
1157
|
| `highlightBorderColor` | `string` | ❌ | `rgba(200, 160, 0, 0.4)` | Border color of the active highlight |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),t=require("lucide-react"),o=require("../ChatCitation/components/wrappers/Modal.js");exports.default=function(r){var s=r.images,a=r.highlights,l=r.pages,d=r.subHeadingText,c=void 0===d?"":d,u=r.showFullScreenMode,g=void 0===u||u,x=r.citationLabelColor,p=void 0===x?"#FFFF2E":x,h=r.showCitationLabelOnHover,f=void 0!==h&&h,_=r.highlightColor,b=void 0===_?"rgba(255, 220, 0, 0.15)":_,v=r.highlightActiveColor,m=void 0===v?"rgba(255, 220, 0, 0.35)":v,y=r.highlightBorderColor,j=void 0===y?"rgba(200, 160, 0, 0.4)":y,C=r.height,w=void 0===C?"700px":C,k=[],I=[];(null==l?void 0:l.length)?l.forEach(function(e,i){var n;e.gs_url&&k.push(e.gs_url),null===(n=e.highlighted_coordinates)||void 0===n||n.forEach(function(e){I.push({pageIndex:i,bboxes:[e]})})}):(k.push.apply(k,s||[]),I.push.apply(I,a||[]));var S=I.flatMap(function(e,i){return e.bboxes.map(function(n,t){return{bbox:n,pageIndex:e.pageIndex,key:"".concat(i,"-").concat(t)}})}).length,z=n.useState(null),M=z[0],R=z[1],F=n.useState(0),B=F[0],q=F[1],L=n.useState(!1),D=L[0],E=L[1],H=n.useState({}),T=H[0],O=H[1],P=n.useRef(null),A=n.useRef(null),W=n.useRef([]),U=n.useRef([]),X=n.useCallback(function(e,i){void 0===i&&(i=!1);var n=Math.max(0,Math.min(S-1,e));q(n),requestAnimationFrame(function(){var e=i?A.current:P.current,t=(i?U:W).current[n];if(e&&t){var o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),s=r.top-o.top+e.scrollTop-e.clientHeight/2+r.height/2;e.scrollTo({top:s,behavior:"smooth"})}})},[S]),Y=function(n){return void 0===n&&(n=!1),S>0&&i.jsx("div",e.__assign({style:{display:"flex",alignItems:"center",marginBottom:"6px"}},{children:i.jsxs("div",e.__assign({style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"}},{children:[i.jsxs("span",e.__assign({style:{fontSize:"12px",color:"#888"}},{children:[B+1," / ",S]})),i.jsx("button",e.__assign({onClick:function(){return X(B-1,n)},disabled:B<=0,style:{padding:"2px 4px",cursor:B<=0?"not-allowed":"pointer",opacity:B<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i.jsx(t.ChevronUp,{size:14,color:"#64748b"})})),i.jsx("button",e.__assign({onClick:function(){return X(B+1,n)},disabled:B>=S-1,style:{padding:"2px 4px",cursor:B>=S-1?"not-allowed":"pointer",opacity:B>=S-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i.jsx(t.ChevronDown,{size:14,color:"#64748b"})})),g&&i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{width:"1px",height:"16px",background:"#e2e8f0",margin:"0 2px"}}),n?i.jsx(t.X,{size:16,color:"#64748b",style:{cursor:"pointer"},onClick:function(){return E(!1)}}):i.jsx(t.Maximize2,{size:16,color:"#64748b",style:{cursor:"pointer"},onClick:function(){return E(!0)}})]})]}))}))},G=function(n){void 0===n&&(n=!1);var t=n?U:W,o=-1;return k.map(function(n,r){var s=I.filter(function(e){return e.pageIndex===r}).flatMap(function(e,i){return e.bboxes.map(function(e,n){return o++,{bbox:e,key:"".concat(r,"-").concat(i,"-").concat(n),globalIndex:o}})});return i.jsxs("div",e.__assign({style:{marginBottom:"8px"}},{children:[i.jsxs("div",e.__assign({style:{fontSize:"12px",color:"#888",marginBottom:"4px"}},{children:["Page ",r+1]})),i.jsx("div",e.__assign({style:{position:"relative",width:"100%",paddingTop:"129%",flexShrink:0}},{children:i.jsxs("div",e.__assign({style:{position:"absolute",inset:0}},{children:[i.jsx("img",{src:n,alt:"Page ".concat(r+1),style:{display:"block",width:"100%",height:"100%",objectFit:"fill"},draggable:!1,ref:function(i){i&&i.complete&&!T[r]&&O(function(i){var n;return e.__assign(e.__assign({},i),((n={})[r]=!0,n))})},onLoad:function(){return O(function(i){var n;return e.__assign(e.__assign({},i),((n={})[r]=!0,n))})}}),T[r]&&s.map(function(n){var o=n.bbox,r=n.key,s=n.globalIndex,a=B===s;return i.jsx("div",e.__assign({ref:function(e){t.current[s]=e},onMouseEnter:function(){return R(s)},onMouseLeave:function(){return R(null)},style:{position:"absolute",left:"".concat(100*o.xmin,"%"),top:"".concat(100*o.ymin,"%"),width:"".concat(100*(o.xmax-o.xmin),"%"),height:"".concat(100*(o.ymax-o.ymin),"%"),background:a?m:b,border:a?"1.5px solid ".concat(j):"none",borderRadius:"2px",zIndex:2}},{children:f&&M===s&&i.jsxs("div",e.__assign({style:{position:"absolute",top:"-18px",right:"0",fontSize:"10px",background:p,color:"black",padding:"2px 6px",borderRadius:"3px",whiteSpace:"nowrap"}},{children:["Citation ",s+1]}))}),r)})]}))}))]}),r)})},J={overflowY:"auto",border:"1px solid #ddd",borderRadius:"4px",padding:"8px",paddingBottom:0,display:"flex",flexDirection:"column",boxSizing:"border-box"};return i.jsxs(i.Fragment,{children:[i.jsxs("div",e.__assign({style:{width:"100%",maxWidth:"800px",fontFamily:"inherit",display:"flex",flexDirection:"column"}},{children:[(c||S>0)&&i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",marginBottom:"6px"}},{children:[c&&i.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#111"}},{children:c})),i.jsx("div",e.__assign({style:{marginLeft:"auto"}},{children:Y(!1)}))]})),i.jsx("div",e.__assign({ref:P,style:e.__assign(e.__assign({},J),{maxHeight:w})},{children:G(!1)}))]})),i.jsx(o.Modal,e.__assign({isOpen:D,onClose:function(){return E(!1)}},{children:i.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}},{children:[Y(!0),i.jsx("div",e.__assign({ref:A,style:e.__assign(e.__assign({},J),{flex:1})},{children:D&&G(!0)}))]}))}))]})};
|
|
2
2
|
//# sourceMappingURL=ScannedDocCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as i,Fragment as n,jsx as o}from"react/jsx-runtime";import{useState as t,useRef as r,useCallback as l}from"react";import{ChevronUp as d,ChevronDown as a,X as c,Maximize2 as p}from"lucide-react";import{Modal as u}from"../ChatCitation/components/wrappers/Modal.js";function s(s){var h=s.images,g=s.highlights,x=s.pages,f=s.subHeadingText,b=void 0===f?"":f,m=s.showFullScreenMode,v=void 0===m||m,y=s.citationLabelColor,w=void 0===y?"#FFFF2E":y,k=s.showCitationLabelOnHover,C=void 0!==k&&k,I=s.highlightColor,z=void 0===I?"rgba(255, 220, 0, 0.15)":I,B=s.highlightActiveColor,F=void 0===B?"rgba(255, 220, 0, 0.35)":B,M=s.highlightBorderColor,S=void 0===M?"rgba(200, 160, 0, 0.4)":M,R=s.height,L=void 0===R?"700px":R,E=[],H=[];(null==x?void 0:x.length)?x.forEach(function(e,i){var n;e.gs_url&&E.push(e.gs_url),null===(n=e.highlighted_coordinates)||void 0===n||n.forEach(function(e){H.push({pageIndex:i,bboxes:[e]})})}):(E.push.apply(E,h||[]),H.push.apply(H,g||[]));var T=H.flatMap(function(e,i){return e.bboxes.map(function(n,o){return{bbox:n,pageIndex:e.pageIndex,key:"".concat(i,"-").concat(o)}})}).length,j=t(null),D=j[0],_=j[1],A=t(0),O=A[0],P=A[1],W=t(!1),q=W[0],Y=W[1],G=t({}),J=G[0],K=G[1],N=r(null),Q=r(null),U=r([]),V=r([]),X=l(function(e,i){void 0===i&&(i=!1);var n=Math.max(0,Math.min(T-1,e));P(n),requestAnimationFrame(function(){var e=i?Q.current:N.current,o=(i?V:U).current[n];if(e&&o){var t=e.getBoundingClientRect(),r=o.getBoundingClientRect(),l=r.top-t.top+e.scrollTop-e.clientHeight/2+r.height/2;e.scrollTo({top:l,behavior:"smooth"})}})},[T]),Z=function(t){return void 0===t&&(t=!1),T>0&&o("div",e({style:{display:"flex",alignItems:"center",marginBottom:"6px"}},{children:i("div",e({style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"}},{children:[i("span",e({style:{fontSize:"12px",color:"#888"}},{children:[O+1," / ",T]})),o("button",e({onClick:function(){return X(O-1,t)},disabled:O<=0,style:{padding:"2px 4px",cursor:O<=0?"not-allowed":"pointer",opacity:O<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:o(d,{size:14,color:"#64748b"})})),o("button",e({onClick:function(){return X(O+1,t)},disabled:O>=T-1,style:{padding:"2px 4px",cursor:O>=T-1?"not-allowed":"pointer",opacity:O>=T-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:o(a,{size:14,color:"#64748b"})})),v&&i(n,{children:[o("span",{style:{width:"1px",height:"16px",background:"#e2e8f0",margin:"0 2px"}}),t?o(c,{size:16,color:"#64748b",style:{cursor:"pointer"},onClick:function(){return Y(!1)}}):o(p,{size:16,color:"#64748b",style:{cursor:"pointer"},onClick:function(){return Y(!0)}})]})]}))}))},$=function(n){void 0===n&&(n=!1);var t=n?V:U,r=-1;return E.map(function(n,l){var d=H.filter(function(e){return e.pageIndex===l}).flatMap(function(e,i){return e.bboxes.map(function(e,n){return r++,{bbox:e,key:"".concat(l,"-").concat(i,"-").concat(n),globalIndex:r}})});return i("div",e({style:{marginBottom:"8px"}},{children:[i("div",e({style:{fontSize:"12px",color:"#888",marginBottom:"4px"}},{children:["Page ",l+1]})),o("div",e({style:{position:"relative",width:"100%",paddingTop:"129%",flexShrink:0}},{children:i("div",e({style:{position:"absolute",inset:0}},{children:[o("img",{src:n,alt:"Page ".concat(l+1),style:{display:"block",width:"100%",height:"100%",objectFit:"fill"},draggable:!1,ref:function(i){i&&i.complete&&!J[l]&&K(function(i){var n;return e(e({},i),((n={})[l]=!0,n))})},onLoad:function(){return K(function(i){var n;return e(e({},i),((n={})[l]=!0,n))})}}),J[l]&&d.map(function(n){var r=n.bbox,l=n.key,d=n.globalIndex,a=O===d;return o("div",e({ref:function(e){t.current[d]=e},onMouseEnter:function(){return _(d)},onMouseLeave:function(){return _(null)},style:{position:"absolute",left:"".concat(100*r.xmin,"%"),top:"".concat(100*r.ymin,"%"),width:"".concat(100*(r.xmax-r.xmin),"%"),height:"".concat(100*(r.ymax-r.ymin),"%"),background:a?F:z,border:a?"1.5px solid ".concat(S):"none",borderRadius:"2px",zIndex:2}},{children:C&&D===d&&i("div",e({style:{position:"absolute",top:"-18px",right:"0",fontSize:"10px",background:w,color:"black",padding:"2px 6px",borderRadius:"3px",whiteSpace:"nowrap"}},{children:["Citation ",d+1]}))}),l)})]}))}))]}),l)})},ee={overflowY:"auto",border:"1px solid #ddd",borderRadius:"4px",padding:"8px",paddingBottom:0,display:"flex",flexDirection:"column",boxSizing:"border-box"};return i(n,{children:[i("div",e({style:{width:"100%",maxWidth:"800px",fontFamily:"inherit",display:"flex",flexDirection:"column"}},{children:[(b||T>0)&&i("div",e({style:{display:"flex",alignItems:"center",marginBottom:"6px"}},{children:[b&&o("div",e({style:{fontSize:"14px",fontWeight:500,color:"#111"}},{children:b})),o("div",e({style:{marginLeft:"auto"}},{children:Z(!1)}))]})),o("div",e({ref:N,style:e(e({},ee),{maxHeight:L})},{children:$(!1)}))]})),o(u,e({isOpen:q,onClose:function(){return Y(!1)}},{children:i("div",e({style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}},{children:[Z(!0),o("div",e({ref:Q,style:e(e({},ee),{flex:1})},{children:q&&$(!0)}))]}))}))]})}export{s as default};
|
|
2
2
|
//# sourceMappingURL=ScannedDocCitation.js.map
|
|
@@ -34,10 +34,12 @@ export interface ScannedDocCitationProps {
|
|
|
34
34
|
pages?: CitationPage[];
|
|
35
35
|
citationLabelColor?: string;
|
|
36
36
|
showCitationLabelOnHover?: boolean;
|
|
37
|
+
subHeadingText?: string;
|
|
38
|
+
showFullScreenMode?: boolean;
|
|
37
39
|
highlightColor?: string;
|
|
38
40
|
highlightActiveColor?: string;
|
|
39
41
|
highlightBorderColor?: string;
|
|
40
42
|
height?: string | number;
|
|
41
43
|
}
|
|
42
|
-
export default function ScannedDocCitation({ images, highlights, pages, citationLabelColor, showCitationLabelOnHover, highlightColor, highlightActiveColor, highlightBorderColor, height, }: ScannedDocCitationProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export default function ScannedDocCitation({ images, highlights, pages, subHeadingText, showFullScreenMode, citationLabelColor, showCitationLabelOnHover, highlightColor, highlightActiveColor, highlightBorderColor, height, }: ScannedDocCitationProps): import("react/jsx-runtime").JSX.Element;
|
|
43
45
|
//# sourceMappingURL=ScannedDocCitation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScannedDocCitation.d.ts","sourceRoot":"","sources":["../../../../../src/features/ScannedDocCitation/ScannedDocCitation.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,IAAI,EAAE,CAAC;CAChB;AACD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB,CAAC,EAAE,IAAI,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,MAAM,EACN,UAAU,EACV,KAAK,EACL,kBAA8B,EAC9B,wBAAgC,EAChC,cAA0C,EAC1C,oBAAgD,EAChD,oBAA+C,EAC/C,MAAgB,GACjB,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ScannedDocCitation.d.ts","sourceRoot":"","sources":["../../../../../src/features/ScannedDocCitation/ScannedDocCitation.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,IAAI,EAAE,CAAC;CAChB;AACD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB,CAAC,EAAE,IAAI,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAiB,EACjB,kBAAuB,EACvB,kBAA8B,EAC9B,wBAAgC,EAChC,cAA0C,EAC1C,oBAAgD,EAChD,oBAA+C,EAC/C,MAAgB,GACjB,EAAE,uBAAuB,2CAiOzB"}
|