@recogito/text-annotator 4.2.1 → 4.2.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.
@@ -1,7 +1,7 @@
1
1
  import type { Store } from '@annotorious/core';
2
2
  import { type Unsubscribe } from 'nanoevents';
3
3
  import type { AnnotationRects } from '../state/text-annotation-store';
4
- import type { RevivedTextAnnotationLike, RevivedTextSelectorLike, TextAnnotationLike, TextAnnotationTargetLike } from '../model';
4
+ import type { RevivedTextAnnotationLike, RevivedTextAnnotationTargetLike, TextAnnotationLike, TextAnnotationTargetLike } from '../model';
5
5
  interface IndexedHighlightRect {
6
6
  minX: number;
7
7
  minY: number;
@@ -15,19 +15,19 @@ interface IndexedHighlightRect {
15
15
  export interface SpatialTreeEvents {
16
16
  recalculate(): void;
17
17
  }
18
- export declare const createSpatialTree: <T extends TextAnnotationLike>(store: Store<T>, container: HTMLElement, hMergeTolerance?: number, vMergeTolerance?: number, selectorReviveFn?: (arg: T["target"]["selector"][number], container: HTMLElement) => RevivedTextSelectorLike) => {
18
+ export declare const createSpatialTree: <T extends TextAnnotationLike>(store: Store<T>, container: HTMLElement, hMergeTolerance?: number, vMergeTolerance?: number) => {
19
19
  all: () => IndexedHighlightRect[][];
20
20
  clear: () => void;
21
21
  getAt: (x: number, y: number, all?: boolean) => string[];
22
22
  getAnnotationBounds: (id: string) => DOMRect | undefined;
23
23
  getAnnotationRects: (id: string) => DOMRect[];
24
24
  getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<RevivedTextAnnotationLike<T>>[];
25
- insert: (target: TextAnnotationTargetLike) => void;
25
+ insert: (target: RevivedTextAnnotationTargetLike) => void;
26
26
  recalculate: () => void;
27
27
  remove: (target: TextAnnotationTargetLike) => void;
28
- set: (targets: TextAnnotationTargetLike[], replace?: boolean) => void;
28
+ set: (targets: RevivedTextAnnotationTargetLike[], replace?: boolean) => void;
29
29
  size: () => number;
30
- update: (target: TextAnnotationTargetLike) => void;
30
+ update: (target: RevivedTextAnnotationTargetLike) => void;
31
31
  on: <E extends keyof SpatialTreeEvents>(event: E, callback: SpatialTreeEvents[E]) => Unsubscribe;
32
32
  };
33
33
  export {};
@@ -2,10 +2,14 @@ import type { Unsubscribe } from 'nanoevents';
2
2
  import type { Filter, Origin, Store } from '@annotorious/core';
3
3
  import type { RevivedTextAnnotationLike, TextAnnotation, TextAnnotationLike } from '../model';
4
4
  import type { SpatialTreeEvents } from '../state/spatial-tree';
5
- export interface TextAnnotationStore<T extends TextAnnotationLike = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations'> {
5
+ export interface TextAnnotationStore<T extends TextAnnotationLike = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations' | 'syncAnnotations'> {
6
6
  addAnnotation(annotation: T, origin?: Origin): boolean;
7
+ /**
8
+ * @deprecated use {@link syncAnnotations} (replace) or {@link bulkUpsertAnnotations} (merge) instead.
9
+ */
7
10
  bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
8
11
  bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
12
+ syncAnnotations(annotations: T[], origin?: Origin): T[];
9
13
  getAnnotationRects(id: string): DOMRect[];
10
14
  getAnnotationBounds(id: string): DOMRect | undefined;
11
15
  getAnnotationRects(id: string): DOMRect[];
@@ -9,7 +9,7 @@ export interface TextAnnotatorOptions<I extends TextAnnotationLike = TextAnnotat
9
9
  * Custom function that turns a stored selector into a revived one (with a live DOM `range`).
10
10
  * Used by sub-formats such as PDF to map their selector shape to a text range.
11
11
  */
12
- selectorReviveFn?: (arg: I['target']['selector'][number], container: HTMLElement) => RevivedTextSelectorLike;
12
+ selectorReviveFn?: (arg: I['target']['selector'][number], container: HTMLElement) => RevivedTextSelectorLike | RevivedTextSelectorLike[];
13
13
  /**
14
14
  * Determines whether an active selection should be dismissed
15
15
  * when a user ends their interaction (click, selection)