@markerjs/markerjs3 3.0.0-alpha.1 → 3.0.0-alpha.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/markerjs3.d.ts CHANGED
@@ -149,6 +149,13 @@ interface MarkerBaseState {
149
149
  opacity?: number;
150
150
  }
151
151
 
152
+ interface AnnotationState {
153
+ version?: number;
154
+ width: number;
155
+ height: number;
156
+ markers: MarkerBaseState[];
157
+ }
158
+
152
159
  /**
153
160
  * Describes a size
154
161
  */
@@ -231,241 +238,828 @@ declare class MarkerBase {
231
238
  scale(scaleX: number, scaleY: number): void;
232
239
  }
233
240
 
234
- interface AnnotationState {
235
- version?: number;
236
- width: number;
237
- height: number;
238
- markers: MarkerBaseState[];
241
+ /**
242
+ * Represents a simplified version of the SVGMatrix.
243
+ */
244
+ interface ITransformMatrix {
245
+ a: number;
246
+ b: number;
247
+ c: number;
248
+ d: number;
249
+ e: number;
250
+ f: number;
239
251
  }
240
252
 
241
- interface MarkerEditorProperties<TMarkerType extends MarkerBase = MarkerBase> {
253
+ /**
254
+ * Represents a state snapshot of a RectangularBoxMarkerBase.
255
+ */
256
+ interface RectangularBoxMarkerBaseState extends MarkerBaseState {
242
257
  /**
243
- * SVG container for the marker and editor elements.
258
+ * x coordinate of the top-left corner.
244
259
  */
245
- container: SVGGElement;
260
+ left: number;
246
261
  /**
247
- * HTML overlay container for editor's HTML elements (such as label text editor).
262
+ * y coordinate of the top-left corner.
248
263
  */
249
- overlayContainer: HTMLDivElement;
264
+ top: number;
250
265
  /**
251
- * Type of marker to create.
266
+ * Marker's width.
252
267
  */
253
- markerType: new (container: SVGGElement) => TMarkerType;
268
+ width: number;
254
269
  /**
255
- * Previously created marker to edit.
270
+ * Marker's height.
256
271
  */
257
- marker?: TMarkerType;
272
+ height: number;
273
+ /**
274
+ * Marker's rotation angle.
275
+ */
276
+ rotationAngle: number;
277
+ visualTransformMatrix?: ITransformMatrix;
278
+ containerTransformMatrix?: ITransformMatrix;
258
279
  }
259
280
 
260
281
  /**
261
- * Represents marker's state (status) in time.
282
+ * RectangularBoxMarkerBase is a base class for all marker's that conceptually fit into a rectangle
283
+ * such as all rectangle markers, ellipse, text and callout markers.
262
284
  */
263
- type MarkerEditorState = 'new' | 'creating' | 'select' | 'move' | 'resize' | 'rotate' | 'edit';
264
- type MarkerCreationStyle = 'draw' | 'drop';
265
- declare class MarkerBaseEditor<TMarkerType extends MarkerBase = MarkerBase> {
266
- protected _markerType: new (container: SVGGElement) => TMarkerType;
267
- protected _creationStyle: MarkerCreationStyle;
268
- get creationStyle(): MarkerCreationStyle;
285
+ declare class RectangularBoxMarkerBase extends MarkerBase {
269
286
  /**
270
- * Type guard for specific marker editor types.
271
- * @param cls
272
- * @returns
287
+ * x coordinate of the top-left corner.
273
288
  */
274
- is<T>(cls: new (...args: any[]) => T): this is T;
275
- protected _marker: TMarkerType;
276
- get marker(): TMarkerType;
277
- protected _container: SVGGElement;
289
+ left: number;
278
290
  /**
279
- * Returns the SVG container for the marker's and editor's visual elements.
291
+ * y coordinate of the top-left corner.
280
292
  */
281
- get container(): SVGGElement;
293
+ top: number;
282
294
  /**
283
- * Overlay container for HTML elements like text editors, etc.
295
+ * Marker width.
284
296
  */
285
- protected _overlayContainer: HTMLDivElement;
297
+ width: number;
286
298
  /**
287
- * Overlay container for HTML elements like text editors, etc.
299
+ * Marker height.
288
300
  */
289
- get overlayContainer(): HTMLDivElement;
301
+ height: number;
290
302
  /**
291
- * Editor's state.
303
+ * Marker's rotation angle.
292
304
  */
293
- protected _state: MarkerEditorState;
305
+ rotationAngle: number;
294
306
  /**
295
- * Gets editor's state.
307
+ * x coordinate of the marker's center.
296
308
  */
297
- get state(): MarkerEditorState;
309
+ get centerX(): number;
298
310
  /**
299
- * Sets editor's state.
311
+ * y coordinate of the marker's center.
300
312
  */
301
- set state(value: MarkerEditorState);
313
+ get centerY(): number;
314
+ private _visual?;
302
315
  /**
303
- * SVG group holding editor's control box.
316
+ * Container for the marker's visual.
304
317
  */
305
- protected _controlBox: SVGGElement;
318
+ protected get visual(): SVGGraphicsElement | undefined;
319
+ protected set visual(value: SVGGraphicsElement);
320
+ constructor(container: SVGGElement);
306
321
  /**
307
- * Method called when marker creation is finished.
322
+ * Moves visual to the specified coordinates.
323
+ * @param point - coordinates of the new top-left corner of the visual.
308
324
  */
309
- onMarkerCreated?: <T extends MarkerBaseEditor<MarkerBase>>(editor: T) => void;
325
+ moveVisual(point: IPoint): void;
326
+ setSize(): void;
327
+ rotate(point: IPoint): void;
328
+ private applyRotation;
310
329
  /**
311
- * Method to call when marker state changes.
330
+ * Returns point coordinates based on the actual screen coordinates and marker's rotation.
331
+ * @param point - original pointer coordinates
312
332
  */
313
- onStateChanged?: <T extends MarkerBaseEditor<MarkerBase>>(editor: T) => void;
333
+ rotatePoint(point: IPoint): IPoint;
314
334
  /**
315
- * Marker's state when it is selected
335
+ * Returns original point coordinates based on coordinates with rotation applied.
336
+ * @param point - rotated point coordinates.
316
337
  */
317
- protected manipulationStartState?: string;
338
+ unrotatePoint(point: IPoint): IPoint;
318
339
  /**
319
- * Is this marker selected?
340
+ * Returns marker's outline path for use while creating, etc.
341
+ * @returns SVG path `d` attribute.
320
342
  */
321
- protected _isSelected: boolean;
343
+ getOutline(): string;
322
344
  /**
323
- * Returns true if the marker is currently selected
345
+ * Returns marker's state.
324
346
  */
325
- get isSelected(): boolean;
326
- protected _continuousCreation: boolean;
327
- get continuousCreation(): boolean;
347
+ getState(): RectangularBoxMarkerBaseState;
328
348
  /**
329
- * Sets rectangle's border stroke color.
330
- * @param color - color as string
349
+ * Restores marker's state to the previously saved one.
350
+ * @param state - previously saved state.
331
351
  */
332
- set strokeColor(color: string);
333
- get strokeColor(): string;
352
+ restoreState(state: MarkerBaseState): void;
334
353
  /**
335
- * Sets rectangle's border stroke (line) width.
336
- * @param color - color as string
354
+ * Scales marker. Used after the image resize.
355
+ *
356
+ * @param scaleX - horizontal scale
357
+ * @param scaleY - vertical scale
337
358
  */
338
- set strokeWidth(width: number);
339
- get strokeWidth(): number;
359
+ scale(scaleX: number, scaleY: number): void;
360
+ }
361
+
362
+ declare class ShapeOutlineMarkerBase extends RectangularBoxMarkerBase {
363
+ static title: string;
364
+ protected applyStrokeColor(): void;
365
+ protected applyStrokeWidth(): void;
366
+ protected applyStrokeDasharray(): void;
367
+ protected applyOpacity(): void;
368
+ constructor(container: SVGGElement);
369
+ ownsTarget(el: EventTarget): boolean;
370
+ protected getPath(width?: number, height?: number): string;
371
+ getOutline(): string;
372
+ createVisual(): void;
373
+ adjustVisual(): void;
374
+ setSize(): void;
340
375
  /**
341
- * Sets rectangle's border stroke dash array.
342
- * @param color - color as string
376
+ * Restores previously saved marker state.
377
+ *
378
+ * @param state - previously saved state.
343
379
  */
344
- set strokeDasharray(dashes: string);
345
- get strokeDasharray(): string;
346
- set fillColor(color: string);
347
- get fillColor(): string;
348
- set opacity(value: number);
349
- get opacity(): number;
350
- constructor(properties: MarkerEditorProperties<TMarkerType>);
351
- ownsTarget(el: EventTarget | null): boolean;
380
+ restoreState(state: MarkerBaseState): void;
352
381
  /**
353
- * Selects this marker and displays appropriate selected marker UI.
382
+ * Scales marker. Used after the image resize.
383
+ *
384
+ * @param scaleX - horizontal scale
385
+ * @param scaleY - vertical scale
354
386
  */
355
- select(): void;
387
+ scale(scaleX: number, scaleY: number): void;
388
+ }
389
+
390
+ /**
391
+ * Represents outline shape's state.
392
+ */
393
+ interface ShapeOutlineMarkerBaseState extends RectangularBoxMarkerBaseState {
394
+ }
395
+
396
+ declare class FrameMarker extends ShapeOutlineMarkerBase {
356
397
  /**
357
- * Deselects this marker and hides selected marker UI.
398
+ * String type name of the marker type.
358
399
  */
359
- deselect(): void;
400
+ static typeName: string;
360
401
  /**
361
- * Handles pointer (mouse, touch, stylus, etc.) down event.
362
- *
363
- * @param point - event coordinates.
364
- * @param target - direct event target element.
402
+ * Marker type title (display name) used for accessibility and other attributes.
365
403
  */
366
- pointerDown(point: IPoint, target?: EventTarget): void;
404
+ static title: string;
405
+ constructor(container: SVGGElement);
406
+ protected getPath(width?: number, height?: number): string;
407
+ getState(): ShapeOutlineMarkerBaseState;
408
+ }
409
+
410
+ /**
411
+ * Represents base state for line-style markers.
412
+ */
413
+ interface LinearMarkerBaseState extends MarkerBaseState {
367
414
  /**
368
- * Handles pointer (mouse, touch, stylus, etc.) double click event.
369
- *
370
- * @param point - event coordinates.
371
- * @param target - direct event target element.
415
+ * x coordinate for the first end-point.
372
416
  */
373
- dblClick(point: IPoint, target?: EventTarget): void;
417
+ x1: number;
374
418
  /**
375
- * Handles marker manipulation (move, resize, rotate, etc.).
376
- *
377
- * @param point - event coordinates.
419
+ * y coordinate for the first end-point.
378
420
  */
379
- manipulate(point: IPoint): void;
421
+ y1: number;
380
422
  /**
381
- * Handles pointer (mouse, touch, stylus, etc.) up event.
382
- *
383
- * @param point - event coordinates.
423
+ * x coordinate for the second end-point.
384
424
  */
385
- pointerUp(point: IPoint): void;
425
+ x2: number;
386
426
  /**
387
- * Disposes the marker and clean's up.
427
+ * y coordinate for the second end-point.
388
428
  */
389
- dispose(): void;
390
- protected adjustControlBox(): void;
391
- scale(scaleX: number, scaleY: number): void;
429
+ y2: number;
430
+ }
431
+
432
+ declare class LinearMarkerBase extends MarkerBase {
392
433
  /**
393
- * Called by a marker when its state could have changed.
394
- * Does a check if the state has indeed changed before firing the handler.
434
+ * x coordinate of the first end-point
395
435
  */
396
- protected stateChanged(): void;
397
- getState(): MarkerBaseState;
436
+ x1: number;
398
437
  /**
399
- * Restores previously saved marker state.
438
+ * y coordinate of the first end-point
439
+ */
440
+ y1: number;
441
+ /**
442
+ * x coordinate of the second end-point
443
+ */
444
+ x2: number;
445
+ /**
446
+ * y coordinate of the second end-point
447
+ */
448
+ y2: number;
449
+ /**
450
+ * Marker's main visual.
451
+ */
452
+ protected visual: SVGGraphicsElement | undefined;
453
+ protected selectorVisual: SVGGraphicsElement | undefined;
454
+ protected visibleVisual: SVGGraphicsElement | undefined;
455
+ protected applyStrokeColor(): void;
456
+ protected applyStrokeWidth(): void;
457
+ protected applyStrokeDasharray(): void;
458
+ protected applyOpacity(): void;
459
+ constructor(container: SVGGElement);
460
+ /**
461
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
400
462
  *
463
+ * @param el - target element.
464
+ */
465
+ ownsTarget(el: EventTarget): boolean;
466
+ protected getPath(): string;
467
+ createVisual(): void;
468
+ /**
469
+ * When implemented adjusts marker visual after manipulation when needed.
470
+ */
471
+ adjustVisual(): void;
472
+ /**
473
+ * Returns marker's state.
474
+ */
475
+ getState(): LinearMarkerBaseState;
476
+ /**
477
+ * Restores marker's state to the previously saved one.
401
478
  * @param state - previously saved state.
402
479
  */
403
480
  restoreState(state: MarkerBaseState): void;
404
- }
405
-
406
- interface MarkerAreaEventMap {
407
481
  /**
408
- * Marker area initialized.
482
+ * Scales marker. Used after the image resize.
483
+ *
484
+ * @param scaleX - horizontal scale
485
+ * @param scaleY - vertical scale
409
486
  */
410
- areainit: CustomEvent<MarkerAreaEventData>;
411
- areashow: CustomEvent<MarkerAreaEventData>;
412
- arearestorestate: CustomEvent<MarkerAreaEventData>;
413
- areafocus: CustomEvent<MarkerAreaEventData>;
414
- areablur: CustomEvent<MarkerAreaEventData>;
415
- areastatechange: CustomEvent<MarkerAreaEventData>;
416
- markerselect: CustomEvent<MarkerEditorEventData>;
417
- markerdeselect: CustomEvent<MarkerEditorEventData>;
418
- markercreating: CustomEvent<MarkerEditorEventData>;
419
- markercreate: CustomEvent<MarkerEditorEventData>;
420
- markerbeforedelete: CustomEvent<MarkerEditorEventData>;
421
- markerdelete: CustomEvent<MarkerEditorEventData>;
422
- markerchange: CustomEvent<MarkerEditorEventData>;
487
+ scale(scaleX: number, scaleY: number): void;
423
488
  }
424
- interface MarkerAreaEventData {
489
+
490
+ interface PolygonMarkerState extends MarkerBaseState {
425
491
  /**
426
- * {@link MarkerArea} instance.
492
+ * Polygon points.
427
493
  */
428
- markerArea: MarkerArea;
494
+ points: Array<IPoint>;
429
495
  }
430
- interface MarkerEditorEventData extends MarkerAreaEventData {
431
- markerEditor: MarkerBaseEditor;
432
- }
433
- declare class MarkerArea extends HTMLElement {
434
- private _contentContainer?;
435
- private _canvasContainer?;
436
- private _overlayContainer;
437
- private _overlayContentContainer;
438
- private _mainCanvas?;
439
- private _groupLayer?;
440
- private _editingTarget?;
441
- private width;
442
- private height;
443
- private _targetWidth;
444
- get targetWidth(): number;
445
- set targetWidth(value: number);
446
- private _targetHeight;
447
- get targetHeight(): number;
448
- set targetHeight(value: number);
449
- private mode;
450
- private _logoUI?;
451
- private _isInitialized;
452
- private _currentMarkerEditor?;
453
- get currentMarkerEditor(): MarkerBaseEditor | undefined;
454
- private _newMarkerOutline;
455
- private _targetImage;
456
- get targetImage(): HTMLImageElement | undefined;
457
- set targetImage(value: HTMLImageElement | undefined);
458
- markerEditors: Map<typeof MarkerBase, typeof MarkerBaseEditor<MarkerBase>>;
459
- editors: MarkerBaseEditor[];
460
- private _zoomLevel;
496
+
497
+ declare class PolygonMarker extends MarkerBase {
498
+ static typeName: string;
499
+ static title: string;
500
+ points: IPoint[];
461
501
  /**
462
- * Returns the current zoom level.
502
+ * Marker's main visual.
463
503
  */
464
- get zoomLevel(): number;
504
+ visual: SVGGraphicsElement | undefined;
505
+ selectorVisual: SVGGElement | undefined;
506
+ selectorVisualLines: SVGLineElement[];
507
+ visibleVisual: SVGGraphicsElement | undefined;
508
+ protected applyStrokeColor(): void;
509
+ protected applyStrokeWidth(): void;
510
+ protected applyStrokeDasharray(): void;
511
+ protected applyOpacity(): void;
512
+ constructor(container: SVGGElement);
465
513
  /**
466
- * Sets the current zoom level.
467
- */
468
- set zoomLevel(value: number);
514
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
515
+ *
516
+ * @param el - target element.
517
+ */
518
+ ownsTarget(el: EventTarget): boolean;
519
+ protected getPath(): string;
520
+ createVisual(): void;
521
+ private createSelectorVisual;
522
+ /**
523
+ * When implemented adjusts marker visual after manipulation when needed.
524
+ */
525
+ adjustVisual(): void;
526
+ private adjustSelectorVisual;
527
+ private addSelectorLine;
528
+ /**
529
+ * Returns marker's state.
530
+ */
531
+ getState(): PolygonMarkerState;
532
+ /**
533
+ * Restores marker's state to the previously saved one.
534
+ * @param state - previously saved state.
535
+ */
536
+ restoreState(state: MarkerBaseState): void;
537
+ /**
538
+ * Scales marker. Used after the image resize.
539
+ *
540
+ * @param scaleX - horizontal scale
541
+ * @param scaleY - vertical scale
542
+ */
543
+ scale(scaleX: number, scaleY: number): void;
544
+ }
545
+
546
+ interface FreehandMarkerState extends MarkerBaseState {
547
+ points: Array<IPoint>;
548
+ }
549
+
550
+ declare class FreehandMarker extends MarkerBase {
551
+ static typeName: string;
552
+ static title: string;
553
+ points: IPoint[];
554
+ /**
555
+ * Marker's main visual.
556
+ */
557
+ visual: SVGGraphicsElement | undefined;
558
+ protected selectorVisual: SVGGraphicsElement | undefined;
559
+ visibleVisual: SVGGraphicsElement | undefined;
560
+ protected applyStrokeColor(): void;
561
+ protected applyStrokeWidth(): void;
562
+ protected applyStrokeDasharray(): void;
563
+ protected applyOpacity(): void;
564
+ constructor(container: SVGGElement);
565
+ /**
566
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
567
+ *
568
+ * @param el - target element.
569
+ */
570
+ ownsTarget(el: EventTarget): boolean;
571
+ protected getPath(): string;
572
+ createVisual(): void;
573
+ /**
574
+ * When implemented adjusts marker visual after manipulation when needed.
575
+ */
576
+ adjustVisual(): void;
577
+ /**
578
+ * Returns marker's state.
579
+ */
580
+ getState(): FreehandMarkerState;
581
+ /**
582
+ * Restores marker's state to the previously saved one.
583
+ * @param state - previously saved state.
584
+ */
585
+ restoreState(state: MarkerBaseState): void;
586
+ /**
587
+ * Scales marker. Used after the image resize.
588
+ *
589
+ * @param scaleX - horizontal scale
590
+ * @param scaleY - vertical scale
591
+ */
592
+ scale(scaleX: number, scaleY: number): void;
593
+ }
594
+
595
+ /**
596
+ * Font size settings.
597
+ */
598
+ interface FontSize {
599
+ /**
600
+ * Number of {@link units}.
601
+ */
602
+ value: number;
603
+ /**
604
+ * Units the {@link value} represents.
605
+ */
606
+ units: string;
607
+ /**
608
+ * Value increment/decrement step for controls cycling through the size values.
609
+ */
610
+ step: number;
611
+ }
612
+
613
+ /**
614
+ * TextBlock represents a block of text used across all text-based stencils and connector labels.
615
+ */
616
+ declare class TextBlock {
617
+ /**
618
+ * Fired when text size changes.
619
+ *
620
+ * @group Events
621
+ */
622
+ onTextSizeChanged?: (textBlock: TextBlock) => void;
623
+ private _text;
624
+ /**
625
+ * Returns the text block's text
626
+ */
627
+ get text(): string;
628
+ /**
629
+ * Sets the text block's text.
630
+ */
631
+ set text(value: string);
632
+ /**
633
+ * Text block's horizontal offset from the automatically calculated position.
634
+ */
635
+ offsetX: number;
636
+ /**
637
+ * Text block's vertical offset from the automatically calculated position.
638
+ */
639
+ offsetY: number;
640
+ private _boundingBox;
641
+ /**
642
+ * Returns the bounding box where text should fit and/or be anchored.
643
+ */
644
+ get boundingBox(): DOMRect;
645
+ /**
646
+ * Sets the bounding box where text should fit and/or be anchored.
647
+ */
648
+ set boundingBox(value: DOMRect);
649
+ private _labelBackground;
650
+ /**
651
+ * Returns the background rectangle (behind the text).
652
+ */
653
+ get labelBackground(): SVGRectElement;
654
+ private _textElement;
655
+ /**
656
+ * Returns the text block's text element.
657
+ */
658
+ get textElement(): SVGTextElement;
659
+ private _color;
660
+ /**
661
+ * Sets the text color.
662
+ */
663
+ set color(value: string);
664
+ /**
665
+ * Returns the text color.
666
+ */
667
+ get color(): string;
668
+ private _fontFamily;
669
+ /**
670
+ * Returns the text's font family.
671
+ */
672
+ get fontFamily(): string;
673
+ /**
674
+ * Sets the text's font family.
675
+ */
676
+ set fontFamily(value: string);
677
+ private _fontSize;
678
+ /**
679
+ * Returns the text's font size.
680
+ */
681
+ get fontSize(): FontSize;
682
+ /**
683
+ * Sets the text's font size.
684
+ */
685
+ set fontSize(value: FontSize);
686
+ /**
687
+ * Creates a text block
688
+ * @param text initial text
689
+ */
690
+ constructor(text?: string);
691
+ /**
692
+ * Returns true if the text block contains the supplied element.
693
+ * @param el element to test.
694
+ * @returns true if the element belongs to the text block, false otherwise.
695
+ */
696
+ ownsTarget(el: EventTarget): boolean;
697
+ private setupTextElement;
698
+ private wrapText;
699
+ wordWrap: boolean;
700
+ private prevWrappedText;
701
+ /**
702
+ * Renders text within the text block according to its settings.
703
+ */
704
+ renderText(): void;
705
+ private applyFontStyles;
706
+ private _textSize?;
707
+ /**
708
+ * Returns the size of the rectangle containing the text block's text.
709
+ */
710
+ get textSize(): DOMRect | undefined;
711
+ /**
712
+ * Positions the text within the text block.
713
+ * @param textBlock
714
+ */
715
+ positionText(textBlock?: TextBlock): void;
716
+ /**
717
+ * Makes the text block content visible.
718
+ */
719
+ show(): void;
720
+ /**
721
+ * Hides the text block content.
722
+ */
723
+ hide(): void;
724
+ /**
725
+ * Shows the text block's dashed outline.
726
+ */
727
+ showControlBox(): void;
728
+ /**
729
+ * Hides the text block's dashed outline.
730
+ */
731
+ hideControlBox(): void;
732
+ }
733
+
734
+ interface TextMarkerState extends RectangularBoxMarkerBaseState {
735
+ color: string;
736
+ fontFamily: string;
737
+ fontSize: FontSize;
738
+ text: string;
739
+ }
740
+
741
+ declare class TextMarker extends RectangularBoxMarkerBase {
742
+ static typeName: string;
743
+ static title: string;
744
+ protected static DEFAULT_TEXT: string;
745
+ onSizeChanged?: (textMarker: TextMarker) => void;
746
+ private _color;
747
+ /**
748
+ * Returns stencil's text color.
749
+ */
750
+ get color(): string;
751
+ /**
752
+ * Sets the stencil's text color.
753
+ */
754
+ set color(value: string);
755
+ private _fontFamily;
756
+ /**
757
+ * Returns the stencil's font family.
758
+ */
759
+ get fontFamily(): string;
760
+ /**
761
+ * Sets the stencil's font family.
762
+ */
763
+ set fontFamily(value: string);
764
+ private _fontSize;
765
+ /**
766
+ * Returns the stencil's font size.
767
+ */
768
+ get fontSize(): FontSize;
769
+ /**
770
+ * Sets the stencil's font size.
771
+ */
772
+ set fontSize(value: FontSize);
773
+ /**
774
+ * Returns the default text for the stencil type.
775
+ * @returns stencil type's default text.
776
+ */
777
+ protected getDefaultText(): string;
778
+ private _text;
779
+ /**
780
+ * Returns the stencil's text.
781
+ */
782
+ get text(): string;
783
+ /**
784
+ * Sets the stencil's text.
785
+ */
786
+ set text(value: string);
787
+ /**
788
+ * Text padding from the bounding box.
789
+ */
790
+ protected padding: number;
791
+ /**
792
+ * Text's bounding box where text should fit and/or be anchored to.
793
+ */
794
+ textBoundingBox: DOMRect;
795
+ /**
796
+ * Text block handling the text rendering.
797
+ */
798
+ textBlock: TextBlock;
799
+ constructor(container: SVGGElement);
800
+ createVisual(): void;
801
+ ownsTarget(el: EventTarget): boolean;
802
+ protected setTextBoundingBox(): void;
803
+ /**
804
+ * Sets (adjusts) the stencil's size.
805
+ */
806
+ setSize(): void;
807
+ private textSizeChanged;
808
+ /**
809
+ * Sets the text color.
810
+ * @param color text color
811
+ */
812
+ setColor(color: string): void;
813
+ /**
814
+ * Sets the font family.
815
+ * @param font font family string
816
+ */
817
+ setFont(font: string): void;
818
+ /**
819
+ * Sets the font size.
820
+ * @param fontSize font size
821
+ */
822
+ setFontSize(fontSize: FontSize): void;
823
+ hideVisual(): void;
824
+ showVisual(): void;
825
+ getState(): TextMarkerState;
826
+ /**
827
+ * Restores previously saved marker state.
828
+ *
829
+ * @param state - previously saved state.
830
+ */
831
+ restoreState(state: MarkerBaseState): void;
832
+ scale(scaleX: number, scaleY: number): void;
833
+ }
834
+
835
+ interface MarkerEditorProperties<TMarkerType extends MarkerBase = MarkerBase> {
836
+ /**
837
+ * SVG container for the marker and editor elements.
838
+ */
839
+ container: SVGGElement;
840
+ /**
841
+ * HTML overlay container for editor's HTML elements (such as label text editor).
842
+ */
843
+ overlayContainer: HTMLDivElement;
844
+ /**
845
+ * Type of marker to create.
846
+ */
847
+ markerType: new (container: SVGGElement) => TMarkerType;
848
+ /**
849
+ * Previously created marker to edit.
850
+ */
851
+ marker?: TMarkerType;
852
+ }
853
+
854
+ /**
855
+ * Represents marker's state (status) in time.
856
+ */
857
+ type MarkerEditorState = 'new' | 'creating' | 'select' | 'move' | 'resize' | 'rotate' | 'edit';
858
+ type MarkerCreationStyle = 'draw' | 'drop';
859
+ declare class MarkerBaseEditor<TMarkerType extends MarkerBase = MarkerBase> {
860
+ protected _markerType: new (container: SVGGElement) => TMarkerType;
861
+ protected _creationStyle: MarkerCreationStyle;
862
+ get creationStyle(): MarkerCreationStyle;
863
+ /**
864
+ * Type guard for specific marker editor types.
865
+ * @param cls
866
+ * @returns
867
+ */
868
+ is<T>(cls: new (...args: any[]) => T): this is T;
869
+ protected _marker: TMarkerType;
870
+ get marker(): TMarkerType;
871
+ protected _container: SVGGElement;
872
+ /**
873
+ * Returns the SVG container for the marker's and editor's visual elements.
874
+ */
875
+ get container(): SVGGElement;
876
+ /**
877
+ * Overlay container for HTML elements like text editors, etc.
878
+ */
879
+ protected _overlayContainer: HTMLDivElement;
880
+ /**
881
+ * Overlay container for HTML elements like text editors, etc.
882
+ */
883
+ get overlayContainer(): HTMLDivElement;
884
+ /**
885
+ * Editor's state.
886
+ */
887
+ protected _state: MarkerEditorState;
888
+ /**
889
+ * Gets editor's state.
890
+ */
891
+ get state(): MarkerEditorState;
892
+ /**
893
+ * Sets editor's state.
894
+ */
895
+ set state(value: MarkerEditorState);
896
+ /**
897
+ * SVG group holding editor's control box.
898
+ */
899
+ protected _controlBox: SVGGElement;
900
+ /**
901
+ * Method called when marker creation is finished.
902
+ */
903
+ onMarkerCreated?: <T extends MarkerBaseEditor<MarkerBase>>(editor: T) => void;
904
+ /**
905
+ * Method to call when marker state changes.
906
+ */
907
+ onStateChanged?: <T extends MarkerBaseEditor<MarkerBase>>(editor: T) => void;
908
+ /**
909
+ * Marker's state when it is selected
910
+ */
911
+ protected manipulationStartState?: string;
912
+ /**
913
+ * Is this marker selected?
914
+ */
915
+ protected _isSelected: boolean;
916
+ /**
917
+ * Returns true if the marker is currently selected
918
+ */
919
+ get isSelected(): boolean;
920
+ protected _continuousCreation: boolean;
921
+ get continuousCreation(): boolean;
922
+ /**
923
+ * Sets rectangle's border stroke color.
924
+ * @param color - color as string
925
+ */
926
+ set strokeColor(color: string);
927
+ get strokeColor(): string;
928
+ /**
929
+ * Sets rectangle's border stroke (line) width.
930
+ * @param color - color as string
931
+ */
932
+ set strokeWidth(width: number);
933
+ get strokeWidth(): number;
934
+ /**
935
+ * Sets rectangle's border stroke dash array.
936
+ * @param color - color as string
937
+ */
938
+ set strokeDasharray(dashes: string);
939
+ get strokeDasharray(): string;
940
+ set fillColor(color: string);
941
+ get fillColor(): string;
942
+ set opacity(value: number);
943
+ get opacity(): number;
944
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
945
+ ownsTarget(el: EventTarget | null): boolean;
946
+ /**
947
+ * Selects this marker and displays appropriate selected marker UI.
948
+ */
949
+ select(): void;
950
+ /**
951
+ * Deselects this marker and hides selected marker UI.
952
+ */
953
+ deselect(): void;
954
+ /**
955
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
956
+ *
957
+ * @param point - event coordinates.
958
+ * @param target - direct event target element.
959
+ */
960
+ pointerDown(point: IPoint, target?: EventTarget): void;
961
+ /**
962
+ * Handles pointer (mouse, touch, stylus, etc.) double click event.
963
+ *
964
+ * @param point - event coordinates.
965
+ * @param target - direct event target element.
966
+ */
967
+ dblClick(point: IPoint, target?: EventTarget): void;
968
+ /**
969
+ * Handles marker manipulation (move, resize, rotate, etc.).
970
+ *
971
+ * @param point - event coordinates.
972
+ */
973
+ manipulate(point: IPoint): void;
974
+ /**
975
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
976
+ *
977
+ * @param point - event coordinates.
978
+ */
979
+ pointerUp(point: IPoint): void;
980
+ /**
981
+ * Disposes the marker and clean's up.
982
+ */
983
+ dispose(): void;
984
+ protected adjustControlBox(): void;
985
+ scale(scaleX: number, scaleY: number): void;
986
+ /**
987
+ * Called by a marker when its state could have changed.
988
+ * Does a check if the state has indeed changed before firing the handler.
989
+ */
990
+ protected stateChanged(): void;
991
+ getState(): MarkerBaseState;
992
+ /**
993
+ * Restores previously saved marker state.
994
+ *
995
+ * @param state - previously saved state.
996
+ */
997
+ restoreState(state: MarkerBaseState): void;
998
+ }
999
+
1000
+ interface MarkerAreaEventMap {
1001
+ /**
1002
+ * Marker area initialized.
1003
+ */
1004
+ areainit: CustomEvent<MarkerAreaEventData>;
1005
+ areashow: CustomEvent<MarkerAreaEventData>;
1006
+ arearestorestate: CustomEvent<MarkerAreaEventData>;
1007
+ areafocus: CustomEvent<MarkerAreaEventData>;
1008
+ areablur: CustomEvent<MarkerAreaEventData>;
1009
+ areastatechange: CustomEvent<MarkerAreaEventData>;
1010
+ markerselect: CustomEvent<MarkerEditorEventData>;
1011
+ markerdeselect: CustomEvent<MarkerEditorEventData>;
1012
+ markercreating: CustomEvent<MarkerEditorEventData>;
1013
+ markercreate: CustomEvent<MarkerEditorEventData>;
1014
+ markerbeforedelete: CustomEvent<MarkerEditorEventData>;
1015
+ markerdelete: CustomEvent<MarkerEditorEventData>;
1016
+ markerchange: CustomEvent<MarkerEditorEventData>;
1017
+ }
1018
+ interface MarkerAreaEventData {
1019
+ /**
1020
+ * {@link MarkerArea} instance.
1021
+ */
1022
+ markerArea: MarkerArea;
1023
+ }
1024
+ interface MarkerEditorEventData extends MarkerAreaEventData {
1025
+ markerEditor: MarkerBaseEditor;
1026
+ }
1027
+ declare class MarkerArea extends HTMLElement {
1028
+ private _contentContainer?;
1029
+ private _canvasContainer?;
1030
+ private _overlayContainer;
1031
+ private _overlayContentContainer;
1032
+ private _mainCanvas?;
1033
+ private _groupLayer?;
1034
+ private _editingTarget?;
1035
+ private width;
1036
+ private height;
1037
+ private _targetWidth;
1038
+ get targetWidth(): number;
1039
+ set targetWidth(value: number);
1040
+ private _targetHeight;
1041
+ get targetHeight(): number;
1042
+ set targetHeight(value: number);
1043
+ private mode;
1044
+ private _logoUI?;
1045
+ private _isInitialized;
1046
+ private _currentMarkerEditor?;
1047
+ get currentMarkerEditor(): MarkerBaseEditor | undefined;
1048
+ private _newMarkerOutline;
1049
+ private _targetImage;
1050
+ get targetImage(): HTMLImageElement | undefined;
1051
+ set targetImage(value: HTMLImageElement | undefined);
1052
+ markerEditors: Map<typeof MarkerBase, typeof MarkerBaseEditor<MarkerBase>>;
1053
+ editors: MarkerBaseEditor[];
1054
+ private _zoomLevel;
1055
+ /**
1056
+ * Returns the current zoom level.
1057
+ */
1058
+ get zoomLevel(): number;
1059
+ /**
1060
+ * Sets the current zoom level.
1061
+ */
1062
+ set zoomLevel(value: number);
469
1063
  private prevPanPoint;
470
1064
  private panTo;
471
1065
  private undoRedoManager;
@@ -503,40 +1097,493 @@ declare class MarkerArea extends HTMLElement {
503
1097
  restoreState(state: AnnotationState): void;
504
1098
  private scaleMarkers;
505
1099
  /**
506
- * NOTE:
1100
+ * NOTE:
1101
+ *
1102
+ * before removing or modifying this method please consider supporting marker.js
1103
+ * by visiting https://markerjs.com/buy for details
1104
+ *
1105
+ * thank you!
1106
+ */
1107
+ private toggleLogo;
1108
+ private addLogo;
1109
+ private removeLogo;
1110
+ private positionLogo;
1111
+ /**
1112
+ * Returns true if undo operation can be performed (undo stack is not empty).
1113
+ */
1114
+ get isUndoPossible(): boolean;
1115
+ /**
1116
+ * Returns true if redo operation can be performed (redo stack is not empty).
1117
+ */
1118
+ get isRedoPossible(): boolean;
1119
+ private addUndoStep;
1120
+ /**
1121
+ * Undo last action.
1122
+ */
1123
+ undo(): void;
1124
+ private undoStep;
1125
+ /**
1126
+ * Redo previously undone action.
1127
+ */
1128
+ redo(): void;
1129
+ private redoStep;
1130
+ addEventListener<T extends keyof MarkerAreaEventMap>(type: T, listener: (this: MarkerArea, ev: MarkerAreaEventMap[T]) => void, options?: boolean | AddEventListenerOptions): void;
1131
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions | undefined): void;
1132
+ removeEventListener<T extends keyof MarkerAreaEventMap>(type: T, listener: (this: MarkerArea, ev: MarkerAreaEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
1133
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | EventListenerOptions | undefined): void;
1134
+ }
1135
+
1136
+ /**
1137
+ * Color type marks the kind of color property a color is referring to.
1138
+ */
1139
+ type ColorType = 'text' | 'stroke' | 'fill' | 'background';
1140
+
1141
+ type GripLocation = 'topleft' | 'topcenter' | 'topright' | 'leftcenter' | 'rightcenter' | 'bottomleft' | 'bottomcenter' | 'bottomright';
1142
+ /**
1143
+ * Represents a single resize-manipulation grip used in marker's manipulation controls.
1144
+ */
1145
+ declare class Grip {
1146
+ /**
1147
+ * Grip's visual element.
1148
+ */
1149
+ protected _visual?: SVGGraphicsElement;
1150
+ get visual(): SVGGraphicsElement;
1151
+ /**
1152
+ * Grip's size (radius).
1153
+ */
1154
+ gripSize: number;
1155
+ fillColor: string;
1156
+ strokeColor: string;
1157
+ /**
1158
+ * Creates a new grip.
1159
+ */
1160
+ constructor();
1161
+ protected createVisual(): void;
1162
+ /**
1163
+ * Returns true if passed SVG element belongs to the grip. False otherwise.
1164
+ *
1165
+ * @param el - target element.
1166
+ */
1167
+ ownsTarget(el: EventTarget): boolean;
1168
+ }
1169
+
1170
+ declare class ResizeGrip extends Grip {
1171
+ }
1172
+
1173
+ declare class RotateGrip extends Grip {
1174
+ constructor();
1175
+ }
1176
+
1177
+ declare class RectangularBoxMarkerBaseEditor<TMarkerType extends RectangularBoxMarkerBase = RectangularBoxMarkerBase> extends MarkerBaseEditor<TMarkerType> {
1178
+ /**
1179
+ * x coordinate of the top-left corner at the start of manipulation.
1180
+ */
1181
+ protected manipulationStartLeft: number;
1182
+ /**
1183
+ * y coordinate of the top-left corner at the start of manipulation.
1184
+ */
1185
+ protected manipulationStartTop: number;
1186
+ /**
1187
+ * Width at the start of manipulation.
1188
+ */
1189
+ protected manipulationStartWidth: number;
1190
+ /**
1191
+ * Height at the start of manipulation.
1192
+ */
1193
+ protected manipulationStartHeight: number;
1194
+ /**
1195
+ * x coordinate of the pointer at the start of manipulation.
1196
+ */
1197
+ protected manipulationStartX: number;
1198
+ /**
1199
+ * y coordinate of the pointer at the start of manipulation.
1200
+ */
1201
+ protected manipulationStartY: number;
1202
+ /**
1203
+ * Pointer's horizontal distance from the top left corner.
1204
+ */
1205
+ protected offsetX: number;
1206
+ /**
1207
+ * Pointer's vertical distance from the top left corner.
1208
+ */
1209
+ protected offsetY: number;
1210
+ /**
1211
+ * Container for the marker's editing controls.
1212
+ */
1213
+ protected controlBox: SVGGElement;
1214
+ private readonly CB_DISTANCE;
1215
+ private controlRect?;
1216
+ private rotatorGripLine?;
1217
+ private controlGrips;
1218
+ protected disabledResizeGrips: GripLocation[];
1219
+ private rotatorGrip?;
1220
+ private activeGrip?;
1221
+ private disableRotation;
1222
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1223
+ /**
1224
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
1225
+ *
1226
+ * @param el - target element.
1227
+ */
1228
+ ownsTarget(el: EventTarget): boolean;
1229
+ /**
1230
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
1231
+ *
1232
+ * @param point - event coordinates.
1233
+ * @param target - direct event target element.
1234
+ */
1235
+ pointerDown(point: IPoint, target?: EventTarget): void;
1236
+ protected _suppressMarkerCreateEvent: boolean;
1237
+ /**
1238
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1239
+ *
1240
+ * @param point - event coordinates.
1241
+ * @param target - direct event target element.
1242
+ */
1243
+ pointerUp(point: IPoint): void;
1244
+ /**
1245
+ * Handles marker manipulation (move, resize, rotate, etc.).
1246
+ *
1247
+ * @param point - event coordinates.
1248
+ */
1249
+ manipulate(point: IPoint): void;
1250
+ /**
1251
+ * Resizes the marker based on pointer coordinates and context.
1252
+ * @param point - pointer coordinates.
1253
+ */
1254
+ protected resize(point: IPoint): void;
1255
+ /**
1256
+ * Sets control box size and location.
1257
+ */
1258
+ protected setSize(): void;
1259
+ /**
1260
+ * Displays marker's controls.
1261
+ */
1262
+ select(): void;
1263
+ /**
1264
+ * Hides marker's controls.
1265
+ */
1266
+ deselect(): void;
1267
+ private setupControlBox;
1268
+ protected adjustControlBox(): void;
1269
+ private addControlGrips;
1270
+ private createRotateGrip;
1271
+ private positionGrips;
1272
+ private positionGrip;
1273
+ /**
1274
+ * Hides marker's editing controls.
1275
+ */
1276
+ protected hideControlBox(): void;
1277
+ /**
1278
+ * Shows marker's editing controls.
1279
+ */
1280
+ protected showControlBox(): void;
1281
+ protected adjustGripVisibility(): void;
1282
+ /**
1283
+ * Scales marker. Used after the image resize.
507
1284
  *
508
- * before removing or modifying this method please consider supporting marker.js
509
- * by visiting https://markerjs.com/buy for details
1285
+ * @param scaleX - horizontal scale
1286
+ * @param scaleY - vertical scale
1287
+ */
1288
+ scale(scaleX: number, scaleY: number): void;
1289
+ }
1290
+
1291
+ declare class ShapeOutlineMarkerEditor<TMarkerType extends ShapeOutlineMarkerBase = ShapeOutlineMarkerBase> extends RectangularBoxMarkerBaseEditor<TMarkerType> {
1292
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1293
+ /**
1294
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
510
1295
  *
511
- * thank you!
1296
+ * @param point - event coordinates.
1297
+ * @param target - direct event target element.
512
1298
  */
513
- private toggleLogo;
514
- private addLogo;
515
- private removeLogo;
516
- private positionLogo;
1299
+ pointerDown(point: IPoint, target?: EventTarget): void;
517
1300
  /**
518
- * Returns true if undo operation can be performed (undo stack is not empty).
1301
+ * Resizes the marker based on the pointer coordinates.
1302
+ * @param point - current pointer coordinates.
519
1303
  */
520
- get isUndoPossible(): boolean;
1304
+ protected resize(point: IPoint): void;
521
1305
  /**
522
- * Returns true if redo operation can be performed (redo stack is not empty).
1306
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1307
+ *
1308
+ * @param point - event coordinates.
1309
+ * @param target - direct event target element.
523
1310
  */
524
- get isRedoPossible(): boolean;
525
- private addUndoStep;
1311
+ pointerUp(point: IPoint): void;
1312
+ }
1313
+
1314
+ declare class LinearMarkerEditor<TMarkerType extends LinearMarkerBase = LinearMarkerBase> extends MarkerBaseEditor<TMarkerType> {
526
1315
  /**
527
- * Undo last action.
1316
+ * Default line length when marker is created with a simple click (without dragging).
528
1317
  */
529
- undo(): void;
530
- private undoStep;
1318
+ protected defaultLength: number;
531
1319
  /**
532
- * Redo previously undone action.
1320
+ * Pointer coordinates at the start of move or resize.
533
1321
  */
534
- redo(): void;
535
- private redoStep;
536
- addEventListener<T extends keyof MarkerAreaEventMap>(type: T, listener: (this: MarkerArea, ev: MarkerAreaEventMap[T]) => void, options?: boolean | AddEventListenerOptions): void;
537
- addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions | undefined): void;
538
- removeEventListener<T extends keyof MarkerAreaEventMap>(type: T, listener: (this: MarkerArea, ev: MarkerAreaEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
539
- removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | EventListenerOptions | undefined): void;
1322
+ protected manipulationStartX: number;
1323
+ protected manipulationStartY: number;
1324
+ private manipulationStartX1;
1325
+ private manipulationStartY1;
1326
+ private manipulationStartX2;
1327
+ private manipulationStartY2;
1328
+ /**
1329
+ * Container for control elements.
1330
+ */
1331
+ protected controlBox: SVGGElement;
1332
+ /**
1333
+ * First manipulation grip
1334
+ */
1335
+ protected grip1?: ResizeGrip;
1336
+ /**
1337
+ * Second manipulation grip.
1338
+ */
1339
+ protected grip2?: ResizeGrip;
1340
+ /**
1341
+ * Active manipulation grip.
1342
+ */
1343
+ protected activeGrip?: ResizeGrip;
1344
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1345
+ /**
1346
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
1347
+ *
1348
+ * @param el - target element.
1349
+ */
1350
+ ownsTarget(el: EventTarget): boolean;
1351
+ /**
1352
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
1353
+ *
1354
+ * @param point - event coordinates.
1355
+ * @param target - direct event target element.
1356
+ */
1357
+ pointerDown(point: IPoint, target?: EventTarget): void;
1358
+ /**
1359
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1360
+ *
1361
+ * @param point - event coordinates.
1362
+ * @param target - direct event target element.
1363
+ */
1364
+ pointerUp(point: IPoint): void;
1365
+ /**
1366
+ * Handles marker manipulation (move, resize, rotate, etc.).
1367
+ *
1368
+ * @param point - event coordinates.
1369
+ */
1370
+ manipulate(point: IPoint): void;
1371
+ /**
1372
+ * Resizes the line marker.
1373
+ * @param point - current manipulation coordinates.
1374
+ */
1375
+ protected resize(point: IPoint): void;
1376
+ /**
1377
+ * Creates control box for manipulation controls.
1378
+ */
1379
+ protected setupControlBox(): void;
1380
+ protected adjustControlBox(): void;
1381
+ /**
1382
+ * Adds control grips to control box.
1383
+ */
1384
+ protected addControlGrips(): void;
1385
+ /**
1386
+ * Creates manipulation grip.
1387
+ * @returns - manipulation grip.
1388
+ */
1389
+ protected createGrip(): ResizeGrip;
1390
+ /**
1391
+ * Updates manipulation grip layout.
1392
+ */
1393
+ protected positionGrips(): void;
1394
+ /**
1395
+ * Positions manipulation grip.
1396
+ * @param grip - grip to position
1397
+ * @param x - new X coordinate
1398
+ * @param y - new Y coordinate
1399
+ */
1400
+ protected positionGrip(grip: SVGGraphicsElement, x: number, y: number): void;
1401
+ /**
1402
+ * Displays marker's controls.
1403
+ */
1404
+ select(): void;
1405
+ /**
1406
+ * Hides marker's controls.
1407
+ */
1408
+ deselect(): void;
1409
+ }
1410
+
1411
+ declare class PolygonMarkerEditor<TMarkerType extends PolygonMarker = PolygonMarker> extends MarkerBaseEditor<TMarkerType> {
1412
+ /**
1413
+ * Default line length when marker is created with a simple click (without dragging).
1414
+ */
1415
+ protected defaultLength: number;
1416
+ /**
1417
+ * Pointer coordinates at the start of move or resize.
1418
+ */
1419
+ protected manipulationStartX: number;
1420
+ protected manipulationStartY: number;
1421
+ /**
1422
+ * Container for control elements.
1423
+ */
1424
+ protected controlBox: SVGGElement;
1425
+ protected grips: ResizeGrip[];
1426
+ /**
1427
+ * Active manipulation grip.
1428
+ */
1429
+ protected activeGrip?: ResizeGrip;
1430
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1431
+ /**
1432
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
1433
+ *
1434
+ * @param el - target element.
1435
+ */
1436
+ ownsTarget(el: EventTarget): boolean;
1437
+ /**
1438
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
1439
+ *
1440
+ * @param point - event coordinates.
1441
+ * @param target - direct event target element.
1442
+ */
1443
+ pointerDown(point: IPoint, target?: EventTarget): void;
1444
+ private startCreation;
1445
+ private addNewPointWhileCreating;
1446
+ private finishCreation;
1447
+ /**
1448
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1449
+ *
1450
+ * @param point - event coordinates.
1451
+ * @param target - direct event target element.
1452
+ */
1453
+ pointerUp(point: IPoint): void;
1454
+ /**
1455
+ * Handles marker manipulation (move, resize, rotate, etc.).
1456
+ *
1457
+ * @param point - event coordinates.
1458
+ */
1459
+ manipulate(point: IPoint): void;
1460
+ /**
1461
+ * Resizes the line marker.
1462
+ * @param point - current manipulation coordinates.
1463
+ */
1464
+ protected resize(point: IPoint): void;
1465
+ dblClick(point: IPoint, target?: EventTarget | undefined): void;
1466
+ /**
1467
+ * Creates control box for manipulation controls.
1468
+ */
1469
+ protected setupControlBox(): void;
1470
+ protected adjustControlBox(): void;
1471
+ /**
1472
+ * Adds control grips to control box.
1473
+ */
1474
+ protected adjustControlGrips(): void;
1475
+ /**
1476
+ * Creates manipulation grip.
1477
+ * @returns - manipulation grip.
1478
+ */
1479
+ protected createGrip(): ResizeGrip;
1480
+ /**
1481
+ * Updates manipulation grip layout.
1482
+ */
1483
+ protected positionGrips(): void;
1484
+ /**
1485
+ * Positions manipulation grip.
1486
+ * @param grip - grip to position
1487
+ * @param x - new X coordinate
1488
+ * @param y - new Y coordinate
1489
+ */
1490
+ protected positionGrip(grip: SVGGraphicsElement, x: number, y: number): void;
1491
+ /**
1492
+ * Displays marker's controls.
1493
+ */
1494
+ select(): void;
1495
+ /**
1496
+ * Hides marker's controls.
1497
+ */
1498
+ deselect(): void;
1499
+ }
1500
+
1501
+ declare class FreehandMarkerEditor<TMarkerType extends FreehandMarker = FreehandMarker> extends MarkerBaseEditor<TMarkerType> {
1502
+ /**
1503
+ * Pointer coordinates at the start of move or resize.
1504
+ */
1505
+ protected manipulationStartX: number;
1506
+ protected manipulationStartY: number;
1507
+ /**
1508
+ * Container for control elements.
1509
+ */
1510
+ protected controlBox: SVGGElement;
1511
+ private controlRect?;
1512
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1513
+ /**
1514
+ * Returns true if passed SVG element belongs to the marker. False otherwise.
1515
+ *
1516
+ * @param el - target element.
1517
+ */
1518
+ ownsTarget(el: EventTarget): boolean;
1519
+ /**
1520
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
1521
+ *
1522
+ * @param point - event coordinates.
1523
+ * @param target - direct event target element.
1524
+ */
1525
+ pointerDown(point: IPoint, target?: EventTarget): void;
1526
+ private startCreation;
1527
+ private addNewPointWhileCreating;
1528
+ private finishCreation;
1529
+ /**
1530
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1531
+ *
1532
+ * @param point - event coordinates.
1533
+ * @param target - direct event target element.
1534
+ */
1535
+ pointerUp(point: IPoint): void;
1536
+ /**
1537
+ * Handles marker manipulation (move, resize, rotate, etc.).
1538
+ *
1539
+ * @param point - event coordinates.
1540
+ */
1541
+ manipulate(point: IPoint): void;
1542
+ /**
1543
+ * Creates control box for manipulation controls.
1544
+ */
1545
+ protected setupControlBox(): void;
1546
+ protected adjustControlBox(): void;
1547
+ /**
1548
+ * Displays marker's controls.
1549
+ */
1550
+ select(): void;
1551
+ /**
1552
+ * Hides marker's controls.
1553
+ */
1554
+ deselect(): void;
1555
+ }
1556
+
1557
+ declare class TextMarkerEditor<TMarkerType extends TextMarker = TextMarker> extends RectangularBoxMarkerBaseEditor<TMarkerType> {
1558
+ private textBlockEditorContainer;
1559
+ private textBlockEditor;
1560
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1561
+ private _pointerDownTime;
1562
+ private _pointerDownPoint;
1563
+ /**
1564
+ * Handles pointer (mouse, touch, stylus, etc.) down event.
1565
+ *
1566
+ * @param point - event coordinates.
1567
+ * @param target - direct event target element.
1568
+ */
1569
+ pointerDown(point: IPoint, target?: EventTarget): void;
1570
+ dblClick(point: IPoint, target?: EventTarget): void;
1571
+ protected setSize(): void;
1572
+ /**
1573
+ * Resizes the marker based on the pointer coordinates.
1574
+ * @param point - current pointer coordinates.
1575
+ */
1576
+ protected resize(point: IPoint): void;
1577
+ /**
1578
+ * Handles pointer (mouse, touch, stylus, etc.) up event.
1579
+ *
1580
+ * @param point - event coordinates.
1581
+ * @param target - direct event target element.
1582
+ */
1583
+ pointerUp(point: IPoint): void;
1584
+ private showEditor;
1585
+ private hideEditor;
1586
+ private markerSizeChanged;
540
1587
  }
541
1588
 
542
1589
  interface MarkerViewEventMap {
@@ -617,4 +1664,65 @@ declare class MarkerView extends HTMLElement {
617
1664
  removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | EventListenerOptions | undefined): void;
618
1665
  }
619
1666
 
620
- export { type IPoint, MarkerArea, type MarkerAreaEventData, type MarkerAreaEventMap, MarkerView, type MarkerViewEventData, type MarkerViewEventMap, SvgHelper };
1667
+ declare class Renderer {
1668
+ private _mainCanvas?;
1669
+ private _editingTarget?;
1670
+ private _targetWidth;
1671
+ get targetWidth(): number;
1672
+ set targetWidth(value: number);
1673
+ private _targetHeight;
1674
+ get targetHeight(): number;
1675
+ set targetHeight(value: number);
1676
+ private _targetImageLoaded;
1677
+ private _targetImage;
1678
+ get targetImage(): HTMLImageElement | undefined;
1679
+ set targetImage(value: HTMLImageElement | undefined);
1680
+ markerTypes: Array<typeof MarkerBase>;
1681
+ markers: MarkerBase[];
1682
+ private _isInitialized;
1683
+ /**
1684
+ * Whether the image should be rendered at the original (natural) target image size.
1685
+ */
1686
+ naturalSize: boolean;
1687
+ /**
1688
+ * Rendered image type (`image/png`, `image/jpeg`, etc.).
1689
+ */
1690
+ imageType: string;
1691
+ /**
1692
+ * For formats that support it, specifies rendering quality.
1693
+ *
1694
+ * In the case of `image/jpeg` you can specify a value between 0 and 1 (lowest to highest quality).
1695
+ *
1696
+ * @type {number} - image rendering quality (0..1)
1697
+ */
1698
+ imageQuality?: number;
1699
+ /**
1700
+ * When set to true, only the marker layer without the original image will be rendered.
1701
+ */
1702
+ markersOnly: boolean;
1703
+ /**
1704
+ * When set and {@linkcode naturalSize} is `false` sets the width of the rendered image.
1705
+ *
1706
+ * Both `width` and `height` have to be set for this to take effect.
1707
+ */
1708
+ width?: number;
1709
+ /**
1710
+ * When set and {@linkcode naturalSize} is `false` sets the height of the rendered image.
1711
+ *
1712
+ * Both `width` and `height` have to be set for this to take effect.
1713
+ */
1714
+ height?: number;
1715
+ constructor();
1716
+ private init;
1717
+ private addMainCanvas;
1718
+ private setMainCanvasSize;
1719
+ private setEditingTargetSize;
1720
+ private addTargetImage;
1721
+ private addNewMarker;
1722
+ private getMarkerTypeByName;
1723
+ restoreState(state: AnnotationState): void;
1724
+ private scaleMarkers;
1725
+ rasterize(state: AnnotationState, targetCanvas?: HTMLCanvasElement): Promise<string>;
1726
+ }
1727
+
1728
+ export { type AnnotationState, type ColorType, FrameMarker, FreehandMarker, FreehandMarkerEditor, type FreehandMarkerState, Grip, type IPoint, LinearMarkerBase, type LinearMarkerBaseState, LinearMarkerEditor, MarkerArea, type MarkerAreaEventData, type MarkerAreaEventMap, MarkerBase, MarkerBaseEditor, type MarkerBaseState, type MarkerEditorProperties, type MarkerEditorState, MarkerView, type MarkerViewEventData, type MarkerViewEventMap, PolygonMarker, PolygonMarkerEditor, type PolygonMarkerState, RectangularBoxMarkerBase, type RectangularBoxMarkerBaseState, Renderer, ResizeGrip, RotateGrip, ShapeOutlineMarkerBase, type ShapeOutlineMarkerBaseState, ShapeOutlineMarkerEditor, SvgHelper, TextMarker, TextMarkerEditor, type TextMarkerState };