@linkurious/ogma-annotations 1.1.16 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -5
- package/dist/index.mjs +169 -166
- package/dist/types/index.d.ts +615 -7
- package/package.json +7 -4
- package/dist/types/Control.d.ts +0 -112
- package/dist/types/Editor/Arrows/defaults.d.ts +0 -10
- package/dist/types/Editor/Arrows/index.d.ts +0 -39
- package/dist/types/Editor/Arrows/render.d.ts +0 -13
- package/dist/types/Editor/Texts/defaults.d.ts +0 -5
- package/dist/types/Editor/Texts/index.d.ts +0 -42
- package/dist/types/Editor/Texts/render.d.ts +0 -7
- package/dist/types/Editor/base.d.ts +0 -84
- package/dist/types/constants.d.ts +0 -13
- package/dist/types/links.d.ts +0 -21
- package/dist/types/types.d.ts +0 -191
- package/dist/types/utils.d.ts +0 -56
- package/dist/types/vec.d.ts +0 -15
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,615 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BBox } from 'geojson';
|
|
2
|
+
import { default as default_2 } from 'eventemitter3';
|
|
3
|
+
import { default as default_3 } from '@linkurious/ogma';
|
|
4
|
+
import { Feature } from 'geojson';
|
|
5
|
+
import { FeatureCollection } from 'geojson';
|
|
6
|
+
import { Geometry } from 'geojson';
|
|
7
|
+
import { GeometryObject } from 'geojson';
|
|
8
|
+
import { LineString } from 'geojson';
|
|
9
|
+
import { Options } from '@linkurious/ogma';
|
|
10
|
+
import { Overlay } from '@linkurious/ogma';
|
|
11
|
+
import { Point as Point_2 } from '@linkurious/ogma';
|
|
12
|
+
import { Polygon } from 'geojson';
|
|
13
|
+
import { SVGLayer } from '@linkurious/ogma';
|
|
14
|
+
|
|
15
|
+
export declare type Annotation = Arrow | Text_2;
|
|
16
|
+
|
|
17
|
+
export declare interface AnnotationCollection extends FeatureCollection {
|
|
18
|
+
features: (Arrow | Text_2)[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface AnnotationFeature<G extends GeometryObject = GeometryObject, P = AnnotationProps> extends Feature<G, P> {
|
|
22
|
+
id: string | number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare type AnnotationOptions = {
|
|
26
|
+
handleSize: number;
|
|
27
|
+
placeholder: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export declare interface AnnotationProps {
|
|
31
|
+
type: AnnotationType;
|
|
32
|
+
style?: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare type AnnotationType = "arrow" | "text";
|
|
36
|
+
|
|
37
|
+
export declare type Arrow = AnnotationFeature<LineString, ArrowProperties>;
|
|
38
|
+
|
|
39
|
+
export declare interface ArrowProperties extends AnnotationProps {
|
|
40
|
+
type: "arrow";
|
|
41
|
+
style?: ArrowStyles;
|
|
42
|
+
link?: Partial<Record<Side, ExportedLink>>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @class Arrows
|
|
47
|
+
* Draw and edit arrows
|
|
48
|
+
*/
|
|
49
|
+
export declare class Arrows extends Editor<Arrow> {
|
|
50
|
+
private draggedHandle;
|
|
51
|
+
private start;
|
|
52
|
+
private end;
|
|
53
|
+
private arrow;
|
|
54
|
+
private startX;
|
|
55
|
+
private startY;
|
|
56
|
+
private minArrowHeight;
|
|
57
|
+
private maxArrowHeight;
|
|
58
|
+
private handles;
|
|
59
|
+
constructor(ogma: default_3, options?: Pick<Partial<ControllerOptions>, "arrowHandleSize" | "maxArrowHeight" | "minArrowHeight">);
|
|
60
|
+
private onHandleMouseDown;
|
|
61
|
+
/**
|
|
62
|
+
* Start drawing a new arrow, it will also be added as a new annotation
|
|
63
|
+
* @param x
|
|
64
|
+
* @param y
|
|
65
|
+
* @param arrow
|
|
66
|
+
*/
|
|
67
|
+
startDrawing(x: number, y: number, arrow?: Arrow): void;
|
|
68
|
+
cancelDrawing(): void;
|
|
69
|
+
private startDragging;
|
|
70
|
+
private onMouseUp;
|
|
71
|
+
private onMouseMove;
|
|
72
|
+
detect(point: Point_2, margin?: number): Arrow | undefined;
|
|
73
|
+
refreshEditor(): void;
|
|
74
|
+
getDefaultOptions(): Arrow;
|
|
75
|
+
draw(svg: SVGSVGElement): void;
|
|
76
|
+
refreshDrawing(): void;
|
|
77
|
+
destroy(): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare interface ArrowStyles extends StrokeOptions {
|
|
81
|
+
tail?: Extremity;
|
|
82
|
+
head?: Extremity;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare type Bounds = [number, number, number, number];
|
|
86
|
+
|
|
87
|
+
export declare function clientToContainerPosition(evt: {
|
|
88
|
+
clientX: number;
|
|
89
|
+
clientY: number;
|
|
90
|
+
}, container?: HTMLElement | null): {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export declare class Control extends default_2<FeatureEvents> {
|
|
96
|
+
private arrows;
|
|
97
|
+
private texts;
|
|
98
|
+
private links;
|
|
99
|
+
private layer;
|
|
100
|
+
private annotations;
|
|
101
|
+
private ogma;
|
|
102
|
+
private options;
|
|
103
|
+
private selected;
|
|
104
|
+
private updateTimeout;
|
|
105
|
+
private hoveredNode;
|
|
106
|
+
private dragged;
|
|
107
|
+
private textToMagnet;
|
|
108
|
+
private activeLinks;
|
|
109
|
+
constructor(ogma: default_3, options?: Partial<ControllerOptions>);
|
|
110
|
+
private _render;
|
|
111
|
+
private _onFeatureDrag;
|
|
112
|
+
private _onFeatureDragEnd;
|
|
113
|
+
private _onFeatureDragStart;
|
|
114
|
+
private _onNodesDragStart;
|
|
115
|
+
private _onNodesDrag;
|
|
116
|
+
private _onLayoutEnd;
|
|
117
|
+
private _moveNodes;
|
|
118
|
+
private _snapToText;
|
|
119
|
+
private _findAndSnapToNode;
|
|
120
|
+
private _snapToNode;
|
|
121
|
+
private _onAdded;
|
|
122
|
+
private _onRemoved;
|
|
123
|
+
private _onUnselect;
|
|
124
|
+
private _onSelect;
|
|
125
|
+
private refreshTextLinks;
|
|
126
|
+
/**
|
|
127
|
+
* @returns the currently selected annotation
|
|
128
|
+
*/
|
|
129
|
+
getSelected(): Annotation | null;
|
|
130
|
+
private findMagnetPoint;
|
|
131
|
+
/**
|
|
132
|
+
* Set the options for the controller
|
|
133
|
+
* @param options new Options
|
|
134
|
+
* @returns the updated options
|
|
135
|
+
*/
|
|
136
|
+
setOptions(options?: Partial<ControllerOptions>): ControllerOptions;
|
|
137
|
+
/**
|
|
138
|
+
* Selects the annotation with the given id
|
|
139
|
+
* @param id the id of the annotation to select
|
|
140
|
+
*/
|
|
141
|
+
select(id: Id): this;
|
|
142
|
+
/**
|
|
143
|
+
* Unselects the currently selected annotation
|
|
144
|
+
*/
|
|
145
|
+
unselect(): this;
|
|
146
|
+
/**
|
|
147
|
+
* Add an annotation to the controller
|
|
148
|
+
* @param annotation The annotation to add
|
|
149
|
+
*/
|
|
150
|
+
add(annotation: Arrow | Text_2 | AnnotationCollection): this;
|
|
151
|
+
/**
|
|
152
|
+
* Remove an annotation or an array of annotations from the controller
|
|
153
|
+
* @param annotation The annotation(s) to remove
|
|
154
|
+
*/
|
|
155
|
+
remove(annotation: Arrow | Text_2 | AnnotationCollection): this;
|
|
156
|
+
private loadLink;
|
|
157
|
+
/**
|
|
158
|
+
* Start adding an arrow (add it, and give control to the user)
|
|
159
|
+
* @param x coord of the first point
|
|
160
|
+
* @param y coord of the first point
|
|
161
|
+
* @param arrow The arrow to add
|
|
162
|
+
*/
|
|
163
|
+
startArrow(x: number, y: number, arrow?: Arrow): void;
|
|
164
|
+
/**
|
|
165
|
+
* Start adding a text (add it, and give control to the user)
|
|
166
|
+
* @param x coord of the top left point
|
|
167
|
+
* @param y coord of the top left point
|
|
168
|
+
* @param text The text to add
|
|
169
|
+
*/
|
|
170
|
+
startText(x: number, y: number, text?: Text_2): void;
|
|
171
|
+
/**
|
|
172
|
+
* Cancel drawing on the current frame
|
|
173
|
+
*/
|
|
174
|
+
cancelDrawing(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Triggers the update event on the annotation
|
|
177
|
+
* @param annotation The annotation updated
|
|
178
|
+
*/
|
|
179
|
+
onUpdate: (annotation: Annotation) => void;
|
|
180
|
+
private _onUpdate;
|
|
181
|
+
/**
|
|
182
|
+
* Update the style of the annotation with the given id
|
|
183
|
+
* @param id The id of the annotation to update
|
|
184
|
+
* @param style The new style
|
|
185
|
+
*/
|
|
186
|
+
updateStyle<A extends Annotation>(id: Id, style: A["properties"]["style"]): this;
|
|
187
|
+
setScale(id: Id, scale: number, ox: number, oy: number): this;
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* @returns the annotations in the controller
|
|
191
|
+
*/
|
|
192
|
+
getAnnotations(): AnnotationCollection;
|
|
193
|
+
/**
|
|
194
|
+
* Retrieve the annotation with the given id
|
|
195
|
+
* @param id the id of the annotation to get
|
|
196
|
+
* @returns The annotation with the given id
|
|
197
|
+
*/
|
|
198
|
+
getAnnotation(id: Id): Arrow | Text_2 | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Destroy the controller and its elements
|
|
201
|
+
*/
|
|
202
|
+
destroy(): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export declare type ControllerOptions = {
|
|
206
|
+
/**
|
|
207
|
+
* The color of the magnet points
|
|
208
|
+
*/
|
|
209
|
+
magnetColor: string;
|
|
210
|
+
/**
|
|
211
|
+
* The radius in which arrows are attracted
|
|
212
|
+
*/
|
|
213
|
+
magnetRadius: number;
|
|
214
|
+
/**
|
|
215
|
+
* The margin in which the Texts are detected when looking for magnet points
|
|
216
|
+
*/
|
|
217
|
+
detectMargin: number;
|
|
218
|
+
/**
|
|
219
|
+
* Display size of the magnet point
|
|
220
|
+
*/
|
|
221
|
+
magnetHandleRadius: number;
|
|
222
|
+
/**
|
|
223
|
+
* Placeholder for the text input
|
|
224
|
+
*/
|
|
225
|
+
textPlaceholder: string;
|
|
226
|
+
/**
|
|
227
|
+
* Size of the text handle
|
|
228
|
+
*/
|
|
229
|
+
textHandleSize: number;
|
|
230
|
+
/**
|
|
231
|
+
* Size of the arrow handle
|
|
232
|
+
*/
|
|
233
|
+
arrowHandleSize: number;
|
|
234
|
+
/**
|
|
235
|
+
* Minimum height of the arrow in units
|
|
236
|
+
*/
|
|
237
|
+
minArrowHeight: number;
|
|
238
|
+
/**
|
|
239
|
+
* Maximum height of the arrow in units
|
|
240
|
+
*/
|
|
241
|
+
maxArrowHeight: number;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export declare const createArrow: (x0?: number, y0?: number, x1?: number, y1?: number, styles?: {
|
|
245
|
+
tail?: Extremity | undefined;
|
|
246
|
+
head?: Extremity | undefined;
|
|
247
|
+
strokeType?: "none" | "plain" | "dashed" | undefined;
|
|
248
|
+
strokeColor?: string | undefined;
|
|
249
|
+
strokeWidth?: number | undefined;
|
|
250
|
+
}) => Arrow;
|
|
251
|
+
|
|
252
|
+
export declare function createSVGElement<T extends SVGElement>(tag: string): T;
|
|
253
|
+
|
|
254
|
+
export declare const createText: (x?: number, y?: number, width?: number, height?: number, content?: string, styles?: Partial<TextStyle>) => Text_2;
|
|
255
|
+
|
|
256
|
+
export declare const defaultArrowOptions: Arrow;
|
|
257
|
+
|
|
258
|
+
export declare const defaultArrowStyle: ArrowStyles;
|
|
259
|
+
|
|
260
|
+
export declare const defaultControllerOptions: AnnotationOptions;
|
|
261
|
+
|
|
262
|
+
export declare const defaultTextOptions: Text_2;
|
|
263
|
+
|
|
264
|
+
export declare const defaultTextStyle: TextStyle;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @class Annotations
|
|
268
|
+
* Abstract class to display Texts and Arrows, provide add/remove/update and mouse events
|
|
269
|
+
* Modifying annotation is handled by the child classes, it is too specific
|
|
270
|
+
*/
|
|
271
|
+
declare abstract class Editor<T extends Annotation> extends default_2<Events<T>> {
|
|
272
|
+
protected ogma: default_3;
|
|
273
|
+
protected elements: T[];
|
|
274
|
+
protected layer: SVGLayer;
|
|
275
|
+
protected editor: Overlay;
|
|
276
|
+
protected selectedId: Id;
|
|
277
|
+
protected hoveredId: Id;
|
|
278
|
+
protected ogmaOptions: Options;
|
|
279
|
+
protected shouldDetect: boolean;
|
|
280
|
+
protected isDragging: boolean;
|
|
281
|
+
protected showeditorOnHover: boolean;
|
|
282
|
+
constructor(ogma: default_3, editorHtml: string);
|
|
283
|
+
private _onKeyUp;
|
|
284
|
+
protected _canRemove(): boolean;
|
|
285
|
+
private _onClickMouseMove;
|
|
286
|
+
/**
|
|
287
|
+
* @method add
|
|
288
|
+
* @param options Params for the annotation (merged with default)
|
|
289
|
+
* @returns the added annotation
|
|
290
|
+
*/
|
|
291
|
+
add(options: T): T;
|
|
292
|
+
updateStyle(annotation: T, style: Partial<T["properties"]["style"]>): void;
|
|
293
|
+
updateGeometry(annotation: T, geometry: Partial<T["geometry"]>): void;
|
|
294
|
+
scale(annotation: T, scale: number, ox: number, oy: number): void;
|
|
295
|
+
/**
|
|
296
|
+
* @method update
|
|
297
|
+
* Updates an annotation (position, color etc)
|
|
298
|
+
* @param id Id of the annotation to update
|
|
299
|
+
* @param element params of the annotation
|
|
300
|
+
*/
|
|
301
|
+
update(id: Id, element: Partial<T>): void;
|
|
302
|
+
updateAnnotation(target: T, element: Partial<T>): void;
|
|
303
|
+
getById(id: Id): T;
|
|
304
|
+
/**
|
|
305
|
+
* @method select
|
|
306
|
+
* @param id id of the element to select
|
|
307
|
+
* Select element, show editor, disable Ogma dragging and fire event
|
|
308
|
+
*/
|
|
309
|
+
select(id: Id): void;
|
|
310
|
+
hover(id: Id): void;
|
|
311
|
+
getSelectedFeature(): T | null;
|
|
312
|
+
unselect(): this;
|
|
313
|
+
unhover(): this;
|
|
314
|
+
/**
|
|
315
|
+
* @method remove
|
|
316
|
+
* @param id Id of the annotation to remove
|
|
317
|
+
* Removes annotation with the given id
|
|
318
|
+
*/
|
|
319
|
+
remove(id: Id): void;
|
|
320
|
+
/**
|
|
321
|
+
* @method disableDragging
|
|
322
|
+
* Prevents Ogma from dragging elements or moving the view while dragging an annotation
|
|
323
|
+
*/
|
|
324
|
+
disableDragging(): void;
|
|
325
|
+
/**
|
|
326
|
+
* @method restoreDragging
|
|
327
|
+
* restore ogma options as they were before we start dragging an annotation
|
|
328
|
+
*/
|
|
329
|
+
restoreDragging(): void;
|
|
330
|
+
enableDetection(): void;
|
|
331
|
+
/**
|
|
332
|
+
* @method disableDetection
|
|
333
|
+
* Disables the hover behaviour, used by controller to avoid hovering
|
|
334
|
+
* arrows while dragging texts and vice versa
|
|
335
|
+
*/
|
|
336
|
+
disableDetection(): void;
|
|
337
|
+
refreshLayer(): void;
|
|
338
|
+
refreshDrawing(): void;
|
|
339
|
+
getElements(): T[];
|
|
340
|
+
abstract refreshEditor(): void;
|
|
341
|
+
abstract draw(svg: SVGSVGElement): void;
|
|
342
|
+
abstract cancelDrawing(): void;
|
|
343
|
+
abstract getDefaultOptions(): T;
|
|
344
|
+
abstract detect(point: Point_2, margin: number): T | undefined;
|
|
345
|
+
destroy(): void;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export declare type Events<T> = {
|
|
349
|
+
[EVT_HOVER]: (evt: T) => void;
|
|
350
|
+
[EVT_UNHOVER]: (evt: T) => void;
|
|
351
|
+
[EVT_SELECT]: (evt: T) => void;
|
|
352
|
+
[EVT_UNSELECT]: (evt: T) => void;
|
|
353
|
+
[EVT_DRAG_START]: (evt: T) => void;
|
|
354
|
+
[EVT_DRAG]: (evt: T, key: "line" | "start" | "end" | "text") => void;
|
|
355
|
+
[EVT_DRAG_END]: (evt: T) => void;
|
|
356
|
+
[EVT_REMOVE]: (evt: T) => void;
|
|
357
|
+
[EVT_ADD]: (evt: T) => void;
|
|
358
|
+
[EVT_UPDATE]: (evt: T) => void;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export declare const EVT_ADD = "add";
|
|
362
|
+
|
|
363
|
+
export declare const EVT_CANCEL_DRAWING = "cancelDrawing";
|
|
364
|
+
|
|
365
|
+
export declare const EVT_DRAG = "dragging";
|
|
366
|
+
|
|
367
|
+
export declare const EVT_DRAG_END = "dragend";
|
|
368
|
+
|
|
369
|
+
export declare const EVT_DRAG_START = "dragstart";
|
|
370
|
+
|
|
371
|
+
export declare const EVT_HOVER = "hover";
|
|
372
|
+
|
|
373
|
+
export declare const EVT_LINK = "link";
|
|
374
|
+
|
|
375
|
+
export declare const EVT_REMOVE = "remove";
|
|
376
|
+
|
|
377
|
+
export declare const EVT_SELECT = "select";
|
|
378
|
+
|
|
379
|
+
export declare const EVT_UNHOVER = "unhover";
|
|
380
|
+
|
|
381
|
+
export declare const EVT_UNSELECT = "unselect";
|
|
382
|
+
|
|
383
|
+
export declare const EVT_UPDATE = "update";
|
|
384
|
+
|
|
385
|
+
declare type ExportedLink = {
|
|
386
|
+
id: Id;
|
|
387
|
+
side: "start" | "end";
|
|
388
|
+
type: "node" | "text";
|
|
389
|
+
magnet?: Point;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
export declare type Extremity = "none" | "arrow" | "arrow-plain";
|
|
393
|
+
|
|
394
|
+
export declare type FeatureEvents = {
|
|
395
|
+
/**
|
|
396
|
+
* Event trigerred when selecting an annotation
|
|
397
|
+
* @param evt The annotation selected
|
|
398
|
+
*/
|
|
399
|
+
[EVT_SELECT]: (evt: Annotation) => void;
|
|
400
|
+
/**
|
|
401
|
+
* Event trigerred when unselecting an annotation
|
|
402
|
+
* @param evt The annotation unselected
|
|
403
|
+
*/
|
|
404
|
+
[EVT_UNSELECT]: (evt: Annotation) => void;
|
|
405
|
+
/**
|
|
406
|
+
* Event trigerred when removing an annotation
|
|
407
|
+
* @param evt The annotation removed
|
|
408
|
+
*/
|
|
409
|
+
[EVT_REMOVE]: (evt: Annotation) => void;
|
|
410
|
+
/**
|
|
411
|
+
* Event trigerred when adding an annotation
|
|
412
|
+
* @param evt The annotation added
|
|
413
|
+
*/
|
|
414
|
+
[EVT_ADD]: (evt: Annotation) => void;
|
|
415
|
+
[EVT_CANCEL_DRAWING]: () => void;
|
|
416
|
+
/**
|
|
417
|
+
* Event trigerred when updating an annotation
|
|
418
|
+
* @returns The annotation updated
|
|
419
|
+
*/
|
|
420
|
+
[EVT_UPDATE]: (evt: Annotation) => void;
|
|
421
|
+
/**
|
|
422
|
+
* Event trigerred when linking an arrow to a text or node
|
|
423
|
+
*/
|
|
424
|
+
[EVT_LINK]: (evt: {
|
|
425
|
+
arrow: Arrow;
|
|
426
|
+
link: Link;
|
|
427
|
+
}) => void;
|
|
428
|
+
/**
|
|
429
|
+
* Event trigerred when starting to drag an arrow or a text
|
|
430
|
+
*/
|
|
431
|
+
[EVT_DRAG_START]: (evt: Arrow | Text_2) => void;
|
|
432
|
+
/**
|
|
433
|
+
* Event trigerred when dragging an arrow or a text
|
|
434
|
+
*/
|
|
435
|
+
[EVT_DRAG]: (evt: Arrow | Text_2, key: "line" | "start" | "end" | "text") => void;
|
|
436
|
+
/**
|
|
437
|
+
* Event trigerred when stopped dragging an arrow or a text
|
|
438
|
+
*/
|
|
439
|
+
[EVT_DRAG_END]: (evt: Arrow | Text_2) => void;
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
export declare function getAnnotationsBounds(annotations: AnnotationCollection): Bounds;
|
|
443
|
+
|
|
444
|
+
export declare function getArrowEnd(a: Arrow): {
|
|
445
|
+
x: number;
|
|
446
|
+
y: number;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
export declare function getArrowEndPoints(a: Arrow): {
|
|
450
|
+
start: {
|
|
451
|
+
x: number;
|
|
452
|
+
y: number;
|
|
453
|
+
};
|
|
454
|
+
end: {
|
|
455
|
+
x: number;
|
|
456
|
+
y: number;
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export declare function getArrowSide(a: Arrow, side: "start" | "end"): {
|
|
461
|
+
x: number;
|
|
462
|
+
y: number;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export declare function getArrowStart(a: Arrow): {
|
|
466
|
+
x: number;
|
|
467
|
+
y: number;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
export declare function getAttachmentPointOnNode(start: Point_2, nodeCenter: Point_2, nodeRadius: number): {
|
|
471
|
+
x: number;
|
|
472
|
+
y: number;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
export declare const getHandleId: (handle: HTMLDivElement) => number;
|
|
476
|
+
|
|
477
|
+
export declare function getTextBbox(t: Text_2): BBox;
|
|
478
|
+
|
|
479
|
+
export declare function getTextPosition(t: Text_2): {
|
|
480
|
+
x: number;
|
|
481
|
+
y: number;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
export declare function getTextSize(t: Text_2): {
|
|
485
|
+
width: number;
|
|
486
|
+
height: number;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
export declare type Id = string | number;
|
|
490
|
+
|
|
491
|
+
export declare const isAnnotationCollection: (a: AnnotationFeature<Geometry, AnnotationProps> | FeatureCollection) => a is AnnotationCollection;
|
|
492
|
+
|
|
493
|
+
export declare const isArrow: (a: AnnotationFeature<Geometry, AnnotationProps>) => a is Arrow;
|
|
494
|
+
|
|
495
|
+
export declare const isText: (a: AnnotationFeature<Geometry, AnnotationProps>) => a is Text_2;
|
|
496
|
+
|
|
497
|
+
export declare type Link = {
|
|
498
|
+
/** arrow attached to the text or node */
|
|
499
|
+
arrow: Id;
|
|
500
|
+
/** id of the text the arrow is attached to */
|
|
501
|
+
id: Id;
|
|
502
|
+
/** On which end the arrow is tighten to the text */
|
|
503
|
+
side: Side;
|
|
504
|
+
/** id of the text or node the arrow is attached to */
|
|
505
|
+
target: Id;
|
|
506
|
+
/** Text or node */
|
|
507
|
+
targetType: TargetType;
|
|
508
|
+
/**
|
|
509
|
+
* On which point relative to topleft corner the arrow is tighten, in case of
|
|
510
|
+
* node, it can be deduced from the arrow itself
|
|
511
|
+
*/
|
|
512
|
+
connectionPoint: Point;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
export declare const NONE = -1;
|
|
516
|
+
|
|
517
|
+
export declare type Point = {
|
|
518
|
+
x: number;
|
|
519
|
+
y: number;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
export declare function scaleGeometry(geometry: LineString | Polygon, scale: number, ox: number, oy: number): LineString | Polygon;
|
|
523
|
+
|
|
524
|
+
export declare function setArrowEnd(a: Arrow, x: number, y: number): void;
|
|
525
|
+
|
|
526
|
+
export declare function setArrowEndPoint(a: Arrow, side: "start" | "end", x: number, y: number): void;
|
|
527
|
+
|
|
528
|
+
export declare function setArrowStart(a: Arrow, x: number, y: number): void;
|
|
529
|
+
|
|
530
|
+
export declare function setTextBbox(t: Text_2, x: number, y: number, width: number, height: number): void;
|
|
531
|
+
|
|
532
|
+
export declare type Side = "start" | "end";
|
|
533
|
+
|
|
534
|
+
export declare type Stroke = {
|
|
535
|
+
type: "plain" | "dashed" | "none";
|
|
536
|
+
color: string;
|
|
537
|
+
width: number;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
export declare type StrokeOptions = {
|
|
541
|
+
strokeType?: "plain" | "dashed" | "none";
|
|
542
|
+
strokeColor?: string;
|
|
543
|
+
strokeWidth?: number;
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
export declare type StrokeStyle = Stroke;
|
|
547
|
+
|
|
548
|
+
export declare type TargetType = "text" | "node";
|
|
549
|
+
|
|
550
|
+
declare type Text_2 = AnnotationFeature<Polygon, TextProperties>;
|
|
551
|
+
export { Text_2 as Text }
|
|
552
|
+
|
|
553
|
+
export declare interface TextProperties extends AnnotationProps {
|
|
554
|
+
type: "text";
|
|
555
|
+
/**text to display*/
|
|
556
|
+
content: string;
|
|
557
|
+
style?: TextStyle;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @class Texts
|
|
562
|
+
* Draw, update, edit texts
|
|
563
|
+
*/
|
|
564
|
+
export declare class Texts extends Editor<Text_2> {
|
|
565
|
+
private textArea;
|
|
566
|
+
private handleSize;
|
|
567
|
+
private rect;
|
|
568
|
+
private annotation;
|
|
569
|
+
private startX;
|
|
570
|
+
private startY;
|
|
571
|
+
private handles;
|
|
572
|
+
private draggedHandle;
|
|
573
|
+
private isFocused;
|
|
574
|
+
private placeholder;
|
|
575
|
+
constructor(ogma: default_3, options?: Pick<Partial<ControllerOptions>, "textHandleSize" | "textPlaceholder">);
|
|
576
|
+
private _onFocus;
|
|
577
|
+
private _onBlur;
|
|
578
|
+
protected _canRemove(): boolean;
|
|
579
|
+
startDrawing: (x: number, y: number, text?: Text_2) => void;
|
|
580
|
+
cancelDrawing: () => void;
|
|
581
|
+
private startDragging;
|
|
582
|
+
private onHandleMouseDown;
|
|
583
|
+
private onMouseMove;
|
|
584
|
+
private _onMouseMove;
|
|
585
|
+
private onMouseUp;
|
|
586
|
+
private _onMousedown;
|
|
587
|
+
private onViewChanged;
|
|
588
|
+
private _onInput;
|
|
589
|
+
detect({ x, y }: Point_2, margin?: number): Text_2 | undefined;
|
|
590
|
+
draw(svg: SVGSVGElement): void;
|
|
591
|
+
refreshDrawing(): void;
|
|
592
|
+
getDefaultOptions(): Text_2;
|
|
593
|
+
refreshEditor(): void;
|
|
594
|
+
select(id: Id): void;
|
|
595
|
+
destroy(): void;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export declare interface TextStyle extends StrokeOptions {
|
|
599
|
+
/** Helvetica, sans-serif... */
|
|
600
|
+
font?: string;
|
|
601
|
+
/** Font size, in pixels */
|
|
602
|
+
fontSize?: number | string;
|
|
603
|
+
/** text color: #f00, yellow...*/
|
|
604
|
+
color?: string;
|
|
605
|
+
/** background color: empty for transparent #f00, yellow...*/
|
|
606
|
+
background?: string;
|
|
607
|
+
/** padding around the text */
|
|
608
|
+
padding?: number;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export declare function updateTextBbox(t: Text_2): void;
|
|
612
|
+
|
|
613
|
+
export declare type Vector = Point;
|
|
614
|
+
|
|
615
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkurious/ogma-annotations",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Headless annotation plugin for Ogma",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.mjs",
|
|
6
7
|
"module": "dist/index.mjs",
|
|
7
8
|
"browser": "dist/index.js",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"bump:patch": "bump2version patch && npm version --no-git-tag-version patch",
|
|
36
37
|
"bump:minor": "bump2version minor && npm version --no-git-tag-version minor",
|
|
37
38
|
"bump:major": "bump2version major && npm version --no-git-tag-version major",
|
|
38
|
-
"build": "vite build
|
|
39
|
+
"build": "vite build",
|
|
39
40
|
"lint:ci": "eslint -f checkstyle -o reports/checkstyle.xml --ext ts --ext js src",
|
|
40
41
|
"lint": "eslint --ext ts --ext js src",
|
|
41
42
|
"types": "tsc --d -emitDeclarationOnly --outDir dist/types",
|
|
@@ -70,11 +71,12 @@
|
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"@borgar/textbox": "1.6.0",
|
|
73
|
-
"
|
|
74
|
+
"@types/geojson": "7946.0.13",
|
|
75
|
+
"eventemitter3": "5.0.1",
|
|
76
|
+
"geojson": "^0.5.0"
|
|
74
77
|
},
|
|
75
78
|
"devDependencies": {
|
|
76
79
|
"@linkurious/eslint-config-ogma": "^1.0.9",
|
|
77
|
-
"@types/geojson": "7946.0.13",
|
|
78
80
|
"canvas": "2.11.2",
|
|
79
81
|
"eslint": "8.56.0",
|
|
80
82
|
"get-port": "7.0.0",
|
|
@@ -84,6 +86,7 @@
|
|
|
84
86
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
85
87
|
"typescript": "5.3.3",
|
|
86
88
|
"vite": "5.2.0",
|
|
89
|
+
"vite-plugin-dts": "^4.1.0",
|
|
87
90
|
"vitest": "1.4.0"
|
|
88
91
|
},
|
|
89
92
|
"eslintConfig": {
|