@recogito/text-annotator 3.0.0-rc.19 → 3.0.0-rc.3

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.
Files changed (49) hide show
  1. package/dist/src/SelectionHandler.d.ts +4 -4
  2. package/dist/src/TextAnnotator.d.ts +4 -7
  3. package/dist/src/TextAnnotatorOptions.d.ts +4 -8
  4. package/dist/src/api/scrollIntoView.d.ts +2 -3
  5. package/dist/src/highlight/HighlightPainter.d.ts +19 -11
  6. package/dist/src/highlight/highlightLayer.d.ts +10 -0
  7. package/dist/src/highlight/index.d.ts +2 -3
  8. package/dist/src/highlight/trackViewport.d.ts +3 -0
  9. package/dist/src/index.d.ts +3 -4
  10. package/dist/src/model/{core/TextAnnotation.d.ts → TextAnnotation.d.ts} +2 -4
  11. package/dist/src/model/index.d.ts +1 -2
  12. package/dist/src/presence/PresencePainter.d.ts +4 -5
  13. package/dist/src/state/TextAnnotationStore.d.ts +6 -7
  14. package/dist/src/state/TextAnnotatorState.d.ts +6 -6
  15. package/dist/src/state/index.d.ts +1 -0
  16. package/dist/src/state/reviveTarget.d.ts +9 -0
  17. package/dist/src/state/spatialTree.d.ts +6 -9
  18. package/dist/src/utils/index.d.ts +0 -9
  19. package/dist/text-annotator.css +1 -1
  20. package/dist/text-annotator.es.js +945 -1480
  21. package/dist/text-annotator.es.js.map +1 -1
  22. package/dist/text-annotator.umd.js +1 -2
  23. package/dist/text-annotator.umd.js.map +1 -1
  24. package/package.json +11 -17
  25. package/dist/src/highlight/Highlight.d.ts +0 -6
  26. package/dist/src/highlight/HighlightStyle.d.ts +0 -12
  27. package/dist/src/highlight/baseRenderer.d.ts +0 -21
  28. package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -4
  29. package/dist/src/highlight/canvas/index.d.ts +0 -1
  30. package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -6
  31. package/dist/src/highlight/highlights/index.d.ts +0 -1
  32. package/dist/src/highlight/span/index.d.ts +0 -1
  33. package/dist/src/highlight/span/spansRenderer.d.ts +0 -4
  34. package/dist/src/highlight/viewport.d.ts +0 -13
  35. package/dist/src/model/core/index.d.ts +0 -1
  36. package/dist/src/model/w3c/W3CTextAnnotation.d.ts +0 -34
  37. package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +0 -13
  38. package/dist/src/model/w3c/index.d.ts +0 -2
  39. package/dist/src/utils/debounce.d.ts +0 -1
  40. package/dist/src/utils/getAnnotatableFragment.d.ts +0 -5
  41. package/dist/src/utils/getQuoteContext.d.ts +0 -4
  42. package/dist/src/utils/isRevived.d.ts +0 -3
  43. package/dist/src/utils/rangeToSelector.d.ts +0 -3
  44. package/dist/src/utils/reviveAnnotation.d.ts +0 -3
  45. package/dist/src/utils/reviveSelector.d.ts +0 -12
  46. package/dist/src/utils/reviveTarget.d.ts +0 -3
  47. package/dist/src/utils/splitAnnotatableRanges.d.ts +0 -6
  48. package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
  49. package/dist/test/model/w3c/fixtures.d.ts +0 -4
@@ -1,7 +1,7 @@
1
- import { TextAnnotatorState } from './state';
2
- import { User } from '@annotorious/core';
3
-
1
+ import { type User } from '@annotorious/core';
2
+ import type { TextAnnotatorState } from './state';
3
+ import type { TextSelector } from './model';
4
+ export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
4
5
  export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, offsetReferenceSelector?: string) => {
5
- destroy: () => void;
6
6
  setUser: (user: User) => User;
7
7
  };
