@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.
@@ -734,7 +734,7 @@ function AnnotationContainer($$anchor, $$props) {
734
734
  "transform-origin": $.get(innerTransformOrigin),
735
735
  outline: $.get(showOutline) ? `${$.get(outlineWidth)}px ${$.get(outlineStyleVal)} ${$.get(outlineColor)}` : "none",
736
736
  "outline-offset": $.get(showOutline) ? `${$.get(outlineOff)}px` : "0px",
737
- "pointer-events": $$props.isSelected && !isMultiSelected() ? "auto" : "none",
737
+ "pointer-events": $$props.isSelected && !isMultiSelected() && !isEditing() ? "auto" : "none",
738
738
  "touch-action": "none",
739
739
  cursor: $$props.isSelected && $.get(effectiveIsDraggable) ? "move" : "default"
740
740
  }
@@ -978,7 +978,7 @@ function AnnotationContainer($$anchor, $$props) {
978
978
  height: `${$.get(innerHeight) ?? ""}px`,
979
979
  transform: $.get(annotationRotation) !== 0 ? `rotate(${$.get(annotationRotation)}deg)` : void 0,
980
980
  "transform-origin": $.get(innerTransformOrigin),
981
- "pointer-events": "none"
981
+ "pointer-events": isEditing() ? "auto" : "none"
982
982
  });
983
983
  });
984
984
  $.append($$anchor, div);
@@ -2677,15 +2677,19 @@ function FreeText($$anchor, $$props) {
2677
2677
  let isIOS = $.state(false);
2678
2678
  let editingRef = false;
2679
2679
  $.user_effect(() => {
2680
- var _a;
2680
+ var _a, _b, _c;
2681
2681
  if (!$$props.isEditing || !editorRef) return;
2682
2682
  editingRef = true;
2683
2683
  editorRef.focus();
2684
- const selection = (_a = window.getSelection) == null ? void 0 : _a.call(window);
2684
+ const tool = (_a = $.get(annotationProvides)) == null ? void 0 : _a.findToolForAnnotation($$props.annotation.object);
2685
+ const isDefaultContent = ((_b = tool == null ? void 0 : tool.defaults) == null ? void 0 : _b.contents) != null && $$props.annotation.object.contents === tool.defaults.contents;
2686
+ const selection = (_c = window.getSelection) == null ? void 0 : _c.call(window);
2685
2687
  if (!selection) return;
2686
2688
  const range = document.createRange();
2687
2689
  range.selectNodeContents(editorRef);
2688
- range.collapse(false);
2690
+ if (!isDefaultContent) {
2691
+ range.collapse(false);
2692
+ }
2689
2693
  selection.removeAllRanges();
2690
2694
  selection.addRange(range);
2691
2695
  });
@@ -2702,7 +2706,7 @@ function FreeText($$anchor, $$props) {
2702
2706
  if (!editingRef) return;
2703
2707
  editingRef = false;
2704
2708
  if (!$.get(annotationProvides) || !editorRef) return;
2705
- $.get(annotationProvides).updateAnnotation($$props.pageIndex, $$props.annotation.object.id, { contents: editorRef.innerText });
2709
+ $.get(annotationProvides).updateAnnotation($$props.pageIndex, $$props.annotation.object.id, { contents: editorRef.innerText.replace(/\u00A0/g, " ") });
2706
2710
  }
2707
2711
  const computedFontPx = $.derived(() => $$props.annotation.object.fontSize * $$props.scale);
2708
2712
  const MIN_IOS_FOCUS_FONT_PX = 16;
@@ -3670,6 +3674,14 @@ function Annotations($$anchor, $$props) {
3670
3674
  });
3671
3675
  return () => off == null ? void 0 : off();
3672
3676
  });
3677
+ $.user_effect(() => {
3678
+ if (!$.get(annotationProvides)) return;
3679
+ return $.get(annotationProvides).onAnnotationEvent((event) => {
3680
+ if (event.type === "create" && event.editAfterCreate) {
3681
+ $.set(editingId, event.annotation.id, true);
3682
+ }
3683
+ });
3684
+ });
3673
3685
  $.user_effect(() => {
3674
3686
  if (!$.get(annotationProvides)) return;
3675
3687
  if (prevScale !== $$props.scale) {
@@ -3685,6 +3697,9 @@ function Annotations($$anchor, $$props) {
3685
3697
  const handlers = {
3686
3698
  onPointerDown: (_, pe) => {
3687
3699
  if (pe.target === pe.currentTarget && $.get(annotationProvides)) {
3700
+ if ($.get(editingId) && $.get(annotations).some((a) => a.object.id === $.get(editingId))) {
3701
+ pe.stopImmediatePropagation();
3702
+ }
3688
3703
  $.get(annotationProvides).deselectAnnotation();
3689
3704
  $.set(editingId, null);
3690
3705
  }