@recogito/text-annotator 3.4.8 → 4.0.0-beta

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 (123) hide show
  1. package/dist/index.d.ts +409 -11
  2. package/dist/model/core/index.d.ts +1 -1
  3. package/dist/model/w3c/index.d.ts +2 -2
  4. package/dist/{src/model/w3c/W3CTextFormatAdapter.d.ts → model/w3c/w3c-text-format-adapter.d.ts} +2 -2
  5. package/dist/rendering/base-renderer.d.ts +31 -0
  6. package/dist/{src/highlight/HighlightStyle.d.ts → rendering/highlight-style.d.ts} +4 -1
  7. package/dist/{src/highlight/Highlight.d.ts → rendering/highlight.d.ts} +2 -1
  8. package/dist/rendering/index.d.ts +4 -0
  9. package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +6 -0
  10. package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
  11. package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
  12. package/dist/rendering/renderer-spans/index.d.ts +1 -0
  13. package/dist/rendering/renderer-spans/spans-renderer.d.ts +2 -0
  14. package/dist/{SelectionHandler.d.ts → selection-handler.d.ts} +5 -5
  15. package/dist/src/index.d.ts +8 -7
  16. package/dist/state/index.d.ts +2 -2
  17. package/dist/state/{spatialTree.d.ts → spatial-tree.d.ts} +4 -4
  18. package/dist/{src/state/TextAnnotationStore.d.ts → state/text-annotation-store.d.ts} +3 -0
  19. package/dist/{src/state/TextAnnotatorState.d.ts → state/text-annotator-state.d.ts} +2 -2
  20. package/dist/{src/TextAnnotatorOptions.d.ts → text-annotator-options.d.ts} +4 -5
  21. package/dist/text-annotator.css +1 -1
  22. package/dist/{TextAnnotator.d.ts → text-annotator.d.ts} +7 -8
  23. package/dist/text-annotator.es.js +745 -824
  24. package/dist/text-annotator.es.js.map +1 -1
  25. package/dist/text-annotator.umd.js +2 -2
  26. package/dist/text-annotator.umd.js.map +1 -1
  27. package/dist/utils/annotation/index.d.ts +4 -0
  28. package/dist/{src/utils/rangeToSelector.d.ts → utils/annotation/range-to-selector.d.ts} +1 -1
  29. package/dist/{src/utils/reviveSelector.d.ts → utils/annotation/revive-annotation.d.ts} +4 -1
  30. package/dist/{api/scrollIntoView.d.ts → utils/annotation/scroll-into-view.d.ts} +2 -2
  31. package/dist/utils/dom/index.d.ts +7 -0
  32. package/dist/utils/events/index.d.ts +3 -0
  33. package/dist/utils/highlight/compute-z-index.d.ts +3 -0
  34. package/dist/utils/highlight/index.d.ts +4 -0
  35. package/package.json +3 -3
  36. package/dist/TextAnnotatorOptions.d.ts +0 -35
  37. package/dist/api/index.d.ts +0 -1
  38. package/dist/highlight/Highlight.d.ts +0 -5
  39. package/dist/highlight/HighlightPainter.d.ts +0 -11
  40. package/dist/highlight/HighlightStyle.d.ts +0 -11
  41. package/dist/highlight/Renderer.d.ts +0 -22
  42. package/dist/highlight/RendererImplementation.d.ts +0 -9
  43. package/dist/highlight/baseRenderer.d.ts +0 -22
  44. package/dist/highlight/canvas/canvasRenderer.d.ts +0 -5
  45. package/dist/highlight/canvas/index.d.ts +0 -1
  46. package/dist/highlight/color.d.ts +0 -2
  47. package/dist/highlight/highlights/highlightsRenderer.d.ts +0 -6
  48. package/dist/highlight/highlights/index.d.ts +0 -1
  49. package/dist/highlight/index.d.ts +0 -8
  50. package/dist/highlight/span/color.d.ts +0 -2
  51. package/dist/highlight/span/index.d.ts +0 -2
  52. package/dist/highlight/span/spansRenderer.d.ts +0 -3
  53. package/dist/highlight/viewport.d.ts +0 -12
  54. package/dist/model/core/TextAnnotation.d.ts +0 -15
  55. package/dist/model/w3c/W3CTextAnnotation.d.ts +0 -34
  56. package/dist/model/w3c/W3CTextFormatAdapter.d.ts +0 -12
  57. package/dist/presence/PresencePainter.d.ts +0 -5
  58. package/dist/presence/PresencePainterOptions.d.ts +0 -3
  59. package/dist/presence/index.d.ts +0 -2
  60. package/dist/src/SelectionHandler.d.ts +0 -9
  61. package/dist/src/TextAnnotator.d.ts +0 -12
  62. package/dist/src/api/index.d.ts +0 -1
  63. package/dist/src/api/scrollIntoView.d.ts +0 -3
  64. package/dist/src/highlight/HighlightPainter.d.ts +0 -11
  65. package/dist/src/highlight/baseRenderer.d.ts +0 -20
  66. package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -4
  67. package/dist/src/highlight/canvas/index.d.ts +0 -1
  68. package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -6
  69. package/dist/src/highlight/highlights/index.d.ts +0 -1
  70. package/dist/src/highlight/index.d.ts +0 -6
  71. package/dist/src/highlight/span/color.d.ts +0 -2
  72. package/dist/src/highlight/span/index.d.ts +0 -1
  73. package/dist/src/highlight/span/spansRenderer.d.ts +0 -4
  74. package/dist/src/model/core/index.d.ts +0 -1
  75. package/dist/src/model/index.d.ts +0 -2
  76. package/dist/src/model/w3c/index.d.ts +0 -2
  77. package/dist/src/presence/PresencePainter.d.ts +0 -4
  78. package/dist/src/presence/PresencePainterOptions.d.ts +0 -3
  79. package/dist/src/presence/index.d.ts +0 -2
  80. package/dist/src/state/index.d.ts +0 -2
  81. package/dist/src/state/spatialTree.d.ts +0 -28
  82. package/dist/src/utils/index.d.ts +0 -17
  83. package/dist/src/utils/isRevived.d.ts +0 -2
  84. package/dist/src/utils/isWhitespaceOrEmpty.d.ts +0 -2
  85. package/dist/src/utils/reviveAnnotation.d.ts +0 -2
  86. package/dist/src/utils/reviveTarget.d.ts +0 -2
  87. package/dist/state/TextAnnotationStore.d.ts +0 -28
  88. package/dist/state/TextAnnotatorState.d.ts +0 -12
  89. package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
  90. package/dist/test/model/w3c/fixtures.d.ts +0 -3
  91. package/dist/utils/cancelSingleClickEvents.d.ts +0 -6
  92. package/dist/utils/cloneEvents.d.ts +0 -11
  93. package/dist/utils/device.d.ts +0 -1
  94. package/dist/utils/getHighlightClientRects.d.ts +0 -1
  95. package/dist/utils/getQuoteContext.d.ts +0 -4
  96. package/dist/utils/index.d.ts +0 -18
  97. package/dist/utils/isNotAnnotatable.d.ts +0 -4
  98. package/dist/utils/isRevived.d.ts +0 -2
  99. package/dist/utils/mergeClientRects.d.ts +0 -2
  100. package/dist/utils/programmaticallyFocusable.d.ts +0 -6
  101. package/dist/utils/rangeToSelector.d.ts +0 -2
  102. package/dist/utils/reviveAnnotation.d.ts +0 -2
  103. package/dist/utils/reviveSelector.d.ts +0 -11
  104. package/dist/utils/reviveTarget.d.ts +0 -2
  105. package/dist/utils/splitAnnotatableRanges.d.ts +0 -5
  106. package/dist/utils/trimRangeToContainer.d.ts +0 -1
  107. /package/dist/{src/model/core/TextAnnotation.d.ts → model/core/text-annotation.d.ts} +0 -0
  108. /package/dist/{src/model/w3c/W3CTextAnnotation.d.ts → model/w3c/w3c-text-annotation.d.ts} +0 -0
  109. /package/dist/{src/highlight → rendering}/viewport.d.ts +0 -0
  110. /package/dist/{src/utils/getQuoteContext.d.ts → utils/annotation/get-quote-context.d.ts} +0 -0
  111. /package/dist/{src/utils → utils/dom}/device.d.ts +0 -0
  112. /package/dist/{src/utils/isNotAnnotatable.d.ts → utils/dom/is-not-annotatable.d.ts} +0 -0
  113. /package/dist/utils/{isWhitespaceOrEmpty.d.ts → dom/is-whitespace-or-empty.d.ts} +0 -0
  114. /package/dist/utils/{mergeRanges.d.ts → dom/merge-ranges.d.ts} +0 -0
  115. /package/dist/{src/utils/programmaticallyFocusable.d.ts → utils/dom/programmatically-focusable.d.ts} +0 -0
  116. /package/dist/{src/utils/splitAnnotatableRanges.d.ts → utils/dom/split-annotatable-ranges.d.ts} +0 -0
  117. /package/dist/{src/utils/trimRangeToContainer.d.ts → utils/dom/trim-range-to-container.d.ts} +0 -0
  118. /package/dist/{src/utils/cancelSingleClickEvents.d.ts → utils/events/cancel-single-click-events.d.ts} +0 -0
  119. /package/dist/{src/utils/cloneEvents.d.ts → utils/events/clone-events.d.ts} +0 -0
  120. /package/dist/{src/utils → utils/events}/debounce.d.ts +0 -0
  121. /package/dist/{src/utils/getHighlightClientRects.d.ts → utils/highlight/get-highlight-client-rects.d.ts} +0 -0
  122. /package/dist/{src/utils/mergeClientRects.d.ts → utils/highlight/merge-client-rects.d.ts} +0 -0
  123. /package/dist/utils/{rectsToBounds.d.ts → highlight/rects-to-bounds.d.ts} +0 -0
