@embedpdf/plugin-annotation 2.9.0 → 2.9.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 +15 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/tools/default-tools.d.ts +5 -1
- package/dist/lib/tools/types.d.ts +2 -0
- package/dist/lib/types.d.ts +3 -0
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +21 -5
- 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 +21 -5
- 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 +21 -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 +32 -16
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/vue/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createPluginPackage } from "@embedpdf/core";
|
|
2
2
|
import { AnnotationPlugin, initialDocumentState, inferRotationCenterFromRects, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, resolveInteractionProp, getAnnotationsByPageIndex, getSelectedAnnotationIds, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
|
-
import { defineComponent, ref, watchEffect, openBlock, createElementBlock, normalizeStyle, createCommentVNode, toValue, watch, computed, shallowRef, toRaw, useSlots, createElementVNode, renderSlot, createBlock, Fragment, unref, normalizeProps, mergeProps, renderList, withCtx, resolveDynamicComponent, Teleport, toDisplayString, markRaw, provide, inject, onUnmounted, onMounted, createVNode, createSlots, guardReactiveProps } from "vue";
|
|
4
|
+
import { defineComponent, ref, watchEffect, openBlock, createElementBlock, normalizeStyle, createCommentVNode, toValue, watch, computed, shallowRef, toRaw, useSlots, createElementVNode, renderSlot, createBlock, Fragment, unref, normalizeProps, mergeProps, renderList, withCtx, resolveDynamicComponent, Teleport, toDisplayString, markRaw, provide, inject, onUnmounted, onMounted, nextTick, createVNode, createSlots, guardReactiveProps } from "vue";
|
|
5
5
|
import { getCounterRotation } from "@embedpdf/utils";
|
|
6
6
|
import { useInteractionHandles, useDoublePressProps, CounterRotate, deepToRaw } from "@embedpdf/utils/vue";
|
|
7
7
|
import { useCapability, usePlugin, useDocumentPermissions, useDocumentState } from "@embedpdf/core/vue";
|
|
@@ -534,7 +534,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
534
534
|
height: `${innerHeight.value}px`,
|
|
535
535
|
transform: annotationRotation.value !== 0 ? `rotate(${annotationRotation.value}deg)` : void 0,
|
|
536
536
|
transformOrigin: innerTransformOrigin.value,
|
|
537
|
-
pointerEvents: "none"
|
|
537
|
+
pointerEvents: props.isEditing ? "auto" : "none"
|
|
538
538
|
}));
|
|
539
539
|
const innerRotatedStyle = computed(() => ({
|
|
540
540
|
position: "absolute",
|
|
@@ -546,7 +546,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
546
546
|
transformOrigin: innerTransformOrigin.value,
|
|
547
547
|
outline: showOutline.value ? `${outlineWidth.value}px ${outlineStyle.value} ${outlineColor.value}` : "none",
|
|
548
548
|
outlineOffset: showOutline.value ? `${outlineOff.value}px` : "0px",
|
|
549
|
-
pointerEvents: props.isSelected && !props.isMultiSelected ? "auto" : "none",
|
|
549
|
+
pointerEvents: props.isSelected && !props.isMultiSelected && !props.isEditing ? "auto" : "none",
|
|
550
550
|
touchAction: "none",
|
|
551
551
|
cursor: props.isSelected && effectiveIsDraggable.value ? "move" : "default"
|
|
552
552
|
}));
|
|
@@ -2498,28 +2498,35 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2498
2498
|
});
|
|
2499
2499
|
watch(
|
|
2500
2500
|
() => props.isEditing,
|
|
2501
|
-
(editing) => {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2501
|
+
async (editing) => {
|
|
2502
|
+
var _a, _b;
|
|
2503
|
+
if (!editing) return;
|
|
2504
|
+
await nextTick();
|
|
2505
|
+
if (!editorRef.value) return;
|
|
2506
|
+
editingRef.value = true;
|
|
2507
|
+
const editor = editorRef.value;
|
|
2508
|
+
editor.focus();
|
|
2509
|
+
const tool = (_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(props.annotation.object);
|
|
2510
|
+
const isDefaultContent = ((_b = tool == null ? void 0 : tool.defaults) == null ? void 0 : _b.contents) != null && props.annotation.object.contents === tool.defaults.contents;
|
|
2511
|
+
const selection = window.getSelection();
|
|
2512
|
+
if (selection) {
|
|
2513
|
+
const range = document.createRange();
|
|
2514
|
+
range.selectNodeContents(editor);
|
|
2515
|
+
if (!isDefaultContent) {
|
|
2510
2516
|
range.collapse(false);
|
|
2511
|
-
selection.removeAllRanges();
|
|
2512
|
-
selection.addRange(range);
|
|
2513
2517
|
}
|
|
2518
|
+
selection.removeAllRanges();
|
|
2519
|
+
selection.addRange(range);
|
|
2514
2520
|
}
|
|
2515
|
-
}
|
|
2521
|
+
},
|
|
2522
|
+
{ immediate: true }
|
|
2516
2523
|
);
|
|
2517
2524
|
const handleBlur = () => {
|
|
2518
2525
|
if (!editingRef.value) return;
|
|
2519
2526
|
editingRef.value = false;
|
|
2520
2527
|
if (!annotationProvides.value || !editorRef.value) return;
|
|
2521
2528
|
annotationProvides.value.updateAnnotation(props.pageIndex, props.annotation.object.id, {
|
|
2522
|
-
contents: editorRef.value.innerText
|
|
2529
|
+
contents: editorRef.value.innerText.replace(/\u00A0/g, " ")
|
|
2523
2530
|
});
|
|
2524
2531
|
};
|
|
2525
2532
|
const editorStyle = computed(() => {
|
|
@@ -3583,6 +3590,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3583
3590
|
syncState(provides.getState());
|
|
3584
3591
|
const off = provides.onStateChange(syncState);
|
|
3585
3592
|
onCleanup(off);
|
|
3593
|
+
const offEvent = provides.onAnnotationEvent((event) => {
|
|
3594
|
+
if (event.type === "create" && event.editAfterCreate) {
|
|
3595
|
+
editingId.value = event.annotation.id;
|
|
3596
|
+
}
|
|
3597
|
+
});
|
|
3598
|
+
onCleanup(offEvent);
|
|
3586
3599
|
},
|
|
3587
3600
|
{ immediate: true }
|
|
3588
3601
|
);
|
|
@@ -3688,6 +3701,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3688
3701
|
};
|
|
3689
3702
|
const handlePointerDown = (_pos, pe) => {
|
|
3690
3703
|
if (pe.target === pe.currentTarget && annotationProvides.value) {
|
|
3704
|
+
if (editingId.value && annotations.value.some((a) => a.object.id === editingId.value)) {
|
|
3705
|
+
pe.stopImmediatePropagation();
|
|
3706
|
+
}
|
|
3691
3707
|
annotationProvides.value.deselectAnnotation();
|
|
3692
3708
|
editingId.value = null;
|
|
3693
3709
|
}
|