@annotorious/annotorious 3.0.0-rc.3 → 3.0.0-rc.31
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 +10 -7
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousOpts.d.ts +8 -6
- package/dist/AnnotoriousOpts.d.ts.map +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +4 -2
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +1 -1
- package/dist/annotation/editors/Handle.svelte.d.ts +1 -0
- package/dist/annotation/editors/editorsRegistry.d.ts +4 -3
- package/dist/annotation/editors/editorsRegistry.d.ts.map +1 -1
- package/dist/annotation/editors/index.d.ts +1 -1
- package/dist/annotation/editors/index.d.ts.map +1 -1
- package/dist/annotation/tools/DrawingToolConfig.d.ts +2 -1
- package/dist/annotation/tools/drawingToolsRegistry.d.ts +5 -4
- package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +1 -1
- package/dist/annotation/utils/responsive.d.ts +1 -1
- package/dist/annotation/utils/styling.d.ts +4 -3
- package/dist/annotation/utils/styling.d.ts.map +1 -1
- package/dist/annotation/utils/touch.d.ts.map +1 -1
- package/dist/annotorious.css +1 -1
- package/dist/annotorious.es.js +2540 -2178
- 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 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/keyboardCommands.d.ts +3 -2
- package/dist/keyboardCommands.d.ts.map +1 -1
- package/dist/model/core/ImageAnnotation.d.ts +3 -2
- package/dist/model/core/Shape.d.ts +2 -1
- package/dist/model/core/ellipse/Ellipse.d.ts +2 -1
- package/dist/model/core/polygon/Polygon.d.ts +2 -1
- package/dist/model/core/rectangle/Rectangle.d.ts +2 -1
- package/dist/model/core/rectangle/rectangleUtils.d.ts +3 -2
- package/dist/model/core/shapeUtils.d.ts +3 -5
- package/dist/model/core/shapeUtils.d.ts.map +1 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts +12 -0
- package/dist/model/w3c/W3CImageAnnotation.d.ts.map +1 -0
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +12 -6
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +3 -3
- package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +1 -1
- package/dist/model/w3c/index.d.ts +1 -0
- package/dist/model/w3c/index.d.ts.map +1 -1
- package/dist/model/w3c/svg/SVG.d.ts.map +1 -1
- package/dist/model/w3c/svg/SVGSelector.d.ts +3 -3
- package/dist/model/w3c/svg/SVGSelector.d.ts.map +1 -1
- package/dist/state/ImageAnnotationStore.d.ts +3 -2
- package/dist/state/ImageAnnotatorState.d.ts +5 -4
- package/dist/state/ImageAnnotatorState.d.ts.map +1 -1
- package/dist/state/spatialTree.d.ts +3 -2
- package/dist/state/spatialTree.d.ts.map +1 -1
- package/dist/themes/smart/setTheme.d.ts +4 -1
- package/dist/themes/smart/setTheme.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/Annotorious.css +9 -5
- package/src/Annotorious.ts +52 -36
- package/src/AnnotoriousOpts.ts +16 -15
- package/src/annotation/SVGAnnotationLayer.svelte +71 -36
- 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 +3 -3
- package/src/annotation/shapes/Polygon.svelte +3 -3
- package/src/annotation/shapes/Rectangle.svelte +3 -3
- package/src/annotation/tools/ToolMount.svelte +3 -3
- package/src/annotation/tools/drawingToolsRegistry.ts +2 -1
- package/src/annotation/tools/polygon/RubberbandPolygon.svelte +40 -13
- package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +27 -11
- package/src/annotation/utils/responsive.ts +1 -1
- package/src/annotation/utils/styling.ts +5 -2
- package/src/annotation/utils/touch.ts +4 -1
- package/src/index.ts +22 -16
- package/src/keyboardCommands.ts +11 -7
- package/src/model/w3c/W3CImageAnnotation.ts +17 -0
- package/src/model/w3c/W3CImageFormatAdapter.ts +79 -31
- 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 +4 -5
- package/src/state/spatialTree.ts +13 -6
- package/src/themes/dark/index.css +2 -2
- package/src/themes/light/index.css +2 -2
- package/src/themes/smart/setTheme.ts +10 -6
- package/dist/annotation/editors/Handle.d.ts +0 -14
- package/dist/annotation/editors/Handle.d.ts.map +0 -1
- package/src/annotation/editors/Handle.ts +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,5 @@ export * from './annotation/tools';
|
|
|
6
6
|
export * from './Annotorious';
|
|
7
7
|
export * from './AnnotoriousOpts';
|
|
8
8
|
export * from './keyboardCommands';
|
|
9
|
-
export
|
|
10
|
-
export * from '@annotorious/core/src/presence';
|
|
11
|
-
export * from '@annotorious/core/src/utils';
|
|
12
|
-
export type { HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver } from '@annotorious/core/src/state';
|
|
13
|
-
import { Origin as _Origin, PointerSelectAction as _PointerSelectAction } from '@annotorious/core/src/state';
|
|
14
|
-
export { _Origin as Origin };
|
|
15
|
-
export { _PointerSelectAction as PointerSelectAction };
|
|
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';
|
|
16
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAGnC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAGnC,YAAY,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,MAAM,EACN,aAAa,EACb,UAAU,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Annotation, UndoStack } from '@annotorious/core';
|
|
2
|
+
|
|
3
|
+
export declare const initKeyboardCommands: <T extends Annotation>(undoStack: UndoStack<T>, container?: Element) => {
|
|
3
4
|
destroy: () => void;
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=keyboardCommands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardCommands.d.ts","sourceRoot":"","sources":["../src/keyboardCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"keyboardCommands.d.ts","sourceRoot":"","sources":["../src/keyboardCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI/D,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,UAAU,aAC5C,SAAS,CAAC,CAAC,CAAC,cACX,OAAO;;CA2CpB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Annotation, AnnotationTarget } from '@annotorious/core';
|
|
2
|
+
import { Shape } from './Shape';
|
|
3
|
+
|
|
3
4
|
export interface ImageAnnotation extends Annotation {
|
|
4
5
|
target: ImageAnnotationTarget;
|
|
5
6
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Rectangle } from './Rectangle';
|
|
2
|
+
import { ShapeUtil } from '../shapeUtils';
|
|
3
|
+
|
|
3
4
|
export declare const RectangleUtil: ShapeUtil<Rectangle>;
|
|
4
5
|
//# sourceMappingURL=rectangleUtils.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Bounds, Shape, ShapeType } from './Shape';
|
|
2
|
+
|
|
2
3
|
export interface ShapeUtil<T extends Shape> {
|
|
3
4
|
area: (shape: T) => number;
|
|
4
5
|
intersects: (shape: T, x: number, y: number) => boolean;
|
|
@@ -28,8 +29,5 @@ export declare const intersects: (shape: Shape, x: number, y: number) => boolean
|
|
|
28
29
|
* @param points the points
|
|
29
30
|
* @returns the Bounds
|
|
30
31
|
*/
|
|
31
|
-
export declare const boundsFromPoints: (points: Array<[
|
|
32
|
-
number,
|
|
33
|
-
number
|
|
34
|
-
]>) => Bounds;
|
|
32
|
+
export declare const boundsFromPoints: (points: Array<[number, number]>) => Bounds;
|
|
35
33
|
//# sourceMappingURL=shapeUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapeUtils.d.ts","sourceRoot":"","sources":["../../../src/model/core/shapeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,KAAK;IAExC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE3B,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAEzD;AAID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAU,SAAS,GAAG,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"shapeUtils.d.ts","sourceRoot":"","sources":["../../../src/model/core/shapeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,KAAK;IAExC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE3B,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAEzD;AAID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAU,SAAS,GAAG,MAAM,QAAQ,SAAS,CAAC,GAAG,CAAC,mBAC1D,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK,WAAkC,CAAC;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,UAAW,KAAK,KAAK,MAAM,KAAK,MAAM,KAAG,OACrB,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAG,MAclE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
|
|
2
|
+
import { FragmentSelector } from './fragment';
|
|
3
|
+
import { SVGSelector } from './svg';
|
|
4
|
+
|
|
5
|
+
export interface W3CImageAnnotation extends W3CAnnotation {
|
|
6
|
+
target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[];
|
|
7
|
+
}
|
|
8
|
+
export interface W3CImageAnnotationTarget extends W3CAnnotationTarget {
|
|
9
|
+
selector: W3CImageSelector | W3CImageSelector[];
|
|
10
|
+
}
|
|
11
|
+
export type W3CImageSelector = FragmentSelector | SVGSelector;
|
|
12
|
+
//# sourceMappingURL=W3CImageAnnotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"W3CImageAnnotation.d.ts","sourceRoot":"","sources":["../../../src/model/w3c/W3CImageAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IAEvD,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,EAAE,CAAC;CAE/D;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IAEnE,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;CAEjD;AAED,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,WAAW,CAAC"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
import { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
|
|
2
|
+
import { ImageAnnotation } from '../core';
|
|
3
|
+
import { W3CImageAnnotation } from './W3CImageAnnotation';
|
|
4
|
+
|
|
5
|
+
export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CImageAnnotation>;
|
|
6
|
+
export interface W3CImageFormatAdapterOpts {
|
|
7
|
+
strict: boolean;
|
|
8
|
+
invertY: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const W3CImageFormat: (source: string, opts?: W3CImageFormatAdapterOpts) => W3CImageFormatAdapter;
|
|
11
|
+
export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, opts: W3CImageFormatAdapterOpts) => ParseResult<ImageAnnotation>;
|
|
12
|
+
export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string, opts: W3CImageFormatAdapterOpts) => W3CImageAnnotation;
|
|
7
13
|
//# sourceMappingURL=W3CImageFormatAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"W3CImageFormatAdapter.d.ts","sourceRoot":"","sources":["../../../src/model/w3c/W3CImageFormatAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"W3CImageFormatAdapter.d.ts","sourceRoot":"","sources":["../../../src/model/w3c/W3CImageFormatAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAKlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC;AAEvF,MAAM,WAAW,yBAAyB;IAExC,MAAM,EAAE,OAAO,CAAC;IAEhB,OAAO,EAAE,OAAO,CAAC;CAElB;AAED,eAAO,MAAM,cAAc,WACjB,MAAM,SACR,yBAAyB,KAC9B,qBASF,CAAA;AAED,eAAO,MAAM,uBAAuB,eACtB,aAAa,QACnB,yBAAyB,KAC9B,WAAW,CAAC,eAAe,CA0C7B,CAAA;AAED,eAAO,MAAM,2BAA2B,eAC1B,eAAe,UACnB,MAAM,QACR,yBAAyB,KAC9B,kBA8CF,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface FragmentSelector
|
|
1
|
+
import { Rectangle, RectangleGeometry } from '../../core';
|
|
2
|
+
|
|
3
|
+
export interface FragmentSelector {
|
|
4
4
|
type: 'FragmentSelector';
|
|
5
5
|
conformsTo: 'http://www.w3.org/TR/media-frags/';
|
|
6
6
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FragmentSelector.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/fragment/FragmentSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"FragmentSelector.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/fragment/FragmentSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/D,MAAM,WAAW,gBAAgB;IAE/B,IAAI,EAAE,kBAAkB,CAAC;IAEzB,UAAU,EAAE,mCAAmC,CAAC;IAEhD,KAAK,EAAE,MAAM,CAAC;CAEf;AAED,eAAO,MAAM,qBAAqB,uBACZ,gBAAgB,GAAG,MAAM,wBAE5C,SA+BF,CAAA;AAED,eAAO,MAAM,yBAAyB,aAAc,iBAAiB,KAAG,gBAQvE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/model/w3c/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/model/w3c/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SVG.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/svg/SVG.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAE1D,eAAO,MAAM,QAAQ,QAAS,OAAO,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"SVG.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/svg/SVG.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAE1D,eAAO,MAAM,QAAQ,QAAS,OAAO,GAAG,QAAQ,uBAkB/C,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,gBAAiB,QAAQ,KAAG,OAW1D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface SVGSelector
|
|
1
|
+
import { Shape } from '../../core';
|
|
2
|
+
|
|
3
|
+
export interface SVGSelector {
|
|
4
4
|
type: 'SvgSelector';
|
|
5
5
|
value: string;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SVGSelector.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/svg/SVGSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SVGSelector.d.ts","sourceRoot":"","sources":["../../../../src/model/w3c/svg/SVGSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsD,KAAK,EAAE,MAAM,YAAY,CAAC;AAI5F,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,aAAa,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC;CAEf;AA0DD,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,KAAK,mBAAmB,WAAW,GAAG,MAAM,KAAG,CASzF,CAAA;AAED,eAAO,MAAM,oBAAoB,UAAW,KAAK,KAAG,WAiBnD,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
|
|
2
|
+
import { ImageAnnotation } from '../model';
|
|
3
|
+
|
|
3
4
|
export type ImageAnnotationStore = Store<ImageAnnotation> & {
|
|
4
5
|
getAt(x: number, y: number): ImageAnnotation | undefined;
|
|
5
6
|
getIntersecting(x: number, y: number, width: number, height: number): ImageAnnotation[];
|
|
@@ -1,7 +1,8 @@
|
|
|
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
6
|
export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotationStore> = AnnotatorState<ImageAnnotation> & {
|
|
6
7
|
store: T;
|
|
7
8
|
selection: SelectionState<ImageAnnotation>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageAnnotatorState.d.ts","sourceRoot":"","sources":["../../src/state/ImageAnnotatorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EACV,oBAAoB,EAEpB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,cAAc,CAAC,eAAe,CAAC,GAAG;IAEzH,KAAK,EAAE,CAAC,CAAC;IAET,SAAS,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAE3C,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;CAEpC,CAAA;AAED,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ImageAnnotatorState.d.ts","sourceRoot":"","sources":["../../src/state/ImageAnnotatorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EACV,oBAAoB,EAEpB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,cAAc,CAAC,eAAe,CAAC,GAAG;IAEzH,KAAK,EAAE,CAAC,CAAC;IAET,SAAS,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAE3C,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;CAEpC,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,OAAO,QACnD,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,KACxC,mBAAmB,CAAC,oBAAoB,CAwC1C,CAAA;AAED,eAAO,MAAM,+BAA+B,GAAI,CAAC,SAAS,OAAO,QACzD,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,KACxC,yBASF,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ImageAnnotationTarget } from '../model';
|
|
2
|
+
|
|
2
3
|
interface IndexedTarget {
|
|
3
4
|
minX: number;
|
|
4
5
|
minY: number;
|
|
@@ -9,7 +10,7 @@ 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
15
|
insert: (target: ImageAnnotationTarget) => void;
|
|
15
16
|
remove: (target: ImageAnnotationTarget) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialTree.d.ts","sourceRoot":"","sources":["../../src/state/spatialTree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,aAAa;IAErB,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,qBAAqB,CAAC;CAE/B;AAED,eAAO,MAAM,iBAAiB;;;
|
|
1
|
+
{"version":3,"file":"spatialTree.d.ts","sourceRoot":"","sources":["../../src/state/spatialTree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,aAAa;IAErB,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,qBAAqB,CAAC;CAE/B;AAED,eAAO,MAAM,iBAAiB;;;eAqDV,MAAM,KAAK,MAAM,KAAG,qBAAqB,GAAG,SAAS;yBAqB3C,MAAM,KAAK,MAAM,SAAS,MAAM,UAAU,MAAM;qBA7DpD,qBAAqB;qBASrB,qBAAqB;mBAYvB,qBAAqB,EAAE,YAAW,OAAO;;uBALrC,qBAAqB,WAAW,qBAAqB;CAmEhF,CAAA"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Theme } from '../../AnnotoriousOpts';
|
|
2
|
+
|
|
1
3
|
export declare const sampleBrightness: (imageOrCanvas: HTMLElement) => number;
|
|
2
|
-
export declare const
|
|
4
|
+
export declare const detectTheme: (imageOrCanvas: HTMLElement) => "dark" | "light";
|
|
5
|
+
export declare const setTheme: (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) => void;
|
|
3
6
|
//# sourceMappingURL=setTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTheme.d.ts","sourceRoot":"","sources":["../../../src/themes/smart/setTheme.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,kBAAmB,WAAW,WAmC1D,CAAA;AAED,eAAO,MAAM,QAAQ,kBAAmB,WAAW,aAAa,WAAW,
|
|
1
|
+
{"version":3,"file":"setTheme.d.ts","sourceRoot":"","sources":["../../../src/themes/smart/setTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,kBAAmB,WAAW,WAmC1D,CAAA;AAED,eAAO,MAAM,WAAW,kBAAmB,WAAW,qBAOrD,CAAA;AAED,eAAO,MAAM,QAAQ,kBAAmB,WAAW,aAAa,WAAW,SAAS,KAAK,SACI,CAAC"}
|
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.31",
|
|
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",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
"require": "./dist/annotorious.js"
|
|
34
34
|
},
|
|
35
35
|
"./annotorious.css": "./dist/annotorious.css",
|
|
36
|
-
"./src": "./src/index.ts"
|
|
37
|
-
"./src/annotation": "./src/annotation/index.ts",
|
|
38
|
-
"./src/model": "./src/model/index.ts"
|
|
36
|
+
"./src": "./src/index.ts"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
42
|
-
"@tsconfig/svelte": "^
|
|
43
|
-
"@types/rbush": "^3.0.
|
|
44
|
-
"jsdom": "^
|
|
45
|
-
"svelte": "^
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"vite
|
|
49
|
-
"
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
40
|
+
"@tsconfig/svelte": "^5.0.4",
|
|
41
|
+
"@types/rbush": "^3.0.3",
|
|
42
|
+
"jsdom": "^24.1.1",
|
|
43
|
+
"svelte": "^4.2.18",
|
|
44
|
+
"svelte-preprocess": "^6.0.2",
|
|
45
|
+
"typescript": "5.5.3",
|
|
46
|
+
"vite": "^5.3.5",
|
|
47
|
+
"vite-plugin-dts": "^3.9.1",
|
|
48
|
+
"vitest": "^2.0.4"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
51
|
+
"@annotorious/core": "3.0.0-rc.31",
|
|
52
|
+
"rbush": "^4.0.0",
|
|
53
|
+
"uuid": "^10.0.0"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
package/src/Annotorious.css
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
user-select: none;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.a9s-annotationlayer.hidden {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
.a9s-annotationlayer ellipse,
|
|
23
27
|
.a9s-annotationlayer polygon,
|
|
24
28
|
.a9s-annotationlayer rect {
|
|
@@ -37,7 +41,7 @@
|
|
|
37
41
|
cursor: move;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
.a9s-
|
|
44
|
+
.a9s-handle {
|
|
41
45
|
cursor: move;
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -57,18 +61,18 @@
|
|
|
57
61
|
cursor: w-resize;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
.a9s-
|
|
64
|
+
.a9s-handle.a9s-corner-handle-topleft {
|
|
61
65
|
cursor: nw-resize;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
.a9s-
|
|
68
|
+
.a9s-handle.a9s-corner-handle-topright {
|
|
65
69
|
cursor: ne-resize;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
.a9s-
|
|
72
|
+
.a9s-handle.a9s-corner-handle-bottomright {
|
|
69
73
|
cursor: se-resize;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
.a9s-
|
|
76
|
+
.a9s-handle.a9s-corner-handle-bottomleft {
|
|
73
77
|
cursor: sw-resize;
|
|
74
78
|
}
|
package/src/Annotorious.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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';
|
|
7
8
|
import type { DrawingToolOpts, SVGAnnotationLayerPointerEvent } from './annotation';
|
|
8
9
|
import type { ImageAnnotation, ShapeType } from './model';
|
|
9
10
|
import { createSvelteImageAnnotatorState } from './state';
|
|
10
|
-
import { setTheme } from './themes';
|
|
11
|
-
import { fillDefaults } from './AnnotoriousOpts';
|
|
11
|
+
import { setTheme as _setTheme } from './themes';
|
|
12
|
+
import { fillDefaults, type Theme } from './AnnotoriousOpts';
|
|
12
13
|
import type { AnnotoriousOpts } from './AnnotoriousOpts';
|
|
13
14
|
import { initKeyboardCommands } from './keyboardCommands';
|
|
14
15
|
|
|
@@ -18,16 +19,20 @@ 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;
|
|
24
27
|
|
|
25
28
|
registerShapeEditor(shapeType: ShapeType, editor: typeof SvelteComponent): void;
|
|
26
29
|
|
|
27
|
-
setDrawingTool(
|
|
30
|
+
setDrawingTool(name: DrawingTool): void;
|
|
28
31
|
|
|
29
32
|
setDrawingEnabled(enabled: boolean): void;
|
|
30
33
|
|
|
34
|
+
setTheme(theme: Theme): void;
|
|
35
|
+
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
@@ -38,43 +43,50 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
38
43
|
if (!image)
|
|
39
44
|
throw 'Missing argument: image';
|
|
40
45
|
|
|
41
|
-
const img = (
|
|
42
|
-
document.getElementById(image) : image
|
|
46
|
+
const img = (
|
|
47
|
+
typeof image === 'string' ? document.getElementById(image) : image
|
|
48
|
+
) as HTMLImageElement | HTMLCanvasElement;
|
|
43
49
|
|
|
44
|
-
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
|
+
});
|
|
45
56
|
|
|
46
57
|
const state = createSvelteImageAnnotatorState(opts);
|
|
47
58
|
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
const lifecycle = createLifecyleObserver<ImageAnnotation, E>(
|
|
51
|
-
store, selection, hover, undefined, opts.adapter, opts.autoSave);
|
|
59
|
+
const { selection, store } = state;
|
|
52
60
|
|
|
53
61
|
const undoStack = createUndoStack(store);
|
|
54
62
|
|
|
63
|
+
const lifecycle = createLifecycleObserver<ImageAnnotation, E>(
|
|
64
|
+
state, undoStack, opts.adapter, opts.autoSave
|
|
65
|
+
);
|
|
66
|
+
|
|
55
67
|
// We'll wrap the image in a container DIV.
|
|
56
|
-
const container = document.createElement('DIV');
|
|
68
|
+
const container = document.createElement('DIV') as HTMLDivElement;
|
|
57
69
|
container.style.position = 'relative';
|
|
58
70
|
container.style.display = 'inline-block';
|
|
59
71
|
|
|
60
72
|
// Wrapper div has unwanted margin at the bottom otherwise!
|
|
61
73
|
img.style.display = 'block';
|
|
62
74
|
|
|
63
|
-
img.parentNode
|
|
75
|
+
img.parentNode!.insertBefore(container, img);
|
|
64
76
|
container.appendChild(img);
|
|
65
77
|
|
|
66
78
|
const keyboardCommands = initKeyboardCommands(undoStack);
|
|
67
79
|
|
|
68
80
|
let currentUser: User = createAnonymousGuest();
|
|
69
81
|
|
|
70
|
-
|
|
82
|
+
_setTheme(img, container, opts.theme!);
|
|
71
83
|
|
|
72
84
|
const annotationLayer = new SVGAnnotationLayer({
|
|
73
85
|
target: container,
|
|
74
86
|
props: {
|
|
75
|
-
drawingEnabled: opts.drawingEnabled,
|
|
87
|
+
drawingEnabled: Boolean(opts.drawingEnabled),
|
|
76
88
|
image: img,
|
|
77
|
-
preferredDrawingMode: opts.drawingMode
|
|
89
|
+
preferredDrawingMode: opts.drawingMode!,
|
|
78
90
|
state,
|
|
79
91
|
style: opts.style,
|
|
80
92
|
user: currentUser
|
|
@@ -84,7 +96,7 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
84
96
|
annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent>) => {
|
|
85
97
|
const { originalEvent, annotation } = evt.detail;
|
|
86
98
|
if (annotation)
|
|
87
|
-
selection.
|
|
99
|
+
selection.userSelect(annotation.id, originalEvent);
|
|
88
100
|
else if (!selection.isEmpty())
|
|
89
101
|
selection.clear();
|
|
90
102
|
});
|
|
@@ -94,15 +106,15 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
94
106
|
/******++++++*************/
|
|
95
107
|
|
|
96
108
|
// Most of the external API functions are covered in the base annotator
|
|
97
|
-
const base = createBaseAnnotator<ImageAnnotation, E>(
|
|
109
|
+
const base = createBaseAnnotator<ImageAnnotation, E>(state, undoStack, opts.adapter);
|
|
98
110
|
|
|
99
111
|
const destroy = () => {
|
|
100
112
|
// Destroy Svelte annotation layer
|
|
101
113
|
annotationLayer.$destroy();
|
|
102
114
|
|
|
103
115
|
// Unwrap the image
|
|
104
|
-
container.parentNode
|
|
105
|
-
container.parentNode
|
|
116
|
+
container.parentNode!.insertBefore(img, container);
|
|
117
|
+
container.parentNode!.removeChild(container);
|
|
106
118
|
|
|
107
119
|
// Other cleanup actions
|
|
108
120
|
keyboardCommands.destroy();
|
|
@@ -117,35 +129,37 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
117
129
|
const registerShapeEditor = (shapeType: ShapeType, editor: typeof SvelteComponent) =>
|
|
118
130
|
registerEditor(shapeType, editor);
|
|
119
131
|
|
|
120
|
-
const setDrawingTool = (
|
|
121
|
-
|
|
132
|
+
const setDrawingTool = (name: DrawingTool) => {
|
|
133
|
+
// Validate that the tool exists
|
|
134
|
+
const toolSpec = getTool(name);
|
|
135
|
+
if (!toolSpec)
|
|
136
|
+
throw `No drawing tool named ${name}`;
|
|
137
|
+
|
|
122
138
|
// @ts-ignore
|
|
123
|
-
annotationLayer.$set({
|
|
139
|
+
annotationLayer.$set({ toolName: name })
|
|
124
140
|
}
|
|
125
141
|
|
|
126
142
|
const setDrawingEnabled = (enabled: boolean) =>
|
|
127
143
|
annotationLayer.$set({ drawingEnabled: enabled });
|
|
128
144
|
|
|
129
|
-
const setFilter = (
|
|
145
|
+
const setFilter = (_: Filter) => {
|
|
130
146
|
console.warn('Filter not implemented yet');
|
|
131
147
|
}
|
|
132
148
|
|
|
133
|
-
const
|
|
134
|
-
if (arg) {
|
|
135
|
-
selection.setSelected(arg);
|
|
136
|
-
} else {
|
|
137
|
-
selection.clear();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const setStyle = (style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) | undefined) =>
|
|
149
|
+
const setStyle = (style: DrawingStyleExpression<ImageAnnotation> | undefined) =>
|
|
142
150
|
annotationLayer.$set({ style });
|
|
143
151
|
|
|
152
|
+
const setTheme = (theme: Theme) => _setTheme(img, container, theme);
|
|
153
|
+
|
|
144
154
|
const setUser = (user: User) => {
|
|
145
155
|
currentUser = user;
|
|
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,
|
|
@@ -158,10 +172,12 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
158
172
|
setDrawingEnabled,
|
|
159
173
|
setDrawingTool,
|
|
160
174
|
setFilter,
|
|
161
|
-
setSelected,
|
|
162
175
|
setStyle,
|
|
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,26 +13,28 @@ 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>;
|
|
19
|
+
|
|
20
|
+
theme?: Theme;
|
|
20
21
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export type DrawingMode = 'click' | 'drag';
|
|
24
25
|
|
|
25
|
-
export
|
|
26
|
-
opts: AnnotoriousOpts<I, E>
|
|
27
|
-
): AnnotoriousOpts<I, E> => {
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
...opts,
|
|
31
|
-
drawingEnabled: opts.drawingEnabled === undefined ? true : opts.drawingEnabled,
|
|
32
|
-
drawingMode: opts.drawingMode || 'drag',
|
|
33
|
-
pointerSelectAction: opts.pointerSelectAction || PointerSelectAction.EDIT
|
|
34
|
-
};
|
|
26
|
+
export type Theme = 'dark' | 'light' | 'auto';
|
|
35
27
|
|
|
36
|
-
|
|
28
|
+
export const fillDefaults = <I extends ImageAnnotation = 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
|
+
});
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
|