@anaralabs/lector 3.5.5 → 3.5.6
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/_tsup-dts-rollup.d.ts +6 -2
- package/dist/index.js +24 -6
- package/package.json +1 -1
|
@@ -32,6 +32,7 @@ declare interface Annotation {
|
|
|
32
32
|
pageNumber: number;
|
|
33
33
|
}>;
|
|
34
34
|
color: string;
|
|
35
|
+
borderColor: string;
|
|
35
36
|
createdAt: Date;
|
|
36
37
|
updatedAt: Date;
|
|
37
38
|
comment?: string;
|
|
@@ -40,7 +41,7 @@ declare interface Annotation {
|
|
|
40
41
|
export { Annotation }
|
|
41
42
|
export { Annotation as Annotation_alias_1 }
|
|
42
43
|
|
|
43
|
-
export declare const AnnotationHighlightLayer: ({ className, style, renderTooltipContent, renderHoverTooltipContent, tooltipClassName, highlightClassName, focusedAnnotationId, focusedHoverAnnotationId, onAnnotationClick, hoverTooltipClassName }: AnnotationHighlightLayerProps) => JSX.Element;
|
|
44
|
+
export declare const AnnotationHighlightLayer: ({ className, style, renderTooltipContent, renderHoverTooltipContent, tooltipClassName, highlightClassName, focusedAnnotationId, focusedHoverAnnotationId, onAnnotationClick, hoverTooltipClassName, tooltipBubbleSize, }: AnnotationHighlightLayerProps) => JSX.Element;
|
|
44
45
|
|
|
45
46
|
declare interface AnnotationHighlightLayerProps {
|
|
46
47
|
className?: string;
|
|
@@ -59,6 +60,7 @@ declare interface AnnotationHighlightLayerProps {
|
|
|
59
60
|
tooltipClassName?: string;
|
|
60
61
|
hoverTooltipClassName?: string;
|
|
61
62
|
highlightClassName?: string;
|
|
63
|
+
tooltipBubbleSize?: number;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -98,7 +100,7 @@ declare interface AnnotationState {
|
|
|
98
100
|
setAnnotations: (annotations: Annotation[]) => void;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
export declare const AnnotationTooltip: ({ annotation, children, tooltipContent, hoverTooltipContent, onOpenChange, className, hoverClassName, isOpen: controlledIsOpen, hoverIsOpen: controlledHoverIsOpen, }: AnnotationTooltipProps) => JSX.Element;
|
|
103
|
+
export declare const AnnotationTooltip: ({ annotation, children, tooltipContent, hoverTooltipContent, onOpenChange, className, hoverClassName, isOpen: controlledIsOpen, tooltipBubbleSize, hoverIsOpen: controlledHoverIsOpen, }: AnnotationTooltipProps) => JSX.Element;
|
|
102
104
|
|
|
103
105
|
declare interface AnnotationTooltipProps {
|
|
104
106
|
annotation: Annotation;
|
|
@@ -110,6 +112,7 @@ declare interface AnnotationTooltipProps {
|
|
|
110
112
|
className?: string;
|
|
111
113
|
hoverClassName?: string;
|
|
112
114
|
hoverIsOpen?: boolean;
|
|
115
|
+
tooltipBubbleSize: number;
|
|
113
116
|
renderHoverTooltipContent?: (props: {
|
|
114
117
|
annotation: Annotation;
|
|
115
118
|
onClose: () => void;
|
|
@@ -428,6 +431,7 @@ export declare const usePdfJump: () => {
|
|
|
428
431
|
}) => void;
|
|
429
432
|
jumpToOffset: (offset: number) => void;
|
|
430
433
|
jumpToHighlightRects: (rects: HighlightRect[], type: "pixels" | "percent", align?: "start" | "center", additionalOffset?: number) => void;
|
|
434
|
+
scrollToHighlightRects: (rects: HighlightRect[], type: "pixels" | "percent", align?: "start" | "center", additionalOffset?: number) => void;
|
|
431
435
|
};
|
|
432
436
|
|
|
433
437
|
declare const usePDFOutline: () => {
|
package/dist/index.js
CHANGED
|
@@ -267,6 +267,7 @@ var AnnotationTooltip = ({
|
|
|
267
267
|
className,
|
|
268
268
|
hoverClassName,
|
|
269
269
|
isOpen: controlledIsOpen,
|
|
270
|
+
tooltipBubbleSize,
|
|
270
271
|
hoverIsOpen: controlledHoverIsOpen
|
|
271
272
|
}) => {
|
|
272
273
|
const viewportRef = usePdf((state) => state.viewportRef);
|
|
@@ -331,7 +332,7 @@ var AnnotationTooltip = ({
|
|
|
331
332
|
setHoverIsOpen(false);
|
|
332
333
|
}, [setHoverIsOpen]);
|
|
333
334
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ jsxs(
|
|
335
336
|
"div",
|
|
336
337
|
{
|
|
337
338
|
ref: (node) => {
|
|
@@ -343,7 +344,18 @@ var AnnotationTooltip = ({
|
|
|
343
344
|
onMouseLeave: handleMouseLeave,
|
|
344
345
|
...getReferenceProps(),
|
|
345
346
|
...getHoverReferenceProps(),
|
|
346
|
-
children
|
|
347
|
+
children: [
|
|
348
|
+
!isOpen && !hoverIsOpen && annotation.comment && /* @__PURE__ */ jsx("div", { className: "rounded-full", style: {
|
|
349
|
+
position: "absolute",
|
|
350
|
+
top: annotation.highlights[0]?.top ? annotation.highlights[0]?.top - tooltipBubbleSize / 2 : 0,
|
|
351
|
+
left: annotation.highlights[0]?.left ? annotation.highlights[0]?.left - tooltipBubbleSize / 2 : 0,
|
|
352
|
+
backgroundColor: annotation.borderColor,
|
|
353
|
+
height: `${tooltipBubbleSize}px`,
|
|
354
|
+
width: `${tooltipBubbleSize}px`,
|
|
355
|
+
zIndex: 50
|
|
356
|
+
} }),
|
|
357
|
+
children
|
|
358
|
+
]
|
|
347
359
|
}
|
|
348
360
|
),
|
|
349
361
|
isOpen && viewportRef.current && createPortal(
|
|
@@ -423,7 +435,8 @@ var AnnotationHighlightLayer = ({
|
|
|
423
435
|
focusedAnnotationId,
|
|
424
436
|
focusedHoverAnnotationId,
|
|
425
437
|
onAnnotationClick,
|
|
426
|
-
hoverTooltipClassName
|
|
438
|
+
hoverTooltipClassName,
|
|
439
|
+
tooltipBubbleSize = 6
|
|
427
440
|
}) => {
|
|
428
441
|
const { annotations } = useAnnotations();
|
|
429
442
|
const pageNumber = usePDFPageNumber();
|
|
@@ -437,6 +450,7 @@ var AnnotationHighlightLayer = ({
|
|
|
437
450
|
className: tooltipClassName,
|
|
438
451
|
hoverClassName: hoverTooltipClassName,
|
|
439
452
|
isOpen: focusedAnnotationId === annotation.id,
|
|
453
|
+
tooltipBubbleSize,
|
|
440
454
|
hoverIsOpen: focusedHoverAnnotationId === annotation.id,
|
|
441
455
|
onOpenChange: (open) => {
|
|
442
456
|
if (open && onAnnotationClick) {
|
|
@@ -542,9 +556,8 @@ var usePdfJump = () => {
|
|
|
542
556
|
behavior: "smooth"
|
|
543
557
|
});
|
|
544
558
|
};
|
|
545
|
-
const
|
|
559
|
+
const scrollToHighlightRects = (rects, type, align = "start", additionalOffset = 0) => {
|
|
546
560
|
if (!virtualizer) return;
|
|
547
|
-
setHighlight(rects);
|
|
548
561
|
const firstPage = Math.min(...rects.map((rect) => rect.pageNumber));
|
|
549
562
|
const pageOffset = virtualizer.getOffsetForIndex(firstPage - 1, "start");
|
|
550
563
|
if (pageOffset === null) return;
|
|
@@ -581,7 +594,12 @@ var usePdfJump = () => {
|
|
|
581
594
|
behavior: "smooth"
|
|
582
595
|
});
|
|
583
596
|
};
|
|
584
|
-
|
|
597
|
+
const jumpToHighlightRects = (rects, type, align = "start", additionalOffset = 0) => {
|
|
598
|
+
if (!virtualizer) return;
|
|
599
|
+
setHighlight(rects);
|
|
600
|
+
scrollToHighlightRects(rects, type, align, additionalOffset);
|
|
601
|
+
};
|
|
602
|
+
return { jumpToPage, jumpToOffset, jumpToHighlightRects, scrollToHighlightRects };
|
|
585
603
|
};
|
|
586
604
|
var LinkService = class {
|
|
587
605
|
_pdfDocumentProxy;
|