@recogito/text-annotator 3.4.10 → 4.0.0
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/index.d.ts +8 -7
- package/dist/model/core/index.d.ts +1 -1
- package/dist/model/w3c/index.d.ts +2 -2
- package/dist/model/w3c/{W3CTextFormatAdapter.d.ts → w3c-text-format-adapter.d.ts} +2 -2
- package/dist/rendering/base-renderer.d.ts +31 -0
- package/dist/{highlight/HighlightStyle.d.ts → rendering/highlight-style.d.ts} +4 -1
- package/dist/{highlight/Highlight.d.ts → rendering/highlight.d.ts} +2 -1
- package/dist/rendering/index.d.ts +5 -0
- package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +7 -0
- package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
- package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
- package/dist/rendering/renderer-spans/index.d.ts +1 -0
- package/dist/rendering/renderer-spans/spans-renderer.d.ts +4 -0
- package/dist/selection-handler.d.ts +12 -0
- package/dist/state/index.d.ts +2 -2
- package/dist/state/{spatialTree.d.ts → spatial-tree.d.ts} +2 -2
- package/dist/state/{TextAnnotationStore.d.ts → text-annotation-store.d.ts} +2 -2
- package/dist/state/{TextAnnotatorState.d.ts → text-annotator-state.d.ts} +3 -3
- package/dist/{TextAnnotatorOptions.d.ts → text-annotator-options.d.ts} +4 -6
- package/dist/text-annotator.css +1 -1
- package/dist/{TextAnnotator.d.ts → text-annotator.d.ts} +7 -7
- package/dist/text-annotator.es.js +778 -841
- 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/dist/utils/annotation/index.d.ts +4 -0
- package/dist/utils/{rangeToSelector.d.ts → annotation/range-to-selector.d.ts} +1 -1
- package/dist/utils/{reviveSelector.d.ts → annotation/revive-annotation.d.ts} +4 -1
- package/dist/{api/scrollIntoView.d.ts → utils/annotation/scroll-into-view.d.ts} +2 -2
- package/dist/utils/dom/index.d.ts +7 -0
- package/dist/utils/events/index.d.ts +3 -0
- package/dist/utils/highlight/compute-z-index.d.ts +3 -0
- package/dist/utils/highlight/index.d.ts +4 -0
- package/package.json +3 -3
- package/dist/SelectionHandler.d.ts +0 -12
- package/dist/api/index.d.ts +0 -1
- package/dist/highlight/HighlightPainter.d.ts +0 -11
- package/dist/highlight/Renderer.d.ts +0 -22
- package/dist/highlight/canvas/canvasRenderer.d.ts +0 -5
- package/dist/highlight/canvas/index.d.ts +0 -1
- package/dist/highlight/highlights/highlightsRenderer.d.ts +0 -6
- package/dist/highlight/highlights/index.d.ts +0 -1
- package/dist/highlight/index.d.ts +0 -8
- package/dist/highlight/span/color.d.ts +0 -2
- package/dist/highlight/span/index.d.ts +0 -2
- package/dist/highlight/span/spansRenderer.d.ts +0 -3
- package/dist/presence/PresencePainter.d.ts +0 -5
- package/dist/presence/PresencePainterOptions.d.ts +0 -3
- package/dist/presence/index.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -19
- package/dist/utils/isRevived.d.ts +0 -2
- package/dist/utils/reviveAnnotation.d.ts +0 -2
- package/dist/utils/reviveTarget.d.ts +0 -2
- /package/dist/model/core/{TextAnnotation.d.ts → text-annotation.d.ts} +0 -0
- /package/dist/model/w3c/{W3CTextAnnotation.d.ts → w3c-text-annotation.d.ts} +0 -0
- /package/dist/{highlight → rendering}/viewport.d.ts +0 -0
- /package/dist/utils/{getQuoteContext.d.ts → annotation/get-quote-context.d.ts} +0 -0
- /package/dist/utils/{device.d.ts → dom/device.d.ts} +0 -0
- /package/dist/utils/{isNotAnnotatable.d.ts → dom/is-not-annotatable.d.ts} +0 -0
- /package/dist/utils/{isWhitespaceOrEmpty.d.ts → dom/is-whitespace-or-empty.d.ts} +0 -0
- /package/dist/utils/{mergeRanges.d.ts → dom/merge-ranges.d.ts} +0 -0
- /package/dist/utils/{programmaticallyFocusable.d.ts → dom/programmatically-focusable.d.ts} +0 -0
- /package/dist/utils/{splitAnnotatableRanges.d.ts → dom/split-annotatable-ranges.d.ts} +0 -0
- /package/dist/utils/{trimRangeToContainer.d.ts → dom/trim-range-to-container.d.ts} +0 -0
- /package/dist/utils/{cancelSingleClickEvents.d.ts → events/cancel-single-click-events.d.ts} +0 -0
- /package/dist/utils/{cloneEvents.d.ts → events/clone-events.d.ts} +0 -0
- /package/dist/utils/{debounce.d.ts → events/debounce.d.ts} +0 -0
- /package/dist/utils/{getHighlightClientRects.d.ts → highlight/get-highlight-client-rects.d.ts} +0 -0
- /package/dist/utils/{mergeClientRects.d.ts → highlight/merge-client-rects.d.ts} +0 -0
- /package/dist/utils/{rectsToBounds.d.ts → highlight/rects-to-bounds.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './highlight';
|
|
3
1
|
export * from './model';
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './rendering';
|
|
5
3
|
export * from './state';
|
|
6
|
-
export * from './utils';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
4
|
+
export * from './utils/annotation';
|
|
5
|
+
export * from './utils/dom';
|
|
6
|
+
export * from './utils/events';
|
|
7
|
+
export * from './utils/highlight';
|
|
8
|
+
export * from './selection-handler';
|
|
9
|
+
export * from './text-annotator';
|
|
10
|
+
export * from './text-annotator-options';
|
|
10
11
|
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
12
|
export { createBody, Origin, UserSelectAction } from '@annotorious/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './text-annotation';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './w3c-text-annotation';
|
|
2
|
+
export * from './w3c-text-format-adapter';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type FormatAdapter, type ParseResult } from '@annotorious/core';
|
|
2
1
|
import type { TextAnnotation } from '../core';
|
|
3
|
-
import type { W3CTextAnnotation } from '
|
|
2
|
+
import type { W3CTextAnnotation } from './';
|
|
3
|
+
import { type FormatAdapter, type ParseResult } from '@annotorious/core';
|
|
4
4
|
export type W3CTextFormatAdapter<I extends TextAnnotation = TextAnnotation, E extends W3CTextAnnotation = W3CTextAnnotation> = FormatAdapter<I, E>;
|
|
5
5
|
/**
|
|
6
6
|
* @param source - the IRI of the annotated content
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Unsubscribe } from 'nanoevents';
|
|
2
|
+
import { type Filter, type ViewportState } from '@annotorious/core';
|
|
3
|
+
import type { TextAnnotation } from '../model';
|
|
4
|
+
import type { TextAnnotatorState } from '../state';
|
|
5
|
+
import { type Highlight, type HighlightStyleExpression, type ViewportBounds } from './';
|
|
6
|
+
/**
|
|
7
|
+
* The renderer runtime interface.
|
|
8
|
+
*/
|
|
9
|
+
export interface Renderer {
|
|
10
|
+
destroy(): void;
|
|
11
|
+
on: <E extends keyof RendererEvents>(event: E, callback: RendererEvents[E]) => Unsubscribe;
|
|
12
|
+
redraw(force?: boolean): void;
|
|
13
|
+
setStyle(style?: HighlightStyleExpression, id?: string): void;
|
|
14
|
+
setFilter(filter?: Filter<any>): void;
|
|
15
|
+
setVisible(visible: boolean): void;
|
|
16
|
+
}
|
|
17
|
+
export interface RendererEvents {
|
|
18
|
+
onRedraw(): void;
|
|
19
|
+
}
|
|
20
|
+
export type RendererFactory<T extends TextAnnotation> = (container: HTMLElement, state: TextAnnotatorState<T, any>, viewport: ViewportState) => Renderer;
|
|
21
|
+
/**
|
|
22
|
+
* A utility interface. Instead of implementing a Renderer from scratch,
|
|
23
|
+
* implementers can simply implement a painter, and wrap it in the
|
|
24
|
+
* BaseRenderer, which will handle common concerns.
|
|
25
|
+
*/
|
|
26
|
+
export interface Painter {
|
|
27
|
+
destroy(): void;
|
|
28
|
+
redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, styleOverrides?: Map<string, HighlightStyleExpression>, force?: boolean): void;
|
|
29
|
+
setVisible(visible: boolean): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const createRenderer: <T extends TextAnnotatorState = TextAnnotatorState<TextAnnotation, any>>(painter: Painter, container: HTMLElement, state: T, viewport: ViewportState) => Renderer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnnotationState, Color, DrawingStyle } from '@annotorious/core';
|
|
2
|
-
import type { TextAnnotation } from '
|
|
2
|
+
import type { TextAnnotation } from '../model';
|
|
3
|
+
import type { Highlight } from './';
|
|
3
4
|
export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity'> {
|
|
4
5
|
underlineStyle?: string;
|
|
5
6
|
underlineColor?: Color;
|
|
@@ -9,3 +10,5 @@ export interface HighlightStyle extends Pick<DrawingStyle, 'fill' | 'fillOpacity
|
|
|
9
10
|
export type HighlightStyleExpression = HighlightStyle | (<I extends TextAnnotation = TextAnnotation>(annotation: I, state: AnnotationState, zIndex?: number) => HighlightStyle | undefined);
|
|
10
11
|
export declare const DEFAULT_STYLE: HighlightStyle;
|
|
11
12
|
export declare const DEFAULT_SELECTED_STYLE: HighlightStyle;
|
|
13
|
+
export declare const getBackgroundColor: (style?: HighlightStyle) => string;
|
|
14
|
+
export declare const computeStyle: (highlight: Highlight, style?: HighlightStyleExpression, z?: number) => HighlightStyle;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnnotationState } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotation } from '../model';
|
|
2
3
|
import type { AnnotationRects } from '../state';
|
|
3
|
-
export interface Highlight extends AnnotationRects {
|
|
4
|
+
export interface Highlight extends AnnotationRects<TextAnnotation> {
|
|
4
5
|
state: AnnotationState;
|
|
5
6
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TextAnnotation } from '../../model';
|
|
2
|
+
import { type Painter, type RendererFactory } from '../';
|
|
3
|
+
/**
|
|
4
|
+
* EXPERIMENTAL!
|
|
5
|
+
*/
|
|
6
|
+
export declare const createCSSHighlightPainter: () => Painter;
|
|
7
|
+
export declare const createCSSHighlightRenderer: RendererFactory<TextAnnotation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './css-highlight-renderer';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './spans-renderer';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Filter, Lifecycle, User } from '@annotorious/core';
|
|
2
|
+
import type { TextAnnotatorState } from './state';
|
|
3
|
+
import type { TextAnnotation } from './model';
|
|
4
|
+
import type { AnnotatingMode } from './text-annotator';
|
|
5
|
+
import type { TextAnnotatorOptions } from './text-annotator-options';
|
|
6
|
+
export declare const createSelectionHandler: <T extends TextAnnotation>(container: HTMLElement, state: TextAnnotatorState<TextAnnotation, any>, lifecycle: Lifecycle<TextAnnotation, any>, options: TextAnnotatorOptions<TextAnnotation, any>) => {
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
setFilter: (filter?: Filter<any>) => Filter<any>;
|
|
9
|
+
setUser: (user?: User) => User;
|
|
10
|
+
setAnnotatingEnabled: (enabled: boolean) => void;
|
|
11
|
+
setAnnotatingMode: (mode?: AnnotatingMode) => AnnotatingMode;
|
|
12
|
+
};
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './text-annotation-store';
|
|
2
|
+
export * from './text-annotator-state';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from '@annotorious/core';
|
|
2
2
|
import { type Unsubscribe } from 'nanoevents';
|
|
3
3
|
import type { TextAnnotation, TextAnnotationTarget } from '../model';
|
|
4
|
-
import type { AnnotationRects } from '
|
|
4
|
+
import type { AnnotationRects } from '../state/text-annotation-store';
|
|
5
5
|
interface IndexedHighlightRect {
|
|
6
6
|
minX: number;
|
|
7
7
|
minY: number;
|
|
@@ -19,7 +19,7 @@ export declare const createSpatialTree: <T extends TextAnnotation>(store: Store<
|
|
|
19
19
|
all: () => IndexedHighlightRect[][];
|
|
20
20
|
clear: () => void;
|
|
21
21
|
getAt: (x: number, y: number, all?: boolean) => string[];
|
|
22
|
-
getAnnotationBounds: (id: string) => DOMRect;
|
|
22
|
+
getAnnotationBounds: (id: string) => DOMRect | undefined;
|
|
23
23
|
getAnnotationRects: (id: string) => DOMRect[];
|
|
24
24
|
getIntersecting: (minX: number, minY: number, maxX: number, maxY: number) => AnnotationRects<T>[];
|
|
25
25
|
insert: (target: TextAnnotationTarget) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Unsubscribe } from 'nanoevents';
|
|
2
2
|
import type { Filter, Origin, Store } from '@annotorious/core';
|
|
3
3
|
import type { TextAnnotation } from '../model';
|
|
4
|
-
import type { SpatialTreeEvents } from '
|
|
5
|
-
export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | '
|
|
4
|
+
import type { SpatialTreeEvents } from '../state/spatial-tree';
|
|
5
|
+
export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation> extends Omit<Store<T>, 'addAnnotation' | 'bulkAddAnnotations' | 'bulkUpsertAnnotations'> {
|
|
6
6
|
addAnnotation(annotation: T, origin?: Origin): boolean;
|
|
7
7
|
bulkAddAnnotations(annotations: T[], replace: boolean, origin?: Origin): T[];
|
|
8
8
|
bulkUpsertAnnotations(annotations: T[], origin?: Origin): T[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ViewportState } from '@annotorious/core';
|
|
2
2
|
import type { AnnotatorState, SelectionState, HoverState } from '@annotorious/core';
|
|
3
3
|
import type { TextAnnotation } from '../model';
|
|
4
|
-
import type { TextAnnotationStore } from '
|
|
5
|
-
import type { TextAnnotatorOptions } from '../
|
|
6
|
-
export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends AnnotatorState<I, E> {
|
|
4
|
+
import type { TextAnnotationStore } from '../state/text-annotation-store';
|
|
5
|
+
import type { TextAnnotatorOptions } from '../text-annotator-options';
|
|
6
|
+
export interface TextAnnotatorState<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<AnnotatorState<I, E>, 'store'> {
|
|
7
7
|
store: TextAnnotationStore<I>;
|
|
8
8
|
selection: SelectionState<I, E>;
|
|
9
9
|
hover: HoverState<I>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { FormatAdapter, UserSelectActionExpression, User } from '@annotorious/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HighlightStyleExpression, RendererFactory } from './rendering';
|
|
3
3
|
import type { TextAnnotation } from './model';
|
|
4
|
-
import type { HighlightStyleExpression, RendererFactory } from './highlight';
|
|
5
4
|
export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> {
|
|
6
|
-
adapter?: FormatAdapter<I, E
|
|
5
|
+
adapter?: FormatAdapter<I, E>;
|
|
7
6
|
allowModifierSelect?: boolean;
|
|
8
7
|
annotatingEnabled?: boolean;
|
|
9
8
|
/**
|
|
@@ -23,13 +22,12 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
|
|
|
23
22
|
verticalTolerance?: number;
|
|
24
23
|
};
|
|
25
24
|
offsetReferenceSelector?: string;
|
|
26
|
-
|
|
27
|
-
renderer?: RendererType | RendererFactory;
|
|
25
|
+
renderer?: RendererType | RendererFactory<I>;
|
|
28
26
|
selectionMode?: 'shortest' | 'all';
|
|
29
27
|
style?: HighlightStyleExpression;
|
|
30
28
|
user?: User;
|
|
31
29
|
userSelectAction?: UserSelectActionExpression<E>;
|
|
32
30
|
}
|
|
33
|
-
export type RendererType = 'SPANS' | '
|
|
31
|
+
export type RendererType = 'SPANS' | 'CSS_HIGHLIGHTS';
|
|
34
32
|
export type DismissOnNotAnnotatableExpression = 'NEVER' | 'ALWAYS' | ((event: Event, container: HTMLElement) => boolean);
|
|
35
33
|
export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
|
package/dist/text-annotator.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.r6o-
|
|
1
|
+
.r6o-annotatable .r6o-span-highlight-layer{position:absolute;top:0;left:0;width:100%;height:100%;mix-blend-mode:multiply;pointer-events:none;overflow:hidden;user-select:none;-webkit-user-select: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}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}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { HighlightStyleExpression } from './
|
|
1
|
+
import { type Annotator } from '@annotorious/core';
|
|
2
|
+
import type { HighlightStyleExpression, Renderer } from './rendering';
|
|
3
3
|
import type { TextAnnotation } from './model';
|
|
4
4
|
import { type TextAnnotatorState } from './state';
|
|
5
|
-
import { type TextAnnotatorOptions } from './
|
|
6
|
-
import './
|
|
7
|
-
export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Annotator<I, E> {
|
|
5
|
+
import { type TextAnnotatorOptions } from './text-annotator-options';
|
|
6
|
+
import './text-annotator.css';
|
|
7
|
+
export interface TextAnnotator<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<Annotator<I, E>, 'setStyle' | 'state'> {
|
|
8
8
|
element: HTMLElement;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
renderer: Renderer;
|
|
10
|
+
setStyle(style?: HighlightStyleExpression, id?: string): void;
|
|
11
11
|
scrollIntoView(annotationOrId: I | string, scrollParentOrId?: string | Element): boolean;
|
|
12
12
|
setAnnotatingEnabled(enabled?: boolean): void;
|
|
13
13
|
setAnnotatingMode(mode?: AnnotatingMode): void;
|