@annotorious/annotorious 3.0.0-rc.30 → 3.0.0-rc.32

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.
Files changed (135) hide show
  1. package/dist/Annotorious.d.ts +1 -2
  2. package/dist/AnnotoriousOpts.d.ts +2 -4
  3. package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -1
  4. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +1 -2
  5. package/dist/annotation/Transform.d.ts +0 -1
  6. package/dist/annotation/editors/Editor.svelte.d.ts +1 -1
  7. package/dist/annotation/editors/EditorMount.svelte.d.ts +1 -1
  8. package/dist/annotation/editors/Handle.svelte.d.ts +1 -1
  9. package/dist/annotation/editors/editorsRegistry.d.ts +0 -2
  10. package/dist/annotation/editors/index.d.ts +0 -1
  11. package/dist/annotation/editors/polygon/PolygonEditor.svelte.d.ts +1 -1
  12. package/dist/annotation/editors/polygon/index.d.ts +0 -1
  13. package/dist/annotation/editors/rectangle/RectangleEditor.svelte.d.ts +1 -1
  14. package/dist/annotation/editors/rectangle/index.d.ts +0 -1
  15. package/dist/annotation/index.d.ts +0 -1
  16. package/dist/annotation/shapes/Ellipse.svelte.d.ts +1 -1
  17. package/dist/annotation/shapes/Polygon.svelte.d.ts +1 -1
  18. package/dist/annotation/shapes/Rectangle.svelte.d.ts +1 -1
  19. package/dist/annotation/shapes/index.d.ts +0 -1
  20. package/dist/annotation/tools/DrawingToolConfig.d.ts +0 -2
  21. package/dist/annotation/tools/ToolMount.svelte.d.ts +1 -1
  22. package/dist/annotation/tools/drawingToolsRegistry.d.ts +0 -2
  23. package/dist/annotation/tools/index.d.ts +0 -1
  24. package/dist/annotation/tools/polygon/RubberbandPolygon.svelte.d.ts +1 -1
  25. package/dist/annotation/tools/polygon/index.d.ts +0 -1
  26. package/dist/annotation/tools/rectangle/RubberbandRectangle.svelte.d.ts +1 -1
  27. package/dist/annotation/tools/rectangle/index.d.ts +0 -1
  28. package/dist/annotation/utils/index.d.ts +0 -1
  29. package/dist/annotation/utils/math.d.ts +0 -1
  30. package/dist/annotation/utils/responsive.d.ts +0 -1
  31. package/dist/annotation/utils/styling.d.ts +0 -2
  32. package/dist/annotation/utils/touch.d.ts +0 -1
  33. package/dist/annotorious.css +1 -1
  34. package/dist/annotorious.es.js +1717 -1622
  35. package/dist/annotorious.es.js.map +1 -1
  36. package/dist/annotorious.js +1 -1
  37. package/dist/annotorious.js.map +1 -1
  38. package/dist/index.d.ts +0 -1
  39. package/dist/keyboardCommands.d.ts +0 -2
  40. package/dist/model/core/ImageAnnotation.d.ts +0 -2
  41. package/dist/model/core/Shape.d.ts +0 -2
  42. package/dist/model/core/ellipse/Ellipse.d.ts +0 -2
  43. package/dist/model/core/ellipse/ellipseUtils.d.ts +0 -1
  44. package/dist/model/core/ellipse/index.d.ts +0 -1
  45. package/dist/model/core/index.d.ts +0 -1
  46. package/dist/model/core/polygon/Polygon.d.ts +0 -2
  47. package/dist/model/core/polygon/index.d.ts +0 -1
  48. package/dist/model/core/polygon/polygonUtils.d.ts +0 -1
  49. package/dist/model/core/rectangle/Rectangle.d.ts +0 -2
  50. package/dist/model/core/rectangle/index.d.ts +0 -1
  51. package/dist/model/core/rectangle/rectangleUtils.d.ts +0 -2
  52. package/dist/model/core/shapeUtils.d.ts +0 -2
  53. package/dist/model/index.d.ts +0 -1
  54. package/dist/model/w3c/W3CImageAnnotation.d.ts +0 -2
  55. package/dist/model/w3c/W3CImageFormatAdapter.d.ts +7 -5
  56. package/dist/model/w3c/fragment/FragmentSelector.d.ts +0 -2
  57. package/dist/model/w3c/fragment/index.d.ts +0 -1
  58. package/dist/model/w3c/index.d.ts +0 -1
  59. package/dist/model/w3c/svg/SVG.d.ts +0 -1
  60. package/dist/model/w3c/svg/SVGSelector.d.ts +0 -2
  61. package/dist/model/w3c/svg/index.d.ts +0 -1
  62. package/dist/state/ImageAnnotationStore.d.ts +0 -2
  63. package/dist/state/ImageAnnotatorState.d.ts +0 -2
  64. package/dist/state/index.d.ts +0 -1
  65. package/dist/state/spatialTree.d.ts +0 -2
  66. package/dist/themes/index.d.ts +0 -1
  67. package/dist/themes/smart/index.d.ts +0 -1
  68. package/dist/themes/smart/setTheme.d.ts +0 -2
  69. package/package.json +12 -12
  70. package/src/Annotorious.css +4 -0
  71. package/src/Annotorious.ts +10 -6
  72. package/src/AnnotoriousOpts.ts +9 -13
  73. package/src/annotation/SVGAnnotationLayer.svelte +47 -20
  74. package/src/annotation/SVGAnnotationLayerPointerEvent.ts +1 -1
  75. package/src/annotation/editors/editorsRegistry.ts +2 -2
  76. package/src/annotation/shapes/Ellipse.svelte +1 -1
  77. package/src/annotation/shapes/Polygon.svelte +1 -1
  78. package/src/annotation/shapes/Rectangle.svelte +1 -1
  79. package/src/annotation/utils/styling.ts +14 -8
  80. package/src/annotation/utils/touch.ts +4 -4
  81. package/src/model/w3c/W3CImageFormatAdapter.ts +29 -13
  82. package/src/state/ImageAnnotatorState.ts +1 -2
  83. package/src/state/spatialTree.ts +10 -4
  84. package/src/themes/dark/index.css +1 -1
  85. package/dist/Annotorious.d.ts.map +0 -1
  86. package/dist/AnnotoriousOpts.d.ts.map +0 -1
  87. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +0 -1
  88. package/dist/annotation/Transform.d.ts.map +0 -1
  89. package/dist/annotation/editors/editorsRegistry.d.ts.map +0 -1
  90. package/dist/annotation/editors/index.d.ts.map +0 -1
  91. package/dist/annotation/editors/polygon/index.d.ts.map +0 -1
  92. package/dist/annotation/editors/rectangle/index.d.ts.map +0 -1
  93. package/dist/annotation/index.d.ts.map +0 -1
  94. package/dist/annotation/shapes/index.d.ts.map +0 -1
  95. package/dist/annotation/tools/DrawingToolConfig.d.ts.map +0 -1
  96. package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +0 -1
  97. package/dist/annotation/tools/index.d.ts.map +0 -1
  98. package/dist/annotation/tools/polygon/index.d.ts.map +0 -1
  99. package/dist/annotation/tools/rectangle/index.d.ts.map +0 -1
  100. package/dist/annotation/utils/index.d.ts.map +0 -1
  101. package/dist/annotation/utils/math.d.ts.map +0 -1
  102. package/dist/annotation/utils/responsive.d.ts.map +0 -1
  103. package/dist/annotation/utils/styling.d.ts.map +0 -1
  104. package/dist/annotation/utils/touch.d.ts.map +0 -1
  105. package/dist/index.d.ts.map +0 -1
  106. package/dist/keyboardCommands.d.ts.map +0 -1
  107. package/dist/model/core/ImageAnnotation.d.ts.map +0 -1
  108. package/dist/model/core/Shape.d.ts.map +0 -1
  109. package/dist/model/core/ellipse/Ellipse.d.ts.map +0 -1
  110. package/dist/model/core/ellipse/ellipseUtils.d.ts.map +0 -1
  111. package/dist/model/core/ellipse/index.d.ts.map +0 -1
  112. package/dist/model/core/index.d.ts.map +0 -1
  113. package/dist/model/core/polygon/Polygon.d.ts.map +0 -1
  114. package/dist/model/core/polygon/index.d.ts.map +0 -1
  115. package/dist/model/core/polygon/polygonUtils.d.ts.map +0 -1
  116. package/dist/model/core/rectangle/Rectangle.d.ts.map +0 -1
  117. package/dist/model/core/rectangle/index.d.ts.map +0 -1
  118. package/dist/model/core/rectangle/rectangleUtils.d.ts.map +0 -1
  119. package/dist/model/core/shapeUtils.d.ts.map +0 -1
  120. package/dist/model/index.d.ts.map +0 -1
  121. package/dist/model/w3c/W3CImageAnnotation.d.ts.map +0 -1
  122. package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +0 -1
  123. package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +0 -1
  124. package/dist/model/w3c/fragment/index.d.ts.map +0 -1
  125. package/dist/model/w3c/index.d.ts.map +0 -1
  126. package/dist/model/w3c/svg/SVG.d.ts.map +0 -1
  127. package/dist/model/w3c/svg/SVGSelector.d.ts.map +0 -1
  128. package/dist/model/w3c/svg/index.d.ts.map +0 -1
  129. package/dist/state/ImageAnnotationStore.d.ts.map +0 -1
  130. package/dist/state/ImageAnnotatorState.d.ts.map +0 -1
  131. package/dist/state/index.d.ts.map +0 -1
  132. package/dist/state/spatialTree.d.ts.map +0 -1
  133. package/dist/themes/index.d.ts.map +0 -1
  134. package/dist/themes/smart/index.d.ts.map +0 -1
  135. package/dist/themes/smart/setTheme.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -7,4 +7,3 @@ export * from './Annotorious';
