@soomo/text-annotator 3.0.0-staging.3 → 3.0.0-staging.30
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 -3
- package/dist/src/TextAnnotator.d.ts +7 -4
- package/dist/src/TextAnnotatorOptions.d.ts +6 -3
- package/dist/src/api/scrollIntoView.d.ts +2 -2
- package/dist/src/highlight/Highlight.d.ts +1 -1
- package/dist/src/highlight/HighlightPainter.d.ts +2 -2
- package/dist/src/highlight/HighlightStyle.d.ts +2 -2
- package/dist/src/highlight/baseRenderer.d.ts +5 -5
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +1 -1
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +2 -2
- package/dist/src/highlight/span/spansRenderer.d.ts +1 -1
- package/dist/src/highlight/viewport.d.ts +1 -1
- package/dist/src/index.d.ts +2 -3
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +2 -2
- package/dist/src/presence/PresencePainter.d.ts +2 -2
- package/dist/src/state/TextAnnotationStore.d.ts +2 -2
- package/dist/src/state/TextAnnotatorState.d.ts +2 -2
- package/dist/src/state/spatialTree.d.ts +3 -3
- package/dist/src/utils/cancelSingleClickEvents.d.ts +6 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/text-annotator.css +1 -1
- package/dist/text-annotator.es.js +967 -936
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +12 -12
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Filter, User } from '@annotorious/core';
|
|
1
2
|
import { TextAnnotatorState } from './state';
|
|
2
|
-
import { User } from '@annotorious/core';
|
|
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
|
+
setFilter: (filter?: Filter) => Filter;
|
|
7
|
+
setUser: (user?: User) => User;
|
|
7
8
|
};
|
|
@@ -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,
|
|
14
|
+
export declare const createTextAnnotator: <E extends unknown = TextAnnotation>(container: HTMLElement, options?: TextAnnotatorOptions<E>) => TextAnnotator<E>;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextAnnotation } from './model';
|
|
1
|
+
import { FormatAdapter, PointerSelectAction, User } from '@annotorious/core';
|
|
3
2
|
import { PresencePainterOptions } from './presence';
|
|
4
|
-
import {
|
|
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) => (
|
|
4
|
+
export declare const scrollIntoView: (container: HTMLElement, store: TextAnnotationStore) => (annotationOrId: string | TextAnnotation) => boolean;
|
|
@@ -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,9 +1,9 @@
|
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ViewportState } from '@annotorious/core';
|
|
2
|
-
import { TextAnnotatorState } from '
|
|
2
|
+
import { TextAnnotatorState } from '../../state';
|
|
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;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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 {
|
|
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 '../presence';
|
|
4
4
|
|
|
5
5
|
export declare const createPresencePainter: (container: HTMLElement, provider: PresenceProvider, opts?: PresencePainterOptions) => HighlightPainter;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Filter, Origin, Store } from '@annotorious/core';
|
|
1
2
|
import { TextAnnotation } from '../model';
|
|
2
|
-
import { Origin, Store } from '@annotorious/core';
|
|
3
3
|
|
|
4
4
|
export interface TextAnnotationStore extends Omit<Store<TextAnnotation>, 'addAnnotation' | 'bulkAddAnnotation'> {
|
|
5
5
|
addAnnotation(annotation: TextAnnotation, origin?: Origin): boolean;
|
|
6
6
|
bulkAddAnnotation(annotations: TextAnnotation[], replace: boolean, origin?: Origin): TextAnnotation[];
|
|
7
7
|
bulkUpsertAnnotations(annotations: TextAnnotation[], origin?: Origin): TextAnnotation[];
|
|
8
8
|
getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect;
|
|
9
|
-
getAt(x: number, y: number): TextAnnotation | undefined;
|
|
9
|
+
getAt(x: number, y: number, filter?: Filter): TextAnnotation | undefined;
|
|
10
10
|
getIntersecting(minX: number, minY: number, maxX: number, maxY: number): AnnotationRects[];
|
|
11
11
|
recalculatePositions(): void;
|
|
12
12
|
}
|
|
@@ -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;
|
|
@@ -15,7 +15,7 @@ interface IndexedHighlightRect {
|
|
|
15
15
|
export declare const createSpatialTree: (store: Store<TextAnnotation>, container: HTMLElement) => {
|
|
16
16
|
all: () => IndexedHighlightRect[][];
|
|
17
17
|
clear: () => void;
|
|
18
|
-
getAt: (x: number, y: number) => string
|
|
18
|
+
getAt: (x: number, y: number, all?: boolean) => string[];
|
|
19
19
|
getAnnotationBounds: (id: string) => DOMRect;
|
|
20
20
|
getAnnotationRects: (id: string) => DOMRect[];
|
|
21
21
|
getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects[];
|
|
@@ -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;
|
package/dist/text-annotator.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.r6o-
|
|
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%;pointer-events:none}.r6o-annotatable .r6o-span-highlight-layer.hidden{display:none}.r6o-annotatable .r6o-span-highlight-layer .r6o-annotation{position:absolute;display:block;border-width:0;border-style:solid}.r6o-annotation{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}.hovered *{cursor:pointer}*::selection,::selection{background:#0080ff2e}::-moz-selection{background:#0080ff2e}
|