@@ -0,0 +1,4 @@
1
+ export * from './get-quote-context';
2
+ export * from './range-to-selector';
3
+ export * from './revive-annotation';
4
+ export * from './scroll-into-view';
@@ -1,2 +1,2 @@
1
- import { TextSelector } from '../model';
1
+ import { TextSelector } from '../../model';
2
2
  export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
@@ -1,4 +1,5 @@
1
- import { TextSelector } from '../model';
1
+ import { TextAnnotation, TextAnnotationTarget, TextSelector } from '../../model';
2
+ export declare const isRevived: (selector: TextSelector[]) => boolean;
2
3
  /**
3
4
  * Creates a new selector object with the revived DOM range from the given text annotation position
4
5
  * Only the annotatable elements are processed and counted towards the range
@@ -9,3 +10,5 @@ import { TextSelector } from '../model';
9
10
  * @returns the revived selector
10
11
  */
11
12
  export declare const reviveSelector: <T extends TextSelector>(selector: T, container: HTMLElement) => T;
13
+ export declare const reviveTarget: <T extends TextAnnotationTarget = TextAnnotationTarget>(target: T, container: HTMLElement) => T;
14
+ export declare const reviveAnnotation: <T extends TextAnnotation>(annotation: T, container: HTMLElement) => T;
@@ -1,3 +1,3 @@
1
- import type { TextAnnotationStore } from '../state';
2
- import type { TextAnnotation } from '../model';
1
+ import { TextAnnotationStore } from '../../state';
2
+ import { TextAnnotation } from '../../model';
3
3
  export declare const scrollIntoView: <I extends TextAnnotation = TextAnnotation>(container: HTMLElement, store: TextAnnotationStore<I>) => <E extends Element = Element>(annotationOrId: string | I, scrollParentOrId?: string | E) => boolean;
