@soomo/text-annotator 3.1.0-staging.9 → 3.2.0-staging.1

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.
@@ -1,7 +1,8 @@
1
1
  import { Filter, User } from '@annotorious/core';
2
2
  import { TextAnnotatorState } from './state';
3
3
  import { TextAnnotation } from './model';
4
- export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, offsetReferenceSelector?: string) => {
4
+ import { TextAnnotatorOptions } from './TextAnnotatorOptions';
5
+ export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
5
6
  destroy: () => void;
6
7
  setFilter: (filter?: Filter) => Filter;
7
8
  setUser: (user?: User) => User;
@@ -11,4 +11,4 @@ export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E exte
11
11
  setAnnotatingEnabled: (enabled: boolean) => void;
12
12
  state: TextAnnotatorState<I, E>;
13
13
  }
14
- export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<TextAnnotation, E>) => TextAnnotator<TextAnnotation, E>;
14
+ export declare const createTextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;
@@ -9,6 +9,7 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
9
9
  offsetReferenceSelector?: string;
10
10
  userSelectAction?: UserSelectActionExpression<E>;
11
11
  presence?: PresencePainterOptions;
12
+ selectionMode?: 'shortest' | 'all';
12
13
  style?: HighlightStyleExpression;
13
14
  user?: User;
14
15
  }
@@ -6,6 +6,6 @@ export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity
6
6
  underlineOffset?: number;
7
7
  underlineThickness?: number;
8
8
  }
