@annotorious/annotorious 3.6.5 → 3.6.7

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.
@@ -1,5 +1,5 @@
1
1
  import { ImageAnnotationTarget } from '../model';
2
- import { Annotation, AnnotationTarget, Filter } from '@annotorious/core';
2
+ import { AnnotationTarget } from '@annotorious/core';
3
3
  interface IndexedTarget {
4
4
  minX: number;
5
5
  minY: number;
@@ -10,7 +10,7 @@ interface IndexedTarget {
10
10
  export declare const createSpatialTree: () => {
11
11
  all: () => IndexedTarget[];
12
12
  clear: () => void;
13
- getAt: (x: number, y: number, filter?: Filter<Annotation>, buffer?: number) => ImageAnnotationTarget[];
13
+ getAt: (x: number, y: number, buffer?: number) => ImageAnnotationTarget[];
14
14
  getIntersecting: (x: number, y: number, width: number, height: number) => ImageAnnotationTarget[];
15
15
  insert: (target: AnnotationTarget) => void;
16
16
  remove: (target: AnnotationTarget) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/annotorious",
3
- "version": "3.6.5",
3
+ "version": "3.6.7",
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",
@@ -49,7 +49,7 @@
49
49
  "vitest": "^3.2.4"
50
50
  },
51
51
  "dependencies": {
52
- "@annotorious/core": "3.6.5",
52
+ "@annotorious/core": "3.6.7",
53
53
  "dequal": "^2.0.3",
54
54
  "rbush": "^4.0.1",
55
55
  "simplify-js": "^1.2.4",
@@ -19,12 +19,12 @@
19
19
  user-select: none;
20
20
  }
21
21
 
22
- .a9s-annotationlayer.hidden {
23
- display: none;
22
+ .a9s-annotationlayer.hover {
23
+ cursor: pointer;
24
24
  }
25
25
 
26
- .a9s-annotationlayer .a9s-annotation {
27
- cursor: pointer;
26
+ .a9s-annotationlayer.hidden {
27
+ display: none;
28
28
  }
29
29
 
30
30
  .a9s-annotationlayer ellipse,
@@ -38,12 +38,12 @@ export const approximateAsPolygon = (corners: PolylinePoint[], closed = false):
38
38
 
39
39
  // If there's a curve to the next point, approximate it
40
40
  if (i < corners.length - 1 || closed) {
41
- const hasCurve = currentPoint.outHandle || nextPoint.inHandle;
41
+ const hasCurve = currentPoint.type === 'CURVE' || nextPoint.type == 'CURVE';
42
42
  if (hasCurve) {
43
43
  const curvePoints = approximateBezierCurve(
44
44
  currentPoint.point,
45
- currentPoint.outHandle || currentPoint.point,
46
- nextPoint.inHandle || nextPoint.point,
45
+ currentPoint.type === 'CURVE' ? currentPoint.outHandle || currentPoint.point : currentPoint.point,
46
+ nextPoint.type === 'CURVE' ? nextPoint.inHandle || nextPoint.point : nextPoint.point,
47
47
  nextPoint.point,
48
48
  10 // number of approximation segments
49
49
  );
@@ -85,12 +85,12 @@ const isPointNearPath = (geom: PolylineGeometry, point: [number, number], buffer
85
85
  const currentPoint = geom.points[i];
86
86
  const nextPoint = geom.points[i + 1];
87
87
 
88
- const hasCurve = currentPoint.outHandle || nextPoint.inHandle;
88
+ const hasCurve = currentPoint.type === 'CURVE' || nextPoint.type === 'CURVE';
89
89
  if (hasCurve) {
90
90
  const curvePoints = approximateBezierCurve(
91
91
  currentPoint.point,
92
- currentPoint.outHandle || currentPoint.point,
93
- nextPoint.inHandle || nextPoint.point,
92
+ currentPoint.type === 'CURVE' ? currentPoint.outHandle || currentPoint.point : currentPoint.point,
93
+ nextPoint.type === 'CURVE' ? nextPoint.inHandle || nextPoint.point : nextPoint.point,
94
94
  nextPoint.point,
95
95
  20 // TODO make configurable? Based on scale factor? Length?
96
96
  );
@@ -174,8 +174,7 @@ export const computeSVGPath = (geom: PolylineGeometry) => {
174
174
  const lastPoint = geom.points[geom.points.length - 1];
175
175
  const firstPointRef = geom.points[0];
176
176
 
177
- const hasClosingCurve = lastPoint.outHandle || firstPointRef.inHandle;
178
-
177
+ const hasClosingCurve = lastPoint.type === 'CURVE' || firstPointRef.type === 'CURVE';
179
178
  if (hasClosingCurve) {
180
179
  const cp1 = lastPoint.outHandle || lastPoint.point;
181
180
  const cp2 = firstPointRef.inHandle || firstPointRef.point;
@@ -55,7 +55,7 @@ export const createImageAnnotatorState = <I extends Annotation, E extends unknow
55
55
  });
56
56
 
57
57
  const getAt = (x: number, y: number, filter?: Filter<I>, buffer?: number): I | undefined => {
58
- const targets = tree.getAt(x, y, filter as Filter<Annotation>, buffer);
58
+ const targets = tree.getAt(x, y, buffer);
59
59
 
60
60
  if (filter) {
61
61
  // Resolve annotations first, so we can filter
@@ -72,8 +72,8 @@ export const createImageAnnotatorState = <I extends Annotation, E extends unknow
72
72
 
73
73
  const getIntersecting = (x: number, y: number, width: number, height: number) =>
74
74
  tree.getIntersecting(x, y, width, height)
75
- .map(target => store.getAnnotation(target.annotation) as I)
76
- .filter(Boolean); // Race conditions may have deleted annotations concurrently
75
+ .map(target => store.getAnnotation(target.annotation) as I)
76
+ .filter(Boolean); // Race conditions may have deleted annotations concurrently
77
77
 
78
78
  return {
79
79
  store: {
@@ -75,7 +75,7 @@ export const createSpatialTree = () => {
75
75
  };
76
76
 
77
77
 
78
- const getAt = (x: number, y: number, filter?: Filter<Annotation>, buffer: number = 0): ImageAnnotationTarget[] => {
78
+ const getAt = (x: number, y: number, buffer: number = 0): ImageAnnotationTarget[] => {
79
79
  const idxHits = tree.search({
80
80
  minX: x - buffer,
81
81
  minY: y - buffer,