Skip to content

Commit

Permalink
Merge branch 'spatial-tree-positioning' into staging
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/text-annotator/src/utils/index.ts
  • Loading branch information
oleksandr-danylchenko committed Sep 2, 2024
2 parents 167b98b + 8071b73 commit 14bede7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/text-annotator/src/state/TextAnnotatorState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@annotorious/core';
import { createSpatialTree, type SpatialTreeEvents } from './spatialTree';
import type { TextAnnotation, TextAnnotationTarget } from '../model';
import type { TextAnnotationStore } from './TextAnnotationStore';
import type { AnnotationRects, TextAnnotationStore } from './TextAnnotationStore';
import { isRevived, reviveAnnotation, reviveTarget } from '../utils';

export interface TextAnnotatorState<T extends TextAnnotation = TextAnnotation> extends AnnotatorState<T> {
Expand Down Expand Up @@ -130,6 +130,13 @@ export const createTextAnnotatorState = (
return tree.getAnnotationBounds(id);
}

const getIntersecting = (
minX: number,
minY: number,
maxX: number,
maxY: number,
): AnnotationRects[] => tree.getIntersecting(minX, minY, maxX, maxY);

const getAnnotationRects = (id: string): DOMRect[] => tree.getAnnotationRects(id);

const recalculatePositions = () => tree.recalculate();
Expand Down Expand Up @@ -159,9 +166,8 @@ export const createTextAnnotatorState = (
bulkUpsertAnnotations,
getAnnotationBounds,
getAnnotationRects,
getIntersecting,
getAt,
getIntersecting: tree.getIntersecting.bind(tree),
getAnnotationRects: tree.getAnnotationRects.bind(tree),
recalculatePositions,
onRecalculatePositions,
updateTarget
Expand Down

0 comments on commit 14bede7

Please sign in to comment.