@annotorious/annotorious 3.0.0-rc.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotorious.d.ts +7 -8
- package/dist/AnnotoriousOpts.d.ts +5 -7
- package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +3 -3
- 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 +2489 -2025
- 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 +2 -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 +2 -3
- package/dist/state/ImageAnnotatorState.d.ts +4 -5
- package/dist/state/index.d.ts +0 -1
- package/dist/state/spatialTree.d.ts +2 -3
- 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 +15 -16
- package/src/Annotorious.css +13 -5
- package/src/Annotorious.ts +33 -17
- package/src/AnnotoriousOpts.ts +12 -16
- package/src/annotation/SVGAnnotationLayer.svelte +68 -35
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +2 -3
- 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/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/ImageAnnotatorState.ts +5 -5
- package/src/state/spatialTree.ts +13 -6
- 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,8 @@
|
|
|
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
|
-
//# sourceMappingURL=ImageAnnotation.d.ts.map
|
|
@@ -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,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
|
|
2
|
+
import { ImageAnnotation } from '../model';
|
|
3
3
|
export type ImageAnnotationStore = Store<ImageAnnotation> & {
|
|
4
4
|
getAt(x: number, y: number): ImageAnnotation | undefined;
|
|
5
5
|
getIntersecting(x: number, y: number, width: number, height: number): ImageAnnotation[];
|
|
@@ -8,4 +8,3 @@ export type SvelteImageAnnotationStore = SvelteStore<ImageAnnotation> & ImageAnn
|
|
|
8
8
|
export type SvelteImageAnnotatorState = SvelteAnnotatorState<ImageAnnotation> & {
|
|
9
9
|
store: SvelteImageAnnotationStore;
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=ImageAnnotationStore.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { ImageAnnotation } from '../model';
|
|
2
|
+
import { AnnotoriousOpts } from '../AnnotoriousOpts';
|
|
3
|
+
import { AnnotatorState, HoverState, SelectionState } from '@annotorious/core';
|
|
4
|
+
import { ImageAnnotationStore, SvelteImageAnnotatorState } from './ImageAnnotationStore';
|
|
5
5
|
export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotationStore> = AnnotatorState<ImageAnnotation> & {
|
|
6
6
|
store: T;
|
|
7
7
|
selection: SelectionState<ImageAnnotation>;
|
|
@@ -9,4 +9,3 @@ export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotation
|
|
|
9
9
|
};
|
|
10
10
|
export declare const createImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => ImageAnnotatorState<ImageAnnotationStore>;
|
|
11
11
|
export declare const createSvelteImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => SvelteImageAnnotatorState;
|
|
12
|
-
//# sourceMappingURL=ImageAnnotatorState.d.ts.map
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ImageAnnotationTarget } from '../model';
|
|
2
2
|
interface IndexedTarget {
|
|
3
3
|
minX: number;
|
|
4
4
|
minY: number;
|
|
@@ -9,7 +9,7 @@ interface IndexedTarget {
|
|
|
9
9
|
export declare const createSpatialTree: () => {
|
|
10
10
|
all: () => IndexedTarget[];
|
|
11
11
|
clear: () => void;
|
|
12
|
-
getAt: (x: number, y: number) => ImageAnnotationTarget |
|
|
12
|
+
getAt: (x: number, y: number) => ImageAnnotationTarget | undefined;
|
|
13
13
|
getIntersecting: (x: number, y: number, width: number, height: number) => ImageAnnotationTarget[];
|
|
14
14
|
insert: (target: ImageAnnotationTarget) => void;
|
|
15
15
|
remove: (target: ImageAnnotationTarget) => void;
|
|
@@ -18,4 +18,3 @@ export declare const createSpatialTree: () => {
|
|
|
18
18
|
update: (previous: ImageAnnotationTarget, updated: ImageAnnotationTarget) => void;
|
|
19
19
|
};
|
|
20
20
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/annotorious",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
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,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.0",
|
|
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 { 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';
|
|
@@ -18,6 +19,8 @@ import './themes/light/index.css';
|
|
|
18
19
|
|
|
19
20
|
export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Annotator<ImageAnnotation, E> {
|
|
20
21
|
|
|
22
|
+
element: HTMLDivElement;
|
|
23
|
+
|
|
21
24
|
listDrawingTools(): string[];
|
|
22
25
|
|
|
23
26
|
registerDrawingTool(name: string, tool: typeof SvelteComponent, opts?: DrawingToolOpts): void;
|
|
@@ -40,10 +43,16 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
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<ImageAnnotation, E>(options
|
|
50
|
+
const opts = fillDefaults<ImageAnnotation, E>(options, {
|
|
51
|
+
drawingEnabled: true,
|
|
52
|
+
drawingMode: 'drag',
|
|
53
|
+
userSelectAction: UserSelectAction.EDIT,
|
|
54
|
+
theme: 'light'
|
|
55
|
+
});
|
|
47
56
|
|
|
48
57
|
const state = createSvelteImageAnnotatorState(opts);
|
|
49
58
|
|
|
@@ -51,33 +60,33 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
51
60
|
|
|
52
61
|
const undoStack = createUndoStack(store);
|
|
53
62
|
|
|
54
|
-
const lifecycle =
|
|
63
|
+
const lifecycle = createLifecycleObserver<ImageAnnotation, 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
|
|
89
|
+
preferredDrawingMode: opts.drawingMode!,
|
|
81
90
|
state,
|
|
82
91
|
style: opts.style,
|
|
83
92
|
user: currentUser
|
|
@@ -87,7 +96,7 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
87
96
|
annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent>) => {
|
|
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
|
});
|
|
@@ -104,8 +113,8 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
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,17 +135,18 @@ 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:
|
|
149
|
+
const setStyle = (style: DrawingStyleExpression<ImageAnnotation> | undefined) =>
|
|
140
150
|
annotationLayer.$set({ style });
|
|
141
151
|
|
|
142
152
|
const setTheme = (theme: Theme) => _setTheme(img, container, theme);
|
|
@@ -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
|
|
|
@@ -27,18 +26,15 @@ export type DrawingMode = 'click' | 'drag';
|
|
|
27
26
|
export type Theme = 'dark' | 'light' | 'auto';
|
|
28
27
|
|
|
29
28
|
export const fillDefaults = <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
|
|
30
|
-
opts: AnnotoriousOpts<I, E
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
};
|
|
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
|
|