@recogito/text-annotator 3.0.0-rc.19 → 3.0.0-rc.3
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 +4 -4
- package/dist/src/TextAnnotator.d.ts +4 -7
- package/dist/src/TextAnnotatorOptions.d.ts +4 -8
- package/dist/src/api/scrollIntoView.d.ts +2 -3
- package/dist/src/highlight/HighlightPainter.d.ts +19 -11
- package/dist/src/highlight/highlightLayer.d.ts +10 -0
- package/dist/src/highlight/index.d.ts +2 -3
- package/dist/src/highlight/trackViewport.d.ts +3 -0
- package/dist/src/index.d.ts +3 -4
- package/dist/src/model/{core/TextAnnotation.d.ts → TextAnnotation.d.ts} +2 -4
- package/dist/src/model/index.d.ts +1 -2
- package/dist/src/presence/PresencePainter.d.ts +4 -5
- package/dist/src/state/TextAnnotationStore.d.ts +6 -7
- package/dist/src/state/TextAnnotatorState.d.ts +6 -6
- package/dist/src/state/index.d.ts +1 -0
- package/dist/src/state/reviveTarget.d.ts +9 -0
- package/dist/src/state/spatialTree.d.ts +6 -9
- package/dist/src/utils/index.d.ts +0 -9
- package/dist/text-annotator.css +1 -1
- package/dist/text-annotator.es.js +945 -1480
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +1 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +11 -17
- package/dist/src/highlight/Highlight.d.ts +0 -6
- package/dist/src/highlight/HighlightStyle.d.ts +0 -12
- package/dist/src/highlight/baseRenderer.d.ts +0 -21
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -4
- package/dist/src/highlight/canvas/index.d.ts +0 -1
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -6
- package/dist/src/highlight/highlights/index.d.ts +0 -1
- package/dist/src/highlight/span/index.d.ts +0 -1
- package/dist/src/highlight/span/spansRenderer.d.ts +0 -4
- package/dist/src/highlight/viewport.d.ts +0 -13
- package/dist/src/model/core/index.d.ts +0 -1
- package/dist/src/model/w3c/W3CTextAnnotation.d.ts +0 -34
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +0 -13
- package/dist/src/model/w3c/index.d.ts +0 -2
- package/dist/src/utils/debounce.d.ts +0 -1
- package/dist/src/utils/getAnnotatableFragment.d.ts +0 -5
- package/dist/src/utils/getQuoteContext.d.ts +0 -4
- package/dist/src/utils/isRevived.d.ts +0 -3
- package/dist/src/utils/rangeToSelector.d.ts +0 -3
- package/dist/src/utils/reviveAnnotation.d.ts +0 -3
- package/dist/src/utils/reviveSelector.d.ts +0 -12
- package/dist/src/utils/reviveTarget.d.ts +0 -3
- package/dist/src/utils/splitAnnotatableRanges.d.ts +0 -6
- package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
- package/dist/test/model/w3c/fixtures.d.ts +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { type User } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotatorState } from './state';
|
|
3
|
+
import type { TextSelector } from './model';
|
|
4
|
+
export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
|
|
4
5
|
export declare const SelectionHandler: (container: HTMLElement, state: TextAnnotatorState, offsetReferenceSelector?: string) => {
|
|
5
|
-
destroy: () => void;
|
|
6
6
|
setUser: (user: User) => User;
|
|
7
7
|
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextAnnotation } from './model';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface TextAnnotator<E extends unknown = TextAnnotation> extends Annotator<TextAnnotation, E> {
|
|
1
|
+
import type { Annotator } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation } from './model';
|
|
3
|
+
import type { TextAnnotatorOptions } from './TextAnnotatorOptions';
|
|
4
|
+
export interface TextAnnotator<T extends unknown = TextAnnotation> extends Annotator<TextAnnotation, T> {
|
|
7
5
|
element: HTMLElement;
|
|
8
6
|
scrollIntoView(annotation: TextAnnotation): boolean;
|
|
9
|
-
state: TextAnnotatorState;
|
|
10
7
|
}
|
|
11
8
|
export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, opts?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FormatAdapter, PointerSelectAction } from '@annotorious/core';
|
|
5
|
-
|
|
1
|
+
import type { DrawingStyle, FormatAdapter, PointerSelectAction } from '@annotorious/core';
|
|
2
|
+
import type { PresencePainterOptions } from './presence';
|
|
3
|
+
import type { TextAnnotation } from './model';
|
|
6
4
|
export interface TextAnnotatorOptions<T extends unknown = TextAnnotation> {
|
|
7
5
|
adapter?: FormatAdapter<TextAnnotation, T> | null;
|
|
8
|
-
renderer?: RendererType;
|
|
9
6
|
offsetReferenceSelector?: string;
|
|
10
7
|
pointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction);
|
|
11
8
|
presence?: PresencePainterOptions;
|
|
12
|
-
style?:
|
|
9
|
+
style?: DrawingStyle | ((annotation: TextAnnotation) => DrawingStyle);
|
|
13
10
|
}
|
|
14
|
-
export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { TextAnnotationStore } from 'src/state';
|
|
2
|
+
import type { TextAnnotation } from '../model/TextAnnotation';
|
|
4
3
|
export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotation: TextAnnotation) => boolean;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
paint(
|
|
9
|
-
|
|
1
|
+
import type { DrawingStyle } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation } from '../model';
|
|
3
|
+
import type { Rect } from '../state';
|
|
4
|
+
/**
|
|
5
|
+
* A painter implements the actual CANVAS highlight drawing logic.
|
|
6
|
+
*/
|
|
7
|
+
export type HighlightPainter = {
|
|
8
|
+
paint(annotation: TextAnnotation, rects: Rect[], bg: CanvasRenderingContext2D, fg: CanvasRenderingContext2D, isSelected?: boolean, style?: DrawingStyle | ((annotation: TextAnnotation, selected?: boolean) => DrawingStyle)): void;
|
|
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;
|
|
10
20
|
}
|
|
11
|
-
/** Helper **/
|
|
12
|
-
export declare const paint: (highlight: Highlight, viewportBounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, zIndex?: number) => HighlightStyle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DrawingStyle, Filter, ViewportState } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation } from '../model';
|
|
3
|
+
import type { TextAnnotatorState } from '../state';
|
|
4
|
+
import { type HighlightPainter } from './HighlightPainter';
|
|
5
|
+
export declare const createHighlightLayer: (container: HTMLElement, state: TextAnnotatorState, viewport: ViewportState) => {
|
|
6
|
+
redraw: () => number;
|
|
7
|
+
setDrawingStyle: (style: DrawingStyle | ((a: TextAnnotation, selected?: boolean) => DrawingStyle)) => void;
|
|
8
|
+
setFilter: (filter?: Filter) => void;
|
|
9
|
+
setPainter: (painter: HighlightPainter) => HighlightPainter;
|
|
10
|
+
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './span';
|
|
1
|
+
export * from './highlightLayer';
|
|
2
|
+
export * from './HighlightPainter';
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { _Origin } from '@annotorious/core';
|
|
2
1
|
export * from './highlight';
|
|
3
2
|
export * from './model';
|
|
4
3
|
export * from './state';
|
|
5
|
-
export * from './utils';
|
|
6
4
|
export * from './presence/PresencePainterOptions';
|
|
7
5
|
export * from './TextAnnotator';
|
|
8
6
|
export * from './TextAnnotatorOptions';
|
|
9
|
-
export
|
|
10
|
-
|
|
7
|
+
export * from '@annotorious/core/src/model';
|
|
8
|
+
import { Origin as _Origin } from '@annotorious/core/src/state';
|
|
9
|
+
export declare const Origin: typeof _Origin;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { Annotation, AnnotationTarget } from '@annotorious/core';
|
|
2
|
-
|
|
1
|
+
import type { Annotation, AnnotationTarget } from '@annotorious/core';
|
|
3
2
|
export interface TextAnnotation extends Annotation {
|
|
4
3
|
target: TextAnnotationTarget;
|
|
5
4
|
}
|
|
6
5
|
export interface TextAnnotationTarget extends AnnotationTarget {
|
|
7
|
-
selector: TextSelector
|
|
6
|
+
selector: TextSelector;
|
|
8
7
|
}
|
|
9
8
|
export interface TextSelector {
|
|
10
|
-
id?: string;
|
|
11
9
|
quote: string;
|
|
12
10
|
start: number;
|
|
13
11
|
end: number;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './w3c';
|
|
1
|
+
export * from './TextAnnotation';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HighlightPainter } from '../highlight
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
|
|
1
|
+
import type { PresenceProvider } from '@annotorious/core';
|
|
2
|
+
import type { HighlightPainter } from '../highlight';
|
|
3
|
+
import type { PresencePainterOptions } from './PresencePainterOptions';
|
|
4
|
+
export declare const createPainter: (provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { Origin, Store } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation } from '../model';
|
|
4
3
|
export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
|
|
5
|
-
addAnnotation(annotation: TextAnnotation, origin
|
|
6
|
-
bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin
|
|
7
|
-
bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
|
|
4
|
+
addAnnotation(annotation: TextAnnotation, origin: Origin): boolean;
|
|
5
|
+
bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin: Origin): TextAnnotation[];
|
|
8
6
|
getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
|
|
9
7
|
getAt(x: number, y: number): TextAnnotation | undefined;
|
|
10
|
-
getIntersecting(minX: number, minY: number, maxX: number, maxY: number):
|
|
8
|
+
getIntersecting(minX: number, minY: number, maxX: number, maxY: number): TextAnnotation[];
|
|
9
|
+
getIntersectingRects(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
|
|
11
10
|
recalculatePositions(): void;
|
|
12
11
|
}
|
|
13
12
|
export interface AnnotationRects {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
import type { PointerSelectAction, ViewportState } from '@annotorious/core';
|
|
2
|
+
import { AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
|
|
3
|
+
import type { TextAnnotation } from '../model';
|
|
4
|
+
import type { TextAnnotationStore } from './TextAnnotationStore';
|
|
5
|
+
export type TextAnnotatorState = AnnotatorState<TextAnnotation> & {
|
|
6
6
|
store: TextAnnotationStore;
|
|
7
7
|
selection: SelectionState<TextAnnotation>;
|
|
8
8
|
hover: HoverState<TextAnnotation>;
|
|
9
9
|
viewport: ViewportState;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
export declare const createTextAnnotatorState: (container: HTMLElement, defaultPointerAction?: PointerSelectAction | ((annotation: TextAnnotation) => PointerSelectAction)) => TextAnnotatorState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextAnnotationTarget } from '../model';
|
|
2
|
+
/**
|
|
3
|
+
* Recalculates the DOM range from the given text annotation target.
|
|
4
|
+
*
|
|
5
|
+
* @param annotation the text annotation
|
|
6
|
+
* @param container the HTML container of the annotated content
|
|
7
|
+
* @returns the DOM range
|
|
8
|
+
*/
|
|
9
|
+
export declare const reviveTarget: (target: TextAnnotationTarget, container: HTMLElement) => TextAnnotationTarget;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextAnnotation, TextAnnotationTarget } from '../model';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface IndexedHighlightRect {
|
|
1
|
+
import type { Store } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation, TextAnnotationTarget } from '../model';
|
|
3
|
+
export interface IndexedHighlightRect {
|
|
6
4
|
minX: number;
|
|
7
5
|
minY: number;
|
|
8
6
|
maxX: number;
|
|
@@ -16,9 +14,9 @@ export declare const createSpatialTree: (store: Store<TextAnnotation>, container
|
|
|
16
14
|
all: () => IndexedHighlightRect[][];
|
|
17
15
|
clear: () => void;
|
|
18
16
|
getAt: (x: number, y: number) => string | undefined;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
getBoundsForAnnotation: (id: string) => DOMRect;
|
|
18
|
+
getDOMRectsForAnnotation: (id: string) => DOMRect[];
|
|
19
|
+
getIntersectingRects: (minX: number, minY: number, maxX: number, maxY: number) => IndexedHighlightRect[];
|
|
22
20
|
insert: (target: TextAnnotationTarget) => void;
|
|
23
21
|
recalculate: () => void;
|
|
24
22
|
remove: (target: TextAnnotationTarget) => void;
|
|
@@ -26,4 +24,3 @@ export declare const createSpatialTree: (store: Store<TextAnnotation>, container
|
|
|
26
24
|
size: () => number;
|
|
27
25
|
update: (target: TextAnnotationTarget) => void;
|
|
28
26
|
};
|
|
29
|
-
export {};
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export * from './debounce';
|
|
2
|
-
export * from './getAnnotatableFragment';
|
|
3
1
|
export * from './getClientRectsPonyfill';
|
|
4
|
-
export * from './getQuoteContext';
|
|
5
|
-
export * from './isRevived';
|
|
6
2
|
export * from './mergeClientRects';
|
|
7
|
-
export * from './rangeToSelector';
|
|
8
|
-
export * from './reviveAnnotation';
|
|
9
|
-
export * from './reviveSelector';
|
|
10
|
-
export * from './reviveTarget';
|
|
11
|
-
export * from './splitAnnotatableRanges';
|
|
12
3
|
export * from './trimRange';
|
package/dist/text-annotator.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
html,body{overscroll-behavior-y:none}.r6o-annotatable,.r6o-annotatable *{position:relative}.r6o-annotatable.hovered{cursor:pointer}.r6o-highlight-layer{height:100vh;left:0;position:fixed;top:0;pointer-events:none;width:100vw}*::selection,::selection{background:rgba(0,128,255,.18)}::-moz-selection{background:rgba(0,128,255,.18)}
|