7
7
  export * from './AnnotoriousOpts';
8
8
  export * from './keyboardCommands';
9
9
  export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,4 @@
1
1
  import { Annotation, UndoStack } from '@annotorious/core';
2
-
3
2
  export declare const initKeyboardCommands: <T extends Annotation>(undoStack: UndoStack<T>, container?: Element) => {
4
3
  destroy: () => void;
5
4
  };
6
- //# sourceMappingURL=keyboardCommands.d.ts.map
@@ -1,10 +1,8 @@
1
1
  import { Annotation, AnnotationTarget } from '@annotorious/core';
2
2
  import { Shape } from './Shape';
3
-
4
3
  export interface ImageAnnotation extends Annotation {
5
4
  target: ImageAnnotationTarget;
6
5
  }
7
6
  export interface ImageAnnotationTarget extends AnnotationTarget {
8
7
  selector: Shape;
9
8
  }
10
- //# sourceMappingURL=ImageAnnotation.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { AbstractSelector } from '@annotorious/core';
2
-
3
2
  export interface Shape extends AbstractSelector {
4
3
  type: ShapeType;
5
4
  geometry: Geometry;
@@ -18,4 +17,3 @@ export interface Bounds {
18
17
  maxX: number;
19
18
  maxY: number;
20
19
  }
21
- //# sourceMappingURL=Shape.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Bounds, Geometry, Shape } from '../Shape';
2
-
3
2
  export interface Ellipse extends Shape {
4
3
  geometry: EllipseGeometry;
5
4
  }
@@ -10,4 +9,3 @@ export interface EllipseGeometry extends Geometry {
10
9
  ry: number;
11
10
  bounds: Bounds;
12
11
  }
13
- //# sourceMappingURL=Ellipse.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=ellipseUtils.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Ellipse';
2
2
  export * from './ellipseUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@ export * from './rectangle';
4
4
  export * from './ImageAnnotation';
5
5
  export * from './Shape';
6
6
  export * from './shapeUtils';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Bounds, Geometry, Shape } from '../Shape';
