@embedpdf/plugin-annotation 2.7.0 → 2.8.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.
Files changed (128) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +335 -82
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/annotation-plugin.d.ts +2 -0
  6. package/dist/lib/handlers/index.d.ts +4 -0
  7. package/dist/lib/handlers/insert-text.handler.d.ts +8 -0
  8. package/dist/lib/handlers/replace-text.handler.d.ts +9 -0
  9. package/dist/lib/handlers/selection-utils.d.ts +7 -0
  10. package/dist/lib/handlers/text-markup.handler.d.ts +7 -0
  11. package/dist/lib/handlers/text.handler.d.ts +3 -0
  12. package/dist/lib/handlers/types.d.ts +12 -0
  13. package/dist/lib/helpers.d.ts +2 -1
  14. package/dist/lib/selectors.d.ts +6 -1
  15. package/dist/lib/tools/default-tools.d.ts +151 -6
  16. package/dist/lib/tools/tools-utils.d.ts +2 -0
  17. package/dist/lib/tools/types.d.ts +2 -0
  18. package/dist/lib/types.d.ts +1 -0
  19. package/dist/preact/index.cjs +1 -1
  20. package/dist/preact/index.cjs.map +1 -1
  21. package/dist/preact/index.js +277 -43
  22. package/dist/preact/index.js.map +1 -1
  23. package/dist/react/index.cjs +1 -1
  24. package/dist/react/index.cjs.map +1 -1
  25. package/dist/react/index.js +277 -43
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/shared/annotation-bounds.d.ts +14 -0
  28. package/dist/shared/components/annotations/caret.d.ts +24 -0
  29. package/dist/shared/components/annotations/circle.d.ts +2 -2
  30. package/dist/shared/components/annotations/free-text.d.ts +2 -2
  31. package/dist/shared/components/annotations/ink.d.ts +2 -2
  32. package/dist/shared/components/annotations/line.d.ts +2 -2
  33. package/dist/shared/components/annotations/link.d.ts +2 -2
  34. package/dist/shared/components/annotations/polygon.d.ts +2 -2
  35. package/dist/shared/components/annotations/polyline.d.ts +8 -4
  36. package/dist/shared/components/annotations/square.d.ts +2 -2
  37. package/dist/shared/components/annotations/stamp.d.ts +2 -2
  38. package/dist/shared/components/annotations/text.d.ts +14 -0
  39. package/dist/shared/components/text-markup/highlight.d.ts +2 -2
  40. package/dist/shared/components/text-markup/squiggly.d.ts +2 -2
  41. package/dist/shared/components/text-markup/strikeout.d.ts +2 -2
  42. package/dist/shared/components/text-markup/underline.d.ts +2 -2
  43. package/dist/shared/components/types.d.ts +2 -2
  44. package/dist/shared-preact/annotation-bounds.d.ts +14 -0
  45. package/dist/shared-preact/components/annotations/caret.d.ts +24 -0
  46. package/dist/shared-preact/components/annotations/circle.d.ts +2 -2
  47. package/dist/shared-preact/components/annotations/free-text.d.ts +2 -2
  48. package/dist/shared-preact/components/annotations/ink.d.ts +2 -2
  49. package/dist/shared-preact/components/annotations/line.d.ts +2 -2
  50. package/dist/shared-preact/components/annotations/link.d.ts +2 -2
  51. package/dist/shared-preact/components/annotations/polygon.d.ts +2 -2
  52. package/dist/shared-preact/components/annotations/polyline.d.ts +8 -4
  53. package/dist/shared-preact/components/annotations/square.d.ts +2 -2
  54. package/dist/shared-preact/components/annotations/stamp.d.ts +2 -2
  55. package/dist/shared-preact/components/annotations/text.d.ts +14 -0
  56. package/dist/shared-preact/components/text-markup/highlight.d.ts +2 -2
  57. package/dist/shared-preact/components/text-markup/squiggly.d.ts +2 -2
  58. package/dist/shared-preact/components/text-markup/strikeout.d.ts +2 -2
  59. package/dist/shared-preact/components/text-markup/underline.d.ts +2 -2
  60. package/dist/shared-preact/components/types.d.ts +2 -2
  61. package/dist/shared-react/annotation-bounds.d.ts +14 -0
  62. package/dist/shared-react/components/annotations/caret.d.ts +24 -0
  63. package/dist/shared-react/components/annotations/circle.d.ts +2 -2
  64. package/dist/shared-react/components/annotations/free-text.d.ts +2 -2
  65. package/dist/shared-react/components/annotations/ink.d.ts +2 -2
  66. package/dist/shared-react/components/annotations/line.d.ts +2 -2
  67. package/dist/shared-react/components/annotations/link.d.ts +2 -2
  68. package/dist/shared-react/components/annotations/polygon.d.ts +2 -2
  69. package/dist/shared-react/components/annotations/polyline.d.ts +8 -4
  70. package/dist/shared-react/components/annotations/square.d.ts +2 -2
  71. package/dist/shared-react/components/annotations/stamp.d.ts +2 -2
  72. package/dist/shared-react/components/annotations/text.d.ts +14 -0
  73. package/dist/shared-react/components/text-markup/highlight.d.ts +2 -2
  74. package/dist/shared-react/components/text-markup/squiggly.d.ts +2 -2
  75. package/dist/shared-react/components/text-markup/strikeout.d.ts +2 -2
  76. package/dist/shared-react/components/text-markup/underline.d.ts +2 -2
  77. package/dist/shared-react/components/types.d.ts +2 -2
  78. package/dist/shared-vue/annotation-bounds.d.ts +14 -0
  79. package/dist/svelte/components/annotations/Caret.svelte.d.ts +13 -0
  80. package/dist/svelte/components/annotations/Circle.svelte.d.ts +1 -1
  81. package/dist/svelte/components/annotations/FreeText.svelte.d.ts +1 -1
  82. package/dist/svelte/components/annotations/Ink.svelte.d.ts +1 -1
  83. package/dist/svelte/components/annotations/Line.svelte.d.ts +1 -1
  84. package/dist/svelte/components/annotations/Link.svelte.d.ts +1 -1
  85. package/dist/svelte/components/annotations/Polygon.svelte.d.ts +1 -1
  86. package/dist/svelte/components/annotations/Polyline.svelte.d.ts +4 -2
  87. package/dist/svelte/components/annotations/Square.svelte.d.ts +1 -1
  88. package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
  89. package/dist/svelte/components/annotations/Text.svelte.d.ts +10 -0
  90. package/dist/svelte/components/annotations/index.d.ts +1 -0
  91. package/dist/svelte/components/renderers/CaretRenderer.svelte.d.ts +5 -0
  92. package/dist/svelte/components/renderers/TextRenderer.svelte.d.ts +5 -0
  93. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +1 -1
  94. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +1 -1
  95. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +1 -1
  96. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +1 -1
  97. package/dist/svelte/context/types.d.ts +1 -1
  98. package/dist/svelte/index.cjs +1 -1
  99. package/dist/svelte/index.cjs.map +1 -1
  100. package/dist/svelte/index.js +350 -147
  101. package/dist/svelte/index.js.map +1 -1
  102. package/dist/vue/components/annotation-container.vue.d.ts +2 -2
  103. package/dist/vue/components/annotation-layer.vue.d.ts +1 -1
  104. package/dist/vue/components/annotations/caret.vue.d.ts +24 -0
  105. package/dist/vue/components/annotations/circle.vue.d.ts +2 -2
  106. package/dist/vue/components/annotations/free-text.vue.d.ts +2 -2
  107. package/dist/vue/components/annotations/index.d.ts +1 -0
  108. package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
  109. package/dist/vue/components/annotations/line.vue.d.ts +2 -2
  110. package/dist/vue/components/annotations/link.vue.d.ts +2 -2
  111. package/dist/vue/components/annotations/polygon.vue.d.ts +2 -2
  112. package/dist/vue/components/annotations/polyline.vue.d.ts +8 -3
  113. package/dist/vue/components/annotations/square.vue.d.ts +2 -2
  114. package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
  115. package/dist/vue/components/annotations/text.vue.d.ts +14 -0
  116. package/dist/vue/components/annotations.vue.d.ts +1 -1
  117. package/dist/vue/components/renderers/caret-renderer.vue.d.ts +6 -0
  118. package/dist/vue/components/renderers/text-renderer.vue.d.ts +6 -0
  119. package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
  120. package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
  121. package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
  122. package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
  123. package/dist/vue/context/types.d.ts +1 -1
  124. package/dist/vue/index.cjs +1 -1
  125. package/dist/vue/index.cjs.map +1 -1
  126. package/dist/vue/index.js +535 -249
  127. package/dist/vue/index.js.map +1 -1
  128. package/package.json +10 -10
