@recogito/text-annotator 3.0.0-rc.18 → 3.0.0-rc.2

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 (44) hide show
  1. package/dist/src/SelectionHandler.d.ts +2 -1
  2. package/dist/src/TextAnnotator.d.ts +0 -1
  3. package/dist/src/TextAnnotatorOptions.d.ts +0 -1
  4. package/dist/src/api/scrollIntoView.d.ts +2 -2
  5. package/dist/src/highlight/HighlightPainter.d.ts +19 -8
  6. package/dist/src/highlight/highlightLayer.d.ts +10 -0
  7. package/dist/src/highlight/index.d.ts +2 -2
  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} +1 -1
  11. package/dist/src/model/index.d.ts +1 -2
  12. package/dist/src/presence/PresencePainter.d.ts +3 -3
  13. package/dist/src/state/TextAnnotationStore.d.ts +0 -1
  14. package/dist/src/state/index.d.ts +1 -0
  15. package/dist/src/state/reviveTarget.d.ts +9 -0
  16. package/dist/src/utils/index.d.ts +0 -9
  17. package/dist/text-annotator.css +1 -1
  18. package/dist/text-annotator.es.js +821 -1391
  19. package/dist/text-annotator.es.js.map +1 -1
  20. package/dist/text-annotator.umd.js +1 -2
  21. package/dist/text-annotator.umd.js.map +1 -1
  22. package/package.json +11 -16
  23. package/dist/src/highlight/HighlightStyle.d.ts +0 -9
  24. package/dist/src/highlight/canvas/highlightRenderer.d.ts +0 -11
  25. package/dist/src/highlight/canvas/index.d.ts +0 -1
  26. package/dist/src/highlight/css/highlightRenderer.d.ts +0 -11
  27. package/dist/src/highlight/css/highlights.d.ts +0 -10
  28. package/dist/src/highlight/css/index.d.ts +0 -1
  29. package/dist/src/highlight/viewport.d.ts +0 -12
  30. package/dist/src/model/core/index.d.ts +0 -1
  31. package/dist/src/model/w3c/W3CTextAnnotation.d.ts +0 -33
  32. package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +0 -12
  33. package/dist/src/model/w3c/index.d.ts +0 -2
  34. package/dist/src/utils/debounce.d.ts +0 -1
  35. package/dist/src/utils/getAnnotatableFragment.d.ts +0 -5
  36. package/dist/src/utils/getQuoteContext.d.ts +0 -4
  37. package/dist/src/utils/isRevived.d.ts +0 -2
  38. package/dist/src/utils/rangeToSelector.d.ts +0 -2
  39. package/dist/src/utils/reviveAnnotation.d.ts +0 -2
  40. package/dist/src/utils/reviveSelector.d.ts +0 -11
  41. package/dist/src/utils/reviveTarget.d.ts +0 -2
  42. package/dist/src/utils/splitAnnotatableRanges.d.ts +0 -6
  43. package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
  44. package/dist/test/model/w3c/fixtures.d.ts +0 -3
@@ -1,6 +1,7 @@
1
1
  import { type User } from '@annotorious/core';
2
2
  import type { TextAnnotatorState } from './state';
3
+ import type { TextSelector } from './model';
4
+ export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
3
5
  export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, offsetReferenceSelector?: string) => {
4
- destroy: () => void;
5
6
  setUser: (user: User) => User;
6
7
  };
@@ -1,7 +1,6 @@
1
1
  import type { Annotator } from '@annotorious/core';
2
2
  import type { TextAnnotation } from './model';
3
3
  import type { TextAnnotatorOptions } from './TextAnnotatorOptions';
4
- import './TextAnnotator.css';
5
4
  export interface TextAnnotator<T extends unknown = TextAnnotation> extends Annotator<TextAnnotation, T> {
6
5
  element: HTMLElement;
7
6
  scrollIntoView(annotation: TextAnnotation): boolean;
@@ -3,7 +3,6 @@ import type { PresencePainterOptions } from './presence';
3
3
  import type { TextAnnotation } from './model';
4
4
  export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
5
5
  adapter?: FormatAdapter<TextAnnotation, T> | null;
6
- experimentalCSSRenderer?: boolean;
7
6
  offsetReferenceSelector?: string;
8
7
  pointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction);
9
8
  presence?: PresencePainterOptions;
@@ -1,3 +1,3 @@
1
- import type { TextAnnotationStore } from '../state';
2
- import type { TextAnnotation } from '../model';
1
+ import type { TextAnnotationStore } from 'src/state';
2
+ import type { TextAnnotation } from '../model/TextAnnotation';
3
3
  export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotation: TextAnnotation) => boolean;
@@ -1,9 +1,20 @@
1
- import type { AnnotationRects } from '../state';
2
- import type { HighlightStyle } from './HighlightStyle';
3
- import type { ViewportBounds } from './viewport';
4
- export interface HighlightPainter {
5
- clear(): void;
6
- destroy(): void;
7
- paint(annotation: AnnotationRects, viewportBounds: ViewportBounds, isSelected?: boolean): HighlightStyle;
8
- 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;
9
20
  }
@@ -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,2 +1,2 @@
1
- export * from './canvas';
2
- export * from './css';
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
1
  export * from './highlight';
2
2
  export * from './model';
3
3
  export * from './state';
4
- export * from './utils';
5
4
  export * from './presence/PresencePainterOptions';
6
5
  export * from './TextAnnotator';
7
6
  export * from './TextAnnotatorOptions';
8
- export type { Filter } from '@annotorious/core';
9
- import { Origin as _Origin } 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;
@@ -3,7 +3,7 @@ export interface TextAnnotation extends Annotation {
3
3
  target: TextAnnotationTarget;
4
4
  }
5
5
  export interface TextAnnotationTarget extends AnnotationTarget {
6
- selector: TextSelector[];
6
+ selector: TextSelector;
7
7
  }
8
8
  export interface TextSelector {
9
9
  quote: string;
@@ -1,2 +1 @@
1
- export * from './core';
2
- export * from './w3c';
1
+ export * from './TextAnnotation';
@@ -1,4 +1,4 @@
1
1
  import type { PresenceProvider } from '@annotorious/core';
2
- import type { HighlightPainter } from '../highlight/HighlightPainter';
3
- import type { PresencePainterOptions } from 'src/presence';
4
- export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
2
+ import type { HighlightPainter } from '../highlight';
3
+ import type { PresencePainterOptions } from './PresencePainterOptions';
4
+ export declare const createPainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -3,7 +3,6 @@ import type { TextAnnotation } from '../model';
3
3
  export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
4
4
  addAnnotation(annotation: TextAnnotation, origin: Origin): boolean;
5
5
  bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin: Origin): TextAnnotation[];
6
- bulkUpsertAnnotations(annotations: TextAnnotation[], origin: Origin): TextAnnotation[];
7
6
  getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
8
7
  getAt(x: number, y: number): TextAnnotation | undefined;
9
8
  getIntersecting(minX: number, minY: number, maxX: number, maxY: number): TextAnnotation[];
@@ -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,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
- 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)}