@annotorious/annotorious 3.0.0-rc.17 → 3.0.0-rc.19
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/annotation/editors/Handle.svelte.d.ts +1 -0
- package/dist/annotation/editors/index.d.ts +1 -1
- package/dist/annotation/editors/index.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 +1864 -1634
- 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 +6 -6
- package/src/Annotorious.css +5 -5
- package/src/annotation/editors/Editor.svelte +6 -7
- package/src/annotation/editors/EditorMount.svelte +1 -1
- package/src/annotation/editors/Handle.svelte +66 -0
- package/src/annotation/editors/index.ts +2 -2
- package/src/annotation/editors/polygon/PolygonEditor.svelte +9 -11
- package/src/annotation/editors/rectangle/RectangleEditor.svelte +43 -40
- package/src/annotation/tools/polygon/RubberbandPolygon.svelte +20 -1
- package/src/annotation/utils/touch.ts +4 -1
- package/src/keyboardCommands.ts +2 -2
- package/src/model/w3c/W3CImageFormatAdapter.ts +11 -3
- package/src/themes/dark/index.css +2 -2
- package/src/themes/light/index.css +2 -2
- 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
|
@@ -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;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,
|
|
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"}
|
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.19",
|
|
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",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
40
40
|
"@tsconfig/svelte": "^5.0.2",
|
|
41
41
|
"@types/rbush": "^3.0.3",
|
|
42
|
-
"jsdom": "^
|
|
43
|
-
"svelte": "^4.2.
|
|
42
|
+
"jsdom": "^24.0.0",
|
|
43
|
+
"svelte": "^4.2.9",
|
|
44
44
|
"typescript": "^5.3.3",
|
|
45
|
-
"vite": "^5.0.
|
|
46
|
-
"vite-plugin-dts": "^3.7.
|
|
47
|
-
"vitest": "^1.
|
|
45
|
+
"vite": "^5.0.12",
|
|
46
|
+
"vite-plugin-dts": "^3.7.2",
|
|
47
|
+
"vitest": "^1.2.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@annotorious/core": "*"
|
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
|
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
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
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) => {
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
|
|
49
48
|
initialShape = shape;
|
|
50
49
|
|
|
51
|
-
dispatch('release');
|
|
50
|
+
dispatch('release', evt);
|
|
52
51
|
}
|
|
53
52
|
</script>
|
|
54
53
|
|
|
@@ -5,7 +5,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,66 @@
|
|
|
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,7 +1,7 @@
|
|
|
1
1
|
export * from './polygon';
|
|
2
2
|
export * from './rectangle';
|
|
3
3
|
export * from './editorsRegistry';
|
|
4
|
-
export * from './Handle';
|
|
5
4
|
|
|
6
5
|
export { default as Editor } from './Editor.svelte';
|
|
7
|
-
export { default as EditorMount } from './EditorMount.svelte';
|
|
6
|
+
export { default as EditorMount } from './EditorMount.svelte';
|
|
7
|
+
export { default as Handle } from './Handle.svelte';
|
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
$: geom = shape.geometry;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const editor = (polygon: Shape, handle: Handle, delta: [number, number]) => {
|
|
15
|
+
const editor = (polygon: Shape, handle: string, delta: [number, number]) => {
|
|
18
16
|
let points: [number, number][];
|
|
19
17
|
|
|
20
18
|
const geom = (polygon.geometry) as PolygonGeometry;
|
|
21
19
|
|
|
22
|
-
if (handle ===
|
|
20
|
+
if (handle === 'SHAPE') {
|
|
23
21
|
points = geom.points.map(([x, y]) => [x + delta[0], y + delta[1]]);
|
|
24
22
|
} else {
|
|
25
23
|
points = geom.points.map(([x, y], idx) =>
|
|
26
|
-
handle ===
|
|
24
|
+
handle === `HANDLE-${idx}` ? [x + delta[0], y + delta[1]] : [x, y]
|
|
27
25
|
);
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -48,19 +46,19 @@
|
|
|
48
46
|
<polygon
|
|
49
47
|
class="a9s-outer"
|
|
50
48
|
style={computedStyle ? 'display:none;' : undefined}
|
|
51
|
-
on:pointerdown={grab(
|
|
49
|
+
on:pointerdown={grab('SHAPE')}
|
|
52
50
|
points={geom.points.map(xy => xy.join(',')).join(' ')} />
|
|
53
51
|
|
|
54
52
|
<polygon
|
|
55
53
|
class="a9s-inner a9s-shape-handle"
|
|
56
54
|
style={computedStyle}
|
|
57
|
-
on:pointerdown={grab(
|
|
55
|
+
on:pointerdown={grab('SHAPE')}
|
|
58
56
|
points={geom.points.map(xy => xy.join(',')).join(' ')} />
|
|
59
57
|
|
|
60
58
|
{#each geom.points as point, idx}
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
<Handle
|
|
60
|
+
on:pointerdown={grab(`HANDLE-${idx}`)}
|
|
61
|
+
x={point[0]} y={point[1]}
|
|
62
|
+
scale={viewportScale} />
|
|
65
63
|
{/each}
|
|
66
64
|
</Editor>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Handle from '../Handle.svelte';
|
|
2
3
|
import type { Rectangle, Shape } from '../../../model';
|
|
3
4
|
import type { Transform } from '../../Transform';
|
|
4
|
-
import { Editor
|
|
5
|
+
import { Editor } from '..';
|
|
5
6
|
|
|
6
7
|
/** Props */
|
|
7
8
|
export let shape: Rectangle;
|
|
@@ -11,9 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
$: geom = shape.geometry;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const editor = (rectangle: Shape, handle: Handle, delta: [number, number]) => {
|
|
15
|
+
const editor = (rectangle: Shape, handle: string, delta: [number, number]) => {
|
|
17
16
|
const initialBounds = rectangle.geometry.bounds;
|
|
18
17
|
|
|
19
18
|
let [x0, y0] = [initialBounds.minX, initialBounds.minY];
|
|
@@ -21,39 +20,39 @@
|
|
|
21
20
|
|
|
22
21
|
const [dx, dy] = delta;
|
|
23
22
|
|
|
24
|
-
if (handle ===
|
|
23
|
+
if (handle === 'SHAPE') {
|
|
25
24
|
x0 += dx;
|
|
26
25
|
x1 += dx;
|
|
27
26
|
y0 += dy;
|
|
28
27
|
y1 += dy;
|
|
29
28
|
} else {
|
|
30
29
|
switch (handle) {
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
30
|
+
case 'TOP':
|
|
31
|
+
case 'TOP_LEFT':
|
|
32
|
+
case 'TOP_RIGHT': {
|
|
34
33
|
y0 += dy;
|
|
35
34
|
break;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
case
|
|
39
|
-
case
|
|
40
|
-
case
|
|
37
|
+
case 'BOTTOM':
|
|
38
|
+
case 'BOTTOM_LEFT':
|
|
39
|
+
case 'BOTTOM_RIGHT': {
|
|
41
40
|
y1 += dy;
|
|
42
41
|
break;
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
switch (handle) {
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
46
|
+
case 'LEFT':
|
|
47
|
+
case 'TOP_LEFT':
|
|
48
|
+
case 'BOTTOM_LEFT': {
|
|
50
49
|
x0 += dx;
|
|
51
50
|
break;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
case
|
|
55
|
-
case
|
|
56
|
-
case
|
|
53
|
+
case 'RIGHT':
|
|
54
|
+
case 'TOP_RIGHT':
|
|
55
|
+
case 'BOTTOM_RIGHT': {
|
|
57
56
|
x1 += dx;
|
|
58
57
|
break;
|
|
59
58
|
}
|
|
@@ -92,52 +91,56 @@
|
|
|
92
91
|
<rect
|
|
93
92
|
class="a9s-outer"
|
|
94
93
|
style={computedStyle ? 'display:none;' : undefined}
|
|
95
|
-
on:pointerdown={grab(
|
|
94
|
+
on:pointerdown={grab('SHAPE')}
|
|
96
95
|
x={geom.x} y={geom.y} width={geom.w} height={geom.h} />
|
|
97
96
|
|
|
98
97
|
<rect
|
|
99
98
|
class="a9s-inner a9s-shape-handle"
|
|
100
99
|
style={computedStyle}
|
|
101
|
-
on:pointerdown={grab(
|
|
100
|
+
on:pointerdown={grab('SHAPE')}
|
|
102
101
|
x={geom.x} y={geom.y} width={geom.w} height={geom.h} />
|
|
103
102
|
|
|
104
103
|
<rect
|
|
105
104
|
class="a9s-edge-handle a9s-edge-handle-top"
|
|
106
|
-
on:pointerdown={grab(
|
|
105
|
+
on:pointerdown={grab('TOP')}
|
|
107
106
|
x={geom.x} y={geom.y} height={1} width={geom.w} />
|
|
108
107
|
|
|
109
108
|
<rect
|
|
110
109
|
class="a9s-edge-handle a9s-edge-handle-right"
|
|
111
|
-
on:pointerdown={grab(
|
|
110
|
+
on:pointerdown={grab('RIGHT')}
|
|
112
111
|
x={geom.x + geom.w} y={geom.y} height={geom.h} width={1}/>
|
|
113
112
|
|
|
114
113
|
<rect
|
|
115
114
|
class="a9s-edge-handle a9s-edge-handle-bottom"
|
|
116
|
-
on:pointerdown={grab(
|
|
115
|
+
on:pointerdown={grab('BOTTOM')}
|
|
117
116
|
x={geom.x} y={geom.y + geom.h} height={1} width={geom.w} />
|
|
118
117
|
|
|
119
118
|
<rect
|
|
120
119
|
class="a9s-edge-handle a9s-edge-handle-left"
|
|
121
|
-
on:pointerdown={grab(
|
|
120
|
+
on:pointerdown={grab('LEFT')}
|
|
122
121
|
x={geom.x} y={geom.y} height={geom.h} width={1} />
|
|
123
122
|
|
|
124
|
-
<
|
|
125
|
-
class="a9s-corner-handle
|
|
126
|
-
on:pointerdown={grab(
|
|
127
|
-
x={geom.x
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
<Handle
|
|
124
|
+
class="a9s-corner-handle-topleft"
|
|
125
|
+
on:pointerdown={grab('TOP_LEFT')}
|
|
126
|
+
x={geom.x} y={geom.y}
|
|
127
|
+
scale={viewportScale} />
|
|
128
|
+
|
|
129
|
+
<Handle
|
|
130
|
+
class="a9s-corner-handle-topright"
|
|
131
|
+
on:pointerdown={grab('TOP_RIGHT')}
|
|
132
|
+
x={geom.x + geom.w} y={geom.y}
|
|
133
|
+
scale={viewportScale} />
|
|
133
134
|
|
|
134
|
-
<
|
|
135
|
-
class="a9s-corner-handle
|
|
136
|
-
on:pointerdown={grab(
|
|
137
|
-
x={geom.x + geom.w
|
|
135
|
+
<Handle
|
|
136
|
+
class="a9s-corner-handle-bottomright"
|
|
137
|
+
on:pointerdown={grab('BOTTOM_RIGHT')}
|
|
138
|
+
x={geom.x + geom.w} y={geom.y + geom.h}
|
|
139
|
+
scale={viewportScale} />
|
|
138
140
|
|
|
139
|
-
<
|
|
140
|
-
class="a9s-corner-handle
|
|
141
|
-
on:pointerdown={grab(
|
|
142
|
-
x={geom.x
|
|
141
|
+
<Handle
|
|
142
|
+
class="a9s-corner-handle-bottomleft"
|
|
143
|
+
on:pointerdown={grab('BOTTOM_LEFT')}
|
|
144
|
+
x={geom.x} y={geom.y + geom.h}
|
|
145
|
+
scale={viewportScale} />
|
|
143
146
|
</Editor>
|
|
@@ -19,10 +19,17 @@
|
|
|
19
19
|
|
|
20
20
|
let cursor: [number, number] | undefined;
|
|
21
21
|
|
|
22
|
+
// Keep track of the user keeping the finger
|
|
23
|
+
// in place. Long pauses will be interpreted like a
|
|
24
|
+
// double click and close the shape.
|
|
25
|
+
let touchPauseTimer: number | undefined;
|
|
26
|
+
|
|
22
27
|
let isClosable: boolean = false;
|
|
23
28
|
|
|
24
29
|
const CLOSE_DISTANCE = 20;
|
|
25
30
|
|
|
31
|
+
const TOUCH_PAUSE_LIMIT = 1500;
|
|
32
|
+
|
|
26
33
|
$: handleSize = 10 / viewportScale;
|
|
27
34
|
|
|
28
35
|
const onPointerDown = (event: Event) => {
|
|
@@ -45,6 +52,8 @@
|
|
|
45
52
|
const onPointerMove = (event: Event) => {
|
|
46
53
|
const evt = event as PointerEvent;
|
|
47
54
|
|
|
55
|
+
if (touchPauseTimer) clearTimeout(touchPauseTimer);
|
|
56
|
+
|
|
48
57
|
if (points.length > 0) {
|
|
49
58
|
cursor = transform.elementToImage(evt.offsetX, evt.offsetY);
|
|
50
59
|
|
|
@@ -52,12 +61,20 @@
|
|
|
52
61
|
const d = distance(cursor, points[0]) * viewportScale;
|
|
53
62
|
isClosable = d < CLOSE_DISTANCE;
|
|
54
63
|
}
|
|
64
|
+
|
|
65
|
+
if (evt.pointerType === 'touch') {
|
|
66
|
+
touchPauseTimer = setTimeout(() => {
|
|
67
|
+
onDblClick();
|
|
68
|
+
}, TOUCH_PAUSE_LIMIT);
|
|
69
|
+
}
|
|
55
70
|
}
|
|
56
71
|
}
|
|
57
72
|
|
|
58
73
|
const onPointerUp = (event: Event) => {
|
|
59
74
|
const evt = event as PointerEvent;
|
|
60
75
|
|
|
76
|
+
if (touchPauseTimer) clearTimeout(touchPauseTimer);
|
|
77
|
+
|
|
61
78
|
if (drawingMode === 'click') {
|
|
62
79
|
const timeDifference = evt.timeStamp - lastPointerDown.timeStamp;
|
|
63
80
|
|
|
@@ -105,9 +122,11 @@
|
|
|
105
122
|
}
|
|
106
123
|
|
|
107
124
|
const onDblClick = () => {
|
|
125
|
+
if (!cursor) return;
|
|
126
|
+
|
|
108
127
|
// Require min 3 points (incl. cursor) and minimum
|
|
109
128
|
// polygon area
|
|
110
|
-
const p = [...points, cursor
|
|
129
|
+
const p = [...points, cursor];
|
|
111
130
|
|
|
112
131
|
const shape: Polygon = {
|
|
113
132
|
type: ShapeType.POLYGON,
|
package/src/keyboardCommands.ts
CHANGED
|
@@ -12,9 +12,9 @@ export const initKeyboardCommands = <T extends Annotation>(
|
|
|
12
12
|
const onWinKeyDown = (evt: Event) => {
|
|
13
13
|
const event = evt as KeyboardEvent;
|
|
14
14
|
|
|
15
|
-
if (event.key === '
|
|
15
|
+
if (event.key === 'z' && event.ctrlKey) {
|
|
16
16
|
undoStack.undo();
|
|
17
|
-
} else if (event.key === '
|
|
17
|
+
} else if (event.key === 'y' && event.ctrlKey) {
|
|
18
18
|
undoStack.redo()
|
|
19
19
|
}
|
|
20
20
|
};
|
|
@@ -62,7 +62,7 @@ export const parseW3CImageAnnotation = (
|
|
|
62
62
|
created: created ? new Date(created) : undefined,
|
|
63
63
|
creator: parseW3CUser(creator),
|
|
64
64
|
updated: modified ? new Date(modified) : undefined,
|
|
65
|
-
...rest.target,
|
|
65
|
+
...(Array.isArray(rest.target) ? rest.target[0] : rest.target),
|
|
66
66
|
annotation: annotationId,
|
|
67
67
|
selector
|
|
68
68
|
}
|
|
@@ -91,7 +91,7 @@ export const serializeW3CImageAnnotation = (
|
|
|
91
91
|
serializeFragmentSelector(selector.geometry as RectangleGeometry) :
|
|
92
92
|
serializeSVGSelector(selector);
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
const serialized = {
|
|
95
95
|
...annotation,
|
|
96
96
|
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
|
97
97
|
id: annotation.id,
|
|
@@ -105,5 +105,13 @@ export const serializeW3CImageAnnotation = (
|
|
|
105
105
|
source,
|
|
106
106
|
selector: w3CSelector
|
|
107
107
|
}
|
|
108
|
-
}
|
|
108
|
+
} as W3CImageAnnotation;
|
|
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;
|
|
109
117
|
}
|
|
@@ -11,8 +11,8 @@ div[data-theme="dark"] .a9s-annotationlayer .a9s-inner {
|
|
|
11
11
|
stroke-width: 1px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
rect.a9s-
|
|
15
|
-
div[data-theme="dark"] rect.a9s-
|
|
14
|
+
rect.a9s-handle,
|
|
15
|
+
div[data-theme="dark"] rect.a9s-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-
|
|
17
|
-
div[data-theme="light"] rect.a9s-
|
|
16
|
+
rect.a9s-handle,
|
|
17
|
+
div[data-theme="light"] rect.a9s-handle {
|
|
18
18
|
fill: #fff;
|
|
19
19
|
rx: 1px;
|
|
20
20
|
stroke: rgba(0, 0, 0, 0.45);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Handle = string;
|
|
2
|
-
export declare const Handle: {
|
|
3
|
-
(value: string | number): string;
|
|
4
|
-
SHAPE: string;
|
|
5
|
-
TOP: string;
|
|
6
|
-
RIGHT: string;
|
|
7
|
-
BOTTOM: string;
|
|
8
|
-
LEFT: string;
|
|
9
|
-
TOP_LEFT: string;
|
|
10
|
-
TOP_RIGHT: string;
|
|
11
|
-
BOTTOM_RIGHT: string;
|
|
12
|
-
BOTTOM_LEFT: string;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=Handle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Handle.d.ts","sourceRoot":"","sources":["../../../src/annotation/editors/Handle.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,eAAO,MAAM,MAAM;YAAW,MAAM,GAAG,MAAM;;;;;;;;;;CAAsB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type Handle = string;
|
|
2
|
-
|
|
3
|
-
export const Handle = (value: string | number) => `HANDLE-${value}`;
|
|
4
|
-
|
|
5
|
-
Handle.SHAPE = 'SHAPE';
|
|
6
|
-
|
|
7
|
-
Handle.TOP = 'TOP';
|
|
8
|
-
|
|
9
|
-
Handle.RIGHT = 'RIGHT';
|
|
10
|
-
|
|
11
|
-
Handle.BOTTOM = 'BOTTOM';
|
|
12
|
-
|
|
13
|
-
Handle.LEFT = 'LEFT';
|
|
14
|
-
|
|
15
|
-
Handle.TOP_LEFT = 'TOP_LEFT';
|
|
16
|
-
|
|
17
|
-
Handle.TOP_RIGHT = 'TOP_RIGHT';
|
|
18
|
-
|
|
19
|
-
Handle.BOTTOM_RIGHT = 'BOTTOM_RIGHT';
|
|
20
|
-
|
|
21
|
-
Handle.BOTTOM_LEFT = 'BOTTOM_LEFT';
|