@markerjs/markerjs3 3.0.0-alpha.1 → 3.0.0-alpha.3

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