@recogito/text-annotator 3.0.0-rc.43 → 3.0.0-rc.45

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.
@@ -3,10 +3,10 @@ import { HighlightStyleExpression } from './highlight';
3
3
  import { TextAnnotatorState } from './state';
4
4
  import { TextAnnotation } from './model';
5
5
  import { TextAnnotatorOptions } from './TextAnnotatorOptions';
6
- export interface TextAnnotator<E extends unknown = TextAnnotation> extends Annotator<TextAnnotation, E> {
6
+ export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<TextAnnotation, E> {
7
7
  element: HTMLElement;
8
8
  setStyle(style: HighlightStyleExpression | undefined): void;
9
- scrollIntoView(annotation: TextAnnotation): boolean;
10
- state: TextAnnotatorState;
9
+ scrollIntoView(annotation: I): boolean;
10
+ state: TextAnnotatorState<I>;
11
11
  }
12
- export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
12
+ export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<TextAnnotation, E>) => TextAnnotator<TextAnnotation, E>;
@@ -2,8 +2,8 @@ import { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/co
2
2
  import { PresencePainterOptions } from './presence';
3
3
  import { TextAnnotation } from './model';
4
4
  import { HighlightStyleExpression } from './highlight';
5
- export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
6
- adapter?: FormatAdapter<TextAnnotation, T> | null;
5
+ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
6
+ adapter?: FormatAdapter<I, E> | null;
7
7
  annotatingEnabled?: boolean;
8
8
  renderer?: RendererType;
9
9
  offsetReferenceSelector?: string;
@@ -13,4 +13,4 @@ export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
13
13
  user?: User;
14
14
  }
15
15
  export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
16
- export declare const fillDefaults: <T extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<T>, defaults: TextAnnotatorOptions<T>) => TextAnnotatorOptions<T>;
16
+ export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
@@ -17,4 +17,4 @@ export interface Renderer {
17
17
  setPainter(painter?: HighlightPainter): void;
18
18
  setVisible(visible: boolean): void;
19
19
  }
20
- export declare const createBaseRenderer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
20
+ export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState<import('..').TextAnnotation>>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
@@ -1,3 +1,3 @@
1
1
  import { ViewportState } from '@annotorious/core';
2
2
  import { TextAnnotatorState } from '../../state';
3
- export declare const createSpansRenderer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => import('../baseRenderer').Renderer;
3
+ export declare const createSpansRenderer: <T extends TextAnnotatorState = TextAnnotatorState<import('../..').TextAnnotation>>(container: HTMLElement, state: T, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1,9 +1,11 @@
1
+ export * from './api';
1
2
  export * from './highlight';
2
3
  export * from './model';
3
4
  export * from './state';
4
5
  export * from './utils';
5
- export * from './presence/PresencePainterOptions';
6
+ export * from './presence';
7
+ export * from './SelectionHandler';
6
8
  export * from './TextAnnotator';
7
9
  export * from './TextAnnotatorOptions';
8
- export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, UserSelectActionExpression, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
10
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, UserSelectActionExpression, ViewportState, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
11
  export { createBody, Origin, UserSelectAction } from '@annotorious/core';
@@ -1,4 +1,4 @@
1
1
  import { PresenceProvider } from '@annotorious/core';
2
2
  import { HighlightPainter } from '../highlight';
3
3
  import { PresencePainterOptions } from '../presence';
4
- export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
4
+ export declare const createPresencePainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -1,16 +1,17 @@
1
1
  import { Filter, Origin, Store } from '@annotorious/core';
2
2
  import { TextAnnotation } from '../model';
3
- export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
4
- addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
5
- bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin?: Origin): TextAnnotation[];
6
- bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
3
+ export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
4
+ addAnnotation(annotation: T, origin?: Origin): boolean;
5
+ bulkAddAnnotation(annotations: T[], replace: boolean, origin?: Origin): T[];
6
+ bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
7
7
  getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
