@embedpdf/plugin-annotation 2.6.2 → 2.8.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +538 -90
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +12 -1
- package/dist/lib/annotation-plugin.d.ts +19 -0
- package/dist/lib/handlers/index.d.ts +4 -0
- package/dist/lib/handlers/insert-text.handler.d.ts +8 -0
- package/dist/lib/handlers/replace-text.handler.d.ts +9 -0
- package/dist/lib/handlers/selection-utils.d.ts +7 -0
- package/dist/lib/handlers/text-markup.handler.d.ts +7 -0
- package/dist/lib/handlers/text.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +12 -0
- package/dist/lib/helpers.d.ts +2 -1
- package/dist/lib/selectors.d.ts +6 -1
- package/dist/lib/tools/default-tools.d.ts +153 -6
- package/dist/lib/tools/tools-utils.d.ts +2 -0
- package/dist/lib/tools/types.d.ts +4 -0
- package/dist/lib/types.d.ts +19 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +1258 -1074
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1258 -1074
- package/dist/react/index.js.map +1 -1
- package/dist/shared/annotation-bounds.d.ts +14 -0
- package/dist/shared/components/annotation-container.d.ts +11 -5
- package/dist/shared/components/annotations/caret.d.ts +24 -0
- package/dist/shared/components/annotations/circle.d.ts +6 -4
- package/dist/shared/components/annotations/free-text.d.ts +6 -3
- package/dist/shared/components/annotations/ink.d.ts +5 -3
- package/dist/shared/components/annotations/line.d.ts +5 -3
- package/dist/shared/components/annotations/link.d.ts +2 -2
- package/dist/shared/components/annotations/polygon.d.ts +5 -4
- package/dist/shared/components/annotations/polyline.d.ts +10 -4
- package/dist/shared/components/annotations/square.d.ts +6 -4
- package/dist/shared/components/annotations/stamp.d.ts +2 -2
- package/dist/shared/components/annotations/text.d.ts +14 -0
- package/dist/shared/components/annotations.d.ts +0 -1
- package/dist/shared/components/appearance-image.d.ts +12 -0
- package/dist/shared/components/built-in-renderers.d.ts +2 -0
- package/dist/shared/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared/components/text-markup/underline.d.ts +5 -3
- package/dist/shared/components/types.d.ts +67 -11
- package/dist/shared-preact/annotation-bounds.d.ts +14 -0
- package/dist/shared-preact/components/annotation-container.d.ts +11 -5
- package/dist/shared-preact/components/annotations/caret.d.ts +24 -0
- package/dist/shared-preact/components/annotations/circle.d.ts +6 -4
- package/dist/shared-preact/components/annotations/free-text.d.ts +6 -3
- package/dist/shared-preact/components/annotations/ink.d.ts +5 -3
- package/dist/shared-preact/components/annotations/line.d.ts +5 -3
- package/dist/shared-preact/components/annotations/link.d.ts +2 -2
- package/dist/shared-preact/components/annotations/polygon.d.ts +5 -4
- package/dist/shared-preact/components/annotations/polyline.d.ts +10 -4
- package/dist/shared-preact/components/annotations/square.d.ts +6 -4
- package/dist/shared-preact/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-preact/components/annotations/text.d.ts +14 -0
- package/dist/shared-preact/components/annotations.d.ts +0 -1
- package/dist/shared-preact/components/appearance-image.d.ts +12 -0
- package/dist/shared-preact/components/built-in-renderers.d.ts +2 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/underline.d.ts +5 -3
- package/dist/shared-preact/components/types.d.ts +67 -11
- package/dist/shared-react/annotation-bounds.d.ts +14 -0
- package/dist/shared-react/components/annotation-container.d.ts +11 -5
- package/dist/shared-react/components/annotations/caret.d.ts +24 -0
- package/dist/shared-react/components/annotations/circle.d.ts +6 -4
- package/dist/shared-react/components/annotations/free-text.d.ts +6 -3
- package/dist/shared-react/components/annotations/ink.d.ts +5 -3
- package/dist/shared-react/components/annotations/line.d.ts +5 -3
- package/dist/shared-react/components/annotations/link.d.ts +2 -2
- package/dist/shared-react/components/annotations/polygon.d.ts +5 -4
- package/dist/shared-react/components/annotations/polyline.d.ts +10 -4
- package/dist/shared-react/components/annotations/square.d.ts +6 -4
- package/dist/shared-react/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-react/components/annotations/text.d.ts +14 -0
- package/dist/shared-react/components/annotations.d.ts +0 -1
- package/dist/shared-react/components/appearance-image.d.ts +12 -0
- package/dist/shared-react/components/built-in-renderers.d.ts +2 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared-react/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared-react/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared-react/components/text-markup/underline.d.ts +5 -3
- package/dist/shared-react/components/types.d.ts +67 -11
- package/dist/shared-vue/annotation-bounds.d.ts +14 -0
- package/dist/svelte/components/Annotations.svelte.d.ts +0 -7
- package/dist/svelte/components/AppearanceImage.svelte.d.ts +8 -0
- package/dist/svelte/components/annotations/Caret.svelte.d.ts +13 -0
- package/dist/svelte/components/annotations/Circle.svelte.d.ts +2 -11
- package/dist/svelte/components/annotations/FreeText.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -2
- package/dist/svelte/components/annotations/Line.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Polygon.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Polyline.svelte.d.ts +5 -3
- package/dist/svelte/components/annotations/Square.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Text.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/built-in-renderers.d.ts +2 -0
- package/dist/svelte/components/renderers/CaretRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/CircleRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/FreeTextRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/HighlightRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/InkRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/LineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/LinkRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/PolygonRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/PolylineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/SquareRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/SquigglyRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/StampRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/StrikeoutRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/TextRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/UnderlineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +3 -1
- package/dist/svelte/components/types.d.ts +8 -2
- package/dist/svelte/context/renderer-registry.svelte.d.ts +2 -2
- package/dist/svelte/context/types.d.ts +63 -2
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +2738 -2890
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-container.vue.d.ts +7 -2
- package/dist/vue/components/annotation-layer.vue.d.ts +2 -21
- package/dist/vue/components/annotations/caret.vue.d.ts +24 -0
- package/dist/vue/components/annotations/circle.vue.d.ts +19 -6
- package/dist/vue/components/annotations/free-text.vue.d.ts +18 -6
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +17 -7
- package/dist/vue/components/annotations/line.vue.d.ts +21 -6
- package/dist/vue/components/annotations/link.vue.d.ts +24 -6
- package/dist/vue/components/annotations/polygon.vue.d.ts +22 -6
- package/dist/vue/components/annotations/polyline.vue.d.ts +25 -7
- package/dist/vue/components/annotations/square.vue.d.ts +19 -6
- package/dist/vue/components/annotations/stamp.vue.d.ts +12 -6
- package/dist/vue/components/annotations/text.vue.d.ts +14 -0
- package/dist/vue/components/annotations.vue.d.ts +9 -576
- package/dist/vue/components/appearance-image.vue.d.ts +9 -0
- package/dist/vue/components/built-in-renderers.d.ts +2 -0
- package/dist/vue/components/group-selection-box.vue.d.ts +2 -2
- package/dist/vue/components/renderers/caret-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/circle-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/free-text-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/highlight-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/ink-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/line-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/link-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/polygon-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/polyline-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/square-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/squiggly-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/stamp-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/strikeout-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/text-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/underline-renderer.vue.d.ts +6 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/underline.vue.d.ts +18 -6
- package/dist/vue/context/renderer-registry.d.ts +2 -2
- package/dist/vue/context/types.d.ts +63 -2
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +1995 -1336
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/lib/actions.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const SET_SELECTION = "ANNOTATION/SET_SELECTION";
|
|
|
14
14
|
export declare const SET_ACTIVE_TOOL_ID = "ANNOTATION/SET_ACTIVE_TOOL_ID";
|
|
15
15
|
export declare const CREATE_ANNOTATION = "ANNOTATION/CREATE_ANNOTATION";
|
|
16
16
|
export declare const PATCH_ANNOTATION = "ANNOTATION/PATCH_ANNOTATION";
|
|
17
|
+
export declare const MOVE_ANNOTATION = "ANNOTATION/MOVE_ANNOTATION";
|
|
17
18
|
export declare const DELETE_ANNOTATION = "ANNOTATION/DELETE_ANNOTATION";
|
|
18
19
|
export declare const COMMIT_PENDING_CHANGES = "ANNOTATION/COMMIT";
|
|
19
20
|
export declare const PURGE_ANNOTATION = "ANNOTATION/PURGE_ANNOTATION";
|
|
@@ -102,6 +103,15 @@ export interface PatchAnnotationAction extends Action {
|
|
|
102
103
|
patch: Partial<PdfAnnotationObject>;
|
|
103
104
|
};
|
|
104
105
|
}
|
|
106
|
+
export interface MoveAnnotationAction extends Action {
|
|
107
|
+
type: typeof MOVE_ANNOTATION;
|
|
108
|
+
payload: {
|
|
109
|
+
documentId: string;
|
|
110
|
+
pageIndex: number;
|
|
111
|
+
id: string;
|
|
112
|
+
patch: Partial<PdfAnnotationObject>;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
105
115
|
export interface DeleteAnnotationAction extends Action {
|
|
106
116
|
type: typeof DELETE_ANNOTATION;
|
|
107
117
|
payload: {
|
|
@@ -140,7 +150,7 @@ export interface AddToolAction extends Action {
|
|
|
140
150
|
type: typeof ADD_TOOL;
|
|
141
151
|
payload: AnnotationTool;
|
|
142
152
|
}
|
|
143
|
-
export type AnnotationAction = InitAnnotationStateAction | CleanupAnnotationStateAction | SetActiveDocumentAction | SetAnnotationsAction | SelectAnnotationAction | DeselectAnnotationAction | AddToSelectionAction | RemoveFromSelectionAction | SetSelectionAction | SetActiveToolIdAction | CreateAnnotationAction | PatchAnnotationAction | DeleteAnnotationAction | CommitAction | PurgeAnnotationAction | AddColorPresetAction | SetToolDefaultsAction | AddToolAction;
|
|
153
|
+
export type AnnotationAction = InitAnnotationStateAction | CleanupAnnotationStateAction | SetActiveDocumentAction | SetAnnotationsAction | SelectAnnotationAction | DeselectAnnotationAction | AddToSelectionAction | RemoveFromSelectionAction | SetSelectionAction | SetActiveToolIdAction | CreateAnnotationAction | PatchAnnotationAction | MoveAnnotationAction | DeleteAnnotationAction | CommitAction | PurgeAnnotationAction | AddColorPresetAction | SetToolDefaultsAction | AddToolAction;
|
|
144
154
|
export declare function initAnnotationState(documentId: string, state: AnnotationDocumentState): InitAnnotationStateAction;
|
|
145
155
|
export declare function cleanupAnnotationState(documentId: string): CleanupAnnotationStateAction;
|
|
146
156
|
export declare function setActiveDocument(documentId: string | null): SetActiveDocumentAction;
|
|
@@ -153,6 +163,7 @@ export declare const setSelection: (documentId: string, ids: string[]) => SetSel
|
|
|
153
163
|
export declare const setActiveToolId: (documentId: string, toolId: string | null) => SetActiveToolIdAction;
|
|
154
164
|
export declare const createAnnotation: (documentId: string, pageIndex: number, annotation: PdfAnnotationObject) => CreateAnnotationAction;
|
|
155
165
|
export declare const patchAnnotation: (documentId: string, pageIndex: number, id: string, patch: Partial<PdfAnnotationObject>) => PatchAnnotationAction;
|
|
166
|
+
export declare const moveAnnotation: (documentId: string, pageIndex: number, id: string, patch: Partial<PdfAnnotationObject>) => MoveAnnotationAction;
|
|
156
167
|
export declare const deleteAnnotation: (documentId: string, pageIndex: number, id: string) => DeleteAnnotationAction;
|
|
157
168
|
export declare const commitPendingChanges: (documentId: string, committedUids: string[]) => CommitAction;
|
|
158
169
|
export declare const purgeAnnotation: (documentId: string, pageIndex: number, uid: string) => PurgeAnnotationAction;
|
|
@@ -17,10 +17,12 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
|
|
|
17
17
|
private importQueue;
|
|
18
18
|
private commitInProgress;
|
|
19
19
|
private handlerFactories;
|
|
20
|
+
private selectionHandlerFactories;
|
|
20
21
|
private readonly activeTool$;
|
|
21
22
|
private readonly events$;
|
|
22
23
|
private readonly toolsChange$;
|
|
23
24
|
private readonly patchRegistry;
|
|
25
|
+
private readonly appearanceCache;
|
|
24
26
|
private readonly unifiedDragStates;
|
|
25
27
|
private readonly unifiedDrag$;
|
|
26
28
|
private readonly unifiedResizeStates;
|
|
@@ -32,6 +34,7 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
|
|
|
32
34
|
protected onDocumentLoaded(documentId: string): void;
|
|
33
35
|
protected onDocumentClosed(documentId: string): void;
|
|
34
36
|
private registerHandlerFactories;
|
|
37
|
+
private registerSelectionHandlerFactories;
|
|
35
38
|
private registerBuiltInPatches;
|
|
36
39
|
initialize(): Promise<void>;
|
|
37
40
|
private registerInteractionForTool;
|
|
@@ -50,6 +53,20 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
|
|
|
50
53
|
private getSelectedAnnotation;
|
|
51
54
|
private getAnnotationById;
|
|
52
55
|
private renderAnnotation;
|
|
56
|
+
/**
|
|
57
|
+
* Batch-fetch rendered appearance stream images for all annotations on a page.
|
|
58
|
+
* Results are cached per document + page. Call invalidatePageAppearances to clear.
|
|
59
|
+
*/
|
|
60
|
+
private getPageAppearances;
|
|
61
|
+
/**
|
|
62
|
+
* Clear cached appearances for a specific page (e.g. on zoom change).
|
|
63
|
+
*/
|
|
64
|
+
private invalidatePageAppearances;
|
|
65
|
+
/**
|
|
66
|
+
* Remove a single annotation's entry from the page appearance cache.
|
|
67
|
+
* Used after committing changes that regenerate the annotation's appearance.
|
|
68
|
+
*/
|
|
69
|
+
private invalidateAnnotationAppearance;
|
|
53
70
|
private importAnnotations;
|
|
54
71
|
private processImportQueue;
|
|
55
72
|
private processImportItems;
|
|
@@ -227,6 +244,8 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
|
|
|
227
244
|
*/
|
|
228
245
|
get onRotateChange(): import('@embedpdf/core').EventHook<UnifiedRotateEvent>;
|
|
229
246
|
private updateAnnotationsMethod;
|
|
247
|
+
private moveAnnotationsMethod;
|
|
248
|
+
private moveAnnotationMethod;
|
|
230
249
|
getActiveTool(documentId?: string): AnnotationTool | null;
|
|
231
250
|
setActiveTool(toolId: string | null, documentId?: string): void;
|
|
232
251
|
getTool<T extends AnnotationTool>(toolId: string): T | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './ink.handler';
|
|
2
|
+
export * from './text.handler';
|
|
2
3
|
export * from './free-text.handler';
|
|
3
4
|
export * from './line.handler';
|
|
4
5
|
export * from './polyline.handler';
|
|
@@ -6,3 +7,6 @@ export * from './polygon.handler';
|
|
|
6
7
|
export * from './square.handler';
|
|
7
8
|
export * from './stamp.handler';
|
|
8
9
|
export * from './circle.handler';
|
|
10
|
+
export * from './text-markup.handler';
|
|
11
|
+
export * from './insert-text.handler';
|
|
12
|
+
export * from './replace-text.handler';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PdfCaretAnnoObject } from '@embedpdf/models';
|
|
2
|
+
import { SelectionHandlerFactory } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Selection handler for the "Insert Text" tool.
|
|
5
|
+
* Creates a single Caret annotation at the end of the text selection
|
|
6
|
+
* with intent "Insert".
|
|
7
|
+
*/
|
|
8
|
+
export declare const insertTextSelectionHandler: SelectionHandlerFactory<PdfCaretAnnoObject>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PdfStrikeOutAnnoObject } from '@embedpdf/models';
|
|
2
|
+
import { SelectionHandlerFactory } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Selection handler for the "Replace Text" tool.
|
|
5
|
+
* Creates a Caret annotation (group leader, intent "Replace") at the end
|
|
6
|
+
* of the selection, plus a StrikeOut annotation (intent "StrikeOutTextEdit")
|
|
7
|
+
* over the full selection, linked to the Caret via IRT/RT=Group.
|
|
8
|
+
*/
|
|
9
|
+
export declare const replaceTextSelectionHandler: SelectionHandlerFactory<PdfStrikeOutAnnoObject>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rect } from '@embedpdf/models';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a caret annotation rect at the end of a text selection.
|
|
4
|
+
* The caret is half the line height, bottom-aligned with the line,
|
|
5
|
+
* and horizontally centered on the line's end edge.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeCaretRect(lastSegRect: Rect): Rect;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SelectionHandlerFactory } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default selection handler for text-markup tools (highlight, underline,
|
|
4
|
+
* strikeout, squiggly). Used as a fallback when no tool-specific
|
|
5
|
+
* SelectionHandlerFactory is registered.
|
|
6
|
+
*/
|
|
7
|
+
export declare const textMarkupSelectionHandler: SelectionHandlerFactory;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';
|
|
2
2
|
import { PdfAnnotationObject, PdfAnnotationSubtype, Rect, Rotation, Size, AnnotationCreateContext, PdfAnnotationBorderStyle, Position, LineEndings, PdfInkListObject, PdfStandardFont, PdfTextAlignment, PdfVerticalAlignment } from '@embedpdf/models';
|
|
3
|
+
import { FormattedSelection } from '@embedpdf/plugin-selection';
|
|
3
4
|
import { AnnotationTool } from '../tools/types';
|
|
4
5
|
export interface CirclePreviewData {
|
|
5
6
|
rect: Rect;
|
|
@@ -138,4 +139,15 @@ export interface HandlerContext<A extends PdfAnnotationObject> {
|
|
|
138
139
|
onPreview: (state: AnyPreviewState | null) => void;
|
|
139
140
|
onCommit: (annotation: A, context?: AnnotationCreateContext<A>) => void;
|
|
140
141
|
}
|
|
142
|
+
export interface SelectionHandlerContext<A extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
143
|
+
toolId: string;
|
|
144
|
+
documentId: string;
|
|
145
|
+
getTool: () => AnnotationTool<A> | null;
|
|
146
|
+
createAnnotation: (pageIndex: number, annotation: PdfAnnotationObject) => void;
|
|
147
|
+
selectAnnotation: (pageIndex: number, id: string) => void;
|
|
148
|
+
}
|
|
149
|
+
export interface SelectionHandlerFactory<A extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
150
|
+
toolId: string;
|
|
151
|
+
handle(context: SelectionHandlerContext<A>, selections: FormattedSelection[], getText: () => Promise<string | undefined>): void;
|
|
152
|
+
}
|
|
141
153
|
export {};
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type AnnoOf<S extends PdfAnnotationSubtype> = Extract<PdfAnnotationObject
|
|
|
8
8
|
type: S;
|
|
9
9
|
}>;
|
|
10
10
|
export type TextMarkupSubtype = PdfAnnotationSubtype.HIGHLIGHT | PdfAnnotationSubtype.UNDERLINE | PdfAnnotationSubtype.STRIKEOUT | PdfAnnotationSubtype.SQUIGGLY;
|
|
11
|
-
export type SidebarSubtype = TextMarkupSubtype | PdfAnnotationSubtype.INK | PdfAnnotationSubtype.SQUARE | PdfAnnotationSubtype.CIRCLE | PdfAnnotationSubtype.POLYGON | PdfAnnotationSubtype.LINE | PdfAnnotationSubtype.POLYLINE | PdfAnnotationSubtype.FREETEXT | PdfAnnotationSubtype.STAMP | PdfAnnotationSubtype.REDACT;
|
|
11
|
+
export type SidebarSubtype = TextMarkupSubtype | PdfAnnotationSubtype.TEXT | PdfAnnotationSubtype.INK | PdfAnnotationSubtype.SQUARE | PdfAnnotationSubtype.CIRCLE | PdfAnnotationSubtype.POLYGON | PdfAnnotationSubtype.LINE | PdfAnnotationSubtype.POLYLINE | PdfAnnotationSubtype.FREETEXT | PdfAnnotationSubtype.STAMP | PdfAnnotationSubtype.REDACT | PdfAnnotationSubtype.CARET;
|
|
12
12
|
/** True when `a.object.type === INK` – and narrows the generic. */
|
|
13
13
|
export declare function isInk(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.INK>>;
|
|
14
14
|
/** Example for Circle – create similar ones for Square, Line, etc. */
|
|
@@ -27,4 +27,5 @@ export declare function isStamp(a: TrackedAnnotation): a is TrackedAnnotation<An
|
|
|
27
27
|
export declare function isText(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.TEXT>>;
|
|
28
28
|
export declare function isLink(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.LINK>>;
|
|
29
29
|
export declare function isRedact(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.REDACT>>;
|
|
30
|
+
export declare function isCaret(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<PdfAnnotationSubtype.CARET>>;
|
|
30
31
|
export declare function isSidebarAnnotation(a: TrackedAnnotation): a is TrackedAnnotation<AnnoOf<SidebarSubtype>>;
|
package/dist/lib/selectors.d.ts
CHANGED
|
@@ -40,9 +40,14 @@ export declare function getToolDefaultsById<K extends keyof ToolMap>(state: Anno
|
|
|
40
40
|
* Collect every sidebar-eligible annotation and attach its TEXT replies,
|
|
41
41
|
* grouped by page for efficient rendering.
|
|
42
42
|
*
|
|
43
|
+
* Annotations linked via IRT / RT=Group are collapsed: the group leader
|
|
44
|
+
* becomes the sidebar entry and its non-LINK group members are attached
|
|
45
|
+
* as `groupMembers`. This keeps the sidebar compact for tools like
|
|
46
|
+
* Replace Text (Caret + StrikeOut pair).
|
|
47
|
+
*
|
|
43
48
|
* Result shape:
|
|
44
49
|
* {
|
|
45
|
-
* 0: [{ page: 0, annotation: <TrackedAnnotation>, replies: [ … ] }, ...],
|
|
50
|
+
* 0: [{ page: 0, annotation: <TrackedAnnotation>, replies: [ … ], groupMembers: [ … ] }, ...],
|
|
46
51
|
* 1: [{ page: 1, annotation: <TrackedAnnotation>, replies: [ … ] }, ...],
|
|
47
52
|
* …
|
|
48
53
|
* }
|
|
@@ -8,8 +8,10 @@ export declare const defaultTools: ({
|
|
|
8
8
|
textSelection: true;
|
|
9
9
|
isDraggable: false;
|
|
10
10
|
isResizable: false;
|
|
11
|
+
isRotatable: false;
|
|
11
12
|
isGroupDraggable: false;
|
|
12
13
|
isGroupResizable: false;
|
|
14
|
+
showSelectionRects?: undefined;
|
|
13
15
|
cursor?: undefined;
|
|
14
16
|
lockAspectRatio?: undefined;
|
|
15
17
|
lockGroupAspectRatio?: undefined;
|
|
@@ -20,8 +22,8 @@ export declare const defaultTools: ({
|
|
|
20
22
|
color: string;
|
|
21
23
|
opacity: number;
|
|
22
24
|
blendMode: PdfBlendMode.Multiply;
|
|
23
|
-
strokeWidth?: undefined;
|
|
24
25
|
intent?: undefined;
|
|
26
|
+
strokeWidth?: undefined;
|
|
25
27
|
strokeStyle?: undefined;
|
|
26
28
|
lineEndings?: undefined;
|
|
27
29
|
contents?: undefined;
|
|
@@ -43,8 +45,10 @@ export declare const defaultTools: ({
|
|
|
43
45
|
textSelection: true;
|
|
44
46
|
isDraggable: false;
|
|
45
47
|
isResizable: false;
|
|
48
|
+
isRotatable: false;
|
|
46
49
|
isGroupDraggable: false;
|
|
47
50
|
isGroupResizable: false;
|
|
51
|
+
showSelectionRects?: undefined;
|
|
48
52
|
cursor?: undefined;
|
|
49
53
|
lockAspectRatio?: undefined;
|
|
50
54
|
lockGroupAspectRatio?: undefined;
|
|
@@ -55,8 +59,8 @@ export declare const defaultTools: ({
|
|
|
55
59
|
color: string;
|
|
56
60
|
opacity: number;
|
|
57
61
|
blendMode?: undefined;
|
|
58
|
-
strokeWidth?: undefined;
|
|
59
62
|
intent?: undefined;
|
|
63
|
+
strokeWidth?: undefined;
|
|
60
64
|
strokeStyle?: undefined;
|
|
61
65
|
lineEndings?: undefined;
|
|
62
66
|
contents?: undefined;
|
|
@@ -78,8 +82,10 @@ export declare const defaultTools: ({
|
|
|
78
82
|
textSelection: true;
|
|
79
83
|
isDraggable: false;
|
|
80
84
|
isResizable: false;
|
|
85
|
+
isRotatable: false;
|
|
81
86
|
isGroupDraggable: false;
|
|
82
87
|
isGroupResizable: false;
|
|
88
|
+
showSelectionRects?: undefined;
|
|
83
89
|
cursor?: undefined;
|
|
84
90
|
lockAspectRatio?: undefined;
|
|
85
91
|
lockGroupAspectRatio?: undefined;
|
|
@@ -90,8 +96,8 @@ export declare const defaultTools: ({
|
|
|
90
96
|
color: string;
|
|
91
97
|
opacity: number;
|
|
92
98
|
blendMode?: undefined;
|
|
93
|
-
strokeWidth?: undefined;
|
|
94
99
|
intent?: undefined;
|
|
100
|
+
strokeWidth?: undefined;
|
|
95
101
|
strokeStyle?: undefined;
|
|
96
102
|
lineEndings?: undefined;
|
|
97
103
|
contents?: undefined;
|
|
@@ -113,8 +119,10 @@ export declare const defaultTools: ({
|
|
|
113
119
|
textSelection: true;
|
|
114
120
|
isDraggable: false;
|
|
115
121
|
isResizable: false;
|
|
122
|
+
isRotatable: false;
|
|
116
123
|
isGroupDraggable: false;
|
|
117
124
|
isGroupResizable: false;
|
|
125
|
+
showSelectionRects?: undefined;
|
|
118
126
|
cursor?: undefined;
|
|
119
127
|
lockAspectRatio?: undefined;
|
|
120
128
|
lockGroupAspectRatio?: undefined;
|
|
@@ -125,8 +133,82 @@ export declare const defaultTools: ({
|
|
|
125
133
|
color: string;
|
|
126
134
|
opacity: number;
|
|
127
135
|
blendMode?: undefined;
|
|
128
|
-
strokeWidth?: undefined;
|
|
129
136
|
intent?: undefined;
|
|
137
|
+
strokeWidth?: undefined;
|
|
138
|
+
strokeStyle?: undefined;
|
|
139
|
+
lineEndings?: undefined;
|
|
140
|
+
contents?: undefined;
|
|
141
|
+
fontSize?: undefined;
|
|
142
|
+
fontColor?: undefined;
|
|
143
|
+
fontFamily?: undefined;
|
|
144
|
+
textAlign?: undefined;
|
|
145
|
+
verticalAlign?: undefined;
|
|
146
|
+
backgroundColor?: undefined;
|
|
147
|
+
};
|
|
148
|
+
clickBehavior?: undefined;
|
|
149
|
+
behavior?: undefined;
|
|
150
|
+
} | {
|
|
151
|
+
id: "insertText";
|
|
152
|
+
name: string;
|
|
153
|
+
matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0 | 2;
|
|
154
|
+
interaction: {
|
|
155
|
+
exclusive: false;
|
|
156
|
+
textSelection: true;
|
|
157
|
+
showSelectionRects: true;
|
|
158
|
+
isDraggable: false;
|
|
159
|
+
isResizable: false;
|
|
160
|
+
isRotatable: false;
|
|
161
|
+
isGroupDraggable: false;
|
|
162
|
+
isGroupResizable: false;
|
|
163
|
+
cursor?: undefined;
|
|
164
|
+
lockAspectRatio?: undefined;
|
|
165
|
+
lockGroupAspectRatio?: undefined;
|
|
166
|
+
};
|
|
167
|
+
defaults: {
|
|
168
|
+
type: PdfAnnotationSubtype.CARET;
|
|
169
|
+
strokeColor: string;
|
|
170
|
+
opacity: number;
|
|
171
|
+
intent: string;
|
|
172
|
+
color?: undefined;
|
|
173
|
+
blendMode?: undefined;
|
|
174
|
+
strokeWidth?: undefined;
|
|
175
|
+
strokeStyle?: undefined;
|
|
176
|
+
lineEndings?: undefined;
|
|
177
|
+
contents?: undefined;
|
|
178
|
+
fontSize?: undefined;
|
|
179
|
+
fontColor?: undefined;
|
|
180
|
+
fontFamily?: undefined;
|
|
181
|
+
textAlign?: undefined;
|
|
182
|
+
verticalAlign?: undefined;
|
|
183
|
+
backgroundColor?: undefined;
|
|
184
|
+
};
|
|
185
|
+
clickBehavior?: undefined;
|
|
186
|
+
behavior?: undefined;
|
|
187
|
+
} | {
|
|
188
|
+
id: "replaceText";
|
|
189
|
+
name: string;
|
|
190
|
+
matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 2;
|
|
191
|
+
interaction: {
|
|
192
|
+
exclusive: false;
|
|
193
|
+
textSelection: true;
|
|
194
|
+
isDraggable: false;
|
|
195
|
+
isResizable: false;
|
|
196
|
+
isRotatable: false;
|
|
197
|
+
isGroupDraggable: false;
|
|
198
|
+
isGroupResizable: false;
|
|
199
|
+
showSelectionRects?: undefined;
|
|
200
|
+
cursor?: undefined;
|
|
201
|
+
lockAspectRatio?: undefined;
|
|
202
|
+
lockGroupAspectRatio?: undefined;
|
|
203
|
+
};
|
|
204
|
+
defaults: {
|
|
205
|
+
type: PdfAnnotationSubtype.STRIKEOUT;
|
|
206
|
+
strokeColor: string;
|
|
207
|
+
opacity: number;
|
|
208
|
+
intent: string;
|
|
209
|
+
color?: undefined;
|
|
210
|
+
blendMode?: undefined;
|
|
211
|
+
strokeWidth?: undefined;
|
|
130
212
|
strokeStyle?: undefined;
|
|
131
213
|
lineEndings?: undefined;
|
|
132
214
|
contents?: undefined;
|
|
@@ -150,8 +232,10 @@ export declare const defaultTools: ({
|
|
|
150
232
|
isResizable: true;
|
|
151
233
|
lockAspectRatio: false;
|
|
152
234
|
textSelection?: undefined;
|
|
235
|
+
isRotatable?: undefined;
|
|
153
236
|
isGroupDraggable?: undefined;
|
|
154
237
|
isGroupResizable?: undefined;
|
|
238
|
+
showSelectionRects?: undefined;
|
|
155
239
|
lockGroupAspectRatio?: undefined;
|
|
156
240
|
};
|
|
157
241
|
defaults: {
|
|
@@ -186,8 +270,10 @@ export declare const defaultTools: ({
|
|
|
186
270
|
lockAspectRatio: false;
|
|
187
271
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
188
272
|
textSelection?: undefined;
|
|
273
|
+
isRotatable?: undefined;
|
|
189
274
|
isGroupDraggable?: undefined;
|
|
190
275
|
isGroupResizable?: undefined;
|
|
276
|
+
showSelectionRects?: undefined;
|
|
191
277
|
};
|
|
192
278
|
defaults: {
|
|
193
279
|
type: PdfAnnotationSubtype.INK;
|
|
@@ -221,8 +307,10 @@ export declare const defaultTools: ({
|
|
|
221
307
|
lockAspectRatio: false;
|
|
222
308
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
223
309
|
textSelection?: undefined;
|
|
310
|
+
isRotatable?: undefined;
|
|
224
311
|
isGroupDraggable?: undefined;
|
|
225
312
|
isGroupResizable?: undefined;
|
|
313
|
+
showSelectionRects?: undefined;
|
|
226
314
|
};
|
|
227
315
|
defaults: {
|
|
228
316
|
type: PdfAnnotationSubtype.CIRCLE;
|
|
@@ -265,8 +353,10 @@ export declare const defaultTools: ({
|
|
|
265
353
|
lockAspectRatio: false;
|
|
266
354
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
267
355
|
textSelection?: undefined;
|
|
356
|
+
isRotatable?: undefined;
|
|
268
357
|
isGroupDraggable?: undefined;
|
|
269
358
|
isGroupResizable?: undefined;
|
|
359
|
+
showSelectionRects?: undefined;
|
|
270
360
|
};
|
|
271
361
|
defaults: {
|
|
272
362
|
type: PdfAnnotationSubtype.SQUARE;
|
|
@@ -310,7 +400,9 @@ export declare const defaultTools: ({
|
|
|
310
400
|
isGroupResizable: true;
|
|
311
401
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
312
402
|
textSelection?: undefined;
|
|
403
|
+
isRotatable?: undefined;
|
|
313
404
|
isGroupDraggable?: undefined;
|
|
405
|
+
showSelectionRects?: undefined;
|
|
314
406
|
};
|
|
315
407
|
defaults: {
|
|
316
408
|
type: PdfAnnotationSubtype.LINE;
|
|
@@ -351,7 +443,9 @@ export declare const defaultTools: ({
|
|
|
351
443
|
isGroupResizable: true;
|
|
352
444
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
353
445
|
textSelection?: undefined;
|
|
446
|
+
isRotatable?: undefined;
|
|
354
447
|
isGroupDraggable?: undefined;
|
|
448
|
+
showSelectionRects?: undefined;
|
|
355
449
|
};
|
|
356
450
|
defaults: {
|
|
357
451
|
type: PdfAnnotationSubtype.LINE;
|
|
@@ -395,7 +489,9 @@ export declare const defaultTools: ({
|
|
|
395
489
|
isGroupResizable: true;
|
|
396
490
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
397
491
|
textSelection?: undefined;
|
|
492
|
+
isRotatable?: undefined;
|
|
398
493
|
isGroupDraggable?: undefined;
|
|
494
|
+
showSelectionRects?: undefined;
|
|
399
495
|
};
|
|
400
496
|
defaults: {
|
|
401
497
|
type: PdfAnnotationSubtype.POLYLINE;
|
|
@@ -430,7 +526,9 @@ export declare const defaultTools: ({
|
|
|
430
526
|
isGroupResizable: true;
|
|
431
527
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
432
528
|
textSelection?: undefined;
|
|
529
|
+
isRotatable?: undefined;
|
|
433
530
|
isGroupDraggable?: undefined;
|
|
531
|
+
showSelectionRects?: undefined;
|
|
434
532
|
};
|
|
435
533
|
defaults: {
|
|
436
534
|
type: PdfAnnotationSubtype.POLYGON;
|
|
@@ -452,6 +550,47 @@ export declare const defaultTools: ({
|
|
|
452
550
|
};
|
|
453
551
|
clickBehavior?: undefined;
|
|
454
552
|
behavior?: undefined;
|
|
553
|
+
} | {
|
|
554
|
+
id: "textComment";
|
|
555
|
+
name: string;
|
|
556
|
+
matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
|
|
557
|
+
interaction: {
|
|
558
|
+
exclusive: false;
|
|
559
|
+
cursor: string;
|
|
560
|
+
isDraggable: true;
|
|
561
|
+
isResizable: false;
|
|
562
|
+
isRotatable: false;
|
|
563
|
+
textSelection?: undefined;
|
|
564
|
+
isGroupDraggable?: undefined;
|
|
565
|
+
isGroupResizable?: undefined;
|
|
566
|
+
showSelectionRects?: undefined;
|
|
567
|
+
lockAspectRatio?: undefined;
|
|
568
|
+
lockGroupAspectRatio?: undefined;
|
|
569
|
+
};
|
|
570
|
+
defaults: {
|
|
571
|
+
type: PdfAnnotationSubtype.TEXT;
|
|
572
|
+
strokeColor: string;
|
|
573
|
+
opacity: number;
|
|
574
|
+
color?: undefined;
|
|
575
|
+
blendMode?: undefined;
|
|
576
|
+
intent?: undefined;
|
|
577
|
+
strokeWidth?: undefined;
|
|
578
|
+
strokeStyle?: undefined;
|
|
579
|
+
lineEndings?: undefined;
|
|
580
|
+
contents?: undefined;
|
|
581
|
+
fontSize?: undefined;
|
|
582
|
+
fontColor?: undefined;
|
|
583
|
+
fontFamily?: undefined;
|
|
584
|
+
textAlign?: undefined;
|
|
585
|
+
verticalAlign?: undefined;
|
|
586
|
+
backgroundColor?: undefined;
|
|
587
|
+
};
|
|
588
|
+
behavior: {
|
|
589
|
+
selectAfterCreate: true;
|
|
590
|
+
insertUpright?: undefined;
|
|
591
|
+
useAppearanceStream?: undefined;
|
|
592
|
+
};
|
|
593
|
+
clickBehavior?: undefined;
|
|
455
594
|
} | {
|
|
456
595
|
id: "freeText";
|
|
457
596
|
name: string;
|
|
@@ -464,8 +603,10 @@ export declare const defaultTools: ({
|
|
|
464
603
|
lockAspectRatio: false;
|
|
465
604
|
lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
|
|
466
605
|
textSelection?: undefined;
|
|
606
|
+
isRotatable?: undefined;
|
|
467
607
|
isGroupDraggable?: undefined;
|
|
468
608
|
isGroupResizable?: undefined;
|
|
609
|
+
showSelectionRects?: undefined;
|
|
469
610
|
};
|
|
470
611
|
defaults: {
|
|
471
612
|
type: PdfAnnotationSubtype.FREETEXT;
|
|
@@ -480,8 +621,8 @@ export declare const defaultTools: ({
|
|
|
480
621
|
opacity: number;
|
|
481
622
|
strokeColor?: undefined;
|
|
482
623
|
blendMode?: undefined;
|
|
483
|
-
strokeWidth?: undefined;
|
|
484
624
|
intent?: undefined;
|
|
625
|
+
strokeWidth?: undefined;
|
|
485
626
|
strokeStyle?: undefined;
|
|
486
627
|
lineEndings?: undefined;
|
|
487
628
|
};
|
|
@@ -497,6 +638,8 @@ export declare const defaultTools: ({
|
|
|
497
638
|
};
|
|
498
639
|
behavior: {
|
|
499
640
|
insertUpright: true;
|
|
641
|
+
selectAfterCreate?: undefined;
|
|
642
|
+
useAppearanceStream?: undefined;
|
|
500
643
|
};
|
|
501
644
|
} | {
|
|
502
645
|
id: "stamp";
|
|
@@ -510,8 +653,10 @@ export declare const defaultTools: ({
|
|
|
510
653
|
lockAspectRatio: true;
|
|
511
654
|
lockGroupAspectRatio: true;
|
|
512
655
|
textSelection?: undefined;
|
|
656
|
+
isRotatable?: undefined;
|
|
513
657
|
isGroupDraggable?: undefined;
|
|
514
658
|
isGroupResizable?: undefined;
|
|
659
|
+
showSelectionRects?: undefined;
|
|
515
660
|
};
|
|
516
661
|
defaults: {
|
|
517
662
|
type: PdfAnnotationSubtype.STAMP;
|
|
@@ -519,8 +664,8 @@ export declare const defaultTools: ({
|
|
|
519
664
|
color?: undefined;
|
|
520
665
|
opacity?: undefined;
|
|
521
666
|
blendMode?: undefined;
|
|
522
|
-
strokeWidth?: undefined;
|
|
523
667
|
intent?: undefined;
|
|
668
|
+
strokeWidth?: undefined;
|
|
524
669
|
strokeStyle?: undefined;
|
|
525
670
|
lineEndings?: undefined;
|
|
526
671
|
contents?: undefined;
|
|
@@ -533,6 +678,8 @@ export declare const defaultTools: ({
|
|
|
533
678
|
};
|
|
534
679
|
behavior: {
|
|
535
680
|
insertUpright: true;
|
|
681
|
+
useAppearanceStream: false;
|
|
682
|
+
selectAfterCreate?: undefined;
|
|
536
683
|
};
|
|
537
684
|
clickBehavior?: undefined;
|
|
538
685
|
})[];
|
|
@@ -22,4 +22,6 @@ export declare const isPolylineTool: (tool: AnnotationTool<any> | undefined) =>
|
|
|
22
22
|
export declare const isPolygonTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["polygon"];
|
|
23
23
|
export declare const isFreeTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["freeText"];
|
|
24
24
|
export declare const isStampTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["stamp"];
|
|
25
|
+
export declare const isInsertTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["insertText"];
|
|
26
|
+
export declare const isReplaceTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["replaceText"];
|
|
25
27
|
export {};
|
|
@@ -109,6 +109,8 @@ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject>
|
|
|
109
109
|
cursor?: string;
|
|
110
110
|
/** If true, this interaction mode is activated by selecting text. */
|
|
111
111
|
textSelection?: boolean;
|
|
112
|
+
/** Whether to show the native text selection rectangles. Only relevant when textSelection is true. Defaults to false. */
|
|
113
|
+
showSelectionRects?: boolean;
|
|
112
114
|
/** Whether this annotation can be dragged when selected individually. Can be dynamic based on annotation. */
|
|
113
115
|
isDraggable?: DynamicBooleanProp;
|
|
114
116
|
/** Whether this annotation can be resized when selected individually. Can be dynamic based on annotation. */
|
|
@@ -132,6 +134,8 @@ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject>
|
|
|
132
134
|
deactivateToolAfterCreate?: boolean;
|
|
133
135
|
/** When true, select the annotation immediately after creation. Overrides plugin config. */
|
|
134
136
|
selectAfterCreate?: boolean;
|
|
137
|
+
/** Override whether this annotation type uses AP rendering before editing (default: true) */
|
|
138
|
+
useAppearanceStream?: boolean;
|
|
135
139
|
} & InsertUprightBehaviorFor<T>;
|
|
136
140
|
} & ClickBehaviorFor<T>;
|
|
137
141
|
export {};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
-
import { AnnotationCreateContext, PdfAnnotationObject, PdfAnnotationSubtype, PdfErrorReason, PdfRenderPageAnnotationOptions, PdfTextAnnoObject, Position, Rect, Size, Task } from '@embedpdf/models';
|
|
2
|
+
import { AnnotationCreateContext, AnnotationAppearanceMap, PdfAnnotationObject, PdfAnnotationSubtype, PdfErrorReason, PdfRenderPageAnnotationOptions, PdfTextAnnoObject, Position, Rect, Size, Task } from '@embedpdf/models';
|
|
3
3
|
import { AnnotationTool } from './tools/types';
|
|
4
4
|
/**
|
|
5
5
|
* Metadata attached to annotation history commands for filtering/purging.
|
|
@@ -38,10 +38,12 @@ export type AnnotationEvent = {
|
|
|
38
38
|
export type AnnotationToolsChangeEvent = {
|
|
39
39
|
tools: AnnotationTool[];
|
|
40
40
|
};
|
|
41
|
-
export type CommitState = 'new' | 'dirty' | 'deleted' | 'synced' | 'ignored';
|
|
41
|
+
export type CommitState = 'new' | 'dirty' | 'moved' | 'deleted' | 'synced' | 'ignored';
|
|
42
42
|
export interface TrackedAnnotation<T extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
43
43
|
commitState: CommitState;
|
|
44
44
|
object: T;
|
|
45
|
+
/** When true, render using dict-based SVG/CSS instead of appearance stream image */
|
|
46
|
+
dictMode?: boolean;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Represents a batch of pending annotation changes to be committed.
|
|
@@ -58,6 +60,8 @@ export interface CommitBatch {
|
|
|
58
60
|
updates: Array<{
|
|
59
61
|
uid: string;
|
|
60
62
|
ta: TrackedAnnotation;
|
|
63
|
+
/** When true, only positional data changed -- skip appearance regeneration */
|
|
64
|
+
moved?: boolean;
|
|
61
65
|
}>;
|
|
62
66
|
/** Annotations that need to be deleted from the PDF */
|
|
63
67
|
deletions: Array<{
|
|
@@ -204,6 +208,8 @@ export interface AnnotationScope {
|
|
|
204
208
|
id: string;
|
|
205
209
|
patch: Partial<PdfAnnotationObject>;
|
|
206
210
|
}>): void;
|
|
211
|
+
/** Move an annotation by delta or to an absolute position (preserves appearance stream) */
|
|
212
|
+
moveAnnotation(pageIndex: number, annotationId: string, position: Position, mode?: 'delta' | 'absolute'): void;
|
|
207
213
|
deleteAnnotation(pageIndex: number, annotationId: string): void;
|
|
208
214
|
/** Delete multiple annotations in batch */
|
|
209
215
|
deleteAnnotations(annotations: Array<{
|
|
@@ -213,6 +219,10 @@ export interface AnnotationScope {
|
|
|
213
219
|
/** Remove an annotation from state without calling the engine (no PDF modification) */
|
|
214
220
|
purgeAnnotation(pageIndex: number, annotationId: string): void;
|
|
215
221
|
renderAnnotation(options: RenderAnnotationOptions): Task<Blob, PdfErrorReason>;
|
|
222
|
+
/** Batch-fetch rendered appearance stream images for all annotations on a page */
|
|
223
|
+
getPageAppearances(pageIndex: number, options?: PdfRenderPageAnnotationOptions): Task<AnnotationAppearanceMap<Blob>, PdfErrorReason>;
|
|
224
|
+
/** Clear cached appearance images for a page (e.g. on zoom change) */
|
|
225
|
+
invalidatePageAppearances(pageIndex: number): void;
|
|
216
226
|
commit(): Task<boolean, PdfErrorReason>;
|
|
217
227
|
/** Get link annotations attached to an annotation via IRT relationship */
|
|
218
228
|
getAttachedLinks(annotationId: string): TrackedAnnotation[];
|
|
@@ -265,6 +275,8 @@ export interface AnnotationCapability {
|
|
|
265
275
|
id: string;
|
|
266
276
|
patch: Partial<PdfAnnotationObject>;
|
|
267
277
|
}>) => void;
|
|
278
|
+
/** Move an annotation by delta or to an absolute position (preserves appearance stream) */
|
|
279
|
+
moveAnnotation: (pageIndex: number, annotationId: string, position: Position, mode?: 'delta' | 'absolute', documentId?: string) => void;
|
|
268
280
|
deleteAnnotation: (pageIndex: number, annotationId: string) => void;
|
|
269
281
|
/** Delete multiple annotations in batch */
|
|
270
282
|
deleteAnnotations: (annotations: Array<{
|
|
@@ -274,6 +286,10 @@ export interface AnnotationCapability {
|
|
|
274
286
|
/** Remove an annotation from state without calling the engine (no PDF modification) */
|
|
275
287
|
purgeAnnotation: (pageIndex: number, annotationId: string, documentId?: string) => void;
|
|
276
288
|
renderAnnotation: (options: RenderAnnotationOptions) => Task<Blob, PdfErrorReason>;
|
|
289
|
+
/** Batch-fetch rendered appearance stream images for all annotations on a page */
|
|
290
|
+
getPageAppearances: (pageIndex: number, options?: PdfRenderPageAnnotationOptions, documentId?: string) => Task<AnnotationAppearanceMap<Blob>, PdfErrorReason>;
|
|
291
|
+
/** Clear cached appearance images for a page (e.g. on zoom change) */
|
|
292
|
+
invalidatePageAppearances: (pageIndex: number, documentId?: string) => void;
|
|
277
293
|
commit: () => Task<boolean, PdfErrorReason>;
|
|
278
294
|
/** Get link annotations attached to an annotation via IRT relationship */
|
|
279
295
|
getAttachedLinks: (annotationId: string, documentId?: string) => TrackedAnnotation[];
|
|
@@ -321,6 +337,7 @@ export interface SidebarAnnotationEntry {
|
|
|
321
337
|
page: number;
|
|
322
338
|
annotation: TrackedAnnotation;
|
|
323
339
|
replies: TrackedAnnotation<PdfTextAnnoObject>[];
|
|
340
|
+
groupMembers?: TrackedAnnotation[];
|
|
324
341
|
}
|
|
325
342
|
/**
|
|
326
343
|
* Information about an annotation needed for constraint calculation.
|