From b74711fab77ede8cd7ece6cc12c6cee925e1ffa5 Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Mon, 16 Dec 2024 15:13:41 +0200 Subject: [PATCH] Added `adapter` forwarding to the `createSelectionState` --- packages/text-annotator/src/TextAnnotator.ts | 3 +-- .../text-annotator/src/state/TextAnnotatorState.ts | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/text-annotator/src/TextAnnotator.ts b/packages/text-annotator/src/TextAnnotator.ts index b391b512..7ce61858 100644 --- a/packages/text-annotator/src/TextAnnotator.ts +++ b/packages/text-annotator/src/TextAnnotator.ts @@ -42,8 +42,7 @@ export const createTextAnnotator = = - createTextAnnotatorState(container, opts.userSelectAction); + const state: TextAnnotatorState = createTextAnnotatorState(container, opts); const { selection, viewport } = state; diff --git a/packages/text-annotator/src/state/TextAnnotatorState.ts b/packages/text-annotator/src/state/TextAnnotatorState.ts index 90301c21..38976bef 100644 --- a/packages/text-annotator/src/state/TextAnnotatorState.ts +++ b/packages/text-annotator/src/state/TextAnnotatorState.ts @@ -1,4 +1,4 @@ -import type { Filter, Store, ViewportState, UserSelectActionExpression } from '@annotorious/core'; +import type { Filter, Store, ViewportState } from '@annotorious/core'; import { createHoverState, createSelectionState, @@ -11,10 +11,12 @@ import type { SelectionState, HoverState, } from '@annotorious/core'; + import { createSpatialTree } from './spatialTree'; import type { TextAnnotation, TextAnnotationTarget } from '../model'; import type { AnnotationRects, TextAnnotationStore } from './TextAnnotationStore'; import { isRevived, reviveAnnotation, reviveTarget } from '../utils'; +import type { TextAnnotatorOptions } from '../TextAnnotatorOptions'; export interface TextAnnotatorState extends AnnotatorState { @@ -30,16 +32,14 @@ export interface TextAnnotatorState( container: HTMLElement, - defaultUserSelectAction?: UserSelectActionExpression + opts: TextAnnotatorOptions ): TextAnnotatorState => { const store: Store = createStore(); const tree = createSpatialTree(store, container); - // Temporary - const selection = createSelectionState(store) - selection.setUserSelectAction(defaultUserSelectAction); + const selection = createSelectionState(store, opts.userSelectAction, opts.adapter); const hover = createHoverState(store);