@@ -6,10 +6,11 @@ import { createContext, Fragment as Fragment$1 } from "preact";
6
6
  import { useState, useCallback, useContext, useRef, useEffect, useMemo, useLayoutEffect } from "preact/hooks";
7
7
  import { createPortal } from "preact/compat";
8
8
  import { useCapability, usePlugin, useDocumentPermissions, useDocumentState } from "@embedpdf/core/preact";
9
- import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
9
+ import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, getContrastStrokeColor, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
10
10
  import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
11
11
  import { useSelectionCapability } from "@embedpdf/plugin-selection/preact";
12
12
  import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/preact";
13
+ import { getCounterRotation } from "@embedpdf/utils";
13
14
  const suppressContentEditableWarningProps = {};
14
15
  const RegisterContext = createContext(null);
15
16
  const RenderersContext = createContext([]);
@@ -150,6 +151,11 @@ function AnnotationContainer({
150
151
  [annotationCapability, documentId]
151
152
  );
152
153
  const currentObject = preview ? { ...trackedAnnotation.object, ...preview } : trackedAnnotation.object;
154
+ const annoFlags = trackedAnnotation.object.flags ?? [];
155
+ const hasNoZoom = annoFlags.includes("noZoom");
156
+ const hasNoRotate = annoFlags.includes("noRotate");
157
+ const visualScale = hasNoZoom ? 1 : scale;
158
+ const effectivePageRotation = hasNoRotate ? 0 : rotation;
153
159
  const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
154
160
  const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
155
161
  const ROTATION_COLOR = (rotationUI == null ? void 0 : rotationUI.color) ?? "white";
@@ -342,17 +348,21 @@ function AnnotationContainer({
342
348
  return () => unsubs.forEach((u) => u());
343
349
  }, [plugin, documentId, trackedAnnotation.object]);
344
350
  const showOutline = isSelected && !isMultiSelected;
345
- const aabbWidth = currentObject.rect.size.width * scale;
346
- const aabbHeight = currentObject.rect.size.height * scale;
347
- const innerWidth = effectiveUnrotatedRect.size.width * scale;
348
- const innerHeight = effectiveUnrotatedRect.size.height * scale;
351
+ const aabbWidth = currentObject.rect.size.width * visualScale;
352
+ const aabbHeight = currentObject.rect.size.height * visualScale;
353
+ const innerWidth = effectiveUnrotatedRect.size.width * visualScale;
354
+ const innerHeight = effectiveUnrotatedRect.size.height * visualScale;
349
355
  const usesCustomPivot = Boolean(explicitUnrotatedRect) && annotationRotation !== 0;
350
- const innerLeft = usesCustomPivot ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * scale : (aabbWidth - innerWidth) / 2;
351
- const innerTop = usesCustomPivot ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * scale : (aabbHeight - innerHeight) / 2;
352
- const innerTransformOrigin = usesCustomPivot && rotationPivot ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * scale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * scale}px` : "center center";
353
- const centerX = rotationPivot ? (rotationPivot.x - currentObject.rect.origin.x) * scale : aabbWidth / 2;
354
- const centerY = rotationPivot ? (rotationPivot.y - currentObject.rect.origin.y) * scale : aabbHeight / 2;
356
+ const innerLeft = usesCustomPivot ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * visualScale : (aabbWidth - innerWidth) / 2;
357
+ const innerTop = usesCustomPivot ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * visualScale : (aabbHeight - innerHeight) / 2;
358
+ const innerTransformOrigin = usesCustomPivot && rotationPivot ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * visualScale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * visualScale}px` : "center center";
359
+ const centerX = rotationPivot ? (rotationPivot.x - currentObject.rect.origin.x) * visualScale : aabbWidth / 2;
360
+ const centerY = rotationPivot ? (rotationPivot.y - currentObject.rect.origin.y) * visualScale : aabbHeight / 2;
355
361
  const guideLength = Math.max(300, Math.max(aabbWidth, aabbHeight) + 80);