@@ -0,0 +1,7 @@
1
+ export * from './device';
2
+ export * from './is-not-annotatable';
3
+ export * from './is-whitespace-or-empty';
4
+ export * from './merge-ranges';
5
+ export * from './programmatically-focusable';
6
+ export * from './split-annotatable-ranges';
7
+ export * from './trim-range-to-container';
@@ -0,0 +1,3 @@
1
+ export * from './cancel-single-click-events';
2
+ export * from './clone-events';
3
+ export * from './debounce';
@@ -0,0 +1,3 @@
1
+ import { Highlight } from '../../rendering';
2
+ import { Rect } from '../../state';
3
+ export declare const computeZIndex: (rect: Rect, all: Highlight[]) => number;
@@ -0,0 +1,4 @@
1
+ export * from './compute-z-index';
2
+ export * from './get-highlight-client-rects';
3
+ export * from './merge-client-rects';
4
+ export * from './rects-to-bounds';
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@recogito/text-annotator",
3
- "version": "3.4.8",
3
+ "version": "4.0.0-beta",
4
4
  "description": "A JavaScript text annotation library",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "start": "vite --host",
10
- "build": "tsc -p tsconfig.build.json && vite build && vite build --config vite.config.umd.ts",
10
+ "build": "vite build && vite build --config vite.config.umd.ts",
11
11
  "preview": "vite preview",
