@soomo/text-annotator 3.0.0-staging.2 → 3.0.0-staging.20

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,7 +1,7 @@
1
- import { TextAnnotatorState } from './state';
2
1
  import { User } from '@annotorious/core';
2
+ import { TextAnnotatorState } from './state';
3
3
 
4
- export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, offsetReferenceSelector?: string) => {
4
+ export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, annotationEnabled: boolean, offsetReferenceSelector?: string) => {
5
5
  destroy: () => void;
6
6
  setUser: (user: User) => User;
7
7
  };
@@ -1,11 +1,14 @@
1
- import { TextAnnotatorOptions } from './TextAnnotatorOptions';
2
- import { TextAnnotation } from './model';
3
- import { TextAnnotatorState } from './state';
4
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';
5
6
 
6
7
  export interface TextAnnotator<E extends unknown = TextAnnotation> extends Annotator<TextAnnotation, E> {
7
8
  element: HTMLElement;
9
+ setStyle(style: HighlightStyleExpression | undefined): void;
10
+ redraw(force?: boolean): void;
8
11
  scrollIntoView(annotation: TextAnnotation): boolean;
9
12
  state: TextAnnotatorState;
10
13
  }
11
- export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, opts?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
14
+ export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
@@ -1,14 +1,17 @@
1
- import { HighlightStyleExpression } from './highlight';
2
- import { TextAnnotation } from './model';
1
+ import { FormatAdapter, PointerSelectAction, User } from '@annotorious/core';
3
2
  import { PresencePainterOptions } from './presence';
4
- import { FormatAdapter, PointerSelectAction } from '@annotorious/core';
3
+ import { TextAnnotation } from './model';
4
+ import { HighlightStyleExpression } from './highlight';
5
5
 
6
6
  export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
7
7
  adapter?: FormatAdapter<TextAnnotation, T> | null;
8
+ annotationEnabled?: boolean;
8
9
  renderer?: RendererType;
9
10
  offsetReferenceSelector?: string;
10
11
  pointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction);
11
12
  presence?: PresencePainterOptions;
12
13
  style?: HighlightStyleExpression;
14
+ user?: User;
13
15
  }
14
16
  export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
17
+ export declare const fillDefaults: <T extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<T>, defaults: TextAnnotatorOptions<T>) => TextAnnotatorOptions<T>;
@@ -1,4 +1,4 @@
1
- import { TextAnnotation } from '../model';
2
1
  import { TextAnnotationStore } from '../state';
2
+ import { TextAnnotation } from '../model';
3
3
 
4
- export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotation: TextAnnotation) => boolean;
4
+ export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotationOrId: string | TextAnnotation) => boolean;
@@ -1,5 +1,5 @@
1
- import { AnnotationRects } from '../state';
2
1
  import { AnnotationState } from '@annotorious/core';
2
+ import { AnnotationRects } from '../state';
3
3
 
