leaflet-tual 0.1.0 → 1.0.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/README.md +45 -45
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -59
- package/dist/index.d.ts +57 -59
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +92 -95
- package/dist/react.d.ts +92 -95
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ type ScreenPoint = {
|
|
|
10
10
|
};
|
|
11
11
|
type ArrowStyle = 'linear' | 'curved' | 'bi' | 'elbow' | 's-curve';
|
|
12
12
|
type ShapeKind = 'square' | 'circle' | 'star' | 'actor' | 'triangle' | 'diamond' | 'hexagon' | 'marker';
|
|
13
|
-
type
|
|
13
|
+
type TualTool = 'select' | 'freedraw' | 'arrow-linear' | 'arrow-curved' | 'arrow-bi' | 'arrow-elbow' | 'arrow-s-curve' | 'shape' | 'ruler' | 'note' | 'text';
|
|
14
14
|
type ToolbarToolGroupId = 'select' | 'freedraw' | 'arrow' | 'shape' | 'ruler' | 'note' | 'text';
|
|
15
15
|
type ArrowHeadStyle = 'triangle' | 'open' | 'both' | 'none';
|
|
16
16
|
interface ArrowItem {
|
|
@@ -93,11 +93,11 @@ interface RulerItem {
|
|
|
93
93
|
unit?: 'metric' | 'imperial';
|
|
94
94
|
createdAt: number;
|
|
95
95
|
}
|
|
96
|
-
type
|
|
96
|
+
type TualItem = ArrowItem | FreeDrawItem | ShapeItem | NoteItem | TextItem | RulerItem;
|
|
97
97
|
|
|
98
98
|
type ToolbarPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-center' | 'bottom-center' | 'left-center' | 'right-center';
|
|
99
99
|
type ToolbarOrientation = 'horizontal' | 'vertical';
|
|
100
|
-
interface
|
|
100
|
+
interface TualLabels {
|
|
101
101
|
select?: string;
|
|
102
102
|
freedraw?: string;
|
|
103
103
|
arrowGroup?: string;
|
|
@@ -151,7 +151,7 @@ interface CanvasLabels {
|
|
|
151
151
|
collapseToolbar?: string;
|
|
152
152
|
expandToolbar?: string;
|
|
153
153
|
}
|
|
154
|
-
interface
|
|
154
|
+
interface TualAnnotationTheme {
|
|
155
155
|
selectionGlowColor?: string;
|
|
156
156
|
selectionGlowWidth?: number;
|
|
157
157
|
guideLineDash?: readonly number[];
|
|
@@ -181,8 +181,8 @@ interface CanvasAnnotationTheme {
|
|
|
181
181
|
labelMaxTextWidth?: number;
|
|
182
182
|
fitLabelsToShape?: boolean;
|
|
183
183
|
}
|
|
184
|
-
type ArrowRenderTheme =
|
|
185
|
-
interface
|
|
184
|
+
type ArrowRenderTheme = TualAnnotationTheme;
|
|
185
|
+
interface LeafletTualClassNames {
|
|
186
186
|
overlay?: string;
|
|
187
187
|
canvas?: string;
|
|
188
188
|
drawingSurface?: string;
|
|
@@ -248,7 +248,7 @@ interface DraftRulerState {
|
|
|
248
248
|
startGeo: GeoPoint;
|
|
249
249
|
currentGeo: GeoPoint;
|
|
250
250
|
}
|
|
251
|
-
interface
|
|
251
|
+
interface TualOverlayOptions {
|
|
252
252
|
interactive?: boolean;
|
|
253
253
|
readOnly?: boolean;
|
|
254
254
|
zIndex?: number;
|
|
@@ -258,29 +258,29 @@ interface CanvasOverlayOptions {
|
|
|
258
258
|
defaultFontSize?: number;
|
|
259
259
|
defaultShape?: ShapeKind;
|
|
260
260
|
}
|
|
261
|
-
interface
|
|
262
|
-
initialItems?:
|
|
263
|
-
items?:
|
|
261
|
+
interface UseLeafletTualOptions extends TualOverlayOptions {
|
|
262
|
+
initialItems?: TualItem[];
|
|
263
|
+
items?: TualItem[];
|
|
264
264
|
maxHistory?: number;
|
|
265
|
-
onItemsChange?: (items:
|
|
266
|
-
onChange?: (items:
|
|
267
|
-
onChangeComplete?: (items:
|
|
268
|
-
onItemsChangeComplete?: (items:
|
|
269
|
-
onEditEnd?: (items:
|
|
270
|
-
onEditComplete?: (items:
|
|
271
|
-
onItemSelect?: (item:
|
|
272
|
-
onItemCreate?: (item:
|
|
273
|
-
onItemChange?: (item:
|
|
265
|
+
onItemsChange?: (items: TualItem[]) => void;
|
|
266
|
+
onChange?: (items: TualItem[]) => void;
|
|
267
|
+
onChangeComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
268
|
+
onItemsChangeComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
269
|
+
onEditEnd?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
270
|
+
onEditComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
271
|
+
onItemSelect?: (item: TualItem | null) => void;
|
|
272
|
+
onItemCreate?: (item: TualItem) => void;
|
|
273
|
+
onItemChange?: (item: TualItem) => void;
|
|
274
274
|
onItemDelete?: (id: string) => void;
|
|
275
|
-
onItemChangeComplete?: (item:
|
|
276
|
-
initialTool?:
|
|
277
|
-
onToolChange?: (tool:
|
|
275
|
+
onItemChangeComplete?: (item: TualItem) => void;
|
|
276
|
+
initialTool?: TualTool;
|
|
277
|
+
onToolChange?: (tool: TualTool) => void;
|
|
278
278
|
}
|
|
279
|
-
type
|
|
280
|
-
interface
|
|
281
|
-
items:
|
|
282
|
-
activeTool:
|
|
283
|
-
setActiveTool: (tool:
|
|
279
|
+
type LeafletTualOptions = UseLeafletTualOptions;
|
|
280
|
+
interface LeafletTualController {
|
|
281
|
+
items: TualItem[];
|
|
282
|
+
activeTool: TualTool;
|
|
283
|
+
setActiveTool: (tool: TualTool) => void;
|
|
284
284
|
readOnly: boolean;
|
|
285
285
|
setReadOnly: (readOnly: boolean) => void;
|
|
286
286
|
activeShape: ShapeKind;
|
|
@@ -289,7 +289,7 @@ interface LeafletCanvasController {
|
|
|
289
289
|
setShapeFilled: (filled: boolean) => void;
|
|
290
290
|
selectedId: string | null;
|
|
291
291
|
setSelectedId: (id: string | null) => void;
|
|
292
|
-
selectedItem:
|
|
292
|
+
selectedItem: TualItem | null;
|
|
293
293
|
isEditingLabel?: boolean;
|
|
294
294
|
setEditingLabel?: (editing: boolean) => void;
|
|
295
295
|
labelEditMode?: boolean;
|
|
@@ -306,20 +306,20 @@ interface LeafletCanvasController {
|
|
|
306
306
|
setFontSize: (size: number) => void;
|
|
307
307
|
fontWeight: 'normal' | 'bold';
|
|
308
308
|
setFontWeight: (weight: 'normal' | 'bold') => void;
|
|
309
|
-
addItem: (item:
|
|
310
|
-
updateItem: (id: string, patch: Partial<
|
|
309
|
+
addItem: (item: TualItem) => void;
|
|
310
|
+
updateItem: (id: string, patch: Partial<TualItem>) => void;
|
|
311
311
|
removeItem: (id: string) => void;
|
|
312
312
|
deleteSelected: () => void;
|
|
313
313
|
clearAll: () => void;
|
|
314
314
|
clear: () => void;
|
|
315
315
|
deleteItem: (id: string) => void;
|
|
316
|
-
setTool: (tool:
|
|
316
|
+
setTool: (tool: TualTool) => void;
|
|
317
317
|
selectItem: (id: string | null) => void;
|
|
318
318
|
undo: () => void;
|
|
319
319
|
redo: () => void;
|
|
320
320
|
canUndo: boolean;
|
|
321
321
|
canRedo: boolean;
|
|
322
|
-
notifyChangeComplete: (targetItem?:
|
|
322
|
+
notifyChangeComplete: (targetItem?: TualItem | null) => void;
|
|
323
323
|
exportJSON: () => string;
|
|
324
324
|
importJSON: (json: string) => boolean;
|
|
325
325
|
}
|
|
@@ -346,7 +346,7 @@ declare const FONT_SIZE_OPTIONS: readonly number[];
|
|
|
346
346
|
/**
|
|
347
347
|
* Super simple unified annotation default theme matching basic HTML element appearance.
|
|
348
348
|
*/
|
|
349
|
-
declare const DEFAULT_ANNOTATION_THEME: Readonly<
|
|
349
|
+
declare const DEFAULT_ANNOTATION_THEME: Readonly<TualAnnotationTheme>;
|
|
350
350
|
|
|
351
351
|
declare function createId(prefix?: string): string;
|
|
352
352
|
declare function geoToScreen(map: L.Map, point: GeoPoint): ScreenPoint;
|
|
@@ -362,7 +362,7 @@ declare function getMapDimensions(map: L.Map | null | undefined): {
|
|
|
362
362
|
width: number;
|
|
363
363
|
height: number;
|
|
364
364
|
} | null;
|
|
365
|
-
declare function
|
|
365
|
+
declare function truncateTualText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string;
|
|
366
366
|
declare function calculateZoomFontSize(initialFontSize: number | undefined, currentZoom: number | null, baseZoom?: number, options?: {
|
|
367
367
|
min?: number;
|
|
368
368
|
max?: number;
|
|
@@ -372,8 +372,8 @@ declare function calculateGeodesicDistance(p1: GeoPoint, p2: GeoPoint): number;
|
|
|
372
372
|
declare function formatRealWorldDistance(meters: number, unit?: 'metric' | 'imperial'): string;
|
|
373
373
|
declare function calculateLineDistance(points: GeoPoint[]): number;
|
|
374
374
|
|
|
375
|
-
declare function
|
|
376
|
-
declare function
|
|
375
|
+
declare function drawTualHandle(ctx: CanvasRenderingContext2D, pt: ScreenPoint, strokeColor: string, fillColor: string, radius: number, strokeWidth?: number): void;
|
|
376
|
+
declare function drawTualLabelPill(ctx: CanvasRenderingContext2D, label: string, midX: number, midY: number, strokeColor: string, maxAllowedBoxWidth: number, theme?: TualAnnotationTheme): void;
|
|
377
377
|
|
|
378
378
|
type ArrowHandleType = 'start' | 'end' | 'control';
|
|
379
379
|
interface ProjectedArrow {
|
|
@@ -397,7 +397,7 @@ declare function projectFreeDraw(map: L.Map, item: Pick<FreeDrawItem, 'points'>)
|
|
|
397
397
|
declare function renderFreeDrawOnCanvas(ctx: CanvasRenderingContext2D, screenPoints: ScreenPoint[], item: Pick<FreeDrawItem, 'color' | 'strokeWidth' | 'dashed'>, options?: {
|
|
398
398
|
isSelected?: boolean;
|
|
399
399
|
isPreview?: boolean;
|
|
400
|
-
theme?:
|
|
400
|
+
theme?: TualAnnotationTheme;
|
|
401
401
|
}): void;
|
|
402
402
|
declare function hitTestFreeDraw(point: ScreenPoint, screenPoints: ScreenPoint[], item: FreeDrawItem, tolerance?: number): boolean;
|
|
403
403
|
|
|
@@ -418,12 +418,12 @@ declare function projectShape(map: L.Map, shape: ShapeItem): ProjectedShape;
|
|
|
418
418
|
declare function renderShapeOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedShape, shape: Pick<ShapeItem, 'shape' | 'color' | 'fillColor' | 'filled' | 'strokeWidth' | 'dashed' | 'label'>, options?: {
|
|
419
419
|
isSelected?: boolean;
|
|
420
420
|
isPreview?: boolean;
|
|
421
|
-
theme?:
|
|
421
|
+
theme?: TualAnnotationTheme;
|
|
422
422
|
}): void;
|
|
423
423
|
declare function hitTestShapeHandle(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): ShapeHandleType | null;
|
|
424
424
|
declare function hitTestShape(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): boolean;
|
|
425
425
|
|
|
426
|
-
declare function tracePolygonShape(ctx: CanvasRenderingContext2D, proj: ProjectedShape, kind: ShapeKind, theme?:
|
|
426
|
+
declare function tracePolygonShape(ctx: CanvasRenderingContext2D, proj: ProjectedShape, kind: ShapeKind, theme?: TualAnnotationTheme): void;
|
|
427
427
|
|
|
428
428
|
type RulerHandleType = 'start' | 'end';
|
|
429
429
|
interface ProjectedRuler {
|
|
@@ -437,7 +437,7 @@ declare function projectRuler(map: L.Map, ruler: Pick<RulerItem, 'start' | 'end'
|
|
|
437
437
|
declare function renderRulerOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedRuler, ruler: Pick<RulerItem, 'start' | 'end' | 'color' | 'strokeWidth' | 'dashed' | 'label' | 'unit'>, options?: {
|
|
438
438
|
isSelected?: boolean;
|
|
439
439
|
isPreview?: boolean;
|
|
440
|
-
theme?:
|
|
440
|
+
theme?: TualAnnotationTheme;
|
|
441
441
|
}): void;
|
|
442
442
|
declare function hitTestRulerHandle(point: ScreenPoint, projected: ProjectedRuler, tolerance?: number): RulerHandleType | null;
|
|
443
443
|
declare function hitTestRuler(point: ScreenPoint, projected: ProjectedRuler, ruler: RulerItem, tolerance?: number): boolean;
|
|
@@ -480,7 +480,7 @@ declare function startFreeDrawBodyDrag(map: L.Map, fd: FreeDrawItem, initialScre
|
|
|
480
480
|
declare function startRulerHandleDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, handle: RulerHandleType, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
481
481
|
declare function startRulerBodyDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
482
482
|
|
|
483
|
-
interface
|
|
483
|
+
interface PaintLeafletTualOptions {
|
|
484
484
|
map: L.Map | null;
|
|
485
485
|
canvas: HTMLCanvasElement | null;
|
|
486
486
|
width: number;
|
|
@@ -501,11 +501,11 @@ interface PaintLeafletCanvasOptions {
|
|
|
501
501
|
strokeWidth: number;
|
|
502
502
|
dashed: boolean;
|
|
503
503
|
shapeFilled: boolean;
|
|
504
|
-
annotationTheme?:
|
|
504
|
+
annotationTheme?: TualAnnotationTheme;
|
|
505
505
|
arrowTheme?: ArrowRenderTheme;
|
|
506
506
|
isReadOnly: boolean;
|
|
507
507
|
}
|
|
508
|
-
declare function
|
|
508
|
+
declare function paintLeafletTual({ map, canvas, width, height, arrowItems, shapeItems, freeDrawItems, rulerItems, selectedId, draftShape, draftArrow, draftRuler, draftFreeDraw, activeColor, strokeWidth, dashed, shapeFilled, annotationTheme, arrowTheme, isReadOnly, }: PaintLeafletTualOptions): void;
|
|
509
509
|
|
|
510
510
|
interface MapViewportDimensions {
|
|
511
511
|
width: number;
|
|
@@ -514,29 +514,27 @@ interface MapViewportDimensions {
|
|
|
514
514
|
declare function bindLeafletSync(map: L.Map, onSync: (dimensions: MapViewportDimensions) => void): () => void;
|
|
515
515
|
declare function bindBlockMapDblClick(map: L.Map): () => void;
|
|
516
516
|
|
|
517
|
-
interface
|
|
518
|
-
subscribe: (listener: (controller:
|
|
519
|
-
getState: () =>
|
|
517
|
+
interface LeafletTualStore extends LeafletTualController {
|
|
518
|
+
subscribe: (listener: (controller: LeafletTualController) => void) => () => void;
|
|
519
|
+
getState: () => LeafletTualController;
|
|
520
520
|
destroy: () => void;
|
|
521
521
|
}
|
|
522
|
-
declare function
|
|
523
|
-
declare const createLeafletTualController: typeof createLeafletCanvasController;
|
|
522
|
+
declare function createLeafletTualController(options?: UseLeafletTualOptions): LeafletTualStore;
|
|
524
523
|
|
|
525
|
-
interface
|
|
526
|
-
controller?:
|
|
527
|
-
annotationTheme?:
|
|
524
|
+
interface CreateLeafletTualOptions extends UseLeafletTualOptions {
|
|
525
|
+
controller?: LeafletTualStore;
|
|
526
|
+
annotationTheme?: TualAnnotationTheme;
|
|
528
527
|
arrowTheme?: ArrowRenderTheme;
|
|
529
|
-
labels?:
|
|
528
|
+
labels?: TualLabels;
|
|
530
529
|
}
|
|
531
|
-
interface
|
|
532
|
-
controller:
|
|
530
|
+
interface LeafletTualInstance {
|
|
531
|
+
controller: LeafletTualStore;
|
|
533
532
|
container: HTMLDivElement;
|
|
534
533
|
canvas: HTMLCanvasElement;
|
|
535
534
|
repaint: () => void;
|
|
536
535
|
destroy: () => void;
|
|
537
536
|
}
|
|
538
|
-
declare function
|
|
539
|
-
declare const createLeafletTual: typeof createLeafletCanvas;
|
|
537
|
+
declare function createLeafletTual(map: L.Map, options?: CreateLeafletTualOptions): LeafletTualInstance;
|
|
540
538
|
|
|
541
539
|
/**
|
|
542
540
|
* leaflet-tual — core (framework-agnostic)
|
|
@@ -550,10 +548,10 @@ declare const createLeafletTual: typeof createLeafletCanvas;
|
|
|
550
548
|
* dependency on React or any UI framework, so it can be used directly from
|
|
551
549
|
* vanilla JavaScript, TypeScript, Vue, Svelte, Angular, or a plain `<script>` tag.
|
|
552
550
|
*
|
|
553
|
-
* React users: see `leaflet-tual/react` for `<
|
|
554
|
-
* `
|
|
551
|
+
* React users: see `leaflet-tual/react` for `<LeafletTual>`, `<TualToolbar>`,
|
|
552
|
+
* `useLeafletTual`, and `useLeafletSync`.
|
|
555
553
|
*/
|
|
556
554
|
|
|
557
555
|
declare const VERSION: string;
|
|
558
556
|
|
|
559
|
-
export { type ArrowHandleType, type ArrowHeadStyle, type ArrowItem, type ArrowRenderTheme, type ArrowStyle, type
|
|
557
|
+
export { type ArrowHandleType, type ArrowHeadStyle, type ArrowItem, type ArrowRenderTheme, type ArrowStyle, type CreateLeafletTualOptions, DEFAULT_ANNOTATION_THEME, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE_OPTIONS, DEFAULT_NOTE_BG, DEFAULT_NOTE_TEXT, DEFAULT_STROKE_COLOR, DEFAULT_STROKE_WIDTH, DEFAULT_STROKE_WIDTH_OPTIONS, type DraftArrowState, type DraftRulerState, type DraftShapeState, FONT_SIZE_OPTIONS, type FreeDrawItem, type GeoPoint, type LeafletTualClassNames, type LeafletTualController, type LeafletTualInstance, type LeafletTualOptions, type LeafletTualStore, type MapViewportDimensions, NOTE_COLOR_THEMES, type NoteCollapseState, type NoteColorTheme, type NoteItem, type PaintLeafletTualOptions, type ProjectedArrow, type ProjectedRuler, type ProjectedShape, type ResolvedNoteTheme, type RulerHandleType, type RulerItem, STROKE_COLORS, STROKE_WIDTH_OPTIONS, type ScreenPoint, type ShapeHandleType, type ShapeItem, type ShapeKind, TOOL_TO_ARROW_STYLE, type TextItem, type ToolbarOrientation, type ToolbarPosition, type ToolbarToolGroupId, type TualAnnotationTheme, type TualItem, type TualLabels, type TualOverlayOptions, type TualTool, type UseLeafletTualOptions, VERSION, bindBlockMapDblClick, bindLeafletSync, buildArrowItem, buildRulerItem, calculateGeodesicDistance, calculateLineDistance, calculateZoomFontSize, clampNotePosition, clampTextPosition, computeDefaultControlGeoPoint, constrainAngleTo45Degrees, constrainToAspectRatio, createDraftNote, createDraftText, createId, createLeafletTual, createLeafletTualController, distanceToQuadraticBezier, distanceToSegment, drawArrowHead, drawTualHandle, drawTualLabelPill, formatRealWorldDistance, geoToScreen, getMapDimensions, getQuadraticBezierPoint, getQuadraticEndAngle, hitTestArrow, hitTestArrowHandle, hitTestFreeDraw, hitTestRuler, hitTestRulerHandle, hitTestShape, hitTestShapeHandle, paintLeafletTual, projectArrow, projectFreeDraw, projectRuler, projectShape, renderArrowOnCanvas, renderFreeDrawOnCanvas, renderRulerOnCanvas, renderShapeOnCanvas, resolveNoteTheme, screenToGeo, startArrowBodyDrag, startArrowDrag, startArrowHandleDrag, startFreeDrawBodyDrag, startFreeDrawDrag, startRulerBodyDrag, startRulerDrag, startRulerHandleDrag, startShapeBodyDrag, startShapeDrag, startShapeHandleDrag, traceArrowPath, tracePolygonShape, truncateTualText };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ type ScreenPoint = {
|
|
|
10
10
|
};
|
|
11
11
|
type ArrowStyle = 'linear' | 'curved' | 'bi' | 'elbow' | 's-curve';
|
|
12
12
|
type ShapeKind = 'square' | 'circle' | 'star' | 'actor' | 'triangle' | 'diamond' | 'hexagon' | 'marker';
|
|
13
|
-
type
|
|
13
|
+
type TualTool = 'select' | 'freedraw' | 'arrow-linear' | 'arrow-curved' | 'arrow-bi' | 'arrow-elbow' | 'arrow-s-curve' | 'shape' | 'ruler' | 'note' | 'text';
|
|
14
14
|
type ToolbarToolGroupId = 'select' | 'freedraw' | 'arrow' | 'shape' | 'ruler' | 'note' | 'text';
|
|
15
15
|
type ArrowHeadStyle = 'triangle' | 'open' | 'both' | 'none';
|
|
16
16
|
interface ArrowItem {
|
|
@@ -93,11 +93,11 @@ interface RulerItem {
|
|
|
93
93
|
unit?: 'metric' | 'imperial';
|
|
94
94
|
createdAt: number;
|
|
95
95
|
}
|
|
96
|
-
type
|
|
96
|
+
type TualItem = ArrowItem | FreeDrawItem | ShapeItem | NoteItem | TextItem | RulerItem;
|
|
97
97
|
|
|
98
98
|
type ToolbarPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-center' | 'bottom-center' | 'left-center' | 'right-center';
|
|
99
99
|
type ToolbarOrientation = 'horizontal' | 'vertical';
|
|
100
|
-
interface
|
|
100
|
+
interface TualLabels {
|
|
101
101
|
select?: string;
|
|
102
102
|
freedraw?: string;
|
|
103
103
|
arrowGroup?: string;
|
|
@@ -151,7 +151,7 @@ interface CanvasLabels {
|
|
|
151
151
|
collapseToolbar?: string;
|
|
152
152
|
expandToolbar?: string;
|
|
153
153
|
}
|
|
154
|
-
interface
|
|
154
|
+
interface TualAnnotationTheme {
|
|
155
155
|
selectionGlowColor?: string;
|
|
156
156
|
selectionGlowWidth?: number;
|
|
157
157
|
guideLineDash?: readonly number[];
|
|
@@ -181,8 +181,8 @@ interface CanvasAnnotationTheme {
|
|
|
181
181
|
labelMaxTextWidth?: number;
|
|
182
182
|
fitLabelsToShape?: boolean;
|
|
183
183
|
}
|
|
184
|
-
type ArrowRenderTheme =
|
|
185
|
-
interface
|
|
184
|
+
type ArrowRenderTheme = TualAnnotationTheme;
|
|
185
|
+
interface LeafletTualClassNames {
|
|
186
186
|
overlay?: string;
|
|
187
187
|
canvas?: string;
|
|
188
188
|
drawingSurface?: string;
|
|
@@ -248,7 +248,7 @@ interface DraftRulerState {
|
|
|
248
248
|
startGeo: GeoPoint;
|
|
249
249
|
currentGeo: GeoPoint;
|
|
250
250
|
}
|
|
251
|
-
interface
|
|
251
|
+
interface TualOverlayOptions {
|
|
252
252
|
interactive?: boolean;
|
|
253
253
|
readOnly?: boolean;
|
|
254
254
|
zIndex?: number;
|
|
@@ -258,29 +258,29 @@ interface CanvasOverlayOptions {
|
|
|
258
258
|
defaultFontSize?: number;
|
|
259
259
|
defaultShape?: ShapeKind;
|
|
260
260
|
}
|
|
261
|
-
interface
|
|
262
|
-
initialItems?:
|
|
263
|
-
items?:
|
|
261
|
+
interface UseLeafletTualOptions extends TualOverlayOptions {
|
|
262
|
+
initialItems?: TualItem[];
|
|
263
|
+
items?: TualItem[];
|
|
264
264
|
maxHistory?: number;
|
|
265
|
-
onItemsChange?: (items:
|
|
266
|
-
onChange?: (items:
|
|
267
|
-
onChangeComplete?: (items:
|
|
268
|
-
onItemsChangeComplete?: (items:
|
|
269
|
-
onEditEnd?: (items:
|
|
270
|
-
onEditComplete?: (items:
|
|
271
|
-
onItemSelect?: (item:
|
|
272
|
-
onItemCreate?: (item:
|
|
273
|
-
onItemChange?: (item:
|
|
265
|
+
onItemsChange?: (items: TualItem[]) => void;
|
|
266
|
+
onChange?: (items: TualItem[]) => void;
|
|
267
|
+
onChangeComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
268
|
+
onItemsChangeComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
269
|
+
onEditEnd?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
270
|
+
onEditComplete?: (items: TualItem[], targetItem?: TualItem | null) => void;
|
|
271
|
+
onItemSelect?: (item: TualItem | null) => void;
|
|
272
|
+
onItemCreate?: (item: TualItem) => void;
|
|
273
|
+
onItemChange?: (item: TualItem) => void;
|
|
274
274
|
onItemDelete?: (id: string) => void;
|
|
275
|
-
onItemChangeComplete?: (item:
|
|
276
|
-
initialTool?:
|
|
277
|
-
onToolChange?: (tool:
|
|
275
|
+
onItemChangeComplete?: (item: TualItem) => void;
|
|
276
|
+
initialTool?: TualTool;
|
|
277
|
+
onToolChange?: (tool: TualTool) => void;
|
|
278
278
|
}
|
|
279
|
-
type
|
|
280
|
-
interface
|
|
281
|
-
items:
|
|
282
|
-
activeTool:
|
|
283
|
-
setActiveTool: (tool:
|
|
279
|
+
type LeafletTualOptions = UseLeafletTualOptions;
|
|
280
|
+
interface LeafletTualController {
|
|
281
|
+
items: TualItem[];
|
|
282
|
+
activeTool: TualTool;
|
|
283
|
+
setActiveTool: (tool: TualTool) => void;
|
|
284
284
|
readOnly: boolean;
|
|
285
285
|
setReadOnly: (readOnly: boolean) => void;
|
|
286
286
|
activeShape: ShapeKind;
|
|
@@ -289,7 +289,7 @@ interface LeafletCanvasController {
|
|
|
289
289
|
setShapeFilled: (filled: boolean) => void;
|
|
290
290
|
selectedId: string | null;
|
|
291
291
|
setSelectedId: (id: string | null) => void;
|
|
292
|
-
selectedItem:
|
|
292
|
+
selectedItem: TualItem | null;
|
|
293
293
|
isEditingLabel?: boolean;
|
|
294
294
|
setEditingLabel?: (editing: boolean) => void;
|
|
295
295
|
labelEditMode?: boolean;
|
|
@@ -306,20 +306,20 @@ interface LeafletCanvasController {
|
|
|
306
306
|
setFontSize: (size: number) => void;
|
|
307
307
|
fontWeight: 'normal' | 'bold';
|
|
308
308
|
setFontWeight: (weight: 'normal' | 'bold') => void;
|
|
309
|
-
addItem: (item:
|
|
310
|
-
updateItem: (id: string, patch: Partial<
|
|
309
|
+
addItem: (item: TualItem) => void;
|
|
310
|
+
updateItem: (id: string, patch: Partial<TualItem>) => void;
|
|
311
311
|
removeItem: (id: string) => void;
|
|
312
312
|
deleteSelected: () => void;
|
|
313
313
|
clearAll: () => void;
|
|
314
314
|
clear: () => void;
|
|
315
315
|
deleteItem: (id: string) => void;
|
|
316
|
-
setTool: (tool:
|
|
316
|
+
setTool: (tool: TualTool) => void;
|
|
317
317
|
selectItem: (id: string | null) => void;
|
|
318
318
|
undo: () => void;
|
|
319
319
|
redo: () => void;
|
|
320
320
|
canUndo: boolean;
|
|
321
321
|
canRedo: boolean;
|
|
322
|
-
notifyChangeComplete: (targetItem?:
|
|
322
|
+
notifyChangeComplete: (targetItem?: TualItem | null) => void;
|
|
323
323
|
exportJSON: () => string;
|
|
324
324
|
importJSON: (json: string) => boolean;
|
|
325
325
|
}
|
|
@@ -346,7 +346,7 @@ declare const FONT_SIZE_OPTIONS: readonly number[];
|
|
|
346
346
|
/**
|
|
347
347
|
* Super simple unified annotation default theme matching basic HTML element appearance.
|
|
348
348
|
*/
|
|
349
|
-
declare const DEFAULT_ANNOTATION_THEME: Readonly<
|
|
349
|
+
declare const DEFAULT_ANNOTATION_THEME: Readonly<TualAnnotationTheme>;
|
|
350
350
|
|
|
351
351
|
declare function createId(prefix?: string): string;
|
|
352
352
|
declare function geoToScreen(map: L.Map, point: GeoPoint): ScreenPoint;
|
|
@@ -362,7 +362,7 @@ declare function getMapDimensions(map: L.Map | null | undefined): {
|
|
|
362
362
|
width: number;
|
|
363
363
|
height: number;
|
|
364
364
|
} | null;
|
|
365
|
-
declare function
|
|
365
|
+
declare function truncateTualText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string;
|
|
366
366
|
declare function calculateZoomFontSize(initialFontSize: number | undefined, currentZoom: number | null, baseZoom?: number, options?: {
|
|
367
367
|
min?: number;
|
|
368
368
|
max?: number;
|
|
@@ -372,8 +372,8 @@ declare function calculateGeodesicDistance(p1: GeoPoint, p2: GeoPoint): number;
|
|
|
372
372
|
declare function formatRealWorldDistance(meters: number, unit?: 'metric' | 'imperial'): string;
|
|
373
373
|
declare function calculateLineDistance(points: GeoPoint[]): number;
|
|
374
374
|
|
|
375
|
-
declare function
|
|
376
|
-
declare function
|
|
375
|
+
declare function drawTualHandle(ctx: CanvasRenderingContext2D, pt: ScreenPoint, strokeColor: string, fillColor: string, radius: number, strokeWidth?: number): void;
|
|
376
|
+
declare function drawTualLabelPill(ctx: CanvasRenderingContext2D, label: string, midX: number, midY: number, strokeColor: string, maxAllowedBoxWidth: number, theme?: TualAnnotationTheme): void;
|
|
377
377
|
|
|
378
378
|
type ArrowHandleType = 'start' | 'end' | 'control';
|
|
379
379
|
interface ProjectedArrow {
|
|
@@ -397,7 +397,7 @@ declare function projectFreeDraw(map: L.Map, item: Pick<FreeDrawItem, 'points'>)
|
|
|
397
397
|
declare function renderFreeDrawOnCanvas(ctx: CanvasRenderingContext2D, screenPoints: ScreenPoint[], item: Pick<FreeDrawItem, 'color' | 'strokeWidth' | 'dashed'>, options?: {
|
|
398
398
|
isSelected?: boolean;
|
|
399
399
|
isPreview?: boolean;
|
|
400
|
-
theme?:
|
|
400
|
+
theme?: TualAnnotationTheme;
|
|
401
401
|
}): void;
|
|
402
402
|
declare function hitTestFreeDraw(point: ScreenPoint, screenPoints: ScreenPoint[], item: FreeDrawItem, tolerance?: number): boolean;
|
|
403
403
|
|
|
@@ -418,12 +418,12 @@ declare function projectShape(map: L.Map, shape: ShapeItem): ProjectedShape;
|
|
|
418
418
|
declare function renderShapeOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedShape, shape: Pick<ShapeItem, 'shape' | 'color' | 'fillColor' | 'filled' | 'strokeWidth' | 'dashed' | 'label'>, options?: {
|
|
419
419
|
isSelected?: boolean;
|
|
420
420
|
isPreview?: boolean;
|
|
421
|
-
theme?:
|
|
421
|
+
theme?: TualAnnotationTheme;
|
|
422
422
|
}): void;
|
|
423
423
|
declare function hitTestShapeHandle(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): ShapeHandleType | null;
|
|
424
424
|
declare function hitTestShape(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): boolean;
|
|
425
425
|
|
|
426
|
-
declare function tracePolygonShape(ctx: CanvasRenderingContext2D, proj: ProjectedShape, kind: ShapeKind, theme?:
|
|
426
|
+
declare function tracePolygonShape(ctx: CanvasRenderingContext2D, proj: ProjectedShape, kind: ShapeKind, theme?: TualAnnotationTheme): void;
|
|
427
427
|
|
|
428
428
|
type RulerHandleType = 'start' | 'end';
|
|
429
429
|
interface ProjectedRuler {
|
|
@@ -437,7 +437,7 @@ declare function projectRuler(map: L.Map, ruler: Pick<RulerItem, 'start' | 'end'
|
|
|
437
437
|
declare function renderRulerOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedRuler, ruler: Pick<RulerItem, 'start' | 'end' | 'color' | 'strokeWidth' | 'dashed' | 'label' | 'unit'>, options?: {
|
|
438
438
|
isSelected?: boolean;
|
|
439
439
|
isPreview?: boolean;
|
|
440
|
-
theme?:
|
|
440
|
+
theme?: TualAnnotationTheme;
|
|
441
441
|
}): void;
|
|
442
442
|
declare function hitTestRulerHandle(point: ScreenPoint, projected: ProjectedRuler, tolerance?: number): RulerHandleType | null;
|
|
443
443
|
declare function hitTestRuler(point: ScreenPoint, projected: ProjectedRuler, ruler: RulerItem, tolerance?: number): boolean;
|
|
@@ -480,7 +480,7 @@ declare function startFreeDrawBodyDrag(map: L.Map, fd: FreeDrawItem, initialScre
|
|
|
480
480
|
declare function startRulerHandleDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, handle: RulerHandleType, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
481
481
|
declare function startRulerBodyDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
482
482
|
|
|
483
|
-
interface
|
|
483
|
+
interface PaintLeafletTualOptions {
|
|
484
484
|
map: L.Map | null;
|
|
485
485
|
canvas: HTMLCanvasElement | null;
|
|
486
486
|
width: number;
|
|
@@ -501,11 +501,11 @@ interface PaintLeafletCanvasOptions {
|
|
|
501
501
|
strokeWidth: number;
|
|
502
502
|
dashed: boolean;
|
|
503
503
|
shapeFilled: boolean;
|
|
504
|
-
annotationTheme?:
|
|
504
|
+
annotationTheme?: TualAnnotationTheme;
|
|
505
505
|
arrowTheme?: ArrowRenderTheme;
|
|
506
506
|
isReadOnly: boolean;
|
|
507
507
|
}
|
|
508
|
-
declare function
|
|
508
|
+
declare function paintLeafletTual({ map, canvas, width, height, arrowItems, shapeItems, freeDrawItems, rulerItems, selectedId, draftShape, draftArrow, draftRuler, draftFreeDraw, activeColor, strokeWidth, dashed, shapeFilled, annotationTheme, arrowTheme, isReadOnly, }: PaintLeafletTualOptions): void;
|
|
509
509
|
|
|
510
510
|
interface MapViewportDimensions {
|
|
511
511
|
width: number;
|
|
@@ -514,29 +514,27 @@ interface MapViewportDimensions {
|
|
|
514
514
|
declare function bindLeafletSync(map: L.Map, onSync: (dimensions: MapViewportDimensions) => void): () => void;
|
|
515
515
|
declare function bindBlockMapDblClick(map: L.Map): () => void;
|
|
516
516
|
|
|
517
|
-
interface
|
|
518
|
-
subscribe: (listener: (controller:
|
|
519
|
-
getState: () =>
|
|
517
|
+
interface LeafletTualStore extends LeafletTualController {
|
|
518
|
+
subscribe: (listener: (controller: LeafletTualController) => void) => () => void;
|
|
519
|
+
getState: () => LeafletTualController;
|
|
520
520
|
destroy: () => void;
|
|
521
521
|
}
|
|
522
|
-
declare function
|
|
523
|
-
declare const createLeafletTualController: typeof createLeafletCanvasController;
|
|
522
|
+
declare function createLeafletTualController(options?: UseLeafletTualOptions): LeafletTualStore;
|
|
524
523
|
|
|
525
|
-
interface
|
|
526
|
-
controller?:
|
|
527
|
-
annotationTheme?:
|
|
524
|
+
interface CreateLeafletTualOptions extends UseLeafletTualOptions {
|
|
525
|
+
controller?: LeafletTualStore;
|
|
526
|
+
annotationTheme?: TualAnnotationTheme;
|
|
528
527
|
arrowTheme?: ArrowRenderTheme;
|
|
529
|
-
labels?:
|
|
528
|
+
labels?: TualLabels;
|
|
530
529
|
}
|
|
531
|
-
interface
|
|
532
|
-
controller:
|
|
530
|
+
interface LeafletTualInstance {
|
|
531
|
+
controller: LeafletTualStore;
|
|
533
532
|
container: HTMLDivElement;
|
|
534
533
|
canvas: HTMLCanvasElement;
|
|
535
534
|
repaint: () => void;
|
|
536
535
|
destroy: () => void;
|
|
537
536
|
}
|
|
538
|
-
declare function
|
|
539
|
-
declare const createLeafletTual: typeof createLeafletCanvas;
|
|
537
|
+
declare function createLeafletTual(map: L.Map, options?: CreateLeafletTualOptions): LeafletTualInstance;
|
|
540
538
|
|
|
541
539
|
/**
|
|
542
540
|
* leaflet-tual — core (framework-agnostic)
|
|
@@ -550,10 +548,10 @@ declare const createLeafletTual: typeof createLeafletCanvas;
|
|
|
550
548
|
* dependency on React or any UI framework, so it can be used directly from
|
|
551
549
|
* vanilla JavaScript, TypeScript, Vue, Svelte, Angular, or a plain `<script>` tag.
|
|
552
550
|
*
|
|
553
|
-
* React users: see `leaflet-tual/react` for `<
|
|
554
|
-
* `
|
|
551
|
+
* React users: see `leaflet-tual/react` for `<LeafletTual>`, `<TualToolbar>`,
|
|
552
|
+
* `useLeafletTual`, and `useLeafletSync`.
|
|
555
553
|
*/
|
|
556
554
|
|
|
557
555
|
declare const VERSION: string;
|
|
558
556
|
|
|
559
|
-
export { type ArrowHandleType, type ArrowHeadStyle, type ArrowItem, type ArrowRenderTheme, type ArrowStyle, type
|
|
557
|
+
export { type ArrowHandleType, type ArrowHeadStyle, type ArrowItem, type ArrowRenderTheme, type ArrowStyle, type CreateLeafletTualOptions, DEFAULT_ANNOTATION_THEME, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE_OPTIONS, DEFAULT_NOTE_BG, DEFAULT_NOTE_TEXT, DEFAULT_STROKE_COLOR, DEFAULT_STROKE_WIDTH, DEFAULT_STROKE_WIDTH_OPTIONS, type DraftArrowState, type DraftRulerState, type DraftShapeState, FONT_SIZE_OPTIONS, type FreeDrawItem, type GeoPoint, type LeafletTualClassNames, type LeafletTualController, type LeafletTualInstance, type LeafletTualOptions, type LeafletTualStore, type MapViewportDimensions, NOTE_COLOR_THEMES, type NoteCollapseState, type NoteColorTheme, type NoteItem, type PaintLeafletTualOptions, type ProjectedArrow, type ProjectedRuler, type ProjectedShape, type ResolvedNoteTheme, type RulerHandleType, type RulerItem, STROKE_COLORS, STROKE_WIDTH_OPTIONS, type ScreenPoint, type ShapeHandleType, type ShapeItem, type ShapeKind, TOOL_TO_ARROW_STYLE, type TextItem, type ToolbarOrientation, type ToolbarPosition, type ToolbarToolGroupId, type TualAnnotationTheme, type TualItem, type TualLabels, type TualOverlayOptions, type TualTool, type UseLeafletTualOptions, VERSION, bindBlockMapDblClick, bindLeafletSync, buildArrowItem, buildRulerItem, calculateGeodesicDistance, calculateLineDistance, calculateZoomFontSize, clampNotePosition, clampTextPosition, computeDefaultControlGeoPoint, constrainAngleTo45Degrees, constrainToAspectRatio, createDraftNote, createDraftText, createId, createLeafletTual, createLeafletTualController, distanceToQuadraticBezier, distanceToSegment, drawArrowHead, drawTualHandle, drawTualLabelPill, formatRealWorldDistance, geoToScreen, getMapDimensions, getQuadraticBezierPoint, getQuadraticEndAngle, hitTestArrow, hitTestArrowHandle, hitTestFreeDraw, hitTestRuler, hitTestRulerHandle, hitTestShape, hitTestShapeHandle, paintLeafletTual, projectArrow, projectFreeDraw, projectRuler, projectShape, renderArrowOnCanvas, renderFreeDrawOnCanvas, renderRulerOnCanvas, renderShapeOnCanvas, resolveNoteTheme, screenToGeo, startArrowBodyDrag, startArrowDrag, startArrowHandleDrag, startFreeDrawBodyDrag, startFreeDrawDrag, startRulerBodyDrag, startRulerDrag, startRulerHandleDrag, startShapeBodyDrag, startShapeDrag, startShapeHandleDrag, traceArrowPath, tracePolygonShape, truncateTualText };
|