@soomo/text-annotator 3.0.0-staging.30 → 3.0.0-staging.32

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,7 @@
1
1
  import { Filter, User } from '@annotorious/core';
2
2
  import { TextAnnotatorState } from './state';
3
3
 
4
- export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, annotationEnabled: boolean, offsetReferenceSelector?: string) => {
4
+ export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, annotatingEnabled: boolean, offsetReferenceSelector?: string) => {
5
5
  destroy: () => void;
6
6
  setFilter: (filter?: Filter) => Filter;
7
7
  setUser: (user?: User) => User;
@@ -1,14 +1,14 @@
1
- import { FormatAdapter, PointerSelectAction, User } from '@annotorious/core';
1
+ import { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
2
  import { PresencePainterOptions } from './presence';
3
3
  import { TextAnnotation } from './model';
4
4
  import { HighlightStyleExpression } from './highlight';
5
5
 
6
6
  export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
7
7
  adapter?: FormatAdapter<TextAnnotation, T> | null;
8
- annotationEnabled?: boolean;
8
+ annotatingEnabled?: boolean;
9
9
  renderer?: RendererType;
10
10
  offsetReferenceSelector?: string;
11
- pointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction);
11
+ userAction?: UserSelectActionExpression<TextAnnotation>;
12
12
  presence?: PresencePainterOptions;
13
13
  style?: HighlightStyleExpression;
14
14
  user?: User;
@@ -5,5 +5,5 @@ export * from './utils';
5
5
  export * from './presence/PresencePainterOptions';
6
6
  export * from './TextAnnotator';
7
7
  export * from './TextAnnotatorOptions';
8
- export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
- export { createBody, Origin, PointerSelectAction } from '@annotorious/core';
8
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, UserSelectActionExpression, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
+ export { createBody, Origin, UserSelectAction } from '@annotorious/core';
@@ -5,7 +5,8 @@ export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnn
5
5
  addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
6
6
  bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin?: Origin): TextAnnotation[];
7
7
  bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
8
- getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
8
+ getAnnotationRects(id: string): DOMRect[];
9
+ getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect | undefined;
9
10
  getAt(x: number, y: number, filter?: Filter): TextAnnotation | undefined;
10
11
  getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
11
12
  recalculatePositions(): void;
@@ -1,4 +1,4 @@
1
- import { PointerSelectAction, ViewportState, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
1
+ import { ViewportState, UserSelectActionExpression, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
2
2
  import { TextAnnotation } from '../model';
3
3
  import { TextAnnotationStore } from './TextAnnotationStore';
4
4
 
@@ -8,4 +8,4 @@ export interface TextAnnotatorState extends AnnotatorState<TextAnnotation> {
8
8
  hover: HoverState<TextAnnotation>;
9
9
  viewport: ViewportState;
10
10
  }
11
- export declare const createTextAnnotatorState: (container: HTMLElement, defaultPointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction)) => TextAnnotatorState;
11
+ export declare const createTextAnnotatorState: (container: HTMLElement, defaultUserAction?: UserSelectActionExpression<TextAnnotation>) => TextAnnotatorState;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Events need to be manually mapped into new objects:
3
+ * 1. It preserves the `target` and `currentTarget` properties.
4
+ * Otherwise, they will be `null` when the event is read beyond the handler.
5
+ * 2. Spread operator can copy only own enumerable properties, not inherited ones.
6
+ * Therefore, we need to manually copy the props we're interested in.
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
8
+ * @see https://github.com/recogito/text-annotator-js/commit/65d13f3108c429311cf8c2523f6babbbc946013d#r144041390
9
+ */
10
+ export declare const clonePointerEvent: (event: PointerEvent) => PointerEvent;
11
+ export declare const cloneKeyboardEvent: (event: KeyboardEvent) => KeyboardEvent;
@@ -1,4 +1,5 @@
1
1
  export * from './cancelSingleClickEvents';
2
+ export * from './programmaticallyFocusable';
2
3
  export * from './debounce';
3
4
  export * from './getAnnotatableFragment';
4
5
  export * from './getClientRectsPonyfill';
@@ -11,3 +12,5 @@ export * from './reviveAnnotation';
11
12
  export * from './reviveSelector';
12
13
  export * from './reviveTarget';
13
14
  export * from './splitAnnotatableRanges';
15
+ export * from './normalizeRects';
16
+ export * from './cloneEvents';
@@ -1 +1,2 @@
1
1
  export declare const mergeClientRects: (rects: DOMRect[]) => DOMRect[];
2
+ export declare const toDomRectList: (rects: DOMRect[]) => DOMRectList;
@@ -0,0 +1,2 @@
1
+ export declare const normalizeRectWithOffset: (rect: DOMRect, offset: DOMRect) => DOMRect;
2
+ export declare const denormalizeRectWithOffset: (rect: DOMRect, offset: DOMRect) => DOMRect;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Makes an element programmatically focusable by adding a `tabindex="-1"` attribute.
3
+ * Or does nothing if the element is already focusable 🤷🏻
4
+ * It's required to process keyboard events on an element that is not natively focusable.
5
+ */
6
+ export declare const programmaticallyFocusable: (container: HTMLElement) => void;
@@ -1 +1 @@
1
- .r6o-canvas-highlight-layer{position:fixed;top:0;bottom:0;left:0;width:100vw;height:100vh;pointer-events:none}.r6o-canvas-highlight-layer.bg{mix-blend-mode:multiply;z-index:1}.r6o-annotatable .r6o-span-highlight-layer{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none}.r6o-annotatable .r6o-span-highlight-layer.hidden{display:none}.r6o-annotatable .r6o-span-highlight-layer .r6o-annotation{position:absolute;display:block;border-width:0;border-style:solid}.r6o-annotation{box-sizing:content-box}.r6o-presence-layer{left:0;position:fixed;top:0;bottom:0;width:100vw;pointer-events:none}html,body{overscroll-behavior-y:none}.r6o-annotatable{position:relative;-webkit-tap-highlight-color:transparent}.hovered *{cursor:pointer}*::selection,::selection{background:#0080ff2e}::-moz-selection{background:#0080ff2e}
1
+ .r6o-canvas-highlight-layer{position:fixed;top:0;bottom:0;left:0;width:100vw;height:100vh;pointer-events:none}.r6o-canvas-highlight-layer.bg{mix-blend-mode:multiply;z-index:1}.r6o-annotatable .r6o-span-highlight-layer{height:100%;left:0;mix-blend-mode:multiply;pointer-events:none;position:absolute;top:0;width:100%}.r6o-annotatable .r6o-span-highlight-layer.hidden{display:none}.r6o-annotatable .r6o-span-highlight-layer .r6o-annotation{border-style:solid;border-width:0;box-sizing:content-box;display:block;position:absolute}.r6o-annotation{box-sizing:content-box}.r6o-presence-layer{left:0;position:fixed;top:0;bottom:0;width:100vw;pointer-events:none}html,body{overscroll-behavior-y:none}.r6o-annotatable{position:relative;-webkit-tap-highlight-color:transparent}.r6o-annotatable.no-focus-outline{outline:none}.hovered *{cursor:pointer}*::selection,::selection{background:#0080ff2e}::-moz-selection{background:#0080ff2e}