2
-
3
2
  export interface Polygon extends Shape {
4
3
  geometry: PolygonGeometry;
5
4
  }
@@ -7,4 +6,3 @@ export interface PolygonGeometry extends Geometry {
7
6
  points: Array<Array<number>>;
8
7
  bounds: Bounds;
9
8
  }
10
- //# sourceMappingURL=Polygon.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Polygon';
2
2
  export * from './polygonUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=polygonUtils.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Bounds, Geometry, Shape } from '../Shape';
2
-
3
2
  export interface Rectangle extends Shape {
4
3
  geometry: RectangleGeometry;
5
4
  }
@@ -10,4 +9,3 @@ export interface RectangleGeometry extends Geometry {
10
9
  h: number;
11
10
  bounds: Bounds;
12
11
  }
13
- //# sourceMappingURL=Rectangle.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Rectangle';
2
2
  export * from './rectangleUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,3 @@
1
1
  import { Rectangle } from './Rectangle';
2
2
  import { ShapeUtil } from '../shapeUtils';
3
-
4
3
  export declare const RectangleUtil: ShapeUtil<Rectangle>;
5
- //# sourceMappingURL=rectangleUtils.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Bounds, Shape, ShapeType } from './Shape';
2
-
3
2
  export interface ShapeUtil<T extends Shape> {
4
3
  area: (shape: T) => number;
5
4
  intersects: (shape: T, x: number, y: number) => boolean;
@@ -30,4 +29,3 @@ export declare const intersects: (shape: Shape, x: number, y: number) => boolean
30
29
  * @returns the Bounds
31
30
  */
32
31
  export declare const boundsFromPoints: (points: Array<[number, number]>) => Bounds;
33
- //# sourceMappingURL=shapeUtils.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './core';
2
2
  export * from './w3c';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
2
2
  import { FragmentSelector } from './fragment';
3
3
  import { SVGSelector } from './svg';
4
-
5
4
  export interface W3CImageAnnotation extends W3CAnnotation {
6
5
  target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[];
7
6
  }
@@ -9,4 +8,3 @@ export interface W3CImageAnnotationTarget extends W3CAnnotationTarget {
9
8
  selector: W3CImageSelector | W3CImageSelector[];
10
9
  }
11
10
  export type W3CImageSelector = FragmentSelector | SVGSelector;
12
- //# sourceMappingURL=W3CImageAnnotation.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
2
2
  import { ImageAnnotation } from '../core';
3
3
  import { W3CImageAnnotation } from './W3CImageAnnotation';
4
-
5
4
  export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CImageAnnotation>;
6
- export declare const W3CImageFormat: (source: string, invertY?: boolean) => W3CImageFormatAdapter;
7
- export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, invertY?: boolean) => ParseResult<ImageAnnotation>;
8
- export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string) => W3CImageAnnotation;
9
- //# sourceMappingURL=W3CImageFormatAdapter.d.ts.map
5
+ export interface W3CImageFormatAdapterOpts {
6
+ strict: boolean;
7
+ invertY: boolean;
8
+ }
9
+ export declare const W3CImageFormat: (source: string, opts?: W3CImageFormatAdapterOpts) => W3CImageFormatAdapter;
10
+ export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, opts?: W3CImageFormatAdapterOpts) => ParseResult<ImageAnnotation>;
11
+ export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string, opts?: W3CImageFormatAdapterOpts) => W3CImageAnnotation;
@@ -1,5 +1,4 @@
1
1
  import { Rectangle, RectangleGeometry } from '../../core';
