@markerjs/markerjs3 3.0.0-rc.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # marker.js 3 — Add image annotation to your web apps
2
2
 
3
- > **Note**: marker.js 3 is in the pre-release stage of its lifecycle and will have many additions and, potentially, breaking changes before the official 3.0 release.
4
- >
5
- > If you need a stable image annotation library, consider using [marker.js 2](https://markerjs.com) for now.
6
-
7
3
  marker.js 3 is a JavaScript browser library to enable image annotation in your web applications. Add marker.js 3 to your web app and enable users to annotate and mark up images. You can save, share or otherwise process the results.
8
4
 
9
5
  ## Installation
@@ -12,15 +8,11 @@ marker.js 3 is a JavaScript browser library to enable image annotation in your w
12
8
  npm install @markerjs/markerjs3
13
9
  ```
14
10
 
15
- or
16
-
17
- ```
18
- yarn add @markerjs/markerjs3
19
- ```
11
+ The library includes TypeScript type definitions out of the box.
20
12
 
21
13
  ## Usage
22
14
 
23
- Unlike the previous version, marker.js 3 is a "headless" (sort of) library. In this case "headless" means that it doesn't come with any toolbars, property editors, and placement preconceptions. This way the library focuses on the core features you need, and you can make it feel totally native in the application you are building without resorting to any tricks or hacks.
15
+ marker.js 3 is a "headless" library. In this case "headless" means that it doesn't come with any toolbars, property editors, and placement preconceptions. This way the library focuses on the core features you need, and you can make it feel totally native in the application you are building without resorting to any tricks or hacks.
24
16
 
25
17
  With that out of the way, here are the simplest usage scenarios...
26
18
 
@@ -50,15 +42,15 @@ editorContainerDiv.appendChild(markerArea);
50
42
  To initiate creation of a marker you just call `createMarker()` and pass it the name (or type) of the marker you want to create. So, if you have a button with id `addFrameButton` you can make it create a new `FrameMarker` with something like this:
51
43
 
52
44
  ```js
53
- document.querySelector("#addButton")!.addEventListener("click", () => {
54
- markerArea.createMarker("FrameMarker");
45
+ document.querySelector('#addButton')?.addEventListener('click', () => {
46
+ markerArea.createMarker('FrameMarker');
55
47
  });
56
48
  ```
57
49
 
58
50
  And whenever you want to save state (current annotation) you just call `getState()`:
59
51
 
60
52
  ```js
61
- document.querySelector("#saveStateButton")!.addEventListener("click", () => {
53
+ document.querySelector('#saveStateButton')?.addEventListener('click', () => {
62
54
  const state = markerArea.getState();
63
55
  console.log(state);
64
56
  });
@@ -101,15 +93,11 @@ markerView.show(savedState);
101
93
 
102
94
  ## Demos
103
95
 
104
- Check out the "work-in-progress" demo [here](https://github.com/ailon/markerjs3-wip-demo). It covers most of the available features with no extra bells or whistles.
105
-
106
- While it's made with React it is purposefully light on React-specific stuff and "best practices" to just focus on marker.js 3 related things.
107
-
108
- _more demos coming soon..._
96
+ Check out the [demos on markerjs.com](https://markerjs.com/demos).
109
97
 
110
98
  ## More docs and tutorials
111
99
 
112
- _coming soon..._
100
+ You can find marker.js 3 reference and tutorials [here](https://markerjs.com/docs-v3/).
113
101
 
114
102
  ## License
115
103
 
package/markerjs3.d.ts CHANGED
@@ -1033,7 +1033,7 @@ declare class TextBlock {
1033
1033
  /**
1034
1034
  * Renders text within the text block according to its settings.
1035
1035
  */
1036
- renderText(): void;
1036
+ renderText(): Promise<void>;
1037
1037
  private applyFontStyles;
1038
1038
  private _textSize?;
1039
1039
  /**
@@ -1158,6 +1158,7 @@ declare class TextMarker extends RectangularBoxMarkerBase {
1158
1158
  */
1159
1159
  textBlock: TextBlock;
1160
1160
  constructor(container: SVGGElement);
1161
+ protected applyOpacity(): void;
1161
1162
  /**
1162
1163
  * Creates marker's visual.
1163
1164
  */
@@ -1395,6 +1396,7 @@ declare class ImageMarkerBase extends RectangularBoxMarkerBase {
1395
1396
  */
1396
1397
  protected naturalHeight: number;
1397
1398
  constructor(container: SVGGElement);
1399
+ protected applyOpacity(): void;
1398
1400
  /**
1399
1401
  * Creates the image element based on the image type and source.
1400
1402
  */
@@ -1403,6 +1405,11 @@ declare class ImageMarkerBase extends RectangularBoxMarkerBase {
1403
1405
  * Creates marker's visual, including its image element.
1404
1406
  */
1405
1407
  createVisual(): void;
1408
+ /**
1409
+ * Adjusts marker's visual according to the current state
1410
+ * (color, width, etc.).
1411
+ */
1412
+ adjustVisual(): void;
1406
1413
  /**
1407
1414
  * Adjusts the image size and position.
1408
1415
  */
@@ -1699,6 +1706,14 @@ declare class MarkerBaseEditor<TMarkerType extends MarkerBase = MarkerBase> {
1699
1706
  * Gets marker's opacity.
1700
1707
  */
1701
1708
  get opacity(): number;
1709
+ /**
1710
+ * Sets marker's notes.
1711
+ */
1712
+ set notes(value: string | undefined);
1713
+ /**
1714
+ * Gets marker's notes.
1715
+ */
1716
+ get notes(): string | undefined;
1702
1717
  /**
1703
1718
  * Creates a new instance of marker editor.
1704
1719
  *
@@ -1906,6 +1921,7 @@ type MarkerAreaMode = 'select' | 'create' | 'delete';
1906
1921
  * const state = markerArea.getState();
1907
1922
  * console.log(state);
1908
1923
  * });
1924
+ * ```
1909
1925
  */
1910
1926
  declare class MarkerArea extends HTMLElement {
1911
1927
  private _contentContainer?;
@@ -1944,6 +1960,10 @@ declare class MarkerArea extends HTMLElement {
1944
1960
  */
1945
1961
  get currentMarkerEditor(): MarkerBaseEditor | undefined;
1946
1962
  private _selectedMarkerEditors;
1963
+ /**
1964
+ * Returns the currently selected marker editors.
1965
+ */
1966
+ get selectedMarkerEditors(): MarkerBaseEditor[];
1947
1967
  private _newMarkerOutline;
1948
1968
  private _targetImageLoaded;
1949
1969
  private _targetImage;
@@ -2740,6 +2760,34 @@ interface MarkerViewEventMap {
2740
2760
  * Viewer state restored.
2741
2761
  */
2742
2762
  viewrestorestate: CustomEvent<MarkerViewEventData>;
2763
+ /**
2764
+ * Marker clicked.
2765
+ */
2766
+ markerclick: CustomEvent<MarkerEventData>;
2767
+ /**
2768
+ * Marker mouse over.
2769
+ */
2770
+ markerover: CustomEvent<MarkerEventData>;
2771
+ /**
2772
+ * Marker pointer down.
2773
+ */
2774
+ markerpointerdown: CustomEvent<MarkerEventData>;
2775
+ /**
2776
+ * Marker pointer move.
2777
+ */
2778
+ markerpointermove: CustomEvent<MarkerEventData>;
2779
+ /**
2780
+ * Marker pointer up.
2781
+ */
2782
+ markerpointerup: CustomEvent<MarkerEventData>;
2783
+ /**
2784
+ * Marker pointer enter.
2785
+ */
2786
+ markerpointerenter: CustomEvent<MarkerEventData>;
2787
+ /**
2788
+ * Marker pointer leave.
2789
+ */
2790
+ markerpointerleave: CustomEvent<MarkerEventData>;
2743
2791
  }
2744
2792
  /**
2745
2793
  * Event data for {@link MarkerView}.
@@ -2750,6 +2798,15 @@ interface MarkerViewEventData {
2750
2798
  */
2751
2799
  markerView: MarkerView;
2752
2800
  }
2801
+ /**
2802
+ * Marker custom event data.
2803
+ */
2804
+ interface MarkerEventData extends MarkerViewEventData {
2805
+ /**
2806
+ * Marker instance.
2807
+ */
2808
+ marker: MarkerBase;
2809
+ }
2753
2810
  /**
2754
2811
  * MarkerView is the main annotation viewer web component.
2755
2812
  *
@@ -2834,6 +2891,7 @@ declare class MarkerView extends HTMLElement {
2834
2891
  private setEditingTargetSize;
2835
2892
  private addTargetImage;
2836
2893
  private addNewMarker;
2894
+ private attachMarkerEvents;
2837
2895
  private attachEvents;
2838
2896
  private attachWindowEvents;
2839
2897
  private detachEvents;
@@ -2998,4 +3056,4 @@ declare class Renderer {
2998
3056
  rasterize(state: AnnotationState, targetCanvas?: HTMLCanvasElement): Promise<string>;
2999
3057
  }
3000
3058
 
3001
- export { Activator, type AnnotationState, ArrowMarker, ArrowMarkerEditor, type ArrowMarkerState, type ArrowType, type BlurHandler, CalloutMarker, CalloutMarkerEditor, type CalloutMarkerState, CaptionFrameMarker, CaptionFrameMarkerEditor, type CaptionFrameMarkerState, CheckImageMarker, CoverMarker, CustomImageMarker, EllipseFrameMarker, EllipseMarker, type FontSize, FrameMarker, FreehandMarker, FreehandMarkerEditor, type FreehandMarkerState, Grip, type GripLocation, HighlightMarker, type IPoint, type ISize, type ITransformMatrix, ImageMarkerBase, type ImageMarkerBaseState, ImageMarkerEditor, type ImageType, LineMarker, LinearMarkerBase, type LinearMarkerBaseState, LinearMarkerEditor, MarkerArea, type MarkerAreaEventData, type MarkerAreaEventMap, type MarkerAreaMode, MarkerBase, MarkerBaseEditor, type MarkerBaseState, type MarkerCreationStyle, type MarkerEditorEventData, type MarkerEditorProperties, type MarkerEditorState, type MarkerStage, 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, TextBlock, TextBlockEditor, type TextChangedHandler, TextMarker, TextMarkerEditor, type TextMarkerState, XImageMarker };
3059
+ export { Activator, type AnnotationState, ArrowMarker, ArrowMarkerEditor, type ArrowMarkerState, type ArrowType, type BlurHandler, CalloutMarker, CalloutMarkerEditor, type CalloutMarkerState, CaptionFrameMarker, CaptionFrameMarkerEditor, type CaptionFrameMarkerState, CheckImageMarker, CoverMarker, CustomImageMarker, EllipseFrameMarker, EllipseMarker, type FontSize, FrameMarker, FreehandMarker, FreehandMarkerEditor, type FreehandMarkerState, Grip, type GripLocation, HighlightMarker, type IPoint, type ISize, type ITransformMatrix, ImageMarkerBase, type ImageMarkerBaseState, ImageMarkerEditor, type ImageType, LineMarker, LinearMarkerBase, type LinearMarkerBaseState, LinearMarkerEditor, MarkerArea, type MarkerAreaEventData, type MarkerAreaEventMap, type MarkerAreaMode, MarkerBase, MarkerBaseEditor, type MarkerBaseState, type MarkerCreationStyle, type MarkerEditorEventData, type MarkerEditorProperties, type MarkerEditorState, type MarkerEventData, type MarkerStage, 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, TextBlock, TextBlockEditor, type TextChangedHandler, TextMarker, TextMarkerEditor, type TextMarkerState, XImageMarker };