@annotorious/annotorious 3.0.0-rc.14 → 3.0.0-rc.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotorious.d.ts +1 -1
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousOpts.d.ts +2 -3
- package/dist/AnnotoriousOpts.d.ts.map +1 -1
- package/dist/annotorious.es.js +1070 -1046
- package/dist/annotorious.es.js.map +1 -1
- package/dist/annotorious.js +1 -1
- package/dist/annotorious.js.map +1 -1
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Annotorious.ts +7 -2
- package/src/AnnotoriousOpts.ts +7 -7
- package/src/model/w3c/W3CImageFormatAdapter.ts +28 -9
|
@@ -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;AAMlE,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AAElF,eAAO,MAAM,cAAc,WACjB,MAAM,YACL,OAAO,0BAUjB,CAAA;AAED,eAAO,MAAM,uBAAuB,eACtB,aAAa,YAChB,OAAO,KACf,YAAY,eAAe,
|
|
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;AAMlE,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AAElF,eAAO,MAAM,cAAc,WACjB,MAAM,YACL,OAAO,0BAUjB,CAAA;AAED,eAAO,MAAM,uBAAuB,eACtB,aAAa,YAChB,OAAO,KACf,YAAY,eAAe,CAyC7B,CAAA;AAED,eAAO,MAAM,2BAA2B,eAC1B,eAAe,UACnB,MAAM,KACb,aA6BF,CAAC"}
|
package/package.json
CHANGED
package/src/Annotorious.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SvelteComponent } from 'svelte';
|
|
2
|
-
import type
|
|
2
|
+
import { PointerSelectAction, type Annotator, type DrawingStyle, type Filter, type User } from '@annotorious/core';
|
|
3
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';
|
|
@@ -43,7 +43,12 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
43
43
|
const img = (typeof image === 'string' ?
|
|
44
44
|
document.getElementById(image) : image) as HTMLImageElement | HTMLCanvasElement;
|
|
45
45
|
|
|
46
|
-
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
|
+
});
|
|
47
52
|
|
|
48
53
|
const state = createSvelteImageAnnotatorState(opts);
|
|
49
54
|
|
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> {
|
|
@@ -27,15 +26,16 @@ 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
|
|
29
|
+
opts: AnnotoriousOpts<I, E>,
|
|
30
|
+
defaults: AnnotoriousOpts<I, E>
|
|
31
31
|
): AnnotoriousOpts<I, E> => {
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
34
|
...opts,
|
|
35
|
-
drawingEnabled: opts.drawingEnabled === undefined ?
|
|
36
|
-
drawingMode: opts.drawingMode ||
|
|
37
|
-
pointerSelectAction: opts.pointerSelectAction ||
|
|
38
|
-
theme: opts.theme ||
|
|
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
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { parseW3CBodies, serializeW3CBodies } from '@annotorious/core';
|
|
2
|
+
import { parseW3CUser, parseW3CBodies, serializeW3CBodies } from '@annotorious/core';
|
|
3
3
|
import type { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
|
|
4
4
|
import { ShapeType } from '../core';
|
|
5
5
|
import type { ImageAnnotation, RectangleGeometry } from '../core';
|
|
@@ -30,7 +30,14 @@ export const parseW3CImageAnnotation = (
|
|
|
30
30
|
): ParseResult<ImageAnnotation> => {
|
|
31
31
|
const annotationId = annotation.id || uuidv4();
|
|
32
32
|
|
|
33
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
creator,
|
|
35
|
+
created,
|
|
36
|
+
updatedBy,
|
|
37
|
+
updated,
|
|
38
|
+
body,
|
|
39
|
+
...rest
|
|
40
|
+
} = annotation;
|
|
34
41
|
|
|
35
42
|
const bodies = parseW3CBodies(body, annotationId);
|
|
36
43
|
|
|
@@ -50,6 +57,8 @@ export const parseW3CImageAnnotation = (
|
|
|
50
57
|
id: annotationId,
|
|
51
58
|
bodies,
|
|
52
59
|
target: {
|
|
60
|
+
created: created ? new Date(created) : undefined,
|
|
61
|
+
creator: parseW3CUser(creator),
|
|
53
62
|
...rest.target,
|
|
54
63
|
annotation: annotationId,
|
|
55
64
|
selector
|
|
@@ -65,12 +74,19 @@ export const serializeW3CImageAnnotation = (
|
|
|
65
74
|
annotation: ImageAnnotation,
|
|
66
75
|
source: string
|
|
67
76
|
): W3CAnnotation => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
const {
|
|
78
|
+
selector,
|
|
79
|
+
creator,
|
|
80
|
+
created,
|
|
81
|
+
updated,
|
|
82
|
+
updatedBy,
|
|
83
|
+
...rest
|
|
84
|
+
} = annotation.target;
|
|
85
|
+
|
|
86
|
+
const w3CSelector =
|
|
87
|
+
selector.type == ShapeType.RECTANGLE ?
|
|
88
|
+
serializeFragmentSelector(selector.geometry as RectangleGeometry) :
|
|
89
|
+
serializeSVGSelector(selector);
|
|
74
90
|
|
|
75
91
|
return {
|
|
76
92
|
...annotation,
|
|
@@ -78,9 +94,12 @@ export const serializeW3CImageAnnotation = (
|
|
|
78
94
|
id: annotation.id,
|
|
79
95
|
type: 'Annotation',
|
|
80
96
|
body: serializeW3CBodies(annotation.bodies),
|
|
97
|
+
creator,
|
|
98
|
+
created: created?.toISOString(),
|
|
81
99
|
target: {
|
|
100
|
+
...rest,
|
|
82
101
|
source,
|
|
83
|
-
selector
|
|
102
|
+
selector: w3CSelector
|
|
84
103
|
}
|
|
85
104
|
};
|
|
86
105
|
};
|