@recogito/text-annotator 3.0.0-rc.5 → 3.0.0-rc.51
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/src/SelectionHandler.d.ts +7 -6
- package/dist/src/TextAnnotator.d.ts +10 -6
- package/dist/src/TextAnnotatorOptions.d.ts +13 -7
- package/dist/src/api/scrollIntoView.d.ts +3 -3
- package/dist/src/highlight/Highlight.d.ts +5 -0
- package/dist/src/highlight/HighlightPainter.d.ts +10 -19
- package/dist/src/highlight/HighlightStyle.d.ts +11 -0
- package/dist/src/highlight/baseRenderer.d.ts +20 -0
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +4 -0
- package/dist/src/highlight/canvas/index.d.ts +1 -0
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +6 -0
- package/dist/src/highlight/highlights/index.d.ts +1 -0
- package/dist/src/highlight/index.d.ts +5 -1
- package/dist/src/highlight/span/index.d.ts +1 -0
- package/dist/src/highlight/span/spansRenderer.d.ts +4 -0
- package/dist/src/highlight/viewport.d.ts +12 -0
- package/dist/src/index.d.ts +6 -3
- package/dist/src/model/{TextAnnotation.d.ts → core/TextAnnotation.d.ts} +3 -2
- package/dist/src/model/core/index.d.ts +1 -0
- package/dist/src/model/index.d.ts +2 -1
- package/dist/src/model/w3c/W3CTextAnnotation.d.ts +34 -0
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +12 -0
- package/dist/src/model/w3c/index.d.ts +2 -0
- package/dist/src/presence/PresencePainter.d.ts +4 -4
- package/dist/src/state/TextAnnotationStore.d.ts +11 -10
- package/dist/src/state/TextAnnotatorState.d.ts +9 -10
- package/dist/src/state/index.d.ts +0 -1
- package/dist/src/state/spatialTree.d.ts +10 -8
- package/dist/src/utils/cancelSingleClickEvents.d.ts +6 -0
- package/dist/src/utils/cloneEvents.d.ts +11 -0
- package/dist/src/utils/debounce.d.ts +1 -0
- package/dist/src/utils/device.d.ts +1 -0
- package/dist/src/utils/getQuoteContext.d.ts +4 -0
- package/dist/src/utils/index.d.ts +15 -2
- package/dist/src/utils/isNotAnnotatable.d.ts +4 -0
- package/dist/src/utils/isRevived.d.ts +2 -0
- package/dist/src/utils/isWhitespaceOrEmpty.d.ts +2 -0
- package/dist/src/utils/programmaticallyFocusable.d.ts +6 -0
- package/dist/src/utils/rangeToSelector.d.ts +2 -0
- package/dist/src/utils/reviveAnnotation.d.ts +2 -0
- package/dist/src/utils/reviveSelector.d.ts +11 -0
- package/dist/src/utils/reviveTarget.d.ts +2 -0
- package/dist/src/utils/splitAnnotatableRanges.d.ts +5 -0
- package/dist/src/utils/trimRangeToContainer.d.ts +1 -0
- package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +1 -0
- package/dist/test/model/w3c/fixtures.d.ts +3 -0
- package/dist/text-annotator.css +1 -1
- package/dist/text-annotator.es.js +1960 -929
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -1
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +18 -13
- package/dist/src/highlight/highlightLayer.d.ts +0 -10
- package/dist/src/highlight/trackViewport.d.ts +0 -3
- package/dist/src/state/reviveTarget.d.ts +0 -9
- package/dist/src/utils/getClientRectsPonyfill.d.ts +0 -1
- package/dist/src/utils/trimRange.d.ts +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Filter, User } from '@annotorious/core';
|
|
2
|
+
import { TextAnnotatorState } from './state';
|
|
3
|
+
import { TextAnnotation } from './model';
|
|
4
|
+
export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState<TextAnnotation, unknown>, annotatingEnabled: boolean, offsetReferenceSelector?: string) => {
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
setFilter: (filter?: Filter) => Filter;
|
|
7
|
+
setUser: (user?: User) => User;
|
|
7
8
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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';
|
|
6
|
+
export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
|
|
5
7
|
element: HTMLElement;
|
|
6
|
-
|
|
8
|
+
setStyle(style: HighlightStyleExpression | undefined): void;
|
|
9
|
+
scrollIntoView(annotationOrId: I | string): boolean;
|
|
10
|
+
state: TextAnnotatorState<I, E>;
|
|
7
11
|
}
|
|
8
|
-
export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement,
|
|
12
|
+
export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<TextAnnotation, E>) => TextAnnotator<TextAnnotation, E>;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
|
|
2
|
+
import { PresencePainterOptions } from './presence';
|
|
3
|
+
import { TextAnnotation } from './model';
|
|
4
|
+
import { HighlightStyleExpression } from './highlight';
|
|
5
|
+
export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
|
|
6
|
+
adapter?: FormatAdapter<I, E> | null;
|
|
7
|
+
annotatingEnabled?: boolean;
|
|
8
|
+
renderer?: RendererType;
|
|
6
9
|
offsetReferenceSelector?: string;
|
|
7
|
-
|
|
10
|
+
userSelectAction?: UserSelectActionExpression<E>;
|
|
8
11
|
presence?: PresencePainterOptions;
|
|
9
|
-
style?:
|
|
12
|
+
style?: HighlightStyleExpression;
|
|
13
|
+
user?: User;
|
|
10
14
|
}
|
|
15
|
+
export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
|
|
16
|
+
export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (
|
|
1
|
+
import { TextAnnotationStore } from '../state';
|
|
2
|
+
import { TextAnnotation } from '../model';
|
|
3
|
+
export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotationOrId: string | TextAnnotation) => boolean;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
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;
|
|
20
9
|
}
|
|
10
|
+
/** Helper **/
|
|
11
|
+
export declare const paint: (highlight: Highlight, viewportBounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, zIndex?: number) => HighlightStyle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
|
|
2
|
+
import { 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 | ((annotation: TextAnnotation, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
|
|
10
|
+
export declare const DEFAULT_STYLE: HighlightStyle;
|
|
11
|
+
export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
|
|
@@ -0,0 +1,20 @@
|
|
|
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<import('..').TextAnnotation, import('..').TextAnnotation>>(container: HTMLElement, state: T, viewport: ViewportState, renderer: RendererImplementation) => Renderer;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './canvasRenderer';
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './highlightsRenderer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './spansRenderer';
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ViewportState } from '@annotorious/core';
|
|
2
|
+
import { 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;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export * from './api';
|
|
1
2
|
export * from './highlight';
|
|
2
3
|
export * from './model';
|
|
3
4
|
export * from './state';
|
|
4
|
-
export * from './
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export * from './presence';
|
|
7
|
+
export * from './SelectionHandler';
|
|
5
8
|
export * from './TextAnnotator';
|
|
6
9
|
export * from './TextAnnotatorOptions';
|
|
7
|
-
|
|
8
|
-
export {
|
|
10
|
+
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';
|
|
11
|
+
export { createBody, Origin, UserSelectAction } from '@annotorious/core';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Annotation, AnnotationTarget } from '@annotorious/core';
|
|
2
2
|
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
|
+
id?: string;
|
|
9
10
|
quote: string;
|
|
10
11
|
start: number;
|
|
11
12
|
end: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TextAnnotation';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './w3c';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { 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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FormatAdapter, ParseResult } from '@annotorious/core';
|
|
2
|
+
import { TextAnnotation } from '../core';
|
|
3
|
+
import { W3CTextAnnotation } from '../w3c';
|
|
4
|
+
export type W3CTextFormatAdapter = FormatAdapter<TextAnnotation, W3CTextAnnotation>;
|
|
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: (source: string, container: HTMLElement) => W3CTextFormatAdapter;
|
|
11
|
+
export declare const parseW3CTextAnnotation: (annotation: W3CTextAnnotation) => ParseResult<TextAnnotation>;
|
|
12
|
+
export declare const serializeW3CTextAnnotation: (annotation: TextAnnotation, source: string, container: HTMLElement) => W3CTextAnnotation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export declare const
|
|
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,16 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export interface TextAnnotationStore extends Omit<Store<
|
|
4
|
-
addAnnotation(annotation:
|
|
5
|
-
bulkAddAnnotation(annotations:
|
|
1
|
+
import { Filter, Origin, Store } from '@annotorious/core';
|
|
2
|
+
import { TextAnnotation } from '../model';
|
|
3
|
+
export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotation'> {
|
|
4
|
+
addAnnotation(annotation: T, origin?: Origin): boolean;
|
|
5
|
+
bulkAddAnnotation(annotations: T[], replace: boolean, origin?: Origin): T[];
|
|
6
|
+
bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
|
|
6
7
|
getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
getAnnotationRects(id: string): DOMRect[];
|
|
9
|
+
getAt(x: number, y: number, filter?: Filter): T | undefined;
|
|
10
|
+
getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects<T>[];
|
|
10
11
|
recalculatePositions(): void;
|
|
11
12
|
}
|
|
12
|
-
export interface AnnotationRects {
|
|
13
|
-
annotation:
|
|
13
|
+
export interface AnnotationRects<T extends TextAnnotation = TextAnnotation> {
|
|
14
|
+
annotation: T;
|
|
14
15
|
rects: Rect[];
|
|
15
16
|
}
|
|
16
17
|
export interface Rect {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
hover: HoverState<TextAnnotation>;
|
|
1
|
+
import { ViewportState, UserSelectActionExpression, AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
|
|
2
|
+
import { TextAnnotation } from '../model';
|
|
3
|
+
import { TextAnnotationStore } from './TextAnnotationStore';
|
|
4
|
+
export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
|
|
5
|
+
store: TextAnnotationStore<I>;
|
|
6
|
+
selection: SelectionState<I, E>;
|
|
7
|
+
hover: HoverState<I>;
|
|
9
8
|
viewport: ViewportState;
|
|
10
|
-
}
|
|
11
|
-
export declare const createTextAnnotatorState:
|
|
9
|
+
}
|
|
10
|
+
export declare const createTextAnnotatorState: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(container: HTMLElement, defaultUserSelectAction?: UserSelectActionExpression<E>) => TextAnnotatorState<I, E>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Store } from '@annotorious/core';
|
|
2
|
+
import { TextAnnotation, TextAnnotationTarget } from '../model';
|
|
3
|
+
import { AnnotationRects } from './TextAnnotationStore';
|
|
4
|
+
interface IndexedHighlightRect {
|
|
4
5
|
minX: number;
|
|
5
6
|
minY: number;
|
|
6
7
|
maxX: number;
|
|
@@ -10,13 +11,13 @@ export interface IndexedHighlightRect {
|
|
|
10
11
|
rects: DOMRect[];
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
export declare const createSpatialTree: (store: Store<
|
|
14
|
+
export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<T>, container: HTMLElement) => {
|
|
14
15
|
all: () => IndexedHighlightRect[][];
|
|
15
16
|
clear: () => void;
|
|
16
|
-
getAt: (x: number, y: number) => string
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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>[];
|
|
20
21
|
insert: (target: TextAnnotationTarget) => void;
|
|
21
22
|
recalculate: () => void;
|
|
22
23
|
remove: (target: TextAnnotationTarget) => void;
|
|
@@ -24,3 +25,4 @@ export declare const createSpatialTree: (store: Store<TextAnnotation>, container
|
|
|
24
25
|
size: () => number;
|
|
25
26
|
update: (target: TextAnnotationTarget) => void;
|
|
26
27
|
};
|
|
28
|
+
export {};
|
|
@@ -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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events need to be manually mapped into new objects:
|
|
3
|
+
* 1. It preserves the `target` and `currentTarget` properties.
|
|
4
|
+
* Otherwise, they will be `null` when the event is read beyond the handler.
|
|
5
|
+
* 2. Spread operator can copy only own enumerable properties, not inherited ones.
|
|
6
|
+
* Therefore, we need to manually copy the props we're interested in.
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
|
|
8
|
+
* @see https://github.com/recogito/text-annotator-js/commit/65d13f3108c429311cf8c2523f6babbbc946013d#r144041390
|
|
9
|
+
*/
|
|
10
|
+
export declare const clonePointerEvent: (event: PointerEvent) => PointerEvent;
|
|
11
|
+
export declare const cloneKeyboardEvent: (event: KeyboardEvent) => KeyboardEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debounce: <T extends (...args: any[]) => void>(func: T, delay?: number) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMac: boolean;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './cancelSingleClickEvents';
|
|
2
|
+
export * from './cloneEvents';
|
|
3
|
+
export * from './device';
|
|
4
|
+
export * from './programmaticallyFocusable';
|
|
5
|
+
export * from './debounce';
|
|
6
|
+
export * from './getQuoteContext';
|
|
7
|
+
export * from './isNotAnnotatable';
|
|
8
|
+
export * from './isRevived';
|
|
9
|
+
export * from './isWhitespaceOrEmpty';
|
|
2
10
|
export * from './mergeClientRects';
|
|
3
|
-
export * from './
|
|
11
|
+
export * from './rangeToSelector';
|
|
12
|
+
export * from './reviveAnnotation';
|
|
13
|
+
export * from './reviveSelector';
|
|
14
|
+
export * from './reviveTarget';
|
|
15
|
+
export * from './splitAnnotatableRanges';
|
|
16
|
+
export * from './trimRangeToContainer';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes an element programmatically focusable by adding a `tabindex="-1"` attribute.
|
|
3
|
+
* Or does nothing if the element is already focusable 🤷🏻
|
|
4
|
+
* It's required to process keyboard events on an element that is not natively focusable.
|
|
5
|
+
*/
|
|
6
|
+
export declare const programmaticallyFocusable: (container: HTMLElement) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TextSelector } from '../model';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new selector object with the revived DOM range from the given text annotation position
|
|
4
|
+
* Only the annotatable elements are processed and counted towards the range
|
|
5
|
+
*
|
|
6
|
+
* @param selector annotation selector with start and end positions
|
|
7
|
+
* @param container the HTML container of the annotated content
|
|
8
|
+
*
|
|
9
|
+
* @returns the revived selector
|
|
10
|
+
*/
|
|
11
|
+
export declare const reviveSelector: <T extends TextSelector>(selector: T, container: HTMLElement) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const trimRangeToContainer: (range: Range, container: HTMLElement) => Range;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/text-annotator.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
.r6o-canvas-highlight-layer{position:fixed;top:0;bottom:0;left:0;width:100vw;height:100vh;pointer-events:none}.r6o-canvas-highlight-layer.bg{mix-blend-mode:multiply;z-index:1}.r6o-annotatable .r6o-span-highlight-layer{position:absolute;top:0;left:0;width:100%;height:100%;mix-blend-mode:multiply;pointer-events: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}.r6o-presence-layer{left:0;position:fixed;top:0;bottom:0;width:100vw;pointer-events:none}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}
|