@annotorious/annotorious 3.0.0-rc.2 → 3.0.0-rc.20
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 -2
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousOpts.d.ts +4 -3
- package/dist/AnnotoriousOpts.d.ts.map +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +1 -1
- package/dist/annotation/Transform.d.ts.map +1 -1
- package/dist/annotation/editors/Handle.svelte.d.ts +1 -0
- package/dist/annotation/editors/editorsRegistry.d.ts +1 -1
- 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/drawingToolsRegistry.d.ts +4 -4
- package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +1 -1
- package/dist/annotation/utils/responsive.d.ts +2 -1
- package/dist/annotation/utils/responsive.d.ts.map +1 -1
- package/dist/annotation/utils/styling.d.ts +1 -1
- 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 +2370 -1991
- 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 +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/keyboardCommands.d.ts +5 -0
- package/dist/keyboardCommands.d.ts.map +1 -0
- package/dist/model/w3c/W3CImageAnnotation.d.ts +11 -0
- package/dist/model/w3c/W3CImageAnnotation.d.ts.map +1 -0
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +3 -2
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +1 -2
- 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 +1 -2
- package/dist/model/w3c/svg/SVGSelector.d.ts.map +1 -1
- package/dist/state/ImageAnnotatorState.d.ts.map +1 -1
- package/dist/state/spatialTree.d.ts +1 -1
- package/dist/state/spatialTree.d.ts.map +1 -1
- package/dist/themes/smart/setTheme.d.ts +3 -1
- package/dist/themes/smart/setTheme.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/Annotorious.css +5 -5
- package/src/Annotorious.ts +44 -29
- package/src/AnnotoriousOpts.ts +11 -6
- package/src/annotation/SVGAnnotationLayer.svelte +21 -15
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +1 -2
- package/src/annotation/Transform.ts +5 -3
- 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/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 +2 -2
- package/src/annotation/shapes/Polygon.svelte +2 -2
- 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 +58 -32
- package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +17 -16
- package/src/annotation/utils/responsive.ts +1 -1
- package/src/annotation/utils/touch.ts +4 -1
- package/src/index.ts +25 -8
- package/src/keyboardCommands.ts +50 -0
- package/src/model/w3c/W3CImageAnnotation.ts +17 -0
- package/src/model/w3c/W3CImageFormatAdapter.ts +54 -20
- 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 +3 -3
- package/src/state/spatialTree.ts +3 -2
- 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
|
@@ -5,8 +5,6 @@ export * from './themes';
|
|
|
5
5
|
export * from './annotation/tools';
|
|
6
6
|
export * from './Annotorious';
|
|
7
7
|
export * from './AnnotoriousOpts';
|
|
8
|
-
export * from '
|
|
9
|
-
export
|
|
10
|
-
export * from '@annotorious/core/src/utils';
|
|
11
|
-
export type { HoverState, Selection, SelectionState, Store, StoreObserver } from '@annotorious/core/src/state';
|
|
8
|
+
export * from './keyboardCommands';
|
|
9
|
+
export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Purpose, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
|
|
12
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;
|
|
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,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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,oCACpB,UAAU,CAAC,CAAC,cACX,OAAO;;CA2CpB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
|
|
2
|
+
import type { FragmentSelector } from './fragment';
|
|
3
|
+
import type { 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;
|
|
11
|
+
//# 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,8 @@
|
|
|
1
1
|
import type { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
|
|
2
2
|
import type { ImageAnnotation } from '../core';
|
|
3
|
-
|
|
3
|
+
import type { W3CImageAnnotation } from './W3CImageAnnotation';
|
|
4
|
+
export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CImageAnnotation>;
|
|
4
5
|
export declare const W3CImageFormat: (source: string, invertY?: boolean) => W3CImageFormatAdapter;
|
|
5
6
|
export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, invertY?: boolean) => ParseResult<ImageAnnotation>;
|
|
6
|
-
export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string) =>
|
|
7
|
+
export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string) => W3CImageAnnotation;
|
|
7
8
|
//# 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,eAAO,MAAM,cAAc,WACjB,MAAM,YACL,OAAO,0BAUjB,CAAA;AAED,eAAO,MAAM,uBAAuB,eACtB,aAAa,YAChB,OAAO,KACf,YAAY,eAAe,CA2C7B,CAAA;AAED,eAAO,MAAM,2BAA2B,eAC1B,eAAe,UACnB,MAAM,KACb,kBAsCF,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { W3CSelector } from '@annotorious/core';
|
|
2
1
|
import type { Rectangle, RectangleGeometry } from '../../core';
|
|
3
|
-
export interface FragmentSelector
|
|
2
|
+
export interface FragmentSelector {
|
|
4
3
|
type: 'FragmentSelector';
|
|
5
4
|
conformsTo: 'http://www.w3.org/TR/media-frags/';
|
|
6
5
|
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 +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,qCAAsC,WAAW,GAAG,MAAM,KAAG,CASzF,CAAA;AAED,eAAO,MAAM,oBAAoB,UAAW,KAAK,KAAG,WAiBnD,CAAA"}
|
|
@@ -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,4BAC9B,gBAAgB,eAAe,EAAE,CAAC,CAAC,KACxC,oBAAoB,oBAAoB,CAwC1C,CAAA;AAED,eAAO,MAAM,+BAA+B,4BACpC,gBAAgB,eAAe,EAAE,CAAC,CAAC,KACxC,yBASF,CAAA"}
|
|
@@ -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;
|
|
@@ -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;;;eA+CV,MAAM,KAAK,MAAM,KAAG,qBAAqB,GAAG,SAAS;yBAqB3C,MAAM,KAAK,MAAM,SAAS,MAAM,UAAU,MAAM;qBAvDpD,qBAAqB;qBASrB,qBAAqB;mBAYvB,qBAAqB,EAAE,YAAW,OAAO;;uBALrC,qBAAqB,WAAW,qBAAqB;CA6DhF,CAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Theme } from '../../AnnotoriousOpts';
|
|
1
2
|
export declare const sampleBrightness: (imageOrCanvas: HTMLElement) => number;
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const detectTheme: (imageOrCanvas: HTMLElement) => "dark" | "light";
|
|
4
|
+
export declare const setTheme: (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) => void;
|
|
3
5
|
//# 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.20",
|
|
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,22 +33,22 @@
|
|
|
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.0.2",
|
|
40
|
+
"@tsconfig/svelte": "^5.0.2",
|
|
41
|
+
"@types/rbush": "^3.0.3",
|
|
42
|
+
"jsdom": "^24.0.0",
|
|
43
|
+
"svelte": "^4.2.12",
|
|
44
|
+
"svelte-preprocess": "^5.1.3",
|
|
45
|
+
"typescript": "^5.3.3",
|
|
46
|
+
"vite": "^5.2.2",
|
|
47
|
+
"vite-plugin-dts": "^3.7.3",
|
|
48
|
+
"vitest": "^1.4.0"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
51
|
+
"@annotorious/core": "*",
|
|
52
52
|
"rbush": "^3.0.1",
|
|
53
53
|
"uuid": "^9.0.1"
|
|
54
54
|
}
|
package/src/Annotorious.css
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
cursor: move;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.a9s-
|
|
40
|
+
.a9s-handle {
|
|
41
41
|
cursor: move;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -57,18 +57,18 @@
|
|
|
57
57
|
cursor: w-resize;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.a9s-
|
|
60
|
+
.a9s-handle.a9s-corner-handle-topleft {
|
|
61
61
|
cursor: nw-resize;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.a9s-
|
|
64
|
+
.a9s-handle.a9s-corner-handle-topright {
|
|
65
65
|
cursor: ne-resize;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.a9s-
|
|
68
|
+
.a9s-handle.a9s-corner-handle-bottomright {
|
|
69
69
|
cursor: se-resize;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
.a9s-
|
|
72
|
+
.a9s-handle.a9s-corner-handle-bottomleft {
|
|
73
73
|
cursor: sw-resize;
|
|
74
74
|
}
|
package/src/Annotorious.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { SvelteComponent } from 'svelte';
|
|
2
|
-
import type
|
|
3
|
-
import { createAnonymousGuest, createBaseAnnotator, createLifecyleObserver } from '@annotorious/core';
|
|
2
|
+
import { PointerSelectAction, type Annotator, type DrawingStyle, type Filter, type User } from '@annotorious/core';
|
|
3
|
+
import { createAnonymousGuest, createBaseAnnotator, createLifecyleObserver, createUndoStack } from '@annotorious/core';
|
|
4
4
|
import { registerEditor } from './annotation/editors';
|
|
5
5
|
import { getTool, registerTool, listDrawingTools, type DrawingTool } from './annotation/tools';
|
|
6
6
|
import { SVGAnnotationLayer } from './annotation';
|
|
7
7
|
import type { DrawingToolOpts, SVGAnnotationLayerPointerEvent } from './annotation';
|
|
8
8
|
import type { ImageAnnotation, ShapeType } from './model';
|
|
9
9
|
import { createSvelteImageAnnotatorState } from './state';
|
|
10
|
-
import { setTheme } from './themes';
|
|
11
|
-
import { fillDefaults } from './AnnotoriousOpts';
|
|
10
|
+
import { setTheme as _setTheme } from './themes';
|
|
11
|
+
import { fillDefaults, type Theme } from './AnnotoriousOpts';
|
|
12
12
|
import type { AnnotoriousOpts } from './AnnotoriousOpts';
|
|
13
|
+
import { initKeyboardCommands } from './keyboardCommands';
|
|
13
14
|
|
|
14
15
|
import './Annotorious.css';
|
|
15
16
|
import './themes/dark/index.css';
|
|
@@ -23,10 +24,12 @@ export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Ann
|
|
|
23
24
|
|
|
24
25
|
registerShapeEditor(shapeType: ShapeType, editor: typeof SvelteComponent): void;
|
|
25
26
|
|
|
26
|
-
setDrawingTool(
|
|
27
|
+
setDrawingTool(name: DrawingTool): void;
|
|
27
28
|
|
|
28
29
|
setDrawingEnabled(enabled: boolean): void;
|
|
29
30
|
|
|
31
|
+
setTheme(theme: Theme): void;
|
|
32
|
+
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
@@ -40,16 +43,22 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
40
43
|
const img = (typeof image === 'string' ?
|
|
41
44
|
document.getElementById(image) : image) as HTMLImageElement | HTMLCanvasElement;
|
|
42
45
|
|
|
43
|
-
const opts = fillDefaults<ImageAnnotation, E>(options
|
|
46
|
+
const opts = fillDefaults<ImageAnnotation, E>(options, {
|
|
47
|
+
drawingEnabled: true,
|
|
48
|
+
drawingMode: 'drag',
|
|
49
|
+
pointerSelectAction: PointerSelectAction.EDIT,
|
|
50
|
+
theme: 'light'
|
|
51
|
+
});
|
|
44
52
|
|
|
45
53
|
const state = createSvelteImageAnnotatorState(opts);
|
|
46
54
|
|
|
47
|
-
const {
|
|
55
|
+
const { selection, store } = state;
|
|
48
56
|
|
|
49
|
-
const
|
|
50
|
-
store, selection, hover, undefined, opts.adapter, opts.autoSave);
|
|
57
|
+
const undoStack = createUndoStack(store);
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
const lifecycle = createLifecyleObserver<ImageAnnotation, E>(
|
|
60
|
+
state, undoStack, opts.adapter, opts.autoSave
|
|
61
|
+
);
|
|
53
62
|
|
|
54
63
|
// We'll wrap the image in a container DIV.
|
|
55
64
|
const container = document.createElement('DIV');
|
|
@@ -59,17 +68,21 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
59
68
|
// Wrapper div has unwanted margin at the bottom otherwise!
|
|
60
69
|
img.style.display = 'block';
|
|
61
70
|
|
|
62
|
-
img.parentNode
|
|
71
|
+
img.parentNode!.insertBefore(container, img);
|
|
63
72
|
container.appendChild(img);
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
const keyboardCommands = initKeyboardCommands(undoStack);
|
|
75
|
+
|
|
76
|
+
let currentUser: User = createAnonymousGuest();
|
|
77
|
+
|
|
78
|
+
_setTheme(img, container, opts.theme!);
|
|
66
79
|
|
|
67
80
|
const annotationLayer = new SVGAnnotationLayer({
|
|
68
81
|
target: container,
|
|
69
82
|
props: {
|
|
70
|
-
drawingEnabled: opts.drawingEnabled,
|
|
83
|
+
drawingEnabled: Boolean(opts.drawingEnabled),
|
|
71
84
|
image: img,
|
|
72
|
-
preferredDrawingMode: opts.drawingMode
|
|
85
|
+
preferredDrawingMode: opts.drawingMode!,
|
|
73
86
|
state,
|
|
74
87
|
style: opts.style,
|
|
75
88
|
user: currentUser
|
|
@@ -89,15 +102,19 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
89
102
|
/******++++++*************/
|
|
90
103
|
|
|
91
104
|
// Most of the external API functions are covered in the base annotator
|
|
92
|
-
const base = createBaseAnnotator<ImageAnnotation, E>(
|
|
105
|
+
const base = createBaseAnnotator<ImageAnnotation, E>(state, undoStack, opts.adapter);
|
|
93
106
|
|
|
94
107
|
const destroy = () => {
|
|
95
108
|
// Destroy Svelte annotation layer
|
|
96
109
|
annotationLayer.$destroy();
|
|
97
110
|
|
|
98
111
|
// Unwrap the image
|
|
99
|
-
container.parentNode
|
|
100
|
-
container.parentNode
|
|
112
|
+
container.parentNode!.insertBefore(img, container);
|
|
113
|
+
container.parentNode!.removeChild(container);
|
|
114
|
+
|
|
115
|
+
// Other cleanup actions
|
|
116
|
+
keyboardCommands.destroy();
|
|
117
|
+
undoStack.destroy();
|
|
101
118
|
}
|
|
102
119
|
|
|
103
120
|
const getUser = () => currentUser;
|
|
@@ -108,10 +125,14 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
108
125
|
const registerShapeEditor = (shapeType: ShapeType, editor: typeof SvelteComponent) =>
|
|
109
126
|
registerEditor(shapeType, editor);
|
|
110
127
|
|
|
111
|
-
const setDrawingTool = (
|
|
112
|
-
|
|
128
|
+
const setDrawingTool = (name: DrawingTool) => {
|
|
129
|
+
// Validate that the tool exists
|
|
130
|
+
const toolSpec = getTool(name);
|
|
131
|
+
if (!toolSpec)
|
|
132
|
+
throw `No drawing tool named ${name}`;
|
|
133
|
+
|
|
113
134
|
// @ts-ignore
|
|
114
|
-
annotationLayer.$set({
|
|
135
|
+
annotationLayer.$set({ toolName: name })
|
|
115
136
|
}
|
|
116
137
|
|
|
117
138
|
const setDrawingEnabled = (enabled: boolean) =>
|
|
@@ -121,17 +142,11 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
121
142
|
console.warn('Filter not implemented yet');
|
|
122
143
|
}
|
|
123
144
|
|
|
124
|
-
const setSelected = (arg?: string | string[]) => {
|
|
125
|
-
if (arg) {
|
|
126
|
-
selection.setSelected(arg);
|
|
127
|
-
} else {
|
|
128
|
-
selection.clear();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
145
|
const setStyle = (style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) | undefined) =>
|
|
133
146
|
annotationLayer.$set({ style });
|
|
134
147
|
|
|
148
|
+
const setTheme = (theme: Theme) => _setTheme(img, container, theme);
|
|
149
|
+
|
|
135
150
|
const setUser = (user: User) => {
|
|
136
151
|
currentUser = user;
|
|
137
152
|
annotationLayer.$set({ user });
|
|
@@ -149,8 +164,8 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
149
164
|
setDrawingEnabled,
|
|
150
165
|
setDrawingTool,
|
|
151
166
|
setFilter,
|
|
152
|
-
setSelected,
|
|
153
167
|
setStyle,
|
|
168
|
+
setTheme,
|
|
154
169
|
setUser,
|
|
155
170
|
state
|
|
156
171
|
}
|
package/src/AnnotoriousOpts.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PointerSelectAction } from '@annotorious/core';
|
|
2
|
-
import type { Annotation, DrawingStyle, FormatAdapter } from '@annotorious/core';
|
|
1
|
+
import type { Annotation, DrawingStyle, FormatAdapter, PointerSelectAction } 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> {
|
|
@@ -18,19 +17,25 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E exten
|
|
|
18
17
|
|
|
19
18
|
style?: DrawingStyle | ((annotation: I) => DrawingStyle);
|
|
20
19
|
|
|
20
|
+
theme?: Theme;
|
|
21
|
+
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export type DrawingMode = 'click' | 'drag';
|
|
24
25
|
|
|
26
|
+
export type Theme = 'dark' | 'light' | 'auto';
|
|
27
|
+
|
|
25
28
|
export const fillDefaults = <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
|
|
26
|
-
opts: AnnotoriousOpts<I, E
|
|
29
|
+
opts: AnnotoriousOpts<I, E>,
|
|
30
|
+
defaults: AnnotoriousOpts<I, E>
|
|
27
31
|
): AnnotoriousOpts<I, E> => {
|
|
28
32
|
|
|
29
33
|
return {
|
|
30
34
|
...opts,
|
|
31
|
-
drawingEnabled: opts.drawingEnabled === undefined ?
|
|
32
|
-
drawingMode: opts.drawingMode ||
|
|
33
|
-
pointerSelectAction: opts.pointerSelectAction ||
|
|
35
|
+
drawingEnabled: opts.drawingEnabled === undefined ? defaults.drawingEnabled : opts.drawingEnabled,
|
|
36
|
+
drawingMode: opts.drawingMode || defaults.drawingMode,
|
|
37
|
+
pointerSelectAction: opts.pointerSelectAction || defaults.pointerSelectAction,
|
|
38
|
+
theme: opts.theme || defaults.theme
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SvelteComponent, onMount } from 'svelte';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import type { DrawingStyle, StoreChangeEvent, User } from '@annotorious/core';
|
|
5
5
|
import { ShapeType } from '../model';
|
|
6
6
|
import type { ImageAnnotation, Shape} from '../model';
|
|
7
|
-
import { getEditor, EditorMount } from './editors';
|
|
7
|
+
import { getEditor as _getEditor, EditorMount } from './editors';
|
|
8
8
|
import { Ellipse, Polygon, Rectangle} from './shapes';
|
|
9
|
-
import { getTool, ToolMount } from './tools';
|
|
9
|
+
import { getTool, listDrawingTools, ToolMount } from './tools';
|
|
10
10
|
import { enableResponsive } from './utils';
|
|
11
11
|
import { createSVGTransform } from './Transform';
|
|
12
12
|
import { addEventListeners } from './SVGAnnotationLayerPointerEvent';
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
export let image: HTMLImageElement | HTMLCanvasElement;
|
|
19
19
|
export let preferredDrawingMode: DrawingMode;
|
|
20
20
|
export let state: SvelteImageAnnotatorState;
|
|
21
|
-
export let style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) = undefined;
|
|
22
|
-
export let
|
|
21
|
+
export let style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) | undefined = undefined;
|
|
22
|
+
export let toolName: string = listDrawingTools()[0];
|
|
23
23
|
export let user: User;
|
|
24
24
|
|
|
25
|
+
$: ({ tool, opts } = getTool(toolName) || { tool: undefined, opts: undefined });
|
|
26
|
+
|
|
25
27
|
$: drawingMode = opts?.drawingMode || preferredDrawingMode;
|
|
26
28
|
|
|
27
29
|
/** Drawing tool layer **/
|
|
@@ -41,16 +43,17 @@
|
|
|
41
43
|
|
|
42
44
|
$: ({ onPointerDown, onPointerUp } = addEventListeners(svgEl, store));
|
|
43
45
|
|
|
44
|
-
let storeObserver
|
|
46
|
+
let storeObserver: (event: StoreChangeEvent<ImageAnnotation>) => void | undefined;
|
|
45
47
|
|
|
46
|
-
let editableAnnotations: ImageAnnotation[]
|
|
48
|
+
let editableAnnotations: ImageAnnotation[] | undefined;
|
|
47
49
|
|
|
48
50
|
$: isEditable = (a: ImageAnnotation) => $selection.selected.find(s => s.id === a.id && s.editable);
|
|
49
51
|
|
|
50
52
|
$: trackSelection($selection.selected);
|
|
51
53
|
|
|
52
54
|
const trackSelection = (selected: { id: string, editable?: boolean }[]) => {
|
|
53
|
-
|
|
55
|
+
if (storeObserver)
|
|
56
|
+
store.unobserve(storeObserver);
|
|
54
57
|
|
|
55
58
|
// Track only editable annotations
|
|
56
59
|
const editableIds =
|
|
@@ -58,17 +61,17 @@
|
|
|
58
61
|
|
|
59
62
|
if (editableIds.length > 0) {
|
|
60
63
|
// Resolve selected IDs from the store
|
|
61
|
-
editableAnnotations = editableIds.map(id => store.getAnnotation(id));
|
|
64
|
+
editableAnnotations = editableIds.map(id => store.getAnnotation(id)!).filter(Boolean);
|
|
62
65
|
|
|
63
66
|
// Track updates on the editable annotations
|
|
64
67
|
storeObserver = (event: StoreChangeEvent<ImageAnnotation>) => {
|
|
65
68
|
const { updated } = event.changes;
|
|
66
|
-
editableAnnotations = updated
|
|
69
|
+
editableAnnotations = updated?.map(change => change.newValue);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
store.observe(storeObserver, { annotations: editableIds });
|
|
70
73
|
} else {
|
|
71
|
-
editableAnnotations =
|
|
74
|
+
editableAnnotations = undefined;
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
|
|
@@ -106,10 +109,13 @@
|
|
|
106
109
|
...target,
|
|
107
110
|
selector: event.detail,
|
|
108
111
|
created: isUpdate ? target.created : new Date(),
|
|
109
|
-
updated: isUpdate ? new Date() :
|
|
110
|
-
updatedBy: isUpdate ? user :
|
|
112
|
+
updated: isUpdate ? new Date() : undefined,
|
|
113
|
+
updatedBy: isUpdate ? user : undefined
|
|
111
114
|
});
|
|
112
115
|
}
|
|
116
|
+
|
|
117
|
+
// To get around lack of TypeScript support in Svelte markup
|
|
118
|
+
const getEditor = (shape: Shape): typeof SvelteComponent => _getEditor(shape)!;
|
|
113
119
|
</script>
|
|
114
120
|
|
|
115
121
|
<svg
|
|
@@ -154,7 +160,7 @@
|
|
|
154
160
|
{/key}
|
|
155
161
|
{/each}
|
|
156
162
|
{:else if (tool && drawingEnabled)}
|
|
157
|
-
{#key
|
|
163
|
+
{#key toolName}
|
|
158
164
|
<ToolMount
|
|
159
165
|
target={drawingEl}
|
|
160
166
|
tool={tool}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createEventDispatcher } from 'svelte';
|
|
2
2
|
import type { SvelteImageAnnotationStore } from '../state';
|
|
3
3
|
import type { ImageAnnotation } from '../model';
|
|
4
|
-
import { isTouch } from './utils';
|
|
5
4
|
|
|
6
5
|
export interface SVGAnnotationLayerPointerEvent {
|
|
7
6
|
|
|
@@ -51,5 +50,5 @@ const getSVGPoint = (evt: PointerEvent, svg: SVGSVGElement) => {
|
|
|
51
50
|
pt.x = x + left;
|
|
52
51
|
pt.y = y + top;
|
|
53
52
|
|
|
54
|
-
return pt.matrixTransform(svg.getScreenCTM()
|
|
53
|
+
return pt.matrixTransform(svg.getScreenCTM()!.inverse());
|
|
55
54
|
}
|
|
@@ -13,11 +13,13 @@ export const IdentityTransform: Transform = {
|
|
|
13
13
|
export const createSVGTransform = (svg: SVGSVGElement): Transform => ({
|
|
14
14
|
|
|
15
15
|
elementToImage: (offsetX: number, offsetY: number) => {
|
|
16
|
+
const bbox = svg.getBoundingClientRect();
|
|
17
|
+
|
|
16
18
|
const pt = svg.createSVGPoint();
|
|
17
|
-
pt.x = offsetX;
|
|
18
|
-
pt.y = offsetY;
|
|
19
|
+
pt.x = offsetX + bbox.x;
|
|
20
|
+
pt.y = offsetY + bbox.y;
|
|
19
21
|
|
|
20
|
-
const { x, y } = pt.matrixTransform(svg.
|
|
22
|
+
const { x, y } = pt.matrixTransform(svg.getScreenCTM()!.inverse());
|
|
21
23
|
return [x, y];
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import type { Shape } from '../../model';
|
|
4
|
-
import type { Handle } from './Handle';
|
|
5
4
|
import type { Transform } from '../Transform';
|
|
6
5
|
|
|
7
|
-
const dispatch = createEventDispatcher<{ grab:
|
|
6
|
+
const dispatch = createEventDispatcher<{ grab: PointerEvent, release: PointerEvent, change: Shape }>();
|
|
8
7
|
|
|
9
8
|
/** Props */
|
|
10
9
|
export let shape: Shape;
|
|
11
|
-
export let editor: (shape: Shape, handle:
|
|
10
|
+
export let editor: (shape: Shape, handle: string, delta: [number, number]) => Shape;
|
|
12
11
|
export let transform: Transform;
|
|
13
12
|
|
|
14
|
-
let grabbedHandle:
|
|
13
|
+
let grabbedHandle: string | undefined;
|
|
15
14
|
|
|
16
15
|
let origin: [number, number];
|
|
17
16
|
|
|
18
|
-
let initialShape: Shape
|
|
17
|
+
let initialShape: Shape | undefined;
|
|
19
18
|
|
|
20
|
-
const onGrab = (handle:
|
|
19
|
+
const onGrab = (handle: string) => (evt: PointerEvent) => {
|
|
21
20
|
grabbedHandle = handle;
|
|
22
21
|
origin = transform.elementToImage(evt.offsetX, evt.offsetY);
|
|
23
22
|
initialShape = shape;
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
const target = evt.target as Element;
|
|
26
25
|
target.setPointerCapture(evt.pointerId);
|
|
27
26
|
|
|
28
|
-
dispatch('grab');
|
|
27
|
+
dispatch('grab', evt);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
const onPointerMove = (evt: PointerEvent) => {
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
|
|
35
34
|
const delta: [number, number] = [x - origin[0], y - origin[1]];
|
|
36
35
|
|
|
37
|
-
shape = editor(initialShape
|
|
36
|
+
shape = editor(initialShape!, grabbedHandle, delta);
|
|
38
37
|
|
|
39
38
|
dispatch('change', shape);
|
|
40
39
|
}
|
|
@@ -44,11 +43,11 @@
|
|
|
44
43
|
const target = evt.target as Element;
|
|
45
44
|
target.releasePointerCapture(evt.pointerId);
|
|
46
45
|
|
|
47
|
-
grabbedHandle =
|
|
46
|
+
grabbedHandle = undefined;
|
|
48
47
|
|
|
49
48
|
initialShape = shape;
|
|
50
49
|
|
|
51
|
-
dispatch('release');
|
|
50
|
+
dispatch('release', evt);
|
|
52
51
|
}
|
|
53
52
|
</script>
|
|
54
53
|
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import { computeStyle } from '../utils/styling';
|
|
6
6
|
import type { Transform } from '../Transform';
|
|
7
7
|
|
|
8
|
-
const dispatch = createEventDispatcher<{ grab:
|
|
8
|
+
const dispatch = createEventDispatcher<{ grab: PointerEvent, release: PointerEvent, change: Shape }>();
|
|
9
9
|
|
|
10
10
|
/** Props */
|
|
11
11
|
export let annotation: ImageAnnotation;
|
|
12
12
|
export let editor: typeof SvelteComponent;
|
|
13
|
-
export let style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle)
|
|
13
|
+
export let style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) | undefined;
|
|
14
14
|
export let target: SVGGElement;
|
|
15
15
|
export let transform: Transform;
|
|
16
16
|
export let viewportScale: number;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
$: computedStyle = computeStyle(annotation, style);
|
|
21
21
|
|
|
22
|
+
$: if (annotation) editorComponent?.$set({ shape: annotation.target.selector });
|
|
22
23
|
$: if (editorComponent) editorComponent.$set({ transform });
|
|
23
|
-
|
|
24
24
|
$: if (editorComponent) editorComponent.$set({ viewportScale });
|
|
25
25
|
|
|
26
26
|
onMount(() => {
|