@reekon-tools/boldr-utils 1.6.13 → 1.6.15
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/annotation/canvas/AnnotationCanvas.native.d.ts +2 -2
- package/dist/annotation/canvas/AnnotationCanvasInner.d.ts +1 -0
- package/dist/annotation/canvas/AnnotationCanvasInner.js +51 -13
- package/dist/annotation/canvas/AnnotationCanvasInner.native.d.ts +1 -0
- package/dist/annotation/canvas/AnnotationCanvasInner.native.js +370 -57
- package/dist/annotation/canvas/AnnotationCanvasSkia.d.ts +16 -1
- package/dist/annotation/canvas/AnnotationCanvasSkia.js +2 -2
- package/dist/annotation/canvas/Tool.d.ts +10 -0
- package/dist/annotation/canvas/elements/ShapeElement.js +115 -38
- package/dist/annotation/canvas/measurementGeometry.d.ts +1 -0
- package/dist/annotation/canvas/measurementGeometry.js +61 -2
- package/dist/annotation/canvas/shapeGeometry.d.ts +5 -0
- package/dist/annotation/canvas/shapeGeometry.js +116 -0
- package/dist/annotation/canvas/stampLayout.d.ts +4 -0
- package/dist/annotation/canvas/stampLayout.js +25 -9
- package/dist/annotation/canvas/tools/measurementLineTool.d.ts +12 -0
- package/dist/annotation/canvas/tools/measurementLineTool.js +95 -0
- package/dist/annotation/canvas/tools/measurementTool.d.ts +15 -0
- package/dist/annotation/canvas/tools/measurementTool.js +133 -0
- package/dist/annotation/canvas/tools/panTool.d.ts +1 -0
- package/dist/annotation/canvas/tools/panTool.js +38 -5
- package/dist/annotation/canvas/tools/penTool.js +5 -1
- package/dist/annotation/canvas/tools/polygonTool.d.ts +11 -0
- package/dist/annotation/canvas/tools/polygonTool.js +162 -0
- package/dist/annotation/canvas/tools/selectTool.js +37 -76
- package/dist/annotation/canvas/tools/shapeTool.d.ts +25 -0
- package/dist/annotation/canvas/tools/shapeTool.js +111 -0
- package/dist/annotation/canvas/tools/textTool.d.ts +3 -1
- package/dist/annotation/canvas/tools/textTool.js +28 -3
- package/dist/annotation/canvas/useAnnotationCanvasState.js +27 -3
- package/dist/annotation/data/hooks/useAnnotationCanvasDoc.js +83 -24
- package/dist/exports.d.ts +8 -4
- package/dist/exports.js +7 -3
- package/dist/formulas/calculateFormula.js +1 -3
- package/dist/types/annotation.d.ts +4 -0
- package/dist/types/firestore.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnnotationCanvasInnerProps } from './AnnotationCanvasInner.native.js';
|
|
2
|
-
export type { AnnotationCanvasHandle
|
|
3
|
-
export type { GestureConfig, PanTrigger
|
|
2
|
+
export type { AnnotationCanvasHandle } from './useAnnotationCanvasState.js';
|
|
3
|
+
export type { GestureConfig, PanTrigger } from './AnnotationCanvasInner.js';
|
|
4
4
|
export type AnnotationCanvasProps = AnnotationCanvasInnerProps & {
|
|
5
5
|
fallback?: unknown;
|
|
6
6
|
canvasKitOpts?: unknown;
|
|
@@ -23,6 +23,7 @@ export interface AnnotationCanvasInnerProps {
|
|
|
23
23
|
requestTextInput?: RequestTextInput;
|
|
24
24
|
renderMeasurementStamp?: RenderMeasurementStamp;
|
|
25
25
|
onMeasurementStampPress?: (placed: PlacedMeasurementRef) => void;
|
|
26
|
+
onMeasurementStampLongPress?: (placed: PlacedMeasurementRef) => void;
|
|
26
27
|
stampFontSource?: unknown;
|
|
27
28
|
stampValueFontSize?: number;
|
|
28
29
|
stampLabelFontSize?: number;
|
|
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useRef, } from 'react';
|
|
|
4
4
|
import { AnnotationCanvasSkia } from './AnnotationCanvasSkia.js';
|
|
5
5
|
import { buildRemoveMeasurementOps } from './measurementGeometry.js';
|
|
6
6
|
import { useAnnotationCanvasState, } from './useAnnotationCanvasState.js';
|
|
7
|
-
import {
|
|
7
|
+
import { stampTileSize } from './stampLayout.js';
|
|
8
8
|
// Screen-px radius of a measurement-annotation endpoint handle (matches the
|
|
9
9
|
// native HANDLE_RADIUS_PX). Divided by zoom for a constant on-screen size.
|
|
10
10
|
const HANDLE_PX = 7;
|
|
@@ -171,7 +171,7 @@ export const AnnotationCanvasInner = (props) => {
|
|
|
171
171
|
...style,
|
|
172
172
|
};
|
|
173
173
|
const customPreview = activeTool?.renderPreview?.(state.customPreviewState, state.ctx);
|
|
174
|
-
const { renderMeasurementStamp, onMeasurementStampPress, selection } = props;
|
|
174
|
+
const { renderMeasurementStamp, onMeasurementStampPress, onMeasurementStampLongPress, selection, } = props;
|
|
175
175
|
return (_jsxs("div", { ref: containerRef, style: containerStyle, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerCancel, onWheel: handleWheel, onContextMenu: handleContextMenu, children: [AnnotationCanvasSkia({
|
|
176
176
|
width,
|
|
177
177
|
height,
|
|
@@ -183,15 +183,20 @@ export const AnnotationCanvasInner = (props) => {
|
|
|
183
183
|
// Endpoint handles on the selected line annotation. Web drives endpoint
|
|
184
184
|
// drag through selectTool's pointer handlers (preview patches update the
|
|
185
185
|
// line, so the handles follow via re-render); no live geometry needed.
|
|
186
|
+
// Handles are drag affordances — suppressed unless the active tool can
|
|
187
|
+
// act on them (view mode's pan tool selects measurements but must not
|
|
188
|
+
// advertise draggability).
|
|
186
189
|
selectedId: selection?.ids[0] ?? null,
|
|
187
|
-
handleRadius:
|
|
190
|
+
handleRadius: activeTool?.dragSelection
|
|
191
|
+
? HANDLE_PX / state.viewport.zoom
|
|
192
|
+
: undefined,
|
|
188
193
|
customPreview,
|
|
189
194
|
}), renderMeasurementStamp && (_jsx("div", { style: {
|
|
190
195
|
position: 'absolute',
|
|
191
196
|
inset: 0,
|
|
192
197
|
pointerEvents: 'none',
|
|
193
198
|
}, children: state.effectiveCanvas.placedMeasurements.map((placed) => {
|
|
194
|
-
const size =
|
|
199
|
+
const size = stampTileSize(placed);
|
|
195
200
|
const cx = (placed.anchor.x - state.viewport.pan.x) * state.viewport.zoom;
|
|
196
201
|
const cy = (placed.anchor.y - state.viewport.pan.y) * state.viewport.zoom;
|
|
197
202
|
const isSelected = selection?.ids.includes(placed.id) ?? false;
|
|
@@ -211,15 +216,9 @@ export const AnnotationCanvasInner = (props) => {
|
|
|
211
216
|
selected: isSelected,
|
|
212
217
|
size,
|
|
213
218
|
zoom: state.viewport.zoom,
|
|
214
|
-
}), onMeasurementStampPress && (_jsx(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
pointerEvents: 'auto',
|
|
218
|
-
cursor: 'pointer',
|
|
219
|
-
background: 'transparent',
|
|
220
|
-
border: 'none',
|
|
221
|
-
padding: 0,
|
|
222
|
-
} })), isSelected && measurement && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
|
|
219
|
+
}), onMeasurementStampPress && (_jsx(StampPressTarget, { onPress: () => onMeasurementStampPress(placed), onLongPress: onMeasurementStampLongPress
|
|
220
|
+
? () => onMeasurementStampLongPress(placed)
|
|
221
|
+
: undefined })), isSelected && measurement && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
|
|
223
222
|
e.stopPropagation();
|
|
224
223
|
const { ops, keepSelection } = buildRemoveMeasurementOps(placed);
|
|
225
224
|
state.ctx.commit({ ops });
|
|
@@ -236,3 +235,42 @@ export const AnnotationCanvasInner = (props) => {
|
|
|
236
235
|
} }))] }, placed.id));
|
|
237
236
|
}) }))] }));
|
|
238
237
|
};
|
|
238
|
+
// Whole-tile press target for the stamp overlay. The DOM has no native
|
|
239
|
+
// long-press, so it's derived: pointerdown arms a timer; if it fires before
|
|
240
|
+
// the pointer lifts (or leaves/cancels), the long-press callback runs and the
|
|
241
|
+
// trailing click is swallowed. Mirrors the native overlay's TouchableOpacity
|
|
242
|
+
// onPress/onLongPress semantics (500ms, RN's default delayLongPress).
|
|
243
|
+
const LONG_PRESS_MS = 500;
|
|
244
|
+
const StampPressTarget = ({ onPress, onLongPress, }) => {
|
|
245
|
+
const timerRef = useRef(null);
|
|
246
|
+
const longPressFiredRef = useRef(false);
|
|
247
|
+
const clearTimer = () => {
|
|
248
|
+
if (timerRef.current != null) {
|
|
249
|
+
clearTimeout(timerRef.current);
|
|
250
|
+
timerRef.current = null;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
return (_jsx("button", { "aria-label": "Open measurement", onPointerDown: (e) => {
|
|
254
|
+
e.stopPropagation();
|
|
255
|
+
longPressFiredRef.current = false;
|
|
256
|
+
if (onLongPress) {
|
|
257
|
+
clearTimer();
|
|
258
|
+
timerRef.current = setTimeout(() => {
|
|
259
|
+
timerRef.current = null;
|
|
260
|
+
longPressFiredRef.current = true;
|
|
261
|
+
onLongPress();
|
|
262
|
+
}, LONG_PRESS_MS);
|
|
263
|
+
}
|
|
264
|
+
}, onPointerUp: clearTimer, onPointerLeave: clearTimer, onPointerCancel: clearTimer, onClick: () => {
|
|
265
|
+
if (!longPressFiredRef.current)
|
|
266
|
+
onPress();
|
|
267
|
+
}, style: {
|
|
268
|
+
position: 'absolute',
|
|
269
|
+
inset: 0,
|
|
270
|
+
pointerEvents: 'auto',
|
|
271
|
+
cursor: 'pointer',
|
|
272
|
+
background: 'transparent',
|
|
273
|
+
border: 'none',
|
|
274
|
+
padding: 0,
|
|
275
|
+
} }));
|
|
276
|
+
};
|
|
@@ -24,6 +24,7 @@ export interface AnnotationCanvasInnerProps {
|
|
|
24
24
|
requestTextInput?: RequestTextInput;
|
|
25
25
|
renderMeasurementStamp?: RenderMeasurementStamp;
|
|
26
26
|
onMeasurementStampPress?: (placed: PlacedMeasurementRef) => void;
|
|
27
|
+
onMeasurementStampLongPress?: (placed: PlacedMeasurementRef) => void;
|
|
27
28
|
stampFontSource?: unknown;
|
|
28
29
|
stampValueFontSize?: number;
|
|
29
30
|
stampLabelFontSize?: number;
|