@recogito/text-annotator 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,12 @@
1
1
  import type { Filter, Lifecycle, User } from '@annotorious/core';
2
2
  import type { TextAnnotatorState } from './state';
3
3
  import type { TextAnnotation } from './model';
4
+ import type { AnnotatingMode } from './TextAnnotator';
4
5
  import type { TextAnnotatorOptions } from './TextAnnotatorOptions';
5
6
  export declare const createSelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, lifecycle: Lifecycle<TextAnnotation, unknown>, options: TextAnnotatorOptions<TextAnnotation, unknown>) => {
6
7
  destroy: () => void;
7
8
  setFilter: (filter?: Filter) => Filter;
8
9
  setUser: (user?: User) => User;
9
10
  setAnnotatingEnabled: (enabled: boolean) => void;
11
+ setAnnotatingMode: (mode?: AnnotatingMode) => AnnotatingMode;
10
12
  };
@@ -1,7 +1,7 @@
1
1
  import type { Annotator } from '@annotorious/core';
2
- import { type HighlightStyleExpression } from './highlight';
3
- import { type TextAnnotatorState } from './state';
2
+ import type { HighlightStyleExpression } from './highlight';
4
3
  import type { TextAnnotation } from './model';
4
+ import { type TextAnnotatorState } from './state';
5
5
  import { type TextAnnotatorOptions } from './TextAnnotatorOptions';
6
6
  import './TextAnnotator.css';
7
7
  export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
@@ -9,7 +9,9 @@ export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E exte
9
9
  setStyle(style: HighlightStyleExpression | undefined): void;
10
10
  redraw(lazy?: boolean): void;
11
11
  scrollIntoView(annotationOrId: I | string, scrollParentOrId?: string | Element): boolean;
12
- setAnnotatingEnabled: (enabled: boolean) => void;
12
+ setAnnotatingEnabled(enabled?: boolean): void;
13
+ setAnnotatingMode(mode?: AnnotatingMode): void;
13
14
  state: TextAnnotatorState<I, E>;
14
15
  }
16
+ export type AnnotatingMode = 'CREATE_NEW' | 'ADD_TO_CURRENT';
15
17
  export declare const createTextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<I, E>) => TextAnnotator<I, E>;
@@ -1,7 +1,7 @@
1
1
  import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
2
2
  import type { PresencePainterOptions } from './presence';
3
3
  import type { TextAnnotation } from './model';
4
- import type { HighlightStyleExpression } from './highlight';
4
+ import type { HighlightStyleExpression, RendererFactory } from './highlight';
5
5
  export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
6
6
  adapter?: FormatAdapter<I, E> | null;
7
7
  allowModifierSelect?: boolean;
@@ -24,7 +24,7 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
24
24
  };
25
25
  offsetReferenceSelector?: string;
26
26
  presence?: PresencePainterOptions;
27
- renderer?: RendererType;
27
+ renderer?: RendererType | RendererFactory;
28
28
  selectionMode?: 'shortest' | 'all';
29
29
  style?: HighlightStyleExpression;
30
30
  user?: User;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,9 @@
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
+ }
@@ -4,11 +4,13 @@ import { type ViewportBounds } from './viewport';
4
4
  import type { HighlightPainter } from './HighlightPainter';
5
5
  import type { Highlight } from './Highlight';
6
6
  import type { HighlightStyleExpression } from './HighlightStyle';
7
+ import type { TextAnnotation } from 'src/model';
7
8
  export interface RendererImplementation {
8
9
  destroy(): void;
9
10
  redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
10
11
  setVisible(visible: boolean): void;
11
12
  }
13
+ export type RendererFactory = (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => Renderer;
12
14
  export interface Renderer {
13
15
  destroy(): void;
14
16
  redraw(force?: boolean): void;
@@ -2,4 +2,4 @@ import type { ViewportState } from '@annotorious/core';
2
2
  import type { TextAnnotatorState } from '../../state';
3
3
  import type { TextAnnotation } from 'src/model';
4
4
  import './canvasRenderer.css';
5
- export declare const createCanvasRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("../baseRenderer").Renderer;
5
+ export declare const createCanvasRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("..").Renderer;
@@ -0,0 +1,2 @@
1
+ import { type HighlightStyle } from './HighlightStyle';
2
+ export declare const getBackgroundColor: (style?: HighlightStyle) => string;
@@ -1,6 +1,6 @@
1
1
  import type { ViewportState } from '@annotorious/core';
2
2
  import type { TextAnnotatorState } from 'src/state';
3
- import { type RendererImplementation } from '../baseRenderer';
3
+ import { type RendererImplementation } from '../Renderer';
4
4
  import type { TextAnnotation } from 'src/model';
5
5
  export declare const createRenderer: () => RendererImplementation;
6
- export declare const createHighlightsRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("../baseRenderer").Renderer;
6
+ export declare const createHighlightsRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("..").Renderer;
@@ -1,6 +1,7 @@
1
- export * from './Highlight';
2
- export * from './HighlightStyle';
3
- export * from './HighlightPainter';
4
1
  export * from './canvas';
5
2
  export * from './highlights';
6
3
  export * from './span';
4
+ export * from './Highlight';
5
+ export * from './HighlightStyle';
6
+ export * from './HighlightPainter';
7
+ export * from './Renderer';
@@ -1,5 +1,3 @@
1
- import type { ViewportState } from '@annotorious/core';
2
- import type { TextAnnotation } from '../../model';
3
- import type { TextAnnotatorState } from '../../state';
1
+ import { type RendererFactory } from '../Renderer';
4
2
  import './spansRenderer.css';
5
- export declare const createSpansRenderer: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, viewport: ViewportState) => import("../baseRenderer").Renderer;
3
+ export declare const createSpansRenderer: RendererFactory;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export * from './api';
2
2
  export * from './highlight';
3
3
  export * from './model';
4
+ export * from './presence';
4
5
  export * from './state';
5
6
  export * from './utils';
6
- export * from './presence';
7
7
  export * from './SelectionHandler';
8
8
  export * from './TextAnnotator';
9
9
  export * from './TextAnnotatorOptions';