@vue-pdf-viewer/viewer 3.8.0-beta.0 → 3.8.0-beta.10

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.
@@ -1,5 +1,10 @@
1
1
  import type { PDFDocumentProxy } from 'pdfjs-dist';
2
2
  import type { AnnotationEventPayload } from '@/utils/types';
3
3
  declare const EVENTS_TO_HANDLER: string[];
4
- declare function annotationEventsHandler(evt: Event, PDFDoc: PDFDocumentProxy, Annotations: Object[], viewerRotation: number): AnnotationEventPayload | Promise<AnnotationEventPayload | undefined> | undefined;
5
- export { EVENTS_TO_HANDLER, annotationEventsHandler };
4
+ declare function annotationEventsHandler(evt: Event, PDFDoc: PDFDocumentProxy, Annotations: Object[], viewerRotation: number, annotationStorage?: any): AnnotationEventPayload | Promise<AnnotationEventPayload | undefined> | undefined;
5
+ /**
6
+ * Get the parent annotation element for a popup.
7
+ * Returns the cached annotation element that triggered this popup.
8
+ */
9
+ declare function getPopupParentAnnotation(popupElement: HTMLElement): HTMLElement | null;
10
+ export { EVENTS_TO_HANDLER, annotationEventsHandler, getPopupParentAnnotation };
@@ -1,4 +1,4 @@
1
- import { Ref } from 'vue';
1
+ import { Ref, ShallowRef } from 'vue';
2
2
  import { AnnotationLayer, DrawLayer, PageViewport, PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
3
3
  import { AnnotationType } from '@vue-pdf-viewer/shared';
4
4
  import { AnnotationHighlight } from '@/utils/types';
@@ -9,35 +9,10 @@ interface UseAnnotationHighlightProps {
9
9
  textLayer: Ref<HTMLDivElement>;
10
10
  annotationLayer: Ref<AnnotationLayer>;
11
11
  document: PDFDocumentProxy;
12
+ /** Shared DrawLayer from parent - ensures unique IDs across all text selection types */
13
+ sharedDrawLayer: ShallowRef<DrawLayer | null>;
12
14
  }
13
15
  export declare const useAnnotationHighlight: (props: UseAnnotationHighlightProps) => {
14
- drawLayer: Ref<{
15
- pageIndex: any;
16
- setParent: (parent: any) => void;
17
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
18
- id: number;
19
- clipPathId: string;
20
- };
21
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
22
- finalizeDraw: (id: any, properties: any) => void;
23
- updateProperties: (elementOrId: any, properties: any) => void;
24
- updateParent: (id: any, layer: any) => void;
25
- remove: (id: any) => void;
26
- destroy: () => void;
27
- } | null, DrawLayer | {
28
- pageIndex: any;
29
- setParent: (parent: any) => void;
30
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
31
- id: number;
32
- clipPathId: string;
33
- };
34
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
35
- finalizeDraw: (id: any, properties: any) => void;
36
- updateProperties: (elementOrId: any, properties: any) => void;
37
- updateParent: (id: any, layer: any) => void;
38
- remove: (id: any) => void;
39
- destroy: () => void;
40
- } | null>;
41
16
  isPrepared: Ref<boolean, boolean>;