2
-
3
2
  export interface FragmentSelector {
4
3
  type: 'FragmentSelector';
5
4
  conformsTo: 'http://www.w3.org/TR/media-frags/';
@@ -7,4 +6,3 @@ export interface FragmentSelector {
7
6
  }
8
7
  export declare const parseFragmentSelector: (fragmentOrSelector: FragmentSelector | string, invertY?: boolean) => Rectangle;
9
8
  export declare const serializeFragmentSelector: (geometry: RectangleGeometry) => FragmentSelector;
10
- //# sourceMappingURL=FragmentSelector.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './FragmentSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,3 @@ export * from './fragment';
2
2
  export * from './svg';
3
3
  export * from './W3CImageAnnotation';
4
4
  export * from './W3CImageFormatAdapter';
5
- //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,3 @@ export declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2
2
  export declare const sanitize: (doc: Element | Document) => Element | Document;
3
3
  /** Helper that forces an un-namespaced node to SVG **/
4
4
  export declare const insertSVGNamespace: (originalDoc: Document) => Element;
5
- //# sourceMappingURL=SVG.d.ts.map
@@ -1,9 +1,7 @@
1
1
  import { Shape } from '../../core';
2
-
3
2
  export interface SVGSelector {
4
3
  type: 'SvgSelector';
5
4
  value: string;
6
5
  }
7
6
  export declare const parseSVGSelector: <T extends Shape>(valueOrSelector: SVGSelector | string) => T;
8
7
  export declare const serializeSVGSelector: (shape: Shape) => SVGSelector;
9
- //# sourceMappingURL=SVGSelector.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './SVGSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,5 @@
1
1
  import { Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
2
2
  import { ImageAnnotation } from '../model';
3
-
4
3
  export type ImageAnnotationStore = Store<ImageAnnotation> & {
5
4
  getAt(x: number, y: number): ImageAnnotation | undefined;
6
5
  getIntersecting(x: number, y: number, width: number, height: number): ImageAnnotation[];
@@ -9,4 +8,3 @@ export type SvelteImageAnnotationStore = SvelteStore<ImageAnnotation> & ImageAnn
9
8
  export type SvelteImageAnnotatorState = SvelteAnnotatorState<ImageAnnotation> & {
10
9
  store: SvelteImageAnnotationStore;
11
10
  };
12
- //# sourceMappingURL=ImageAnnotationStore.d.ts.map
@@ -2,7 +2,6 @@ import { ImageAnnotation } from '../model';
2
2
  import { AnnotoriousOpts } from '../AnnotoriousOpts';
3
3
  import { AnnotatorState, HoverState, SelectionState } from '@annotorious/core';
4
4
  import { ImageAnnotationStore, SvelteImageAnnotatorState } from './ImageAnnotationStore';
5
-
6
5
  export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotationStore> = AnnotatorState<ImageAnnotation> & {
7
6
  store: T;
8
7
  selection: SelectionState<ImageAnnotation>;
@@ -10,4 +9,3 @@ export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotation
10
9
  };
11
10
  export declare const createImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => ImageAnnotatorState<ImageAnnotationStore>;
12
11
  export declare const createSvelteImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => SvelteImageAnnotatorState;
13
- //# sourceMappingURL=ImageAnnotatorState.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './ImageAnnotationStore';
2
2
  export * from './ImageAnnotatorState';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { ImageAnnotationTarget } from '../model';
2
-
3
2
  interface IndexedTarget {
4
3
  minX: number;
5
4
  minY: number;
@@ -19,4 +18,3 @@ export declare const createSpatialTree: () => {
19
18
  update: (previous: ImageAnnotationTarget, updated: ImageAnnotationTarget) => void;
20
19
  };
21
20
  export {};
22
- //# sourceMappingURL=spatialTree.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './smart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './setTheme';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,4 @@
1
1
  import { Theme } from '../../AnnotoriousOpts';
2
-
3
2
  export declare const sampleBrightness: (imageOrCanvas: HTMLElement) => number;
4
3
  export declare const detectTheme: (imageOrCanvas: HTMLElement) => "dark" | "light";
5
4
  export declare const setTheme: (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) => void;
6
- //# sourceMappingURL=setTheme.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/annotorious",
3
- "version": "3.0.0-rc.30",
3
+ "version": "3.0.0-rc.32",
4
4
  "description": "Add image annotation functionality to any web page with a few lines of JavaScript",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -36,20 +36,20 @@
36
36
  "./src": "./src/index.ts"
37
37
  },
38
38
  "devDependencies": {
39
- "@sveltejs/vite-plugin-svelte": "^3.1.1",
39
+ "@sveltejs/vite-plugin-svelte": "^3.1.2",
40
40
  "@tsconfig/svelte": "^5.0.4",
41
- "@types/rbush": "^3.0.3",
42
- "jsdom": "^24.1.0",
43
- "svelte": "^4.2.18",
44
- "svelte-preprocess": "^6.0.1",
45
- "typescript": "^5.5.2",
46
- "vite": "^5.3.1",
47
- "vite-plugin-dts": "^3.9.1",
48
- "vitest": "^1.6.0"
41
+ "@types/rbush": "^3.0.4",
42
+ "jsdom": "^24.1.1",
43
+ "svelte": "^4.2.19",
44
+ "svelte-preprocess": "^6.0.2",
45
+ "typescript": "5.5.4",
46
+ "vite": "^5.4.2",
47
+ "vite-plugin-dts": "^4.0.3",
48
+ "vitest": "^2.0.5"
49
49
  },
50
50
  "dependencies": {
51
- "@annotorious/core": "3.0.0-rc.30",
52
- "rbush": "^4.0.0",
51
+ "@annotorious/core": "3.0.0-rc.32",
52
+ "rbush": "^4.0.1",
53
53
  "uuid": "^10.0.0"
54
54
  }
55
55
  }
@@ -23,6 +23,10 @@
23
23
  display: none;
24
24
  }
25
25
 
26
+ .a9s-annotationlayer .a9s-annotation {
27
+ cursor: pointer;
28
+ }
29
+
26
30
  .a9s-annotationlayer ellipse,
27
31
  .a9s-annotationlayer polygon,
28
32
  .a9s-annotationlayer rect {
@@ -1,5 +1,5 @@
1
1
  import type { SvelteComponent } from 'svelte';
2
- import { PointerSelectAction } from '@annotorious/core';
2
+ import { UserSelectAction } from '@annotorious/core';
3
3
  import type { Annotator, DrawingStyleExpression, Filter, User } from '@annotorious/core';
4
4
  import { createAnonymousGuest, createBaseAnnotator, createLifecycleObserver, createUndoStack } from '@annotorious/core';
5
5
  import { registerEditor } from './annotation/editors';
@@ -19,6 +19,8 @@ import './themes/light/index.css';
19
19
 
20
20
  export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Annotator<ImageAnnotation, E> {
21
21
 
22
+ element: HTMLDivElement;
23
+
22
24
  listDrawingTools(): string[];
23
25
 
24
26
  registerDrawingTool(name: string, tool: typeof SvelteComponent, opts?: DrawingToolOpts): void;
@@ -41,13 +43,14 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
41
43
  if (!image)
42
44
  throw 'Missing argument: image';
43
45
 
44
- const img = (typeof image === 'string' ?
45
- document.getElementById(image) : image) as HTMLImageElement | HTMLCanvasElement;
46
+ const img = (
47
+ typeof image === 'string' ? document.getElementById(image) : image
48
+ ) as HTMLImageElement | HTMLCanvasElement;
46
49
 
47
50
  const opts = fillDefaults<ImageAnnotation, E>(options, {
48
51
  drawingEnabled: true,
49
52
  drawingMode: 'drag',
50
- pointerSelectAction: PointerSelectAction.EDIT,
53
+ userSelectAction: UserSelectAction.EDIT,
51
54
  theme: 'light'
52
55
  });
53
56
 
@@ -62,7 +65,7 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
62
65
  );
63
66
 
64
67
  // We'll wrap the image in a container DIV.
65
- const container = document.createElement('DIV');
68
+ const container = document.createElement('DIV') as HTMLDivElement;
66
69
  container.style.position = 'relative';
67
70
  container.style.display = 'inline-block';
68
71
 
@@ -93,7 +96,7 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
93
96
  annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent>) => {
94
97
  const { originalEvent, annotation } = evt.detail;
95
98
  if (annotation)
96
- selection.clickSelect(annotation.id, originalEvent);
99
+ selection.userSelect(annotation.id, originalEvent);
97
100
  else if (!selection.isEmpty())
98
101
  selection.clear();
99
102
  });