362
+ const counterRot = hasNoRotate ? getCounterRotation(
363
+ { origin: { x: 0, y: 0 }, size: { width: aabbWidth, height: aabbHeight } },
364
+ rotation
365
+ ) : null;
356
366
  const childObject = useMemo(() => {
357
367
  if (explicitUnrotatedRect) {
358
368
  return { ...currentObject, rect: explicitUnrotatedRect };
@@ -368,10 +378,15 @@ function AnnotationContainer({
368
378
  position: "absolute",
369
379
  left: currentObject.rect.origin.x * scale,
370
380
  top: currentObject.rect.origin.y * scale,
371
- width: aabbWidth,
372
- height: aabbHeight,
381
+ width: counterRot ? counterRot.width : aabbWidth,
382
+ height: counterRot ? counterRot.height : aabbHeight,
373
383
  pointerEvents: "none",
374
384
  zIndex,
385
+ // noRotate: apply counter-rotation matrix so the annotation stays upright
386
+ ...counterRot && {
387
+ transform: counterRot.matrix,
388
+ transformOrigin: "0 0"
389
+ },
375
390
  ...style
376
391
  },
377
392
  ...props,
@@ -600,13 +615,13 @@ function AnnotationContainer({
600
615
  y: currentObject.rect.origin.y * scale
601
616
  },
602
617
  size: {
603
- width: currentObject.rect.size.width * scale,
604
- height: currentObject.rect.size.height * scale
618
+ width: currentObject.rect.size.width * visualScale,
619
+ height: currentObject.rect.size.height * visualScale
605
620
  }
606
621
  },
607
622
  rotation,
608
623
  children: (counterRotateProps) => {
609
- const effectiveAngle = ((annotationRotation + rotation * 90) % 360 + 360) % 360;
624
+ const effectiveAngle = ((annotationRotation + effectivePageRotation * 90) % 360 + 360) % 360;
610
625
  const handleNearMenuSide = effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;
611
626
  return selectionMenu({
612
627
  ...counterRotateProps,
@@ -651,6 +666,57 @@ function AnnotationContainer({
651
666
  )
652
667
  ] });
653
668
  }
669
+ function mapCounterRotatePoint(x, y, width, height, rotation) {
670
+ switch (rotation) {
671
+ case 1:
672
+ return { x: y, y: height - x };
673
+ case 2:
674
+ return { x: width - x, y: height - y };
675
+ case 3:
676
+ return { x: width - y, y: x };
677
+ default:
678
+ return { x, y };
679
+ }
680
+ }
681
+ function getAnnotationScreenBounds(annotation, scale, rotation) {
682
+ const flags = annotation.object.flags ?? [];
683
+ const hasNoZoom = flags.includes("noZoom");
684
+ const hasNoRotate = flags.includes("noRotate");
685
+ const left = annotation.object.rect.origin.x * scale;
686
+ const top = annotation.object.rect.origin.y * scale;
687
+ const width = annotation.object.rect.size.width * (hasNoZoom ? 1 : scale);
688
+ const height = annotation.object.rect.size.height * (hasNoZoom ? 1 : scale);
689
+ if (!hasNoRotate || rotation === 0) {
690
+ return {
691
+ left,
692
+ top,
693
+ right: left + width,
694
+ bottom: top + height
695
+ };
696
+ }
697
+ const corners = [
698
+ mapCounterRotatePoint(0, 0, width, height, rotation),
699
+ mapCounterRotatePoint(width, 0, width, height, rotation),
700
+ mapCounterRotatePoint(0, height, width, height, rotation),
701
+ mapCounterRotatePoint(width, height, width, height, rotation)
702
+ ];
703
+ let minX = Infinity;
704
+ let minY = Infinity;
705
+ let maxX = -Infinity;
706
+ let maxY = -Infinity;
707
+ for (const corner of corners) {
708
+ if (corner.x < minX) minX = corner.x;
709
+ if (corner.y < minY) minY = corner.y;
710
+ if (corner.x > maxX) maxX = corner.x;
711
+ if (corner.y > maxY) maxY = corner.y;
712
+ }
713
+ return {
714
+ left: left + minX,
715
+ top: top + minY,
716
+ right: left + maxX,
717
+ bottom: top + maxY
718
+ };
719
+ }
654
720
  function GroupSelectionBox({
655
721
  documentId,
656
722
  pageIndex,
@@ -858,8 +924,29 @@ function GroupSelectionBox({
858
924
  if (selectedAnnotations.length < 2) {
859
925
  return null;
860
926
  }
861
- const groupBoxWidth = previewGroupBox.size.width * scale;
862
- const groupBoxHeight = previewGroupBox.size.height * scale;
927
+ let visualLeft = Infinity;
928
+ let visualTop = Infinity;
929
+ let visualRight = -Infinity;
930
+ let visualBottom = -Infinity;
931
+ for (const ta of selectedAnnotations) {
932
+ const bounds = getAnnotationScreenBounds(ta, scale, rotation);
933
+ visualLeft = Math.min(visualLeft, bounds.left);
934
+ visualTop = Math.min(visualTop, bounds.top);
935
+ visualRight = Math.max(visualRight, bounds.right);
936
+ visualBottom = Math.max(visualBottom, bounds.bottom);
937
+ }
938
+ const initialLogicalLeft = groupBox.origin.x * scale;
939
+ const initialLogicalTop = groupBox.origin.y * scale;
940
+ const initialLogicalRight = (groupBox.origin.x + groupBox.size.width) * scale;
941
+ const initialLogicalBottom = (groupBox.origin.y + groupBox.size.height) * scale;
942
+ const leftCorrection = visualLeft - initialLogicalLeft;
943
+ const topCorrection = visualTop - initialLogicalTop;
944
+ const rightCorrection = visualRight - initialLogicalRight;
945
+ const bottomCorrection = visualBottom - initialLogicalBottom;
946
+ const groupBoxLeft = previewGroupBox.origin.x * scale + leftCorrection;
947
+ const groupBoxTop = previewGroupBox.origin.y * scale + topCorrection;
948
+ const groupBoxWidth = previewGroupBox.size.width * scale + (rightCorrection - leftCorrection);
949
+ const groupBoxHeight = previewGroupBox.size.height * scale + (bottomCorrection - topCorrection);
863
950
  const groupCenterX = groupBoxWidth / 2;
864
951
  const groupCenterY = groupBoxHeight / 2;
865
952
  const groupGuideLength = Math.max(300, Math.max(groupBoxWidth, groupBoxHeight) + 80);
@@ -869,8 +956,8 @@ function GroupSelectionBox({
869
956
  {
870
957
  style: {
871
958
  position: "absolute",
872
- left: previewGroupBox.origin.x * scale,
873
- top: previewGroupBox.origin.y * scale,
959
+ left: groupBoxLeft,
960
+ top: groupBoxTop,
874
961
  width: groupBoxWidth,
875
962
  height: groupBoxHeight,
876
963
  pointerEvents: "none",
@@ -1084,12 +1171,12 @@ function GroupSelectionBox({
1084
1171
  {
1085
1172
  rect: {
1086
1173
  origin: {
1087
- x: previewGroupBox.origin.x * scale,
1088
- y: previewGroupBox.origin.y * scale
1174
+ x: groupBoxLeft,
1175
+ y: groupBoxTop
1089
1176
  },
1090
1177
  size: {
1091
- width: previewGroupBox.size.width * scale,
1092
- height: previewGroupBox.size.height * scale
1178
+ width: groupBoxWidth,
1179
+ height: groupBoxHeight
1093
1180
  }
1094
1181
  },
1095
1182
  rotation,
@@ -1179,7 +1266,6 @@ function Ink({
1179
1266
  stroke: "transparent",
1180
1267
  strokeWidth: hitStrokeWidth,
1181
1268
  onPointerDown: onClick,
1182
- onTouchStart: onClick,
1183
1269
  style: {
1184
1270
  cursor: isSelected ? "move" : "pointer",
1185
1271
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1264,7 +1350,6 @@ function Square({
1264
1350
  stroke: "transparent",
1265
1351
  strokeWidth: hitStrokeWidth,
1266
1352
  onPointerDown: onClick,
1267
- onTouchStart: onClick,
1268
1353
  style: {
1269
1354
  cursor: isSelected ? "move" : "pointer",
1270
1355
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
@@ -1351,7 +1436,6 @@ function Circle({
1351
1436
  stroke: "transparent",
1352
1437
  strokeWidth: hitStrokeWidth,
1353
1438
  onPointerDown: onClick,
1354
- onTouchStart: onClick,
1355
1439
  style: {
1356
1440
  cursor: isSelected ? "move" : "pointer",
1357
1441
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
@@ -1440,7 +1524,6 @@ function Line({
1440
1524
  stroke: "transparent",
1441
1525
  strokeWidth: hitStrokeWidth,
1442
1526
  onPointerDown: onClick,
1443
- onTouchStart: onClick,
1444
1527
  style: {
1445
1528
  cursor: isSelected ? "move" : "pointer",
1446
1529
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1457,7 +1540,6 @@ function Line({
1457
1540
  stroke: "transparent",
1458
1541
  strokeWidth: hitStrokeWidth,
1459
1542
  onPointerDown: onClick,
1460
- onTouchStart: onClick,
1461
1543
  style: {
1462
1544
  cursor: isSelected ? "move" : "pointer",
1463
1545
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
@@ -1474,7 +1556,6 @@ function Line({
1474
1556
  stroke: "transparent",
1475
1557
  strokeWidth: hitStrokeWidth,
1476
1558
  onPointerDown: onClick,
1477
- onTouchStart: onClick,
1478
1559
  style: {
1479
1560
  cursor: isSelected ? "move" : "pointer",
1480
1561
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
@@ -1549,6 +1630,8 @@ function Polyline({
1549
1630
  strokeColor = "#000000",
1550
1631
  opacity = 1,
1551
1632
  strokeWidth,
1633
+ strokeStyle = PdfAnnotationBorderStyle.SOLID,
1634
+ strokeDashArray,
1552
1635
  scale,
1553
1636
  isSelected,
1554
1637
  onClick,
@@ -1611,7 +1694,6 @@ function Polyline({
1611
1694
  stroke: "transparent",
1612
1695
  strokeWidth: hitStrokeWidth,
1613
1696
  onPointerDown: onClick,
1614
- onTouchStart: onClick,
1615
1697
  style: {
1616
1698
  cursor: isSelected ? "move" : "pointer",
1617
1699
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1629,7 +1711,6 @@ function Polyline({
1629
1711
  stroke: "transparent",
1630
1712
  strokeWidth: hitStrokeWidth,
1631
1713
  onPointerDown: onClick,
1632
- onTouchStart: onClick,
1633
1714
  style: {
1634
1715
  cursor: isSelected ? "move" : "pointer",
1635
1716
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
@@ -1646,7 +1727,6 @@ function Polyline({
1646
1727
  stroke: "transparent",
1647
1728
  strokeWidth: hitStrokeWidth,
1648
1729
  onPointerDown: onClick,
1649
- onTouchStart: onClick,
1650
1730
  style: {
1651
1731
  cursor: isSelected ? "move" : "pointer",
1652
1732
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
@@ -1666,7 +1746,10 @@ function Polyline({
1666
1746
  strokeWidth,
1667
1747
  pointerEvents: "none",
1668
1748
  strokeLinecap: "butt",
1669
- strokeLinejoin: "miter"
1749
+ strokeLinejoin: "miter",
1750
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1751
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1752
+ }
1670
1753
  }
1671
1754
  }
1672
1755
  ),
@@ -1680,7 +1763,10 @@ function Polyline({
1680
1763
  style: {
1681
1764
  pointerEvents: "none",
1682
1765
  strokeWidth,
1683
- strokeLinecap: "butt"
1766
+ strokeLinecap: "butt",
1767
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1768
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1769
+ }
1684
1770
  }
1685
1771
  }
1686
1772
  ),
@@ -1694,7 +1780,10 @@ function Polyline({
1694
1780
  style: {
1695
1781
  pointerEvents: "none",
1696
1782
  strokeWidth,
1697
- strokeLinecap: "butt"
1783
+ strokeLinecap: "butt",
1784
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1785
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1786
+ }
1698
1787
  }
1699
1788
  }
1700
1789
  )
@@ -1758,7 +1847,6 @@ function Polygon({
1758
1847
  stroke: "transparent",
1759
1848
  strokeWidth: hitStrokeWidth,
1760
1849
  onPointerDown: onClick,
1761
- onTouchStart: onClick,
1762
1850
  style: {
1763
1851
  cursor: isSelected ? "move" : "pointer",
1764
1852
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
@@ -1819,6 +1907,57 @@ function Polygon({
1819
1907
  }
1820
1908
  );
1821
1909
  }
1910
+ function Text({
1911
+ isSelected,
1912
+ color = "#facc15",
1913
+ opacity = 1,
1914
+ onClick,
1915
+ appearanceActive = false
1916
+ }) {
1917
+ const lineColor = getContrastStrokeColor(color);
1918
+ return /* @__PURE__ */ jsx(
1919
+ "div",
1920
+ {
1921
+ style: {
1922
+ position: "absolute",
1923
+ inset: 0,
1924
+ zIndex: 2,
1925
+ pointerEvents: isSelected ? "none" : "auto",
1926
+ cursor: isSelected ? "move" : "pointer"
1927
+ },
1928
+ onPointerDown: onClick,
1929
+ children: !appearanceActive && /* @__PURE__ */ jsxs(
1930
+ "svg",
1931
+ {
1932
+ style: {
1933
+ position: "absolute",
1934
+ inset: 0,
1935
+ pointerEvents: "none"
1936
+ },
1937
+ viewBox: "0 0 20 20",
1938
+ width: "100%",
1939
+ height: "100%",
1940
+ children: [
1941
+ /* @__PURE__ */ jsx(
1942
+ "path",
1943
+ {
1944
+ d: "M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z",
1945
+ fill: color,
1946
+ opacity,
1947
+ stroke: lineColor,
1948
+ strokeWidth: "1",
1949
+ strokeLinejoin: "miter"
1950
+ }
1951
+ ),
1952
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "4.25", x2: "17.5", y2: "4.25", stroke: lineColor, strokeWidth: "1" }),
1953
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "8", x2: "17.5", y2: "8", stroke: lineColor, strokeWidth: "1" }),
1954
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "11.75", x2: "17.5", y2: "11.75", stroke: lineColor, strokeWidth: "1" })
1955
+ ]
1956
+ }
1957
+ )
1958
+ }
1959
+ );
1960
+ }
1822
1961
  function FreeText({
1823
1962
  documentId,
1824
1963
  isSelected,
@@ -1886,7 +2025,6 @@ function FreeText({
1886
2025
  opacity: appearanceActive ? 0 : 1
1887
2026
  },
1888
2027
  onPointerDown: onClick,
1889
- onTouchStart: onClick,
1890
2028
  children: /* @__PURE__ */ jsx(
1891
2029
  "span",
1892
2030
  {
@@ -2013,7 +2151,6 @@ function Stamp({
2013
2151
  cursor: "pointer"
2014
2152
  },
2015
2153
  onPointerDown: onClick,
2016
- onTouchStart: onClick,
2017
2154
  children: /* @__PURE__ */ jsx(
2018
2155
  RenderAnnotation,
2019
2156
  {
@@ -2076,7 +2213,6 @@ function Link({
2076
2213
  height,
2077
2214
  fill: "transparent",
2078
2215
  onPointerDown: hasIRT ? void 0 : onClick,
2079
- onTouchStart: hasIRT ? void 0 : onClick,
2080
2216
  style: {
2081
2217
  cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
2082
2218
  pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
@@ -2138,7 +2274,6 @@ function Highlight({
2138
2274
  "div",
2139
2275
  {
2140
2276
  onPointerDown: onClick,
2141
- onTouchStart: onClick,
2142
2277
  style: {
2143
2278
  position: "absolute",
2144
2279
  left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
@@ -2172,7 +2307,6 @@ function Underline({
2172
2307
  "div",
2173
2308
  {
2174
2309
  onPointerDown: onClick,
2175
- onTouchStart: onClick,
2176
2310
  style: {
2177
2311
  position: "absolute",
2178
2312
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2220,7 +2354,6 @@ function Strikeout({
2220
2354
  "div",
2221
2355
  {
2222
2356
  onPointerDown: onClick,
2223
- onTouchStart: onClick,
2224
2357
  style: {
2225
2358
  position: "absolute",
2226
2359
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2275,7 +2408,6 @@ function Squiggly({
2275
2408
  "div",
2276
2409
  {
2277
2410
  onPointerDown: onClick,
2278
- onTouchStart: onClick,
2279
2411
  style: {
2280
2412
  position: "absolute",
2281
2413
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2309,6 +2441,74 @@ function Squiggly({
2309
2441
  i
2310
2442
  )) });
2311
2443
  }
2444
+ function Caret({
2445
+ isSelected,
2446
+ strokeColor = "#000000",
2447
+ opacity = 1,
2448
+ rect,
2449
+ scale,
2450
+ onClick,
2451
+ appearanceActive = false
2452
+ }) {
2453
+ const { width, height, path } = useMemo(() => {
2454
+ const w = rect.size.width;
2455
+ const h = rect.size.height;
2456
+ const midX = w / 2;
2457
+ const d = [
2458
+ `M 0 ${h}`,
2459
+ `C ${w * 0.27} ${h} ${midX} ${h - h * 0.44} ${midX} 0`,
2460
+ `C ${midX} ${h - h * 0.44} ${w - w * 0.27} ${h} ${w} ${h}`,
2461
+ "Z"
2462
+ ].join(" ");
2463
+ return { width: w, height: h, path: d };
2464
+ }, [rect]);
2465
+ const svgWidth = width * scale;
2466
+ const svgHeight = height * scale;
2467
+ return /* @__PURE__ */ jsxs(
2468
+ "svg",
2469
+ {
2470
+ style: {
2471
+ position: "absolute",
2472
+ width: svgWidth,
2473
+ height: svgHeight,
2474
+ pointerEvents: "none",
2475
+ zIndex: 2
2476
+ },
2477
+ width: svgWidth,
2478
+ height: svgHeight,
2479
+ viewBox: `0 0 ${width} ${height}`,
2480
+ overflow: "visible",
2481
+ children: [
2482
+ /* @__PURE__ */ jsx(
2483
+ "path",
2484
+ {
2485
+ d: path,
2486
+ fill: "transparent",
2487
+ stroke: "transparent",
2488
+ strokeWidth: 4,
2489
+ onPointerDown: onClick,
2490
+ style: {
2491
+ cursor: isSelected ? "move" : "pointer",
2492
+ pointerEvents: isSelected ? "none" : "visible"
2493
+ }
2494
+ }
2495
+ ),
2496
+ !appearanceActive && /* @__PURE__ */ jsx(
2497
+ "path",
2498
+ {
2499
+ d: path,
2500
+ fill: strokeColor,
2501
+ stroke: strokeColor,
2502
+ strokeWidth: 0.5,
2503
+ opacity,
2504
+ fillRule: "evenodd",
2505
+ style: { pointerEvents: "none" }
2506
+ }
2507
+ )
2508
+ ]
2509
+ }
2510
+ );
2511
+ }
2312
2512
  const builtInRenderers = [
2313
2513
  // --- Drawing ---
2314
2514
  createRenderer({
@@ -2482,6 +2682,38 @@ const builtInRenderers = [
2482
2682
  zIndex: 0,
2483
2683
  interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2484
2684
  }),
2685
+ // --- Text Comment ---
2686
+ createRenderer({
2687
+ id: "text",
2688
+ matches: (a) => a.type === PdfAnnotationSubtype.TEXT && !a.inReplyToId,
2689
+ render: ({ currentObject, isSelected, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2690
+ Text,
2691
+ {
2692
+ isSelected,
2693
+ color: currentObject.strokeColor ?? currentObject.color,
2694
+ opacity: currentObject.opacity,
2695
+ onClick,
2696
+ appearanceActive
2697
+ }
2698
+ ),
2699
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: false }
2700
+ }),
2701
+ // --- Caret ---
2702
+ createRenderer({
2703
+ id: "caret",
2704
+ matches: (a) => a.type === PdfAnnotationSubtype.CARET,
2705
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2706
+ Caret,
2707
+ {
2708
+ ...currentObject,
2709
+ isSelected,
2710
+ scale,
2711
+ onClick,
2712
+ appearanceActive
2713
+ }
2714
+ ),
2715
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2716
+ }),
2485
2717
  // --- FreeText ---
2486
2718
  createRenderer({
2487
2719
  id: "freeText",
@@ -2945,6 +3177,8 @@ function TextMarkup({ documentId, pageIndex, scale }) {
2945
3177
  )
2946
3178
  }
2947
3179
  );
3180
+ case PdfAnnotationSubtype.CARET:
3181
+ return null;
2948
3182
  default:
2949
3183
  return null;
2950
3184
  }