@recogito/text-annotator 4.0.3-beta → 4.1.0

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.
@@ -13,3 +13,15 @@ export interface TextSelector {
13
13
  range: Range;
14
14
  offsetReference?: HTMLElement;
15
15
  }
16
+ export interface TextAnnotationLike extends Annotation {
17
+ target: TextAnnotationTargetLike;
18
+ }
19
+ export interface TextAnnotationTargetLike extends AnnotationTarget {
20
+ selector: TextSelectorLike[];
21
+ }
22
+ export interface TextSelectorLike {
23
+ id?: string;
24
+ quote: string;
25
+ range: Range;
26
+ offsetReference?: HTMLElement;
27
+ }
@@ -1,5 +1,5 @@
1
1
  import { type Unsubscribe } from 'nanoevents';
2
- import { type Filter, type ViewportState } from '@annotorious/core';
2
+ import { type Annotation, type AnnotatorState, type Filter, type ViewportState } from '@annotorious/core';
3
3
  import type { TextAnnotation } from '../model';
4
4
  import type { TextAnnotatorState } from '../state';
5
5
  import { type Highlight, type HighlightStyleExpression, type ViewportBounds } from './';
@@ -17,7 +17,7 @@ export interface Renderer {
17
17
  export interface RendererEvents {
18
18
  onRedraw(): void;
19
19
  }
20
- export type RendererFactory<T extends TextAnnotation> = (container: HTMLElement, state: TextAnnotatorState<T, any>, viewport: ViewportState) => Renderer;
20
+ export type RendererFactory<T extends Annotation> = (container: HTMLElement, state: AnnotatorState<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
@@ -1,6 +1,6 @@
1
1
  import type { Store } from '@annotorious/core';
2
2
  import { type Unsubscribe } from 'nanoevents';
3
- import type { TextAnnotation, TextAnnotationTarget } from '../model';
3
+ import type { TextAnnotationLike, TextAnnotationTarget } from '../model';
4
4
  import type { AnnotationRects } from '../state/text-annotation-store';
5
5
  interface IndexedHighlightRect {
6
6
  minX: number;
@@ -15,7 +15,7 @@ interface IndexedHighlightRect {
15
15
  export interface SpatialTreeEvents {
16
16
  recalculate(): void;
17
17
  }
18
- export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<T>, container: HTMLElement, hMergeTolerance?: number, vMergeTolerance?: number) => {
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[];
@@ -1,8 +1,8 @@
1
1
  import type { Unsubscribe } from 'nanoevents';
2
2
  import type { Filter, Origin, Store } from '@annotorious/core';
3
- import type { TextAnnotation } from '../model';
3
+ import type { TextAnnotation, TextAnnotationLike } from '../model';
4
4
  import type { SpatialTreeEvents } from '../state/spatial-tree';
5
- export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations'> {
5
+ export interface TextAnnotationStore<T extends TextAnnotationLike = 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[];
@@ -16,7 +16,7 @@ export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation>
16
16
  recalculatePositions(): void;
17
17
  onRecalculatePositions(callback: SpatialTreeEvents['recalculate']): Unsubscribe;
18
18
  }
19
- export interface AnnotationRects<T extends TextAnnotation = TextAnnotation> {
19
+ export interface AnnotationRects<T extends TextAnnotationLike = TextAnnotation> {
20
20
  annotation: T;
21
21
  rects: Rect[];
22
22
  }
@@ -1,9 +1,9 @@
1
1
  import type { ViewportState } from '@annotorious/core';
2
2
  import type { AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
3
- import type { TextAnnotation } from '../model';
3
+ import type { TextAnnotation, TextAnnotationLike } 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 Omit<AnnotatorState<I, E>, 'store'> {
6
+ export interface TextAnnotatorState<I extends TextAnnotationLike = 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>;
@@ -1,7 +1,7 @@
1
1
  import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
2
  import type { HighlightStyleExpression, RendererFactory } from './rendering';
3
- import type { TextAnnotation } from './model';
4
- export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
3
+ import type { TextAnnotation, TextAnnotationLike } from './model';
4
+ export interface TextAnnotatorOptions<I extends TextAnnotationLike = TextAnnotation, E extends unknown = TextAnnotation> {
5
5
  adapter?: FormatAdapter<I, E>;
6
6
  allowModifierSelect?: boolean;
7
7
  annotatingEnabled?: boolean;
@@ -30,4 +30,4 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
30
30
  }
31
31
  export type RendererType = 'SPANS' | 'CSS_HIGHLIGHTS';
32
32
  export type DismissOnNotAnnotatableExpression = 'NEVER' | 'ALWAYS' | ((event: Event, container: HTMLElement) => boolean);
33
- export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
33
+ export declare const fillDefaults: <I extends TextAnnotationLike = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
@@ -1,10 +1,10 @@
1
1
  import { type Annotator } from '@annotorious/core';
2
2
  import type { HighlightStyleExpression, Renderer } from './rendering';
3
- import type { TextAnnotation } from './model';
3
+ import type { TextAnnotation, TextAnnotationLike } 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 Omit<Annotator<I, E>, 'setStyle' | 'state'> {
7
+ export interface TextAnnotator<I extends TextAnnotationLike = 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;
@@ -14,4 +14,4 @@ export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E exte
14
14
  state: TextAnnotatorState<I, E>;
15
15
  }
16
16
  export type AnnotatingMode = 'CREATE_NEW' | 'ADD_TO_CURRENT' | 'REPLACE_CURRENT';
17
- export declare const createTextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;
17
+ export declare const createTextAnnotator: <I extends TextAnnotationLike = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;