@annotorious/annotorious 3.0.0-rc.5 → 3.0.0-rc.6
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/annotorious.es.js +873 -871
- package/dist/annotorious.es.js.map +1 -1
- package/dist/annotorious.js +1 -1
- package/dist/annotorious.js.map +1 -1
- package/package.json +1 -1
- package/src/Annotorious.ts +8 -5
- package/src/annotation/SVGAnnotationLayer.svelte +5 -3
package/package.json
CHANGED
package/src/Annotorious.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Ann
|
|
|
24
24
|
|
|
25
25
|
registerShapeEditor(shapeType: ShapeType, editor: typeof SvelteComponent): void;
|
|
26
26
|
|
|
27
|
-
setDrawingTool(
|
|
27
|
+
setDrawingTool(name: DrawingTool): void;
|
|
28
28
|
|
|
29
29
|
setDrawingEnabled(enabled: boolean): void;
|
|
30
30
|
|
|
@@ -120,10 +120,13 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
|
|
|
120
120
|
const registerShapeEditor = (shapeType: ShapeType, editor: typeof SvelteComponent) =>
|
|
121
121
|
registerEditor(shapeType, editor);
|
|
122
122
|
|
|
123
|
-
const setDrawingTool = (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
const setDrawingTool = (name: DrawingTool) => {
|
|
124
|
+
// Validate that the tool exists
|
|
125
|
+
const toolSpec = getTool(name);
|
|
126
|
+
if (!toolSpec)
|
|
127
|
+
throw `No drawing tool named ${name}`;
|
|
128
|
+
|
|
129
|
+
annotationLayer.$set({ toolName: name })
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
const setDrawingEnabled = (enabled: boolean) =>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { ImageAnnotation, Shape} from '../model';
|
|
7
7
|
import { 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';
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
export let preferredDrawingMode: DrawingMode;
|
|
20
20
|
export let state: SvelteImageAnnotatorState;
|
|
21
21
|
export let style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) = undefined;
|
|
22
|
-
export let
|
|
22
|
+
export let toolName: string = listDrawingTools().length > 0 ? listDrawingTools()[0] : undefined;
|
|
23
23
|
export let user: User;
|
|
24
24
|
|
|
25
|
+
$: ({ tool, opts } = getTool(toolName));
|
|
26
|
+
|
|
25
27
|
$: drawingMode = opts?.drawingMode || preferredDrawingMode;
|
|
26
28
|
|
|
27
29
|
/** Drawing tool layer **/
|
|
@@ -154,7 +156,7 @@
|
|
|
154
156
|
{/key}
|
|
155
157
|
{/each}
|
|
156
158
|
{:else if (tool && drawingEnabled)}
|
|
157
|
-
{#key
|
|
159
|
+
{#key toolName}
|
|
158
160
|
<ToolMount
|
|
159
161
|
target={drawingEl}
|
|
160
162
|
tool={tool}
|