@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
@@ -5,10 +5,11 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { createContext, useState, useCallback, useContext, useRef, useEffect, useMemo, useLayoutEffect, Fragment as Fragment$1 } from "react";
6
6
  import { createPortal } from "react-dom";
7
7
  import { useCapability, usePlugin, useDocumentPermissions, useDocumentState } from "@embedpdf/core/react";
8
- import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
8
+ import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, getContrastStrokeColor, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
9
9
  import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
10
10
  import { useSelectionCapability } from "@embedpdf/plugin-selection/react";
11
11
  import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/react";
12
+ import { getCounterRotation } from "@embedpdf/utils";
12
13
  const suppressContentEditableWarningProps = {
13
14
  suppressContentEditableWarning: true
14
15
  };
@@ -151,6 +152,11 @@ function AnnotationContainer({
151
152
  [annotationCapability, documentId]
152
153
  );
153
154
  const currentObject = preview ? { ...trackedAnnotation.object, ...preview } : trackedAnnotation.object;
155
+ const annoFlags = trackedAnnotation.object.flags ?? [];
156
+ const hasNoZoom = annoFlags.includes("noZoom");
157
+ const hasNoRotate = annoFlags.includes("noRotate");
158
+ const visualScale = hasNoZoom ? 1 : scale;
159
+ const effectivePageRotation = hasNoRotate ? 0 : rotation;
154
160
  const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
155
161
  const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
156
162
  const ROTATION_COLOR = (rotationUI == null ? void 0 : rotationUI.color) ?? "white";
@@ -343,17 +349,21 @@ function AnnotationContainer({
343
349
  return () => unsubs.forEach((u) => u());
344
350
  }, [plugin, documentId, trackedAnnotation.object]);
345
351
  const showOutline = isSelected && !isMultiSelected;
346
- const aabbWidth = currentObject.rect.size.width * scale;
347
- const aabbHeight = currentObject.rect.size.height * scale;
348
- const innerWidth = effectiveUnrotatedRect.size.width * scale;
349
- const innerHeight = effectiveUnrotatedRect.size.height * scale;
352
+ const aabbWidth = currentObject.rect.size.width * visualScale;
353
+ const aabbHeight = currentObject.rect.size.height * visualScale;
354
+ const innerWidth = effectiveUnrotatedRect.size.width * visualScale;
355
+ const innerHeight = effectiveUnrotatedRect.size.height * visualScale;
350
356
  const usesCustomPivot = Boolean(explicitUnrotatedRect) && annotationRotation !== 0;
351
- const innerLeft = usesCustomPivot ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * scale : (aabbWidth - innerWidth) / 2;
352
- const innerTop = usesCustomPivot ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * scale : (aabbHeight - innerHeight) / 2;
353
- const innerTransformOrigin = usesCustomPivot && rotationPivot ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * scale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * scale}px` : "center center";
354
- const centerX = rotationPivot ? (rotationPivot.x - currentObject.rect.origin.x) * scale : aabbWidth / 2;
355
- const centerY = rotationPivot ? (rotationPivot.y - currentObject.rect.origin.y) * scale : aabbHeight / 2;
357
+ const innerLeft = usesCustomPivot ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * visualScale : (aabbWidth - innerWidth) / 2;
358
+ const innerTop = usesCustomPivot ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * visualScale : (aabbHeight - innerHeight) / 2;
359
+ const innerTransformOrigin = usesCustomPivot && rotationPivot ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * visualScale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * visualScale}px` : "center center";
360
+ const centerX = rotationPivot ? (rotationPivot.x - currentObject.rect.origin.x) * visualScale : aabbWidth / 2;
361
+ const centerY = rotationPivot ? (rotationPivot.y - currentObject.rect.origin.y) * visualScale : aabbHeight / 2;
356
362
  const guideLength = Math.max(300, Math.max(aabbWidth, aabbHeight) + 80);