@@ -173,6 +176,7 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
173
176
  setTheme,
174
177
  setUser,
175
178
  setVisible,
179
+ element: container,
176
180
  state
177
181
  }
178
182
 
@@ -1,4 +1,4 @@
1
- import type { Annotation, DrawingStyle, DrawingStyleExpression, FormatAdapter, PointerSelectAction } from '@annotorious/core';
1
+ import type { Annotation, DrawingStyleExpression, FormatAdapter, UserSelectActionExpression } from '@annotorious/core';
2
2
  import type { ImageAnnotation } from './model';
3
3
 
4
4
  export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> {
@@ -13,7 +13,7 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E exten
13
13
  // 'drag': starts drawing on drag, single click always selects
14
14
  drawingMode?: DrawingMode;
15
15
 
16
- pointerSelectAction?: PointerSelectAction | ((a: I) => PointerSelectAction);
16
+ userSelectAction?: UserSelectActionExpression<I>;
17
17
 
18
18
  style?: DrawingStyleExpression<ImageAnnotation>;
19
19
 
@@ -28,17 +28,13 @@ export type Theme = 'dark' | 'light' | 'auto';
28
28
  export const fillDefaults = <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
29
29
  opts: AnnotoriousOpts<I, E>,
30
30
  defaults: AnnotoriousOpts<I, E>
31
- ): AnnotoriousOpts<I, E> => {
32
-
33
- return {
34
- ...opts,
35
- drawingEnabled: opts.drawingEnabled === undefined ? defaults.drawingEnabled : opts.drawingEnabled,
36
- drawingMode: opts.drawingMode || defaults.drawingMode,
37
- pointerSelectAction: opts.pointerSelectAction || defaults.pointerSelectAction,
38
- theme: opts.theme || defaults.theme
39
- };
40
-
41
- };
31
+ ): AnnotoriousOpts<I, E> => ({
32
+ ...opts,
33
+ drawingEnabled: opts.drawingEnabled === undefined ? defaults.drawingEnabled : opts.drawingEnabled,
34
+ drawingMode: opts.drawingMode || defaults.drawingMode,
35
+ userSelectAction: opts.userSelectAction || defaults.userSelectAction,
36
+ theme: opts.theme || defaults.theme
37
+ });
42
38
 