42
17
  highlightAnnotations: Ref<{
43
18
  hexColor: string;
@@ -1,6 +1,6 @@
1
1
  import { type Ref } from 'vue';
2
2
  import { type AnnotationPluginApi } from '@vue-pdf-viewer/shared';
3
- import type { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
3
+ import type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist/types/src/display/api';
4
4
  /**
5
5
  * Set the global annotation plugin API reference
6
6
  * Called from usePlugins when the plugin is registered
@@ -71,6 +71,18 @@ export interface UseAnnotationStorageReturn {
71
71
  findEditorAnnotationKey: (annotationId: string) => string | undefined;
72
72
  }
73
73
  export declare const getGlobalStorageEntries: () => unknown[];
74
+ /**
75
+ * Pre-set noView flag for Underline/StrikeOut annotations before canvas rendering.
76
+ * This prevents race condition where canvas renders these annotations before
77
+ * LayerAnnotationEditor has a chance to hide them.
78
+ *
79
+ * Why this is needed:
80
+ * - Highlight annotations are supported by PDF.js for editing, so they respond to isEditing flag
81
+ * - Underline (type 10) and StrikeOut (type 12) are NOT supported by PDF.js for editing
82
+ * - PDF.js renders them on canvas but does NOT respond to isEditing flag
83
+ * - We need to set noView: true BEFORE canvas rendering starts
84
+ */
85
+ export declare function prepareTextMarkupAnnotationsForCanvas(pageProxy: PDFPageProxy, isTextSelectionActive: boolean): Promise<void>;
74
86
  /**
75
87
  * Creates a serializable version of the annotation data
76
88
  * @param value - The annotation data to serialize
@@ -1,6 +1,6 @@
1
1
  import { AnnotationHighlight } from '@/utils/types';
2
2
  import { AnnotationLayer, DrawLayer, PageViewport, PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
3
- import { Ref } from 'vue';
3
+ import { Ref, ShallowRef } from 'vue';
4
4
  import { AnnotationType } from '@vue-pdf-viewer/shared';
5
5
  interface UseAnnotationStrikethroughProps {
6
6
  page: Ref<PDFPageProxy>;
@@ -9,6 +9,8 @@ interface UseAnnotationStrikethroughProps {
9
9
  textLayer: Ref<HTMLDivElement>;
10
10
  annotationLayer: Ref<AnnotationLayer>;
11
11
  document: PDFDocumentProxy;
12
+ /** Shared DrawLayer from parent - ensures unique IDs across all text selection types */
13
+ sharedDrawLayer: ShallowRef<DrawLayer | null>;
12
14
  }
13
15
  interface StrikethroughAnnotation extends AnnotationHighlight {
14
16
  isAddedNew?: boolean;
@@ -696,33 +698,6 @@ export declare const useAnnotationStrikethrough: (props: UseAnnotationStrikethro
696
698
  drawLayerId: number;
697
699
  strikethroughSvg?: SVGSVGElement | undefined;
698
700
  }>>;
699
- drawLayer: Ref<{
700
- pageIndex: any;
701
- setParent: (parent: any) => void;
702
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
703
- id: number;
704
- clipPathId: string;
705
- };
706
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
707
- finalizeDraw: (id: any, properties: any) => void;
708
- updateProperties: (elementOrId: any, properties: any) => void;
709
- updateParent: (id: any, layer: any) => void;
710
- remove: (id: any) => void;
711
- destroy: () => void;
712
- } | null, DrawLayer | {
713
- pageIndex: any;
714
- setParent: (parent: any) => void;
715
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
716
- id: number;
717
- clipPathId: string;
718
- };
719
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
720
- finalizeDraw: (id: any, properties: any) => void;
721
- updateProperties: (elementOrId: any, properties: any) => void;
722
- updateParent: (id: any, layer: any) => void;
723
- remove: (id: any) => void;
724
- destroy: () => void;
725
- } | null>;
726
701
  isPrepared: Ref<boolean, boolean>;
727
702
  prepareStrikethroughElements: (editorActive: boolean) => Promise<void>;
