@embedpdf/plugin-annotation 2.2.0 → 2.3.0

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.
Files changed (97) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1196 -92
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +31 -2
  6. package/dist/lib/annotation-plugin.d.ts +177 -2
  7. package/dist/lib/handlers/types.d.ts +1 -1
  8. package/dist/lib/helpers.d.ts +6 -1
  9. package/dist/lib/selectors.d.ts +97 -8
  10. package/dist/lib/tools/default-tools.d.ts +39 -11
  11. package/dist/lib/tools/types.d.ts +7 -1
  12. package/dist/lib/types.d.ts +265 -1
  13. package/dist/preact/adapter.d.ts +3 -3
  14. package/dist/preact/index.cjs +1 -1
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.js +857 -403
  17. package/dist/preact/index.js.map +1 -1
  18. package/dist/react/adapter.d.ts +1 -1
  19. package/dist/react/index.cjs +1 -1
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.js +857 -403
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/shared/components/annotation-container.d.ts +8 -1
  24. package/dist/shared/components/annotation-layer.d.ts +4 -2
  25. package/dist/shared/components/annotations/ink.d.ts +3 -3
  26. package/dist/shared/components/annotations/link.d.ts +28 -0
  27. package/dist/shared/components/annotations.d.ts +2 -1
  28. package/dist/shared/components/group-selection-box.d.ts +32 -0
  29. package/dist/shared/components/index.d.ts +1 -0
  30. package/dist/shared/components/text-markup/highlight.d.ts +3 -2
  31. package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
  32. package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
  33. package/dist/shared/components/text-markup/underline.d.ts +3 -2
  34. package/dist/shared/components/types.d.ts +7 -0
  35. package/dist/shared-preact/components/annotation-container.d.ts +8 -1
  36. package/dist/shared-preact/components/annotation-layer.d.ts +4 -2
  37. package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
  38. package/dist/shared-preact/components/annotations/link.d.ts +28 -0
  39. package/dist/shared-preact/components/annotations.d.ts +2 -1
  40. package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
  41. package/dist/shared-preact/components/index.d.ts +1 -0
  42. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
  43. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
  44. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
  45. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
  46. package/dist/shared-preact/components/types.d.ts +7 -0
  47. package/dist/shared-react/components/annotation-container.d.ts +8 -1
  48. package/dist/shared-react/components/annotation-layer.d.ts +4 -2
  49. package/dist/shared-react/components/annotations/ink.d.ts +3 -3
  50. package/dist/shared-react/components/annotations/link.d.ts +28 -0
  51. package/dist/shared-react/components/annotations.d.ts +2 -1
  52. package/dist/shared-react/components/group-selection-box.d.ts +32 -0
  53. package/dist/shared-react/components/index.d.ts +1 -0
  54. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
  55. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
  56. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
  57. package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
  58. package/dist/shared-react/components/types.d.ts +7 -0
  59. package/dist/svelte/components/AnnotationLayer.svelte.d.ts +5 -1
  60. package/dist/svelte/components/Annotations.svelte.d.ts +5 -1
  61. package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
  62. package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
  63. package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
  64. package/dist/svelte/components/annotations/index.d.ts +1 -0
  65. package/dist/svelte/components/index.d.ts +1 -0
  66. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
  67. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
  68. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
  69. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
  70. package/dist/svelte/components/types.d.ts +2 -0
  71. package/dist/svelte/index.cjs +1 -1
  72. package/dist/svelte/index.cjs.map +1 -1
  73. package/dist/svelte/index.js +905 -255
  74. package/dist/svelte/index.js.map +1 -1
  75. package/dist/svelte/types.d.ts +7 -0
  76. package/dist/vue/components/annotation-container.vue.d.ts +2 -0
  77. package/dist/vue/components/annotation-layer.vue.d.ts +28 -5
  78. package/dist/vue/components/annotations/index.d.ts +1 -0
  79. package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
  80. package/dist/vue/components/annotations/line.vue.d.ts +1 -1
  81. package/dist/vue/components/annotations/link.vue.d.ts +29 -0
  82. package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
  83. package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
  84. package/dist/vue/components/annotations.vue.d.ts +65 -1
  85. package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
  86. package/dist/vue/components/index.d.ts +1 -0
  87. package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
  88. package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
  89. package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
  90. package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
  91. package/dist/vue/hooks/use-annotation.d.ts +2 -0
  92. package/dist/vue/index.cjs +1 -1
  93. package/dist/vue/index.cjs.map +1 -1
  94. package/dist/vue/index.js +946 -406
  95. package/dist/vue/index.js.map +1 -1
  96. package/dist/vue/types.d.ts +7 -0
  97. package/package.json +10 -10
@@ -8,6 +8,9 @@ export declare const SET_ACTIVE_DOCUMENT = "ANNOTATION/SET_ACTIVE_DOCUMENT";
8
8
  export declare const SET_ANNOTATIONS = "ANNOTATION/SET_ANNOTATIONS";
