@embedpdf/plugin-annotation 2.9.0 → 2.10.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 +3082 -2656
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +25 -6
- package/dist/lib/annotation-plugin.d.ts +15 -12
- package/dist/lib/handlers/index.d.ts +1 -0
- package/dist/lib/handlers/link.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +9 -1
- package/dist/lib/helpers.d.ts +12 -5
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/reducer.d.ts +1 -1
- package/dist/lib/tools/default-tools.d.ts +149 -299
- package/dist/lib/tools/tools-utils.d.ts +448 -22
- package/dist/lib/tools/types.d.ts +37 -2
- package/dist/lib/types.d.ts +108 -24
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +213 -92
- 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 +213 -92
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared/components/annotations/stamp.d.ts +1 -1
- package/dist/shared/components/preview-renderer.d.ts +4 -3
- package/dist/shared/components/types.d.ts +21 -4
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-annotation.d.ts +2 -2
- package/dist/shared/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/shared-preact/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-preact/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-preact/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-preact/components/preview-renderer.d.ts +4 -3
- package/dist/shared-preact/components/types.d.ts +21 -4
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-preact/hooks/use-ios-zoom-prevention.d.ts +15 -0
- package/dist/shared-react/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-react/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-react/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-react/components/preview-renderer.d.ts +4 -3
- package/dist/shared-react/components/types.d.ts +21 -4
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-react/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/svelte/components/AnnotationNavigationHandler.svelte.d.ts +3 -0
- package/dist/svelte/components/PreviewRenderer.svelte.d.ts +3 -2
- package/dist/svelte/components/annotations/LinkLockedMode.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/LinkPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/context/renderer-registry.svelte.d.ts +1 -1
- package/dist/svelte/context/types.d.ts +20 -3
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-annotation.svelte.d.ts +1 -1
- package/dist/svelte/hooks/use-ios-zoom-prevention.svelte.d.ts +6 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +422 -234
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-navigation-handler.vue.d.ts +3 -0
- package/dist/vue/components/annotations/link-locked.vue.d.ts +5 -0
- package/dist/vue/components/annotations/link-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
- package/dist/vue/components/preview-renderer.vue.d.ts +3 -2
- package/dist/vue/context/renderer-registry.d.ts +1 -1
- package/dist/vue/context/types.d.ts +20 -3
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-annotation.d.ts +24 -2
- package/dist/vue/hooks/use-ios-zoom-prevention.d.ts +7 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +433 -277
- package/dist/vue/index.js.map +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AnnotationNavigationHandler(): null;
|
|
@@ -7,7 +7,7 @@ interface StampProps {
|
|
|
7
7
|
documentId: string;
|
|
8
8
|
pageIndex: number;
|
|
9
9
|
scale: number;
|
|
10
|
-
onClick
|
|
10
|
+
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function Stamp({ isSelected, annotation, documentId, pageIndex, scale, onClick, }: StampProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewState } from '../../index.ts';
|
|
2
2
|
interface Props {
|
|
3
|
-
|
|
3
|
+
toolId: string;
|
|
4
|
+
preview: PreviewState;
|
|
4
5
|
scale: number;
|
|
5
6
|
}
|
|
6
|
-
export declare function PreviewRenderer({ preview, scale }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare function PreviewRenderer({ toolId, preview, scale }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
7
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';
|
|
1
|
+
import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
|
|
2
2
|
import { TrackedAnnotation } from '../../index.ts';
|
|
3
3
|
import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
|
|
4
4
|
import { JSX, CSSProperties, MouseEvent } from '../../react/adapter.ts';
|
|
@@ -122,7 +122,7 @@ export interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnno
|
|
|
122
122
|
scale: number;
|
|
123
123
|
pageIndex: number;
|
|
124
124
|
documentId: string;
|
|
125
|
-
onClick
|
|
125
|
+
onClick?: (e: AnnotationInteractionEvent) => void;
|
|
126
126
|
/** When true, AP canvas provides the visual; component should only render hit area */
|
|
127
127
|
appearanceActive: boolean;
|
|
128
128
|
}
|
|
@@ -141,13 +141,19 @@ export interface SelectOverrideHelpers {
|
|
|
141
141
|
* This allows external plugins to provide their own rendering for annotation subtypes.
|
|
142
142
|
* Used at definition time for type safety.
|
|
143
143
|
*/
|
|
144
|
-
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
144
|
+
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
|
|
145
145
|
/** Unique identifier for this renderer (usually matches tool id) */
|
|
146
146
|
id: string;
|
|
147
147
|
/** Returns true if this renderer should handle the annotation */
|
|
148
148
|
matches: (annotation: PdfAnnotationObject) => annotation is T;
|
|
149
149
|
/** The component to render the annotation */
|
|
150
150
|
render: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
151
|
+
/** Render a preview during drag-to-create. P is the preview data type. */
|
|
152
|
+
renderPreview?: (props: {
|
|
153
|
+
data: P;
|
|
154
|
+
bounds: Rect;
|
|
155
|
+
scale: number;
|
|
156
|
+
}) => JSX.Element;
|
|
151
157
|
/** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
|
|
152
158
|
vertexConfig?: VertexConfig<T>;
|
|
153
159
|
/** z-index for the annotation container (default: 1, text markup uses 0) */
|
|
@@ -175,6 +181,10 @@ export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnno
|
|
|
175
181
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation<T>, helpers: SelectOverrideHelpers) => void;
|
|
176
182
|
/** Return true to hide the selection menu for this annotation */
|
|
177
183
|
hideSelectionMenu?: (annotation: T) => boolean;
|
|
184
|
+
/** When true, the annotation is completely hidden when locked (e.g., form widgets defer to the form-filling layer). */
|
|
185
|
+
hiddenWhenLocked?: boolean;
|
|
186
|
+
/** Optional locked-mode renderer. When the annotation is locked, this replaces `render` inside the container. */
|
|
187
|
+
renderLocked?: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
178
188
|
}
|
|
179
189
|
/**
|
|
180
190
|
* Boxed renderer that encapsulates type safety internally.
|
|
@@ -184,6 +194,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
184
194
|
id: string;
|
|
185
195
|
matches: (annotation: PdfAnnotationObject) => boolean;
|
|
186
196
|
render: (props: AnnotationRendererProps) => JSX.Element;
|
|
197
|
+
renderPreview?: (props: {
|
|
198
|
+
data: unknown;
|
|
199
|
+
bounds: Rect;
|
|
200
|
+
scale: number;
|
|
201
|
+
}) => JSX.Element;
|
|
187
202
|
vertexConfig?: VertexConfig<PdfAnnotationObject>;
|
|
188
203
|
zIndex?: number;
|
|
189
204
|
defaultBlendMode?: PdfBlendMode;
|
|
@@ -202,9 +217,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
202
217
|
onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;
|
|
203
218
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation, helpers: SelectOverrideHelpers) => void;
|
|
204
219
|
hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;
|
|
220
|
+
hiddenWhenLocked?: boolean;
|
|
221
|
+
renderLocked?: (props: AnnotationRendererProps) => JSX.Element;
|
|
205
222
|
}
|
|
206
223
|
/**
|
|
207
224
|
* Creates a boxed renderer from a typed entry.
|
|
208
225
|
* Type safety is enforced at definition time, then erased for storage.
|
|
209
226
|
*/
|
|
210
|
-
export declare function createRenderer<T extends PdfAnnotationObject>(entry: AnnotationRendererEntry<T>): BoxedAnnotationRenderer;
|
|
227
|
+
export declare function createRenderer<T extends PdfAnnotationObject, P = never>(entry: AnnotationRendererEntry<T, P>): BoxedAnnotationRenderer;
|
|
@@ -5,7 +5,7 @@ export declare const useAnnotationPlugin: () => {
|
|
|
5
5
|
ready: Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
export declare const useAnnotationCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../index.ts').AnnotationCapability
|
|
8
|
+
provides: Readonly<import('../../index.ts').AnnotationCapability<import('../../index.ts').AnnotationToolMap>> | null;
|
|
9
9
|
isLoading: boolean;
|
|
10
10
|
ready: Promise<void>;
|
|
11
11
|
};
|
|
@@ -15,5 +15,5 @@ export declare const useAnnotationCapability: () => {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const useAnnotation: (documentId: string) => {
|
|
17
17
|
state: AnnotationDocumentState;
|
|
18
|
-
provides: import('../../index.ts').AnnotationScope | null;
|
|
18
|
+
provides: import('../../index.ts').AnnotationScope<import('../../index.ts').AnnotationToolMap> | null;
|
|
19
19
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Prevents iOS Safari from auto-zooming when a focused input's computed
|
|
4
|
+
* font-size is below 16px. Returns an adjusted font size and optional
|
|
5
|
+
* wrapper style that uses `transform: scale()` to visually match the
|
|
6
|
+
* intended size while keeping the real font at >= 16px.
|
|
7
|
+
*
|
|
8
|
+
* @param computedFontPx - The intended on-screen font size (fontSize * scale)
|
|
9
|
+
* @param active - Whether compensation should apply (e.g. isEditing, or always true for form inputs)
|
|
10
|
+
*/
|
|
11
|
+
export declare function useIOSZoomPrevention(computedFontPx: number, active: boolean): {
|
|
12
|
+
needsComp: boolean;
|
|
13
|
+
adjustedFontPx: number;
|
|
14
|
+
scaleComp: number;
|
|
15
|
+
wrapperStyle: CSSProperties | undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AnnotationNavigationHandler(): null;
|
|
@@ -7,7 +7,7 @@ interface StampProps {
|
|
|
7
7
|
documentId: string;
|
|
8
8
|
pageIndex: number;
|
|
9
9
|
scale: number;
|
|
10
|
-
onClick
|
|
10
|
+
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function Stamp({ isSelected, annotation, documentId, pageIndex, scale, onClick, }: StampProps): import("preact").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewState } from '../../lib/index.ts';
|
|
2
2
|
interface Props {
|
|
3
|
-
|
|
3
|
+
toolId: string;
|
|
4
|
+
preview: PreviewState;
|
|
4
5
|
scale: number;
|
|
5
6
|
}
|
|
6
|
-
export declare function PreviewRenderer({ preview, scale }: Props): import("preact").JSX.Element | null;
|
|
7
|
+
export declare function PreviewRenderer({ toolId, preview, scale }: Props): import("preact").JSX.Element | null;
|
|
7
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';
|
|
1
|
+
import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
|
|
2
2
|
import { TrackedAnnotation } from '../../lib/index.ts';
|
|
3
3
|
import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../preact/utils.ts';
|
|
4
4
|
import { JSX, CSSProperties, MouseEvent } from '../../preact/adapter.ts';
|
|
@@ -122,7 +122,7 @@ export interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnno
|
|
|
122
122
|
scale: number;
|
|
123
123
|
pageIndex: number;
|
|
124
124
|
documentId: string;
|
|
125
|
-
onClick
|
|
125
|
+
onClick?: (e: AnnotationInteractionEvent) => void;
|
|
126
126
|
/** When true, AP canvas provides the visual; component should only render hit area */
|
|
127
127
|
appearanceActive: boolean;
|
|
128
128
|
}
|
|
@@ -141,13 +141,19 @@ export interface SelectOverrideHelpers {
|
|
|
141
141
|
* This allows external plugins to provide their own rendering for annotation subtypes.
|
|
142
142
|
* Used at definition time for type safety.
|
|
143
143
|
*/
|
|
144
|
-
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
144
|
+
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
|
|
145
145
|
/** Unique identifier for this renderer (usually matches tool id) */
|
|
146
146
|
id: string;
|
|
147
147
|
/** Returns true if this renderer should handle the annotation */
|
|
148
148
|
matches: (annotation: PdfAnnotationObject) => annotation is T;
|
|
149
149
|
/** The component to render the annotation */
|
|
150
150
|
render: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
151
|
+
/** Render a preview during drag-to-create. P is the preview data type. */
|
|
152
|
+
renderPreview?: (props: {
|
|
153
|
+
data: P;
|
|
154
|
+
bounds: Rect;
|
|
155
|
+
scale: number;
|
|
156
|
+
}) => JSX.Element;
|
|
151
157
|
/** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
|
|
152
158
|
vertexConfig?: VertexConfig<T>;
|
|
153
159
|
/** z-index for the annotation container (default: 1, text markup uses 0) */
|
|
@@ -175,6 +181,10 @@ export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnno
|
|
|
175
181
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation<T>, helpers: SelectOverrideHelpers) => void;
|
|
176
182
|
/** Return true to hide the selection menu for this annotation */
|
|
177
183
|
hideSelectionMenu?: (annotation: T) => boolean;
|
|
184
|
+
/** When true, the annotation is completely hidden when locked (e.g., form widgets defer to the form-filling layer). */
|
|
185
|
+
hiddenWhenLocked?: boolean;
|
|
186
|
+
/** Optional locked-mode renderer. When the annotation is locked, this replaces `render` inside the container. */
|
|
187
|
+
renderLocked?: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
178
188
|
}
|
|
179
189
|
/**
|
|
180
190
|
* Boxed renderer that encapsulates type safety internally.
|
|
@@ -184,6 +194,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
184
194
|
id: string;
|
|
185
195
|
matches: (annotation: PdfAnnotationObject) => boolean;
|
|
186
196
|
render: (props: AnnotationRendererProps) => JSX.Element;
|
|
197
|
+
renderPreview?: (props: {
|
|
198
|
+
data: unknown;
|
|
199
|
+
bounds: Rect;
|
|
200
|
+
scale: number;
|
|
201
|
+
}) => JSX.Element;
|
|
187
202
|
vertexConfig?: VertexConfig<PdfAnnotationObject>;
|
|
188
203
|
zIndex?: number;
|
|
189
204
|
defaultBlendMode?: PdfBlendMode;
|
|
@@ -202,9 +217,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
202
217
|
onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;
|
|
203
218
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation, helpers: SelectOverrideHelpers) => void;
|
|
204
219
|
hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;
|
|
220
|
+
hiddenWhenLocked?: boolean;
|
|
221
|
+
renderLocked?: (props: AnnotationRendererProps) => JSX.Element;
|
|
205
222
|
}
|
|
206
223
|
/**
|
|
207
224
|
* Creates a boxed renderer from a typed entry.
|
|
208
225
|
* Type safety is enforced at definition time, then erased for storage.
|
|
209
226
|
*/
|
|
210
|
-
export declare function createRenderer<T extends PdfAnnotationObject>(entry: AnnotationRendererEntry<T>): BoxedAnnotationRenderer;
|
|
227
|
+
export declare function createRenderer<T extends PdfAnnotationObject, P = never>(entry: AnnotationRendererEntry<T, P>): BoxedAnnotationRenderer;
|
|
@@ -5,7 +5,7 @@ export declare const useAnnotationPlugin: () => {
|
|
|
5
5
|
ready: Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
export declare const useAnnotationCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../lib/index.ts').AnnotationCapability
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').AnnotationCapability<import('../../lib/index.ts').AnnotationToolMap>> | null;
|
|
9
9
|
isLoading: boolean;
|
|
10
10
|
ready: Promise<void>;
|
|
11
11
|
};
|
|
@@ -15,5 +15,5 @@ export declare const useAnnotationCapability: () => {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const useAnnotation: (documentId: string) => {
|
|
17
17
|
state: AnnotationDocumentState;
|
|
18
|
-
provides: import('../../lib/index.ts').AnnotationScope | null;
|
|
18
|
+
provides: import('../../lib/index.ts').AnnotationScope<import('../../lib/index.ts').AnnotationToolMap> | null;
|
|
19
19
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prevents iOS Safari from auto-zooming when a focused input's computed
|
|
3
|
+
* font-size is below 16px. Returns an adjusted font size and optional
|
|
4
|
+
* wrapper style that uses `transform: scale()` to visually match the
|
|
5
|
+
* intended size while keeping the real font at >= 16px.
|
|
6
|
+
*
|
|
7
|
+
* @param computedFontPx - The intended on-screen font size (fontSize * scale)
|
|
8
|
+
* @param active - Whether compensation should apply (e.g. isEditing, or always true for form inputs)
|
|
9
|
+
*/
|
|
10
|
+
export declare function useIOSZoomPrevention(computedFontPx: number, active: boolean): {
|
|
11
|
+
needsComp: boolean;
|
|
12
|
+
adjustedFontPx: number;
|
|
13
|
+
scaleComp: number;
|
|
14
|
+
wrapperStyle: import("preact").JSX.CSSProperties | undefined;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AnnotationNavigationHandler(): null;
|
|
@@ -7,7 +7,7 @@ interface StampProps {
|
|
|
7
7
|
documentId: string;
|
|
8
8
|
pageIndex: number;
|
|
9
9
|
scale: number;
|
|
10
|
-
onClick
|
|
10
|
+
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function Stamp({ isSelected, annotation, documentId, pageIndex, scale, onClick, }: StampProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewState } from '../../lib/index.ts';
|
|
2
2
|
interface Props {
|
|
3
|
-
|
|
3
|
+
toolId: string;
|
|
4
|
+
preview: PreviewState;
|
|
4
5
|
scale: number;
|
|
5
6
|
}
|
|
6
|
-
export declare function PreviewRenderer({ preview, scale }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare function PreviewRenderer({ toolId, preview, scale }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
7
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';
|
|
1
|
+
import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
|
|
2
2
|
import { TrackedAnnotation } from '../../lib/index.ts';
|
|
3
3
|
import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
|
|
4
4
|
import { JSX, CSSProperties, MouseEvent } from '../../react/adapter.ts';
|
|
@@ -122,7 +122,7 @@ export interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnno
|
|
|
122
122
|
scale: number;
|
|
123
123
|
pageIndex: number;
|
|
124
124
|
documentId: string;
|
|
125
|
-
onClick
|
|
125
|
+
onClick?: (e: AnnotationInteractionEvent) => void;
|
|
126
126
|
/** When true, AP canvas provides the visual; component should only render hit area */
|
|
127
127
|
appearanceActive: boolean;
|
|
128
128
|
}
|
|
@@ -141,13 +141,19 @@ export interface SelectOverrideHelpers {
|
|
|
141
141
|
* This allows external plugins to provide their own rendering for annotation subtypes.
|
|
142
142
|
* Used at definition time for type safety.
|
|
143
143
|
*/
|
|
144
|
-
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
144
|
+
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
|
|
145
145
|
/** Unique identifier for this renderer (usually matches tool id) */
|
|
146
146
|
id: string;
|
|
147
147
|
/** Returns true if this renderer should handle the annotation */
|
|
148
148
|
matches: (annotation: PdfAnnotationObject) => annotation is T;
|
|
149
149
|
/** The component to render the annotation */
|
|
150
150
|
render: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
151
|
+
/** Render a preview during drag-to-create. P is the preview data type. */
|
|
152
|
+
renderPreview?: (props: {
|
|
153
|
+
data: P;
|
|
154
|
+
bounds: Rect;
|
|
155
|
+
scale: number;
|
|
156
|
+
}) => JSX.Element;
|
|
151
157
|
/** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
|
|
152
158
|
vertexConfig?: VertexConfig<T>;
|
|
153
159
|
/** z-index for the annotation container (default: 1, text markup uses 0) */
|
|
@@ -175,6 +181,10 @@ export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnno
|
|
|
175
181
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation<T>, helpers: SelectOverrideHelpers) => void;
|
|
176
182
|
/** Return true to hide the selection menu for this annotation */
|
|
177
183
|
hideSelectionMenu?: (annotation: T) => boolean;
|
|
184
|
+
/** When true, the annotation is completely hidden when locked (e.g., form widgets defer to the form-filling layer). */
|
|
185
|
+
hiddenWhenLocked?: boolean;
|
|
186
|
+
/** Optional locked-mode renderer. When the annotation is locked, this replaces `render` inside the container. */
|
|
187
|
+
renderLocked?: (props: AnnotationRendererProps<T>) => JSX.Element;
|
|
178
188
|
}
|
|
179
189
|
/**
|
|
180
190
|
* Boxed renderer that encapsulates type safety internally.
|
|
@@ -184,6 +194,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
184
194
|
id: string;
|
|
185
195
|
matches: (annotation: PdfAnnotationObject) => boolean;
|
|
186
196
|
render: (props: AnnotationRendererProps) => JSX.Element;
|
|
197
|
+
renderPreview?: (props: {
|
|
198
|
+
data: unknown;
|
|
199
|
+
bounds: Rect;
|
|
200
|
+
scale: number;
|
|
201
|
+
}) => JSX.Element;
|
|
187
202
|
vertexConfig?: VertexConfig<PdfAnnotationObject>;
|
|
188
203
|
zIndex?: number;
|
|
189
204
|
defaultBlendMode?: PdfBlendMode;
|
|
@@ -202,9 +217,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
202
217
|
onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;
|
|
203
218
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation, helpers: SelectOverrideHelpers) => void;
|
|
204
219
|
hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;
|
|
220
|
+
hiddenWhenLocked?: boolean;
|
|
221
|
+
renderLocked?: (props: AnnotationRendererProps) => JSX.Element;
|
|
205
222
|
}
|
|
206
223
|
/**
|
|
207
224
|
* Creates a boxed renderer from a typed entry.
|
|
208
225
|
* Type safety is enforced at definition time, then erased for storage.
|
|
209
226
|
*/
|
|
210
|
-
export declare function createRenderer<T extends PdfAnnotationObject>(entry: AnnotationRendererEntry<T>): BoxedAnnotationRenderer;
|
|
227
|
+
export declare function createRenderer<T extends PdfAnnotationObject, P = never>(entry: AnnotationRendererEntry<T, P>): BoxedAnnotationRenderer;
|
|
@@ -5,7 +5,7 @@ export declare const useAnnotationPlugin: () => {
|
|
|
5
5
|
ready: Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
export declare const useAnnotationCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../lib/index.ts').AnnotationCapability
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').AnnotationCapability<import('../../lib/index.ts').AnnotationToolMap>> | null;
|
|
9
9
|
isLoading: boolean;
|
|
10
10
|
ready: Promise<void>;
|
|
11
11
|
};
|
|
@@ -15,5 +15,5 @@ export declare const useAnnotationCapability: () => {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const useAnnotation: (documentId: string) => {
|
|
17
17
|
state: AnnotationDocumentState;
|
|
18
|
-
provides: import('../../lib/index.ts').AnnotationScope | null;
|
|
18
|
+
provides: import('../../lib/index.ts').AnnotationScope<import('../../lib/index.ts').AnnotationToolMap> | null;
|
|
19
19
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Prevents iOS Safari from auto-zooming when a focused input's computed
|
|
4
|
+
* font-size is below 16px. Returns an adjusted font size and optional
|
|
5
|
+
* wrapper style that uses `transform: scale()` to visually match the
|
|
6
|
+
* intended size while keeping the real font at >= 16px.
|
|
7
|
+
*
|
|
8
|
+
* @param computedFontPx - The intended on-screen font size (fontSize * scale)
|
|
9
|
+
* @param active - Whether compensation should apply (e.g. isEditing, or always true for form inputs)
|
|
10
|
+
*/
|
|
11
|
+
export declare function useIOSZoomPrevention(computedFontPx: number, active: boolean): {
|
|
12
|
+
needsComp: boolean;
|
|
13
|
+
adjustedFontPx: number;
|
|
14
|
+
scaleComp: number;
|
|
15
|
+
wrapperStyle: CSSProperties | undefined;
|
|
16
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewState } from '../../lib/index.ts';
|
|
2
2
|
interface PreviewRendererProps {
|
|
3
|
-
|
|
3
|
+
toolId: string;
|
|
4
|
+
preview: PreviewState;
|
|
4
5
|
scale: number;
|
|
5
6
|
}
|
|
6
7
|
declare const PreviewRenderer: import('svelte', { with: { "resolution-mode": "import" } }).Component<PreviewRendererProps, {}, "">;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PdfLinkAnnoObject } from '@embedpdf/models';
|
|
2
|
+
import { AnnotationRendererProps } from '../../context/types';
|
|
3
|
+
declare const LinkLockedMode: import('svelte', { with: { "resolution-mode": "import" } }).Component<AnnotationRendererProps<PdfLinkAnnoObject>, {}, "">;
|
|
4
|
+
type LinkLockedMode = ReturnType<typeof LinkLockedMode>;
|
|
5
|
+
export default LinkLockedMode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rect } from '@embedpdf/models';
|
|
2
|
+
import { LinkPreviewData } from '../../../lib/index.ts';
|
|
3
|
+
interface LinkPreviewProps {
|
|
4
|
+
data: LinkPreviewData;
|
|
5
|
+
bounds: Rect;
|
|
6
|
+
scale: number;
|
|
7
|
+
}
|
|
8
|
+
declare const LinkPreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<LinkPreviewProps, {}, "">;
|
|
9
|
+
type LinkPreview = ReturnType<typeof LinkPreview>;
|
|
10
|
+
export default LinkPreview;
|
|
@@ -6,7 +6,7 @@ interface StampProps {
|
|
|
6
6
|
annotation: TrackedAnnotation<PdfStampAnnoObject>;
|
|
7
7
|
pageIndex: number;
|
|
8
8
|
scale: number;
|
|
9
|
-
onClick
|
|
9
|
+
onClick?: (e: MouseEvent) => void;
|
|
10
10
|
}
|
|
11
11
|
declare const Stamp: import('svelte', { with: { "resolution-mode": "import" } }).Component<StampProps, {}, "">;
|
|
12
12
|
type Stamp = ReturnType<typeof Stamp>;
|
|
@@ -16,5 +16,5 @@ export declare function getRendererRegistry(): AnnotationRendererRegistry | null
|
|
|
16
16
|
/**
|
|
17
17
|
* Factory to create a boxed renderer from a typed entry.
|
|
18
18
|
*/
|
|
19
|
-
export declare function createRenderer<T extends PdfAnnotationObject>(entry: AnnotationRendererEntry<T>): BoxedAnnotationRenderer;
|
|
19
|
+
export declare function createRenderer<T extends PdfAnnotationObject, P = never>(entry: AnnotationRendererEntry<T, P>): BoxedAnnotationRenderer;
|
|
20
20
|
export type { AnnotationRendererProps, AnnotationRendererEntry, BoxedAnnotationRenderer, AnnotationInteractionEvent, SelectOverrideHelpers, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'svelte';
|
|
2
|
-
import { PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';
|
|
2
|
+
import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
|
|
3
3
|
import { TrackedAnnotation } from '../../lib/index.ts';
|
|
4
4
|
import { VertexConfig } from '../../shared-svelte/types';
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ export interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnno
|
|
|
17
17
|
scale: number;
|
|
18
18
|
pageIndex: number;
|
|
19
19
|
documentId: string;
|
|
20
|
-
onClick
|
|
20
|
+
onClick?: (e: AnnotationInteractionEvent) => void;
|
|
21
21
|
/** When true, AP canvas provides the visual; component should only render hit area */
|
|
22
22
|
appearanceActive: boolean;
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ export interface SelectOverrideHelpers {
|
|
|
35
35
|
* Entry for defining a custom annotation renderer.
|
|
36
36
|
* Type safety enforced at definition time via generic.
|
|
37
37
|
*/
|
|
38
|
-
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {
|
|
38
|
+
export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
|
|
39
39
|
/** Unique identifier for this renderer */
|
|
40
40
|
id: string;
|
|
41
41
|
/** Returns true if this renderer handles the annotation */
|
|
@@ -69,6 +69,16 @@ export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnno
|
|
|
69
69
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation<T>, helpers: SelectOverrideHelpers) => void;
|
|
70
70
|
/** Return true to hide the selection menu for this annotation */
|
|
71
71
|
hideSelectionMenu?: (annotation: T) => boolean;
|
|
72
|
+
/** Render a preview during drag-to-create. P is the preview data type. */
|
|
73
|
+
renderPreview?: Component<{
|
|
74
|
+
data: P;
|
|
75
|
+
bounds: Rect;
|
|
76
|
+
scale: number;
|
|
77
|
+
}>;
|
|
78
|
+
/** When true, the annotation is completely hidden when locked (e.g., form widgets defer to the form-filling layer). */
|
|
79
|
+
hiddenWhenLocked?: boolean;
|
|
80
|
+
/** Optional locked-mode renderer. When the annotation is locked, this replaces `component` inside the container. */
|
|
81
|
+
renderLocked?: Component<AnnotationRendererProps<T>>;
|
|
72
82
|
}
|
|
73
83
|
/**
|
|
74
84
|
* Boxed renderer stored in registry (generic erased for storage)
|
|
@@ -95,4 +105,11 @@ export interface BoxedAnnotationRenderer {
|
|
|
95
105
|
onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;
|
|
96
106
|
selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation, helpers: SelectOverrideHelpers) => void;
|
|
97
107
|
hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;
|
|
108
|
+
renderPreview?: Component<{
|
|
109
|
+
data: unknown;
|
|
110
|
+
bounds: Rect;
|
|
111
|
+
scale: number;
|
|
112
|
+
}>;
|
|
113
|
+
hiddenWhenLocked?: boolean;
|
|
114
|
+
renderLocked?: Component<AnnotationRendererProps>;
|
|
98
115
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnnotationPlugin, AnnotationDocumentState, AnnotationScope } from '../../lib/index.ts';
|
|
2
2
|
export declare const useAnnotationCapability: () => {
|
|
3
|
-
provides: Readonly<import('../../lib/index.ts').AnnotationCapability
|
|
3
|
+
provides: Readonly<import('../../lib/index.ts').AnnotationCapability<import('../../lib/index.ts').AnnotationToolMap>> | null;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
ready: Promise<void>;
|
|
6
6
|
};
|