@recogito/text-annotator 4.0.0-beta → 4.0.2-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.
package/dist/index.d.ts CHANGED
@@ -1,409 +1,12 @@
1
- import { Annotation } from '@annotorious/core';
2
- import { AnnotationBody } from '@annotorious/core';
3
- import { AnnotationState } from '@annotorious/core';
4
- import { AnnotationTarget } from '@annotorious/core';
5
- import { Annotator } from '@annotorious/core';
6
- import { AnnotatorState } from '@annotorious/core';
7
- import { Color } from '@annotorious/core';
8
- import { createBody } from '@annotorious/core';
9
- import { DrawingStyle } from '@annotorious/core';
10
- import { Filter } from '@annotorious/core';
11
- import { FormatAdapter } from '@annotorious/core';
12
- import { HoverState } from '@annotorious/core';
13
- import { Lifecycle } from '@annotorious/core';
14
- import { Origin } from '@annotorious/core';
15
- import { ParseResult } from '@annotorious/core';
16
- import { Selection as Selection_2 } from '@annotorious/core';
17
- import { SelectionState } from '@annotorious/core';
18
- import { Store } from '@annotorious/core';
19
- import { StoreChangeEvent } from '@annotorious/core';
20
- import { StoreObserver } from '@annotorious/core';
21
- import { Unsubscribe } from 'nanoevents';
22
- import { User } from '@annotorious/core';
23
- import { UserSelectAction } from '@annotorious/core';
24
- import { UserSelectActionExpression } from '@annotorious/core';
25
- import { ViewportState } from '@annotorious/core';
26
- import { W3CAnnotation } from '@annotorious/core';
27
- import { W3CAnnotationBody } from '@annotorious/core';
28
- import { W3CAnnotationTarget } from '@annotorious/core';
29
-
30
- export declare type AnnotatingMode = 'CREATE_NEW' | 'ADD_TO_CURRENT' | 'REPLACE_CURRENT';
31
-
32
- export { Annotation }
33
-
34
- export { AnnotationBody }
35
-
36
- export declare interface AnnotationRects<T extends TextAnnotation = TextAnnotation> {
37
- annotation: T;
38
- rects: Rect[];
39
- }
40
-
41
- export { AnnotationTarget }
42
-
43
- export { Annotator }
44
-
45
- export { AnnotatorState }
46
-
47
- /**
48
- * Calls .preventDefault() on click events in annotable areas, in order
49
- * to prevent problematic default browser behavior. (Specifically: keep
50
- * Chrome Android from triggering word selection on single click.)
51
- */
52
- export declare const cancelSingleClickEvents: (container: HTMLElement) => void;
53
-
54
- export declare const cloneKeyboardEvent: (event: KeyboardEvent) => KeyboardEvent;
55
-
56
- /**
57
- * Events need to be manually mapped into new objects:
58
- * 1. It preserves the `target` and `currentTarget` properties.
59
- * Otherwise, they will be `null` when the event is read beyond the handler.
60
- * 2. Spread operator can copy only own enumerable properties, not inherited ones.
61
- * Therefore, we need to manually copy the props we're interested in.
62
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
63
- * @see https://github.com/recogito/text-annotator-js/commit/65d13f3108c429311cf8c2523f6babbbc946013d#r144041390
64
- */
65
- export declare const clonePointerEvent: (event: PointerEvent) => PointerEvent;
66
-
67
- export { Color }
68
-
69
- export declare const computeStyle: (highlight: Highlight_2, style?: HighlightStyleExpression, z?: number) => HighlightStyle;
70
-
71
- export declare const computeZIndex: (rect: Rect, all: Highlight_2[]) => number;
72
-
73
- export { createBody }
74
-
75
- export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
76
-
77
- export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, lifecycle: Lifecycle<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
78
- destroy: () => void;
79
- setFilter: (filter?: Filter) => Filter;
80
- setUser: (user?: User) => User;
81
- setAnnotatingEnabled: (enabled: boolean) => void;
82
- setAnnotatingMode: (mode?: AnnotatingMode) => AnnotatingMode;
83
- };
84
-
85
- export declare const createTextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;
86
-
87
- export declare const createTextAnnotatorState: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, opts: TextAnnotatorOptions<I, E>) => TextAnnotatorState<I, E>;
88
-
89
- export declare const debounce: <T extends (...args: any[]) => void>(func: T, delay?: number) => T;
90
-
91
- export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
92
-
93
- export declare const DEFAULT_STYLE: HighlightStyle;
94
-
95
- export declare type DismissOnNotAnnotatableExpression = 'NEVER' | 'ALWAYS' | ((event: Event, container: HTMLElement) => boolean);
96
-
97
- export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
98
-
99
- export { Filter }
100
-
101
- export { FormatAdapter }
102
-
103
- export declare const getBackgroundColor: (style?: HighlightStyle) => string;
104
-
105
- export declare const getHighlightClientRects: (range: Range) => DOMRect[];
106
-
107
- export declare const getQuoteContext: (range: Range, container: HTMLElement, length?: number, offsetReferenceSelector?: string) => {
108
- prefix: string;
109
- suffix: string;
110
- };
111
-
112
- export declare const getRangeAnnotatableContents: (range: Range) => DocumentFragment;
113
-
114
- export declare const getViewportBounds: (container: HTMLElement) => ViewportBounds;
115
-
116
- declare interface Highlight_2 extends AnnotationRects<TextAnnotation> {
117
- state: AnnotationState;
118
- }
119
- export { Highlight_2 as Highlight }
120
-
121
- export declare interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity'> {
122
- underlineStyle?: string;
123
- underlineColor?: Color;
124
- underlineOffset?: number;
125
- underlineThickness?: number;
126
- }
127
-
128
- export declare type HighlightStyleExpression = HighlightStyle | (<I extends TextAnnotation = TextAnnotation>(annotation: I, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
129
-
130
- export { HoverState }
131
-
132
- export declare const isMac: boolean;
133
-
134
- export declare const isNodeWhitespaceOrEmpty: (node: Node) => boolean;
135
-
136
- export declare const isNotAnnotatable: (container: Node, node: Node) => boolean;
137
-
138
- export declare const isRangeAnnotatable: (container: Node, range: Range) => boolean;
139
-
140
- export declare const isRangeWhitespaceOrEmpty: (range: Range) => boolean;
141
-
142
- export declare const isRevived: (selector: TextSelector[]) => boolean;
143
-
144
- export declare const mergeClientRects: (rects: DOMRect[], hTolerance?: number, vTolerance?: number) => DOMRect[];
145
-
146
- export declare const mergeRanges: (ranges: Range[]) => Range[];
147
-
148
- export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
149
-
150
- export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
151
-
152
- export { Origin }
153
-
154
- /**
155
- * A utility interface. Instead of implementing a Renderer from scratch,
156
- * implementers can simply implement a painter, and wrap it in the
157
- * BaseRenderer, which will handle common concerns.
158
- */
159
- export declare interface Painter {
160
- destroy(): void;
161
- redraw(highlights: Highlight_2[], bounds: ViewportBounds, style?: HighlightStyleExpression, styleOverrides?: Map<string, HighlightStyleExpression>, force?: boolean): void;
162
- setVisible(visible: boolean): void;
163
- }
164
-
165
- export { ParseResult }
166
-
167
- export declare const parseW3CTextAnnotation: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(annotation: E) => ParseResult<I>;
168
-
169
- /**
170
- * Makes an element programmatically focusable by adding a `tabindex="-1"` attribute.
171
- * Or does nothing if the element is already focusable 🤷🏻
172
- * It's required to process keyboard events on an element that is not natively focusable.
173
- */
174
- export declare const programmaticallyFocusable: (container: HTMLElement) => void;
175
-
176
- export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
177
-
178
- export declare interface Rect {
179
- x: number;
180
- y: number;
181
- width: number;
182
- height: number;
183
- }
184
-
185
- /**
186
- * The renderer runtime interface.
187
- */
188
- export declare interface Renderer {
189
- destroy(): void;
190
- on: <E extends keyof RendererEvents>(event: E, callback: RendererEvents[E]) => Unsubscribe;
191
- redraw(force?: boolean): void;
192
- setStyle(style?: HighlightStyleExpression, id?: string): void;
193
- setFilter(filter?: Filter): void;
194
- setVisible(visible: boolean): void;
195
- }
196
-
197
- export declare interface RendererEvents {
198
- onRedraw(): void;
199
- }
200
-
201
- export declare type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
202
-
203
- export declare type RendererType = 'SPANS' | 'CSS_HIGHLIGHTS';
204
-
205
- export declare const reviveAnnotation: <T extends TextAnnotation>(annotation: T, container: HTMLElement) => T;
206
-
207
- /**
208
- * Creates a new selector object with the revived DOM range from the given text annotation position
209
- * Only the annotatable elements are processed and counted towards the range
210
- *
211
- * @param selector annotation selector with start and end positions
212
- * @param container the HTML container of the annotated content
213
- *
214
- * @returns the revived selector
215
- */
216
- export declare const reviveSelector: <T extends TextSelector>(selector: T, container: HTMLElement) => T;
217
-
218
- export declare const reviveTarget: <T extends TextAnnotationTarget = TextAnnotationTarget>(target: T, container: HTMLElement) => T;
219
-
220
- export declare const scrollIntoView: <I extends TextAnnotation = TextAnnotation>(container: HTMLElement, store: TextAnnotationStore<I>) => <E extends Element = Element>(annotationOrId: string | I, scrollParentOrId?: string | E) => boolean;
221
-
222
- export { Selection_2 as Selection }
223
-
224
- export { SelectionState }
225
-
226
- export declare const serializeW3CTextAnnotation: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(annotation: I, source: string, container?: HTMLElement) => E;
227
-
228
- declare interface SpatialTreeEvents {
229
- recalculate(): void;
230
- }
231
-
232
- /**
233
- * Splits a DOM Range into one or more ranges that span annotatable content only.
234
- */
235
- export declare const splitAnnotatableRanges: (container: Node, range: Range) => Range[];
236
-
237
- export { Store }
238
-
239
- export { StoreChangeEvent }
240
-
241
- export { StoreObserver }
242
-
243
- export declare interface TextAnnotation extends Annotation {
244
- target: TextAnnotationTarget;
245
- }
246
-
247
- export declare interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
248
- addAnnotation(annotation: T, origin?: Origin): boolean;
249
- bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
250
- bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
251
- getAnnotationRects(id: string): DOMRect[];
252
- getAnnotationBounds(id: string): DOMRect | undefined;
253
- getAnnotationRects(id: string): DOMRect[];
254
- getAt(x: number, y: number, all: true, filter?: Filter): T[] | undefined;
255
- getAt(x: number, y: number, all: false, filter?: Filter): T | undefined;
256
- getAt(x: number, y: number, all?: boolean, filter?: Filter): T | T[] | undefined;
257
- getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];
258
- recalculatePositions(): void;
259
- onRecalculatePositions(callback: SpatialTreeEvents['recalculate']): Unsubscribe;
260
- }
261
-
262
- export declare interface TextAnnotationTarget extends AnnotationTarget {
263
- selector: TextSelector[];
264
- }
265
-
266
- export declare interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
267
- element: HTMLElement;
268
- renderer: Renderer;
269
- setStyle(style?: HighlightStyleExpression, id?: string): void;
270
- scrollIntoView(annotationOrId: I | string, scrollParentOrId?: string | Element): boolean;
271
- setAnnotatingEnabled(enabled?: boolean): void;
272
- setAnnotatingMode(mode?: AnnotatingMode): void;
273
- state: TextAnnotatorState<I, E>;
274
- }
275
-
276
- export declare interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
277
- adapter?: FormatAdapter<I, E> | null;
278
- allowModifierSelect?: boolean;
279
- annotatingEnabled?: boolean;
280
- /**
281
- * Determines whether an active selection should be dismissed
282
- * when a user ends their interaction (click, selection)
283
- * on a non-annotatable element.
284
- * - NEVER - don't dismiss the selection, ignore the action.
285
- * - ALWAYS - dismiss the selection.
286
- * - function - a custom matcher that takes an event and container as arguments.
287
- * Returns `true` if the selection should be dismissed.
288
- *
289
- * @defaut NEVER
290
- */
291
- dismissOnNotAnnotatable?: DismissOnNotAnnotatableExpression;
292
- mergeHighlights?: {
293
- horizontalTolerance?: number;
294
- verticalTolerance?: number;
295
- };
296
- offsetReferenceSelector?: string;
297
- renderer?: RendererType | RendererFactory;
298
- selectionMode?: 'shortest' | 'all';
299
- style?: HighlightStyleExpression;
300
- user?: User;
301
- userSelectAction?: UserSelectActionExpression<E>;
302
- }
303
-
304
- export declare interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
305
- store: TextAnnotationStore<I>;
306
- selection: SelectionState<I, E>;
307
- hover: HoverState<I>;
308
- viewport: ViewportState;
309
- }
310
-
311
- export declare interface TextSelector {
312
- id?: string;
313
- quote: string;
314
- start: number;
315
- end: number;
316
- range: Range;
317
- offsetReference?: HTMLElement;
318
- }
319
-
320
- export declare const toDomRectList: (rects: DOMRect[]) => DOMRectList;
321
-
322
- /**
323
- * Offsets the given rect relative to the offset parent.
324
- */
325
- export declare const toParentBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
326
-
327
- /**
328
- * Inverse: translates the given relative rect back into viewport bounds.
329
- */
330
- export declare const toViewportBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
331
-
332
- export declare const trackViewport: (viewport: ViewportState) => (annotations: TextAnnotation[]) => void;
333
-
334
- export declare const trimRangeToContainer: (range: Range, container: HTMLElement) => Range;
335
-
336
- export { User }
337
-
338
- export { UserSelectAction }
339
-
340
- export { UserSelectActionExpression }
341
-
342
- export declare interface ViewportBounds {
343
- top: number;
344
- left: number;
345
- minX: number;
346
- minY: number;
347
- maxX: number;
348
- maxY: number;
349
- }
350
-
351
- export { ViewportState }
352
-
353
- export { W3CAnnotation }
354
-
355
- export { W3CAnnotationBody }
356
-
357
- export declare type W3CAnnotationStylesheet = string | {
358
- type: 'CssStylesheet';
359
- value: string;
360
- };
361
-
362
- export { W3CAnnotationTarget }
363
-
364
- export declare interface W3CTextAnnotation extends W3CAnnotation {
365
- target: W3CTextAnnotationTarget | W3CTextAnnotationTarget[];
366
- stylesheet?: W3CAnnotationStylesheet;
367
- }
368
-
369
- export declare interface W3CTextAnnotationTarget extends W3CAnnotationTarget {
370
- selector: W3CTextSelector | W3CTextSelector[];
371
- styleClass?: string;
372
- scope?: string;
373
- }
374
-
375
- /**
376
- * @param source - the IRI of the annotated content
377
- * @param container - the HTML container of the annotated content,
378
- * Required to locate the content's `range` within the DOM
379
- */
380
- export declare const W3CTextFormat: <I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation>(source: string, container?: HTMLElement) => W3CTextFormatAdapter<I, E>;
381
-
382
- export declare type W3CTextFormatAdapter<I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation> = FormatAdapter<I, E>;
383
-
384
- /**
385
- * Matches the `Text Position Selector` spec
386
- * @see https://www.w3.org/TR/annotation-model/#text-position-selector
387
- */
388
- export declare interface W3CTextPositionSelector {
389
- type: 'TextPositionSelector';
390
- start: number;
391
- end: number;
392
- }
393
-
394
- /**
395
- * Matches the `Text Quote Selector` spec
396
- * @see https://www.w3.org/TR/annotation-model/#text-quote-selector
397
- */
398
- export declare interface W3CTextQuoteSelector {
399
- type: 'TextQuoteSelector';
400
- exact: string;
401
- prefix?: string;
402
- suffix?: string;
403
- }
404
-
405
- export declare type W3CTextSelector = W3CTextQuoteSelector | W3CTextPositionSelector;
406
-
407
- export declare const whitespaceOrEmptyRegex: RegExp;
408
-
409
- export { }
1
+ export * from './model';
2
+ export * from './rendering';
3
+ export * from './state';
4
+ export * from './utils/annotation';
5
+ export * from './utils/dom';
6
+ export * from './utils/events';
7
+ export * from './utils/highlight';
8
+ export * from './selection-handler';
9
+ export * from './text-annotator';
10
+ export * from './text-annotator-options';
11
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, UserSelectActionExpression, ViewportState, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
12
+ export { createBody, Origin, UserSelectAction } from '@annotorious/core';
@@ -1,4 +1,4 @@
1
- import { Annotation, AnnotationTarget } from '@annotorious/core';
1
+ import type { Annotation, AnnotationTarget } from '@annotorious/core';
2
2
  export interface TextAnnotation extends Annotation {
3
3
  target: TextAnnotationTarget;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
1
+ import type { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
2
2
  export interface W3CTextAnnotation extends W3CAnnotation {
3
3
  target: W3CTextAnnotationTarget | W3CTextAnnotationTarget[];
4
4
  stylesheet?: W3CAnnotationStylesheet;
@@ -1,6 +1,6 @@
1
- import { TextAnnotation } from '../core';
2
- import { W3CTextAnnotation } from '.';
3
- import { FormatAdapter, ParseResult } from '@annotorious/core';
1
+ import type { TextAnnotation } from '../core';
2
+ import type { W3CTextAnnotation } from './';
3
+ import { type FormatAdapter, type ParseResult } from '@annotorious/core';
4
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
@@ -1,8 +1,8 @@
1
- import { Unsubscribe } from 'nanoevents';
2
- import { Filter, ViewportState } from '@annotorious/core';
3
- import { TextAnnotation } from '../model';
4
- import { TextAnnotatorState } from '../state';
5
- import { Highlight, HighlightStyleExpression, ViewportBounds } from '.';
1
+ import { type Unsubscribe } from 'nanoevents';
2
+ import { type Filter, type ViewportState } from '@annotorious/core';
3
+ import type { TextAnnotation } from '../model';
4
+ import type { TextAnnotatorState } from '../state';
5
+ import { type Highlight, type HighlightStyleExpression, type ViewportBounds } from './';
6
6
  /**
7
7
  * The renderer runtime interface.
8
8
  */
@@ -11,13 +11,13 @@ export interface Renderer {
11
11
  on: <E extends keyof RendererEvents>(event: E, callback: RendererEvents[E]) => Unsubscribe;
12
12
  redraw(force?: boolean): void;
13
13
  setStyle(style?: HighlightStyleExpression, id?: string): void;
14
- setFilter(filter?: Filter): void;
14
+ setFilter(filter?: Filter<any>): void;
15
15
  setVisible(visible: boolean): void;
16
16
  }
17
17
  export interface RendererEvents {
18
18
  onRedraw(): void;
19
19
  }
20
- export type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
20
+ export type RendererFactory<T extends TextAnnotation> = (container: HTMLElement, state: TextAnnotatorState<T, any>, viewport: ViewportState) => Renderer;
21
21
  /**
22
22
  * A utility interface. Instead of implementing a Renderer from scratch,
23
23
  * implementers can simply implement a painter, and wrap it in the
@@ -28,4 +28,4 @@ export interface Painter {
28
28
  redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, styleOverrides?: Map<string, HighlightStyleExpression>, force?: boolean): void;
29
29
  setVisible(visible: boolean): void;
30
30
  }
31
- export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
31
+ export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState<TextAnnotation, any>>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
@@ -1,6 +1,6 @@
1
- import { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
2
- import { TextAnnotation } from '../model';
3
- import { Highlight } from '.';
1
+ import type { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
+ import type { Highlight } from './';
4
4
  export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity'> {
5
5
  underlineStyle?: string;
6
6
  underlineColor?: Color;
@@ -1,6 +1,6 @@
1
- import { AnnotationState } from '@annotorious/core';
2
- import { TextAnnotation } from '../model';
3
- import { AnnotationRects } from '../state';
1
+ import type { AnnotationState } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
+ import type { AnnotationRects } from '../state';
4
4
  export interface Highlight extends AnnotationRects<TextAnnotation> {
5
5
  state: AnnotationState;
6
6
  }
@@ -1,4 +1,5 @@
1
1
  export * from './base-renderer';
2
2
  export * from './highlight';
3
3
  export * from './highlight-style';
4
+ export * from './renderer-spans';
4
5
  export * from './viewport';
@@ -1,6 +1,7 @@
1
- import { Painter, RendererFactory } from '..';
1
+ import type { TextAnnotation } from '../../model';
2
+ import { type Painter, type RendererFactory } from '../';
2
3
  /**
3
4
  * EXPERIMENTAL!
4
5
  */
5
6
  export declare const createCSSHighlightPainter: () => Painter;
6
- export declare const createCSSHighlightRenderer: RendererFactory;
7
+ export declare const createCSSHighlightRenderer: RendererFactory<TextAnnotation>;
@@ -1,2 +1,4 @@
1
- import { RendererFactory } from '..';
2
- export declare const createSpansRenderer: RendererFactory;
1
+ import type { TextAnnotation } from '../../model';
2
+ import { type RendererFactory } from '../';
3
+ import './spans-renderer.css';
4
+ export declare const createSpansRenderer: RendererFactory<TextAnnotation>;
@@ -1,5 +1,5 @@
1
- import { ViewportState } from '@annotorious/core';
2
- import { TextAnnotation } from '../model';
1
+ import type { ViewportState } from '@annotorious/core';
2
+ import type { TextAnnotation } from '../model';
3
3
  export interface ViewportBounds {
4
4
  top: number;
5
5
  left: number;
@@ -1,11 +1,11 @@
1
- import { Filter, Lifecycle, User } from '@annotorious/core';
2
- import { TextAnnotatorState } from './state';
3
- import { TextAnnotation } from './model';
4
- import { AnnotatingMode } from './text-annotator';
5
- import { TextAnnotatorOptions } from './text-annotator-options';
6
- export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, lifecycle: Lifecycle<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
1
+ import type { Filter, Lifecycle, User } from '@annotorious/core';
2
+ import type { TextAnnotatorState } from './state';
3
+ import type { TextAnnotation } from './model';
4
+ import type { AnnotatingMode } from './text-annotator';
5
+ import type { TextAnnotatorOptions } from './text-annotator-options';
6
+ export declare const createSelectionHandler: <T extends TextAnnotation>(container: HTMLElement, state: TextAnnotatorState<TextAnnotation, any>, lifecycle: Lifecycle<TextAnnotation, any>, options: TextAnnotatorOptions<TextAnnotation, any>) => {
7
7
  destroy: () => void;
8
- setFilter: (filter?: Filter) => Filter;
8
+ setFilter: (filter?: Filter<any>) => Filter<any>;
9
9
  setUser: (user?: User) => User;
10
10
  setAnnotatingEnabled: (enabled: boolean) => void;
11
11
  setAnnotatingMode: (mode?: AnnotatingMode) => AnnotatingMode;
@@ -1,7 +1,7 @@
1
- import { Store } from '@annotorious/core';
2
- import { Unsubscribe } from 'nanoevents';
3
- import { TextAnnotation, TextAnnotationTarget } from '../model';
4
- import { AnnotationRects } from './text-annotation-store';
1
+ import type { Store } from '@annotorious/core';
2
+ import { type Unsubscribe } from 'nanoevents';
3
+ import type { TextAnnotation, TextAnnotationTarget } from '../model';
4
+ import type { AnnotationRects } from '../state/text-annotation-store';
5
5
  interface IndexedHighlightRect {
6
6
  minX: number;
7
7
  minY: number;
@@ -19,7 +19,7 @@ export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<
19
19
  all: () => IndexedHighlightRect[][];
20
20
  clear: () => void;
21
21
  getAt: (x: number, y: number, all?: boolean) => string[];
22
- getAnnotationBounds: (id: string) => DOMRect;
22
+ getAnnotationBounds: (id: string) => DOMRect | undefined;
23
23
  getAnnotationRects: (id: string) => DOMRect[];
24
24
  getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<T>[];
25
25
  insert: (target: TextAnnotationTarget) => void;
@@ -1,8 +1,8 @@
1
- import { Unsubscribe } from 'nanoevents';
2
- import { Filter, Origin, Store } from '@annotorious/core';
3
- import { TextAnnotation } from '../model';
4
- import { SpatialTreeEvents } from './spatial-tree';
5
- export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
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 '../state/spatial-tree';
5
+ export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations'> {
6
6
  addAnnotation(annotation: T, origin?: Origin): boolean;
7
7
  bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
8
8
  bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
@@ -1,8 +1,9 @@
1
- import { ViewportState, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
2
- import { TextAnnotation } from '../model';
3
- import { TextAnnotationStore } from './text-annotation-store';
4
- import { TextAnnotatorOptions } from '../text-annotator-options';
5
- export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
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 '../state/text-annotation-store';
5
+ import type { TextAnnotatorOptions } from '../text-annotator-options';
6
+ export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<AnnotatorState<I, E>, 'store'> {
6
7
  store: TextAnnotationStore<I>;
7
8
  selection: SelectionState<I, E>;
8
9
  hover: HoverState<I>;
@@ -1,8 +1,8 @@
1
- import { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
- import { HighlightStyleExpression, RendererFactory } from './rendering';
3
- import { TextAnnotation } from './model';
1
+ import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
+ import type { HighlightStyleExpression, RendererFactory } from './rendering';
3
+ import type { TextAnnotation } from './model';
4
4
  export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
5
- adapter?: FormatAdapter<I, E> | null;
5
+ adapter?: FormatAdapter<I, E>;
6
6
  allowModifierSelect?: boolean;
7
7
  annotatingEnabled?: boolean;
8
8
  /**
@@ -22,7 +22,7 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
22
22
  verticalTolerance?: number;
23
23
  };
24
24
  offsetReferenceSelector?: string;
25
- renderer?: RendererType | RendererFactory;
25
+ renderer?: RendererType | RendererFactory<I>;
26
26
  selectionMode?: 'shortest' | 'all';
27
27
  style?: HighlightStyleExpression;
28
28
  user?: User;
@@ -1 +1 @@
1
- .r6o-annotatable .r6o-span-highlight-layer{position:absolute;top:0;left:0;width:100%;height:100%;mix-blend-mode:multiply;pointer-events:none;overflow:hidden;z-index:1}.r6o-annotatable .r6o-span-highlight-layer.hidden{display:none}.r6o-annotatable .r6o-span-highlight-layer .r6o-annotation{position:absolute;display:block;border-style:solid;border-width:0;box-sizing:content-box}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}
1
+ .r6o-annotatable .r6o-span-highlight-layer{position:absolute;top:0;left:0;width:100%;height:100%;mix-blend-mode:multiply;pointer-events:none;overflow:hidden;user-select:none;-webkit-user-select:none;z-index:1}.r6o-annotatable .r6o-span-highlight-layer.hidden{display:none}.r6o-annotatable .r6o-span-highlight-layer .r6o-annotation{position:absolute;display:block;border-style:solid;border-width:0;box-sizing:content-box}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}