@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/vue/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ref, toValue, watch, computed, defineComponent, shallowRef, toRaw, useSlots, createElementBlock, openBlock, createElementVNode, createBlock, createCommentVNode, mergeProps, unref, renderSlot, Fragment, renderList, withCtx, resolveDynamicComponent, normalizeStyle, onMounted, toDisplayString, onUnmounted, createVNode, watchEffect, normalizeProps, guardReactiveProps } from "vue";
2
- import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/vue";
2
+ import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/vue";
3
3
  import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isLine, isPolyline, isPolygon, isFreeText, isStamp, isUnderline, isStrikeout, isSquiggly, isHighlight } from "@embedpdf/plugin-annotation";
4
4
  export * from "@embedpdf/plugin-annotation";
5
5
  import { useInteractionHandles, useDoublePressProps, CounterRotate, deepToRaw } from "@embedpdf/utils/vue";
@@ -75,7 +75,20 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
75
75
  const VERTEX_SIZE = 12;
76
76
  const preview = shallowRef(toRaw(props.trackedAnnotation.object));
77
77
  const { provides: annotationCapability } = useAnnotationCapability();
78
+ const permissions = useDocumentPermissions(props.documentId);
78
79
  const gestureBaseRef = ref(null);
80
+ const effectiveIsDraggable = computed(
81
+ () => permissions.value.canModifyAnnotations && props.isDraggable
82
+ );
83
+ const effectiveIsResizable = computed(
84
+ () => permissions.value.canModifyAnnotations && props.isResizable
85
+ );
86
+ const guardedOnDoubleClick = props.onDoubleClick ? (e) => {
87
+ var _a;
88
+ if (permissions.value.canModifyAnnotations) {
89
+ (_a = props.onDoubleClick) == null ? void 0 : _a.call(props, e);
90
+ }
91
+ } : void 0;
79
92
  const annotationProvides = computed(
80
93
  () => annotationCapability.value ? annotationCapability.value.forDocument(props.documentId) : null
81
94
  );
@@ -181,7 +194,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
181
194
  },
182
195
  includeVertices: !!props.vertexConfig
183
196
  });
184
- const doubleProps = useDoublePressProps(props.onDoubleClick);
197
+ const doubleProps = useDoublePressProps(guardedOnDoubleClick);
185
198
  watch(
186
199
  () => props.trackedAnnotation.object,
187
200
  (newObject) => {
@@ -199,7 +212,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
199
212
  outlineOffset: props.isSelected ? `${props.outlineOffset}px` : "0px",
200
213
  pointerEvents: props.isSelected ? "auto" : "none",
201
214
  touchAction: "none",
202
- cursor: props.isSelected && props.isDraggable ? "move" : "default",
215
+ cursor: props.isSelected && effectiveIsDraggable.value ? "move" : "default",
203
216
  zIndex: props.zIndex
204
217
  }));
205
218
  const mergedContainerStyle = computed(() => ({
@@ -209,9 +222,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
209
222
  const slots = useSlots();
210
223
  return (_ctx, _cache) => {
211
224
  return openBlock(), createElementBlock("div", _hoisted_1$8, [
212
- createElementVNode("div", mergeProps({ ...unref(dragProps), ...unref(doubleProps) }, { style: mergedContainerStyle.value }), [
225
+ createElementVNode("div", mergeProps({ ...effectiveIsDraggable.value && __props.isSelected ? unref(dragProps) : {}, ...unref(doubleProps) }, { style: mergedContainerStyle.value }), [
213
226
  renderSlot(_ctx.$slots, "default", { annotation: currentObject.value }),
214
- __props.isSelected && __props.isResizable ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(resize), ({ key, style, ...handle }) => {
227
+ __props.isSelected && effectiveIsResizable.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(resize), ({ key, style, ...handle }) => {
215
228
  return openBlock(), createElementBlock(Fragment, { key }, [
216
229
  unref(slots)["resize-handle"] ? renderSlot(_ctx.$slots, "resize-handle", mergeProps({
217
230
  key: 0,
@@ -228,7 +241,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
228
241
  }), null, 16))
229
242
  ], 64);
230
243
  }), 128)) : createCommentVNode("", true),
231
- __props.isSelected && unref(vertices).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(vertices), ({ key, style, ...vertex }) => {
244
+ __props.isSelected && unref(permissions).canModifyAnnotations && unref(vertices).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(vertices), ({ key, style, ...vertex }) => {
232
245
  return openBlock(), createElementBlock(Fragment, { key }, [
233
246
  unref(slots)["vertex-handle"] ? renderSlot(_ctx.$slots, "vertex-handle", mergeProps({
234
247
  key: 0,