@recogito/text-annotator 3.3.2 → 3.4.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/SelectionHandler.d.ts +10 -0
- package/dist/TextAnnotator.d.ts +15 -0
- package/dist/TextAnnotatorOptions.d.ts +34 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/scrollIntoView.d.ts +3 -0
- package/dist/highlight/Highlight.d.ts +5 -0
- package/dist/highlight/HighlightPainter.d.ts +11 -0
- package/dist/highlight/HighlightStyle.d.ts +11 -0
- package/dist/highlight/baseRenderer.d.ts +20 -0
- package/dist/highlight/canvas/canvasRenderer.d.ts +5 -0
- package/dist/highlight/canvas/index.d.ts +1 -0
- package/dist/highlight/highlights/highlightsRenderer.d.ts +6 -0
- package/dist/highlight/highlights/index.d.ts +1 -0
- package/dist/highlight/index.d.ts +6 -0
- package/dist/highlight/span/color.d.ts +2 -0
- package/dist/highlight/span/index.d.ts +1 -0
- package/dist/highlight/span/spansRenderer.d.ts +5 -0
- package/dist/highlight/viewport.d.ts +12 -0
- package/dist/index.d.ts +11 -0
- package/dist/model/core/TextAnnotation.d.ts +15 -0
- package/dist/model/core/index.d.ts +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/w3c/W3CTextAnnotation.d.ts +34 -0
- package/dist/model/w3c/W3CTextFormatAdapter.d.ts +12 -0
- package/dist/model/w3c/index.d.ts +2 -0
- package/dist/presence/PresencePainter.d.ts +5 -0
- package/dist/presence/PresencePainterOptions.d.ts +3 -0
- package/dist/presence/index.d.ts +2 -0
- package/dist/src/utils/isWhitespaceOrEmpty.d.ts +1 -2
- package/dist/state/TextAnnotationStore.d.ts +25 -0
- package/dist/state/TextAnnotatorState.d.ts +12 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/spatialTree.d.ts +28 -0
- package/dist/text-annotator.es.js +603 -579
- 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/cancelSingleClickEvents.d.ts +6 -0
- package/dist/utils/cloneEvents.d.ts +11 -0
- package/dist/utils/device.d.ts +1 -0
- package/dist/utils/getHighlightClientRects.d.ts +1 -0
- package/dist/utils/getQuoteContext.d.ts +4 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/isNotAnnotatable.d.ts +4 -0
- package/dist/utils/isRevived.d.ts +2 -0
- package/dist/utils/isWhitespaceOrEmpty.d.ts +3 -0
- package/dist/utils/mergeClientRects.d.ts +2 -0
- package/dist/utils/programmaticallyFocusable.d.ts +6 -0
- package/dist/utils/rangeToSelector.d.ts +2 -0
- package/dist/utils/rectsToBounds.d.ts +8 -0
- package/dist/utils/reviveAnnotation.d.ts +2 -0
- package/dist/utils/reviveSelector.d.ts +11 -0
- package/dist/utils/reviveTarget.d.ts +2 -0
- package/dist/utils/splitAnnotatableRanges.d.ts +5 -0
- package/dist/utils/trimRangeToContainer.d.ts +1 -0
- package/package.json +6 -6
|
@@ -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 isMac: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getHighlightClientRects: (range: Range) => DOMRect[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './cancelSingleClickEvents';
|
|
2
|
+
export * from './cloneEvents';
|
|
3
|
+
export * from './device';
|
|
4
|
+
export * from './programmaticallyFocusable';
|
|
5
|
+
export * from './getHighlightClientRects';
|
|
6
|
+
export * from './getQuoteContext';
|
|
7
|
+
export * from './isNotAnnotatable';
|
|
8
|
+
export * from './isRevived';
|
|
9
|
+
export * from './isWhitespaceOrEmpty';
|
|
10
|
+
export * from './mergeClientRects';
|
|
11
|
+
export * from './rangeToSelector';
|
|
12
|
+
export * from './rectsToBounds';
|
|
13
|
+
export * from './reviveAnnotation';
|
|
14
|
+
export * from './reviveSelector';
|
|
15
|
+
export * from './reviveTarget';
|
|
16
|
+
export * from './splitAnnotatableRanges';
|
|
17
|
+
export * from './trimRangeToContainer';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
|
|
2
|
+
export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
|
|
3
|
+
export declare const isNotAnnotatable: (container: Node, node: Node) => boolean;
|
|
4
|
+
export declare const isRangeAnnotatable: (container: Node, range: Range) => boolean;
|
|
@@ -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,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offsets the given rect relative to the offset parent.
|
|
3
|
+
*/
|
|
4
|
+
export declare const toParentBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
|
|
5
|
+
/**
|
|
6
|
+
* Inverse: translates the given relative rect back into viewport bounds.
|
|
7
|
+
*/
|
|
8
|
+
export declare const toViewportBounds: (rect: DOMRect, offset: DOMRect) => DOMRect;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { 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;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recogito/text-annotator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "A JavaScript text annotation library",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"start": "vite --host",
|
|
10
|
-
"build": "vite build && vite build --config vite.config.umd.ts",
|
|
10
|
+
"build": "tsc -p tsconfig.build.json && vite build && vite build --config vite.config.umd.ts",
|
|
11
11
|
"preview": "vite preview",
|
|
12
12
|
"test": "vitest"
|
|
13
13
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"types": "./dist/
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
23
|
"import": "./dist/text-annotator.es.js",
|
|
24
24
|
"require": "./dist/text-annotator.umd.js"
|
|
25
25
|
},
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"jsdom": "^27.0.0",
|
|
32
32
|
"typescript": "5.9.3",
|
|
33
33
|
"vite": "^6.3.6",
|
|
34
|
-
"vite-plugin-dts": "^4.5.4",
|
|
35
34
|
"vite-plugin-externalize-deps": "^0.9.0",
|
|
36
35
|
"vitest": "^3.2.4"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@annotorious/core": "^3.7.
|
|
38
|
+
"@annotorious/core": "^3.7.11",
|
|
40
39
|
"colord": "^2.9.3",
|
|
40
|
+
"debounce": "^2.2.0",
|
|
41
41
|
"dequal": "^2.0.3",
|
|
42
42
|
"hotkeys-js": "^3.13.15",
|
|
43
43
|
"poll": "^3.2.2",
|
|
44
44
|
"rbush": "^4.0.1",
|
|
45
|
-
"ua-parser-js": "^2.0.
|
|
45
|
+
"ua-parser-js": "^2.0.6",
|
|
46
46
|
"uuid": "^13.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|