728
703
  createStrikethroughFromBoxes: (boxes: Array<{
@@ -1,6 +1,6 @@
1
1
  import { AnnotationHighlight } from '@/utils/types';
2
2
  import { AnnotationLayer, DrawLayer, PageViewport, PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
3
- import { Ref } from 'vue';
3
+ import { Ref, ShallowRef } from 'vue';
4
4
  import { AnnotationType } from '@vue-pdf-viewer/shared';
5
5
  interface UseAnnotationUnderlineProps {
6
6
  page: Ref<PDFPageProxy>;
@@ -9,6 +9,8 @@ interface UseAnnotationUnderlineProps {
9
9
  textLayer: Ref<HTMLDivElement>;
10
10
  annotationLayer: Ref<AnnotationLayer>;
11
11
  document: PDFDocumentProxy;
12
+ /** Shared DrawLayer from parent - ensures unique IDs across all text selection types */
13
+ sharedDrawLayer: ShallowRef<DrawLayer | null>;
12
14
  }
13
15
  interface UnderlineAnnotation extends AnnotationHighlight {
14
16
  isAddedNew?: boolean;
@@ -696,33 +698,6 @@ export declare const useAnnotationUnderline: (props: UseAnnotationUnderlineProps
696
698
  drawLayerId: number;
697
699
  underlineSvg?: SVGSVGElement | undefined;
698
700
  }>>;
699
- drawLayer: Ref<{
700
- pageIndex: any;
701
- setParent: (parent: any) => void;
702
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
703
- id: number;
704
- clipPathId: string;
705
- };
706
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
707
- finalizeDraw: (id: any, properties: any) => void;
708
- updateProperties: (elementOrId: any, properties: any) => void;
709
- updateParent: (id: any, layer: any) => void;
710
- remove: (id: any) => void;
711
- destroy: () => void;
712
- } | null, DrawLayer | {
713
- pageIndex: any;
714
- setParent: (parent: any) => void;
715
- draw: (properties: any, isPathUpdatable?: boolean | undefined, hasClip?: boolean | undefined) => {
716
- id: number;
717
- clipPathId: string;
718
- };
719
- drawOutline: (properties: any, mustRemoveSelfIntersections: any) => number;
720
- finalizeDraw: (id: any, properties: any) => void;
721
- updateProperties: (elementOrId: any, properties: any) => void;
722
- updateParent: (id: any, layer: any) => void;
723
- remove: (id: any) => void;
724
- destroy: () => void;
725
- } | null>;
726
701
  isPrepared: Ref<boolean, boolean>;
727
702
  prepareUnderlineElements: (editorActive: boolean) => Promise<void>;
728
703
  createUnderlineFromBoxes: (boxes: Array<{
@@ -35,8 +35,8 @@ export declare const MIN_ZOOM_SCALE = 0.25;
35
35
  export declare const MAX_ZOOM_SCALE = 10;
36
36
  export declare const DEFAULT_SCALE_DELTA = 1.1;
37
37
  export declare const ANNOTATION_OUTLINE_BORDER_WIDTH = 0.0025;
38
- export declare const ANNOTATION_OUTLINE_INNER_MARGIN = 0;
39
- export declare const TEXT_MARKUP_LINE_THICKNESS = 0.15;
38
+ export declare const ANNOTATION_OUTLINE_INNER_MARGIN = 0.00025;
39
+ export declare const TEXT_MARKUP_LINE_THICKNESS = 0.075;
40
40
  export declare const SCROLL_BAR_WIDTH = 20;
41
41
  export declare const PAGE_PADDING = 1;
42
42
  export declare const PAGE_OFFSET = 0;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utility for adjusting PDF.js annotation popup position to stay within viewer bounds.
3
+ * Popups use percentage-based positioning relative to their page.
4
+ * The popup should stay visually connected to its parent annotation.
5
+ */
6
+ export interface PopupBoundsResult {
7
+ needsAdjustment: boolean;
8
+ left?: string;
9
+ top?: string;
10
+ }
11
+ /**
12
+ * Check if a popup overflows the container bounds and calculate adjusted position.
13
+ * The popup will try to stay adjacent to its parent annotation, flipping sides if needed.
14
+ *
15
+ * @param popup - The .popup element inside .popupAnnotation
16
+ * @param container - The scroll container (.vpv-pages-inner-container)
17
+ * @param page - The annotation layer element (.vpv-annotation-layer)
18
+ * @param annotationRect - Bounding rect of the parent annotation element
19
+ * @returns Adjustment result with new percentage-based left/top if needed
20
+ */
21
+ export declare function adjustPopupBounds(popup: HTMLElement, container: HTMLElement, page: HTMLElement, annotationRect: DOMRect | null): PopupBoundsResult;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vue-pdf-viewer/viewer",
3
3
  "private": false,
4
- "version": "3.8.0-beta.0",
4
+ "version": "3.8.0-beta.10",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
7
7
  "module": "./dist/index.js",
@@ -60,7 +60,7 @@
60
60
  "prepare": "husky"
61
61
  },
62
62
  "dependencies": {
63
- "@vue-pdf-viewer/shared": "1.2.0-rc.16",
63
+ "@vue-pdf-viewer/shared": "1.2.0",
64
64
  "@vueuse/core": "^13.6.0",
65
65
  "node-forge": "^1.3.2",
66
66
  "pdfjs-dist": "4.10.38",