@@ -1,11 +1,8 @@
1
- import { TextAnnotatorOptions } from './TextAnnotatorOptions';
2
- import { TextAnnotation } from './model';
3
- import { TextAnnotatorState } from './state';
4
- import { Annotator } from '@annotorious/core';
5
-
6
- export interface TextAnnotator<E extends unknown = TextAnnotation> extends Annotator<TextAnnotation, E> {
1
+ import type { Annotator } from '@annotorious/core';
2
+ import type { TextAnnotation } from './model';
3
+ import type { TextAnnotatorOptions } from './TextAnnotatorOptions';
4
+ export interface TextAnnotator<T extends unknown = TextAnnotation> extends Annotator<TextAnnotation, T> {
7
5
  element: HTMLElement;
8
6
  scrollIntoView(annotation: TextAnnotation): boolean;
9
- state: TextAnnotatorState;
10
7
  }
11
8
  export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, opts?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
@@ -1,14 +1,10 @@
1
- import { HighlightStyleExpression } from './highlight/HighlightStyle';
2
- import { TextAnnotation } from './model';
3
- import { PresencePainterOptions } from './presence';
4
- import { FormatAdapter, PointerSelectAction } from '@annotorious/core';
5
-
1
+ import type { DrawingStyle, FormatAdapter, PointerSelectAction } from '@annotorious/core';
2
+ import type { PresencePainterOptions } from './presence';
3
+ import type { TextAnnotation } from './model';
6
4
  export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
7
5
  adapter?: FormatAdapter<TextAnnotation, T> | null;
8
- renderer?: RendererType;
9
6
  offsetReferenceSelector?: string;
10
7
  pointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction);
11
8
  presence?: PresencePainterOptions;
12
- style?: HighlightStyleExpression;
9
+ style?: DrawingStyle | ((annotation: TextAnnotation) => DrawingStyle);
13
10
  }
14
- export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
@@ -1,4 +1,3 @@
1
- import { TextAnnotation } from '../model';
2
- import { TextAnnotationStore } from '../state';
3
-
1
+ import type { TextAnnotationStore } from 'src/state';
2
+ import type { TextAnnotation } from '../model/TextAnnotation';
4
3
  export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotation: TextAnnotation) => boolean;
