@annotorious/annotorious 3.0.0-rc.9 → 3.0.1
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 +9 -10
- package/dist/AnnotoriousOpts.d.ts +5 -7
- package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +6 -6
- 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 -0
- package/dist/annotation/editors/editorsRegistry.d.ts +3 -4
- package/dist/annotation/editors/index.d.ts +1 -2
- 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 +1 -2
- package/dist/annotation/tools/ToolMount.svelte.d.ts +1 -1
- package/dist/annotation/tools/drawingToolsRegistry.d.ts +4 -5
- 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 +1 -2
- package/dist/annotation/utils/styling.d.ts +3 -4
- package/dist/annotation/utils/touch.d.ts +0 -1
- package/dist/annotorious.css +1 -1
- package/dist/annotorious.es.js +2538 -2061
- 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 +1 -2
- package/dist/keyboardCommands.d.ts +2 -2
- package/dist/model/core/ImageAnnotation.d.ts +4 -3
- package/dist/model/core/Shape.d.ts +1 -2
- package/dist/model/core/ellipse/Ellipse.d.ts +1 -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 +1 -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 +1 -2
- package/dist/model/core/rectangle/index.d.ts +0 -1
- package/dist/model/core/rectangle/rectangleUtils.d.ts +2 -3
- package/dist/model/core/shapeUtils.d.ts +2 -6
- package/dist/model/index.d.ts +0 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts +10 -0
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +11 -7
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +2 -4
- package/dist/model/w3c/fragment/index.d.ts +0 -1
- package/dist/model/w3c/index.d.ts +1 -1
- package/dist/model/w3c/svg/SVG.d.ts +0 -1
- package/dist/model/w3c/svg/SVGSelector.d.ts +2 -4
- package/dist/model/w3c/svg/index.d.ts +0 -1
- package/dist/state/ImageAnnotationStore.d.ts +6 -7
- package/dist/state/ImageAnnotatorState.d.ts +8 -9
- package/dist/state/index.d.ts +0 -1
- package/dist/state/spatialTree.d.ts +7 -7
- package/dist/themes/index.d.ts +0 -1
- package/dist/themes/smart/index.d.ts +0 -1
- package/dist/themes/smart/setTheme.d.ts +1 -2
- package/package.json +16 -17
- package/src/Annotorious.css +13 -5
- package/src/Annotorious.ts +42 -26
- package/src/AnnotoriousOpts.ts +13 -17
- package/src/annotation/SVGAnnotationLayer.svelte +77 -42
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +8 -9
- package/src/annotation/Transform.ts +1 -1
- package/src/annotation/editors/Editor.svelte +10 -11
- package/src/annotation/editors/EditorMount.svelte +3 -3
- package/src/annotation/editors/Handle.svelte +66 -0
- package/src/annotation/editors/editorsRegistry.ts +2 -2
- package/src/annotation/editors/index.ts +2 -2
- package/src/annotation/editors/polygon/PolygonEditor.svelte +16 -16
- package/src/annotation/editors/rectangle/RectangleEditor.svelte +46 -43
- package/src/annotation/shapes/Ellipse.svelte +4 -4
- package/src/annotation/shapes/Polygon.svelte +4 -4
- package/src/annotation/shapes/Rectangle.svelte +4 -4
- package/src/annotation/tools/ToolMount.svelte +3 -3
- package/src/annotation/tools/drawingToolsRegistry.ts +2 -1
- package/src/annotation/tools/polygon/RubberbandPolygon.svelte +36 -11
- package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +27 -11
- package/src/annotation/utils/responsive.ts +1 -1
- package/src/annotation/utils/styling.ts +18 -9
- package/src/annotation/utils/touch.ts +9 -1
- package/src/index.ts +1 -3
- package/src/keyboardCommands.ts +13 -5
- package/src/model/core/ImageAnnotation.ts +12 -1
- package/src/model/w3c/W3CImageAnnotation.ts +17 -0
- package/src/model/w3c/W3CImageFormatAdapter.ts +79 -32
- package/src/model/w3c/fragment/FragmentSelector.ts +5 -6
- package/src/model/w3c/index.ts +1 -0
- package/src/model/w3c/svg/SVG.ts +1 -2
- package/src/model/w3c/svg/SVGSelector.ts +11 -13
- package/src/state/ImageAnnotationStore.ts +5 -5
- package/src/state/ImageAnnotatorState.ts +19 -19
- package/src/state/spatialTree.ts +23 -11
- package/src/themes/dark/index.css +3 -3
- package/src/themes/light/index.css +2 -2
- package/src/themes/smart/setTheme.ts +2 -2
- 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/Handle.d.ts +0 -14
- package/dist/annotation/editors/Handle.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/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/src/annotation/editors/Handle.ts +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,4 @@ export * from './annotation/tools';
|
|
|
6
6
|
export * from './Annotorious';
|
|
7
7
|
export * from './AnnotoriousOpts';
|
|
8
8
|
export * from './keyboardCommands';
|
|
9
|
-
export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser,
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Annotation, UndoStack } from '@annotorious/core';
|
|
2
|
+
export declare const isMac: boolean;
|
|
2
3
|
export declare const initKeyboardCommands: <T extends Annotation>(undoStack: UndoStack<T>, container?: Element) => {
|
|
3
4
|
destroy: () => void;
|
|
4
5
|
};
|
|
5
|
-
//# sourceMappingURL=keyboardCommands.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Annotation, AnnotationTarget } from '@annotorious/core';
|
|
2
|
+
import { Shape } from './Shape';
|
|
3
3
|
export interface ImageAnnotation extends Annotation {
|
|
4
4
|
target: ImageAnnotationTarget;
|
|
5
5
|
}
|
|
6
6
|
export interface ImageAnnotationTarget extends AnnotationTarget {
|
|
7
7
|
selector: Shape;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
export declare const isImageAnnotation: <T extends Annotation>(a: T | ImageAnnotation) => a is ImageAnnotation;
|
|
10
|
+
export declare const isImageAnnotationTarget: <T extends AnnotationTarget>(t: T | ImageAnnotationTarget) => t is ImageAnnotationTarget;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AbstractSelector } from '@annotorious/core';
|
|
2
2
|
export interface Shape extends AbstractSelector {
|
|
3
3
|
type: ShapeType;
|
|
4
4
|
geometry: Geometry;
|
|
@@ -17,4 +17,3 @@ export interface Bounds {
|
|
|
17
17
|
maxX: number;
|
|
18
18
|
maxY: number;
|
|
19
19
|
}
|
|
20
|
-
//# sourceMappingURL=Shape.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Bounds, Geometry, Shape } from '../Shape';
|
|
2
2
|
export interface Ellipse extends Shape {
|
|
3
3
|
geometry: EllipseGeometry;
|
|
4
4
|
}
|
|
@@ -9,4 +9,3 @@ export interface EllipseGeometry extends Geometry {
|
|
|
9
9
|
ry: number;
|
|
10
10
|
bounds: Bounds;
|
|
11
11
|
}
|
|
12
|
-
//# sourceMappingURL=Ellipse.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Bounds, Geometry, Shape } from '../Shape';
|
|
2
2
|
export interface Polygon extends Shape {
|
|
3
3
|
geometry: PolygonGeometry;
|
|
4
4
|
}
|
|
@@ -6,4 +6,3 @@ export interface PolygonGeometry extends Geometry {
|
|
|
6
6
|
points: Array<Array<number>>;
|
|
7
7
|
bounds: Bounds;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=Polygon.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Bounds, Geometry, Shape } from '../Shape';
|
|
2
2
|
export interface Rectangle extends Shape {
|
|
3
3
|
geometry: RectangleGeometry;
|
|
4
4
|
}
|
|
@@ -9,4 +9,3 @@ export interface RectangleGeometry extends Geometry {
|
|
|
9
9
|
h: number;
|
|
10
10
|
bounds: Bounds;
|
|
11
11
|
}
|
|
12
|
-
//# sourceMappingURL=Rectangle.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Rectangle } from './Rectangle';
|
|
2
|
+
import { ShapeUtil } from '../shapeUtils';
|
|
3
3
|
export declare const RectangleUtil: ShapeUtil<Rectangle>;
|
|
4
|
-
//# sourceMappingURL=rectangleUtils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Bounds, Shape, ShapeType } from './Shape';
|
|
2
2
|
export interface ShapeUtil<T extends Shape> {
|
|
3
3
|
area: (shape: T) => number;
|
|
4
4
|
intersects: (shape: T, x: number, y: number) => boolean;
|
|
@@ -28,8 +28,4 @@ export declare const intersects: (shape: Shape, x: number, y: number) => boolean
|
|
|
28
28
|
* @param points the points
|
|
29
29
|
* @returns the Bounds
|
|
30
30
|
*/
|
|
31
|
-
export declare const boundsFromPoints: (points: Array<[
|
|
32
|
-
number,
|
|
33
|
-
number
|
|
34
|
-
]>) => Bounds;
|
|
35
|
-
//# sourceMappingURL=shapeUtils.d.ts.map
|
|
31
|
+
export declare const boundsFromPoints: (points: Array<[number, number]>) => Bounds;
|
package/dist/model/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
|
|
2
|
+
import { FragmentSelector } from './fragment';
|
|
3
|
+
import { SVGSelector } from './svg';
|
|
4
|
+
export interface W3CImageAnnotation extends W3CAnnotation {
|
|
5
|
+
target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[];
|
|
6
|
+
}
|
|
7
|
+
export interface W3CImageAnnotationTarget extends W3CAnnotationTarget {
|
|
8
|
+
selector: W3CImageSelector | W3CImageSelector[];
|
|
9
|
+
}
|
|
10
|
+
export type W3CImageSelector = FragmentSelector | SVGSelector;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
|
|
2
|
+
import { ImageAnnotation } from '../core';
|
|
3
|
+
import { W3CImageAnnotation } from './W3CImageAnnotation';
|
|
4
|
+
export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CImageAnnotation>;
|
|
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,10 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface FragmentSelector extends W3CSelector {
|
|
1
|
+
import { Rectangle, RectangleGeometry } from '../../core';
|
|
2
|
+
export interface FragmentSelector {
|
|
4
3
|
type: 'FragmentSelector';
|
|
5
4
|
conformsTo: 'http://www.w3.org/TR/media-frags/';
|
|
6
5
|
value: string;
|
|
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
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface SVGSelector extends W3CSelector {
|
|
1
|
+
import { Shape } from '../../core';
|
|
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,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export type ImageAnnotationStore = Store<
|
|
1
|
+
import { Annotation, Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
|
|
2
|
+
import { ImageAnnotation } from '../model';
|
|
3
|
+
export type ImageAnnotationStore<I extends Annotation> = Store<I> & {
|
|
4
4
|
getAt(x: number, y: number): ImageAnnotation | undefined;
|
|
5
5
|
getIntersecting(x: number, y: number, width: number, height: number): ImageAnnotation[];
|
|
6
6
|
};
|
|
7
|
-
export type SvelteImageAnnotationStore = SvelteStore<
|
|
8
|
-
export type SvelteImageAnnotatorState = SvelteAnnotatorState<
|
|
9
|
-
store: SvelteImageAnnotationStore
|
|
7
|
+
export type SvelteImageAnnotationStore<I extends Annotation = Annotation> = SvelteStore<I> & ImageAnnotationStore<I>;
|
|
8
|
+
export type SvelteImageAnnotatorState<I extends Annotation = Annotation> = SvelteAnnotatorState<I> & {
|
|
9
|
+
store: SvelteImageAnnotationStore<I>;
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=ImageAnnotationStore.d.ts.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
export type ImageAnnotatorState<
|
|
6
|
-
store:
|
|
1
|
+
import { ImageAnnotation } from '../model';
|
|
2
|
+
import { AnnotoriousOpts } from '../AnnotoriousOpts';
|
|
3
|
+
import { Annotation, AnnotatorState, HoverState, SelectionState } from '@annotorious/core';
|
|
4
|
+
import { ImageAnnotationStore, SvelteImageAnnotatorState } from './ImageAnnotationStore';
|
|
5
|
+
export type ImageAnnotatorState<I extends Annotation> = AnnotatorState<I> & {
|
|
6
|
+
store: ImageAnnotationStore<I>;
|
|
7
7
|
selection: SelectionState<ImageAnnotation>;
|
|
8
8
|
hover: HoverState<ImageAnnotation>;
|
|
9
9
|
};
|
|
10
|
-
export declare const createImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<
|
|
11
|
-
export declare const createSvelteImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<
|
|
12
|
-
//# sourceMappingURL=ImageAnnotatorState.d.ts.map
|
|
10
|
+
export declare const createImageAnnotatorState: <I extends Annotation, E extends unknown>(opts: AnnotoriousOpts<I, E>) => ImageAnnotatorState<I>;
|
|
11
|
+
export declare const createSvelteImageAnnotatorState: <I extends Annotation, E extends unknown>(opts: AnnotoriousOpts<I, E>) => SvelteImageAnnotatorState<I>;
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ImageAnnotationTarget } from '../model';
|
|
2
|
+
import { AnnotationTarget } from '@annotorious/core';
|
|
2
3
|
interface IndexedTarget {
|
|
3
4
|
minX: number;
|
|
4
5
|
minY: number;
|
|
@@ -9,13 +10,12 @@ interface IndexedTarget {
|
|
|
9
10
|
export declare const createSpatialTree: () => {
|
|
10
11
|
all: () => IndexedTarget[];
|
|
11
12
|
clear: () => void;
|
|
12
|
-
getAt: (x: number, y: number) => ImageAnnotationTarget |
|
|
13
|
+
getAt: (x: number, y: number) => ImageAnnotationTarget | undefined;
|
|
13
14
|
getIntersecting: (x: number, y: number, width: number, height: number) => ImageAnnotationTarget[];
|
|
14
|
-
insert: (target:
|
|
15
|
-
remove: (target:
|
|
16
|
-
set: (targets:
|
|
15
|
+
insert: (target: AnnotationTarget) => void;
|
|
16
|
+
remove: (target: AnnotationTarget) => void;
|
|
17
|
+
set: (targets: AnnotationTarget[], replace?: boolean) => void;
|
|
17
18
|
size: () => number;
|
|
18
|
-
update: (previous:
|
|
19
|
+
update: (previous: AnnotationTarget, updated: AnnotationTarget) => void;
|
|
19
20
|
};
|
|
20
21
|
export {};
|
|
21
|
-
//# sourceMappingURL=spatialTree.d.ts.map
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Theme } from '../../AnnotoriousOpts';
|
|
2
2
|
export declare const sampleBrightness: (imageOrCanvas: HTMLElement) => number;
|
|
3
3
|
export declare const detectTheme: (imageOrCanvas: HTMLElement) => "dark" | "light";
|
|
4
4
|
export declare const setTheme: (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) => void;
|
|
5
|
-
//# sourceMappingURL=setTheme.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/annotorious",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
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",
|
|
7
|
-
"homepage": "https://annotorious.
|
|
7
|
+
"homepage": "https://annotorious.dev",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,21 +36,20 @@
|
|
|
36
36
|
"./src": "./src/index.ts"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
40
|
-
"@tsconfig/svelte": "^
|
|
41
|
-
"@types/rbush": "^3.0.
|
|
42
|
-
"jsdom": "^
|
|
43
|
-
"svelte": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"vite
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"@annotorious/core": "*"
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
40
|
+
"@tsconfig/svelte": "^5.0.4",
|
|
41
|
+
"@types/rbush": "^3.0.4",
|
|
42
|
+
"jsdom": "^25.0.0",
|
|
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"
|
|
51
49
|
},
|
|
52
50
|
"dependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
51
|
+
"@annotorious/core": "3.0.1",
|
|
52
|
+
"rbush": "^4.0.1",
|
|
53
|
+
"uuid": "^10.0.0"
|
|
55
54
|
}
|
|
56
|
-
}
|
|
55
|
+
}
|
package/src/Annotorious.css
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
user-select: none;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.a9s-annotationlayer.hidden {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.a9s-annotationlayer .a9s-annotation {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
.a9s-annotationlayer ellipse,
|
|
23
31
|
.a9s-annotationlayer polygon,
|
|
24
32
|
.a9s-annotationlayer rect {
|
|
@@ -37,7 +45,7 @@
|
|
|
37
45
|
cursor: move;
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
.a9s-
|
|
48
|
+
.a9s-handle {
|
|
41
49
|
cursor: move;
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -57,18 +65,18 @@
|
|
|
57
65
|
cursor: w-resize;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
.a9s-
|
|
68
|
+
.a9s-handle.a9s-corner-handle-topleft {
|
|
61
69
|
cursor: nw-resize;
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
.a9s-
|
|
72
|
+
.a9s-handle.a9s-corner-handle-topright {
|
|
65
73
|
cursor: ne-resize;
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
.a9s-
|
|
76
|
+
.a9s-handle.a9s-corner-handle-bottomright {
|
|
69
77
|
cursor: se-resize;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
.a9s-
|
|
80
|
+
.a9s-handle.a9s-corner-handle-bottomleft {
|
|
73
81
|
cursor: sw-resize;
|
|
74
82
|
}
|
package/src/Annotorious.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SvelteComponent } from 'svelte';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { UserSelectAction } from '@annotorious/core';
|
|
3
|
+
import type { Annotation, Annotator, DrawingStyleExpression, Filter, User } from '@annotorious/core';
|
|
4
|
+
import { createAnonymousGuest, createBaseAnnotator, createLifecycleObserver, createUndoStack } from '@annotorious/core';
|
|
4
5
|
import { registerEditor } from './annotation/editors';
|
|
5
6
|
import { getTool, registerTool, listDrawingTools, type DrawingTool } from './annotation/tools';
|
|
6
7
|
import { SVGAnnotationLayer } from './annotation';
|
|
@@ -16,7 +17,9 @@ import './Annotorious.css';
|
|
|
16
17
|
import './themes/dark/index.css';
|
|
17
18
|
import './themes/light/index.css';
|
|
18
19
|
|
|
19
|
-
export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Annotator<
|
|
20
|
+
export interface ImageAnnotator<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> extends Annotator<I, E> {
|
|
21
|
+
|
|
22
|
+
element: HTMLDivElement;
|
|
20
23
|
|
|
21
24
|
listDrawingTools(): string[];
|
|
22
25
|
|
|
@@ -32,62 +35,68 @@ export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Ann
|
|
|
32
35
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
38
|
+
export const createImageAnnotator = <I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation>(
|
|
36
39
|
image: string | HTMLImageElement | HTMLCanvasElement,
|
|
37
|
-
options: AnnotoriousOpts<
|
|
38
|
-
): ImageAnnotator<E> => {
|
|
40
|
+
options: AnnotoriousOpts<I, E> = {}
|
|
41
|
+
): ImageAnnotator<I, E> => {
|
|
39
42
|
|
|
40
43
|
if (!image)
|
|
41
44
|
throw 'Missing argument: image';
|
|
42
45
|
|
|
43
|
-
const img = (
|
|
44
|
-
document.getElementById(image) : image
|
|
46
|
+
const img = (
|
|
47
|
+
typeof image === 'string' ? document.getElementById(image) : image
|
|
48
|
+
) as HTMLImageElement | HTMLCanvasElement;
|
|
45
49
|
|
|
46
|
-
const opts = fillDefaults<
|
|
50
|
+
const opts = fillDefaults<I, E>(options, {
|
|
51
|
+
drawingEnabled: true,
|
|
52
|
+
drawingMode: 'drag',
|
|
53
|
+
userSelectAction: UserSelectAction.EDIT,
|
|
54
|
+
theme: 'light'
|
|
55
|
+
});
|
|
47
56
|
|
|
48
|
-
const state = createSvelteImageAnnotatorState(opts);
|
|
57
|
+
const state = createSvelteImageAnnotatorState<I, E>(opts);
|
|
49
58
|
|
|
50
59
|
const { selection, store } = state;
|
|
51
60
|
|
|
52
61
|
const undoStack = createUndoStack(store);
|
|
53
62
|
|
|
54
|
-
const lifecycle =
|
|
63
|
+
const lifecycle = createLifecycleObserver<I, E>(
|
|
55
64
|
state, undoStack, opts.adapter, opts.autoSave
|
|
56
65
|
);
|
|
57
66
|
|
|
58
67
|
// We'll wrap the image in a container DIV.
|
|
59
|
-
const container = document.createElement('DIV');
|
|
68
|
+
const container = document.createElement('DIV') as HTMLDivElement;
|
|
60
69
|
container.style.position = 'relative';
|
|
61
70
|
container.style.display = 'inline-block';
|
|
62
71
|
|
|
63
72
|
// Wrapper div has unwanted margin at the bottom otherwise!
|
|
64
73
|
img.style.display = 'block';
|
|
65
74
|
|
|
66
|
-
img.parentNode
|
|
75
|
+
img.parentNode!.insertBefore(container, img);
|
|
67
76
|
container.appendChild(img);
|
|
68
77
|
|
|
69
78
|
const keyboardCommands = initKeyboardCommands(undoStack);
|
|
70
79
|
|
|
71
80
|
let currentUser: User = createAnonymousGuest();
|
|
72
81
|
|
|
73
|
-
_setTheme(img, container, opts.theme);
|
|
82
|
+
_setTheme(img, container, opts.theme!);
|
|
74
83
|
|
|
75
84
|
const annotationLayer = new SVGAnnotationLayer({
|
|
76
85
|
target: container,
|
|
77
86
|
props: {
|
|
78
|
-
drawingEnabled: opts.drawingEnabled,
|
|
87
|
+
drawingEnabled: Boolean(opts.drawingEnabled),
|
|
79
88
|
image: img,
|
|
80
|
-
preferredDrawingMode: opts.drawingMode
|
|
81
|
-
state,
|
|
89
|
+
preferredDrawingMode: opts.drawingMode!,
|
|
90
|
+
state: state,
|
|
82
91
|
style: opts.style,
|
|
83
92
|
user: currentUser
|
|
84
93
|
}
|
|
85
94
|
});
|
|
86
95
|
|
|
87
|
-
annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent
|
|
96
|
+
annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent<I>>) => {
|
|
88
97
|
const { originalEvent, annotation } = evt.detail;
|
|
89
98
|
if (annotation)
|
|
90
|
-
selection.
|
|
99
|
+
selection.userSelect(annotation.id, originalEvent);
|
|
91
100
|
else if (!selection.isEmpty())
|
|
92
101
|
selection.clear();
|
|
93
102
|
});
|
|
@@ -97,15 +106,15 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
97
106
|
/******++++++*************/
|
|
98
107
|
|
|
99
108
|
// Most of the external API functions are covered in the base annotator
|
|
100
|
-
const base = createBaseAnnotator<
|
|
109
|
+
const base = createBaseAnnotator<I, E>(state, undoStack, opts.adapter);
|
|
101
110
|
|
|
102
111
|
const destroy = () => {
|
|
103
112
|
// Destroy Svelte annotation layer
|
|
104
113
|
annotationLayer.$destroy();
|
|
105
114
|
|
|
106
115
|
// Unwrap the image
|
|
107
|
-
container.parentNode
|
|
108
|
-
container.parentNode
|
|
116
|
+
container.parentNode!.insertBefore(img, container);
|
|
117
|
+
container.parentNode!.removeChild(container);
|
|
109
118
|
|
|
110
119
|
// Other cleanup actions
|
|
111
120
|
keyboardCommands.destroy();
|
|
@@ -126,18 +135,19 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
126
135
|
if (!toolSpec)
|
|
127
136
|
throw `No drawing tool named ${name}`;
|
|
128
137
|
|
|
138
|
+
// @ts-ignore
|
|
129
139
|
annotationLayer.$set({ toolName: name })
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
const setDrawingEnabled = (enabled: boolean) =>
|
|
133
143
|
annotationLayer.$set({ drawingEnabled: enabled });
|
|
134
144
|
|
|
135
|
-
const setFilter = (
|
|
145
|
+
const setFilter = (_: Filter) => {
|
|
136
146
|
console.warn('Filter not implemented yet');
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
const setStyle = (style:
|
|
140
|
-
annotationLayer.$set({ style });
|
|
149
|
+
const setStyle = (style: DrawingStyleExpression<I> | undefined) =>
|
|
150
|
+
annotationLayer.$set({ style: style as DrawingStyleExpression<ImageAnnotation> });
|
|
141
151
|
|
|
142
152
|
const setTheme = (theme: Theme) => _setTheme(img, container, theme);
|
|
143
153
|
|
|
@@ -146,6 +156,10 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
146
156
|
annotationLayer.$set({ user });
|
|
147
157
|
}
|
|
148
158
|
|
|
159
|
+
const setVisible = (visible: boolean) =>
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
annotationLayer.$set({ visible });
|
|
162
|
+
|
|
149
163
|
return {
|
|
150
164
|
...base,
|
|
151
165
|
destroy,
|
|
@@ -161,7 +175,9 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
161
175
|
setStyle,
|
|
162
176
|
setTheme,
|
|
163
177
|
setUser,
|
|
178
|
+
setVisible,
|
|
179
|
+
element: container,
|
|
164
180
|
state
|
|
165
181
|
}
|
|
166
182
|
|
|
167
|
-
}
|
|
183
|
+
}
|
package/src/AnnotoriousOpts.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Annotation, DrawingStyle, FormatAdapter } from '@annotorious/core';
|
|
1
|
+
import type { Annotation, DrawingStyleExpression, FormatAdapter, UserSelectActionExpression } from '@annotorious/core';
|
|
3
2
|
import type { ImageAnnotation } from './model';
|
|
4
3
|
|
|
5
4
|
export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> {
|
|
@@ -14,9 +13,9 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E exten
|
|
|
14
13
|
// 'drag': starts drawing on drag, single click always selects
|
|
15
14
|
drawingMode?: DrawingMode;
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
userSelectAction?: UserSelectActionExpression<I>;
|
|
18
17
|
|
|
19
|
-
style?:
|
|
18
|
+
style?: DrawingStyleExpression<ImageAnnotation>;
|
|
20
19
|
|
|
21
20
|
theme?: Theme;
|
|
22
21
|
|
|
@@ -26,19 +25,16 @@ export type DrawingMode = 'click' | 'drag';
|
|
|
26
25
|
|
|
27
26
|
export type Theme = 'dark' | 'light' | 'auto';
|
|
28
27
|
|
|
29
|
-
export const fillDefaults = <I extends
|
|
30
|
-
opts: AnnotoriousOpts<I, E
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
};
|
|
28
|
+
export const fillDefaults = <I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
|
|
29
|
+
opts: AnnotoriousOpts<I, E>,
|
|
30
|
+
defaults: AnnotoriousOpts<I, E>
|
|
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
|
|