12
12
  "test": "vitest"
13
13
  },
@@ -32,7 +32,7 @@
32
32
  "typescript": "5.9.3",
33
33
  "vite": "^7.2.2",
34
34
  "vite-plugin-externalize-deps": "^0.10.0",
35
- "vitest": "^4.0.9"
35
+ "vitest": "^4.0.10"
36
36
  },
37
37
  "dependencies": {
38
38
  "@annotorious/core": "^3.7.13",
@@ -1,35 +0,0 @@
1
- import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
- import type { PresencePainterOptions } from './presence';
3
- import type { TextAnnotation } from './model';
4
- import type { HighlightStyleExpression, RendererFactory } from './highlight';
5
- export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
6
- adapter?: FormatAdapter<I, E> | null;
7
- allowModifierSelect?: boolean;
8
- annotatingEnabled?: boolean;
9
- /**
10
- * Determines whether an active selection should be dismissed
11
- * when a user ends their interaction (click, selection)
12
- * on a non-annotatable element.
13
- * - NEVER - don't dismiss the selection, ignore the action.
14
- * - ALWAYS - dismiss the selection.
15
- * - function - a custom matcher that takes an event and container as arguments.
16
- * Returns `true` if the selection should be dismissed.
17
- *
18
- * @defaut NEVER
19
- */
20
- dismissOnNotAnnotatable?: DismissOnNotAnnotatableExpression;
21
- mergeHighlights?: {
22
- horizontalTolerance?: number;
23
- verticalTolerance?: number;
24
- };
25
- offsetReferenceSelector?: string;
26
- presence?: PresencePainterOptions;
27
- renderer?: RendererType | RendererFactory;
28
- selectionMode?: 'shortest' | 'all';
29
- style?: HighlightStyleExpression;
30
- user?: User;
31
- userSelectAction?: UserSelectActionExpression<E>;
32
- }
33
- export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
34
- export type DismissOnNotAnnotatableExpression = 'NEVER' | 'ALWAYS' | ((event: Event, container: HTMLElement) => boolean);
35
- export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
@@ -1 +0,0 @@
1
- export * from './scrollIntoView';
@@ -1,5 +0,0 @@
1
- import type { AnnotationState } from '@annotorious/core';
2
- import type { AnnotationRects } from '../state';
3
- export interface Highlight extends AnnotationRects {
4
- state: AnnotationState;
5
- }
@@ -1,11 +0,0 @@
1
- import type { Highlight } from './Highlight';
2
- import type { HighlightStyle, HighlightStyleExpression } from './HighlightStyle';
3
- import type { ViewportBounds } from './viewport';
4
- export interface HighlightPainter {
5
- clear(): void;
6
- destroy(): void;
7
- paint(highlight: Highlight, viewportBounds: ViewportBounds): HighlightStyle;
8
- reset(): void;
9
- }
10
- /** Helper **/
11
- export declare const paint: (highlight: Highlight, viewportBounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, zIndex?: number) => HighlightStyle;
@@ -1,11 +0,0 @@
1
- import type { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
2
- import type { TextAnnotation } from 'src/model';
3
- export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity'> {
4
- underlineStyle?: string;
5
- underlineColor?: Color;
6
- underlineOffset?: number;
7
- underlineThickness?: number;
8
- }
9
- export type HighlightStyleExpression = HighlightStyle | (<I extends TextAnnotation = TextAnnotation>(annotation: I, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
10
- export declare const DEFAULT_STYLE: HighlightStyle;
11
- export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
@@ -1,22 +0,0 @@
1
- import { type Filter, type ViewportState } from '@annotorious/core';
2
- import type { TextAnnotation } from '../model';
3
- import type { TextAnnotatorState } from '../state';
4
- import { type ViewportBounds } from './viewport';
5
- import type { HighlightPainter } from './HighlightPainter';
6
- import type { Highlight } from './Highlight';
7
- import type { HighlightStyleExpression } from './HighlightStyle';
8
- export type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
9
- export interface RendererImplementation {
10
- destroy(): void;
11
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
12
- setVisible(visible: boolean): void;
13
- }
14
- export interface Renderer {
15
- destroy(): void;
16
- redraw(force?: boolean): void;
17
- setStyle(style?: HighlightStyleExpression): void;
18
- setFilter(filter?: Filter): void;
19
- setPainter(painter?: HighlightPainter): void;
20
- setVisible(visible: boolean): void;
21
- }
22
- export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
@@ -1,9 +0,0 @@
1
- import type { Highlight } from './Highlight';
2
- import type { HighlightPainter } from './HighlightPainter';
3
- import type { HighlightStyleExpression } from './HighlightStyle';
4
- import type { ViewportBounds } from './viewport';
5
- export interface RendererImplementation {
6
- destroy(): void;
7
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
8
- setVisible(visible: boolean): void;
9
- }
@@ -1,22 +0,0 @@
1
- import { type Filter, type ViewportState } from '@annotorious/core';
2
- import type { TextAnnotatorState } from '../state';
3
- import { type ViewportBounds } from './viewport';
4
- import type { HighlightPainter } from './HighlightPainter';
5
- import type { Highlight } from './Highlight';
6
- import type { HighlightStyleExpression } from './HighlightStyle';
7
- import type { TextAnnotation } from 'src/model';
8
- export interface RendererImplementation {
9
- destroy(): void;
10
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
11
- setVisible(visible: boolean): void;
12
- }
13
- export type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
14
- export interface Renderer {
15
- destroy(): void;
16
- redraw(force?: boolean): void;
17
- setStyle(style?: HighlightStyleExpression): void;
18
- setFilter(filter?: Filter): void;
19
- setPainter(painter?: HighlightPainter): void;
20
- setVisible(visible: boolean): void;
21
- }
22
- export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
@@ -1,5 +0,0 @@
1
- import type { ViewportState } from '@annotorious/core';
2
- import type { TextAnnotatorState } from '../../state';
3
- import type { TextAnnotation } from 'src/model';
4
- import './canvasRenderer.css';
5
- export declare const createCanvasRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("..").Renderer;
@@ -1 +0,0 @@
1
- export * from './canvasRenderer';
@@ -1,2 +0,0 @@
1
- import { type HighlightStyle } from './HighlightStyle';
2
- export declare const getBackgroundColor: (style?: HighlightStyle) => string;
@@ -1,6 +0,0 @@
1
- import type { ViewportState } from '@annotorious/core';
2
- import type { TextAnnotatorState } from 'src/state';
3
- import { type RendererImplementation } from '../Renderer';
4
- import type { TextAnnotation } from 'src/model';
5
- export declare const createRenderer: () => RendererImplementation;
6
- export declare const createHighlightsRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("..").Renderer;
@@ -1 +0,0 @@
1
- export * from './highlightsRenderer';
@@ -1,8 +0,0 @@
1
- export * from './canvas';
2
- export * from './highlights';
3
- export * from './span';
4
- export * from './Highlight';
5
- export * from './HighlightPainter';
6
- export * from './HighlightStyle';
7
- export * from './Renderer';
8
- export * from './viewport';
@@ -1,2 +0,0 @@
1
- import { type HighlightStyle } from '../HighlightStyle';
2
- export declare const getBackgroundColor: (style?: HighlightStyle) => string;
@@ -1,2 +0,0 @@
1
- export * from './color';
2
- export * from './spansRenderer';
@@ -1,3 +0,0 @@
1
- import { type RendererFactory } from '../Renderer';
2
- import './spansRenderer.css';
3
- export declare const createSpansRenderer: RendererFactory;
@@ -1,12 +0,0 @@
1
- import type { ViewportState } from '@annotorious/core';
2
- import type { TextAnnotation } from '../model';
3
- export interface ViewportBounds {
4
- top: number;
5
- left: number;
6
- minX: number;
7
- minY: number;
8
- maxX: number;
9
- maxY: number;
10
- }
11
- export declare const getViewportBounds: (container: HTMLElement) => ViewportBounds;
12
- export declare const trackViewport: (viewport: ViewportState) => (annotations: TextAnnotation[]) => void;
@@ -1,15 +0,0 @@
1
- import type { Annotation, AnnotationTarget } from '@annotorious/core';
2
- export interface TextAnnotation extends Annotation {
3
- target: TextAnnotationTarget;
4
- }
5
- export interface TextAnnotationTarget extends AnnotationTarget {
6
- selector: TextSelector[];
7
- }
8
- export interface TextSelector {
9
- id?: string;
10
- quote: string;
11
- start: number;
12
- end: number;
13
- range: Range;
14
- offsetReference?: HTMLElement;
15
- }
@@ -1,34 +0,0 @@
1
- import type { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
2
- export interface W3CTextAnnotation extends W3CAnnotation {
3
- target: W3CTextAnnotationTarget | W3CTextAnnotationTarget[];
4
- stylesheet?: W3CAnnotationStylesheet;
5
- }
6
- export interface W3CTextAnnotationTarget extends W3CAnnotationTarget {
7
- selector: W3CTextSelector | W3CTextSelector[];
8
- styleClass?: string;
9
- scope?: string;
10
- }
11
- /**
12
- * Matches the `Text Quote Selector` spec
13
- * @see https://www.w3.org/TR/annotation-model/#text-quote-selector
14
- */
15
- export interface W3CTextQuoteSelector {
16
- type: 'TextQuoteSelector';
17
- exact: string;
18
- prefix?: string;
19
- suffix?: string;
20
- }
21
- /**
22
- * Matches the `Text Position Selector` spec
23
- * @see https://www.w3.org/TR/annotation-model/#text-position-selector
24
- */
25
- export interface W3CTextPositionSelector {
26
- type: 'TextPositionSelector';
27
- start: number;
28
- end: number;
29
- }
30
- export type W3CTextSelector = W3CTextQuoteSelector | W3CTextPositionSelector;
31
- export type W3CAnnotationStylesheet = string | {
32
- type: 'CssStylesheet';
33
- value: string;
34
- };
@@ -1,12 +0,0 @@
1
- import { type FormatAdapter, type ParseResult } from '@annotorious/core';
2
- import type { TextAnnotation } from '../core';
3
- import type { W3CTextAnnotation } from '../w3c';
4
- export type W3CTextFormatAdapter<I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation> = FormatAdapter<I, E>;
5
- /**
6
- * @param source - the IRI of the annotated content
7
- * @param container - the HTML container of the annotated content,
8
- * Required to locate the content's `range` within the DOM
9
- */
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;
@@ -1,5 +0,0 @@
1
- import type { PresenceProvider } from '@annotorious/core';
2
- import type { HighlightPainter } from '../highlight';
3
- import type { PresencePainterOptions } from '../presence';
4
- import './PresencePainter.css';
5
- export declare const createPresencePainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -1,3 +0,0 @@
1
- export interface PresencePainterOptions {
2
- font?: string;
3
- }
@@ -1,2 +0,0 @@
1
- export * from './PresencePainter';
2
- export * from './PresencePainterOptions';
@@ -1,9 +0,0 @@
1
- import { Filter, User } from '@annotorious/core';
2
- import { TextAnnotatorState } from './state';
3
- import { TextAnnotation } from './model';
4
- import { TextAnnotatorOptions } from './TextAnnotatorOptions';
5
- export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
6
- destroy: () => void;
7
- setFilter: (filter?: Filter) => Filter;
8
- setUser: (user?: User) => User;
9
- };
@@ -1,12 +0,0 @@
1
- import { Annotator } from '@annotorious/core';
2
- import { HighlightStyleExpression } from './highlight';
3
- import { TextAnnotatorState } from './state';
4
- import { TextAnnotation } from './model';
5
- import { TextAnnotatorOptions } from './TextAnnotatorOptions';
6
- export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
7
- element: HTMLElement;
8
- setStyle(style: HighlightStyleExpression | undefined): void;
9
- scrollIntoView(annotationOrId: I | string): boolean;
10
- state: TextAnnotatorState<I, E>;
11
- }
12
- export declare const createTextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;
@@ -1 +0,0 @@
1
- export * from './scrollIntoView';
@@ -1,3 +0,0 @@
1
- import { TextAnnotationStore } from '../state';
2
- import { TextAnnotation } from '../model';
3
- export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotationOrId: string | TextAnnotation) => boolean;
@@ -1,11 +0,0 @@
1
- import { Highlight } from './Highlight';
2
- import { HighlightStyle, HighlightStyleExpression } from './HighlightStyle';
3
- import { ViewportBounds } from './viewport';
4
- export interface HighlightPainter {
5
- clear(): void;
6
- destroy(): void;
7
- paint(highlight: Highlight, viewportBounds: ViewportBounds): HighlightStyle;
8
- reset(): void;
9
- }
10
- /** Helper **/
11
- export declare const paint: (highlight: Highlight, viewportBounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, zIndex?: number) => HighlightStyle;
@@ -1,20 +0,0 @@
1
- import { Filter, ViewportState } from '@annotorious/core';
2
- import { TextAnnotatorState } from '../state';
3
- import { ViewportBounds } from './viewport';
4
- import { HighlightPainter } from './HighlightPainter';
5
- import { Highlight } from './Highlight';
6
- import { HighlightStyleExpression } from './HighlightStyle';
7
- export interface RendererImplementation {
8
- destroy(): void;
9
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
10
- setVisible(visible: boolean): void;
11
- }
12
- export interface Renderer {
13
- destroy(): void;
14
- redraw(force?: boolean): void;
15
- setStyle(style?: HighlightStyleExpression): void;
16
- setFilter(filter?: Filter): void;
17
- setPainter(painter?: HighlightPainter): void;
18
- setVisible(visible: boolean): void;
19
- }
20
- export declare const createBaseRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
@@ -1,4 +0,0 @@
1
- import { ViewportState } from '@annotorious/core';
2
- import { TextAnnotatorState } from '../../state';
3
- import { TextAnnotation } from 'src/model';
4
- export declare const createCanvasRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1 +0,0 @@
1
- export * from './canvasRenderer';
@@ -1,6 +0,0 @@
1
- import { ViewportState } from '@annotorious/core';
2
- import { TextAnnotatorState } from 'src/state';
3
- import { RendererImplementation } from '../baseRenderer';
4
- import { TextAnnotation } from 'src/model';
5
- export declare const createRenderer: () => RendererImplementation;
6
- export declare const createHighlightsRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1 +0,0 @@
1
- export * from './highlightsRenderer';
@@ -1,6 +0,0 @@
1
- export * from './Highlight';
2
- export * from './HighlightStyle';
3
- export * from './HighlightPainter';
4
- export * from './canvas';
5
- export * from './highlights';
6
- export * from './span';
@@ -1,2 +0,0 @@
1
- import { HighlightStyle } from '../HighlightStyle';
2
- export declare const getBackgroundColor: (style?: HighlightStyle) => string;
@@ -1 +0,0 @@
1
- export * from './spansRenderer';
@@ -1,4 +0,0 @@
1
- import { ViewportState } from '@annotorious/core';
2
- import { TextAnnotatorState } from '../../state';
3
- import { TextAnnotation } from 'src/model';
4
- export declare const createSpansRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1 +0,0 @@
1
- export * from './TextAnnotation';
@@ -1,2 +0,0 @@
1
- export * from './core';
2
- export * from './w3c';
@@ -1,2 +0,0 @@
1
- export * from './W3CTextAnnotation';
2
- export * from './W3CTextFormatAdapter';
@@ -1,4 +0,0 @@
1
- import { PresenceProvider } from '@annotorious/core';
2
- import { HighlightPainter } from '../highlight';
3
- import { PresencePainterOptions } from '../presence';
4
- export declare const createPresencePainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -1,3 +0,0 @@
1
- export interface PresencePainterOptions {
2
- font?: string;
3
- }
@@ -1,2 +0,0 @@
1
- export * from './PresencePainter';
2
- export * from './PresencePainterOptions';
@@ -1,2 +0,0 @@
1
- export * from './TextAnnotationStore';
2
- export * from './TextAnnotatorState';
@@ -1,28 +0,0 @@
1
- import { Store } from '@annotorious/core';
2
- import { TextAnnotation, TextAnnotationTarget } from '../model';
3
- import { AnnotationRects } from './TextAnnotationStore';
4
- interface IndexedHighlightRect {
5
- minX: number;
6
- minY: number;
7
- maxX: number;
8
- maxY: number;
9
- annotation: {
10
- id: string;
11
- rects: DOMRect[];
12
- };
13
- }
14
- export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<T>, container: HTMLElement, hMergeTolerance?: number, vMergeTolerance?: number) => {
15
- all: () => IndexedHighlightRect[][];
16
- clear: () => void;
17
- getAt: (x: number, y: number, all?: boolean) => string[];
18
- getAnnotationBounds: (id: string) => DOMRect;
19
- getAnnotationRects: (id: string) => DOMRect[];
20
- getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<T>[];
21
- insert: (target: TextAnnotationTarget) => void;
22
- recalculate: () => void;
23
- remove: (target: TextAnnotationTarget) => void;
24
- set: (targets: TextAnnotationTarget[], replace?: boolean) => void;
25
- size: () => number;
26
- update: (target: TextAnnotationTarget) => void;
27
- };
28
- export {};
@@ -1,17 +0,0 @@
1
- export * from './cancelSingleClickEvents';
2
- export * from './cloneEvents';
3
- export * from './device';
4
- export * from './programmaticallyFocusable';
5
- export * from './debounce';
6
- export * from './getHighlightClientRects';
7
- export * from './getQuoteContext';
8
- export * from './isNotAnnotatable';
9
- export * from './isRevived';
10
- export * from './isWhitespaceOrEmpty';
11
- export * from './mergeClientRects';
12
- export * from './rangeToSelector';
13
- export * from './reviveAnnotation';
14
- export * from './reviveSelector';
15
- export * from './reviveTarget';
16
- export * from './splitAnnotatableRanges';
17
- export * from './trimRangeToContainer';
@@ -1,2 +0,0 @@
1
- import { TextSelector } from '../model';
2
- export declare const isRevived: (selector: TextSelector[]) => boolean;
@@ -1,2 +0,0 @@
1
- export declare const whitespaceOrEmptyRegex: RegExp;
2
- export declare const isWhitespaceOrEmpty: (range: Range) => boolean;
@@ -1,2 +0,0 @@
1
- import { TextAnnotation } from '../model';
2
- export declare const reviveAnnotation: <T extends TextAnnotation>(annotation: T, container: HTMLElement) => T;
@@ -1,2 +0,0 @@
1
- import { TextAnnotationTarget } from '../model';
2
- export declare const reviveTarget: <T extends TextAnnotationTarget = TextAnnotationTarget>(target: T, container: HTMLElement) => T;
@@ -1,28 +0,0 @@
1
- import type { Unsubscribe } from 'nanoevents';
2
- import type { Filter, Origin, Store } from '@annotorious/core';
3
- import type { TextAnnotation } from '../model';
4
- import type { SpatialTreeEvents } from './spatialTree';
5
- export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
6
- addAnnotation(annotation: T, origin?: Origin): boolean;
7
- bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
8
- bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
9
- getAnnotationRects(id: string): DOMRect[];
10
- getAnnotationBounds(id: string): DOMRect | undefined;
11
- getAnnotationRects(id: string): DOMRect[];
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;
15
- getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];
16
- recalculatePositions(): void;
17
- onRecalculatePositions(callback: SpatialTreeEvents['recalculate']): Unsubscribe;
18
- }
19
- export interface AnnotationRects<T extends TextAnnotation = TextAnnotation> {
20
- annotation: T;
21
- rects: Rect[];
22
- }
23
- export interface Rect {
24
- x: number;
25
- y: number;
26
- width: number;
27
- height: number;
28
- }
@@ -1,12 +0,0 @@
1
- import type { ViewportState } from '@annotorious/core';
2
- import type { AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
3
- import type { TextAnnotation } from '../model';
4
- import type { TextAnnotationStore } from './TextAnnotationStore';
5
- import type { TextAnnotatorOptions } from '../TextAnnotatorOptions';
6
- export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
7
- store: TextAnnotationStore<I>;
8
- selection: SelectionState<I, E>;
9
- hover: HoverState<I>;
10
- viewport: ViewportState;
11
- }
12
- export declare const createTextAnnotatorState: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, opts: TextAnnotatorOptions<I, E>) => TextAnnotatorState<I, E>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { W3CTextAnnotation } from '../../../src';
2
- export declare const textAnnotation: W3CTextAnnotation;
3
- export declare const incompleteTextAnnotation: W3CTextAnnotation;