@@ -1,12 +1,20 @@
1
- import { ViewportBounds } from './viewport';
2
- import { HighlightStyle, HighlightStyleExpression } from './HighlightStyle';
3
- import { Highlight } from './Highlight';
4
-
5
- export interface HighlightPainter {
6
- clear(): void;
7
- destroy(): void;
8
- paint(highlight: Highlight, viewportBounds: ViewportBounds): HighlightStyle;
9
- reset(): void;
1
+ import type { DrawingStyle } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
+ import type { Rect } from '../state';
4
+ /**
5
+ * A painter implements the actual CANVAS highlight drawing logic.
6
+ */
7
+ export type HighlightPainter = {
8
+ paint(annotation: TextAnnotation, rects: Rect[], bg: CanvasRenderingContext2D, fg: CanvasRenderingContext2D, isSelected?: boolean, style?: DrawingStyle | ((annotation: TextAnnotation, selected?: boolean) => DrawingStyle)): void;
9
+ };
10
+ /**
11
+ * The default painter.
12
+ */
13
+ export declare const defaultPainter: HighlightPainter;
14
+ export interface HighlightStyle {
15
+ fill?: string;
16
+ fillOpacity?: number;
17
+ underline?: string;
18
+ underlineOpacity?: number;
19
+ underlineWidth?: number;
10
20
  }
11
- /** Helper **/
12
- export declare const paint: (highlight: Highlight, viewportBounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, zIndex?: number) => HighlightStyle;
@@ -0,0 +1,10 @@
1
+ import type { DrawingStyle, Filter, ViewportState } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
+ import type { TextAnnotatorState } from '../state';
4
+ import { type HighlightPainter } from './HighlightPainter';
5
+ export declare const createHighlightLayer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => {
6
+ redraw: () => number;
7
+ setDrawingStyle: (style: DrawingStyle | ((a: TextAnnotation, selected?: boolean) => DrawingStyle)) => void;
8
+ setFilter: (filter?: Filter) => void;
9
+ setPainter: (painter: HighlightPainter) => HighlightPainter;
10
+ };
@@ -1,3 +1,2 @@
1
- export * from './canvas';
2
- export * from './highlights';
3
- export * from './span';
1
+ export * from './highlightLayer';
2
+ export * from './HighlightPainter';
@@ -0,0 +1,3 @@
1
+ import type { ViewportState } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
+ export declare const trackViewport: (viewport: ViewportState) => (annotations: TextAnnotation[]) => void;
@@ -1,10 +1,9 @@
1
- import { _Origin } from '@annotorious/core';
2
1
  export * from './highlight';
3
2
  export * from './model';
4
3
  export * from './state';
5
- export * from './utils';
6
4
  export * from './presence/PresencePainterOptions';
7
5
  export * from './TextAnnotator';
8
6
  export * from './TextAnnotatorOptions';
9
- export type { Filter } from '@annotorious/core';
10
- export { _Origin as Origin };
7
+ export * from '@annotorious/core/src/model';
8
+ import { Origin as _Origin } from '@annotorious/core/src/state';
9
+ export declare const Origin: typeof _Origin;
@@ -1,13 +1,11 @@
1
- import { Annotation, AnnotationTarget } from '@annotorious/core';
2
-
1
+ import type { Annotation, AnnotationTarget } from '@annotorious/core';
3
2
  export interface TextAnnotation extends Annotation {
4
3
  target: TextAnnotationTarget;
5
4
  }
6
5
  export interface TextAnnotationTarget extends AnnotationTarget {
7
- selector: TextSelector[];
6
+ selector: TextSelector;
8
7
  }
9
8
  export interface TextSelector {
10
- id?: string;
11
9
  quote: string;
12
10
  start: number;
13
11
  end: number;
@@ -1,2 +1 @@
1
- export * from './core';
2
- export * from './w3c';
1
+ export * from './TextAnnotation';
@@ -1,5 +1,4 @@
1
- import { PresencePainterOptions } from 'src/presence';
2
- import { HighlightPainter } from '../highlight/HighlightPainter';
3
- import { PresenceProvider } from '@annotorious/core';
4
-
5
- export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
1
+ import type { PresenceProvider } from '@annotorious/core';
2
+ import type { HighlightPainter } from '../highlight';
3
+ import type { PresencePainterOptions } from './PresencePainterOptions';
4
+ export declare const createPainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -1,13 +1,12 @@
1
- import { TextAnnotation } from '../model';
2
- import { Origin, Store } from '@annotorious/core';
3
-
1
+ import type { Origin, Store } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
4
3
  export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
5
- addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
6
- bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin?: Origin): TextAnnotation[];
7
- bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
4
+ addAnnotation(annotation: TextAnnotation, origin: Origin): boolean;
5
+ bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin: Origin): TextAnnotation[];
8
6
  getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
9
7
  getAt(x: number, y: number): TextAnnotation | undefined;
10
- getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
8
+ getIntersecting(minX: number, minY: number, maxX: number, maxY: number): TextAnnotation[];
9
+ getIntersectingRects(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
11
10
  recalculatePositions(): void;
12
11
  }