9
9
  export declare const SELECT_ANNOTATION = "ANNOTATION/SELECT_ANNOTATION";
10
10
  export declare const DESELECT_ANNOTATION = "ANNOTATION/DESELECT_ANNOTATION";
11
+ export declare const ADD_TO_SELECTION = "ANNOTATION/ADD_TO_SELECTION";
12
+ export declare const REMOVE_FROM_SELECTION = "ANNOTATION/REMOVE_FROM_SELECTION";
13
+ export declare const SET_SELECTION = "ANNOTATION/SET_SELECTION";
11
14
  export declare const SET_ACTIVE_TOOL_ID = "ANNOTATION/SET_ACTIVE_TOOL_ID";
12
15
  export declare const CREATE_ANNOTATION = "ANNOTATION/CREATE_ANNOTATION";
13
16
  export declare const PATCH_ANNOTATION = "ANNOTATION/PATCH_ANNOTATION";
@@ -53,6 +56,28 @@ export interface DeselectAnnotationAction extends Action {
53
56
  documentId: string;
54
57
  };
55
58
  }
59
+ export interface AddToSelectionAction extends Action {
60
+ type: typeof ADD_TO_SELECTION;
61
+ payload: {
62
+ documentId: string;
63
+ pageIndex: number;
64
+ id: string;
65
+ };
66
+ }
67
+ export interface RemoveFromSelectionAction extends Action {
68
+ type: typeof REMOVE_FROM_SELECTION;
69
+ payload: {
70
+ documentId: string;
71
+ id: string;
72
+ };
73
+ }
74
+ export interface SetSelectionAction extends Action {
75
+ type: typeof SET_SELECTION;
76
+ payload: {
77
+ documentId: string;
78
+ ids: string[];
79
+ };
80
+ }
56
81
  export interface SetActiveToolIdAction extends Action {
57
82
  type: typeof SET_ACTIVE_TOOL_ID;
58
83
  payload: {
@@ -89,6 +114,7 @@ export interface CommitAction extends Action {
89
114
  type: typeof COMMIT_PENDING_CHANGES;
90
115
  payload: {
91
116
  documentId: string;
117
+ committedUids: string[];
92
118
  };
93
119
  }
94
120
  export interface PurgeAnnotationAction extends Action {
@@ -113,18 +139,21 @@ export interface AddToolAction extends Action {
113
139
  type: typeof ADD_TOOL;
114
140
  payload: AnnotationTool;
115
141
  }
116
- export type AnnotationAction = InitAnnotationStateAction | CleanupAnnotationStateAction | SetActiveDocumentAction | SetAnnotationsAction | SelectAnnotationAction | DeselectAnnotationAction | SetActiveToolIdAction | CreateAnnotationAction | PatchAnnotationAction | DeleteAnnotationAction | CommitAction | PurgeAnnotationAction | AddColorPresetAction | SetToolDefaultsAction | AddToolAction;
142
+ export type AnnotationAction = InitAnnotationStateAction | CleanupAnnotationStateAction | SetActiveDocumentAction | SetAnnotationsAction | SelectAnnotationAction | DeselectAnnotationAction | AddToSelectionAction | RemoveFromSelectionAction | SetSelectionAction | SetActiveToolIdAction | CreateAnnotationAction | PatchAnnotationAction | DeleteAnnotationAction | CommitAction | PurgeAnnotationAction | AddColorPresetAction | SetToolDefaultsAction | AddToolAction;
117
143
  export declare function initAnnotationState(documentId: string, state: AnnotationDocumentState): InitAnnotationStateAction;
118
144
  export declare function cleanupAnnotationState(documentId: string): CleanupAnnotationStateAction;
119
145
  export declare function setActiveDocument(documentId: string | null): SetActiveDocumentAction;
120
146
  export declare const setAnnotations: (documentId: string, annotations: Record<number, PdfAnnotationObject[]>) => SetAnnotationsAction;
121
147
  export declare const selectAnnotation: (documentId: string, pageIndex: number, id: string) => SelectAnnotationAction;
122
148
  export declare const deselectAnnotation: (documentId: string) => DeselectAnnotationAction;
149
+ export declare const addToSelection: (documentId: string, pageIndex: number, id: string) => AddToSelectionAction;
150
+ export declare const removeFromSelection: (documentId: string, id: string) => RemoveFromSelectionAction;
151
+ export declare const setSelection: (documentId: string, ids: string[]) => SetSelectionAction;
123
152
  export declare const setActiveToolId: (documentId: string, toolId: string | null) => SetActiveToolIdAction;
124
153
  export declare const createAnnotation: (documentId: string, pageIndex: number, annotation: PdfAnnotationObject) => CreateAnnotationAction;
125
154
  export declare const patchAnnotation: (documentId: string, pageIndex: number, id: string, patch: Partial<PdfAnnotationObject>) => PatchAnnotationAction;
126
155
  export declare const deleteAnnotation: (documentId: string, pageIndex: number, id: string) => DeleteAnnotationAction;
127
- export declare const commitPendingChanges: (documentId: string) => CommitAction;
156
+ export declare const commitPendingChanges: (documentId: string, committedUids: string[]) => CommitAction;
128
157
  export declare const purgeAnnotation: (documentId: string, uid: string) => PurgeAnnotationAction;
129
158
  export declare const addColorPreset: (c: string) => AddColorPresetAction;
130
159
  export declare const setToolDefaults: (toolId: string, patch: Partial<any>) => SetToolDefaultsAction;
@@ -1,6 +1,6 @@
1
1
  import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
- import { PdfAnnotationObject } from '@embedpdf/models';
3
- import { AnnotationCapability, AnnotationPluginConfig, AnnotationState } from './types';
2
+ import { PdfAnnotationObject, Position, Rect } from '@embedpdf/models';
3
+ import { AnnotationCapability, AnnotationPluginConfig, AnnotationState, UnifiedDragOptions, UnifiedDragState, UnifiedDragEvent, UnifiedResizeOptions, UnifiedResizeState, UnifiedResizeEvent } from './types';
4
4
  import { AnnotationAction } from './actions';
5
5
  import { AnnotationTool } from './tools/types';
6
6
  import { AnyPreviewState, HandlerServices } from './handlers/types';
@@ -15,11 +15,16 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
15
15
  private pendingContexts;
16
16
  private isInitialLoadComplete;
17
17
  private importQueue;
18
+ private commitInProgress;
18
19
  private handlerFactories;
19
20
  private readonly activeTool$;
20
21
  private readonly events$;
21
22
  private readonly toolsChange$;
22
23
  private readonly patchRegistry;
24
+ private readonly unifiedDragStates;
25
+ private readonly unifiedDrag$;
26
+ private readonly unifiedResizeStates;
27
+ private readonly unifiedResize$;
23
28
  constructor(id: string, registry: PluginRegistry, config: AnnotationPluginConfig);
24
29
  protected onDocumentLoadingStarted(documentId: string): void;
25
30
  protected onDocumentLoaded(documentId: string): void;
@@ -50,12 +55,182 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
50
55
  private buildPatch;
51
56
  private updateAnnotation;
52
57
  private deleteAnnotation;
58
+ private deleteAnnotationsMethod;
53
59
  private selectAnnotation;
54
60
  private deselectAnnotation;
61
+ private getSelectedAnnotationsMethod;
62
+ private getSelectedAnnotationIdsMethod;
63
+ private toggleSelectionMethod;
64
+ private addToSelectionMethod;
65
+ private removeFromSelectionMethod;
66
+ private setSelectionMethod;
67
+ private getAttachedLinksMethod;
68
+ private hasAttachedLinksMethod;
69
+ private deleteAttachedLinksMethod;
70
+ /**
71
+ * Group the currently selected annotations.
72
+ * The first selected annotation becomes the group leader.
73
+ * All other selected annotations get their IRT set to the leader's ID with RT = Group.
74
+ */
75
+ private groupAnnotationsMethod;
76
+ /**
77
+ * Ungroup all annotations in the group containing the specified annotation.
78
+ * Clears IRT and RT from all group members (the leader doesn't have them).
79
+ */
80
+ private ungroupAnnotationsMethod;
81
+ /**
82
+ * Get all annotations in the same group as the specified annotation.
83
+ */
84
+ private getGroupMembersMethod;
85
+ /**
86
+ * Check if an annotation is part of a group.
87
+ */
88
+ private isInGroupMethod;
89
+ /**
90
+ * Get the available grouping action for the current selection.
91
+ */
92
+ private getGroupingActionMethod;
93
+ /**
94
+ * Compute combined constraints from all selected annotations.
95
+ * This finds the "weakest link" in each direction - the annotation with the least
96
+ * room to move determines the group's limit.
97
+ */
98
+ private computeCombinedConstraints;
99
+ /**
100
+ * Clamp a delta to the combined constraints.
101
+ * Negative y = moving up, positive y = moving down
102
+ * Negative x = moving left, positive x = moving right
103
+ */
104
+ private clampDelta;
105
+ /**
106
+ * Start a unified drag operation.
107
+ * The plugin automatically expands the selection to include attached links.
108
+ * Framework components should call this instead of building their own logic.
109
+ *
110
+ * @param documentId - The document ID
111
+ * @param options - Drag options (annotationIds and pageSize)
112
+ */
113
+ startDrag(documentId: string, options: UnifiedDragOptions): void;
114
+ /**
115
+ * Compute preview patches for all drag participants.
116
+ * Uses transformAnnotation to properly handle vertices, inkList, etc.
117
+ */
118
+ private computeDragPreviewPatches;
119
+ /**
120
+ * Update the drag delta during a unified drag operation.
121
+ * Returns the clamped delta synchronously for the caller's preview.
122
+ *
123
+ * @param documentId - The document ID
124
+ * @param rawDelta - The unconstrained delta from the drag gesture
125
+ * @returns The clamped delta
126
+ */
127
+ updateDrag(documentId: string, rawDelta: Position): Position;
128
+ /**
129
+ * Commit the drag - plugin builds and applies ALL patches.
130
+ * This is the key method that centralizes patch building in the plugin.
131
+ *
132
+ * @param documentId - The document ID
133
+ */
134
+ commitDrag(documentId: string): void;
135
+ /**
136
+ * Cancel the drag without committing.
137
+ *
138
+ * @param documentId - The document ID
139
+ */
140
+ cancelDrag(documentId: string): void;
141
+ /**
142
+ * Get the current unified drag state for a document.
143
+ */
144
+ getDragState(documentId: string): UnifiedDragState | null;
145
+ /**
146
+ * Subscribe to unified drag state changes.
147
+ * Framework components use this for preview updates.
148
+ */
149
+ get onDragChange(): import('@embedpdf/core').EventHook<UnifiedDragEvent>;
150
+ /**
151
+ * Compute the union bounding box of multiple rects.
152
+ */
153
+ private computeUnifiedGroupBoundingBox;
154
+ /**
155
+ * Compute relative positions for annotations within a group bounding box.
156
+ */
157
+ private computeUnifiedRelativePositions;
158
+ /**
159
+ * Compute new rects for all annotations based on the new group bounding box.
160
+ */
161
+ private computeUnifiedResizedRects;
162
+ /**
163
+ * Compute preview patches for all resize participants.
164
+ * Uses transformAnnotation to properly handle vertices, inkList, etc.
165
+ */
166
+ private computeResizePreviewPatches;
167
+ /**
168
+ * Start a unified resize operation.
169
+ * The plugin automatically expands the selection to include attached links.
170
+ *
171
+ * @param documentId - The document ID
172
+ * @param options - Resize options
173
+ */
174
+ startResize(documentId: string, options: UnifiedResizeOptions): void;
175
+ /**
176
+ * Update the resize with a new group bounding box.
177
+ * Returns the computed rects synchronously for immediate preview use.
178
+ *
179
+ * @param documentId - The document ID
180
+ * @param newGroupBox - The new group bounding box
181
+ * @returns Record of annotation ID to new rect
182
+ */
183
+ updateResize(documentId: string, newGroupBox: Rect): Record<string, Rect>;
184
+ /**
185
+ * Commit the resize - plugin builds and applies ALL patches.
186
+ *
187
+ * @param documentId - The document ID
188
+ */
189
+ commitResize(documentId: string): void;
190
+ /**
191
+ * Cancel the resize without committing.
192
+ *
193
+ * @param documentId - The document ID
194
+ */
195
+ cancelResize(documentId: string): void;
196
+ /**
197
+ * Get the current unified resize state for a document.
198
+ */
199
+ getResizeState(documentId: string): UnifiedResizeState | null;
200
+ /**
201
+ * Subscribe to unified resize state changes.
202
+ * Framework components use this for preview updates.
203
+ */
204
+ get onResizeChange(): import('@embedpdf/core').EventHook<UnifiedResizeEvent>;
205
+ private updateAnnotationsMethod;
55
206
  getActiveTool(documentId?: string): AnnotationTool | null;
56
207
  setActiveTool(toolId: string | null, documentId?: string): void;
57
208
  getTool<T extends AnnotationTool>(toolId: string): T | undefined;
58
209
  findToolForAnnotation(annotation: PdfAnnotationObject): AnnotationTool | null;
210
+ /**
211
+ * Collects all pending annotation changes for a document into a batch.
212
+ * This separates the "what to commit" from "how to commit" for cleaner code.
213
+ */
214
+ private collectPendingChanges;
215
+ /**
216
+ * Executes a batch of pending changes by creating engine tasks.
217
+ * Returns a task that resolves when all operations complete.
218
+ */
219
+ private executeCommitBatch;
220
+ /**
221
+ * Emits commit events for all completed operations.
222
+ * Centralizes event emission for cleaner separation of concerns.
223
+ */
224
+ private emitCommitEvents;
225
+ /**
226
+ * Attempts to acquire the commit lock for a document.
227
+ * Returns true if acquired, false if a commit is already in progress.
228
+ */
229
+ private acquireCommitLock;
230
+ /**
231
+ * Releases the commit lock for a document.
232
+ */
233
+ private releaseCommitLock;
59
234
  private commit;
60
235
  /**
61
236
  * Gets the effective behavior setting for a tool, checking tool-specific config first,
@@ -51,7 +51,7 @@ export interface InkPreviewData {
51
51
  rect: Rect;
52
52
  inkList: PdfInkListObject[];
53
53
  strokeWidth: number;
54
- color: string;
54
+ strokeColor: string;
55
55
  opacity: number;
56
56
  }
57
57
  export interface FreeTextPreviewData {
@@ -1,5 +1,9 @@
1
- import { PdfAnnotationSubtype, PdfAnnotationObject } from '@embedpdf/models';
1
+ import { PdfAnnotationSubtype, PdfAnnotationObject, Rect } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from './types';
3
+ /**
4
+ * Check if two rectangles intersect
5
+ */
6
+ export declare function rectsIntersect(a: Rect, b: Rect): boolean;
3
7
  export type AnnoOf<S extends PdfAnnotationSubtype> = Extract<PdfAnnotationObject, {
4
8
  type: S;
5
9
  }>;
@@ -21,4 +25,5 @@ export declare function isTextMarkup(a: TrackedAnnotation): a is TrackedAnnotati
21
25
  export declare function isFreeText(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.FREETEXT>>;
22
26
  export declare function isStamp(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.STAMP>>;
23
27
  export declare function isText(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.TEXT>>;
28
+ export declare function isLink(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.LINK>>;
24
29
  export declare function isSidebarAnnotation(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<SidebarSubtype>>;
@@ -1,16 +1,32 @@
1
- import { AnnotationState, AnnotationDocumentState, SidebarAnnotationEntry, TrackedAnnotation } from './types';
1
+ import { AnnotationState, AnnotationDocumentState, SidebarAnnotationEntry, TrackedAnnotation, GroupingAction } from './types';
2
+ import { PdfAnnotationSubtype, PdfAnnotationObject } from '@embedpdf/models';
2
3
  import { ToolMap } from './tools/tools-utils';
3
4
  /** All annotations _objects_ on a single page (order preserved). */
4
- export declare const getAnnotationsByPageIndex: (s: AnnotationDocumentState, page: number) => TrackedAnnotation<import('@embedpdf/models').PdfAnnotationObject>[];
5
+ export declare const getAnnotationsByPageIndex: (s: AnnotationDocumentState, page: number) => TrackedAnnotation<PdfAnnotationObject>[];
5
6
  /** Shortcut: every page → list of annotation objects. */
6
- export declare const getAnnotations: (s: AnnotationDocumentState) => Record<number, TrackedAnnotation<import('@embedpdf/models').PdfAnnotationObject>[]>;
7
- /** The full `TrackedAnnotation` for the current selection. */
8
- export declare const getSelectedAnnotation: (s: AnnotationDocumentState) => TrackedAnnotation<import('@embedpdf/models').PdfAnnotationObject> | null;
7
+ export declare const getAnnotations: (s: AnnotationDocumentState) => Record<number, TrackedAnnotation<PdfAnnotationObject>[]>;
8
+ /**
9
+ * The full `TrackedAnnotation` for the current selection.
10
+ * @deprecated Use getSelectedAnnotations() for multi-select support. Returns first selected or null.
11
+ */
12
+ export declare const getSelectedAnnotation: (s: AnnotationDocumentState) => TrackedAnnotation | null;
13
+ /** Get all selected TrackedAnnotations */
14
+ export declare const getSelectedAnnotations: (s: AnnotationDocumentState) => TrackedAnnotation[];
15
+ /** Get the IDs of all selected annotations */
16
+ export declare const getSelectedAnnotationIds: (s: AnnotationDocumentState) => string[];
9
17
  /** Get a tracked annotation by its ID */
10
- export declare const getAnnotationByUid: (s: AnnotationDocumentState, uid: string) => TrackedAnnotation<import('@embedpdf/models').PdfAnnotationObject>;
11
- export declare const getSelectedAnnotationByPageIndex: (s: AnnotationDocumentState, pageIndex: number) => TrackedAnnotation<import('@embedpdf/models').PdfAnnotationObject> | null;
12
- /** Check if a given anno on a page is the current selection. */
18
+ export declare const getAnnotationByUid: (s: AnnotationDocumentState, uid: string) => TrackedAnnotation<PdfAnnotationObject>;
19
+ /**
20
+ * Get selected annotation on a specific page (single, for backward compatibility)
21
+ * @deprecated Use getSelectedAnnotationsByPageIndex() for multi-select support.
22
+ */
23
+ export declare const getSelectedAnnotationByPageIndex: (s: AnnotationDocumentState, pageIndex: number) => TrackedAnnotation | null;
24
+ /** Get all selected annotations on a specific page */
25
+ export declare const getSelectedAnnotationsByPageIndex: (s: AnnotationDocumentState, pageIndex: number) => TrackedAnnotation[];
26
+ /** Check if a given annotation is in the current selection. */
13
27
  export declare const isAnnotationSelected: (s: AnnotationDocumentState, id: string) => boolean;
28
+ /** Check if multiple annotations are selected */
29
+ export declare const hasMultipleSelected: (s: AnnotationDocumentState) => boolean;
14
30
  /**
15
31
  * Returns the current defaults for a specific tool by its ID.
16
32
  * This is fully type-safe and infers the correct return type.
@@ -43,3 +59,76 @@ export declare const getSidebarAnnotationsWithRepliesGroupedByPage: (s: Annotati
43
59
  * ]
44
60
  */
45
61
  export declare const getSidebarAnnotationsWithReplies: (s: AnnotationDocumentState) => SidebarAnnotationEntry[];
62
+ /**
63
+ * Get all IRT child annotation info for cascade delete.
64
+ * Returns array of { id, pageIndex } for each annotation that references parentId.
65
+ */
66
+ export declare const getIRTChildIds: (s: AnnotationDocumentState, parentId: string) => {
67
+ id: string;
68
+ pageIndex: number;
69
+ }[];
70
+ /**
71
+ * Check if an annotation has any IRT children (links, replies, etc.)
72
+ */
73
+ export declare const hasIRTChildren: (s: AnnotationDocumentState, parentId: string) => boolean;
74
+ /**
75
+ * Get IRT children filtered by annotation type (e.g., only LINK).
76
+ * @param s - The annotation document state
77
+ * @param parentId - The parent annotation ID
78
+ * @param types - Array of annotation subtypes to include
79
+ */
80
+ export declare const getIRTChildrenByType: (s: AnnotationDocumentState, parentId: string, types: PdfAnnotationSubtype[]) => TrackedAnnotation[];
81
+ /**
82
+ * Get link annotations attached to a parent annotation via IRT relationship.
83
+ * @param s - The annotation document state
84
+ * @param parentId - The parent annotation ID
85
+ */
86
+ export declare const getAttachedLinks: (s: AnnotationDocumentState, parentId: string) => TrackedAnnotation[];
87
+ /**
88
+ * Check if an annotation has attached link children.
89
+ * @param s - The annotation document state
90
+ * @param parentId - The parent annotation ID
91
+ */
92
+ export declare const hasAttachedLinks: (s: AnnotationDocumentState, parentId: string) => boolean;
93
+ /**
94
+ * Get the leader ID of a group.
95
+ * If the annotation has inReplyToId with replyType = Group, return the inReplyToId.
96
+ * Otherwise, the annotation itself is the leader.
97
+ *
98
+ * @param s - The annotation document state
99
+ * @param annotationId - The annotation ID to find the group leader for
100
+ * @returns The leader annotation ID, or undefined if annotation not found
101
+ */
102
+ export declare const getGroupLeaderId: (s: AnnotationDocumentState, annotationId: string) => string | undefined;
103
+ /**
104
+ * Get all annotations in the same group as the given annotation.
105
+ * Returns the leader plus all annotations with inReplyToId pointing to leader and replyType = Group.
106
+ * Note: LINK annotations are excluded - they use IRT/Group for attachment but are not "group members"
107
+ * in the user-facing sense.
108
+ *
109
+ * @param s - The annotation document state
110
+ * @param annotationId - Any annotation ID in the group
111
+ * @returns Array of TrackedAnnotations in the group (including the annotation itself)
112
+ */
113
+ export declare const getGroupMembers: (s: AnnotationDocumentState, annotationId: string) => TrackedAnnotation<PdfAnnotationObject>[];
114
+ /**
115
+ * Check if an annotation is part of a group.
116
+ * An annotation is in a group if:
117
+ * - It has inReplyToId with replyType = Group (it's a group member), OR
118
+ * - It has at least one other annotation pointing to it with replyType = Group (it's a group leader)
119
+ *
120
+ * Note: LINK annotations are excluded - they use IRT/Group for attachment but are not "group members"
121
+ * in the user-facing sense. An annotation with only attached links is NOT considered "in a group".
122
+ *
123
+ * @param s - The annotation document state
124
+ * @param annotationId - The annotation ID to check
125
+ * @returns true if the annotation is part of a group
126
+ */
127
+ export declare const isInGroup: (s: AnnotationDocumentState, annotationId: string) => boolean;
128
+ /**
129
+ * Determine what grouping action is available for the current selection.
130
+ *
131
+ * @param s - The annotation document state
132
+ * @returns The available grouping action
133
+ */
134
+ export declare const getSelectionGroupingAction: (s: AnnotationDocumentState) => GroupingAction;
@@ -8,17 +8,19 @@ export declare const defaultTools: ({
8
8
  textSelection: true;
9
9
  isDraggable: false;
10
10
  isResizable: false;
11
+ isGroupDraggable: false;
12
+ isGroupResizable: false;
11
13
  cursor?: undefined;
12
14
  lockAspectRatio?: undefined;
13
15
  };
14
16
  defaults: {
15
17
  type: PdfAnnotationSubtype.HIGHLIGHT;
18
+ strokeColor: string;
16
19
  color: string;
17
20
  opacity: number;
18
21
  blendMode: PdfBlendMode.Multiply;
19
22
  strokeWidth?: undefined;
20
23
  intent?: undefined;
21
- strokeColor?: undefined;
22
24
  strokeStyle?: undefined;
23
25
  lineEndings?: undefined;
24
26
  contents?: undefined;
@@ -39,17 +41,19 @@ export declare const defaultTools: ({
39
41
  textSelection: true;
40
42
  isDraggable: false;
41
43
  isResizable: false;
44
+ isGroupDraggable: false;
45
+ isGroupResizable: false;
42
46
  cursor?: undefined;
43
47
  lockAspectRatio?: undefined;
44
48
  };
45
49
  defaults: {
46
50
  type: PdfAnnotationSubtype.UNDERLINE;
51
+ strokeColor: string;
47
52
  color: string;
48
53
  opacity: number;
49
54
  blendMode?: undefined;
50
55
  strokeWidth?: undefined;
51
56
  intent?: undefined;
52
- strokeColor?: undefined;
53
57
  strokeStyle?: undefined;
54
58
  lineEndings?: undefined;
55
59
  contents?: undefined;
@@ -68,19 +72,21 @@ export declare const defaultTools: ({
68
72
  interaction: {
69
73
  exclusive: false;
70
74
  textSelection: true;
71
- isDraggable?: undefined;
72
- isResizable?: undefined;
75
+ isDraggable: false;
76
+ isResizable: false;
77
+ isGroupDraggable: false;
78
+ isGroupResizable: false;
73
79
  cursor?: undefined;
74
80
  lockAspectRatio?: undefined;
75
81
  };
76
82
  defaults: {
77
83
  type: PdfAnnotationSubtype.STRIKEOUT;
84
+ strokeColor: string;
78
85
  color: string;
79
86
  opacity: number;
80
87
  blendMode?: undefined;
81
88
  strokeWidth?: undefined;
82
89
  intent?: undefined;
83
- strokeColor?: undefined;
84
90
  strokeStyle?: undefined;
85
91
  lineEndings?: undefined;
86
92
  contents?: undefined;
@@ -101,17 +107,19 @@ export declare const defaultTools: ({
101
107
  textSelection: true;
102
108
  isDraggable: false;
103
109
  isResizable: false;
110
+ isGroupDraggable: false;
111
+ isGroupResizable: false;
104
112
  cursor?: undefined;
105
113
  lockAspectRatio?: undefined;
106
114
  };
107
115
  defaults: {
108
116
  type: PdfAnnotationSubtype.SQUIGGLY;
117
+ strokeColor: string;
109
118
  color: string;
110
119
  opacity: number;
111
120
  blendMode?: undefined;
112
121
  strokeWidth?: undefined;
113
122
  intent?: undefined;
114
- strokeColor?: undefined;
115
123
  strokeStyle?: undefined;
116
124
  lineEndings?: undefined;
117
125
  contents?: undefined;
@@ -134,15 +142,17 @@ export declare const defaultTools: ({
134
142
  isResizable: true;
135
143
  lockAspectRatio: false;
136
144
  textSelection?: undefined;
145
+ isGroupDraggable?: undefined;
146
+ isGroupResizable?: undefined;
137
147
  };
138
148
  defaults: {
139
149
  type: PdfAnnotationSubtype.INK;
150
+ strokeColor: string;
140
151
  color: string;
141
152
  opacity: number;
142
153
  strokeWidth: number;
143
154
  blendMode?: undefined;
144
155
  intent?: undefined;
145
- strokeColor?: undefined;
146
156
  strokeStyle?: undefined;
147
157
  lineEndings?: undefined;
148
158
  contents?: undefined;
@@ -165,15 +175,17 @@ export declare const defaultTools: ({
165
175
  isResizable: true;
166
176
  lockAspectRatio: false;
167
177
  textSelection?: undefined;
178
+ isGroupDraggable?: undefined;
179
+ isGroupResizable?: undefined;
168
180
  };
169
181
  defaults: {
170
182
  type: PdfAnnotationSubtype.INK;
171
183
  intent: string;
184
+ strokeColor: string;
172
185
  color: string;
173
186
  opacity: number;
174
187
  strokeWidth: number;
175
188
  blendMode: PdfBlendMode.Multiply;
176
- strokeColor?: undefined;
177
189
  strokeStyle?: undefined;
178
190
  lineEndings?: undefined;
179
191
  contents?: undefined;
@@ -196,6 +208,8 @@ export declare const defaultTools: ({
196
208
  isResizable: true;
197
209
  lockAspectRatio: false;
198
210
  textSelection?: undefined;
211
+ isGroupDraggable?: undefined;
212
+ isGroupResizable?: undefined;
199
213
  };
200
214
  defaults: {
201
215
  type: PdfAnnotationSubtype.CIRCLE;
@@ -236,6 +250,8 @@ export declare const defaultTools: ({
236
250
  isResizable: true;
237
251
  lockAspectRatio: false;
238
252
  textSelection?: undefined;
253
+ isGroupDraggable?: undefined;
254
+ isGroupResizable?: undefined;
239
255
  };
240
256
  defaults: {
241
257
  type: PdfAnnotationSubtype.SQUARE;
@@ -275,7 +291,9 @@ export declare const defaultTools: ({
275
291
  isDraggable: true;
276
292
  isResizable: false;
277
293
  lockAspectRatio: false;
294
+ isGroupResizable: true;
278
295
  textSelection?: undefined;
296
+ isGroupDraggable?: undefined;
279
297
  };
280
298
  defaults: {
281
299
  type: PdfAnnotationSubtype.LINE;
@@ -312,7 +330,9 @@ export declare const defaultTools: ({
312
330
  isDraggable: true;
313
331
  isResizable: false;
314
332
  lockAspectRatio: false;
333
+ isGroupResizable: true;
315
334
  textSelection?: undefined;
335
+ isGroupDraggable?: undefined;
316
336
  };
317
337
  defaults: {
318
338
  type: PdfAnnotationSubtype.LINE;
@@ -352,7 +372,9 @@ export declare const defaultTools: ({
352
372
  isDraggable: true;
353
373
  isResizable: false;
354
374
  lockAspectRatio: false;
375
+ isGroupResizable: true;
355
376
  textSelection?: undefined;
377
+ isGroupDraggable?: undefined;
356
378
  };
357
379
  defaults: {
358
380
  type: PdfAnnotationSubtype.POLYLINE;
@@ -383,7 +405,9 @@ export declare const defaultTools: ({
383
405
  isDraggable: true;
384
406
  isResizable: false;
385
407
  lockAspectRatio: false;
408
+ isGroupResizable: true;
386
409
  textSelection?: undefined;
410
+ isGroupDraggable?: undefined;
387
411
  };
388
412
  defaults: {
389
413
  type: PdfAnnotationSubtype.POLYGON;
@@ -415,6 +439,8 @@ export declare const defaultTools: ({
415
439
  isResizable: true;
416
440
  lockAspectRatio: false;
417
441
  textSelection?: undefined;
442
+ isGroupDraggable?: undefined;
443
+ isGroupResizable?: undefined;
418
444
  };
419
445
  defaults: {
420
446
  type: PdfAnnotationSubtype.FREETEXT;
@@ -424,13 +450,13 @@ export declare const defaultTools: ({
424
450
  fontFamily: PdfStandardFont.Helvetica;
425
451
  textAlign: PdfTextAlignment.Left;
426
452
  verticalAlign: PdfVerticalAlignment.Top;
453
+ color: string;
427
454
  backgroundColor: string;
428
455
  opacity: number;
429
- color?: undefined;
456
+ strokeColor?: undefined;
430
457
  blendMode?: undefined;
431
458
  strokeWidth?: undefined;
432
459
  intent?: undefined;
433
- strokeColor?: undefined;
434
460
  strokeStyle?: undefined;
435
461
  lineEndings?: undefined;
436
462
  };
@@ -455,15 +481,17 @@ export declare const defaultTools: ({
455
481
  isResizable: true;
456
482
  lockAspectRatio: true;
457
483
  textSelection?: undefined;
484
+ isGroupDraggable?: undefined;
485
+ isGroupResizable?: undefined;
458
486
  };
459
487
  defaults: {
460
488
  type: PdfAnnotationSubtype.STAMP;
489
+ strokeColor?: undefined;
461
490
  color?: undefined;
462
491
  opacity?: undefined;
463
492
  blendMode?: undefined;
464
493
  strokeWidth?: undefined;
465
494
  intent?: undefined;
466
- strokeColor?: undefined;
467
495
  strokeStyle?: undefined;
468
496
  lineEndings?: undefined;
469
497
  contents?: undefined;
@@ -84,10 +84,16 @@ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject>
84
84
  cursor?: string;
85
85
  /** If true, this interaction mode is activated by selecting text. */
86
86
  textSelection?: boolean;
87
- /** Annotation interaction behaviors */
87
+ /** Whether this annotation can be dragged when selected individually. */
88
88
  isDraggable?: boolean;
89
+ /** Whether this annotation can be resized when selected individually. */
89
90
  isResizable?: boolean;
91
+ /** Whether to maintain aspect ratio during resize. */
90
92
  lockAspectRatio?: boolean;
93
+ /** Whether this annotation can be dragged when part of a group. Defaults to isDraggable. */
94
+ isGroupDraggable?: boolean;
95
+ /** Whether this annotation can be resized when part of a group. Defaults to isResizable. */
96
+ isGroupResizable?: boolean;
91
97
  };
92
98
  /** Tool-specific behavior settings that override plugin defaults */
93
99
  behavior?: {