@embedpdf/plugin-annotation 2.3.0 → 2.4.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 +40 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +2 -1
- package/dist/lib/annotation-plugin.d.ts +1 -0
- package/dist/lib/helpers.d.ts +2 -1
- package/dist/lib/tools/types.d.ts +22 -10
- package/dist/lib/types.d.ts +13 -0
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +326 -50
- 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 +325 -49
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +6 -2
- package/dist/shared/components/annotation-layer.d.ts +4 -2
- package/dist/shared/components/annotations.d.ts +3 -1
- package/dist/shared/components/types.d.ts +43 -1
- package/dist/shared/context/index.d.ts +1 -0
- package/dist/shared/context/renderer-registry.d.ts +21 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared-preact/components/annotation-container.d.ts +6 -2
- package/dist/shared-preact/components/annotation-layer.d.ts +4 -2
- package/dist/shared-preact/components/annotations.d.ts +3 -1
- package/dist/shared-preact/components/types.d.ts +43 -1
- package/dist/shared-preact/context/index.d.ts +1 -0
- package/dist/shared-preact/context/renderer-registry.d.ts +21 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/annotation-container.d.ts +6 -2
- package/dist/shared-react/components/annotation-layer.d.ts +4 -2
- package/dist/shared-react/components/annotations.d.ts +3 -1
- package/dist/shared-react/components/types.d.ts +43 -1
- package/dist/shared-react/context/index.d.ts +1 -0
- package/dist/shared-react/context/renderer-registry.d.ts +21 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/svelte/components/AnnotationLayer.svelte.d.ts +3 -0
- package/dist/svelte/components/Annotations.svelte.d.ts +3 -0
- package/dist/svelte/components/RendererRegistryProvider.svelte.d.ts +7 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/context/index.d.ts +2 -0
- package/dist/svelte/context/renderer-registry.svelte.d.ts +20 -0
- package/dist/svelte/context/types.d.ts +33 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.js +412 -241
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-container.vue.d.ts +1 -1
- package/dist/vue/components/annotation-layer.vue.d.ts +3 -0
- package/dist/vue/components/annotations/free-text.vue.d.ts +1 -1
- package/dist/vue/components/annotations/stamp.vue.d.ts +1 -1
- package/dist/vue/components/annotations.vue.d.ts +94 -60
- package/dist/vue/components/group-selection-box.vue.d.ts +1 -1
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/components/preview-renderer.vue.d.ts +1 -1
- package/dist/vue/components/renderer-registry-provider.vue.d.ts +13 -0
- package/dist/vue/context/index.d.ts +2 -0
- package/dist/vue/context/renderer-registry.d.ts +26 -0
- package/dist/vue/context/types.d.ts +33 -0
- package/dist/vue/hooks/use-annotation.d.ts +5 -5
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.ts +3 -1
- package/dist/vue/index.js +245 -120
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -83,9 +83,9 @@ const commitPendingChanges = (documentId, committedUids) => ({
|
|
|
83
83
|
type: COMMIT_PENDING_CHANGES,
|
|
84
84
|
payload: { documentId, committedUids }
|
|
85
85
|
});
|
|
86
|
-
const purgeAnnotation = (documentId, uid) => ({
|
|
86
|
+
const purgeAnnotation = (documentId, pageIndex, uid) => ({
|
|
87
87
|
type: PURGE_ANNOTATION,
|
|
88
|
-
payload: { documentId, uid }
|
|
88
|
+
payload: { documentId, pageIndex, uid }
|
|
89
89
|
});
|
|
90
90
|
const addColorPreset = (c) => ({
|
|
91
91
|
type: ADD_COLOR_PRESET,
|
|
@@ -147,8 +147,11 @@ function isText(a) {
|
|
|
147
147
|
function isLink(a) {
|
|
148
148
|
return a.object.type === PdfAnnotationSubtype.LINK;
|
|
149
149
|
}
|
|
150
|
+
function isRedact(a) {
|
|
151
|
+
return a.object.type === PdfAnnotationSubtype.REDACT;
|
|
152
|
+
}
|
|
150
153
|
function isSidebarAnnotation(a) {
|
|
151
|
-
return isTextMarkup(a) || isInk(a) || isSquare(a) || isCircle(a) || isPolygon(a) || isLine(a) || isPolyline(a) || isFreeText(a) || isStamp(a);
|
|
154
|
+
return isTextMarkup(a) || isInk(a) || isSquare(a) || isCircle(a) || isPolygon(a) || isLine(a) || isPolyline(a) || isFreeText(a) || isStamp(a) || isRedact(a);
|
|
152
155
|
}
|
|
153
156
|
const getAnnotationsByPageIndex = (s, page) => (s.pages[page] ?? []).map((uid) => s.byUid[uid]);
|
|
154
157
|
const getAnnotations = (s) => {
|
|
@@ -926,15 +929,22 @@ const reducer = (state, action) => {
|
|
|
926
929
|
};
|
|
927
930
|
}
|
|
928
931
|
case PURGE_ANNOTATION: {
|
|
929
|
-
const { documentId, uid } = action.payload;
|
|
932
|
+
const { documentId, pageIndex, uid } = action.payload;
|
|
930
933
|
const docState = state.documents[documentId];
|
|
931
|
-
if (!docState) return state;
|
|
934
|
+
if (!docState || !docState.byUid[uid]) return state;
|
|
932
935
|
const { [uid]: _gone, ...rest } = docState.byUid;
|
|
933
936
|
return {
|
|
934
937
|
...state,
|
|
935
938
|
documents: {
|
|
936
939
|
...state.documents,
|
|
937
|
-
[documentId]: {
|
|
940
|
+
[documentId]: {
|
|
941
|
+
...docState,
|
|
942
|
+
pages: {
|
|
943
|
+
...docState.pages,
|
|
944
|
+
[pageIndex]: (docState.pages[pageIndex] ?? []).filter((u) => u !== uid)
|
|
945
|
+
},
|
|
946
|
+
byUid: rest
|
|
947
|
+
}
|
|
938
948
|
}
|
|
939
949
|
};
|
|
940
950
|
}
|
|
@@ -2645,6 +2655,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2645
2655
|
updateAnnotations: (patches) => this.updateAnnotationsMethod(patches),
|
|
2646
2656
|
deleteAnnotation: (pageIndex, id) => this.deleteAnnotation(pageIndex, id),
|
|
2647
2657
|
deleteAnnotations: (annotations, documentId) => this.deleteAnnotationsMethod(annotations, documentId),
|
|
2658
|
+
purgeAnnotation: (pageIndex, id, documentId) => this.purgeAnnotationMethod(pageIndex, id, documentId),
|
|
2648
2659
|
renderAnnotation: (options) => this.renderAnnotation(options),
|
|
2649
2660
|
commit: () => this.commit(),
|
|
2650
2661
|
// Attached links (IRT link children)
|
|
@@ -2704,6 +2715,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2704
2715
|
updateAnnotations: (patches) => this.updateAnnotationsMethod(patches, documentId),
|
|
2705
2716
|
deleteAnnotation: (pageIndex, id) => this.deleteAnnotation(pageIndex, id, documentId),
|
|
2706
2717
|
deleteAnnotations: (annotations) => this.deleteAnnotationsMethod(annotations, documentId),
|
|
2718
|
+
purgeAnnotation: (pageIndex, id) => this.purgeAnnotationMethod(pageIndex, id, documentId),
|
|
2707
2719
|
renderAnnotation: (options) => this.renderAnnotation(options, documentId),
|
|
2708
2720
|
commit: () => this.commit(documentId),
|
|
2709
2721
|
getAttachedLinks: (id) => this.getAttachedLinksMethod(id, documentId),
|
|
@@ -2946,7 +2958,8 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2946
2958
|
pageIndex,
|
|
2947
2959
|
committed: false
|
|
2948
2960
|
});
|
|
2949
|
-
}
|
|
2961
|
+
},
|
|
2962
|
+
metadata: { annotationIds: [id] }
|
|
2950
2963
|
};
|
|
2951
2964
|
const historyScope = this.history.forDocument(docId);
|
|
2952
2965
|
historyScope.register(command, this.ANNOTATION_HISTORY_TOPIC);
|
|
@@ -3007,7 +3020,8 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3007
3020
|
patch: originalPatch,
|
|
3008
3021
|
committed: false
|
|
3009
3022
|
});
|
|
3010
|
-
}
|
|
3023
|
+
},
|
|
3024
|
+
metadata: { annotationIds: [id] }
|
|
3011
3025
|
};
|
|
3012
3026
|
const historyScope = this.history.forDocument(docId);
|
|
3013
3027
|
historyScope.register(command, this.ANNOTATION_HISTORY_TOPIC);
|
|
@@ -3082,7 +3096,8 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3082
3096
|
committed: false
|
|
3083
3097
|
});
|
|
3084
3098
|
}
|
|
3085
|
-
}
|
|
3099
|
+
},
|
|
3100
|
+
metadata: { annotationIds: [id, ...irtChildren.map((c) => c.id)] }
|
|
3086
3101
|
};
|
|
3087
3102
|
const historyScope = this.history.forDocument(docId);
|
|
3088
3103
|
historyScope.register(command, this.ANNOTATION_HISTORY_TOPIC);
|
|
@@ -3092,6 +3107,10 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3092
3107
|
this.deleteAnnotation(pageIndex, id, documentId);
|
|
3093
3108
|
}
|
|
3094
3109
|
}
|
|
3110
|
+
purgeAnnotationMethod(pageIndex, id, documentId) {
|
|
3111
|
+
const docId = documentId ?? this.getActiveDocumentId();
|
|
3112
|
+
this.dispatch(purgeAnnotation(docId, pageIndex, id));
|
|
3113
|
+
}
|
|
3095
3114
|
selectAnnotation(pageIndex, id, documentId) {
|
|
3096
3115
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
3097
3116
|
if (this.isInGroupMethod(id, docId)) {
|
|
@@ -3764,7 +3783,8 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3764
3783
|
committed: false
|
|
3765
3784
|
});
|
|
3766
3785
|
}
|
|
3767
|
-
}
|
|
3786
|
+
},
|
|
3787
|
+
metadata: { annotationIds: patchData.map((p) => p.id) }
|
|
3768
3788
|
};
|
|
3769
3789
|
const historyScope = this.history.forDocument(docId);
|
|
3770
3790
|
historyScope.register(command, this.ANNOTATION_HISTORY_TOPIC);
|
|
@@ -3877,7 +3897,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3877
3897
|
removeTask.wait(() => deleteTask.resolve(true), deleteTask.fail);
|
|
3878
3898
|
pendingOps.push({ type: "delete", task: deleteTask, ta, uid });
|
|
3879
3899
|
} else {
|
|
3880
|
-
this.dispatch(purgeAnnotation(docId, uid));
|
|
3900
|
+
this.dispatch(purgeAnnotation(docId, ta.object.pageIndex, uid));
|
|
3881
3901
|
}
|
|
3882
3902
|
}
|
|
3883
3903
|
const allTasks = pendingOps.map((op) => op.task);
|
|
@@ -3921,7 +3941,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
3921
3941
|
});
|
|
3922
3942
|
break;
|
|
3923
3943
|
case "delete":
|
|
3924
|
-
this.dispatch(purgeAnnotation(docId, op.uid));
|
|
3944
|
+
this.dispatch(purgeAnnotation(docId, op.ta.object.pageIndex, op.uid));
|
|
3925
3945
|
this.events$.emit({
|
|
3926
3946
|
type: "delete",
|
|
3927
3947
|
documentId: docId,
|
|
@@ -4005,6 +4025,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
4005
4025
|
};
|
|
4006
4026
|
_AnnotationPlugin.id = "annotation";
|
|
4007
4027
|
let AnnotationPlugin = _AnnotationPlugin;
|
|
4028
|
+
function resolveInteractionProp(prop, annotation, defaultValue) {
|
|
4029
|
+
if (prop === void 0) return defaultValue;
|
|
4030
|
+
if (typeof prop === "function") return prop(annotation);
|
|
4031
|
+
return prop;
|
|
4032
|
+
}
|
|
4008
4033
|
function createToolPredicate(id) {
|
|
4009
4034
|
return (tool) => {
|
|
4010
4035
|
return (tool == null ? void 0 : tool.id) === id;
|
|
@@ -4074,6 +4099,7 @@ export {
|
|
|
4074
4099
|
isPolygonTool,
|
|
4075
4100
|
isPolyline,
|
|
4076
4101
|
isPolylineTool,
|
|
4102
|
+
isRedact,
|
|
4077
4103
|
isSidebarAnnotation,
|
|
4078
4104
|
isSquare,
|
|
4079
4105
|
isSquareTool,
|
|
@@ -4089,6 +4115,7 @@ export {
|
|
|
4089
4115
|
isUnderlineTool,
|
|
4090
4116
|
manifest,
|
|
4091
4117
|
index as patching,
|
|
4092
|
-
rectsIntersect
|
|
4118
|
+
rectsIntersect,
|
|
4119
|
+
resolveInteractionProp
|
|
4093
4120
|
};
|
|
4094
4121
|
//# sourceMappingURL=index.js.map
|