9
- export type HighlightStyleExpression = HighlightStyle | ((annotation: TextAnnotation, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
9
+ export type HighlightStyleExpression = HighlightStyle | (<I extends TextAnnotation = TextAnnotation>(annotation: I, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
10
10
  export declare const DEFAULT_STYLE: HighlightStyle;
11
11
  export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
@@ -17,4 +17,4 @@ export interface Renderer {
17
17
  setPainter(painter?: HighlightPainter): void;
18
18
  setVisible(visible: boolean): void;
19
19
  }
20
- export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState<import('..').TextAnnotation, import('..').TextAnnotation>>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
20
+ export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
@@ -4,7 +4,6 @@ export interface TextAnnotation extends Annotation {
4
4
  }
5
5
  export interface TextAnnotationTarget extends AnnotationTarget {
6
6
  selector: TextSelector[];
7
- styleClass?: string;
8
7
  }
9
8
  export interface TextSelector {
10
9
  id?: string;
@@ -5,7 +5,9 @@ export interface W3CTextAnnotation extends W3CAnnotation {
5
5
  }
6
6
  export interface W3CTextAnnotationTarget extends W3CAnnotationTarget {
7
7
  selector: W3CTextSelector | W3CTextSelector[];
8
+ outdated?: boolean;
8
9
  styleClass?: string;
10
+ scope?: string;
9
11
  }
10
12
  /**
11
13
  * Matches the `Text Quote Selector` spec
@@ -1,12 +1,12 @@
1
1
  import { FormatAdapter, ParseResult } from '@annotorious/core';
2
2
  import { TextAnnotation } from '../core';
3
3
  import { W3CTextAnnotation } from '../w3c';
4
- export type W3CTextFormatAdapter = FormatAdapter<TextAnnotation, W3CTextAnnotation>;
4
+ export type W3CTextFormatAdapter<I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation> = FormatAdapter<I, E>;
5
5
  /**
6
6
  * @param source - the IRI of the annotated content
7
7
  * @param container - the HTML container of the annotated content,
8
8
  * Required to locate the content's `range` within the DOM
9
9
  */
10
- export declare const W3CTextFormat: (source: string, container: HTMLElement) => W3CTextFormatAdapter;
11
- export declare const parseW3CTextAnnotation: (annotation: W3CTextAnnotation) => ParseResult<TextAnnotation>;
12
- export declare const serializeW3CTextAnnotation: (annotation: TextAnnotation, source: string, container: HTMLElement) => W3CTextAnnotation;
10
+ export declare const W3CTextFormat: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(source: string, container?: HTMLElement) => W3CTextFormatAdapter<I, E>;
11
+ export declare const parseW3CTextAnnotation: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(annotation: E) => ParseResult<I>;
12
+ export declare const serializeW3CTextAnnotation: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(annotation: I, source: string, container?: HTMLElement) => E;
@@ -4,12 +4,14 @@ import { TextAnnotation } from '../model';
4
4
  import { SpatialTreeEvents } from './spatialTree';
5
5
  export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
6
6
  addAnnotation(annotation: T, origin?: Origin): boolean;
7
- bulkAddAnnotation(annotations: T[], replace: boolean, origin?: Origin): T[];
7
+ bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
8
8
  bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
9
9
  getAnnotationRects(id: string): DOMRect[];
10
- getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect | undefined;
10
+ getAnnotationBounds(id: string): DOMRect | undefined;
11
11
  getAnnotationRects(id: string): DOMRect[];
12
- getAt(x: number, y: number, filter?: Filter): T | undefined;
12
+ getAt(x: number, y: number, all: true, filter?: Filter): T[] | undefined;
13
+ getAt(x: number, y: number, all: false, filter?: Filter): T | undefined;
14
+ getAt(x: number, y: number, all?: boolean, filter?: Filter): T | T[] | undefined;
13
15
  getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];
14
16
  recalculatePositions(): void;
15
17
  onRecalculatePositions(callback: SpatialTreeEvents['recalculate']): Unsubscribe;
@@ -1,10 +1,11 @@
1
- import { ViewportState, UserSelectActionExpression, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
1
+ import { ViewportState, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
2
2
  import { TextAnnotation } from '../model';
3
3
  import { TextAnnotationStore } from './TextAnnotationStore';
4
+ import { TextAnnotatorOptions } from '../TextAnnotatorOptions';
4
5
  export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
5
6
  store: TextAnnotationStore<I>;
6
7
  selection: SelectionState<I, E>;
7
8
  hover: HoverState<I>;
8
9
  viewport: ViewportState;
9
10
  }
10
- export declare const createTextAnnotatorState: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, defaultUserSelectAction?: UserSelectActionExpression<E>) => TextAnnotatorState<I, E>;
11
+ export declare const createTextAnnotatorState: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, opts: TextAnnotatorOptions<I, E>) => TextAnnotatorState<I, E>;
@@ -2,8 +2,9 @@ export * from './cancelSingleClickEvents';
2
2
  export * from './device';
3
3
  export * from './programmaticallyFocusable';
4
4
  export * from './getQuoteContext';
5
- export * from './isWhitespaceOrEmpty';
5
+ export * from './isNotAnnotatable';
6
6
  export * from './isRevived';
7
+ export * from './isWhitespaceOrEmpty';
7
8
  export * from './mergeClientRects';
8
9
  export * from './rangeToSelector';
9
10
  export * from './reviveAnnotation';
@@ -13,4 +14,4 @@ export * from './splitAnnotatableRanges';
13
14
  export * from './trimRangeToContainer';
14
15
  export * from './cloneEvents';
15
16
  export * from './rangeContains';
16
- export * from './normalizeRects';
17
+ export * from './rectsToBounds';
@@ -0,0 +1,4 @@
1
+ export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
2
+ export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
3
+ export declare const isNotAnnotatable: (node: Node) => boolean;
4
+ export declare const isRangeAnnotatable: (range: Range) => boolean;
@@ -0,0 +1,2 @@
1
+ export declare const toParentBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
2
+ export declare const toViewportBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
@@ -1,7 +1,3 @@
1
- export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
2
- export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
3
- export declare const isNotAnnotatable: (node: Node) => boolean;
4
- export declare const isRangeAnnotatable: (range: Range) => boolean;
5
1
  /**
6
2
  * Splits a DOM Range into one or more ranges that span annotatable content only.
7
3
  */