43
39
 
44
40
 
@@ -9,7 +9,7 @@
9
9
  import { getTool, listDrawingTools, ToolMount } from './tools';
10
10
  import { enableResponsive } from './utils';
11
11
  import { createSVGTransform } from './Transform';
12
- import { addEventListeners } from './SVGAnnotationLayerPointerEvent';
12
+ import { addEventListeners, getSVGPoint } from './SVGAnnotationLayerPointerEvent';
13
13
  import type { SvelteImageAnnotatorState } from 'src/state';
14
14
  import type { DrawingMode } from 'src/AnnotoriousOpts';
15
15
 
@@ -40,7 +40,7 @@
40
40
  $: transform = createSVGTransform(svgEl);
41
41
 
42
42
  /** Selection tracking */
43
- const { selection, store } = state;
43
+ const { hover, selection, store } = state;
44
44
 
45
45
  $: ({ onPointerDown, onPointerUp } = addEventListeners(svgEl, store));
46
46
 
@@ -115,6 +115,19 @@
115
115
  });
116
116
  }
117
117
 
118
+ const onPointerMove = (evt: PointerEvent) => {
119
+ const { x, y } = getSVGPoint(evt, svgEl);
120
+
121
+ const hit = store.getAt(x, y);
122
+ if (hit) {
123
+ if ($hover !== hit.id) {
124
+ hover.set(hit.id);
125
+ }
126
+ } else {
127
+ hover.set(undefined);
128
+ }
129
+ }
130
+
118
131
  // To get around lack of TypeScript support in Svelte markup
