@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.
- package/dist/Annotorious.d.ts +1 -2
- package/dist/AnnotoriousOpts.d.ts +2 -4
- package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +1 -2
- package/dist/annotation/Transform.d.ts +0 -1
- package/dist/annotation/editors/Editor.svelte.d.ts +1 -1
- package/dist/annotation/editors/EditorMount.svelte.d.ts +1 -1
- package/dist/annotation/editors/Handle.svelte.d.ts +1 -1
- package/dist/annotation/editors/editorsRegistry.d.ts +0 -2
- package/dist/annotation/editors/index.d.ts +0 -1
- package/dist/annotation/editors/polygon/PolygonEditor.svelte.d.ts +1 -1
- package/dist/annotation/editors/polygon/index.d.ts +0 -1
- package/dist/annotation/editors/rectangle/RectangleEditor.svelte.d.ts +1 -1
- package/dist/annotation/editors/rectangle/index.d.ts +0 -1
- package/dist/annotation/index.d.ts +0 -1
- package/dist/annotation/shapes/Ellipse.svelte.d.ts +1 -1
- package/dist/annotation/shapes/Polygon.svelte.d.ts +1 -1
- package/dist/annotation/shapes/Rectangle.svelte.d.ts +1 -1
- package/dist/annotation/shapes/index.d.ts +0 -1
- package/dist/annotation/tools/DrawingToolConfig.d.ts +0 -2
- package/dist/annotation/tools/ToolMount.svelte.d.ts +1 -1
- package/dist/annotation/tools/drawingToolsRegistry.d.ts +0 -2
- package/dist/annotation/tools/index.d.ts +0 -1
- package/dist/annotation/tools/polygon/RubberbandPolygon.svelte.d.ts +1 -1
- package/dist/annotation/tools/polygon/index.d.ts +0 -1
- package/dist/annotation/tools/rectangle/RubberbandRectangle.svelte.d.ts +1 -1
- package/dist/annotation/tools/rectangle/index.d.ts +0 -1
- package/dist/annotation/utils/index.d.ts +0 -1
- package/dist/annotation/utils/math.d.ts +0 -1
- package/dist/annotation/utils/responsive.d.ts +0 -1
- package/dist/annotation/utils/styling.d.ts +0 -2
- package/dist/annotation/utils/touch.d.ts +0 -1
- package/dist/annotorious.css +1 -1
- package/dist/annotorious.es.js +1717 -1622
- package/dist/annotorious.es.js.map +1 -1
- package/dist/annotorious.js +1 -1
- package/dist/annotorious.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/keyboardCommands.d.ts +0 -2
- package/dist/model/core/ImageAnnotation.d.ts +0 -2
- package/dist/model/core/Shape.d.ts +0 -2
- package/dist/model/core/ellipse/Ellipse.d.ts +0 -2
- package/dist/model/core/ellipse/ellipseUtils.d.ts +0 -1
- package/dist/model/core/ellipse/index.d.ts +0 -1
- package/dist/model/core/index.d.ts +0 -1
- package/dist/model/core/polygon/Polygon.d.ts +0 -2
- package/dist/model/core/polygon/index.d.ts +0 -1
- package/dist/model/core/polygon/polygonUtils.d.ts +0 -1
- package/dist/model/core/rectangle/Rectangle.d.ts +0 -2
- package/dist/model/core/rectangle/index.d.ts +0 -1
- package/dist/model/core/rectangle/rectangleUtils.d.ts +0 -2
- package/dist/model/core/shapeUtils.d.ts +0 -2
- package/dist/model/index.d.ts +0 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts +0 -2
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +7 -5
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +0 -2
- package/dist/model/w3c/fragment/index.d.ts +0 -1
- package/dist/model/w3c/index.d.ts +0 -1
- package/dist/model/w3c/svg/SVG.d.ts +0 -1
- package/dist/model/w3c/svg/SVGSelector.d.ts +0 -2
- package/dist/model/w3c/svg/index.d.ts +0 -1
- package/dist/state/ImageAnnotationStore.d.ts +0 -2
- package/dist/state/ImageAnnotatorState.d.ts +0 -2
- package/dist/state/index.d.ts +0 -1
- package/dist/state/spatialTree.d.ts +0 -2
- package/dist/themes/index.d.ts +0 -1
- package/dist/themes/smart/index.d.ts +0 -1
- package/dist/themes/smart/setTheme.d.ts +0 -2
- package/package.json +12 -12
- package/src/Annotorious.css +4 -0
- package/src/Annotorious.ts +10 -6
- package/src/AnnotoriousOpts.ts +9 -13
- package/src/annotation/SVGAnnotationLayer.svelte +47 -20
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +1 -1
- package/src/annotation/editors/editorsRegistry.ts +2 -2
- package/src/annotation/shapes/Ellipse.svelte +1 -1
- package/src/annotation/shapes/Polygon.svelte +1 -1
- package/src/annotation/shapes/Rectangle.svelte +1 -1
- package/src/annotation/utils/styling.ts +14 -8
- package/src/annotation/utils/touch.ts +4 -4
- package/src/model/w3c/W3CImageFormatAdapter.ts +29 -13
- package/src/state/ImageAnnotatorState.ts +1 -2
- package/src/state/spatialTree.ts +10 -4
- package/src/themes/dark/index.css +1 -1
- package/dist/Annotorious.d.ts.map +0 -1
- package/dist/AnnotoriousOpts.d.ts.map +0 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +0 -1
- package/dist/annotation/Transform.d.ts.map +0 -1
- package/dist/annotation/editors/editorsRegistry.d.ts.map +0 -1
- package/dist/annotation/editors/index.d.ts.map +0 -1
- package/dist/annotation/editors/polygon/index.d.ts.map +0 -1
- package/dist/annotation/editors/rectangle/index.d.ts.map +0 -1
- package/dist/annotation/index.d.ts.map +0 -1
- package/dist/annotation/shapes/index.d.ts.map +0 -1
- package/dist/annotation/tools/DrawingToolConfig.d.ts.map +0 -1
- package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +0 -1
- package/dist/annotation/tools/index.d.ts.map +0 -1
- package/dist/annotation/tools/polygon/index.d.ts.map +0 -1
- package/dist/annotation/tools/rectangle/index.d.ts.map +0 -1
- package/dist/annotation/utils/index.d.ts.map +0 -1
- package/dist/annotation/utils/math.d.ts.map +0 -1
- package/dist/annotation/utils/responsive.d.ts.map +0 -1
- package/dist/annotation/utils/styling.d.ts.map +0 -1
- package/dist/annotation/utils/touch.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/keyboardCommands.d.ts.map +0 -1
- package/dist/model/core/ImageAnnotation.d.ts.map +0 -1
- package/dist/model/core/Shape.d.ts.map +0 -1
- package/dist/model/core/ellipse/Ellipse.d.ts.map +0 -1
- package/dist/model/core/ellipse/ellipseUtils.d.ts.map +0 -1
- package/dist/model/core/ellipse/index.d.ts.map +0 -1
- package/dist/model/core/index.d.ts.map +0 -1
- package/dist/model/core/polygon/Polygon.d.ts.map +0 -1
- package/dist/model/core/polygon/index.d.ts.map +0 -1
- package/dist/model/core/polygon/polygonUtils.d.ts.map +0 -1
- package/dist/model/core/rectangle/Rectangle.d.ts.map +0 -1
- package/dist/model/core/rectangle/index.d.ts.map +0 -1
- package/dist/model/core/rectangle/rectangleUtils.d.ts.map +0 -1
- package/dist/model/core/shapeUtils.d.ts.map +0 -1
- package/dist/model/index.d.ts.map +0 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts.map +0 -1
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +0 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +0 -1
- package/dist/model/w3c/fragment/index.d.ts.map +0 -1
- package/dist/model/w3c/index.d.ts.map +0 -1
- package/dist/model/w3c/svg/SVG.d.ts.map +0 -1
- package/dist/model/w3c/svg/SVGSelector.d.ts.map +0 -1
- package/dist/model/w3c/svg/index.d.ts.map +0 -1
- package/dist/state/ImageAnnotationStore.d.ts.map +0 -1
- package/dist/state/ImageAnnotatorState.d.ts.map +0 -1
- package/dist/state/index.d.ts.map +0 -1
- package/dist/state/spatialTree.d.ts.map +0 -1
- package/dist/themes/index.d.ts.map +0 -1
- package/dist/themes/smart/index.d.ts.map +0 -1
- 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,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,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,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,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
|
package/dist/model/index.d.ts
CHANGED
|
@@ -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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
@@ -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,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
|
package/dist/state/index.d.ts
CHANGED
|
@@ -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
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
40
40
|
"@tsconfig/svelte": "^5.0.4",
|
|
41
|
-
"@types/rbush": "^3.0.
|
|
42
|
-
"jsdom": "^24.1.
|
|
43
|
-
"svelte": "^4.2.
|
|
44
|
-
"svelte-preprocess": "^6.0.
|
|
45
|
-
"typescript": "
|
|
46
|
-
"vite": "^5.
|
|
47
|
-
"vite-plugin-dts": "^
|
|
48
|
-
"vitest": "^
|
|
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.
|
|
52
|
-
"rbush": "^4.0.
|
|
51
|
+
"@annotorious/core": "3.0.0-rc.32",
|
|
52
|
+
"rbush": "^4.0.1",
|
|
53
53
|
"uuid": "^10.0.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/Annotorious.css
CHANGED
package/src/Annotorious.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SvelteComponent } from 'svelte';
|
|
2
|
-
import {
|
|
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 = (
|
|
45
|
-
document.getElementById(image) : image
|
|
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
|
-
|
|
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.
|
|
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
|
|
package/src/AnnotoriousOpts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Annotation,
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
136
|
-
<Ellipse
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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);
|
|
@@ -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}
|
|
17
|
-
|
|
18
|
-
|
|
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 =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const isTouch = window && navigator && (
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0
|
|
4
|
+
);
|