@recogito/text-annotator 4.0.1-beta → 4.0.2-beta

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.
@@ -11,13 +11,13 @@ export interface Renderer {
11
11
  on: <E extends keyof RendererEvents>(event: E, callback: RendererEvents[E]) => Unsubscribe;
12
12
  redraw(force?: boolean): void;
13
13
  setStyle(style?: HighlightStyleExpression, id?: string): void;
14
- setFilter(filter?: Filter): void;
14
+ setFilter(filter?: Filter<any>): void;
15
15
  setVisible(visible: boolean): void;
16
16
  }
17
17
  export interface RendererEvents {
18
18
  onRedraw(): void;
19
19
  }
20
- export type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
20
+ export type RendererFactory<T extends TextAnnotation> = (container: HTMLElement, state: TextAnnotatorState<T, any>, viewport: ViewportState) => Renderer;
21
21
  /**
22
22
  * A utility interface. Instead of implementing a Renderer from scratch,
23
23
  * implementers can simply implement a painter, and wrap it in the
@@ -28,4 +28,4 @@ export interface Painter {
28
28
  redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, styleOverrides?: Map<string, HighlightStyleExpression>, force?: boolean): void;
29
29
  setVisible(visible: boolean): void;
30
30
  }
31
- export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
31
+ export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState<TextAnnotation, any>>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
@@ -1,6 +1,7 @@
1
+ import type { TextAnnotation } from '../../model';
1
2
  import { type Painter, type RendererFactory } from '../';
2
3
  /**
3
4
  * EXPERIMENTAL!
4
5
  */
5
6
  export declare const createCSSHighlightPainter: () => Painter;
6
- export declare const createCSSHighlightRenderer: RendererFactory;
7
+ export declare const createCSSHighlightRenderer: RendererFactory<TextAnnotation>;
@@ -1,3 +1,4 @@
1
+ import type { TextAnnotation } from '../../model';
1
2
  import { type RendererFactory } from '../';
2
3
  import './spans-renderer.css';
3
- export declare const createSpansRenderer: RendererFactory;
4
+ export declare const createSpansRenderer: RendererFactory<TextAnnotation>;
@@ -3,9 +3,9 @@ import type { TextAnnotatorState } from './state';
3
3
  import type { TextAnnotation } from './model';
4
4
  import type { AnnotatingMode } from './text-annotator';
5
5
  import type { TextAnnotatorOptions } from './text-annotator-options';
6
- export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, lifecycle: Lifecycle<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
6
+ export declare const createSelectionHandler: <T extends TextAnnotation>(container: HTMLElement, state: TextAnnotatorState<TextAnnotation, any>, lifecycle: Lifecycle<TextAnnotation, any>, options: TextAnnotatorOptions<TextAnnotation, any>) => {
7
7
  destroy: () => void;
8
- setFilter: (filter?: Filter) => Filter;
8
+ setFilter: (filter?: Filter<any>) => Filter<any>;
9
9
  setUser: (user?: User) => User;
10
10
  setAnnotatingEnabled: (enabled: boolean) => void;
11
11
  setAnnotatingMode: (mode?: AnnotatingMode) => AnnotatingMode;
@@ -19,7 +19,7 @@ export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<
19
19
  all: () => IndexedHighlightRect[][];
20
20
  clear: () => void;
21
21
  getAt: (x: number, y: number, all?: boolean) => string[];
22
- getAnnotationBounds: (id: string) => DOMRect;
22
+ getAnnotationBounds: (id: string) => DOMRect | undefined;
23
23
  getAnnotationRects: (id: string) => DOMRect[];
24
24
  getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<T>[];
25
25
  insert: (target: TextAnnotationTarget) => void;
@@ -2,7 +2,7 @@ import type { Unsubscribe } from 'nanoevents';
2
2
  import type { Filter, Origin, Store } from '@annotorious/core';
3
3
  import type { TextAnnotation } from '../model';
4
4
  import type { SpatialTreeEvents } from '../state/spatial-tree';
5
- export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
5
+ export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations'> {
6
6
  addAnnotation(annotation: T, origin?: Origin): boolean;
7
7
  bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
8
8
  bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
@@ -3,7 +3,7 @@ import type { AnnotatorState, SelectionState, HoverState } from '@annotorious/co
3
3
  import type { TextAnnotation } from '../model';
4
4
  import type { TextAnnotationStore } from '../state/text-annotation-store';
5
5
  import type { TextAnnotatorOptions } from '../text-annotator-options';
6
- export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
6
+ export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<AnnotatorState<I, E>, 'store'> {
7
7
  store: TextAnnotationStore<I>;
8
8
  selection: SelectionState<I, E>;
9
9
  hover: HoverState<I>;
@@ -2,7 +2,7 @@ import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorio
2
2
  import type { HighlightStyleExpression, RendererFactory } from './rendering';
3
3
  import type { TextAnnotation } from './model';
4
4
  export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
5
- adapter?: FormatAdapter<I, E> | null;
5
+ adapter?: FormatAdapter<I, E>;
6
6
  allowModifierSelect?: boolean;
7
7
  annotatingEnabled?: boolean;
8
8
  /**
@@ -22,7 +22,7 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
22
22
  verticalTolerance?: number;
23
23
  };
24
24
  offsetReferenceSelector?: string;
25
- renderer?: RendererType | RendererFactory;
25
+ renderer?: RendererType | RendererFactory<I>;
26
26
  selectionMode?: 'shortest' | 'all';
27
27
  style?: HighlightStyleExpression;
28
28
  user?: User;
@@ -4,7 +4,7 @@ import type { TextAnnotation } from './model';
4
4
  import { type TextAnnotatorState } from './state';
5
5
  import { type TextAnnotatorOptions } from './text-annotator-options';
6
6
  import './text-annotator.css';
7
- export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
7
+ export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<Annotator<I, E>, 'setStyle' | 'state'> {
8
8
  element: HTMLElement;
9
9
  renderer: Renderer;
10
10
  setStyle(style?: HighlightStyleExpression, id?: string): void;