@markerjs/markerjs3 3.0.0-alpha.2 → 3.0.0-alpha.4

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
@@ -393,6 +393,32 @@ declare class ShapeOutlineMarkerBase extends RectangularBoxMarkerBase {
393
393
  interface ShapeOutlineMarkerBaseState extends RectangularBoxMarkerBaseState {
394
394
  }
395
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;
410
+ /**
411
+ * Returns current marker state that can be restored in the future.
412
+ */
413
+ getState(): ShapeMarkerBaseState;
414
+ /**
415
+ * Restores previously saved marker state.
416
+ *
417
+ * @param state - previously saved state.
418
+ */
419
+ restoreState(state: MarkerBaseState): void;
420
+ }
421
+
396
422
  declare class FrameMarker extends ShapeOutlineMarkerBase {
397
423
  /**
398
424
  * String type name of the marker type.
@@ -487,6 +513,54 @@ declare class LinearMarkerBase extends MarkerBase {
487
513
  scale(scaleX: number, scaleY: number): void;
488
514
  }
489
515
 
516
+ declare class LineMarker extends LinearMarkerBase {
517
+ static typeName: string;
518
+ static title: string;
519
+ constructor(container: SVGGElement);
520
+ protected getPath(): string;
521
+ /**
522
+ * Returns current marker state that can be restored in the future.
523
+ */
524
+ getState(): LinearMarkerBaseState;
525
+ }
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;
541
+ /**
542
+ * Returns marker's state.
543
+ */
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;
550
+ }
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;
562
+ }
563
+
490
564
  interface PolygonMarkerState extends MarkerBaseState {
491
565
  /**
492
566
  * Polygon points.
@@ -798,6 +872,7 @@ declare class TextMarker extends RectangularBoxMarkerBase {
798
872
  textBlock: TextBlock;
799
873
  constructor(container: SVGGElement);
800
874
  createVisual(): void;
875
+ adjustVisual(): void;
801
876
  ownsTarget(el: EventTarget): boolean;
802
877
  protected setTextBoundingBox(): void;
803
878
  /**
@@ -832,6 +907,86 @@ declare class TextMarker extends RectangularBoxMarkerBase {
832
907
  scale(scaleX: number, scaleY: number): void;
833
908
  }
834
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
+ declare class EllipseFrameMarker extends ShapeOutlineMarkerBase {
963
+ /**
964
+ * String type name of the marker type.
965
+ */
966
+ static typeName: string;
967
+ /**
968
+ * Marker type title (display name) used for accessibility and other attributes.
969
+ */
970
+ static title: string;
971
+ constructor(container: SVGGElement);
972
+ protected getPath(width?: number, height?: number): string;
973
+ getState(): ShapeOutlineMarkerBaseState;
974
+ }
975
+
976
+ declare class EllipseMarker extends ShapeMarkerBase {
977
+ /**
978
+ * String type name of the marker type.
979
+ */
980
+ static typeName: string;
981
+ /**
982
+ * Marker type title (display name) used for accessibility and other attributes.
983
+ */
984
+ static title: string;
985
+ constructor(container: SVGGElement);
986
+ protected getPath(width?: number, height?: number): string;
987
+ getState(): ShapeMarkerBaseState;
988
+ }
989
+
835
990
  interface MarkerEditorProperties<TMarkerType extends MarkerBase = MarkerBase> {
836
991
  /**
837
992
  * SVG container for the marker and editor elements.
@@ -943,10 +1098,11 @@ declare class MarkerBaseEditor<TMarkerType extends MarkerBase = MarkerBase> {
943
1098
  get opacity(): number;
944
1099
  constructor(properties: MarkerEditorProperties<TMarkerType>);
945
1100
  ownsTarget(el: EventTarget | null): boolean;
1101
+ protected isMultiSelected: boolean;
946
1102
  /**
947
1103
  * Selects this marker and displays appropriate selected marker UI.
948
1104
  */
949
- select(): void;
1105
+ select(multi?: boolean): void;
950
1106
  /**
951
1107
  * Deselects this marker and hides selected marker UI.
952
1108
  */
@@ -1045,6 +1201,7 @@ declare class MarkerArea extends HTMLElement {
1045
1201
  private _isInitialized;
1046
1202
  private _currentMarkerEditor?;
1047
1203
  get currentMarkerEditor(): MarkerBaseEditor | undefined;
1204
+ private _selectedMarkerEditors;
1048
1205
  private _newMarkerOutline;
1049
1206
  private _targetImage;
1050
1207
  get targetImage(): HTMLImageElement | undefined;
@@ -1076,15 +1233,25 @@ declare class MarkerArea extends HTMLElement {
1076
1233
  private addNewMarker;
1077
1234
  private markerCreated;
1078
1235
  private markerStateChanged;
1236
+ deleteMarker(markerEditor: MarkerBaseEditor): void;
1237
+ deleteSelectedMarkers(): void;
1079
1238
  setCurrentEditor(editor?: MarkerBaseEditor): void;
1239
+ selectEditor(editor: MarkerBaseEditor): void;
1240
+ deselectEditor(editor?: MarkerBaseEditor): void;
1080
1241
  private touchPoints;
1081
1242
  private isDragging;
1243
+ private isSelecting;
1244
+ private _marqueeSelectOutline;
1245
+ private _marqueeSelectRect;
1246
+ private _manipulationStartX;
1247
+ private _manipulationStartY;
1082
1248
  private onCanvasPointerDown;
1083
1249
  private onCanvasDblClick;
1084
1250
  private onPointerMove;
1085
1251
  private showOutline;
1086
1252
  private hideOutline;
1087
1253
  private onPointerUp;
1254
+ private finishMarqueeSelection;
1088
1255
  private onPointerOut;
1089
1256
  private onKeyUp;
1090
1257
  private attachEvents;
@@ -1211,13 +1378,14 @@ declare class RectangularBoxMarkerBaseEditor<TMarkerType extends RectangularBoxM
1211
1378
  * Container for the marker's editing controls.
1212
1379
  */
1213
1380
  protected controlBox: SVGGElement;
1381
+ protected manipulationBox: SVGGElement;
1214
1382
  private readonly CB_DISTANCE;
1215
1383
  private controlRect?;
1216
1384
  private rotatorGripLine?;
1217
1385
  private controlGrips;
1218
1386
  protected disabledResizeGrips: GripLocation[];
1219
1387
  private rotatorGrip?;
1220
- private activeGrip?;
1388
+ protected activeGrip?: Grip;
1221
1389
  private disableRotation;
1222
1390
  constructor(properties: MarkerEditorProperties<TMarkerType>);
1223
1391
  /**
@@ -1259,17 +1427,17 @@ declare class RectangularBoxMarkerBaseEditor<TMarkerType extends RectangularBoxM
1259
1427
  /**
1260
1428
  * Displays marker's controls.
1261
1429
  */
1262
- select(): void;
1430
+ select(multi?: boolean): void;
1263
1431
  /**
1264
1432
  * Hides marker's controls.
1265
1433
  */
1266
1434
  deselect(): void;
1267
1435
  private setupControlBox;
1268
1436
  protected adjustControlBox(): void;
1269
- private addControlGrips;
1437
+ protected addControlGrips(): void;
1270
1438
  private createRotateGrip;
1271
- private positionGrips;
1272
- private positionGrip;
1439
+ protected positionGrips(): void;
1440
+ protected positionGrip(grip: SVGGraphicsElement | undefined, x: number, y: number): void;
1273
1441
  /**
1274
1442
  * Hides marker's editing controls.
1275
1443
  */
@@ -1311,6 +1479,9 @@ declare class ShapeOutlineMarkerEditor<TMarkerType extends ShapeOutlineMarkerBas
1311
1479
  pointerUp(point: IPoint): void;
1312
1480
  }
1313
1481
 
1482
+ declare class ShapeMarkerEditor<TMarkerType extends ShapeMarkerBase = ShapeMarkerBase> extends ShapeOutlineMarkerEditor<TMarkerType> {
1483
+ }
1484
+
1314
1485
  declare class LinearMarkerEditor<TMarkerType extends LinearMarkerBase = LinearMarkerBase> extends MarkerBaseEditor<TMarkerType> {
1315
1486
  /**
1316
1487
  * Default line length when marker is created with a simple click (without dragging).
@@ -1329,6 +1500,7 @@ declare class LinearMarkerEditor<TMarkerType extends LinearMarkerBase = LinearMa
1329
1500
  * Container for control elements.
1330
1501
  */
1331
1502
  protected controlBox: SVGGElement;
1503
+ protected manipulationBox: SVGGElement;
1332
1504
  /**
1333
1505
  * First manipulation grip
1334
1506
  */
@@ -1401,7 +1573,7 @@ declare class LinearMarkerEditor<TMarkerType extends LinearMarkerBase = LinearMa
1401
1573
  /**
1402
1574
  * Displays marker's controls.
1403
1575
  */
1404
- select(): void;
1576
+ select(multi?: boolean): void;
1405
1577
  /**
1406
1578
  * Hides marker's controls.
1407
1579
  */
@@ -1422,6 +1594,7 @@ declare class PolygonMarkerEditor<TMarkerType extends PolygonMarker = PolygonMar
1422
1594
  * Container for control elements.
1423
1595
  */
1424
1596
  protected controlBox: SVGGElement;
1597
+ protected manipulationBox: SVGGElement;
1425
1598
  protected grips: ResizeGrip[];
1426
1599
  /**
1427
1600
  * Active manipulation grip.
@@ -1491,7 +1664,7 @@ declare class PolygonMarkerEditor<TMarkerType extends PolygonMarker = PolygonMar
1491
1664
  /**
1492
1665
  * Displays marker's controls.
1493
1666
  */
1494
- select(): void;
1667
+ select(multi?: boolean): void;
1495
1668
  /**
1496
1669
  * Hides marker's controls.
1497
1670
  */
@@ -1586,6 +1759,24 @@ declare class TextMarkerEditor<TMarkerType extends TextMarker = TextMarker> exte
1586
1759
  private markerSizeChanged;
1587
1760
  }
1588
1761
 
1762
+ declare class ArrowMarkerEditor<TMarkerType extends ArrowMarker = ArrowMarker> extends LinearMarkerEditor<TMarkerType> {
1763
+ set arrowType(value: ArrowType);
1764
+ get arrowType(): ArrowType;
1765
+ }
1766
+
1767
+ declare class CalloutMarkerEditor<TMarkerType extends CalloutMarker = CalloutMarker> extends TextMarkerEditor<TMarkerType> {
1768
+ private tipGrip?;
1769
+ private manipulationStartTipPositionX;
1770
+ private manipulationStartTipPositionY;
1771
+ constructor(properties: MarkerEditorProperties<TMarkerType>);
1772
+ protected addControlGrips(): void;
1773
+ private createTipGrip;
1774
+ protected positionGrips(): void;
1775
+ ownsTarget(el: EventTarget): boolean;
1776
+ pointerDown(point: IPoint, target?: EventTarget): void;
1777
+ protected resize(point: IPoint): void;
1778
+ }
1779
+
1589
1780
  interface MarkerViewEventMap {
1590
1781
  /**
1591
1782
  * Viewer initialized.
@@ -1725,4 +1916,4 @@ declare class Renderer {
1725
1916
  rasterize(state: AnnotationState, targetCanvas?: HTMLCanvasElement): Promise<string>;
1726
1917
  }
1727
1918
 
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 };
1919
+ export { type AnnotationState, ArrowMarker, ArrowMarkerEditor, type ArrowMarkerState, type ArrowType, CalloutMarker, CalloutMarkerEditor, type CalloutMarkerState, type ColorType, CoverMarker, EllipseFrameMarker, EllipseMarker, 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 };