119
132
  const getEditor = (shape: Shape): typeof SvelteComponent => _getEditor(shape)!;
120
133
  </script>
@@ -124,20 +137,31 @@
124
137
  class="a9s-annotationlayer"
125
138
  class:drawing={tool}
126
139
  class:hidden={!visible}
140
+ class:hover={$hover}
127
141
  on:pointerup={onPointerUp}
128
- on:pointerdown={onPointerDown}>
142
+ on:pointerdown={onPointerDown}
143
+ on:pointermove={onPointerMove}>
129
144
 
130
145
  <g>
131
146
  {#each $store as annotation}
132
147
  {#if !isEditable(annotation)}
133
148
  {@const selector = annotation.target.selector}
134
149
  {#key annotation.id}
135
- {#if (selector.type === ShapeType.ELLIPSE)}
136
- <Ellipse annotation={annotation} geom={selector.geometry} style={style} />
137
- {:else if (selector.type === ShapeType.RECTANGLE)}
138
- <Rectangle annotation={annotation} geom={selector.geometry} style={style} />
139
- {:else if (selector.type === ShapeType.POLYGON)}
140
- <Polygon annotation={annotation} geom={selector.geometry} style={style} />
150
+ {#if (selector?.type === ShapeType.ELLIPSE)}
151
+ <Ellipse
152
+ annotation={annotation}
153
+ geom={selector?.geometry}
154
+ style={style} />
155
+ {:else if (selector?.type === ShapeType.RECTANGLE)}
156
+ <Rectangle
157
+ annotation={annotation}
158
+ geom={selector.geometry}
159
+ style={style} />
160
+ {:else if (selector?.type === ShapeType.POLYGON)}
161
+ <Polygon
162
+ annotation={annotation}
163
+ geom={selector.geometry}
164
+ style={style} />
141
165
  {/if}
142
166
  {/key}
143
167
  {/if}
@@ -150,16 +174,19 @@
150
174
  {#if drawingEl}
151
175
  {#if editableAnnotations}
152
176
  {#each editableAnnotations as editable}
153
- {#key editable.id}
154
- <EditorMount
155
- target={drawingEl}
156
- editor={getEditor(editable.target.selector)}
157
- annotation={editable}
158
- style={style}
159
- transform={transform}
160
- viewportScale={$scale}
161
- on:change={onChangeSelected(editable)} />
162
- {/key}
177
+ {@const editor = getEditor(editable.target.selector)}
178
+ {#if editor}
179
+ {#key editable.id}
180
+ <EditorMount
181
+ target={drawingEl}
182
+ editor={getEditor(editable.target.selector)}
183
+ annotation={editable}
184
+ style={style}
185
+ transform={transform}
186
+ viewportScale={$scale}
187
+ on:change={onChangeSelected(editable)} />
188
+ {/key}
189
+ {/if}
163
190
  {/each}
164
191
  {:else if (tool && drawingEnabled)}
165
192
  {#key toolName}
@@ -174,4 +201,4 @@
174
201
  {/if}
175
202
  {/if}
176
203
  </g>
177
- </svg>
204
+ </svg>
@@ -39,7 +39,7 @@ export const addEventListeners = (svg: SVGSVGElement, store: SvelteImageAnnotati
39
39
  return { onPointerDown, onPointerUp };
40
40
  }
41
41
 
42
- const getSVGPoint = (evt: PointerEvent, svg: SVGSVGElement) => {
42
+ export const getSVGPoint = (evt: PointerEvent, svg: SVGSVGElement) => {
43
43
  const pt = svg.createSVGPoint();
44
44
  const bbox = svg.getBoundingClientRect();
45
45
 
@@ -4,8 +4,8 @@ import { PolygonEditor } from './polygon';
4
4
  import { RectangleEditor } from './rectangle';
5
5
 
6
6
  const REGISTERED = new Map<ShapeType, typeof SvelteComponent>([
7
- [ShapeType.RECTANGLE, RectangleEditor],
8
- [ShapeType.POLYGON, PolygonEditor]
7
+ [ShapeType.RECTANGLE, RectangleEditor as typeof SvelteComponent],
8
+ [ShapeType.POLYGON, PolygonEditor as typeof SvelteComponent]
9
9
  ]);
10
10
 
11
11
  export const getEditor = (shape: Shape) => REGISTERED.get(shape.type);
@@ -13,7 +13,7 @@
13
13
  const { cx, cy, rx, ry } = geom as EllipseGeometry;
14
14
  </script>
15
15
 
16
- <g data-id={annotation.id}>
16
+ <g class="a9s-annotation" data-id={annotation.id}>
17
17
  <ellipse
18
18
  class="a9s-outer"
19
19
  style={computedStyle ? 'display:none;' : undefined}
@@ -13,7 +13,7 @@
13
13
  const { points } = geom as PolygonGeometry;
14
14
  </script>
15
15
 
16
- <g data-id={annotation.id}>
16
+ <g class="a9s-annotation" data-id={annotation.id}>
17
17
  <polygon
18
18
  class="a9s-outer"
19
19
  style={computedStyle ? 'display:none;' : undefined}
@@ -13,7 +13,7 @@
13
13
  $: ({ x, y, w, h } = geom as RectangleGeometry);
14
14
  </script>
15
15
 
16
- <g data-id={annotation.id}>
16
+ <g class="a9s-annotation" data-id={annotation.id}>
17
17
  <rect
18
18
  class="a9s-outer"
19
19
  style={computedStyle ? 'display:none;' : undefined}
@@ -2,21 +2,27 @@ import type { DrawingStyleExpression } from '@annotorious/core';
2
2
  import type { ImageAnnotation } from '../../model';
3
3
 
4
4
  export const computeStyle = (
5
- annotation: ImageAnnotation,
5
+ annotation: ImageAnnotation,
6
6
  style?: DrawingStyleExpression<ImageAnnotation>
7
7
  ) => {
8
8
  const computed = typeof style === 'function' ? style(annotation) : style;
9
9
 
10
10
  if (computed) {
11
- const { fill, fillOpacity } = computed;
11
+ const { fill, fillOpacity, stroke, strokeWidth, strokeOpacity } = computed;
12
12
 
13
13
  let css = '';
14
-
15
- if (fill)
16
- css += `fill:${fill};stroke:${fill};`;
17
-
18
- css += `fill-opacity:${fillOpacity || '0.25'};`;
14
+
15
+ if (fill) {
16
+ css += `fill:${fill};`;
17
+ css += `fill-opacity:${fillOpacity || '0.25'};`;
18
+ }
19
+
20
+ if (stroke) {
21
+ css += `stroke:${stroke};`;
22
+ css += `stroke-width:${strokeWidth || '1'};`;
23
+ css += `stroke-opacity:${strokeOpacity || '1'};`;
24
+ }
19
25
 
20
26
  return css;
21
27
  }
22
- }
28
+ };
@@ -1,4 +1,4 @@
1
- export const isTouch = 'ontouchstart' in window
2
- || navigator.maxTouchPoints > 0
3
- // @ts-ignore
4
- || navigator.msMaxTouchPoints > 0;
1
+ export const isTouch = window && navigator && (
2
+ // @ts-ignore
3
+ 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0
4
+ );