@embedpdf/plugin-annotation 2.11.1 → 2.12.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.
@@ -210,7 +210,7 @@ var root_7 = $.from_html(`<div style="display: contents;"><!> <div><svg viewBox=
210
210
  var root_12 = $.from_html(`<div></div>`);
211
211
  var root_16 = $.from_html(`<div></div>`);
212
212
  var root_23 = $.from_html(`<div><div> </div></div>`);
213
- var root$h = $.from_html(`<div data-no-interaction=""><div><div><!> <!></div></div> <div><!> <!> <div><!> <!></div></div> <!> <!></div>`);
213
+ var root$i = $.from_html(`<div data-no-interaction=""><div><div><!> <!></div></div> <div><!> <!> <div><!> <!></div></div> <!> <!></div>`);
214
214
  function AnnotationContainer($$anchor, $$props) {
215
215
  $.push($$props, true);
216
216
  let isEditing = $.prop($$props, "isEditing", 3, false), isMultiSelected = $.prop($$props, "isMultiSelected", 3, false), isRotatable = $.prop($$props, "isRotatable", 3, true), lockAspectRatio = $.prop($$props, "lockAspectRatio", 3, false), propsClass = $.prop($$props, "class", 3, ""), outlineOffset = $.prop($$props, "outlineOffset", 3, 1), zIndex = $.prop($$props, "zIndex", 3, 1), restProps = $.rest_props($$props, [
@@ -569,7 +569,7 @@ function AnnotationContainer($$anchor, $$props) {
569
569
  }
570
570
  };
571
571
  }
572
- var div = root$h();
572
+ var div = root$i();
573
573
  var div_1 = $.child(div);
574
574
  let styles;
575
575
  var div_2 = $.child(div_1);
@@ -1735,7 +1735,7 @@ function GroupSelectionBox($$anchor, $$props) {
1735
1735
  $.pop();
1736
1736
  }
1737
1737
  $.delegate(["pointermove"]);
1738
- var root$g = $.from_html(`<div role="link" tabindex="-1"></div>`);
1738
+ var root$h = $.from_html(`<div role="link" tabindex="-1"></div>`);
1739
1739
  function LinkLockedMode($$anchor, $$props) {
1740
1740
  $.push($$props, true);
1741
1741
  const { provides } = useAnnotationCapability();
@@ -1744,7 +1744,7 @@ function LinkLockedMode($$anchor, $$props) {
1744
1744
  if (!target || !provides) return;
1745
1745
  provides.forDocument($$props.documentId).navigateTarget(target);
1746
1746
  }
1747
- var div = root$g();
1747
+ var div = root$h();
1748
1748
  div.__click = handleClick;
1749
1749
  div.__keydown = (e) => {
1750
1750
  if (e.key === "Enter") handleClick();
@@ -1759,10 +1759,10 @@ function LinkLockedMode($$anchor, $$props) {
1759
1759
  $.pop();
1760
1760
  }
1761
1761
  $.delegate(["click", "keydown"]);
1762
- var root$f = $.from_html(`<div></div>`);
1762
+ var root$g = $.from_html(`<div></div>`);
1763
1763
  function LinkPreview($$anchor, $$props) {
1764
1764
  $.push($$props, true);
1765
- var div = root$f();
1765
+ var div = root$g();
1766
1766
  let styles;
1767
1767
  $.template_effect(() => styles = $.set_style(div, "", styles, {
1768
1768
  position: "absolute",
@@ -1779,7 +1779,7 @@ function LinkPreview($$anchor, $$props) {
1779
1779
  }
1780
1780
  var root_1$d = $.from_svg(`<path fill="none" stroke="transparent"></path>`);
1781
1781
  var root_3$3 = $.from_svg(`<path fill="none"></path>`);
1782
- var root$e = $.from_svg(`<svg><!><!></svg>`);
1782
+ var root$f = $.from_svg(`<svg><!><!></svg>`);
1783
1783
  function Ink($$anchor, $$props) {
1784
1784
  $.push($$props, true);
1785
1785
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -1798,7 +1798,7 @@ function Ink($$anchor, $$props) {
1798
1798
  const width = $.derived(() => $$props.rect.size.width * $$props.scale);
1799
1799
  const height = $.derived(() => $$props.rect.size.height * $$props.scale);
1800
1800
  const hitStrokeWidth = $.derived(() => Math.max($$props.strokeWidth, MIN_HIT_AREA_SCREEN_PX / $$props.scale));
1801
- var svg = root$e();
1801
+ var svg = root$f();
1802
1802
  let styles;
1803
1803
  var node = $.child(svg);
1804
1804
  $.each(node, 19, () => $.get(paths), (d, i) => `hit-${i}`, ($$anchor2, d) => {
@@ -1873,7 +1873,7 @@ var root_1$c = $.from_svg(`<path fill="transparent" stroke="transparent"></path>
1873
1873
  var root_2$9 = $.from_svg(`<rect fill="transparent" stroke="transparent"></rect>`);
1874
1874
  var root_4$5 = $.from_svg(`<path stroke-linejoin="round"></path>`);
1875
1875
  var root_5$4 = $.from_svg(`<rect></rect>`);
1876
- var root$d = $.from_svg(`<svg overflow="visible"><!><!></svg>`);
1876
+ var root$e = $.from_svg(`<svg overflow="visible"><!><!></svg>`);
1877
1877
  function Square($$anchor, $$props) {
1878
1878
  $.push($$props, true);
1879
1879
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -1912,7 +1912,7 @@ function Square($$anchor, $$props) {
1912
1912
  var _a;
1913
1913
  return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
1914
1914
  });
1915
- var svg = root$d();
1915
+ var svg = root$e();
1916
1916
  let styles;
1917
1917
  var node = $.child(svg);
1918
1918
  {
@@ -2038,7 +2038,7 @@ var root_1$b = $.from_svg(`<path fill="transparent" stroke="transparent"></path>
2038
2038
  var root_2$8 = $.from_svg(`<ellipse fill="transparent" stroke="transparent"></ellipse>`);
2039
2039
  var root_4$4 = $.from_svg(`<path stroke-linejoin="round"></path>`);
2040
2040
  var root_5$3 = $.from_svg(`<ellipse></ellipse>`);
2041
- var root$c = $.from_svg(`<svg overflow="visible"><!><!></svg>`);
2041
+ var root$d = $.from_svg(`<svg overflow="visible"><!><!></svg>`);
2042
2042
  function Circle($$anchor, $$props) {
2043
2043
  $.push($$props, true);
2044
2044
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -2076,7 +2076,7 @@ function Circle($$anchor, $$props) {
2076
2076
  let svgHeight = $.derived(() => $.get(height) * $$props.scale);
2077
2077
  let hitStrokeWidth = $.derived(() => Math.max($$props.strokeWidth, MIN_HIT_AREA_SCREEN_PX / $$props.scale));
2078
2078
  let peValue = $.derived(() => !$$props.onClick ? "none" : $$props.isSelected ? "none" : color() === "transparent" ? "visibleStroke" : "visible");
2079
- var svg = root$c();
2079
+ var svg = root$d();
2080
2080
  let styles;
2081
2081
  var node = $.child(svg);
2082
2082
  {
@@ -2208,7 +2208,7 @@ var root_2$7 = $.from_svg(`<path fill="transparent" stroke="transparent"></path>
2208
2208
  var root_4$3 = $.from_svg(`<path></path>`);
2209
2209
  var root_5$2 = $.from_svg(`<path></path>`);
2210
2210
  var root_3$2 = $.from_svg(`<line></line><!><!>`, 1);
2211
- var root$b = $.from_svg(`<svg><line stroke="transparent"></line><!><!><!></svg>`);
2211
+ var root$c = $.from_svg(`<svg><line stroke="transparent"></line><!><!><!></svg>`);
2212
2212
  function Line($$anchor, $$props) {
2213
2213
  $.push($$props, true);
2214
2214
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -2232,7 +2232,7 @@ function Line($$anchor, $$props) {
2232
2232
  var _a;
2233
2233
  return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
2234
2234
  });
2235
- var svg = root$b();
2235
+ var svg = root$c();
2236
2236
  let styles;
2237
2237
  var line = $.child(svg);
2238
2238
  line.__pointerdown = function(...$$args) {
@@ -2399,7 +2399,7 @@ var root_2$6 = $.from_svg(`<path fill="transparent" stroke="transparent"></path>
2399
2399
  var root_4$2 = $.from_svg(`<path></path>`);
2400
2400
  var root_5$1 = $.from_svg(`<path></path>`);
2401
2401
  var root_3$1 = $.from_svg(`<path></path><!><!>`, 1);
2402
- var root$a = $.from_svg(`<svg><path fill="none" stroke="transparent"></path><!><!><!></svg>`);
2402
+ var root$b = $.from_svg(`<svg><path fill="none" stroke="transparent"></path><!><!><!></svg>`);
2403
2403
  function Polyline($$anchor, $$props) {
2404
2404
  $.push($$props, true);
2405
2405
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -2427,7 +2427,7 @@ function Polyline($$anchor, $$props) {
2427
2427
  var _a;
2428
2428
  return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
2429
2429
  });
2430
- var svg = root$a();
2430
+ var svg = root$b();
2431
2431
  let styles;
2432
2432
  var path = $.child(svg);
2433
2433
  path.__pointerdown = function(...$$args) {
@@ -2590,7 +2590,7 @@ var root_2$5 = $.from_svg(`<path></path>`);
2590
2590
  var root_4$1 = $.from_svg(`<path fill="none"></path>`);
2591
2591
  var root_5 = $.from_svg(`<rect></rect>`);
2592
2592
  var root_3 = $.from_svg(`<path></path><!><!>`, 1);
2593
- var root$9 = $.from_svg(`<svg><path fill="transparent" stroke="transparent"></path><!></svg>`);
2593
+ var root$a = $.from_svg(`<svg><path fill="transparent" stroke="transparent"></path><!></svg>`);
2594
2594
  function Polygon($$anchor, $$props) {
2595
2595
  $.push($$props, true);
2596
2596
  const MIN_HIT_AREA_SCREEN_PX = 20;
@@ -2616,7 +2616,7 @@ function Polygon($$anchor, $$props) {
2616
2616
  var _a;
2617
2617
  return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
2618
2618
  });
2619
- var svg = root$9();
2619
+ var svg = root$a();
2620
2620
  let styles;
2621
2621
  var path = $.child(svg);
2622
2622
  path.__pointerdown = function(...$$args) {
@@ -2748,10 +2748,10 @@ function PolygonPreview($$anchor, $$props) {
2748
2748
  () => $$props.data
2749
2749
  ));
2750
2750
  }
2751
- var root$8 = $.from_html(`<div></div>`);
2751
+ var root$9 = $.from_html(`<div></div>`);
2752
2752
  function FreeTextPreview($$anchor, $$props) {
2753
2753
  $.push($$props, true);
2754
- var div = root$8();
2754
+ var div = root$9();
2755
2755
  let styles;
2756
2756
  $.template_effect(() => styles = $.set_style(div, "", styles, {
2757
2757
  width: "100%",
@@ -2762,6 +2762,26 @@ function FreeTextPreview($$anchor, $$props) {
2762
2762
  $.append($$anchor, div);
2763
2763
  $.pop();
2764
2764
  }
2765
+ var root$8 = $.from_html(`<img alt=""/>`);
2766
+ function StampPreview($$anchor, $$props) {
2767
+ $.push($$props, true);
2768
+ const rotationDeg = $.derived(() => (4 - $$props.data.pageRotation) % 4 * 90);
2769
+ var img = root$8();
2770
+ let styles;
2771
+ $.template_effect(() => {
2772
+ $.set_attribute(img, "src", $$props.data.ghostUrl);
2773
+ styles = $.set_style(img, "", styles, {
2774
+ width: "100%",
2775
+ height: "100%",
2776
+ opacity: "0.6",
2777
+ "object-fit": "contain",
2778
+ "pointer-events": "none",
2779
+ transform: $.get(rotationDeg) ? `rotate(${$.get(rotationDeg)}deg)` : void 0
2780
+ });
2781
+ });
2782
+ $.append($$anchor, img);
2783
+ $.pop();
2784
+ }
2765
2785
  function InkRenderer($$anchor, $$props) {
2766
2786
  Ink($$anchor, $.spread_props(() => $$props.currentObject, {
2767
2787
  get isSelected() {
@@ -3798,7 +3818,9 @@ const builtInRenderers = [
3798
3818
  createRenderer({
3799
3819
  id: "stamp",
3800
3820
  matches: (a) => a.type === PdfAnnotationSubtype.STAMP,
3821
+ matchesPreview: (p) => p.type === PdfAnnotationSubtype.STAMP,
3801
3822
  component: StampRenderer,
3823
+ renderPreview: StampPreview,
3802
3824
  useAppearanceStream: false,
3803
3825
  interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
3804
3826
  }),
@@ -3834,7 +3856,10 @@ function Annotations($$anchor, $$props) {
3834
3856
  let annotationsProps = $.rest_props($$props, ["$$slots", "$$events", "$$legacy"]);
3835
3857
  const annotationCapability = useAnnotationCapability();
3836
3858
  const selectionCapability = useSelectionCapability();
3837
- const pointerHandlers = usePointerHandlers({ documentId: $$props.documentId, pageIndex: $$props.pageIndex });
3859
+ const pointerHandlers = usePointerHandlers({
3860
+ documentId: () => $$props.documentId,
3861
+ pageIndex: $$props.pageIndex
3862
+ });
3838
3863
  let annotations = $.state($.proxy([]));
3839
3864
  let allSelectedIds = $.state($.proxy([]));
3840
3865
  let editingId = $.state(null);
@@ -4542,13 +4567,12 @@ function PreviewRenderer($$anchor, $$props) {
4542
4567
  $.append($$anchor, fragment);
4543
4568
  $.pop();
4544
4569
  }
4545
- var root$1 = $.from_html(`<input type="file"/> <canvas></canvas> <!>`, 1);
4570
+ var root$1 = $.from_html(`<input type="file"/> <!>`, 1);
4546
4571
  function AnnotationPaintLayer($$anchor, $$props) {
4547
4572
  $.push($$props, true);
4548
4573
  const annotationPlugin = useAnnotationPlugin();
4549
4574
  let previews = $.state($.proxy(/* @__PURE__ */ new Map()));
4550
4575
  let fileInputRef = $.state(null);
4551
- let canvasRef = $.state(null);
4552
4576
  const services = {
4553
4577
  requestFile: ({ accept, onFile }) => {
4554
4578
  if (!$.get(fileInputRef)) return;
@@ -4563,29 +4587,6 @@ function AnnotationPaintLayer($$anchor, $$props) {
4563
4587
  }
4564
4588
  };
4565
4589
  input.click();
4566
- },
4567
- processImage: ({ source, maxWidth, maxHeight, onComplete }) => {
4568
- const canvas = $.get(canvasRef);
4569
- if (!canvas || !canvas.getContext) return;
4570
- const ctx = canvas.getContext("2d");
4571
- if (!ctx) return;
4572
- const img = new Image();
4573
- img.crossOrigin = "Anonymous";
4574
- img.onload = () => {
4575
- let { naturalWidth: width, naturalHeight: height } = img;
4576
- const scaleX = maxWidth ? maxWidth / width : 1;
4577
- const scaleY = maxHeight ? maxHeight / height : 1;
4578
- const scaleFactor = Math.min(scaleX, scaleY, 1);
4579
- const finalWidth = width * scaleFactor;
4580
- const finalHeight = height * scaleFactor;
4581
- canvas.width = finalWidth;
4582
- canvas.height = finalHeight;
4583
- ctx.drawImage(img, 0, 0, finalWidth, finalHeight);
4584
- const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);
4585
- if (typeof source !== "string") URL.revokeObjectURL(img.src);
4586
- onComplete({ imageData, width: finalWidth, height: finalHeight });
4587
- };
4588
- img.src = typeof source === "string" ? source : URL.createObjectURL(source);
4589
4590
  }
4590
4591
  };
4591
4592
  $.user_effect(() => {
@@ -4606,10 +4607,7 @@ function AnnotationPaintLayer($$anchor, $$props) {
4606
4607
  var input_1 = $.first_child(fragment);
4607
4608
  $.set_style(input_1, "", {}, { display: "none" });
4608
4609
  $.bind_this(input_1, ($$value) => $.set(fileInputRef, $$value), () => $.get(fileInputRef));
4609
- var canvas_1 = $.sibling(input_1, 2);
4610
- $.set_style(canvas_1, "", {}, { display: "none" });
4611
- $.bind_this(canvas_1, ($$value) => $.set(canvasRef, $$value), () => $.get(canvasRef));
4612
- var node = $.sibling(canvas_1, 2);
4610
+ var node = $.sibling(input_1, 2);
4613
4611
  $.each(node, 17, () => Array.from($.get(previews).entries()), ([toolId, preview]) => toolId, ($$anchor2, $$item) => {
4614
4612
  var $$array = $.derived(() => $.to_array($.get($$item), 2));
4615
4613
  let toolId = () => $.get($$array)[0];