@annotorious/annotorious 3.0.0-rc.20 → 3.0.0-rc.3
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 +2 -7
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousOpts.d.ts +3 -4
- package/dist/AnnotoriousOpts.d.ts.map +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +1 -1
- package/dist/annotation/editors/Handle.d.ts +14 -0
- package/dist/annotation/editors/Handle.d.ts.map +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 +1 -2
- 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 +2087 -2359
- 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 +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/keyboardCommands.d.ts +2 -2
- package/dist/keyboardCommands.d.ts.map +1 -1
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +2 -3
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +2 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +1 -1
- package/dist/model/w3c/index.d.ts +0 -1
- 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 +2 -1
- 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 +1 -3
- 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 +28 -34
- package/src/AnnotoriousOpts.ts +6 -11
- package/src/annotation/SVGAnnotationLayer.svelte +15 -21
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +2 -1
- package/src/annotation/Transform.ts +1 -1
- package/src/annotation/editors/Editor.svelte +11 -10
- package/src/annotation/editors/EditorMount.svelte +2 -2
- package/src/annotation/editors/Handle.ts +21 -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 +43 -46
- package/src/annotation/shapes/Ellipse.svelte +2 -2
- package/src/annotation/shapes/Polygon.svelte +2 -2
- package/src/annotation/shapes/Rectangle.svelte +2 -2
- package/src/annotation/tools/ToolMount.svelte +3 -3
- package/src/annotation/tools/drawingToolsRegistry.ts +1 -2
- package/src/annotation/tools/polygon/RubberbandPolygon.svelte +13 -40
- package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +10 -16
- package/src/annotation/utils/responsive.ts +1 -1
- package/src/annotation/utils/touch.ts +1 -4
- package/src/index.ts +16 -23
- package/src/keyboardCommands.ts +7 -11
- package/src/model/w3c/W3CImageFormatAdapter.ts +21 -53
- package/src/model/w3c/fragment/FragmentSelector.ts +6 -5
- package/src/model/w3c/index.ts +0 -1
- package/src/model/w3c/svg/SVG.ts +2 -1
- package/src/model/w3c/svg/SVGSelector.ts +13 -11
- package/src/state/ImageAnnotatorState.ts +3 -3
- package/src/state/spatialTree.ts +2 -3
- package/src/themes/dark/index.css +2 -2
- package/src/themes/light/index.css +2 -2
- package/src/themes/smart/setTheme.ts +6 -10
- package/dist/annotation/editors/Handle.svelte.d.ts +0 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts +0 -11
- package/dist/model/w3c/W3CImageAnnotation.d.ts.map +0 -1
- package/src/annotation/editors/Handle.svelte +0 -66
- package/src/model/w3c/W3CImageAnnotation.ts +0 -17
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import {
|
|
2
|
+
import { 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';
|
|
6
|
-
import type {FragmentSelector } from './fragment';
|
|
6
|
+
import type { FragmentSelector } from './fragment';
|
|
7
7
|
import { parseFragmentSelector, serializeFragmentSelector } from './fragment';
|
|
8
8
|
import type { SVGSelector } from './svg';
|
|
9
9
|
import { parseSVGSelector, serializeSVGSelector } from './svg';
|
|
10
|
-
import type { W3CImageAnnotation } from './W3CImageAnnotation';
|
|
11
10
|
|
|
12
|
-
export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation,
|
|
11
|
+
export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CAnnotation>;
|
|
13
12
|
|
|
14
13
|
export const W3CImageFormat = (
|
|
15
14
|
source: string,
|
|
@@ -31,26 +30,18 @@ export const parseW3CImageAnnotation = (
|
|
|
31
30
|
): ParseResult<ImageAnnotation> => {
|
|
32
31
|
const annotationId = annotation.id || uuidv4();
|
|
33
32
|
|
|
34
|
-
const {
|
|
35
|
-
creator,
|
|
36
|
-
created,
|
|
37
|
-
modified,
|
|
38
|
-
body,
|
|
39
|
-
...rest
|
|
40
|
-
} = annotation;
|
|
33
|
+
const { body, ...rest } = annotation;
|
|
41
34
|
|
|
42
35
|
const bodies = parseW3CBodies(body, annotationId);
|
|
43
36
|
|
|
44
|
-
const
|
|
45
|
-
? annotation.target[0] : annotation.target;
|
|
37
|
+
const target = Array.isArray(annotation.target) ? annotation.target[0] : annotation.target;
|
|
46
38
|
|
|
47
|
-
const w3cSelector = Array.isArray(
|
|
48
|
-
? w3cTarget.selector[0] : w3cTarget.selector;
|
|
39
|
+
const w3cSelector = Array.isArray(target.selector) ? target.selector[0] : target.selector;
|
|
49
40
|
|
|
50
41
|
const selector =
|
|
51
|
-
w3cSelector
|
|
42
|
+
w3cSelector.type === 'FragmentSelector' ?
|
|
52
43
|
parseFragmentSelector(w3cSelector as FragmentSelector, invertY) :
|
|
53
|
-
w3cSelector
|
|
44
|
+
w3cSelector.type === 'SvgSelector' ?
|
|
54
45
|
parseSVGSelector(w3cSelector as SVGSelector) : undefined;
|
|
55
46
|
|
|
56
47
|
return selector ? {
|
|
@@ -59,16 +50,12 @@ export const parseW3CImageAnnotation = (
|
|
|
59
50
|
id: annotationId,
|
|
60
51
|
bodies,
|
|
61
52
|
target: {
|
|
62
|
-
created: created ? new Date(created) : undefined,
|
|
63
|
-
creator: parseW3CUser(creator),
|
|
64
|
-
updated: modified ? new Date(modified) : undefined,
|
|
65
|
-
...(Array.isArray(rest.target) ? rest.target[0] : rest.target),
|
|
66
53
|
annotation: annotationId,
|
|
67
54
|
selector
|
|
68
55
|
}
|
|
69
56
|
}
|
|
70
57
|
} : {
|
|
71
|
-
error: Error(`
|
|
58
|
+
error: Error(`Unknown selector type: ${selector.type}`)
|
|
72
59
|
};
|
|
73
60
|
|
|
74
61
|
}
|
|
@@ -76,42 +63,23 @@ export const parseW3CImageAnnotation = (
|
|
|
76
63
|
export const serializeW3CImageAnnotation = (
|
|
77
64
|
annotation: ImageAnnotation,
|
|
78
65
|
source: string
|
|
79
|
-
):
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const w3CSelector =
|
|
90
|
-
selector.type == ShapeType.RECTANGLE ?
|
|
91
|
-
serializeFragmentSelector(selector.geometry as RectangleGeometry) :
|
|
92
|
-
serializeSVGSelector(selector);
|
|
93
|
-
|
|
94
|
-
const serialized = {
|
|
66
|
+
): W3CAnnotation => {
|
|
67
|
+
const shape = annotation.target.selector;
|
|
68
|
+
|
|
69
|
+
const selector =
|
|
70
|
+
shape.type == ShapeType.RECTANGLE ?
|
|
71
|
+
serializeFragmentSelector(shape.geometry as RectangleGeometry) :
|
|
72
|
+
serializeSVGSelector(shape);
|
|
73
|
+
|
|
74
|
+
return {
|
|
95
75
|
...annotation,
|
|
96
76
|
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
|
97
77
|
id: annotation.id,
|
|
98
78
|
type: 'Annotation',
|
|
99
79
|
body: serializeW3CBodies(annotation.bodies),
|
|
100
|
-
created: created?.toISOString(),
|
|
101
|
-
creator,
|
|
102
|
-
modified: updated?.toISOString(),
|
|
103
80
|
target: {
|
|
104
|
-
...rest,
|
|
105
81
|
source,
|
|
106
|
-
selector
|
|
82
|
+
selector
|
|
107
83
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Remove core properties that should not appear in the W3C annotation
|
|
111
|
-
delete serialized.bodies;
|
|
112
|
-
|
|
113
|
-
if ('annotation' in serialized.target)
|
|
114
|
-
delete serialized.target.annotation;
|
|
115
|
-
|
|
116
|
-
return serialized;
|
|
117
|
-
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { W3CSelector } from '@annotorious/core';
|
|
2
2
|
import { ShapeType } from '../../core';
|
|
3
|
+
import type { Rectangle, RectangleGeometry } from '../../core';
|
|
3
4
|
|
|
4
|
-
export interface FragmentSelector {
|
|
5
|
+
export interface FragmentSelector extends W3CSelector {
|
|
5
6
|
|
|
6
7
|
type: 'FragmentSelector';
|
|
7
8
|
|
|
8
9
|
conformsTo: 'http://www.w3.org/TR/media-frags/',
|
|
9
10
|
|
|
10
11
|
value: string;
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const parseFragmentSelector = (
|
|
@@ -45,7 +46,7 @@ export const parseFragmentSelector = (
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
+
};
|
|
49
50
|
|
|
50
51
|
export const serializeFragmentSelector = (geometry: RectangleGeometry): FragmentSelector => {
|
|
51
52
|
const { x, y, w, h } = geometry;
|
|
@@ -55,4 +56,4 @@ export const serializeFragmentSelector = (geometry: RectangleGeometry): Fragment
|
|
|
55
56
|
conformsTo: 'http://www.w3.org/TR/media-frags/',
|
|
56
57
|
value: `xywh=pixel:${x},${y},${w},${h}`
|
|
57
58
|
};
|
|
58
|
-
}
|
|
59
|
+
};
|
package/src/model/w3c/index.ts
CHANGED
package/src/model/w3c/svg/SVG.ts
CHANGED
|
@@ -13,7 +13,8 @@ export const sanitize = (doc: Element | Document) => {
|
|
|
13
13
|
// Remove script tags
|
|
14
14
|
const scripts = doc.getElementsByTagName('script');
|
|
15
15
|
|
|
16
|
-
Array.from(scripts).reverse().forEach(el =>
|
|
16
|
+
Array.from(scripts).reverse().forEach(el =>
|
|
17
|
+
el.parentNode.removeChild(el));
|
|
17
18
|
|
|
18
19
|
Array.from(doc.querySelectorAll('*')).forEach(cleanEl);
|
|
19
20
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { W3CSelector } from '@annotorious/core';
|
|
2
2
|
import { boundsFromPoints, ShapeType } from '../../core';
|
|
3
|
-
import {
|
|
3
|
+
import type { Ellipse, EllipseGeometry, Polygon, PolygonGeometry, Shape } from '../../core';
|
|
4
|
+
import { SVG_NAMESPACE, insertSVGNamespace, sanitize } from './SVG';
|
|
4
5
|
|
|
5
|
-
export interface SVGSelector {
|
|
6
|
+
export interface SVGSelector extends W3CSelector {
|
|
6
7
|
|
|
7
8
|
type: 'SvgSelector';
|
|
8
9
|
|
|
9
10
|
value: string;
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const parseSVGXML = (value: string): Element => {
|
|
@@ -28,6 +29,9 @@ const parseSVGXML = (value: string): Element => {
|
|
|
28
29
|
|
|
29
30
|
const parseSVGPolygon = (value: string): Polygon => {
|
|
30
31
|
const [a, b, str] = value.match(/(<polygon points=["|'])([^("|')]*)/) || [];
|
|
32
|
+
|
|
33
|
+
if (!str) return;
|
|
34
|
+
|
|
31
35
|
const points = str.split(' ').map((p) => p.split(',').map(parseFloat));
|
|
32
36
|
|
|
33
37
|
return {
|
|
@@ -42,10 +46,10 @@ const parseSVGPolygon = (value: string): Polygon => {
|
|
|
42
46
|
const parseSVGEllipse = (value: string): Ellipse => {
|
|
43
47
|
const doc = parseSVGXML(value);
|
|
44
48
|
|
|
45
|
-
const cx = parseFloat(doc.getAttribute('cx')
|
|
46
|
-
const cy = parseFloat(doc.getAttribute('cy')
|
|
47
|
-
const rx = parseFloat(doc.getAttribute('rx')
|
|
48
|
-
const ry = parseFloat(doc.getAttribute('ry')
|
|
49
|
+
const cx = parseFloat(doc.getAttribute('cx'));
|
|
50
|
+
const cy = parseFloat(doc.getAttribute('cy'));
|
|
51
|
+
const rx = parseFloat(doc.getAttribute('rx'));
|
|
52
|
+
const ry = parseFloat(doc.getAttribute('ry'));
|
|
49
53
|
|
|
50
54
|
const bounds = {
|
|
51
55
|
minX: cx - rx,
|
|
@@ -73,12 +77,10 @@ export const parseSVGSelector = <T extends Shape>(valueOrSelector: SVGSelector |
|
|
|
73
77
|
return parseSVGPolygon(value) as unknown as T;
|
|
74
78
|
else if (value.includes('<ellipse '))
|
|
75
79
|
return parseSVGEllipse(value) as unknown as T;
|
|
76
|
-
else
|
|
77
|
-
throw 'Unsupported SVG shape: ' + value;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
export const serializeSVGSelector = (shape: Shape): SVGSelector => {
|
|
81
|
-
let value: string
|
|
83
|
+
let value: string;
|
|
82
84
|
|
|
83
85
|
if (shape.type === ShapeType.POLYGON) {
|
|
84
86
|
const geom = shape.geometry as PolygonGeometry;
|
|
@@ -44,11 +44,11 @@ export const createImageAnnotatorState = <E extends unknown>(
|
|
|
44
44
|
const viewport = createViewportState();
|
|
45
45
|
|
|
46
46
|
store.observe(({ changes }) => {
|
|
47
|
-
tree.set(
|
|
47
|
+
tree.set(changes.created.map(a => a.target as ImageAnnotationTarget), false);
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
changes.deleted.forEach(a => tree.remove(a.target as ImageAnnotationTarget));
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
changes.updated.forEach(({ oldValue, newValue }) =>
|
|
52
52
|
tree.update(oldValue.target, newValue.target));
|
|
53
53
|
});
|
|
54
54
|
|
package/src/state/spatialTree.ts
CHANGED
|
@@ -40,8 +40,7 @@ export const createSpatialTree = () => {
|
|
|
40
40
|
|
|
41
41
|
const remove = (target: ImageAnnotationTarget) => {
|
|
42
42
|
const item = index.get(target.annotation);
|
|
43
|
-
|
|
44
|
-
tree.remove(item);
|
|
43
|
+
tree.remove(item);
|
|
45
44
|
index.delete(target.annotation);
|
|
46
45
|
};
|
|
47
46
|
|
|
@@ -63,7 +62,7 @@ export const createSpatialTree = () => {
|
|
|
63
62
|
tree.load(indexedTargets);
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
const getAt = (x: number, y: number): ImageAnnotationTarget |
|
|
65
|
+
const getAt = (x: number, y: number): ImageAnnotationTarget | null => {
|
|
67
66
|
const idxHits = tree.search({
|
|
68
67
|
minX: x,
|
|
69
68
|
minY: y,
|
|
@@ -11,8 +11,8 @@ div[data-theme="dark"] .a9s-annotationlayer .a9s-inner {
|
|
|
11
11
|
stroke-width: 1px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
rect.a9s-handle,
|
|
15
|
-
div[data-theme="dark"] rect.a9s-handle {
|
|
14
|
+
rect.a9s-corner-handle,
|
|
15
|
+
div[data-theme="dark"] rect.a9s-corner-handle {
|
|
16
16
|
fill: #000;
|
|
17
17
|
rx: 2px;
|
|
18
18
|
}
|
|
@@ -13,8 +13,8 @@ div[data-theme="light"] .a9s-annotationlayer .a9s-inner {
|
|
|
13
13
|
stroke-width: 1.5px;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
rect.a9s-handle,
|
|
17
|
-
div[data-theme="light"] rect.a9s-handle {
|
|
16
|
+
rect.a9s-corner-handle,
|
|
17
|
+
div[data-theme="light"] rect.a9s-corner-handle {
|
|
18
18
|
fill: #fff;
|
|
19
19
|
rx: 1px;
|
|
20
20
|
stroke: rgba(0, 0, 0, 0.45);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Theme } from '../../AnnotoriousOpts';
|
|
2
|
-
|
|
3
1
|
export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
4
2
|
|
|
5
3
|
let canvas: HTMLCanvasElement;
|
|
@@ -8,7 +6,7 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
8
6
|
|
|
9
7
|
if (imageOrCanvas.nodeName === 'CANVAS') {
|
|
10
8
|
canvas = imageOrCanvas as HTMLCanvasElement;
|
|
11
|
-
context = canvas.getContext('2d', { willReadFrequently: true })
|
|
9
|
+
context = canvas.getContext('2d', { willReadFrequently: true });
|
|
12
10
|
} else {
|
|
13
11
|
const img = imageOrCanvas as HTMLImageElement;
|
|
14
12
|
// Copy image to in-memory canvas for processing
|
|
@@ -16,7 +14,7 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
16
14
|
canvas.width = img.width;
|
|
17
15
|
canvas.height = img.height;
|
|
18
16
|
|
|
19
|
-
context = canvas.getContext('2d', { willReadFrequently: true })
|
|
17
|
+
context = canvas.getContext('2d', { willReadFrequently: true });
|
|
20
18
|
context.drawImage(img, 0, 0, img.width, img.height);
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -37,14 +35,12 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
37
35
|
return totalBrightness / 81;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
export const
|
|
38
|
+
export const setTheme = (imageOrCanvas: HTMLElement, container: HTMLElement) => {
|
|
41
39
|
const brightness = sampleBrightness(imageOrCanvas);
|
|
40
|
+
|
|
42
41
|
const theme = brightness > 0.6 ? 'dark' : 'light'
|
|
43
42
|
|
|
44
43
|
console.log(`[Annotorious] Image brightness: ${brightness.toFixed(1)}. Setting ${theme} theme.`);
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const setTheme = (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) =>
|
|
50
|
-
container.setAttribute('data-theme', theme === 'auto' ? detectTheme(imageOrCanvas) : theme);
|
|
45
|
+
container.setAttribute('data-theme', theme);
|
|
46
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SvelteComponentTyped as default } from 'svelte';
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,66 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { isTouch } from '../utils';
|
|
3
|
-
|
|
4
|
-
/** props **/
|
|
5
|
-
export let x: number;
|
|
6
|
-
export let y: number;
|
|
7
|
-
export let scale: number;
|
|
8
|
-
export let radius: number = 30;
|
|
9
|
-
|
|
10
|
-
let touched = false;
|
|
11
|
-
|
|
12
|
-
const onPointerDown = (event: PointerEvent) => {
|
|
13
|
-
if (event.pointerType === 'touch')
|
|
14
|
-
touched = true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const onPointerUp = () =>
|
|
18
|
-
touched = false;
|
|
19
|
-
|
|
20
|
-
$: handleSize = 10 / scale;
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
{#if isTouch}
|
|
24
|
-
<g class="a9s-touch-handle">
|
|
25
|
-
<circle
|
|
26
|
-
cx={x}
|
|
27
|
-
cy={y}
|
|
28
|
-
r={radius / scale}
|
|
29
|
-
class="a9s-touch-halo"
|
|
30
|
-
class:touched={touched}
|
|
31
|
-
on:pointerdown
|
|
32
|
-
on:pointerdown={onPointerDown}
|
|
33
|
-
on:pointerup={onPointerUp} />
|
|
34
|
-
|
|
35
|
-
<rect
|
|
36
|
-
class={`a9s-handle ${$$props.class || ''}`.trim()}
|
|
37
|
-
x={x - handleSize / 2}
|
|
38
|
-
y={y - handleSize / 2}
|
|
39
|
-
width={handleSize}
|
|
40
|
-
height={handleSize}
|
|
41
|
-
on:pointerdown
|
|
42
|
-
on:pointerdown={onPointerDown}
|
|
43
|
-
on:pointerup={onPointerUp} />
|
|
44
|
-
</g>
|
|
45
|
-
{:else}
|
|
46
|
-
<rect
|
|
47
|
-
class={`a9s-handle ${$$props.class || ''}`.trim()}
|
|
48
|
-
x={x - handleSize / 2}
|
|
49
|
-
y={y - handleSize / 2}
|
|
50
|
-
width={handleSize}
|
|
51
|
-
height={handleSize}
|
|
52
|
-
on:pointerdown />
|
|
53
|
-
{/if}
|
|
54
|
-
|
|
55
|
-
<style>
|
|
56
|
-
.a9s-touch-halo {
|
|
57
|
-
fill: transparent;
|
|
58
|
-
stroke-width: 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.a9s-touch-halo.touched {
|
|
62
|
-
fill: rgba(255, 255, 255, 0.25);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</style>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
|
|
2
|
-
import type { FragmentSelector } from './fragment';
|
|
3
|
-
import type { SVGSelector } from './svg';
|
|
4
|
-
|
|
5
|
-
export interface W3CImageAnnotation extends W3CAnnotation {
|
|
6
|
-
|
|
7
|
-
target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[];
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface W3CImageAnnotationTarget extends W3CAnnotationTarget {
|
|
12
|
-
|
|
13
|
-
selector: W3CImageSelector | W3CImageSelector[];
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type W3CImageSelector = FragmentSelector | SVGSelector;
|