@embedpdf/plugin-annotation 2.1.2 → 2.2.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 +37 -2
- package/dist/index.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +13 -6
- 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 +13 -6
- package/dist/react/index.js.map +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +10 -6
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +19 -6
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clamp, BasePlugin, createBehaviorEmitter } from "@embedpdf/core";
|
|
2
|
-
import { PdfAnnotationSubtype, PdfBlendMode, PdfAnnotationBorderStyle, PdfAnnotationLineEnding, PdfVerticalAlignment, PdfTextAlignment, PdfStandardFont, expandRect, rectFromPoints, uuidV4, rotateAndTranslatePoint, PdfAnnotationIcon, ignore, PdfTaskHelper, PdfErrorCode, Task } from "@embedpdf/models";
|
|
2
|
+
import { PdfAnnotationSubtype, PdfBlendMode, PdfAnnotationBorderStyle, PdfAnnotationLineEnding, PdfVerticalAlignment, PdfTextAlignment, PdfStandardFont, expandRect, rectFromPoints, uuidV4, rotateAndTranslatePoint, PdfAnnotationIcon, PdfPermissionFlag, ignore, PdfTaskHelper, PdfErrorCode, Task } from "@embedpdf/models";
|
|
3
3
|
const ANNOTATION_PLUGIN_ID = "annotation";
|
|
4
4
|
const manifest = {
|
|
5
5
|
id: ANNOTATION_PLUGIN_ID,
|
|
@@ -2320,6 +2320,9 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2320
2320
|
});
|
|
2321
2321
|
(_b = this.selection) == null ? void 0 : _b.onEndSelection(({ documentId }) => {
|
|
2322
2322
|
var _a2, _b2, _c;
|
|
2323
|
+
if (!this.checkPermission(documentId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2323
2326
|
const activeTool = this.getActiveTool(documentId);
|
|
2324
2327
|
if (!activeTool || !activeTool.interaction.textSelection) return;
|
|
2325
2328
|
const formattedSelection = (_a2 = this.selection) == null ? void 0 : _a2.getFormattedSelection();
|
|
@@ -2609,8 +2612,16 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2609
2612
|
if (this.config.autoCommit !== false) this.commit(documentId);
|
|
2610
2613
|
}
|
|
2611
2614
|
createAnnotation(pageIndex, annotation, ctx, documentId) {
|
|
2612
|
-
const id = annotation.id;
|
|
2613
2615
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
2616
|
+
if (!this.checkPermission(docId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
2617
|
+
this.logger.debug(
|
|
2618
|
+
"AnnotationPlugin",
|
|
2619
|
+
"CreateAnnotation",
|
|
2620
|
+
`Cannot create annotation: document ${docId} lacks ModifyAnnotations permission`
|
|
2621
|
+
);
|
|
2622
|
+
return;
|
|
2623
|
+
}
|
|
2624
|
+
const id = annotation.id;
|
|
2614
2625
|
const contexts = this.pendingContexts.get(docId);
|
|
2615
2626
|
if (!contexts) return;
|
|
2616
2627
|
const newAnnotation = {
|
|
@@ -2661,6 +2672,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2661
2672
|
}
|
|
2662
2673
|
updateAnnotation(pageIndex, id, patch, documentId) {
|
|
2663
2674
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
2675
|
+
if (!this.checkPermission(docId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
2676
|
+
this.logger.debug(
|
|
2677
|
+
"AnnotationPlugin",
|
|
2678
|
+
"UpdateAnnotation",
|
|
2679
|
+
`Cannot update annotation: document ${docId} lacks ModifyAnnotations permission`
|
|
2680
|
+
);
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2664
2683
|
const docState = this.getDocumentState(docId);
|
|
2665
2684
|
const originalObject = docState.byUid[id].object;
|
|
2666
2685
|
const finalPatch = this.buildPatch(originalObject, {
|
|
@@ -2708,6 +2727,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2708
2727
|
deleteAnnotation(pageIndex, id, documentId) {
|
|
2709
2728
|
var _a;
|
|
2710
2729
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
2730
|
+
if (!this.checkPermission(docId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
2731
|
+
this.logger.debug(
|
|
2732
|
+
"AnnotationPlugin",
|
|
2733
|
+
"DeleteAnnotation",
|
|
2734
|
+
`Cannot delete annotation: document ${docId} lacks ModifyAnnotations permission`
|
|
2735
|
+
);
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2711
2738
|
const docState = this.getDocumentState(docId);
|
|
2712
2739
|
const originalAnnotation = (_a = docState.byUid[id]) == null ? void 0 : _a.object;
|
|
2713
2740
|
if (!originalAnnotation) return;
|
|
@@ -2759,6 +2786,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
|
|
|
2759
2786
|
setActiveTool(toolId, documentId) {
|
|
2760
2787
|
var _a, _b;
|
|
2761
2788
|
const docId = documentId ?? this.getActiveDocumentId();
|
|
2789
|
+
if (toolId !== null && !this.checkPermission(docId, PdfPermissionFlag.ModifyAnnotations)) {
|
|
2790
|
+
this.logger.debug(
|
|
2791
|
+
"AnnotationPlugin",
|
|
2792
|
+
"SetActiveTool",
|
|
2793
|
+
`Cannot activate tool: document ${docId} lacks ModifyAnnotations permission`
|
|
2794
|
+
);
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2762
2797
|
const docState = this.getDocumentState(docId);
|
|
2763
2798
|
if (toolId === docState.activeToolId) return;
|
|
2764
2799
|
this.dispatch(setActiveToolId(docId, toolId));
|