@embedpdf/plugin-annotation 2.7.0 → 2.9.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1131 -203
- package/dist/index.js.map +1 -1
- package/dist/lib/annotation-plugin.d.ts +2 -0
- package/dist/lib/geometry/cloudy-border.d.ts +90 -0
- package/dist/lib/geometry/index.d.ts +1 -0
- package/dist/lib/handlers/index.d.ts +4 -0
- package/dist/lib/handlers/insert-text.handler.d.ts +8 -0
- package/dist/lib/handlers/replace-text.handler.d.ts +9 -0
- package/dist/lib/handlers/selection-utils.d.ts +7 -0
- package/dist/lib/handlers/text-markup.handler.d.ts +7 -0
- package/dist/lib/handlers/text.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +14 -1
- package/dist/lib/helpers.d.ts +2 -1
- package/dist/lib/selectors.d.ts +6 -1
- package/dist/lib/tools/default-tools.d.ts +141 -45
- package/dist/lib/tools/tools-utils.d.ts +2 -0
- package/dist/lib/tools/types.d.ts +34 -1
- package/dist/lib/types.d.ts +1 -0
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +621 -274
- 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 +621 -274
- package/dist/react/index.js.map +1 -1
- package/dist/shared/annotation-bounds.d.ts +14 -0
- package/dist/shared/components/annotation-container.d.ts +4 -2
- package/dist/shared/components/annotations/caret.d.ts +24 -0
- package/dist/shared/components/annotations/circle.d.ts +8 -4
- package/dist/shared/components/annotations/free-text.d.ts +2 -2
- package/dist/shared/components/annotations/ink.d.ts +2 -2
- package/dist/shared/components/annotations/line.d.ts +2 -2
- package/dist/shared/components/annotations/link.d.ts +2 -2
- package/dist/shared/components/annotations/polygon.d.ts +5 -3
- package/dist/shared/components/annotations/polyline.d.ts +8 -4
- package/dist/shared/components/annotations/square.d.ts +8 -4
- package/dist/shared/components/annotations/stamp.d.ts +2 -2
- package/dist/shared/components/annotations/text.d.ts +14 -0
- package/dist/shared/components/text-markup/highlight.d.ts +2 -2
- package/dist/shared/components/text-markup/squiggly.d.ts +2 -2
- package/dist/shared/components/text-markup/strikeout.d.ts +2 -2
- package/dist/shared/components/text-markup/underline.d.ts +2 -2
- package/dist/shared/components/types.d.ts +8 -4
- package/dist/shared-preact/annotation-bounds.d.ts +14 -0
- package/dist/shared-preact/components/annotation-container.d.ts +4 -2
- package/dist/shared-preact/components/annotations/caret.d.ts +24 -0
- package/dist/shared-preact/components/annotations/circle.d.ts +8 -4
- package/dist/shared-preact/components/annotations/free-text.d.ts +2 -2
- package/dist/shared-preact/components/annotations/ink.d.ts +2 -2
- package/dist/shared-preact/components/annotations/line.d.ts +2 -2
- package/dist/shared-preact/components/annotations/link.d.ts +2 -2
- package/dist/shared-preact/components/annotations/polygon.d.ts +5 -3
- package/dist/shared-preact/components/annotations/polyline.d.ts +8 -4
- package/dist/shared-preact/components/annotations/square.d.ts +8 -4
- package/dist/shared-preact/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-preact/components/annotations/text.d.ts +14 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/underline.d.ts +2 -2
- package/dist/shared-preact/components/types.d.ts +8 -4
- package/dist/shared-react/annotation-bounds.d.ts +14 -0
- package/dist/shared-react/components/annotation-container.d.ts +4 -2
- package/dist/shared-react/components/annotations/caret.d.ts +24 -0
- package/dist/shared-react/components/annotations/circle.d.ts +8 -4
- package/dist/shared-react/components/annotations/free-text.d.ts +2 -2
- package/dist/shared-react/components/annotations/ink.d.ts +2 -2
- package/dist/shared-react/components/annotations/line.d.ts +2 -2
- package/dist/shared-react/components/annotations/link.d.ts +2 -2
- package/dist/shared-react/components/annotations/polygon.d.ts +5 -3
- package/dist/shared-react/components/annotations/polyline.d.ts +8 -4
- package/dist/shared-react/components/annotations/square.d.ts +8 -4
- package/dist/shared-react/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-react/components/annotations/text.d.ts +14 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +2 -2
- package/dist/shared-react/components/text-markup/squiggly.d.ts +2 -2
- package/dist/shared-react/components/text-markup/strikeout.d.ts +2 -2
- package/dist/shared-react/components/text-markup/underline.d.ts +2 -2
- package/dist/shared-react/components/types.d.ts +8 -4
- package/dist/shared-vue/annotation-bounds.d.ts +14 -0
- package/dist/svelte/components/annotations/Caret.svelte.d.ts +13 -0
- package/dist/svelte/components/annotations/Circle.svelte.d.ts +4 -2
- package/dist/svelte/components/annotations/FreeText.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Line.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Polygon.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Polyline.svelte.d.ts +4 -2
- package/dist/svelte/components/annotations/Square.svelte.d.ts +4 -2
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Text.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/renderers/CaretRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/TextRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +1 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +1 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +1 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +1 -1
- package/dist/svelte/components/types.d.ts +2 -1
- package/dist/svelte/context/types.d.ts +7 -3
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +831 -416
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-container.vue.d.ts +9 -8
- package/dist/vue/components/annotation-layer.vue.d.ts +1 -1
- package/dist/vue/components/annotations/caret.vue.d.ts +24 -0
- package/dist/vue/components/annotations/circle.vue.d.ts +7 -3
- package/dist/vue/components/annotations/free-text.vue.d.ts +2 -2
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
- package/dist/vue/components/annotations/line.vue.d.ts +2 -2
- package/dist/vue/components/annotations/link.vue.d.ts +2 -2
- package/dist/vue/components/annotations/polygon.vue.d.ts +4 -2
- package/dist/vue/components/annotations/polyline.vue.d.ts +8 -3
- package/dist/vue/components/annotations/square.vue.d.ts +7 -3
- package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
- package/dist/vue/components/annotations/text.vue.d.ts +14 -0
- package/dist/vue/components/annotations.vue.d.ts +9 -10
- package/dist/vue/components/renderers/caret-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/text-renderer.vue.d.ts +6 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
- package/dist/vue/context/types.d.ts +7 -3
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +778 -354
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/preact/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
-
import { initialDocumentState, AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
|
|
2
|
+
import { initialDocumentState, AnnotationPlugin, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
4
|
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
5
5
|
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
|
|
9
|
+
import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, getContrastStrokeColor, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfBlendMode, PdfAnnotationSubtype, blendModeToCss } 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([]);
|
|
@@ -113,6 +114,7 @@ function AnnotationContainer({
|
|
|
113
114
|
isRotatable = true,
|
|
114
115
|
lockAspectRatio = false,
|
|
115
116
|
style = {},
|
|
117
|
+
blendMode,
|
|
116
118
|
vertexConfig,
|
|
117
119
|
selectionMenu,
|
|
118
120
|
outlineOffset = 1,
|
|
@@ -150,6 +152,11 @@ function AnnotationContainer({
|
|
|
150
152
|
[annotationCapability, documentId]
|
|
151
153
|
);
|
|
152
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;
|
|
153
160
|
const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
|
|
154
161
|
const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
|
|
155
162
|
const ROTATION_COLOR = (rotationUI == null ? void 0 : rotationUI.color) ?? "white";
|
|
@@ -342,17 +349,21 @@ function AnnotationContainer({
|
|
|
342
349
|
return () => unsubs.forEach((u) => u());
|
|
343
350
|
}, [plugin, documentId, trackedAnnotation.object]);
|
|
344
351
|
const showOutline = isSelected && !isMultiSelected;
|
|
345
|
-
const aabbWidth = currentObject.rect.size.width *
|
|
346
|
-
const aabbHeight = currentObject.rect.size.height *
|
|
347
|
-
const innerWidth = effectiveUnrotatedRect.size.width *
|
|
348
|
-
const innerHeight = effectiveUnrotatedRect.size.height *
|
|
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;
|
|
349
356
|
const usesCustomPivot = Boolean(explicitUnrotatedRect) && annotationRotation !== 0;
|
|
350
|
-
const innerLeft = usesCustomPivot ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) *
|
|
351
|
-
const innerTop = usesCustomPivot ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) *
|
|
352
|
-
const innerTransformOrigin = usesCustomPivot && rotationPivot ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) *
|
|
353
|
-
const centerX = rotationPivot ? (rotationPivot.x - currentObject.rect.origin.x) *
|
|
354
|
-
const centerY = rotationPivot ? (rotationPivot.y - currentObject.rect.origin.y) *
|
|
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;
|
|
355
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;
|
|
356
367
|
const childObject = useMemo(() => {
|
|
357
368
|
if (explicitUnrotatedRect) {
|
|
358
369
|
return { ...currentObject, rect: explicitUnrotatedRect };
|
|
@@ -360,237 +371,250 @@ function AnnotationContainer({
|
|
|
360
371
|
return currentObject;
|
|
361
372
|
}, [currentObject, explicitUnrotatedRect]);
|
|
362
373
|
const apActive = !!(appearance == null ? void 0 : appearance.normal) && !gestureActive && !isEditing && !trackedAnnotation.dictMode;
|
|
374
|
+
const layerBaseStyle = {
|
|
375
|
+
position: "absolute",
|
|
376
|
+
left: currentObject.rect.origin.x * scale,
|
|
377
|
+
top: currentObject.rect.origin.y * scale,
|
|
378
|
+
width: counterRot ? counterRot.width : aabbWidth,
|
|
379
|
+
height: counterRot ? counterRot.height : aabbHeight,
|
|
380
|
+
pointerEvents: "none",
|
|
381
|
+
zIndex,
|
|
382
|
+
// noRotate: apply counter-rotation matrix so the annotation stays upright
|
|
383
|
+
...counterRot && {
|
|
384
|
+
transform: counterRot.matrix,
|
|
385
|
+
transformOrigin: "0 0"
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
const innerDivBaseStyle = {
|
|
389
|
+
position: "absolute",
|
|
390
|
+
left: innerLeft,
|
|
391
|
+
top: innerTop,
|
|
392
|
+
width: innerWidth,
|
|
393
|
+
height: innerHeight,
|
|
394
|
+
transform: annotationRotation !== 0 ? `rotate(${annotationRotation}deg)` : void 0,
|
|
395
|
+
transformOrigin: innerTransformOrigin
|
|
396
|
+
};
|
|
363
397
|
return /* @__PURE__ */ jsxs("div", { "data-no-interaction": true, children: [
|
|
364
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ jsx(
|
|
365
399
|
"div",
|
|
366
400
|
{
|
|
367
401
|
style: {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
top: currentObject.rect.origin.y * scale,
|
|
371
|
-
width: aabbWidth,
|
|
372
|
-
height: aabbHeight,
|
|
373
|
-
pointerEvents: "none",
|
|
374
|
-
zIndex,
|
|
402
|
+
...layerBaseStyle,
|
|
403
|
+
...blendMode && { mixBlendMode: blendMode },
|
|
375
404
|
...style
|
|
376
405
|
},
|
|
377
|
-
...
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
406
|
+
children: /* @__PURE__ */ jsxs("div", { style: { ...innerDivBaseStyle, pointerEvents: "none" }, children: [
|
|
407
|
+
(() => {
|
|
408
|
+
const childrenRender = typeof children === "function" ? children(childObject, { appearanceActive: apActive }) : children;
|
|
409
|
+
const customRender = customAnnotationRenderer == null ? void 0 : customAnnotationRenderer({
|
|
410
|
+
annotation: childObject,
|
|
411
|
+
children: childrenRender,
|
|
412
|
+
isSelected,
|
|
413
|
+
scale,
|
|
414
|
+
rotation,
|
|
415
|
+
pageWidth,
|
|
416
|
+
pageHeight,
|
|
417
|
+
pageIndex,
|
|
418
|
+
onSelect
|
|
419
|
+
});
|
|
420
|
+
return customRender ?? childrenRender;
|
|
421
|
+
})(),
|
|
422
|
+
(appearance == null ? void 0 : appearance.normal) && /* @__PURE__ */ jsx(
|
|
423
|
+
AppearanceImage,
|
|
424
|
+
{
|
|
425
|
+
appearance: appearance.normal,
|
|
426
|
+
style: { display: apActive ? "block" : "none" }
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] })
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
/* @__PURE__ */ jsxs("div", { style: layerBaseStyle, ...props, children: [
|
|
433
|
+
rotationActive && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
434
|
+
/* @__PURE__ */ jsx(
|
|
435
|
+
"div",
|
|
436
|
+
{
|
|
437
|
+
style: {
|
|
438
|
+
position: "absolute",
|
|
439
|
+
left: centerX - guideLength / 2,
|
|
440
|
+
top: centerY,
|
|
441
|
+
width: guideLength,
|
|
442
|
+
height: 1,
|
|
443
|
+
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
444
|
+
opacity: 0.35,
|
|
445
|
+
pointerEvents: "none"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
),
|
|
449
|
+
/* @__PURE__ */ jsx(
|
|
450
|
+
"div",
|
|
451
|
+
{
|
|
452
|
+
style: {
|
|
453
|
+
position: "absolute",
|
|
454
|
+
left: centerX,
|
|
455
|
+
top: centerY - guideLength / 2,
|
|
456
|
+
width: 1,
|
|
457
|
+
height: guideLength,
|
|
458
|
+
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
459
|
+
opacity: 0.35,
|
|
460
|
+
pointerEvents: "none"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ jsx(
|
|
465
|
+
"div",
|
|
466
|
+
{
|
|
467
|
+
style: {
|
|
468
|
+
position: "absolute",
|
|
469
|
+
left: centerX - guideLength / 2,
|
|
470
|
+
top: centerY,
|
|
471
|
+
width: guideLength,
|
|
472
|
+
height: 1,
|
|
473
|
+
transformOrigin: "center center",
|
|
474
|
+
transform: `rotate(${annotationRotation}deg)`,
|
|
475
|
+
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
476
|
+
opacity: 0.8,
|
|
477
|
+
pointerEvents: "none"
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] }),
|
|
482
|
+
isSelected && effectiveIsRotatable && rotationHandle && ((rotationUI == null ? void 0 : rotationUI.component) ? /* @__PURE__ */ jsx(
|
|
483
|
+
"div",
|
|
484
|
+
{
|
|
485
|
+
onPointerEnter: () => setIsHandleHovered(true),
|
|
486
|
+
onPointerLeave: () => {
|
|
487
|
+
setIsHandleHovered(false);
|
|
488
|
+
setCursorScreen(null);
|
|
489
|
+
},
|
|
490
|
+
onPointerMove: (e) => {
|
|
491
|
+
if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });
|
|
492
|
+
},
|
|
493
|
+
style: { display: "contents" },
|
|
494
|
+
children: rotationUI.component({
|
|
495
|
+
...rotationHandle.handle,
|
|
496
|
+
backgroundColor: ROTATION_COLOR,
|
|
497
|
+
iconColor: ROTATION_ICON_COLOR,
|
|
498
|
+
connectorStyle: {
|
|
499
|
+
...rotationHandle.connector.style,
|
|
500
|
+
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
501
|
+
opacity: rotationActive ? 0 : 1
|
|
502
|
+
},
|
|
503
|
+
showConnector: SHOW_CONNECTOR,
|
|
504
|
+
opacity: rotationActive ? 0 : 1,
|
|
505
|
+
border: {
|
|
506
|
+
color: ROTATION_BORDER_COLOR,
|
|
507
|
+
width: ROTATION_BORDER_WIDTH,
|
|
508
|
+
style: ROTATION_BORDER_STYLE
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
}
|
|
512
|
+
) : /* @__PURE__ */ jsxs(
|
|
513
|
+
"div",
|
|
514
|
+
{
|
|
515
|
+
onPointerEnter: () => setIsHandleHovered(true),
|
|
516
|
+
onPointerLeave: () => {
|
|
517
|
+
setIsHandleHovered(false);
|
|
518
|
+
setCursorScreen(null);
|
|
519
|
+
},
|
|
520
|
+
onPointerMove: (e) => {
|
|
521
|
+
if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });
|
|
522
|
+
},
|
|
523
|
+
style: { display: "contents" },
|
|
524
|
+
children: [
|
|
525
|
+
SHOW_CONNECTOR && /* @__PURE__ */ jsx(
|
|
396
526
|
"div",
|
|
397
527
|
{
|
|
398
528
|
style: {
|
|
399
|
-
|
|
400
|
-
left: centerX,
|
|
401
|
-
top: centerY - guideLength / 2,
|
|
402
|
-
width: 1,
|
|
403
|
-
height: guideLength,
|
|
529
|
+
...rotationHandle.connector.style,
|
|
404
530
|
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
405
|
-
opacity: 0
|
|
406
|
-
pointerEvents: "none"
|
|
531
|
+
opacity: rotationActive ? 0 : 1
|
|
407
532
|
}
|
|
408
533
|
}
|
|
409
534
|
),
|
|
410
535
|
/* @__PURE__ */ jsx(
|
|
411
536
|
"div",
|
|
412
537
|
{
|
|
413
|
-
style: {
|
|
414
|
-
position: "absolute",
|
|
415
|
-
left: centerX - guideLength / 2,
|
|
416
|
-
top: centerY,
|
|
417
|
-
width: guideLength,
|
|
418
|
-
height: 1,
|
|
419
|
-
transformOrigin: "center center",
|
|
420
|
-
transform: `rotate(${annotationRotation}deg)`,
|
|
421
|
-
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
422
|
-
opacity: 0.8,
|
|
423
|
-
pointerEvents: "none"
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
)
|
|
427
|
-
] }),
|
|
428
|
-
isSelected && effectiveIsRotatable && rotationHandle && ((rotationUI == null ? void 0 : rotationUI.component) ? /* @__PURE__ */ jsx(
|
|
429
|
-
"div",
|
|
430
|
-
{
|
|
431
|
-
onPointerEnter: () => setIsHandleHovered(true),
|
|
432
|
-
onPointerLeave: () => {
|
|
433
|
-
setIsHandleHovered(false);
|
|
434
|
-
setCursorScreen(null);
|
|
435
|
-
},
|
|
436
|
-
onPointerMove: (e) => {
|
|
437
|
-
if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });
|
|
438
|
-
},
|
|
439
|
-
style: { display: "contents" },
|
|
440
|
-
children: rotationUI.component({
|
|
441
538
|
...rotationHandle.handle,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
539
|
+
style: {
|
|
540
|
+
...rotationHandle.handle.style,
|
|
541
|
+
backgroundColor: ROTATION_COLOR,
|
|
542
|
+
border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,
|
|
543
|
+
boxSizing: "border-box",
|
|
544
|
+
display: "flex",
|
|
545
|
+
alignItems: "center",
|
|
546
|
+
justifyContent: "center",
|
|
547
|
+
pointerEvents: "auto",
|
|
447
548
|
opacity: rotationActive ? 0 : 1
|
|
448
549
|
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
border: {
|
|
452
|
-
color: ROTATION_BORDER_COLOR,
|
|
453
|
-
width: ROTATION_BORDER_WIDTH,
|
|
454
|
-
style: ROTATION_BORDER_STYLE
|
|
455
|
-
}
|
|
456
|
-
})
|
|
457
|
-
}
|
|
458
|
-
) : /* @__PURE__ */ jsxs(
|
|
459
|
-
"div",
|
|
460
|
-
{
|
|
461
|
-
onPointerEnter: () => setIsHandleHovered(true),
|
|
462
|
-
onPointerLeave: () => {
|
|
463
|
-
setIsHandleHovered(false);
|
|
464
|
-
setCursorScreen(null);
|
|
465
|
-
},
|
|
466
|
-
onPointerMove: (e) => {
|
|
467
|
-
if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });
|
|
468
|
-
},
|
|
469
|
-
style: { display: "contents" },
|
|
470
|
-
children: [
|
|
471
|
-
SHOW_CONNECTOR && /* @__PURE__ */ jsx(
|
|
472
|
-
"div",
|
|
473
|
-
{
|
|
474
|
-
style: {
|
|
475
|
-
...rotationHandle.connector.style,
|
|
476
|
-
backgroundColor: ROTATION_CONNECTOR_COLOR,
|
|
477
|
-
opacity: rotationActive ? 0 : 1
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
),
|
|
481
|
-
/* @__PURE__ */ jsx(
|
|
482
|
-
"div",
|
|
483
|
-
{
|
|
484
|
-
...rotationHandle.handle,
|
|
485
|
-
style: {
|
|
486
|
-
...rotationHandle.handle.style,
|
|
487
|
-
backgroundColor: ROTATION_COLOR,
|
|
488
|
-
border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,
|
|
489
|
-
boxSizing: "border-box",
|
|
490
|
-
display: "flex",
|
|
491
|
-
alignItems: "center",
|
|
492
|
-
justifyContent: "center",
|
|
493
|
-
pointerEvents: "auto",
|
|
494
|
-
opacity: rotationActive ? 0 : 1
|
|
495
|
-
},
|
|
496
|
-
children: /* @__PURE__ */ jsxs(
|
|
497
|
-
"svg",
|
|
498
|
-
{
|
|
499
|
-
width: Math.round(ROTATION_SIZE * 0.6),
|
|
500
|
-
height: Math.round(ROTATION_SIZE * 0.6),
|
|
501
|
-
viewBox: "0 0 24 24",
|
|
502
|
-
fill: "none",
|
|
503
|
-
stroke: ROTATION_ICON_COLOR,
|
|
504
|
-
strokeWidth: "2",
|
|
505
|
-
strokeLinecap: "round",
|
|
506
|
-
strokeLinejoin: "round",
|
|
507
|
-
children: [
|
|
508
|
-
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }),
|
|
509
|
-
/* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" })
|
|
510
|
-
]
|
|
511
|
-
}
|
|
512
|
-
)
|
|
513
|
-
}
|
|
514
|
-
)
|
|
515
|
-
]
|
|
516
|
-
}
|
|
517
|
-
)),
|
|
518
|
-
/* @__PURE__ */ jsxs(
|
|
519
|
-
"div",
|
|
520
|
-
{
|
|
521
|
-
...effectiveIsDraggable && isSelected ? dragProps : {},
|
|
522
|
-
...doubleProps,
|
|
523
|
-
style: {
|
|
524
|
-
position: "absolute",
|
|
525
|
-
left: innerLeft,
|
|
526
|
-
top: innerTop,
|
|
527
|
-
width: innerWidth,
|
|
528
|
-
height: innerHeight,
|
|
529
|
-
transform: annotationRotation !== 0 ? `rotate(${annotationRotation}deg)` : void 0,
|
|
530
|
-
transformOrigin: innerTransformOrigin,
|
|
531
|
-
outline: showOutline ? `${outlineWidth}px ${outlineStyle} ${outlineColor}` : "none",
|
|
532
|
-
outlineOffset: showOutline ? `${outlineOff}px` : "0px",
|
|
533
|
-
pointerEvents: isSelected && !isMultiSelected ? "auto" : "none",
|
|
534
|
-
touchAction: "none",
|
|
535
|
-
cursor: isSelected && effectiveIsDraggable ? "move" : "default"
|
|
536
|
-
},
|
|
537
|
-
children: [
|
|
538
|
-
(() => {
|
|
539
|
-
const childrenRender = typeof children === "function" ? children(childObject, { appearanceActive: apActive }) : children;
|
|
540
|
-
const customRender = customAnnotationRenderer == null ? void 0 : customAnnotationRenderer({
|
|
541
|
-
annotation: childObject,
|
|
542
|
-
children: childrenRender,
|
|
543
|
-
isSelected,
|
|
544
|
-
scale,
|
|
545
|
-
rotation,
|
|
546
|
-
pageWidth,
|
|
547
|
-
pageHeight,
|
|
548
|
-
pageIndex,
|
|
549
|
-
onSelect
|
|
550
|
-
});
|
|
551
|
-
return customRender ?? childrenRender;
|
|
552
|
-
})(),
|
|
553
|
-
(appearance == null ? void 0 : appearance.normal) && /* @__PURE__ */ jsx(
|
|
554
|
-
AppearanceImage,
|
|
550
|
+
children: /* @__PURE__ */ jsxs(
|
|
551
|
+
"svg",
|
|
555
552
|
{
|
|
556
|
-
|
|
557
|
-
|
|
553
|
+
width: Math.round(ROTATION_SIZE * 0.6),
|
|
554
|
+
height: Math.round(ROTATION_SIZE * 0.6),
|
|
555
|
+
viewBox: "0 0 24 24",
|
|
556
|
+
fill: "none",
|
|
557
|
+
stroke: ROTATION_ICON_COLOR,
|
|
558
|
+
strokeWidth: "2",
|
|
559
|
+
strokeLinecap: "round",
|
|
560
|
+
strokeLinejoin: "round",
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }),
|
|
563
|
+
/* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" })
|
|
564
|
+
]
|
|
558
565
|
}
|
|
559
|
-
),
|
|
560
|
-
isSelected && effectiveIsResizable && !rotationActive && resize.map(
|
|
561
|
-
({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
|
|
562
|
-
key,
|
|
563
|
-
...hProps,
|
|
564
|
-
backgroundColor: HANDLE_COLOR
|
|
565
|
-
}) : /* @__PURE__ */ jsx(
|
|
566
|
-
"div",
|
|
567
|
-
{
|
|
568
|
-
...hProps,
|
|
569
|
-
style: { ...hProps.style, backgroundColor: HANDLE_COLOR }
|
|
570
|
-
},
|
|
571
|
-
key
|
|
572
|
-
)
|
|
573
|
-
),
|
|
574
|
-
isSelected && canModifyAnnotations && !isMultiSelected && !rotationActive && vertices.map(
|
|
575
|
-
({ key, ...vProps }) => (vertexUI == null ? void 0 : vertexUI.component) ? vertexUI.component({
|
|
576
|
-
key,
|
|
577
|
-
...vProps,
|
|
578
|
-
backgroundColor: VERTEX_COLOR
|
|
579
|
-
}) : /* @__PURE__ */ jsx(
|
|
580
|
-
"div",
|
|
581
|
-
{
|
|
582
|
-
...vProps,
|
|
583
|
-
style: { ...vProps.style, backgroundColor: VERTEX_COLOR }
|
|
584
|
-
},
|
|
585
|
-
key
|
|
586
|
-
)
|
|
587
566
|
)
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
)),
|
|
572
|
+
/* @__PURE__ */ jsxs(
|
|
573
|
+
"div",
|
|
574
|
+
{
|
|
575
|
+
...effectiveIsDraggable && isSelected ? dragProps : {},
|
|
576
|
+
...doubleProps,
|
|
577
|
+
style: {
|
|
578
|
+
...innerDivBaseStyle,
|
|
579
|
+
outline: showOutline ? `${outlineWidth}px ${outlineStyle} ${outlineColor}` : "none",
|
|
580
|
+
outlineOffset: showOutline ? `${outlineOff}px` : "0px",
|
|
581
|
+
pointerEvents: isSelected && !isMultiSelected ? "auto" : "none",
|
|
582
|
+
touchAction: "none",
|
|
583
|
+
cursor: isSelected && effectiveIsDraggable ? "move" : "default"
|
|
584
|
+
},
|
|
585
|
+
children: [
|
|
586
|
+
isSelected && effectiveIsResizable && !rotationActive && resize.map(
|
|
587
|
+
({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
|
|
588
|
+
key,
|
|
589
|
+
...hProps,
|
|
590
|
+
backgroundColor: HANDLE_COLOR
|
|
591
|
+
}) : /* @__PURE__ */ jsx(
|
|
592
|
+
"div",
|
|
593
|
+
{
|
|
594
|
+
...hProps,
|
|
595
|
+
style: { ...hProps.style, backgroundColor: HANDLE_COLOR }
|
|
596
|
+
},
|
|
597
|
+
key
|
|
598
|
+
)
|
|
599
|
+
),
|
|
600
|
+
isSelected && canModifyAnnotations && !isMultiSelected && !rotationActive && vertices.map(
|
|
601
|
+
({ key, ...vProps }) => (vertexUI == null ? void 0 : vertexUI.component) ? vertexUI.component({
|
|
602
|
+
key,
|
|
603
|
+
...vProps,
|
|
604
|
+
backgroundColor: VERTEX_COLOR
|
|
605
|
+
}) : /* @__PURE__ */ jsx(
|
|
606
|
+
"div",
|
|
607
|
+
{
|
|
608
|
+
...vProps,
|
|
609
|
+
style: { ...vProps.style, backgroundColor: VERTEX_COLOR }
|
|
610
|
+
},
|
|
611
|
+
key
|
|
612
|
+
)
|
|
613
|
+
)
|
|
614
|
+
]
|
|
615
|
+
}
|
|
616
|
+
)
|
|
617
|
+
] }),
|
|
594
618
|
selectionMenu && !isMultiSelected && !rotationActive && /* @__PURE__ */ jsx(
|
|
595
619
|
CounterRotate,
|
|
596
620
|
{
|
|
@@ -600,13 +624,13 @@ function AnnotationContainer({
|
|
|
600
624
|
y: currentObject.rect.origin.y * scale
|
|
601
625
|
},
|
|
602
626
|
size: {
|
|
603
|
-
width: currentObject.rect.size.width *
|
|
604
|
-
height: currentObject.rect.size.height *
|
|
627
|
+
width: currentObject.rect.size.width * visualScale,
|
|
628
|
+
height: currentObject.rect.size.height * visualScale
|
|
605
629
|
}
|
|
606
630
|
},
|
|
607
631
|
rotation,
|
|
608
632
|
children: (counterRotateProps) => {
|
|
609
|
-
const effectiveAngle = ((annotationRotation +
|
|
633
|
+
const effectiveAngle = ((annotationRotation + effectivePageRotation * 90) % 360 + 360) % 360;
|
|
610
634
|
const handleNearMenuSide = effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;
|
|
611
635
|
return selectionMenu({
|
|
612
636
|
...counterRotateProps,
|
|
@@ -651,6 +675,57 @@ function AnnotationContainer({
|
|
|
651
675
|
)
|
|
652
676
|
] });
|
|
653
677
|
}
|
|
678
|
+
function mapCounterRotatePoint(x, y, width, height, rotation) {
|
|
679
|
+
switch (rotation) {
|
|
680
|
+
case 1:
|
|
681
|
+
return { x: y, y: height - x };
|
|
682
|
+
case 2:
|
|
683
|
+
return { x: width - x, y: height - y };
|
|
684
|
+
case 3:
|
|
685
|
+
return { x: width - y, y: x };
|
|
686
|
+
default:
|
|
687
|
+
return { x, y };
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function getAnnotationScreenBounds(annotation, scale, rotation) {
|
|
691
|
+
const flags = annotation.object.flags ?? [];
|
|
692
|
+
const hasNoZoom = flags.includes("noZoom");
|
|
693
|
+
const hasNoRotate = flags.includes("noRotate");
|
|
694
|
+
const left = annotation.object.rect.origin.x * scale;
|
|
695
|
+
const top = annotation.object.rect.origin.y * scale;
|
|
696
|
+
const width = annotation.object.rect.size.width * (hasNoZoom ? 1 : scale);
|
|
697
|
+
const height = annotation.object.rect.size.height * (hasNoZoom ? 1 : scale);
|
|
698
|
+
if (!hasNoRotate || rotation === 0) {
|
|
699
|
+
return {
|
|
700
|
+
left,
|
|
701
|
+
top,
|
|
702
|
+
right: left + width,
|
|
703
|
+
bottom: top + height
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
const corners = [
|
|
707
|
+
mapCounterRotatePoint(0, 0, width, height, rotation),
|
|
708
|
+
mapCounterRotatePoint(width, 0, width, height, rotation),
|
|
709
|
+
mapCounterRotatePoint(0, height, width, height, rotation),
|
|
710
|
+
mapCounterRotatePoint(width, height, width, height, rotation)
|
|
711
|
+
];
|
|
712
|
+
let minX = Infinity;
|
|
713
|
+
let minY = Infinity;
|
|
714
|
+
let maxX = -Infinity;
|
|
715
|
+
let maxY = -Infinity;
|
|
716
|
+
for (const corner of corners) {
|
|
717
|
+
if (corner.x < minX) minX = corner.x;
|
|
718
|
+
if (corner.y < minY) minY = corner.y;
|
|
719
|
+
if (corner.x > maxX) maxX = corner.x;
|
|
720
|
+
if (corner.y > maxY) maxY = corner.y;
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
left: left + minX,
|
|
724
|
+
top: top + minY,
|
|
725
|
+
right: left + maxX,
|
|
726
|
+
bottom: top + maxY
|
|
727
|
+
};
|
|
728
|
+
}
|
|
654
729
|
function GroupSelectionBox({
|
|
655
730
|
documentId,
|
|
656
731
|
pageIndex,
|
|
@@ -858,8 +933,29 @@ function GroupSelectionBox({
|
|
|
858
933
|
if (selectedAnnotations.length < 2) {
|
|
859
934
|
return null;
|
|
860
935
|
}
|
|
861
|
-
|
|
862
|
-
|
|
936
|
+
let visualLeft = Infinity;
|
|
937
|
+
let visualTop = Infinity;
|
|
938
|
+
let visualRight = -Infinity;
|
|
939
|
+
let visualBottom = -Infinity;
|
|
940
|
+
for (const ta of selectedAnnotations) {
|
|
941
|
+
const bounds = getAnnotationScreenBounds(ta, scale, rotation);
|
|
942
|
+
visualLeft = Math.min(visualLeft, bounds.left);
|
|
943
|
+
visualTop = Math.min(visualTop, bounds.top);
|
|
944
|
+
visualRight = Math.max(visualRight, bounds.right);
|
|
945
|
+
visualBottom = Math.max(visualBottom, bounds.bottom);
|
|
946
|
+
}
|
|
947
|
+
const initialLogicalLeft = groupBox.origin.x * scale;
|
|
948
|
+
const initialLogicalTop = groupBox.origin.y * scale;
|
|
949
|
+
const initialLogicalRight = (groupBox.origin.x + groupBox.size.width) * scale;
|
|
950
|
+
const initialLogicalBottom = (groupBox.origin.y + groupBox.size.height) * scale;
|
|
951
|
+
const leftCorrection = visualLeft - initialLogicalLeft;
|
|
952
|
+
const topCorrection = visualTop - initialLogicalTop;
|
|
953
|
+
const rightCorrection = visualRight - initialLogicalRight;
|
|
954
|
+
const bottomCorrection = visualBottom - initialLogicalBottom;
|
|
955
|
+
const groupBoxLeft = previewGroupBox.origin.x * scale + leftCorrection;
|
|
956
|
+
const groupBoxTop = previewGroupBox.origin.y * scale + topCorrection;
|
|
957
|
+
const groupBoxWidth = previewGroupBox.size.width * scale + (rightCorrection - leftCorrection);
|
|
958
|
+
const groupBoxHeight = previewGroupBox.size.height * scale + (bottomCorrection - topCorrection);
|
|
863
959
|
const groupCenterX = groupBoxWidth / 2;
|
|
864
960
|
const groupCenterY = groupBoxHeight / 2;
|
|
865
961
|
const groupGuideLength = Math.max(300, Math.max(groupBoxWidth, groupBoxHeight) + 80);
|
|
@@ -869,8 +965,8 @@ function GroupSelectionBox({
|
|
|
869
965
|
{
|
|
870
966
|
style: {
|
|
871
967
|
position: "absolute",
|
|
872
|
-
left:
|
|
873
|
-
top:
|
|
968
|
+
left: groupBoxLeft,
|
|
969
|
+
top: groupBoxTop,
|
|
874
970
|
width: groupBoxWidth,
|
|
875
971
|
height: groupBoxHeight,
|
|
876
972
|
pointerEvents: "none",
|
|
@@ -1079,17 +1175,17 @@ function GroupSelectionBox({
|
|
|
1079
1175
|
),
|
|
1080
1176
|
document.body
|
|
1081
1177
|
),
|
|
1082
|
-
groupSelectionMenu && /* @__PURE__ */ jsx(
|
|
1178
|
+
groupSelectionMenu && !rotationActive && /* @__PURE__ */ jsx(
|
|
1083
1179
|
CounterRotate,
|
|
1084
1180
|
{
|
|
1085
1181
|
rect: {
|
|
1086
1182
|
origin: {
|
|
1087
|
-
x:
|
|
1088
|
-
y:
|
|
1183
|
+
x: groupBoxLeft,
|
|
1184
|
+
y: groupBoxTop
|
|
1089
1185
|
},
|
|
1090
1186
|
size: {
|
|
1091
|
-
width:
|
|
1092
|
-
height:
|
|
1187
|
+
width: groupBoxWidth,
|
|
1188
|
+
height: groupBoxHeight
|
|
1093
1189
|
}
|
|
1094
1190
|
},
|
|
1095
1191
|
rotation,
|
|
@@ -1120,6 +1216,7 @@ function createRenderer(entry) {
|
|
|
1120
1216
|
render: (props) => entry.render(props),
|
|
1121
1217
|
vertexConfig: entry.vertexConfig,
|
|
1122
1218
|
zIndex: entry.zIndex,
|
|
1219
|
+
defaultBlendMode: entry.defaultBlendMode,
|
|
1123
1220
|
containerStyle: entry.containerStyle,
|
|
1124
1221
|
interactionDefaults: entry.interactionDefaults,
|
|
1125
1222
|
useAppearanceStream: entry.useAppearanceStream,
|
|
@@ -1179,7 +1276,6 @@ function Ink({
|
|
|
1179
1276
|
stroke: "transparent",
|
|
1180
1277
|
strokeWidth: hitStrokeWidth,
|
|
1181
1278
|
onPointerDown: onClick,
|
|
1182
|
-
onTouchStart: onClick,
|
|
1183
1279
|
style: {
|
|
1184
1280
|
cursor: isSelected ? "move" : "pointer",
|
|
1185
1281
|
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
@@ -1221,8 +1317,11 @@ function Square({
|
|
|
1221
1317
|
rect,
|
|
1222
1318
|
scale,
|
|
1223
1319
|
onClick,
|
|
1224
|
-
appearanceActive = false
|
|
1320
|
+
appearanceActive = false,
|
|
1321
|
+
cloudyBorderIntensity,
|
|
1322
|
+
rectangleDifferences
|
|
1225
1323
|
}) {
|
|
1324
|
+
const isCloudy = (cloudyBorderIntensity ?? 0) > 0;
|
|
1226
1325
|
const { width, height, x, y } = useMemo(() => {
|
|
1227
1326
|
const outerW = rect.size.width;
|
|
1228
1327
|
const outerH = rect.size.height;
|
|
@@ -1235,8 +1334,17 @@ function Square({
|
|
|
1235
1334
|
y: strokeWidth / 2
|
|
1236
1335
|
};
|
|
1237
1336
|
}, [rect, strokeWidth]);
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1337
|
+
const cloudyPath = useMemo(() => {
|
|
1338
|
+
if (!isCloudy) return null;
|
|
1339
|
+
return generateCloudyRectanglePath(
|
|
1340
|
+
{ x: 0, y: 0, width: rect.size.width, height: rect.size.height },
|
|
1341
|
+
rectangleDifferences,
|
|
1342
|
+
cloudyBorderIntensity,
|
|
1343
|
+
strokeWidth
|
|
1344
|
+
);
|
|
1345
|
+
}, [isCloudy, rect, rectangleDifferences, cloudyBorderIntensity, strokeWidth]);
|
|
1346
|
+
const svgWidth = rect.size.width * scale;
|
|
1347
|
+
const svgHeight = rect.size.height * scale;
|
|
1240
1348
|
const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$4 / scale);
|
|
1241
1349
|
return /* @__PURE__ */ jsxs(
|
|
1242
1350
|
"svg",
|
|
@@ -1250,10 +1358,23 @@ function Square({
|
|
|
1250
1358
|
},
|
|
1251
1359
|
width: svgWidth,
|
|
1252
1360
|
height: svgHeight,
|
|
1253
|
-
viewBox: `0 0 ${width
|
|
1361
|
+
viewBox: `0 0 ${rect.size.width} ${rect.size.height}`,
|
|
1254
1362
|
overflow: "visible",
|
|
1255
1363
|
children: [
|
|
1256
|
-
/* @__PURE__ */ jsx(
|
|
1364
|
+
isCloudy && cloudyPath ? /* @__PURE__ */ jsx(
|
|
1365
|
+
"path",
|
|
1366
|
+
{
|
|
1367
|
+
d: cloudyPath.path,
|
|
1368
|
+
fill: "transparent",
|
|
1369
|
+
stroke: "transparent",
|
|
1370
|
+
strokeWidth: hitStrokeWidth,
|
|
1371
|
+
onPointerDown: onClick,
|
|
1372
|
+
style: {
|
|
1373
|
+
cursor: isSelected ? "move" : "pointer",
|
|
1374
|
+
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
) : /* @__PURE__ */ jsx(
|
|
1257
1378
|
"rect",
|
|
1258
1379
|
{
|
|
1259
1380
|
x,
|
|
@@ -1264,14 +1385,26 @@ function Square({
|
|
|
1264
1385
|
stroke: "transparent",
|
|
1265
1386
|
strokeWidth: hitStrokeWidth,
|
|
1266
1387
|
onPointerDown: onClick,
|
|
1267
|
-
onTouchStart: onClick,
|
|
1268
1388
|
style: {
|
|
1269
1389
|
cursor: isSelected ? "move" : "pointer",
|
|
1270
1390
|
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1271
1391
|
}
|
|
1272
1392
|
}
|
|
1273
1393
|
),
|
|
1274
|
-
!appearanceActive && /* @__PURE__ */ jsx(
|
|
1394
|
+
!appearanceActive && (isCloudy && cloudyPath ? /* @__PURE__ */ jsx(
|
|
1395
|
+
"path",
|
|
1396
|
+
{
|
|
1397
|
+
d: cloudyPath.path,
|
|
1398
|
+
fill: color,
|
|
1399
|
+
opacity,
|
|
1400
|
+
style: {
|
|
1401
|
+
pointerEvents: "none",
|
|
1402
|
+
stroke: strokeColor ?? color,
|
|
1403
|
+
strokeWidth,
|
|
1404
|
+
strokeLinejoin: "round"
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
) : /* @__PURE__ */ jsx(
|
|
1275
1408
|
"rect",
|
|
1276
1409
|
{
|
|
1277
1410
|
x,
|
|
@@ -1289,7 +1422,7 @@ function Square({
|
|
|
1289
1422
|
}
|
|
1290
1423
|
}
|
|
1291
1424
|
}
|
|
1292
|
-
)
|
|
1425
|
+
))
|
|
1293
1426
|
]
|
|
1294
1427
|
}
|
|
1295
1428
|
);
|
|
@@ -1306,8 +1439,11 @@ function Circle({
|
|
|
1306
1439
|
scale,
|
|
1307
1440
|
onClick,
|
|
1308
1441
|
isSelected,
|
|
1309
|
-
appearanceActive = false
|
|
1442
|
+
appearanceActive = false,
|
|
1443
|
+
cloudyBorderIntensity,
|
|
1444
|
+
rectangleDifferences
|
|
1310
1445
|
}) {
|
|
1446
|
+
const isCloudy = (cloudyBorderIntensity ?? 0) > 0;
|
|
1311
1447
|
const { width, height, cx, cy, rx, ry } = useMemo(() => {
|
|
1312
1448
|
const outerW = rect.size.width;
|
|
1313
1449
|
const outerH = rect.size.height;
|
|
@@ -1322,6 +1458,15 @@ function Circle({
|
|
|
1322
1458
|
ry: innerH / 2
|
|
1323
1459
|
};
|
|
1324
1460
|
}, [rect, strokeWidth]);
|
|
1461
|
+
const cloudyPath = useMemo(() => {
|
|
1462
|
+
if (!isCloudy) return null;
|
|
1463
|
+
return generateCloudyEllipsePath(
|
|
1464
|
+
{ x: 0, y: 0, width: rect.size.width, height: rect.size.height },
|
|
1465
|
+
rectangleDifferences,
|
|
1466
|
+
cloudyBorderIntensity,
|
|
1467
|
+
strokeWidth
|
|
1468
|
+
);
|
|
1469
|
+
}, [isCloudy, rect, rectangleDifferences, cloudyBorderIntensity, strokeWidth]);
|
|
1325
1470
|
const svgWidth = width * scale;
|
|
1326
1471
|
const svgHeight = height * scale;
|
|
1327
1472
|
const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$3 / scale);
|
|
@@ -1340,7 +1485,20 @@ function Circle({
|
|
|
1340
1485
|
viewBox: `0 0 ${width} ${height}`,
|
|
1341
1486
|
overflow: "visible",
|
|
1342
1487
|
children: [
|
|
1343
|
-
/* @__PURE__ */ jsx(
|
|
1488
|
+
isCloudy && cloudyPath ? /* @__PURE__ */ jsx(
|
|
1489
|
+
"path",
|
|
1490
|
+
{
|
|
1491
|
+
d: cloudyPath.path,
|
|
1492
|
+
fill: "transparent",
|
|
1493
|
+
stroke: "transparent",
|
|
1494
|
+
strokeWidth: hitStrokeWidth,
|
|
1495
|
+
onPointerDown: onClick,
|
|
1496
|
+
style: {
|
|
1497
|
+
cursor: isSelected ? "move" : "pointer",
|
|
1498
|
+
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
) : /* @__PURE__ */ jsx(
|
|
1344
1502
|
"ellipse",
|
|
1345
1503
|
{
|
|
1346
1504
|
cx,
|
|
@@ -1351,14 +1509,26 @@ function Circle({
|
|
|
1351
1509
|
stroke: "transparent",
|
|
1352
1510
|
strokeWidth: hitStrokeWidth,
|
|
1353
1511
|
onPointerDown: onClick,
|
|
1354
|
-
onTouchStart: onClick,
|
|
1355
1512
|
style: {
|
|
1356
1513
|
cursor: isSelected ? "move" : "pointer",
|
|
1357
1514
|
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1358
1515
|
}
|
|
1359
1516
|
}
|
|
1360
1517
|
),
|
|
1361
|
-
!appearanceActive && /* @__PURE__ */ jsx(
|
|
1518
|
+
!appearanceActive && (isCloudy && cloudyPath ? /* @__PURE__ */ jsx(
|
|
1519
|
+
"path",
|
|
1520
|
+
{
|
|
1521
|
+
d: cloudyPath.path,
|
|
1522
|
+
fill: color,
|
|
1523
|
+
opacity,
|
|
1524
|
+
style: {
|
|
1525
|
+
pointerEvents: "none",
|
|
1526
|
+
stroke: strokeColor ?? color,
|
|
1527
|
+
strokeWidth,
|
|
1528
|
+
strokeLinejoin: "round"
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
) : /* @__PURE__ */ jsx(
|
|
1362
1532
|
"ellipse",
|
|
1363
1533
|
{
|
|
1364
1534
|
cx,
|
|
@@ -1376,7 +1546,7 @@ function Circle({
|
|
|
1376
1546
|
}
|
|
1377
1547
|
}
|
|
1378
1548
|
}
|
|
1379
|
-
)
|
|
1549
|
+
))
|
|
1380
1550
|
]
|
|
1381
1551
|
}
|
|
1382
1552
|
);
|
|
@@ -1440,7 +1610,6 @@ function Line({
|
|
|
1440
1610
|
stroke: "transparent",
|
|
1441
1611
|
strokeWidth: hitStrokeWidth,
|
|
1442
1612
|
onPointerDown: onClick,
|
|
1443
|
-
onTouchStart: onClick,
|
|
1444
1613
|
style: {
|
|
1445
1614
|
cursor: isSelected ? "move" : "pointer",
|
|
1446
1615
|
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
@@ -1457,7 +1626,6 @@ function Line({
|
|
|
1457
1626
|
stroke: "transparent",
|
|
1458
1627
|
strokeWidth: hitStrokeWidth,
|
|
1459
1628
|
onPointerDown: onClick,
|
|
1460
|
-
onTouchStart: onClick,
|
|
1461
1629
|
style: {
|
|
1462
1630
|
cursor: isSelected ? "move" : "pointer",
|
|
1463
1631
|
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
@@ -1474,7 +1642,6 @@ function Line({
|
|
|
1474
1642
|
stroke: "transparent",
|
|
1475
1643
|
strokeWidth: hitStrokeWidth,
|
|
1476
1644
|
onPointerDown: onClick,
|
|
1477
|
-
onTouchStart: onClick,
|
|
1478
1645
|
style: {
|
|
1479
1646
|
cursor: isSelected ? "move" : "pointer",
|
|
1480
1647
|
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
@@ -1549,6 +1716,8 @@ function Polyline({
|
|
|
1549
1716
|
strokeColor = "#000000",
|
|
1550
1717
|
opacity = 1,
|
|
1551
1718
|
strokeWidth,
|
|
1719
|
+
strokeStyle = PdfAnnotationBorderStyle.SOLID,
|
|
1720
|
+
strokeDashArray,
|
|
1552
1721
|
scale,
|
|
1553
1722
|
isSelected,
|
|
1554
1723
|
onClick,
|
|
@@ -1611,7 +1780,6 @@ function Polyline({
|
|
|
1611
1780
|
stroke: "transparent",
|
|
1612
1781
|
strokeWidth: hitStrokeWidth,
|
|
1613
1782
|
onPointerDown: onClick,
|
|
1614
|
-
onTouchStart: onClick,
|
|
1615
1783
|
style: {
|
|
1616
1784
|
cursor: isSelected ? "move" : "pointer",
|
|
1617
1785
|
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
@@ -1629,7 +1797,6 @@ function Polyline({
|
|
|
1629
1797
|
stroke: "transparent",
|
|
1630
1798
|
strokeWidth: hitStrokeWidth,
|
|
1631
1799
|
onPointerDown: onClick,
|
|
1632
|
-
onTouchStart: onClick,
|
|
1633
1800
|
style: {
|
|
1634
1801
|
cursor: isSelected ? "move" : "pointer",
|
|
1635
1802
|
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
@@ -1646,7 +1813,6 @@ function Polyline({
|
|
|
1646
1813
|
stroke: "transparent",
|
|
1647
1814
|
strokeWidth: hitStrokeWidth,
|
|
1648
1815
|
onPointerDown: onClick,
|
|
1649
|
-
onTouchStart: onClick,
|
|
1650
1816
|
style: {
|
|
1651
1817
|
cursor: isSelected ? "move" : "pointer",
|
|
1652
1818
|
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
@@ -1666,7 +1832,10 @@ function Polyline({
|
|
|
1666
1832
|
strokeWidth,
|
|
1667
1833
|
pointerEvents: "none",
|
|
1668
1834
|
strokeLinecap: "butt",
|
|
1669
|
-
strokeLinejoin: "miter"
|
|
1835
|
+
strokeLinejoin: "miter",
|
|
1836
|
+
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
1837
|
+
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
1838
|
+
}
|
|
1670
1839
|
}
|
|
1671
1840
|
}
|
|
1672
1841
|
),
|
|
@@ -1680,7 +1849,10 @@ function Polyline({
|
|
|
1680
1849
|
style: {
|
|
1681
1850
|
pointerEvents: "none",
|
|
1682
1851
|
strokeWidth,
|
|
1683
|
-
strokeLinecap: "butt"
|
|
1852
|
+
strokeLinecap: "butt",
|
|
1853
|
+
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
1854
|
+
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
1855
|
+
}
|
|
1684
1856
|
}
|
|
1685
1857
|
}
|
|
1686
1858
|
),
|
|
@@ -1694,7 +1866,10 @@ function Polyline({
|
|
|
1694
1866
|
style: {
|
|
1695
1867
|
pointerEvents: "none",
|
|
1696
1868
|
strokeWidth,
|
|
1697
|
-
strokeLinecap: "butt"
|
|
1869
|
+
strokeLinecap: "butt",
|
|
1870
|
+
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
1871
|
+
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
1872
|
+
}
|
|
1698
1873
|
}
|
|
1699
1874
|
}
|
|
1700
1875
|
)
|
|
@@ -1718,8 +1893,10 @@ function Polygon({
|
|
|
1718
1893
|
onClick,
|
|
1719
1894
|
currentVertex,
|
|
1720
1895
|
handleSize = 14,
|
|
1721
|
-
appearanceActive = false
|
|
1896
|
+
appearanceActive = false,
|
|
1897
|
+
cloudyBorderIntensity
|
|
1722
1898
|
}) {
|
|
1899
|
+
const isCloudy = (cloudyBorderIntensity ?? 0) > 0;
|
|
1723
1900
|
const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;
|
|
1724
1901
|
const localPts = useMemo(
|
|
1725
1902
|
() => allPoints.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),
|
|
@@ -1731,6 +1908,10 @@ function Polygon({
|
|
|
1731
1908
|
const isPreview = !!currentVertex;
|
|
1732
1909
|
return (`M ${first.x} ${first.y} ` + rest.map((p) => `L ${p.x} ${p.y}`).join(" ") + (isPreview ? "" : " Z")).trim();
|
|
1733
1910
|
}, [localPts, currentVertex]);
|
|
1911
|
+
const cloudyPath = useMemo(() => {
|
|
1912
|
+
if (!isCloudy || allPoints.length < 3) return null;
|
|
1913
|
+
return generateCloudyPolygonPath(allPoints, rect.origin, cloudyBorderIntensity, strokeWidth);
|
|
1914
|
+
}, [isCloudy, allPoints, rect.origin, cloudyBorderIntensity, strokeWidth]);
|
|
1734
1915
|
const isPreviewing = currentVertex && vertices.length > 0;
|
|
1735
1916
|
const width = rect.size.width * scale;
|
|
1736
1917
|
const height = rect.size.height * scale;
|
|
@@ -1753,12 +1934,11 @@ function Polygon({
|
|
|
1753
1934
|
/* @__PURE__ */ jsx(
|
|
1754
1935
|
"path",
|
|
1755
1936
|
{
|
|
1756
|
-
d: pathData,
|
|
1937
|
+
d: isCloudy && cloudyPath ? cloudyPath.path : pathData,
|
|
1757
1938
|
fill: "transparent",
|
|
1758
1939
|
stroke: "transparent",
|
|
1759
1940
|
strokeWidth: hitStrokeWidth,
|
|
1760
1941
|
onPointerDown: onClick,
|
|
1761
|
-
onTouchStart: onClick,
|
|
1762
1942
|
style: {
|
|
1763
1943
|
cursor: isSelected ? "move" : "pointer",
|
|
1764
1944
|
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
@@ -1767,7 +1947,20 @@ function Polygon({
|
|
|
1767
1947
|
}
|
|
1768
1948
|
}
|
|
1769
1949
|
),
|
|
1770
|
-
!appearanceActive && /* @__PURE__ */
|
|
1950
|
+
!appearanceActive && /* @__PURE__ */ jsx(Fragment, { children: isCloudy && cloudyPath ? /* @__PURE__ */ jsx(
|
|
1951
|
+
"path",
|
|
1952
|
+
{
|
|
1953
|
+
d: cloudyPath.path,
|
|
1954
|
+
opacity,
|
|
1955
|
+
style: {
|
|
1956
|
+
fill: color,
|
|
1957
|
+
stroke: strokeColor ?? color,
|
|
1958
|
+
strokeWidth,
|
|
1959
|
+
pointerEvents: "none",
|
|
1960
|
+
strokeLinejoin: "round"
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1771
1964
|
/* @__PURE__ */ jsx(
|
|
1772
1965
|
"path",
|
|
1773
1966
|
{
|
|
@@ -1814,11 +2007,62 @@ function Polygon({
|
|
|
1814
2007
|
style: { pointerEvents: "none" }
|
|
1815
2008
|
}
|
|
1816
2009
|
)
|
|
1817
|
-
] })
|
|
2010
|
+
] }) })
|
|
1818
2011
|
]
|
|
1819
2012
|
}
|
|
1820
2013
|
);
|
|
1821
2014
|
}
|
|
2015
|
+
function Text({
|
|
2016
|
+
isSelected,
|
|
2017
|
+
color = "#facc15",
|
|
2018
|
+
opacity = 1,
|
|
2019
|
+
onClick,
|
|
2020
|
+
appearanceActive = false
|
|
2021
|
+
}) {
|
|
2022
|
+
const lineColor = getContrastStrokeColor(color);
|
|
2023
|
+
return /* @__PURE__ */ jsx(
|
|
2024
|
+
"div",
|
|
2025
|
+
{
|
|
2026
|
+
style: {
|
|
2027
|
+
position: "absolute",
|
|
2028
|
+
inset: 0,
|
|
2029
|
+
zIndex: 2,
|
|
2030
|
+
pointerEvents: isSelected ? "none" : "auto",
|
|
2031
|
+
cursor: isSelected ? "move" : "pointer"
|
|
2032
|
+
},
|
|
2033
|
+
onPointerDown: onClick,
|
|
2034
|
+
children: !appearanceActive && /* @__PURE__ */ jsxs(
|
|
2035
|
+
"svg",
|
|
2036
|
+
{
|
|
2037
|
+
style: {
|
|
2038
|
+
position: "absolute",
|
|
2039
|
+
inset: 0,
|
|
2040
|
+
pointerEvents: "none"
|
|
2041
|
+
},
|
|
2042
|
+
viewBox: "0 0 20 20",
|
|
2043
|
+
width: "100%",
|
|
2044
|
+
height: "100%",
|
|
2045
|
+
children: [
|
|
2046
|
+
/* @__PURE__ */ jsx(
|
|
2047
|
+
"path",
|
|
2048
|
+
{
|
|
2049
|
+
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",
|
|
2050
|
+
fill: color,
|
|
2051
|
+
opacity,
|
|
2052
|
+
stroke: lineColor,
|
|
2053
|
+
strokeWidth: "1",
|
|
2054
|
+
strokeLinejoin: "miter"
|
|
2055
|
+
}
|
|
2056
|
+
),
|
|
2057
|
+
/* @__PURE__ */ jsx("line", { x1: "2.5", y1: "4.25", x2: "17.5", y2: "4.25", stroke: lineColor, strokeWidth: "1" }),
|
|
2058
|
+
/* @__PURE__ */ jsx("line", { x1: "2.5", y1: "8", x2: "17.5", y2: "8", stroke: lineColor, strokeWidth: "1" }),
|
|
2059
|
+
/* @__PURE__ */ jsx("line", { x1: "2.5", y1: "11.75", x2: "17.5", y2: "11.75", stroke: lineColor, strokeWidth: "1" })
|
|
2060
|
+
]
|
|
2061
|
+
}
|
|
2062
|
+
)
|
|
2063
|
+
}
|
|
2064
|
+
);
|
|
2065
|
+
}
|
|
1822
2066
|
function FreeText({
|
|
1823
2067
|
documentId,
|
|
1824
2068
|
isSelected,
|
|
@@ -1886,7 +2130,6 @@ function FreeText({
|
|
|
1886
2130
|
opacity: appearanceActive ? 0 : 1
|
|
1887
2131
|
},
|
|
1888
2132
|
onPointerDown: onClick,
|
|
1889
|
-
onTouchStart: onClick,
|
|
1890
2133
|
children: /* @__PURE__ */ jsx(
|
|
1891
2134
|
"span",
|
|
1892
2135
|
{
|
|
@@ -2013,7 +2256,6 @@ function Stamp({
|
|
|
2013
2256
|
cursor: "pointer"
|
|
2014
2257
|
},
|
|
2015
2258
|
onPointerDown: onClick,
|
|
2016
|
-
onTouchStart: onClick,
|
|
2017
2259
|
children: /* @__PURE__ */ jsx(
|
|
2018
2260
|
RenderAnnotation,
|
|
2019
2261
|
{
|
|
@@ -2076,7 +2318,6 @@ function Link({
|
|
|
2076
2318
|
height,
|
|
2077
2319
|
fill: "transparent",
|
|
2078
2320
|
onPointerDown: hasIRT ? void 0 : onClick,
|
|
2079
|
-
onTouchStart: hasIRT ? void 0 : onClick,
|
|
2080
2321
|
style: {
|
|
2081
2322
|
cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
|
|
2082
2323
|
pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
|
|
@@ -2138,7 +2379,6 @@ function Highlight({
|
|
|
2138
2379
|
"div",
|
|
2139
2380
|
{
|
|
2140
2381
|
onPointerDown: onClick,
|
|
2141
|
-
onTouchStart: onClick,
|
|
2142
2382
|
style: {
|
|
2143
2383
|
position: "absolute",
|
|
2144
2384
|
left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
|
|
@@ -2172,7 +2412,6 @@ function Underline({
|
|
|
2172
2412
|
"div",
|
|
2173
2413
|
{
|
|
2174
2414
|
onPointerDown: onClick,
|
|
2175
|
-
onTouchStart: onClick,
|
|
2176
2415
|
style: {
|
|
2177
2416
|
position: "absolute",
|
|
2178
2417
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -2220,7 +2459,6 @@ function Strikeout({
|
|
|
2220
2459
|
"div",
|
|
2221
2460
|
{
|
|
2222
2461
|
onPointerDown: onClick,
|
|
2223
|
-
onTouchStart: onClick,
|
|
2224
2462
|
style: {
|
|
2225
2463
|
position: "absolute",
|
|
2226
2464
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -2275,7 +2513,6 @@ function Squiggly({
|
|
|
2275
2513
|
"div",
|
|
2276
2514
|
{
|
|
2277
2515
|
onPointerDown: onClick,
|
|
2278
|
-
onTouchStart: onClick,
|
|
2279
2516
|
style: {
|
|
2280
2517
|
position: "absolute",
|
|
2281
2518
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -2309,6 +2546,74 @@ function Squiggly({
|
|
|
2309
2546
|
i
|
|
2310
2547
|
)) });
|
|
2311
2548
|
}
|
|
2549
|
+
function Caret({
|
|
2550
|
+
isSelected,
|
|
2551
|
+
strokeColor = "#000000",
|
|
2552
|
+
opacity = 1,
|
|
2553
|
+
rect,
|
|
2554
|
+
scale,
|
|
2555
|
+
onClick,
|
|
2556
|
+
appearanceActive = false
|
|
2557
|
+
}) {
|
|
2558
|
+
const { width, height, path } = useMemo(() => {
|
|
2559
|
+
const w = rect.size.width;
|
|
2560
|
+
const h = rect.size.height;
|
|
2561
|
+
const midX = w / 2;
|
|
2562
|
+
const d = [
|
|
2563
|
+
`M 0 ${h}`,
|
|
2564
|
+
`C ${w * 0.27} ${h} ${midX} ${h - h * 0.44} ${midX} 0`,
|
|
2565
|
+
`C ${midX} ${h - h * 0.44} ${w - w * 0.27} ${h} ${w} ${h}`,
|
|
2566
|
+
"Z"
|
|
2567
|
+
].join(" ");
|
|
2568
|
+
return { width: w, height: h, path: d };
|
|
2569
|
+
}, [rect]);
|
|
2570
|
+
const svgWidth = width * scale;
|
|
2571
|
+
const svgHeight = height * scale;
|
|
2572
|
+
return /* @__PURE__ */ jsxs(
|
|
2573
|
+
"svg",
|
|
2574
|
+
{
|
|
2575
|
+
style: {
|
|
2576
|
+
position: "absolute",
|
|
2577
|
+
width: svgWidth,
|
|
2578
|
+
height: svgHeight,
|
|
2579
|
+
pointerEvents: "none",
|
|
2580
|
+
zIndex: 2
|
|
2581
|
+
},
|
|
2582
|
+
width: svgWidth,
|
|
2583
|
+
height: svgHeight,
|
|
2584
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
2585
|
+
overflow: "visible",
|
|
2586
|
+
children: [
|
|
2587
|
+
/* @__PURE__ */ jsx(
|
|
2588
|
+
"path",
|
|
2589
|
+
{
|
|
2590
|
+
d: path,
|
|
2591
|
+
fill: "transparent",
|
|
2592
|
+
stroke: "transparent",
|
|
2593
|
+
strokeWidth: 4,
|
|
2594
|
+
onPointerDown: onClick,
|
|
2595
|
+
style: {
|
|
2596
|
+
cursor: isSelected ? "move" : "pointer",
|
|
2597
|
+
pointerEvents: isSelected ? "none" : "visible"
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
),
|
|
2601
|
+
!appearanceActive && /* @__PURE__ */ jsx(
|
|
2602
|
+
"path",
|
|
2603
|
+
{
|
|
2604
|
+
d: path,
|
|
2605
|
+
fill: strokeColor,
|
|
2606
|
+
stroke: strokeColor,
|
|
2607
|
+
strokeWidth: 0.5,
|
|
2608
|
+
opacity,
|
|
2609
|
+
fillRule: "evenodd",
|
|
2610
|
+
style: { pointerEvents: "none" }
|
|
2611
|
+
}
|
|
2612
|
+
)
|
|
2613
|
+
]
|
|
2614
|
+
}
|
|
2615
|
+
);
|
|
2616
|
+
}
|
|
2312
2617
|
const builtInRenderers = [
|
|
2313
2618
|
// --- Drawing ---
|
|
2314
2619
|
createRenderer({
|
|
@@ -2433,9 +2738,7 @@ const builtInRenderers = [
|
|
|
2433
2738
|
),
|
|
2434
2739
|
zIndex: 0,
|
|
2435
2740
|
interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
|
|
2436
|
-
|
|
2437
|
-
mixBlendMode: blendModeToCss(a.blendMode ?? PdfBlendMode.Multiply)
|
|
2438
|
-
})
|
|
2741
|
+
defaultBlendMode: PdfBlendMode.Multiply
|
|
2439
2742
|
}),
|
|
2440
2743
|
createRenderer({
|
|
2441
2744
|
id: "underline",
|
|
@@ -2482,6 +2785,38 @@ const builtInRenderers = [
|
|
|
2482
2785
|
zIndex: 0,
|
|
2483
2786
|
interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
|
|
2484
2787
|
}),
|
|
2788
|
+
// --- Text Comment ---
|
|
2789
|
+
createRenderer({
|
|
2790
|
+
id: "text",
|
|
2791
|
+
matches: (a) => a.type === PdfAnnotationSubtype.TEXT && !a.inReplyToId,
|
|
2792
|
+
render: ({ currentObject, isSelected, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
|
|
2793
|
+
Text,
|
|
2794
|
+
{
|
|
2795
|
+
isSelected,
|
|
2796
|
+
color: currentObject.strokeColor ?? currentObject.color,
|
|
2797
|
+
opacity: currentObject.opacity,
|
|
2798
|
+
onClick,
|
|
2799
|
+
appearanceActive
|
|
2800
|
+
}
|
|
2801
|
+
),
|
|
2802
|
+
interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: false }
|
|
2803
|
+
}),
|
|
2804
|
+
// --- Caret ---
|
|
2805
|
+
createRenderer({
|
|
2806
|
+
id: "caret",
|
|
2807
|
+
matches: (a) => a.type === PdfAnnotationSubtype.CARET,
|
|
2808
|
+
render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
|
|
2809
|
+
Caret,
|
|
2810
|
+
{
|
|
2811
|
+
...currentObject,
|
|
2812
|
+
isSelected,
|
|
2813
|
+
scale,
|
|
2814
|
+
onClick,
|
|
2815
|
+
appearanceActive
|
|
2816
|
+
}
|
|
2817
|
+
),
|
|
2818
|
+
interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
|
|
2819
|
+
}),
|
|
2485
2820
|
// --- FreeText ---
|
|
2486
2821
|
createRenderer({
|
|
2487
2822
|
id: "freeText",
|
|
@@ -2796,9 +3131,10 @@ function Annotations(annotationsProps) {
|
|
|
2796
3131
|
renderer.onDoubleClick(annotation.object.id, setEditingId);
|
|
2797
3132
|
} : void 0,
|
|
2798
3133
|
zIndex: renderer.zIndex,
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
3134
|
+
blendMode: blendModeToCss(
|
|
3135
|
+
annotation.object.blendMode ?? renderer.defaultBlendMode ?? PdfBlendMode.Normal
|
|
3136
|
+
),
|
|
3137
|
+
style: (_c = renderer.containerStyle) == null ? void 0 : _c.call(renderer, annotation.object),
|
|
2802
3138
|
appearance: useAP ? getAppearanceForAnnotation(annotation) : void 0,
|
|
2803
3139
|
...annotationsProps,
|
|
2804
3140
|
children: (currentObject, { appearanceActive }) => renderer.render({
|
|
@@ -2945,6 +3281,8 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
2945
3281
|
)
|
|
2946
3282
|
}
|
|
2947
3283
|
);
|
|
3284
|
+
case PdfAnnotationSubtype.CARET:
|
|
3285
|
+
return null;
|
|
2948
3286
|
default:
|
|
2949
3287
|
return null;
|
|
2950
3288
|
}
|
|
@@ -2976,7 +3314,16 @@ function PreviewRenderer({ preview, scale }) {
|
|
|
2976
3314
|
return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(Line, { isSelected: false, scale, ...preview.data }) });
|
|
2977
3315
|
}
|
|
2978
3316
|
if (preview.type === PdfAnnotationSubtype.INK) {
|
|
2979
|
-
return /* @__PURE__ */ jsx(
|
|
3317
|
+
return /* @__PURE__ */ jsx(
|
|
3318
|
+
"div",
|
|
3319
|
+
{
|
|
3320
|
+
style: {
|
|
3321
|
+
...style,
|
|
3322
|
+
mixBlendMode: blendModeToCss(preview.data.blendMode ?? PdfBlendMode.Normal)
|
|
3323
|
+
},
|
|
3324
|
+
children: /* @__PURE__ */ jsx(Ink, { isSelected: false, scale, ...preview.data })
|
|
3325
|
+
}
|
|
3326
|
+
);
|
|
2980
3327
|
}
|
|
2981
3328
|
if (preview.type === PdfAnnotationSubtype.FREETEXT) {
|
|
2982
3329
|
return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
|