4
4
  export interface Highlight extends AnnotationRects {
5
5
  state: AnnotationState;
@@ -1,6 +1,6 @@
1
- import { ViewportBounds } from './viewport';
2
- import { HighlightStyle, HighlightStyleExpression } from './HighlightStyle';
3
1
  import { Highlight } from './Highlight';
2
+ import { HighlightStyle, HighlightStyleExpression } from './HighlightStyle';
3
+ import { ViewportBounds } from './viewport';
4
4
 
5
5
  export interface HighlightPainter {
6
6
  clear(): void;
@@ -1,5 +1,5 @@
1
- import { TextAnnotation } from 'src/model';
2
1
  import { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
2
+ import { TextAnnotation } from 'src/model';
3
3
 
4
4
  export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity'> {
5
5
  underlineStyle?: string;
@@ -7,6 +7,6 @@ export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity
7
7
  underlineOffset?: number;
8
8
  underlineThickness?: number;
9
9
  }
10
- export type HighlightStyleExpression = HighlightStyle | ((annotation: TextAnnotation, state: AnnotationState, zIndex?: number) => HighlightStyle);
10
+ export type HighlightStyleExpression = HighlightStyle | ((annotation: TextAnnotation, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
11
11
  export declare const DEFAULT_STYLE: HighlightStyle;
12
12
  export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
@@ -1,13 +1,13 @@
1
- import { HighlightStyleExpression } from './HighlightStyle';
2
- import { Highlight } from './Highlight';
3
- import { HighlightPainter } from './HighlightPainter';
4
- import { ViewportBounds } from './viewport';
5
- import { TextAnnotatorState } from '../state';
6
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
7
 
8
8
  export interface RendererImplementation {
9
9
  destroy(): void;
10
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, force?: boolean): void;
10
+ redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
11
11
  setVisible(visible: boolean): void;
12
12
  }
13
13
  export interface Renderer {
@@ -1,4 +1,4 @@
1
- import { ViewportState } from '@annotorious/core';
2
1
  import { TextAnnotatorState } from 'src/state';
2
+ import { ViewportState } from '@annotorious/core';
3
3
 
4
4
  export declare const createCanvasRenderer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1,6 +1,6 @@
1
- import { RendererImplementation } from '../baseRenderer';
2
- import { TextAnnotatorState } from 'src/state';
3
1
  import { ViewportState } from '@annotorious/core';
2
+ import { TextAnnotatorState } from 'src/state';
3
+ import { RendererImplementation } from '../baseRenderer';
4
4
 
5
5
  export declare const createRenderer: () => RendererImplementation;
6
6
  export declare const createHighlightsRenderer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1,4 +1,4 @@
1
- import { TextAnnotatorState } from '../../state';
2
1
  import { ViewportState } from '@annotorious/core';
2
+ import { TextAnnotatorState } from '../../state';
3
3
 
4
4
  export declare const createSpansRenderer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => import('../baseRenderer').Renderer;
@@ -1,5 +1,5 @@
1
- import { TextAnnotation } from '../model';
2
1
  import { ViewportState } from '@annotorious/core';
2
+ import { TextAnnotation } from '../model';
3
3
 
4
4
  export interface ViewportBounds {
5
5
  top: number;
@@ -1,4 +1,3 @@
1
- import { Origin as _Origin } from '@annotorious/core';
2
1
  export * from './highlight';
3
2
  export * from './model';
4
3
  export * from './state';
@@ -6,5 +5,5 @@ export * from './utils';
6
5
  export * from './presence/PresencePainterOptions';
7
6
  export * from './TextAnnotator';
8
7
  export * from './TextAnnotatorOptions';
9
- export type { Filter } from '@annotorious/core';
10
- export { _Origin as Origin };
8
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
+ export { createBody, Origin, PointerSelectAction } from '@annotorious/core';
@@ -1,6 +1,6 @@
1
- import { W3CTextAnnotation } from '../w3c';
2
- import { TextAnnotation } from '../core';
3
1
  import { FormatAdapter, ParseResult } from '@annotorious/core';
2
+ import { TextAnnotation } from '../core';
3
+ import { W3CTextAnnotation } from '../w3c';
4
4
 
5
5
  export type W3CTextFormatAdapter = FormatAdapter<TextAnnotation, W3CTextAnnotation>;
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { PresencePainterOptions } from 'src/presence';
2
- import { HighlightPainter } from '../highlight';
3
1
  import { PresenceProvider } from '@annotorious/core';
2
+ import { HighlightPainter } from '../highlight';
3
+ import { PresencePainterOptions } from 'src/presence';
4
4
 
5
5
  export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
@@ -1,5 +1,5 @@
1
- import { TextAnnotation } from '../model';
2
1
  import { Origin, Store } from '@annotorious/core';
2
+ import { TextAnnotation } from '../model';
3
3
 
4
4
  export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
5
5
  addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
@@ -1,6 +1,6 @@
1
- import { TextAnnotationStore } from './TextAnnotationStore';
2
- import { TextAnnotation } from '../model';
3
1
  import { PointerSelectAction, ViewportState, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
2
+ import { TextAnnotation } from '../model';
3
+ import { TextAnnotationStore } from './TextAnnotationStore';
4
4
 
5
5
  export interface TextAnnotatorState extends AnnotatorState<TextAnnotation> {
6
6
  store: TextAnnotationStore;
@@ -1,6 +1,6 @@
1
- import { AnnotationRects } from './TextAnnotationStore';
2
- import { TextAnnotation, TextAnnotationTarget } from '../model';
3
1
  import { Store } from '@annotorious/core';
2
+ import { TextAnnotation, TextAnnotationTarget } from '../model';
3
+ import { AnnotationRects } from './TextAnnotationStore';
4
4
 
5
5
  interface IndexedHighlightRect {
6
6
  minX: number;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Calls .preventDefault() on click events in annotable areas, in order
3
+ * to prevent problematic default browser behavior. (Specifically: keep
4
+ * Chrome Android from triggering word selection on single click.)
5
+ */
6
+ export declare const cancelSingleClickEvents: (container: HTMLElement) => void;
@@ -1,3 +1,4 @@
1
+ export * from './cancelSingleClickEvents';
1
2
  export * from './debounce';
2
3
  export * from './getAnnotatableFragment';
3
4
  export * from './getClientRectsPonyfill';
@@ -1,3 +1,4 @@
1
+ export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
1
2
  export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
2
3
  /**
3
4
  * Splits a DOM Range into one or more ranges that span annotatable content only.