@embedpdf/utils 2.0.0 → 2.0.2
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/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +143 -123
- 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 +143 -123
- package/dist/react/index.js.map +1 -1
- package/dist/shared/plugin-interaction-primitives/drag-resize-controller.d.ts +18 -0
- package/dist/shared-preact/plugin-interaction-primitives/drag-resize-controller.d.ts +18 -0
- package/dist/shared-react/plugin-interaction-primitives/drag-resize-controller.d.ts +18 -0
- package/dist/shared-svelte/plugin-interaction-primitives/drag-resize-controller.d.ts +18 -0
- package/dist/shared-vue/plugin-interaction-primitives/drag-resize-controller.d.ts +18 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +143 -123
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/counter-rotate-container.vue.d.ts +17 -3
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +143 -123
- package/dist/vue/index.js.map +1 -1
- package/package.json +2 -2
package/dist/react/index.js
CHANGED
|
@@ -48,6 +48,12 @@ function CounterRotate({ children, ...props }) {
|
|
|
48
48
|
}
|
|
49
49
|
}) });
|
|
50
50
|
}
|
|
51
|
+
function getAnchor(handle) {
|
|
52
|
+
return {
|
|
53
|
+
x: handle.includes("e") ? "left" : handle.includes("w") ? "right" : "center",
|
|
54
|
+
y: handle.includes("s") ? "top" : handle.includes("n") ? "bottom" : "center"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
51
57
|
class DragResizeController {
|
|
52
58
|
constructor(config, onUpdate) {
|
|
53
59
|
this.config = config;
|
|
@@ -305,134 +311,124 @@ class DragResizeController {
|
|
|
305
311
|
};
|
|
306
312
|
return this.applyConstraints(position);
|
|
307
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Calculate the new rect after a resize operation.
|
|
316
|
+
* Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
|
|
317
|
+
*/
|
|
308
318
|
calculateResizePosition(delta, handle) {
|
|
309
|
-
var _a;
|
|
310
319
|
if (!this.startElement) return this.config.element;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
case "se":
|
|
317
|
-
width += delta.x;
|
|
318
|
-
height += delta.y;
|
|
319
|
-
break;
|
|
320
|
-
case "sw":
|
|
321
|
-
x += delta.x;
|
|
322
|
-
width -= delta.x;
|
|
323
|
-
height += delta.y;
|
|
324
|
-
break;
|
|
325
|
-
case "ne":
|
|
326
|
-
width += delta.x;
|
|
327
|
-
y += delta.y;
|
|
328
|
-
height -= delta.y;
|
|
329
|
-
break;
|
|
330
|
-
case "nw":
|
|
331
|
-
x += delta.x;
|
|
332
|
-
width -= delta.x;
|
|
333
|
-
y += delta.y;
|
|
334
|
-
height -= delta.y;
|
|
335
|
-
break;
|
|
336
|
-
case "n":
|
|
337
|
-
y += delta.y;
|
|
338
|
-
height -= delta.y;
|
|
339
|
-
break;
|
|
340
|
-
case "s":
|
|
341
|
-
height += delta.y;
|
|
342
|
-
break;
|
|
343
|
-
case "e":
|
|
344
|
-
width += delta.x;
|
|
345
|
-
break;
|
|
346
|
-
case "w":
|
|
347
|
-
x += delta.x;
|
|
348
|
-
width -= delta.x;
|
|
349
|
-
break;
|
|
320
|
+
const anchor = getAnchor(handle);
|
|
321
|
+
const aspectRatio = this.startElement.size.width / this.startElement.size.height || 1;
|
|
322
|
+
let rect = this.applyResizeDelta(delta, anchor);
|
|
323
|
+
if (this.config.maintainAspectRatio) {
|
|
324
|
+
rect = this.enforceAspectRatio(rect, anchor, aspectRatio);
|
|
350
325
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
326
|
+
rect = this.clampToBounds(rect, anchor, aspectRatio);
|
|
327
|
+
return this.applyConstraints(rect);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Apply the mouse delta to produce a raw (unconstrained) resized rect.
|
|
331
|
+
*/
|
|
332
|
+
applyResizeDelta(delta, anchor) {
|
|
333
|
+
const start = this.startElement;
|
|
334
|
+
let x = start.origin.x;
|
|
335
|
+
let y = start.origin.y;
|
|
336
|
+
let width = start.size.width;
|
|
337
|
+
let height = start.size.height;
|
|
338
|
+
if (anchor.x === "left") {
|
|
339
|
+
width += delta.x;
|
|
340
|
+
} else if (anchor.x === "right") {
|
|
341
|
+
x += delta.x;
|
|
342
|
+
width -= delta.x;
|
|
343
|
+
}
|
|
344
|
+
if (anchor.y === "top") {
|
|
345
|
+
height += delta.y;
|
|
346
|
+
} else if (anchor.y === "bottom") {
|
|
347
|
+
y += delta.y;
|
|
348
|
+
height -= delta.y;
|
|
349
|
+
}
|
|
350
|
+
return { origin: { x, y }, size: { width, height } };
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Enforce aspect ratio while respecting the anchor.
|
|
354
|
+
* For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
|
|
355
|
+
* For corner handles, the anchor corner stays fixed.
|
|
356
|
+
*/
|
|
357
|
+
enforceAspectRatio(rect, anchor, aspectRatio) {
|
|
358
|
+
const start = this.startElement;
|
|
359
|
+
let { x, y } = rect.origin;
|
|
360
|
+
let { width, height } = rect.size;
|
|
361
|
+
const isEdgeHandle = anchor.x === "center" || anchor.y === "center";
|
|
362
|
+
if (isEdgeHandle) {
|
|
363
|
+
if (anchor.y === "center") {
|
|
364
|
+
height = width / aspectRatio;
|
|
365
|
+
y = start.origin.y + (start.size.height - height) / 2;
|
|
368
366
|
} else {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (widthChange > heightChange) {
|
|
372
|
-
height = width / aspectRatio;
|
|
373
|
-
} else {
|
|
374
|
-
width = height * aspectRatio;
|
|
375
|
-
}
|
|
376
|
-
if (handle.includes("w")) {
|
|
377
|
-
x = this.startElement.origin.x + this.startElement.size.width - width;
|
|
378
|
-
}
|
|
379
|
-
if (handle.includes("n")) {
|
|
380
|
-
y = this.startElement.origin.y + this.startElement.size.height - height;
|
|
381
|
-
}
|
|
367
|
+
width = height * aspectRatio;
|
|
368
|
+
x = start.origin.x + (start.size.width - width) / 2;
|
|
382
369
|
}
|
|
370
|
+
} else {
|
|
371
|
+
const dw = Math.abs(width - start.size.width);
|
|
372
|
+
const dh = Math.abs(height - start.size.height);
|
|
373
|
+
if (dw >= dh) {
|
|
374
|
+
height = width / aspectRatio;
|
|
375
|
+
} else {
|
|
376
|
+
width = height * aspectRatio;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (anchor.x === "right") {
|
|
380
|
+
x = start.origin.x + start.size.width - width;
|
|
381
|
+
}
|
|
382
|
+
if (anchor.y === "bottom") {
|
|
383
|
+
y = start.origin.y + start.size.height - height;
|
|
383
384
|
}
|
|
385
|
+
return { origin: { x, y }, size: { width, height } };
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Clamp rect to bounding box while respecting anchor and aspect ratio.
|
|
389
|
+
*/
|
|
390
|
+
clampToBounds(rect, anchor, aspectRatio) {
|
|
391
|
+
var _a;
|
|
384
392
|
const bbox = (_a = this.config.constraints) == null ? void 0 : _a.boundingBox;
|
|
385
|
-
if (bbox)
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
break;
|
|
403
|
-
case "n":
|
|
404
|
-
if (y < 0) {
|
|
405
|
-
height += y;
|
|
406
|
-
y = 0;
|
|
407
|
-
}
|
|
408
|
-
break;
|
|
409
|
-
case "sw":
|
|
410
|
-
if (x < 0) {
|
|
411
|
-
width += x;
|
|
412
|
-
x = 0;
|
|
413
|
-
}
|
|
414
|
-
height = Math.min(height, bbox.height - y);
|
|
415
|
-
break;
|
|
416
|
-
case "nw":
|
|
417
|
-
if (x < 0) {
|
|
418
|
-
width += x;
|
|
419
|
-
x = 0;
|
|
420
|
-
}
|
|
421
|
-
if (y < 0) {
|
|
422
|
-
height += y;
|
|
423
|
-
y = 0;
|
|
424
|
-
}
|
|
425
|
-
break;
|
|
426
|
-
case "ne":
|
|
427
|
-
width = Math.min(width, bbox.width - x);
|
|
428
|
-
if (y < 0) {
|
|
429
|
-
height += y;
|
|
430
|
-
y = 0;
|
|
431
|
-
}
|
|
432
|
-
break;
|
|
393
|
+
if (!bbox) return rect;
|
|
394
|
+
const start = this.startElement;
|
|
395
|
+
let { x, y } = rect.origin;
|
|
396
|
+
let { width, height } = rect.size;
|
|
397
|
+
width = Math.max(1, width);
|
|
398
|
+
height = Math.max(1, height);
|
|
399
|
+
const anchorX = anchor.x === "left" ? start.origin.x : start.origin.x + start.size.width;
|
|
400
|
+
const anchorY = anchor.y === "top" ? start.origin.y : start.origin.y + start.size.height;
|
|
401
|
+
const maxW = anchor.x === "left" ? bbox.width - anchorX : anchor.x === "right" ? anchorX : Math.min(start.origin.x, bbox.width - start.origin.x - start.size.width) * 2 + start.size.width;
|
|
402
|
+
const maxH = anchor.y === "top" ? bbox.height - anchorY : anchor.y === "bottom" ? anchorY : Math.min(start.origin.y, bbox.height - start.origin.y - start.size.height) * 2 + start.size.height;
|
|
403
|
+
if (this.config.maintainAspectRatio) {
|
|
404
|
+
const scaleW = width > maxW ? maxW / width : 1;
|
|
405
|
+
const scaleH = height > maxH ? maxH / height : 1;
|
|
406
|
+
const scale = Math.min(scaleW, scaleH);
|
|
407
|
+
if (scale < 1) {
|
|
408
|
+
width *= scale;
|
|
409
|
+
height *= scale;
|
|
433
410
|
}
|
|
411
|
+
} else {
|
|
412
|
+
width = Math.min(width, maxW);
|
|
413
|
+
height = Math.min(height, maxH);
|
|
434
414
|
}
|
|
435
|
-
|
|
415
|
+
if (anchor.x === "left") {
|
|
416
|
+
x = anchorX;
|
|
417
|
+
} else if (anchor.x === "right") {
|
|
418
|
+
x = anchorX - width;
|
|
419
|
+
} else {
|
|
420
|
+
x = start.origin.x + (start.size.width - width) / 2;
|
|
421
|
+
}
|
|
422
|
+
if (anchor.y === "top") {
|
|
423
|
+
y = anchorY;
|
|
424
|
+
} else if (anchor.y === "bottom") {
|
|
425
|
+
y = anchorY - height;
|
|
426
|
+
} else {
|
|
427
|
+
y = start.origin.y + (start.size.height - height) / 2;
|
|
428
|
+
}
|
|
429
|
+
x = Math.max(0, Math.min(x, bbox.width - width));
|
|
430
|
+
y = Math.max(0, Math.min(y, bbox.height - height));
|
|
431
|
+
return { origin: { x, y }, size: { width, height } };
|
|
436
432
|
}
|
|
437
433
|
applyConstraints(position) {
|
|
438
434
|
const { constraints } = this.config;
|
|
@@ -441,10 +437,34 @@ class DragResizeController {
|
|
|
441
437
|
origin: { x, y },
|
|
442
438
|
size: { width, height }
|
|
443
439
|
} = position;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
440
|
+
const minW = constraints.minWidth ?? 1;
|
|
441
|
+
const minH = constraints.minHeight ?? 1;
|
|
442
|
+
const maxW = constraints.maxWidth;
|
|
443
|
+
const maxH = constraints.maxHeight;
|
|
444
|
+
if (this.config.maintainAspectRatio && width > 0 && height > 0) {
|
|
445
|
+
const ratio = width / height;
|
|
446
|
+
if (width < minW) {
|
|
447
|
+
width = minW;
|
|
448
|
+
height = width / ratio;
|
|
449
|
+
}
|
|
450
|
+
if (height < minH) {
|
|
451
|
+
height = minH;
|
|
452
|
+
width = height * ratio;
|
|
453
|
+
}
|
|
454
|
+
if (maxW !== void 0 && width > maxW) {
|
|
455
|
+
width = maxW;
|
|
456
|
+
height = width / ratio;
|
|
457
|
+
}
|
|
458
|
+
if (maxH !== void 0 && height > maxH) {
|
|
459
|
+
height = maxH;
|
|
460
|
+
width = height * ratio;
|
|
461
|
+
}
|
|
462
|
+
} else {
|
|
463
|
+
width = Math.max(minW, width);
|
|
464
|
+
height = Math.max(minH, height);
|
|
465
|
+
if (maxW !== void 0) width = Math.min(maxW, width);
|
|
466
|
+
if (maxH !== void 0) height = Math.min(maxH, height);
|
|
467
|
+
}
|
|
448
468
|
if (constraints.boundingBox) {
|
|
449
469
|
x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));
|
|
450
470
|
y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/react/adapter.ts","../../src/shared/components/counter-rotate-container.tsx","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/shared/hooks/use-drag-resize.ts","../../src/shared/hooks/use-interaction-handles.ts","../../src/shared/hooks/use-double-press-props.ts"],"sourcesContent":["export {\n Fragment,\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n JSX,\n createContext,\n useContext,\n} from 'react';\nexport type {\n ReactNode,\n HTMLAttributes,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n TouchEvent,\n ComponentType,\n} from 'react';\n\nexport const dblClickProp = 'onDoubleClick' as const;\n","import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, Fragment, useRef, useEffect } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n ref: (el: HTMLDivElement | null) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n const elementRef = useRef<HTMLDivElement | null>(null);\n\n // Use native event listeners with capture phase to prevent event propagation\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n const handlePointerDown = (e: Event) => {\n // Stop propagation to prevent underlying layers from receiving the event\n e.stopPropagation();\n // DO NOT use e.preventDefault() here - it breaks click events on mobile/tablet!\n // preventDefault() stops the browser from generating click events from touch,\n // which makes buttons inside this container non-functional on touch devices.\n };\n\n const handleTouchStart = (e: Event) => {\n // Stop propagation to prevent underlying layers from receiving the event\n e.stopPropagation();\n // DO NOT use e.preventDefault() here - it breaks click events on mobile/tablet!\n // preventDefault() stops the browser from generating click events from touch,\n // which makes buttons inside this container non-functional on touch devices.\n };\n\n // Use capture phase to intercept before synthetic events\n element.addEventListener('pointerdown', handlePointerDown, { capture: true });\n element.addEventListener('touchstart', handleTouchStart, { capture: true });\n\n return () => {\n element.removeEventListener('pointerdown', handlePointerDown, { capture: true });\n element.removeEventListener('touchstart', handleTouchStart, { capture: true });\n };\n }, []);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps: MenuWrapperProps = {\n style: menuWrapperStyle,\n ref: (el: HTMLDivElement | null) => {\n elementRef.current = el;\n },\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = this.startElement;\n\n switch (handle) {\n case 'se':\n width += delta.x;\n height += delta.y;\n break;\n case 'sw':\n x += delta.x;\n width -= delta.x;\n height += delta.y;\n break;\n case 'ne':\n width += delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'nw':\n x += delta.x;\n width -= delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'n':\n y += delta.y;\n height -= delta.y;\n break;\n case 's':\n height += delta.y;\n break;\n case 'e':\n width += delta.x;\n break;\n case 'w':\n x += delta.x;\n width -= delta.x;\n break;\n }\n\n // Maintain aspect ratio if needed\n if (this.config.maintainAspectRatio && this.startElement) {\n const aspectRatio = this.startElement.size.width / this.startElement.size.height;\n\n if (['n', 's', 'e', 'w'].includes(handle)) {\n if (handle === 'n' || handle === 's') {\n const newWidth = height * aspectRatio;\n const widthDiff = newWidth - width;\n width = newWidth;\n x -= widthDiff / 2;\n } else {\n const newHeight = width / aspectRatio;\n const heightDiff = newHeight - height;\n height = newHeight;\n if (handle === 'w') {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n y -= heightDiff / 2;\n }\n } else {\n const widthChange = Math.abs(width - this.startElement.size.width);\n const heightChange = Math.abs(height - this.startElement.size.height);\n if (widthChange > heightChange) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n if (handle.includes('w')) {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n if (handle.includes('n')) {\n y = this.startElement.origin.y + this.startElement.size.height - height;\n }\n }\n }\n\n // Handle-aware bounding box clamping to avoid shifting opposite edge\n const bbox = this.config.constraints?.boundingBox;\n if (bbox) {\n switch (handle) {\n case 'e':\n width = Math.min(width, bbox.width - x);\n break;\n case 's':\n height = Math.min(height, bbox.height - y);\n break;\n case 'se':\n width = Math.min(width, bbox.width - x);\n height = Math.min(height, bbox.height - y);\n break;\n case 'w':\n if (x < 0) {\n width += x;\n x = 0;\n }\n break;\n case 'n':\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'sw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n height = Math.min(height, bbox.height - y);\n break;\n case 'nw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'ne':\n width = Math.min(width, bbox.width - x);\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n }\n }\n\n return this.applyConstraints({ origin: { x, y }, size: { width, height } });\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n // Apply size constraints\n width = Math.max(constraints.minWidth || 1, width);\n height = Math.max(constraints.minHeight || 1, height);\n\n if (constraints.maxWidth) width = Math.min(constraints.maxWidth, width);\n if (constraints.maxHeight) height = Math.min(constraints.maxHeight, height);\n\n // Apply bounding box constraints\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { useRef, useCallback, useEffect, PointerEvent } from '@framework';\nimport {\n DragResizeController,\n DragResizeConfig,\n InteractionEvent,\n ResizeHandle,\n} from '../plugin-interaction-primitives';\n\nexport interface UseDragResizeOptions extends DragResizeConfig {\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: boolean;\n}\n\nexport interface ResizeHandleEventProps {\n onPointerDown: (e: PointerEvent) => void;\n onPointerMove: (e: PointerEvent) => void;\n onPointerUp: (e: PointerEvent) => void;\n onPointerCancel: (e: PointerEvent) => void;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const { onUpdate, enabled = true, ...config } = options;\n const controllerRef = useRef<DragResizeController | null>(null);\n const onUpdateRef = useRef<typeof onUpdate>(onUpdate);\n\n useEffect(() => {\n onUpdateRef.current = onUpdate;\n }, [onUpdate]);\n\n // Initialize or update controller\n useEffect(() => {\n if (!controllerRef.current) {\n controllerRef.current = new DragResizeController(config, (event) =>\n onUpdateRef.current?.(event),\n );\n } else {\n controllerRef.current.updateConfig(config);\n }\n }, [\n config.element,\n config.constraints,\n config.maintainAspectRatio,\n config.pageRotation,\n config.scale,\n config.vertices,\n ]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n [enabled],\n );\n\n const handleMove = useCallback((e: PointerEvent) => {\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.move(e.clientX, e.clientY);\n }, []);\n\n const handleEnd = useCallback((e: PointerEvent) => {\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n }, []);\n\n const createResizeHandler = useCallback(\n (handle: ResizeHandle): ResizeHandleEventProps => ({\n onPointerDown: (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }),\n [enabled, handleMove, handleEnd],\n );\n\n const createVertexHandler = useCallback(\n (vertexIndex: number): ResizeHandleEventProps => ({\n onPointerDown: (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }),\n [enabled, handleMove, handleEnd],\n );\n\n return {\n dragProps: enabled\n ? {\n onPointerDown: handleDragStart,\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }\n : {},\n createResizeProps: createResizeHandler,\n createVertexProps: createVertexHandler,\n };\n}\n","import { useMemo, PointerEvent } from '@framework';\nimport type { CSSProperties } from '@framework';\nimport { useDragResize, UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../plugin-interaction-primitives/utils';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerDown: (e: PointerEvent) => void;\n onPointerMove: (e: PointerEvent) => void;\n onPointerUp: (e: PointerEvent) => void;\n onPointerCancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport function useInteractionHandles(opts: {\n controller: UseDragResizeOptions; // SINGLE config (rect/scale/rotation/vertices/…)\n resizeUI?: ResizeUI; // purely visual knobs\n vertexUI?: VertexUI; // purely visual knobs\n includeVertices?: boolean; // default false\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Resize handles: only uses data from the SAME controller config.\n const resize: HandleElementProps[] = useMemo(() => {\n const desc = describeResizeFromConfig(controller, resizeUI);\n return desc.map((d) => ({\n key: d.attrs?.['data-epdf-handle'] as string,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n // deps: controller geometry knobs + UI knobs + handler factory\n }, [\n controller.element.origin.x,\n controller.element.origin.y,\n controller.element.size.width,\n controller.element.size.height,\n controller.scale,\n controller.pageRotation,\n controller.maintainAspectRatio,\n resizeUI?.handleSize,\n resizeUI?.spacing,\n resizeUI?.offsetMode,\n resizeUI?.includeSides,\n resizeUI?.zIndex,\n resizeUI?.rotationAwareCursor,\n createResizeProps,\n handleAttrs,\n ]);\n\n // Vertex handles: same source; prefer live vertices if parent rerenders with updated cfg.vertices\n const vertices: HandleElementProps[] = useMemo(() => {\n if (!includeVertices) return [];\n const desc = describeVerticesFromConfig(controller, vertexUI, controller.vertices);\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n }, [\n includeVertices,\n controller.element.origin.x,\n controller.element.origin.y,\n controller.element.size.width,\n controller.element.size.height,\n controller.scale,\n controller.vertices, // identity/content drives recalculation\n vertexUI?.vertexSize,\n vertexUI?.zIndex,\n createVertexProps,\n vertexAttrs,\n ]);\n\n return { dragProps, resize, vertices };\n}\n","import { useRef, useCallback, dblClickProp } from '@framework';\nimport type { PointerEvent } from '@framework';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler<T extends Element> = ((e: PointerEvent<T> | MouseEvent) => void) | undefined;\n\ntype DoubleProps<K extends string> = Partial<Record<K, (e: any) => void>> & {\n onPointerUp?: (e: any) => void;\n};\n\nexport function useDoublePressProps<\n T extends Element = Element,\n K extends string = typeof dblClickProp,\n>(\n onDouble?: DoubleHandler<T>,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps<K> {\n const last = useRef({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = useCallback(\n (e: any) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX as number;\n const y = e.clientY as number;\n\n const withinTime = now - last.current.t <= delay;\n const dx = x - last.current.x;\n const dy = y - last.current.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) onDouble?.(e as PointerEvent<T>);\n\n last.current = { t: now, x, y };\n },\n [onDouble, delay, tolerancePx],\n );\n\n const handleDouble = useCallback(\n (e: any) => {\n onDouble?.(e);\n },\n [onDouble],\n );\n\n return onDouble\n ? ({\n // Computed property uses the framework’s name ('onDoubleClick' or 'onDblClick')\n [dblClickProp]: handleDouble,\n onPointerUpCapture: handlePointerUp,\n } as DoubleProps<K>)\n : {};\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,eAAe;ACCrB,SAAS,cAAc,EAAE,UAAU,GAAG,SAAsC;AACjF,QAAM,EAAE,MAAM,SAAA,IAAa;AAC3B,QAAM,EAAE,QAAQ,OAAO,WAAW,mBAAmB,MAAM,QAAQ;AACnE,QAAM,aAAa,OAA8B,IAAI;AAGrD,YAAU,MAAM;AACd,UAAM,UAAU,WAAW;AAC3B,QAAI,CAAC,QAAS;AAEd,UAAM,oBAAoB,CAAC,MAAa;AAEtC,QAAE,gBAAA;AAAA,IAIJ;AAEA,UAAM,mBAAmB,CAAC,MAAa;AAErC,QAAE,gBAAA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GAAG,EAAA;AAAA,IAC9B;AAAA,IACA,CAAC,UAAU,OAAO,WAAW;AAAA,EAAA;AAG/B,QAAM,eAAe;AAAA,IACnB,CAAC,MAAW;AACV,2CAAW;AAAA,IACb;AAAA,IACA,CAAC,QAAQ;AAAA,EAAA;AAGX,SAAO,WACF;AAAA;AAAA,IAEC,CAAC,YAAY,GAAG;AAAA,IAChB,oBAAoB;AAAA,EAAA,IAEtB,CAAA;AACN;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/react/adapter.ts","../../src/shared/components/counter-rotate-container.tsx","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/shared/hooks/use-drag-resize.ts","../../src/shared/hooks/use-interaction-handles.ts","../../src/shared/hooks/use-double-press-props.ts"],"sourcesContent":["export {\n Fragment,\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n JSX,\n createContext,\n useContext,\n} from 'react';\nexport type {\n ReactNode,\n HTMLAttributes,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n TouchEvent,\n ComponentType,\n} from 'react';\n\nexport const dblClickProp = 'onDoubleClick' as const;\n","import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, Fragment, useRef, useEffect } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n ref: (el: HTMLDivElement | null) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n const elementRef = useRef<HTMLDivElement | null>(null);\n\n // Use native event listeners with capture phase to prevent event propagation\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n const handlePointerDown = (e: Event) => {\n // Stop propagation to prevent underlying layers from receiving the event\n e.stopPropagation();\n // DO NOT use e.preventDefault() here - it breaks click events on mobile/tablet!\n // preventDefault() stops the browser from generating click events from touch,\n // which makes buttons inside this container non-functional on touch devices.\n };\n\n const handleTouchStart = (e: Event) => {\n // Stop propagation to prevent underlying layers from receiving the event\n e.stopPropagation();\n // DO NOT use e.preventDefault() here - it breaks click events on mobile/tablet!\n // preventDefault() stops the browser from generating click events from touch,\n // which makes buttons inside this container non-functional on touch devices.\n };\n\n // Use capture phase to intercept before synthetic events\n element.addEventListener('pointerdown', handlePointerDown, { capture: true });\n element.addEventListener('touchstart', handleTouchStart, { capture: true });\n\n return () => {\n element.removeEventListener('pointerdown', handlePointerDown, { capture: true });\n element.removeEventListener('touchstart', handleTouchStart, { capture: true });\n };\n }, []);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps: MenuWrapperProps = {\n style: menuWrapperStyle,\n ref: (el: HTMLDivElement | null) => {\n elementRef.current = el;\n },\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/** Anchor describes which edges stay fixed when resizing. */\ntype Anchor = {\n x: 'left' | 'right' | 'center';\n y: 'top' | 'bottom' | 'center';\n};\n\n/**\n * Derive anchor from handle.\n * - 'e' means we're dragging east → left edge is anchored\n * - 'nw' means we're dragging north-west → bottom-right corner is anchored\n */\nfunction getAnchor(handle: ResizeHandle): Anchor {\n return {\n x: handle.includes('e') ? 'left' : handle.includes('w') ? 'right' : 'center',\n y: handle.includes('s') ? 'top' : handle.includes('n') ? 'bottom' : 'center',\n };\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n /**\n * Calculate the new rect after a resize operation.\n * Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints\n */\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n const anchor = getAnchor(handle);\n const aspectRatio = this.startElement.size.width / this.startElement.size.height || 1;\n\n // Step 1: Apply delta to get raw resize\n let rect = this.applyResizeDelta(delta, anchor);\n\n // Step 2: Enforce aspect ratio if enabled\n if (this.config.maintainAspectRatio) {\n rect = this.enforceAspectRatio(rect, anchor, aspectRatio);\n }\n\n // Step 3: Clamp to bounding box\n rect = this.clampToBounds(rect, anchor, aspectRatio);\n\n // Step 4: Apply min/max constraints\n return this.applyConstraints(rect);\n }\n\n /**\n * Apply the mouse delta to produce a raw (unconstrained) resized rect.\n */\n private applyResizeDelta(delta: Position, anchor: Anchor): Rect {\n const start = this.startElement!;\n let x = start.origin.x;\n let y = start.origin.y;\n let width = start.size.width;\n let height = start.size.height;\n\n // Horizontal: if anchor is left, right edge moves; if anchor is right, left edge moves\n if (anchor.x === 'left') {\n width += delta.x;\n } else if (anchor.x === 'right') {\n x += delta.x;\n width -= delta.x;\n }\n // anchor.x === 'center' means no horizontal resize from this handle\n\n // Vertical: if anchor is top, bottom edge moves; if anchor is bottom, top edge moves\n if (anchor.y === 'top') {\n height += delta.y;\n } else if (anchor.y === 'bottom') {\n y += delta.y;\n height -= delta.y;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Enforce aspect ratio while respecting the anchor.\n * For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.\n * For corner handles, the anchor corner stays fixed.\n */\n private enforceAspectRatio(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n const isEdgeHandle = anchor.x === 'center' || anchor.y === 'center';\n\n if (isEdgeHandle) {\n // Edge handle: one dimension drives, the other follows, centered on the non-moving axis\n if (anchor.y === 'center') {\n // Horizontal edge (e/w): width is primary\n height = width / aspectRatio;\n // Center vertically relative to original\n y = start.origin.y + (start.size.height - height) / 2;\n } else {\n // Vertical edge (n/s): height is primary\n width = height * aspectRatio;\n // Center horizontally relative to original\n x = start.origin.x + (start.size.width - width) / 2;\n }\n } else {\n // Corner handle: pick the dominant axis based on which changed more\n const dw = Math.abs(width - start.size.width);\n const dh = Math.abs(height - start.size.height);\n\n if (dw >= dh) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n }\n\n // Reposition based on anchor\n if (anchor.x === 'right') {\n x = start.origin.x + start.size.width - width;\n }\n if (anchor.y === 'bottom') {\n y = start.origin.y + start.size.height - height;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Clamp rect to bounding box while respecting anchor and aspect ratio.\n */\n private clampToBounds(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return rect;\n\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n // Ensure positive dimensions\n width = Math.max(1, width);\n height = Math.max(1, height);\n\n // Calculate anchor points (the edges/corners that must stay fixed)\n const anchorX = anchor.x === 'left' ? start.origin.x : start.origin.x + start.size.width;\n const anchorY = anchor.y === 'top' ? start.origin.y : start.origin.y + start.size.height;\n\n // Calculate max available space from anchor\n const maxW =\n anchor.x === 'left'\n ? bbox.width - anchorX\n : anchor.x === 'right'\n ? anchorX\n : Math.min(start.origin.x, bbox.width - start.origin.x - start.size.width) * 2 +\n start.size.width;\n\n const maxH =\n anchor.y === 'top'\n ? bbox.height - anchorY\n : anchor.y === 'bottom'\n ? anchorY\n : Math.min(start.origin.y, bbox.height - start.origin.y - start.size.height) * 2 +\n start.size.height;\n\n if (this.config.maintainAspectRatio) {\n // Find the scaling factor that fits both constraints\n const scaleW = width > maxW ? maxW / width : 1;\n const scaleH = height > maxH ? maxH / height : 1;\n const scale = Math.min(scaleW, scaleH);\n\n if (scale < 1) {\n width *= scale;\n height *= scale;\n }\n } else {\n // Clamp independently\n width = Math.min(width, maxW);\n height = Math.min(height, maxH);\n }\n\n // Recompute position based on anchor\n if (anchor.x === 'left') {\n x = anchorX;\n } else if (anchor.x === 'right') {\n x = anchorX - width;\n } else {\n x = start.origin.x + (start.size.width - width) / 2;\n }\n\n if (anchor.y === 'top') {\n y = anchorY;\n } else if (anchor.y === 'bottom') {\n y = anchorY - height;\n } else {\n y = start.origin.y + (start.size.height - height) / 2;\n }\n\n // Final clamp to ensure we're within bounds (handles center anchor edge cases)\n x = Math.max(0, Math.min(x, bbox.width - width));\n y = Math.max(0, Math.min(y, bbox.height - height));\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n const minW = constraints.minWidth ?? 1;\n const minH = constraints.minHeight ?? 1;\n const maxW = constraints.maxWidth;\n const maxH = constraints.maxHeight;\n\n if (this.config.maintainAspectRatio && width > 0 && height > 0) {\n const ratio = width / height;\n\n // Enforce mins (scale up)\n if (width < minW) {\n width = minW;\n height = width / ratio;\n }\n if (height < minH) {\n height = minH;\n width = height * ratio;\n }\n\n // Enforce maxes (scale down)\n if (maxW !== undefined && width > maxW) {\n width = maxW;\n height = width / ratio;\n }\n if (maxH !== undefined && height > maxH) {\n height = maxH;\n width = height * ratio;\n }\n } else {\n width = Math.max(minW, width);\n height = Math.max(minH, height);\n if (maxW !== undefined) width = Math.min(maxW, width);\n if (maxH !== undefined) height = Math.min(maxH, height);\n }\n\n // Clamp position to bounding box\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { useRef, useCallback, useEffect, PointerEvent } from '@framework';\nimport {\n DragResizeController,\n DragResizeConfig,\n InteractionEvent,\n ResizeHandle,\n} from '../plugin-interaction-primitives';\n\nexport interface UseDragResizeOptions extends DragResizeConfig {\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: boolean;\n}\n\nexport interface ResizeHandleEventProps {\n onPointerDown: (e: PointerEvent) => void;\n onPointerMove: (e: PointerEvent) => void;\n onPointerUp: (e: PointerEvent) => void;\n onPointerCancel: (e: PointerEvent) => void;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const { onUpdate, enabled = true, ...config } = options;\n const controllerRef = useRef<DragResizeController | null>(null);\n const onUpdateRef = useRef<typeof onUpdate>(onUpdate);\n\n useEffect(() => {\n onUpdateRef.current = onUpdate;\n }, [onUpdate]);\n\n // Initialize or update controller\n useEffect(() => {\n if (!controllerRef.current) {\n controllerRef.current = new DragResizeController(config, (event) =>\n onUpdateRef.current?.(event),\n );\n } else {\n controllerRef.current.updateConfig(config);\n }\n }, [\n config.element,\n config.constraints,\n config.maintainAspectRatio,\n config.pageRotation,\n config.scale,\n config.vertices,\n ]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n [enabled],\n );\n\n const handleMove = useCallback((e: PointerEvent) => {\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.move(e.clientX, e.clientY);\n }, []);\n\n const handleEnd = useCallback((e: PointerEvent) => {\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n }, []);\n\n const createResizeHandler = useCallback(\n (handle: ResizeHandle): ResizeHandleEventProps => ({\n onPointerDown: (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }),\n [enabled, handleMove, handleEnd],\n );\n\n const createVertexHandler = useCallback(\n (vertexIndex: number): ResizeHandleEventProps => ({\n onPointerDown: (e: PointerEvent) => {\n if (!enabled) return;\n e.preventDefault();\n e.stopPropagation();\n controllerRef.current?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n },\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }),\n [enabled, handleMove, handleEnd],\n );\n\n return {\n dragProps: enabled\n ? {\n onPointerDown: handleDragStart,\n onPointerMove: handleMove,\n onPointerUp: handleEnd,\n onPointerCancel: handleEnd,\n }\n : {},\n createResizeProps: createResizeHandler,\n createVertexProps: createVertexHandler,\n };\n}\n","import { useMemo, PointerEvent } from '@framework';\nimport type { CSSProperties } from '@framework';\nimport { useDragResize, UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../plugin-interaction-primitives/utils';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerDown: (e: PointerEvent) => void;\n onPointerMove: (e: PointerEvent) => void;\n onPointerUp: (e: PointerEvent) => void;\n onPointerCancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport function useInteractionHandles(opts: {\n controller: UseDragResizeOptions; // SINGLE config (rect/scale/rotation/vertices/…)\n resizeUI?: ResizeUI; // purely visual knobs\n vertexUI?: VertexUI; // purely visual knobs\n includeVertices?: boolean; // default false\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Resize handles: only uses data from the SAME controller config.\n const resize: HandleElementProps[] = useMemo(() => {\n const desc = describeResizeFromConfig(controller, resizeUI);\n return desc.map((d) => ({\n key: d.attrs?.['data-epdf-handle'] as string,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n // deps: controller geometry knobs + UI knobs + handler factory\n }, [\n controller.element.origin.x,\n controller.element.origin.y,\n controller.element.size.width,\n controller.element.size.height,\n controller.scale,\n controller.pageRotation,\n controller.maintainAspectRatio,\n resizeUI?.handleSize,\n resizeUI?.spacing,\n resizeUI?.offsetMode,\n resizeUI?.includeSides,\n resizeUI?.zIndex,\n resizeUI?.rotationAwareCursor,\n createResizeProps,\n handleAttrs,\n ]);\n\n // Vertex handles: same source; prefer live vertices if parent rerenders with updated cfg.vertices\n const vertices: HandleElementProps[] = useMemo(() => {\n if (!includeVertices) return [];\n const desc = describeVerticesFromConfig(controller, vertexUI, controller.vertices);\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n }, [\n includeVertices,\n controller.element.origin.x,\n controller.element.origin.y,\n controller.element.size.width,\n controller.element.size.height,\n controller.scale,\n controller.vertices, // identity/content drives recalculation\n vertexUI?.vertexSize,\n vertexUI?.zIndex,\n createVertexProps,\n vertexAttrs,\n ]);\n\n return { dragProps, resize, vertices };\n}\n","import { useRef, useCallback, dblClickProp } from '@framework';\nimport type { PointerEvent } from '@framework';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler<T extends Element> = ((e: PointerEvent<T> | MouseEvent) => void) | undefined;\n\ntype DoubleProps<K extends string> = Partial<Record<K, (e: any) => void>> & {\n onPointerUp?: (e: any) => void;\n};\n\nexport function useDoublePressProps<\n T extends Element = Element,\n K extends string = typeof dblClickProp,\n>(\n onDouble?: DoubleHandler<T>,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps<K> {\n const last = useRef({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = useCallback(\n (e: any) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX as number;\n const y = e.clientY as number;\n\n const withinTime = now - last.current.t <= delay;\n const dx = x - last.current.x;\n const dy = y - last.current.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) onDouble?.(e as PointerEvent<T>);\n\n last.current = { t: now, x, y };\n },\n [onDouble, delay, tolerancePx],\n );\n\n const handleDouble = useCallback(\n (e: any) => {\n onDouble?.(e);\n },\n [onDouble],\n );\n\n return onDouble\n ? ({\n // Computed property uses the framework’s name ('onDoubleClick' or 'onDblClick')\n [dblClickProp]: handleDouble,\n onPointerUpCap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|
63
63
|
private clampPoint;
|
|
64
64
|
private calculateVertexPosition;
|
|
65
65
|
private calculateDragPosition;
|
|
66
|
+
/**
|
|
67
|
+
* Calculate the new rect after a resize operation.
|
|
68
|
+
* Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
|
|
69
|
+
*/
|
|
66
70
|
private calculateResizePosition;
|
|
71
|
+
/**
|
|
72
|
+
* Apply the mouse delta to produce a raw (unconstrained) resized rect.
|
|
73
|
+
*/
|
|
74
|
+
private applyResizeDelta;
|
|
75
|
+
/**
|
|
76
|
+
* Enforce aspect ratio while respecting the anchor.
|
|
77
|
+
* For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
|
|
78
|
+
* For corner handles, the anchor corner stays fixed.
|
|
79
|
+
*/
|
|
80
|
+
private enforceAspectRatio;
|
|
81
|
+
/**
|
|
82
|
+
* Clamp rect to bounding box while respecting anchor and aspect ratio.
|
|
83
|
+
*/
|
|
84
|
+
private clampToBounds;
|
|
67
85
|
private applyConstraints;
|
|
68
86
|
}
|
|
@@ -63,6 +63,24 @@ export declare class DragResizeController {
|
|
|
63
63
|
private clampPoint;
|
|
64
64
|
private calculateVertexPosition;
|
|
65
65
|
private calculateDragPosition;
|
|
66
|
+
/**
|
|
67
|
+
* Calculate the new rect after a resize operation.
|
|
68
|
+
* Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
|
|
69
|
+
*/
|
|
66
70
|
private calculateResizePosition;
|
|
71
|
+
/**
|
|
72
|
+
* Apply the mouse delta to produce a raw (unconstrained) resized rect.
|
|
73
|
+
*/
|
|
74
|
+
private applyResizeDelta;
|
|
75
|
+
/**
|
|
76
|
+
* Enforce aspect ratio while respecting the anchor.
|
|
77
|
+
* For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
|
|
78
|
+
* For corner handles, the anchor corner stays fixed.
|
|
79
|
+
*/
|
|
80
|
+
private enforceAspectRatio;
|
|
81
|
+
/**
|
|
82
|
+
* Clamp rect to bounding box while respecting anchor and aspect ratio.
|
|
83
|
+
*/
|
|
84
|
+
private clampToBounds;
|
|
67
85
|
private applyConstraints;
|
|
68
86
|
}
|
|
@@ -63,6 +63,24 @@ export declare class DragResizeController {
|
|
|
63
63
|
private clampPoint;
|
|
64
64
|
private calculateVertexPosition;
|
|
65
65
|
private calculateDragPosition;
|
|
66
|
+
/**
|
|
67
|
+
* Calculate the new rect after a resize operation.
|
|
68
|
+
* Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
|
|
69
|
+
*/
|
|
66
70
|
private calculateResizePosition;
|
|
71
|
+
/**
|
|
72
|
+
* Apply the mouse delta to produce a raw (unconstrained) resized rect.
|
|
73
|
+
*/
|
|
74
|
+
private applyResizeDelta;
|
|
75
|
+
/**
|
|
76
|
+
* Enforce aspect ratio while respecting the anchor.
|
|
77
|
+
* For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
|
|
78
|
+
* For corner handles, the anchor corner stays fixed.
|
|
79
|
+
*/
|
|
80
|
+
private enforceAspectRatio;
|
|
81
|
+
/**
|
|
82
|
+
* Clamp rect to bounding box while respecting anchor and aspect ratio.
|
|
83
|
+
*/
|
|
84
|
+
private clampToBounds;
|
|
67
85
|
private applyConstraints;
|
|
68
86
|
}
|
|
@@ -63,6 +63,24 @@ export declare class DragResizeController {
|
|
|
63
63
|
private clampPoint;
|
|
64
64
|
private calculateVertexPosition;
|
|
65
65
|
private calculateDragPosition;
|
|
66
|
+
/**
|
|
67
|
+
* Calculate the new rect after a resize operation.
|
|
68
|
+
* Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
|
|
69
|
+
*/
|
|
66
70
|
private calculateResizePosition;
|
|
71
|
+
/**
|
|
72
|
+
* Apply the mouse delta to produce a raw (unconstrained) resized rect.
|
|
73
|
+
*/
|
|
74
|
+
private applyResizeDelta;
|
|
75
|
+
/**
|
|
76
|
+
* Enforce aspect ratio while respecting the anchor.
|
|
77
|
+
* For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
|
|
78
|
+
* For corner handles, the anchor corner stays fixed.
|
|
79
|
+
*/
|
|
80
|
+
private enforceAspectRatio;
|
|
81
|
+
/**
|
|
82
|
+
* Clamp rect to bounding box while respecting anchor and aspect ratio.
|
|
83
|
+
*/
|
|
84
|
+
private clampToBounds;
|
|
67
85
|
private applyConstraints;
|
|
68
86
|
}
|