@annotorious/annotorious 3.0.18 → 3.0.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/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export * from './annotation/tools';
6
6
  export * from './Annotorious';
7
7
  export * from './AnnotoriousOpts';
8
8
  export * from './keyboardCommands';
9
- export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, ChangeSet, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, ChangeSet, Color, DrawingStyle, Filter, FormatAdapter, History, HoverState, LifecycleEvents, ParseResult, PresentUser, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
10
10
  export { chainStyles, computeStyle, createBody, defaultColorProvider, UserSelectAction } from '@annotorious/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/annotorious",
3
- "version": "3.0.18",
3
+ "version": "3.0.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",
@@ -46,10 +46,10 @@
46
46
  "typescript": "5.7.2",
47
47
  "vite": "^5.4.11",
48
48
  "vite-plugin-dts": "^4.3.0",
49
- "vitest": "^2.1.6"
49
+ "vitest": "^2.1.8"
50
50
  },
51
51
  "dependencies": {
52
- "@annotorious/core": "3.0.18",
52
+ "@annotorious/core": "3.0.20",
53
53
  "rbush": "^4.0.1",
54
54
  "uuid": "^11.0.3"
55
55
  }
@@ -114,10 +114,8 @@ export const createImageAnnotator = <I extends Annotation = ImageAnnotation, E e
114
114
  // Most of the external API functions are covered in the base annotator
115
115
  const base = createBaseAnnotator<I, E>(state, undoStack, opts.adapter);
116
116
 
117
- const cancelDrawing = () => {
118
- annotationLayer.$set({ drawingEnabled: false });
119
- setTimeout(() => annotationLayer.$set({ drawingEnabled: true }), 1);
120
- }
117
+ const cancelDrawing = () =>
118
+ annotationLayer.cancelDrawing();
121
119
 
122
120
  const destroy = () => {
123
121
  // Destroy Svelte annotation layer
@@ -1,4 +1,4 @@
1
- import type { Annotation, ChangeSet, DrawingStyleExpression, FormatAdapter, UserSelectActionExpression } from '@annotorious/core';
1
+ import type { Annotation, DrawingStyleExpression, FormatAdapter, History, UserSelectActionExpression } from '@annotorious/core';
2
2
  import type { ImageAnnotation } from './model';
3
3
 
4
4
  export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> {
@@ -13,7 +13,7 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E exten
13
13
  // 'drag': starts drawing on drag, single click always selects
14
14
  drawingMode?: DrawingMode;
15
15
 
16
- initialHistory?: ChangeSet<I>[];
16
+ initialHistory?: History<I>;
17
17
 
18
18
  // Modal selection mode WILL NOT CHANGE OR DE-SELECT THE CURRENT SELECTION if another
19
19
  // annotation or empty space is clicked. Warning: this means that the user is no longer
@@ -23,7 +23,11 @@
23
23
  export let user: User;
24
24
  export let visible = true;
25
25
 
26
+ // Trick to force tool re-mounting on cancelDrawing
27
+ let toolMountKey = 0;
28
+
26
29
  /** API methods */
30
+ export const cancelDrawing = () => toolMountKey += 1;
27
31
  export const getDrawingTool = () => toolName;
28
32
  export const isDrawingEnabled = () => drawingEnabled;
29
33
 
@@ -195,7 +199,7 @@
195
199
  {/if}
196
200
  {/each}
197
201
  {:else if (tool && drawingEnabled)}
198
- {#key toolName}
202
+ {#key `${toolName}-${toolMountKey}`}
199
203
  <ToolMount
200
204
  target={drawingEl}
201
205
  tool={tool}
@@ -181,7 +181,7 @@
181
181
 
182
182
  {#if isClosable}
183
183
  <rect
184
- class="a9s-corner-handle"
184
+ class="a9s-handle"
185
185
  x={points[0][0] - handleSize / 2}
186
186
  y={points[0][1] - handleSize / 2}
187
187
  height={handleSize}
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export type {
21
21
  DrawingStyle,
22
22
  Filter,
23
23
  FormatAdapter,
24
+ History,
24
25
  HoverState,
25
26
  LifecycleEvents,
26
27
  ParseResult,