Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing adapter forwarding to the createSelectionState #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/text-annotator/src/TextAnnotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const createTextAnnotator = <I extends TextAnnotation = TextAnnotation, E
user: createAnonymousGuest()
});

const state: TextAnnotatorState<I, E> =
createTextAnnotatorState<I, E>(container, opts.userSelectAction);
const state: TextAnnotatorState<I, E> = createTextAnnotatorState<I, E>(container, opts);

const { selection, viewport } = state;

Expand Down
10 changes: 5 additions & 5 deletions packages/text-annotator/src/state/TextAnnotatorState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Filter, Store, ViewportState, UserSelectActionExpression } from '@annotorious/core';
import type { Filter, Store, ViewportState } from '@annotorious/core';
import {
createHoverState,
createSelectionState,
Expand All @@ -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<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {

Expand All @@ -30,16 +32,14 @@ export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E

export const createTextAnnotatorState = <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(
container: HTMLElement,
defaultUserSelectAction?: UserSelectActionExpression<E>
opts: TextAnnotatorOptions<I, E>
): TextAnnotatorState<I, E> => {

const store: Store<I> = createStore<I>();

const tree = createSpatialTree(store, container);

// Temporary
const selection = createSelectionState<I, E>(store)
selection.setUserSelectAction(defaultUserSelectAction);
const selection = createSelectionState<I, E>(store, opts.userSelectAction, opts.adapter);

const hover = createHoverState(store);

Expand Down