8
- getAt(x: number, y: number, filter?: Filter): TextAnnotation | undefined;
9
- getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
8
+ getAnnotationRects(id: string): DOMRect[];
9
+ getAt(x: number, y: number, filter?: Filter): T | undefined;
10
+ getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];
10
11
  recalculatePositions(): void;
11
12
  }
12
- export interface AnnotationRects {
13
- annotation: TextAnnotation;
13
+ export interface AnnotationRects<T extends TextAnnotation = TextAnnotation> {
14
+ annotation: T;
14
15
  rects: Rect[];
15
16
  }
16
17
  export interface Rect {
@@ -1,10 +1,10 @@
1
1
  import { ViewportState, UserSelectActionExpression, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
2
2
  import { TextAnnotation } from '../model';
3
3
  import { TextAnnotationStore } from './TextAnnotationStore';
4
- export interface TextAnnotatorState extends AnnotatorState<TextAnnotation> {
5
- store: TextAnnotationStore;
6
- selection: SelectionState<TextAnnotation>;
7
- hover: HoverState<TextAnnotation>;
4
+ export interface TextAnnotatorState<T extends TextAnnotation = TextAnnotation> extends AnnotatorState<T> {
5
+ store: TextAnnotationStore<T>;
6
+ selection: SelectionState<T>;
7
+ hover: HoverState<T>;
8
8
  viewport: ViewportState;
9
9
  }
10
- export declare const createTextAnnotatorState: (container: HTMLElement, defaultUserSelectAction?: UserSelectActionExpression<TextAnnotation>) => TextAnnotatorState;
10
+ export declare const createTextAnnotatorState: <T extends TextAnnotation>(container: HTMLElement, defaultUserSelectAction?: UserSelectActionExpression<TextAnnotation>) => TextAnnotatorState<T>;
@@ -11,13 +11,13 @@ interface IndexedHighlightRect {
11
11
  rects: DOMRect[];
12
12
  };
13
13
  }
14
- export declare const createSpatialTree: (store: Store<TextAnnotation>, container: HTMLElement) => {
14
+ export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<T>, container: HTMLElement) => {
15
15
  all: () => IndexedHighlightRect[][];
16
16
  clear: () => void;
17
17
  getAt: (x: number, y: number, all?: boolean) => string[];
18
18
  getAnnotationBounds: (id: string) => DOMRect;
19
19
  getAnnotationRects: (id: string) => DOMRect[];
20
- getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects[];
20
+ getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<T>[];
21
21
  insert: (target: TextAnnotationTarget) => void;
22
22
  recalculate: () => void;
23
23
  remove: (target: TextAnnotationTarget) => void;
@@ -1,7 +1,6 @@
1
1
  export * from './cancelSingleClickEvents';
2
2
  export * from './debounce';
3
3
  export * from './getAnnotatableFragment';
4
- export * from './getClientRectsPonyfill';
5
4
  export * from './getQuoteContext';
6
5
  export * from './isWhitespaceOrEmpty';
7
6
  export * from './isRevived';
@@ -1,2 +1,2 @@
1
1
  import { TextAnnotation } from '../model';
2
- export declare const reviveAnnotation: (annotation: TextAnnotation, container: HTMLElement) => TextAnnotation;
2
+ export declare const reviveAnnotation: <T extends TextAnnotation>(annotation: T, container: HTMLElement) => T;
@@ -8,4 +8,4 @@ import { TextSelector } from '../model';
8
8
  *
9
9
  * @returns the revived selector
10
10
  */
11
- export declare const reviveSelector: (selector: TextSelector, container: HTMLElement) => TextSelector;
11
+ export declare const reviveSelector: <T extends TextSelector>(selector: T, container: HTMLElement) => T;
@@ -1,2 +1,2 @@
1
1
  import { TextAnnotationTarget } from '../model';
2
- export declare const reviveTarget: (target: TextAnnotationTarget, container: HTMLElement) => TextAnnotationTarget;
2
+ export declare const reviveTarget: <T extends TextAnnotationTarget = TextAnnotationTarget>(target: T, container: HTMLElement) => T;