@embedpdf/plugin-annotation 2.10.1 → 2.11.1
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 +19 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +2 -1
- package/dist/lib/annotation-plugin.d.ts +1 -1
- package/dist/lib/handlers/types.d.ts +17 -5
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/tools/default-tools.d.ts +12 -12
- package/dist/lib/tools/tools-utils.d.ts +9 -9
- package/dist/lib/tools/types.d.ts +1 -1
- package/dist/lib/types.d.ts +5 -4
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +48 -45
- 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 +48 -45
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/types.d.ts +19 -5
- package/dist/shared-preact/components/types.d.ts +19 -5
- package/dist/shared-react/components/types.d.ts +19 -5
- package/dist/svelte/components/annotations/CirclePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/FreeTextPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/InkPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/LinePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/PolygonPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/PolylinePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/SquarePreview.svelte.d.ts +10 -0
- package/dist/svelte/context/types.d.ts +19 -5
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +247 -425
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotations/circle-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/free-text-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/ink-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/line-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/polygon-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/polyline-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/square-preview.vue.d.ts +10 -0
- package/dist/vue/context/types.d.ts +19 -5
- package/dist/vue/hooks/use-annotation.d.ts +2 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +279 -163
- package/dist/vue/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clamp, BasePlugin, createScopedEmitter, createBehaviorEmitter } from "@embedpdf/core";
|
|
2
|
-
import { PdfAnnotationSubtype, PdfAnnotationReplyType, expandRect, rectFromPoints, uuidV4, PdfAnnotationLineEnding, getRectCenter, inferRotationCenterFromRects, calculateRotatedRectAABBAroundPoint, rotateAndTranslatePoint, calculateRotatedRectAABB, rotatePointAround, rotateVertices,
|
|
2
|
+
import { PdfAnnotationSubtype, PdfAnnotationReplyType, expandRect, rectFromPoints, uuidV4, PdfAnnotationLineEnding, getRectCenter, inferRotationCenterFromRects, calculateRotatedRectAABBAroundPoint, rotateAndTranslatePoint, calculateRotatedRectAABB, rotatePointAround, rotateVertices, PdfAnnotationName, PdfVerticalAlignment, PdfTextAlignment, PdfStandardFont, PdfAnnotationBorderStyle, PdfBlendMode, PdfPermissionFlag, ignore, PdfTaskHelper, PdfErrorCode, Task, PdfActionType, PdfZoomMode, TaskStage } from "@embedpdf/models";
|
|
3
3
|
import { calculateRotatedRectAABB as calculateRotatedRectAABB2, calculateRotatedRectAABBAroundPoint as calculateRotatedRectAABBAroundPoint2, getRectCenter as getRectCenter2, inferRotationCenterFromRects as inferRotationCenterFromRects2, rotatePointAround as rotatePointAround2, rotateVertices as rotateVertices2 } from "@embedpdf/models";
|
|
4
4
|
const ANNOTATION_PLUGIN_ID = "annotation";
|
|
5
5
|
const manifest = {
|
|
@@ -68,9 +68,9 @@ const setSelection = (documentId, ids) => ({
|
|
|
68
68
|
type: SET_SELECTION,
|
|
69
69
|
payload: { documentId, ids }
|
|
70
70
|
});
|
|
71
|
-
const setActiveToolId = (documentId, toolId) => ({
|
|
71
|
+
const setActiveToolId = (documentId, toolId, context) => ({
|
|
72
72
|
type: SET_ACTIVE_TOOL_ID,
|
|
73
|
-
payload: { documentId, toolId }
|
|
73
|
+
payload: { documentId, toolId, context }
|
|
74
74
|
});
|
|
75
75
|
const createAnnotation = (documentId, pageIndex, annotation) => ({
|
|
76
76
|
type: CREATE_ANNOTATION,
|
|
@@ -930,7 +930,7 @@ const textHandlerFactory = {
|
|
|
930
930
|
...tool.defaults,
|
|
931
931
|
rect,
|
|
932
932
|
type: PdfAnnotationSubtype.TEXT,
|
|
933
|
-
|
|
933
|
+
name: tool.defaults.name ?? PdfAnnotationName.Comment,
|
|
934
934
|
contents: tool.defaults.contents ?? "",
|
|
935
935
|
flags: tool.defaults.flags ?? ["print", "noRotate", "noZoom"],
|
|
936
936
|
pageIndex: context.pageIndex,
|
|
@@ -2220,7 +2220,7 @@ const stampHandlerFactory = {
|
|
|
2220
2220
|
...tool.defaults,
|
|
2221
2221
|
rect,
|
|
2222
2222
|
type: PdfAnnotationSubtype.STAMP,
|
|
2223
|
-
|
|
2223
|
+
name: tool.defaults.name ?? PdfAnnotationName.Image,
|
|
2224
2224
|
subject: tool.defaults.subject ?? "Stamp",
|
|
2225
2225
|
flags: tool.defaults.flags ?? ["print"],
|
|
2226
2226
|
pageIndex: context.pageIndex,
|
|
@@ -3938,14 +3938,14 @@ const reducer = (state, action) => {
|
|
|
3938
3938
|
};
|
|
3939
3939
|
}
|
|
3940
3940
|
case SET_ACTIVE_TOOL_ID: {
|
|
3941
|
-
const { documentId, toolId } = action.payload;
|
|
3941
|
+
const { documentId, toolId, context } = action.payload;
|
|
3942
3942
|
const docState = state.documents[documentId];
|
|
3943
3943
|
if (!docState) return state;
|
|
3944
3944
|
return {
|
|
3945
3945
|
...state,
|
|
3946
3946
|
documents: {
|
|
3947
3947
|
...state.documents,
|
|
3948
|
-
[documentId]: { ...docState, activeToolId: toolId }
|
|
3948
|
+
[documentId]: { ...docState, activeToolId: toolId, activeToolContext: context }
|
|
3949
3949
|
}
|
|
3950
3950
|
};
|
|
3951
3951
|
}
|
|
@@ -4288,7 +4288,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
4288
4288
|
return {
|
|
4289
4289
|
// Active document operations
|
|
4290
4290
|
getActiveTool: () => this.getActiveTool(),
|
|
4291
|
-
setActiveTool: (toolId) => this.setActiveTool(toolId),
|
|
4291
|
+
setActiveTool: (toolId, context) => this.setActiveTool(toolId, void 0, context),
|
|
4292
4292
|
getState: () => this.getDocumentState(),
|
|
4293
4293
|
getPageAnnotations: (options) => this.getPageAnnotations(options),
|
|
4294
4294
|
getSelectedAnnotation: () => this.getSelectedAnnotation(),
|
|
@@ -4372,7 +4372,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
4372
4372
|
setSelection: (ids) => this.setSelectionMethod(ids, documentId),
|
|
4373
4373
|
deselectAnnotation: () => this.deselectAnnotation(documentId),
|
|
4374
4374
|
getActiveTool: () => this.getActiveTool(documentId),
|
|
4375
|
-
setActiveTool: (toolId) => this.setActiveTool(toolId, documentId),
|
|
4375
|
+
setActiveTool: (toolId, context) => this.setActiveTool(toolId, documentId, context),
|
|
4376
4376
|
findToolForAnnotation: (anno) => this.findToolForAnnotation(anno),
|
|
4377
4377
|
importAnnotations: (items) => this.importAnnotations(items, documentId),
|
|
4378
4378
|
createAnnotation: (pageIndex, anno, ctx) => this.createAnnotation(pageIndex, anno, ctx, documentId),
|
|
@@ -4461,7 +4461,6 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
4461
4461
|
pageRotation: effectivePageRotation,
|
|
4462
4462
|
scale,
|
|
4463
4463
|
services: callbacks.services,
|
|
4464
|
-
// Pass through services
|
|
4465
4464
|
onPreview: (state) => callbacks.onPreview(tool.id, state),
|
|
4466
4465
|
onCommit: (annotation, ctx) => {
|
|
4467
4466
|
var _a2, _b2, _c;
|
|
@@ -4474,7 +4473,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
4474
4473
|
this.selectAnnotation(pageIndex, annotation.id, documentId);
|
|
4475
4474
|
}
|
|
4476
4475
|
},
|
|
4477
|
-
getTool: () => this.state.tools.find((t) => t.id === tool.id)
|
|
4476
|
+
getTool: () => this.state.tools.find((t) => t.id === tool.id),
|
|
4477
|
+
getToolContext: () => {
|
|
4478
|
+
var _a2;
|
|
4479
|
+
return (_a2 = this.state.documents[documentId]) == null ? void 0 : _a2.activeToolContext;
|
|
4480
|
+
}
|
|
4478
4481
|
};
|
|
4479
4482
|
const unregister = this.interactionManager.registerHandlers({
|
|
4480
4483
|
documentId,
|
|
@@ -5865,7 +5868,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
5865
5868
|
if (!docState.activeToolId) return null;
|
|
5866
5869
|
return this.state.tools.find((t) => t.id === docState.activeToolId) ?? null;
|
|
5867
5870
|
}
|
|
5868
|
-
setActiveTool(toolId, documentId) {
|
|
5871
|
+
setActiveTool(toolId, documentId, context) {
|
|
5869
5872
|
var _a, _b;
|
|
5870
5873
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
5871
5874
|
if (toolId !== null && !this.checkPermission(docId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
@@ -5877,8 +5880,8 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
5877
5880
|
return;
|
|
5878
5881
|
}
|
|
5879
5882
|
const docState = this.getDocumentState(docId);
|
|
5880
|
-
if (toolId === docState.activeToolId) return;
|
|
5881
|
-
this.dispatch(setActiveToolId(docId, toolId));
|
|
5883
|
+
if (toolId === docState.activeToolId && !context) return;
|
|
5884
|
+
this.dispatch(setActiveToolId(docId, toolId, context));
|
|
5882
5885
|
const tool = this.state.tools.find((t) => t.id === toolId);
|
|
5883
5886
|
if (tool) {
|
|
5884
5887
|
(_a = this.interactionManager) == null ? void 0 : _a.forDocument(docId).activate(tool.interaction.mode ?? tool.id);
|
|
@@ -6228,8 +6231,10 @@ export {
|
|
|
6228
6231
|
AnnotationPlugin,
|
|
6229
6232
|
AnnotationPluginPackage,
|
|
6230
6233
|
LockModeType,
|
|
6234
|
+
applyInsertUpright,
|
|
6231
6235
|
calculateRotatedRectAABB2 as calculateRotatedRectAABB,
|
|
6232
6236
|
calculateRotatedRectAABBAroundPoint2 as calculateRotatedRectAABBAroundPoint,
|
|
6237
|
+
clampAnnotationToPage,
|
|
6233
6238
|
convertAABBRectToUnrotatedSpace,
|
|
6234
6239
|
createToolPredicate,
|
|
6235
6240
|
defineAnnotationTool,
|