13
12
  export interface AnnotationRects {
@@ -1,11 +1,11 @@
1
- import { TextAnnotationStore } from './TextAnnotationStore';
2
- import { TextAnnotation } from '../model';
3
- import { PointerSelectAction, ViewportState, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
4
-
5
- export interface TextAnnotatorState extends AnnotatorState<TextAnnotation> {
1
+ import type { PointerSelectAction, ViewportState } from '@annotorious/core';
2
+ import { AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
3
+ import type { TextAnnotation } from '../model';
4
+ import type { TextAnnotationStore } from './TextAnnotationStore';
5
+ export type TextAnnotatorState = AnnotatorState<TextAnnotation> & {
6
6
  store: TextAnnotationStore;
7
7
  selection: SelectionState<TextAnnotation>;
8
8
  hover: HoverState<TextAnnotation>;
9
9
  viewport: ViewportState;
10
- }
10
+ };
11
11
  export declare const createTextAnnotatorState: (container: HTMLElement, defaultPointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction)) => TextAnnotatorState;
@@ -1,2 +1,3 @@
1
+ export * from './reviveTarget';
1
2
  export * from './TextAnnotationStore';
2
3
  export * from './TextAnnotatorState';
@@ -0,0 +1,9 @@
1
+ import type { TextAnnotationTarget } from '../model';
2
+ /**
3
+ * Recalculates the DOM range from the given text annotation target.
4
+ *
5
+ * @param annotation the text annotation
6
+ * @param container the HTML container of the annotated content
7
+ * @returns the DOM range
8
+ */
9
+ export declare const reviveTarget: (target: TextAnnotationTarget, container: HTMLElement) => TextAnnotationTarget;
@@ -1,8 +1,6 @@
1
- import { AnnotationRects } from './TextAnnotationStore';
2
- import { TextAnnotation, TextAnnotationTarget } from '../model';
3
- import { Store } from '@annotorious/core';
4
-
5
- interface IndexedHighlightRect {
1
+ import type { Store } from '@annotorious/core';
2
+ import type { TextAnnotation, TextAnnotationTarget } from '../model';
3
+ export interface IndexedHighlightRect {
6
4
  minX: number;
7
5
  minY: number;
8
6
  maxX: number;
@@ -16,9 +14,9 @@ export declare const createSpatialTree: (store: Store<TextAnnotation>, container
16
14
  all: () => IndexedHighlightRect[][];
17
15
  clear: () => void;
18
16
  getAt: (x: number, y: number) => string | undefined;
19
- getAnnotationBounds: (id: string) => DOMRect;
20
- getAnnotationRects: (id: string) => DOMRect[];
21
- getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects[];
17
+ getBoundsForAnnotation: (id: string) => DOMRect;
18
+ getDOMRectsForAnnotation: (id: string) => DOMRect[];
19
+ getIntersectingRects: (minX: number, minY: number, maxX: number, maxY: number) => IndexedHighlightRect[];
22
20
  insert: (target: TextAnnotationTarget) => void;
23
21
  recalculate: () => void;
24
22
  remove: (target: TextAnnotationTarget) => void;
@@ -26,4 +24,3 @@ export declare const createSpatialTree: (store: Store<TextAnnotation>, container
26
24
  size: () => number;
27
25
  update: (target: TextAnnotationTarget) => void;
28
26
  };
29
- export {};
@@ -1,12 +1,3 @@
1
- export * from './debounce';
2
- export * from './getAnnotatableFragment';
3
1
  export * from './getClientRectsPonyfill';
4
- export * from './getQuoteContext';
5
- export * from './isRevived';
6
2
  export * from './mergeClientRects';
7
- export * from './rangeToSelector';
8
- export * from './reviveAnnotation';
9
- export * from './reviveSelector';
10
- export * from './reviveTarget';
11
- export * from './splitAnnotatableRanges';
12
3
  export * from './trimRange';
@@ -1 +1 @@
1
- .r6o-annotatable .r6o-span-highlight-layer{height:100%;left:0;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;position:absolute;display:block}html,body{overscroll-behavior-y:none}.r6o-annotatable{-webkit-tap-highlight-color:transparent}.r6o-annotatable,.r6o-annotatable *{position:relative}.hovered *{cursor:pointer}.r6o-highlight-layer{left:0;position:fixed;top:0;bottom:0;width:100vw;pointer-events:none}*::selection,::selection{background:#0080ff2e}::-moz-selection{background:#0080ff2e}
1
+ html,body{overscroll-behavior-y:none}.r6o-annotatable,.r6o-annotatable *{position:relative}.r6o-annotatable.hovered{cursor:pointer}.r6o-highlight-layer{height:100vh;left:0;position:fixed;top:0;pointer-events:none;width:100vw}*::selection,::selection{background:rgba(0,128,255,.18)}::-moz-selection{background:rgba(0,128,255,.18)}