Skip to content

Commit

Permalink
More TypeScript flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Sep 2, 2024
1 parent b036292 commit 992dd67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions packages/text-annotator/src/state/TextAnnotationStore.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import type { Filter, Origin, Store } from '@annotorious/core';
import type { TextAnnotation } from '../model';

export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {

// Minor changes to default Annotorious store - text store returns feedback
// on annotations that failed to render, to support lazy document loading scenarios
addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
addAnnotation(annotation: T, origin?: Origin): boolean;

bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin?: Origin): TextAnnotation[];
bulkAddAnnotation(annotations: T[], replace: boolean, origin?: Origin): T[];

bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];

getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;

getAnnotationRects(id: string): DOMRect[];

getAt(x: number, y: number, filter?: Filter): TextAnnotation | undefined;

getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];

recalculatePositions(): void;

}

export interface AnnotationRects {
export interface AnnotationRects <T extends TextAnnotation = TextAnnotation>{

annotation: TextAnnotation;
annotation: T;

rects: Rect[];

Expand Down
4 changes: 2 additions & 2 deletions packages/text-annotator/src/state/TextAnnotatorState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type { TextAnnotation, TextAnnotationTarget } from '../model';
import type { TextAnnotationStore } from './TextAnnotationStore';
import { isRevived, reviveAnnotation, reviveTarget } from '../utils';

export interface TextAnnotatorState extends AnnotatorState<TextAnnotation> {
export interface TextAnnotatorState<T extends TextAnnotation = TextAnnotation> extends AnnotatorState<T> {

store: TextAnnotationStore;
store: TextAnnotationStore<T>;

selection: SelectionState<TextAnnotation>;

Expand Down

0 comments on commit 992dd67

Please sign in to comment.