363
+ const counterRot = hasNoRotate ? getCounterRotation(
364
+ { origin: { x: 0, y: 0 }, size: { width: aabbWidth, height: aabbHeight } },
365
+ rotation
366
+ ) : null;
357
367
  const childObject = useMemo(() => {
358
368
  if (explicitUnrotatedRect) {
359
369
  return { ...currentObject, rect: explicitUnrotatedRect };
@@ -369,10 +379,15 @@ function AnnotationContainer({
369
379
  position: "absolute",
370
380
  left: currentObject.rect.origin.x * scale,
371
381
  top: currentObject.rect.origin.y * scale,
372
- width: aabbWidth,
373
- height: aabbHeight,
382
+ width: counterRot ? counterRot.width : aabbWidth,
383
+ height: counterRot ? counterRot.height : aabbHeight,
374
384
  pointerEvents: "none",
375
385
  zIndex,
386
+ // noRotate: apply counter-rotation matrix so the annotation stays upright
387
+ ...counterRot && {
388
+ transform: counterRot.matrix,
389
+ transformOrigin: "0 0"
390
+ },
376
391
  ...style
377
392
  },
378
393
  ...props,
@@ -601,13 +616,13 @@ function AnnotationContainer({
601
616
  y: currentObject.rect.origin.y * scale
602
617
  },
603
618
  size: {
604
- width: currentObject.rect.size.width * scale,
605
- height: currentObject.rect.size.height * scale
619
+ width: currentObject.rect.size.width * visualScale,
620
+ height: currentObject.rect.size.height * visualScale
606
621
  }
607
622
  },
608
623
  rotation,
609
624
  children: (counterRotateProps) => {
610
- const effectiveAngle = ((annotationRotation + rotation * 90) % 360 + 360) % 360;
625
+ const effectiveAngle = ((annotationRotation + effectivePageRotation * 90) % 360 + 360) % 360;
611
626
  const handleNearMenuSide = effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;
612
627
  return selectionMenu({
613
628
  ...counterRotateProps,
@@ -652,6 +667,57 @@ function AnnotationContainer({
652
667
  )
653
668
  ] });
654
669
  }
670
+ function mapCounterRotatePoint(x, y, width, height, rotation) {
671
+ switch (rotation) {
672
+ case 1:
673
+ return { x: y, y: height - x };
674
+ case 2:
675
+ return { x: width - x, y: height - y };
676
+ case 3:
677
+ return { x: width - y, y: x };
678
+ default:
679
+ return { x, y };
680
+ }
681
+ }
682
+ function getAnnotationScreenBounds(annotation, scale, rotation) {
683
+ const flags = annotation.object.flags ?? [];
684
+ const hasNoZoom = flags.includes("noZoom");
685
+ const hasNoRotate = flags.includes("noRotate");
686
+ const left = annotation.object.rect.origin.x * scale;
687
+ const top = annotation.object.rect.origin.y * scale;
688
+ const width = annotation.object.rect.size.width * (hasNoZoom ? 1 : scale);
689
+ const height = annotation.object.rect.size.height * (hasNoZoom ? 1 : scale);
690
+ if (!hasNoRotate || rotation === 0) {
691
+ return {
692
+ left,
693
+ top,
694
+ right: left + width,
695
+ bottom: top + height
696
+ };
697
+ }
698
+ const corners = [
699
+ mapCounterRotatePoint(0, 0, width, height, rotation),
700
+ mapCounterRotatePoint(width, 0, width, height, rotation),
701
+ mapCounterRotatePoint(0, height, width, height, rotation),
702
+ mapCounterRotatePoint(width, height, width, height, rotation)
703
+ ];
704
+ let minX = Infinity;
705
+ let minY = Infinity;
706
+ let maxX = -Infinity;
707
+ let maxY = -Infinity;
708
+ for (const corner of corners) {
709
+ if (corner.x < minX) minX = corner.x;
710
+ if (corner.y < minY) minY = corner.y;
711
+ if (corner.x > maxX) maxX = corner.x;
712
+ if (corner.y > maxY) maxY = corner.y;
713
+ }
714
+ return {
715
+ left: left + minX,
716
+ top: top + minY,
717
+ right: left + maxX,
718
+ bottom: top + maxY
719
+ };
720
+ }
655
721
  function GroupSelectionBox({
656
722
  documentId,
657
723
  pageIndex,
@@ -859,8 +925,29 @@ function GroupSelectionBox({
859
925
  if (selectedAnnotations.length < 2) {
860
926
  return null;
861
927
  }
862
- const groupBoxWidth = previewGroupBox.size.width * scale;
863
- const groupBoxHeight = previewGroupBox.size.height * scale;
928
+ let visualLeft = Infinity;
929
+ let visualTop = Infinity;
930
+ let visualRight = -Infinity;
931
+ let visualBottom = -Infinity;
932
+ for (const ta of selectedAnnotations) {
933
+ const bounds = getAnnotationScreenBounds(ta, scale, rotation);
934
+ visualLeft = Math.min(visualLeft, bounds.left);
935
+ visualTop = Math.min(visualTop, bounds.top);
936
+ visualRight = Math.max(visualRight, bounds.right);
937
+ visualBottom = Math.max(visualBottom, bounds.bottom);
938
+ }
939
+ const initialLogicalLeft = groupBox.origin.x * scale;
940
+ const initialLogicalTop = groupBox.origin.y * scale;
941
+ const initialLogicalRight = (groupBox.origin.x + groupBox.size.width) * scale;
942
+ const initialLogicalBottom = (groupBox.origin.y + groupBox.size.height) * scale;
943
+ const leftCorrection = visualLeft - initialLogicalLeft;
944
+ const topCorrection = visualTop - initialLogicalTop;
945
+ const rightCorrection = visualRight - initialLogicalRight;
946
+ const bottomCorrection = visualBottom - initialLogicalBottom;
947
+ const groupBoxLeft = previewGroupBox.origin.x * scale + leftCorrection;
948
+ const groupBoxTop = previewGroupBox.origin.y * scale + topCorrection;
949
+ const groupBoxWidth = previewGroupBox.size.width * scale + (rightCorrection - leftCorrection);
950
+ const groupBoxHeight = previewGroupBox.size.height * scale + (bottomCorrection - topCorrection);
864
951
  const groupCenterX = groupBoxWidth / 2;
865
952
  const groupCenterY = groupBoxHeight / 2;
866
953
  const groupGuideLength = Math.max(300, Math.max(groupBoxWidth, groupBoxHeight) + 80);
@@ -870,8 +957,8 @@ function GroupSelectionBox({
870
957
  {
871
958
  style: {
872
959
  position: "absolute",
873
- left: previewGroupBox.origin.x * scale,
874
- top: previewGroupBox.origin.y * scale,
960
+ left: groupBoxLeft,
961
+ top: groupBoxTop,
875
962
  width: groupBoxWidth,
876
963
  height: groupBoxHeight,
877
964
  pointerEvents: "none",
@@ -1085,12 +1172,12 @@ function GroupSelectionBox({
1085
1172
  {
1086
1173
  rect: {
1087
1174
  origin: {
1088
- x: previewGroupBox.origin.x * scale,
1089
- y: previewGroupBox.origin.y * scale
1175
+ x: groupBoxLeft,
1176
+ y: groupBoxTop
1090
1177
  },
1091
1178
  size: {
1092
- width: previewGroupBox.size.width * scale,
1093
- height: previewGroupBox.size.height * scale
1179
+ width: groupBoxWidth,
1180
+ height: groupBoxHeight
1094
1181
  }
1095
1182
  },
1096
1183
  rotation,
@@ -1180,7 +1267,6 @@ function Ink({
1180
1267
  stroke: "transparent",
1181
1268
  strokeWidth: hitStrokeWidth,
1182
1269
  onPointerDown: onClick,
1183
- onTouchStart: onClick,
1184
1270
  style: {
1185
1271
  cursor: isSelected ? "move" : "pointer",
1186
1272
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1265,7 +1351,6 @@ function Square({
1265
1351
  stroke: "transparent",
1266
1352
  strokeWidth: hitStrokeWidth,
1267
1353
  onPointerDown: onClick,
1268
- onTouchStart: onClick,
1269
1354
  style: {
1270
1355
  cursor: isSelected ? "move" : "pointer",
1271
1356
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
@@ -1352,7 +1437,6 @@ function Circle({
1352
1437
  stroke: "transparent",
1353
1438
  strokeWidth: hitStrokeWidth,
1354
1439
  onPointerDown: onClick,
1355
- onTouchStart: onClick,
1356
1440
  style: {
1357
1441
  cursor: isSelected ? "move" : "pointer",
1358
1442
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
@@ -1441,7 +1525,6 @@ function Line({
1441
1525
  stroke: "transparent",
1442
1526
  strokeWidth: hitStrokeWidth,
1443
1527
  onPointerDown: onClick,
1444
- onTouchStart: onClick,
1445
1528
  style: {
1446
1529
  cursor: isSelected ? "move" : "pointer",
1447
1530
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1458,7 +1541,6 @@ function Line({
1458
1541
  stroke: "transparent",
1459
1542
  strokeWidth: hitStrokeWidth,
1460
1543
  onPointerDown: onClick,
1461
- onTouchStart: onClick,
1462
1544
  style: {
1463
1545
  cursor: isSelected ? "move" : "pointer",
1464
1546
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
@@ -1475,7 +1557,6 @@ function Line({
1475
1557
  stroke: "transparent",
1476
1558
  strokeWidth: hitStrokeWidth,
1477
1559
  onPointerDown: onClick,
1478
- onTouchStart: onClick,
1479
1560
  style: {
1480
1561
  cursor: isSelected ? "move" : "pointer",
1481
1562
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
@@ -1550,6 +1631,8 @@ function Polyline({
1550
1631
  strokeColor = "#000000",
1551
1632
  opacity = 1,
1552
1633
  strokeWidth,
1634
+ strokeStyle = PdfAnnotationBorderStyle.SOLID,
1635
+ strokeDashArray,
1553
1636
  scale,
1554
1637
  isSelected,
1555
1638
  onClick,
@@ -1612,7 +1695,6 @@ function Polyline({
1612
1695
  stroke: "transparent",
1613
1696
  strokeWidth: hitStrokeWidth,
1614
1697
  onPointerDown: onClick,
1615
- onTouchStart: onClick,
1616
1698
  style: {
1617
1699
  cursor: isSelected ? "move" : "pointer",
1618
1700
  pointerEvents: isSelected ? "none" : "visibleStroke",
@@ -1630,7 +1712,6 @@ function Polyline({
1630
1712
  stroke: "transparent",
1631
1713
  strokeWidth: hitStrokeWidth,
1632
1714
  onPointerDown: onClick,
1633
- onTouchStart: onClick,
1634
1715
  style: {
1635
1716
  cursor: isSelected ? "move" : "pointer",
1636
1717
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
@@ -1647,7 +1728,6 @@ function Polyline({
1647
1728
  stroke: "transparent",
1648
1729
  strokeWidth: hitStrokeWidth,
1649
1730
  onPointerDown: onClick,
1650
- onTouchStart: onClick,
1651
1731
  style: {
1652
1732
  cursor: isSelected ? "move" : "pointer",
1653
1733
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
@@ -1667,7 +1747,10 @@ function Polyline({
1667
1747
  strokeWidth,
1668
1748
  pointerEvents: "none",
1669
1749
  strokeLinecap: "butt",
1670
- strokeLinejoin: "miter"
1750
+ strokeLinejoin: "miter",
1751
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1752
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1753
+ }
1671
1754
  }
1672
1755
  }
1673
1756
  ),
@@ -1681,7 +1764,10 @@ function Polyline({
1681
1764
  style: {
1682
1765
  pointerEvents: "none",
1683
1766
  strokeWidth,
1684
- strokeLinecap: "butt"
1767
+ strokeLinecap: "butt",
1768
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1769
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1770
+ }
1685
1771
  }
1686
1772
  }
1687
1773
  ),
@@ -1695,7 +1781,10 @@ function Polyline({
1695
1781
  style: {
1696
1782
  pointerEvents: "none",
1697
1783
  strokeWidth,
1698
- strokeLinecap: "butt"
1784
+ strokeLinecap: "butt",
1785
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1786
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1787
+ }
1699
1788
  }
1700
1789
  }
1701
1790
  )
@@ -1759,7 +1848,6 @@ function Polygon({
1759
1848
  stroke: "transparent",
1760
1849
  strokeWidth: hitStrokeWidth,
1761
1850
  onPointerDown: onClick,
1762
- onTouchStart: onClick,
1763
1851
  style: {
1764
1852
  cursor: isSelected ? "move" : "pointer",
1765
1853
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
@@ -1820,6 +1908,57 @@ function Polygon({
1820
1908
  }
1821
1909
  );
1822
1910
  }
1911
+ function Text({
1912
+ isSelected,
1913
+ color = "#facc15",
1914
+ opacity = 1,
1915
+ onClick,
1916
+ appearanceActive = false
1917
+ }) {
1918
+ const lineColor = getContrastStrokeColor(color);
1919
+ return /* @__PURE__ */ jsx(
1920
+ "div",
1921
+ {
1922
+ style: {
1923
+ position: "absolute",
1924
+ inset: 0,
1925
+ zIndex: 2,
1926
+ pointerEvents: isSelected ? "none" : "auto",
1927
+ cursor: isSelected ? "move" : "pointer"
1928
+ },
1929
+ onPointerDown: onClick,
1930
+ children: !appearanceActive && /* @__PURE__ */ jsxs(
1931
+ "svg",
1932
+ {
1933
+ style: {
1934
+ position: "absolute",
1935
+ inset: 0,
1936
+ pointerEvents: "none"
1937
+ },
1938
+ viewBox: "0 0 20 20",
1939
+ width: "100%",
1940
+ height: "100%",
1941
+ children: [
1942
+ /* @__PURE__ */ jsx(
1943
+ "path",
1944
+ {
1945
+ 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",
1946
+ fill: color,
1947
+ opacity,
1948
+ stroke: lineColor,
1949
+ strokeWidth: "1",
1950
+ strokeLinejoin: "miter"
1951
+ }
1952
+ ),
1953
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "4.25", x2: "17.5", y2: "4.25", stroke: lineColor, strokeWidth: "1" }),
1954
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "8", x2: "17.5", y2: "8", stroke: lineColor, strokeWidth: "1" }),
1955
+ /* @__PURE__ */ jsx("line", { x1: "2.5", y1: "11.75", x2: "17.5", y2: "11.75", stroke: lineColor, strokeWidth: "1" })
1956
+ ]
1957
+ }
1958
+ )
1959
+ }
1960
+ );
1961
+ }
1823
1962
  function FreeText({
1824
1963
  documentId,
1825
1964
  isSelected,
@@ -1887,7 +2026,6 @@ function FreeText({
1887
2026
  opacity: appearanceActive ? 0 : 1
1888
2027
  },
1889
2028
  onPointerDown: onClick,
1890
- onTouchStart: onClick,
1891
2029
  children: /* @__PURE__ */ jsx(
1892
2030
  "span",
1893
2031
  {
@@ -2014,7 +2152,6 @@ function Stamp({
2014
2152
  cursor: "pointer"
2015
2153
  },
2016
2154
  onPointerDown: onClick,
2017
- onTouchStart: onClick,
2018
2155
  children: /* @__PURE__ */ jsx(
2019
2156
  RenderAnnotation,
2020
2157
  {
@@ -2077,7 +2214,6 @@ function Link({
2077
2214
  height,
2078
2215
  fill: "transparent",
2079
2216
  onPointerDown: hasIRT ? void 0 : onClick,
2080
- onTouchStart: hasIRT ? void 0 : onClick,
2081
2217
  style: {
2082
2218
  cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
2083
2219
  pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
@@ -2139,7 +2275,6 @@ function Highlight({
2139
2275
  "div",
2140
2276
  {
2141
2277
  onPointerDown: onClick,
2142
- onTouchStart: onClick,
2143
2278
  style: {
2144
2279
  position: "absolute",
2145
2280
  left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
@@ -2173,7 +2308,6 @@ function Underline({
2173
2308
  "div",
2174
2309
  {
2175
2310
  onPointerDown: onClick,
2176
- onTouchStart: onClick,
2177
2311
  style: {
2178
2312
  position: "absolute",
2179
2313
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2221,7 +2355,6 @@ function Strikeout({
2221
2355
  "div",
2222
2356
  {
2223
2357
  onPointerDown: onClick,
2224
- onTouchStart: onClick,
2225
2358
  style: {
2226
2359
  position: "absolute",
2227
2360
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2276,7 +2409,6 @@ function Squiggly({
2276
2409
  "div",
2277
2410
  {
2278
2411
  onPointerDown: onClick,
2279
- onTouchStart: onClick,
2280
2412
  style: {
2281
2413
  position: "absolute",
2282
2414
  left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
@@ -2310,6 +2442,74 @@ function Squiggly({
2310
2442
  i
2311
2443
  )) });
2312
2444
  }
2445
+ function Caret({
2446
+ isSelected,
2447
+ strokeColor = "#000000",
2448
+ opacity = 1,
2449
+ rect,
2450
+ scale,
2451
+ onClick,
2452
+ appearanceActive = false
2453
+ }) {
2454
+ const { width, height, path } = useMemo(() => {
2455
+ const w = rect.size.width;
2456
+ const h = rect.size.height;
2457
+ const midX = w / 2;
2458
+ const d = [
2459
+ `M 0 ${h}`,
2460
+ `C ${w * 0.27} ${h} ${midX} ${h - h * 0.44} ${midX} 0`,
2461
+ `C ${midX} ${h - h * 0.44} ${w - w * 0.27} ${h} ${w} ${h}`,
2462
+ "Z"
2463
+ ].join(" ");
2464
+ return { width: w, height: h, path: d };
2465
+ }, [rect]);
2466
+ const svgWidth = width * scale;
2467
+ const svgHeight = height * scale;
2468
+ return /* @__PURE__ */ jsxs(
2469
+ "svg",
2470
+ {
2471
+ style: {
2472
+ position: "absolute",
2473
+ width: svgWidth,
2474
+ height: svgHeight,
2475
+ pointerEvents: "none",
2476
+ zIndex: 2
2477
+ },
2478
+ width: svgWidth,
2479
+ height: svgHeight,
2480
+ viewBox: `0 0 ${width} ${height}`,
2481
+ overflow: "visible",
2482
+ children: [
2483
+ /* @__PURE__ */ jsx(
2484
+ "path",
2485
+ {
2486
+ d: path,
2487
+ fill: "transparent",
2488
+ stroke: "transparent",
2489
+ strokeWidth: 4,
2490
+ onPointerDown: onClick,
2491
+ style: {
2492
+ cursor: isSelected ? "move" : "pointer",
2493
+ pointerEvents: isSelected ? "none" : "visible"
2494
+ }
2495
+ }
2496
+ ),
2497
+ !appearanceActive && /* @__PURE__ */ jsx(
2498
+ "path",
2499
+ {
2500
+ d: path,
2501
+ fill: strokeColor,
2502
+ stroke: strokeColor,
2503
+ strokeWidth: 0.5,
2504
+ opacity,
2505
+ fillRule: "evenodd",
2506
+ style: { pointerEvents: "none" }
2507
+ }
2508
+ )
2509
+ ]
2510
+ }
2511
+ );
2512
+ }
2313
2513
  const builtInRenderers = [
2314
2514
  // --- Drawing ---
2315
2515
  createRenderer({
@@ -2483,6 +2683,38 @@ const builtInRenderers = [
2483
2683
  zIndex: 0,
2484
2684
  interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2485
2685
  }),
2686
+ // --- Text Comment ---
2687
+ createRenderer({
2688
+ id: "text",
2689
+ matches: (a) => a.type === PdfAnnotationSubtype.TEXT && !a.inReplyToId,
2690
+ render: ({ currentObject, isSelected, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2691
+ Text,
2692
+ {
2693
+ isSelected,
2694
+ color: currentObject.strokeColor ?? currentObject.color,
2695
+ opacity: currentObject.opacity,
2696
+ onClick,
2697
+ appearanceActive
2698
+ }
2699
+ ),
2700
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: false }
2701
+ }),
2702
+ // --- Caret ---
2703
+ createRenderer({
2704
+ id: "caret",
2705
+ matches: (a) => a.type === PdfAnnotationSubtype.CARET,
2706
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2707
+ Caret,
2708
+ {
2709
+ ...currentObject,
2710
+ isSelected,
2711
+ scale,
2712
+ onClick,
2713
+ appearanceActive
2714
+ }
2715
+ ),
2716
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2717
+ }),
2486
2718
  // --- FreeText ---
2487
2719
  createRenderer({
2488
2720
  id: "freeText",
@@ -2946,6 +3178,8 @@ function TextMarkup({ documentId, pageIndex, scale }) {
2946
3178
  )
2947
3179
  }
2948
3180
  );
3181
+ case PdfAnnotationSubtype.CARET:
3182
+ return null;
2949
3183
  default:
2950
3184
  return null;
2951
3185
  }