@soomo/text-annotator 3.4.14-staging.0 → 4.1.0-staging.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.
Files changed (51) hide show
  1. package/dist/index.d.ts +8 -7
  2. package/dist/model/core/index.d.ts +1 -1
  3. package/dist/model/core/text-annotation.d.ts +27 -0
  4. package/dist/model/w3c/index.d.ts +2 -2
  5. package/dist/model/w3c/w3c-text-annotation.d.ts +36 -0
  6. package/dist/model/w3c/w3c-text-format-adapter.d.ts +12 -0
  7. package/dist/rendering/base-renderer.d.ts +31 -0
  8. package/dist/rendering/highlight-style.d.ts +14 -0
  9. package/dist/rendering/highlight.d.ts +6 -0
  10. package/dist/rendering/index.d.ts +5 -0
  11. package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +7 -0
  12. package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
  13. package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
  14. package/dist/rendering/renderer-spans/index.d.ts +1 -0
  15. package/dist/rendering/renderer-spans/spans-renderer.d.ts +4 -0
  16. package/dist/rendering/viewport.d.ts +12 -0
  17. package/dist/selection-handler.d.ts +12 -0
  18. package/dist/state/index.d.ts +2 -2
  19. package/dist/state/spatial-tree.d.ts +33 -0
  20. package/dist/state/text-annotation-store.d.ts +28 -0
  21. package/dist/state/text-annotator-state.d.ts +12 -0
  22. package/dist/text-annotator-options.d.ts +33 -0
  23. package/dist/text-annotator.css +1 -1
  24. package/dist/text-annotator.d.ts +17 -0
  25. package/dist/text-annotator.es.js +768 -826
  26. package/dist/text-annotator.es.js.map +1 -1
  27. package/dist/text-annotator.umd.js +2 -2
  28. package/dist/text-annotator.umd.js.map +1 -1
  29. package/dist/utils/annotation/get-quote-context.d.ts +4 -0
  30. package/dist/utils/annotation/index.d.ts +4 -0
  31. package/dist/utils/annotation/range-to-selector.d.ts +2 -0
  32. package/dist/utils/annotation/revive-annotation.d.ts +14 -0
  33. package/dist/utils/annotation/scroll-into-view.d.ts +3 -0
  34. package/dist/utils/dom/device.d.ts +1 -0
  35. package/dist/utils/dom/index.d.ts +7 -0
  36. package/dist/utils/dom/is-not-annotatable.d.ts +4 -0
  37. package/dist/utils/dom/is-whitespace-or-empty.d.ts +3 -0
  38. package/dist/utils/dom/merge-ranges.d.ts +1 -0
  39. package/dist/utils/dom/programmatically-focusable.d.ts +6 -0
  40. package/dist/utils/dom/split-annotatable-ranges.d.ts +5 -0
  41. package/dist/utils/dom/trim-range-to-container.d.ts +1 -0
  42. package/dist/utils/events/cancel-single-click-events.d.ts +6 -0
  43. package/dist/utils/events/clone-events.d.ts +11 -0
  44. package/dist/utils/events/debounce.d.ts +1 -0
  45. package/dist/utils/events/index.d.ts +3 -0
  46. package/dist/utils/highlight/compute-z-index.d.ts +3 -0
  47. package/dist/utils/highlight/get-highlight-client-rects.d.ts +1 -0
  48. package/dist/utils/highlight/index.d.ts +4 -0
  49. package/dist/utils/highlight/merge-client-rects.d.ts +2 -0
  50. package/dist/utils/highlight/rects-to-bounds.d.ts +8 -0
  51. package/package.json +8 -8
@@ -0,0 +1,4 @@
1
+ export declare const getQuoteContext: (range: Range, container: HTMLElement, length?: number, offsetReferenceSelector?: string) => {
2
+ prefix: string;
3
+ suffix: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export * from './get-quote-context';
2
+ export * from './range-to-selector';
3
+ export * from './revive-annotation';
4
+ export * from './scroll-into-view';
@@ -0,0 +1,2 @@
1
+ import type { TextSelector } from '../../model';
2
+ export declare const rangeToSelector: (range: Range, container: HTMLElement, offsetReferenceSelector?: string) => TextSelector;
@@ -0,0 +1,14 @@
1
+ import type { TextAnnotation, TextAnnotationTarget, TextSelector, TextSelectorLike } from '../../model';
2
+ export declare const isRevived: (selector: TextSelectorLike[]) => boolean;
3
+ /**
4
+ * Creates a new selector object with the revived DOM range from the given text annotation position
5
+ * Only the annotatable elements are processed and counted towards the range
6
+ *
7
+ * @param selector annotation selector with start and end positions
8
+ * @param container the HTML container of the annotated content
9
+ *
10
+ * @returns the revived selector
11
+ */
12
+ export declare const reviveSelector: <T extends TextSelector>(selector: T, container: HTMLElement) => T;
13
+ export declare const reviveTarget: <T extends TextAnnotationTarget = TextAnnotationTarget>(target: T, container: HTMLElement) => T;
14
+ export declare const reviveAnnotation: <T extends TextAnnotation>(annotation: T, container: HTMLElement) => T;
@@ -0,0 +1,3 @@
1
+ import type { TextAnnotationStore } from '../../state';
2
+ import type { TextAnnotation } from '../../model';
3
+ export declare const scrollIntoView: <I extends TextAnnotation = TextAnnotation>(container: HTMLElement, store: TextAnnotationStore<I>) => <E extends Element = Element>(annotationOrId: string | I, scrollParentOrId?: string | E) => boolean;
@@ -0,0 +1 @@
1
+ export declare const isMac: boolean;
@@ -0,0 +1,7 @@
1
+ export * from './device';
2
+ export * from './is-not-annotatable';
3
+ export * from './is-whitespace-or-empty';
4
+ export * from './merge-ranges';
5
+ export * from './programmatically-focusable';
6
+ export * from './split-annotatable-ranges';
7
+ export * from './trim-range-to-container';
@@ -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,3 @@
1
+ export declare const whitespaceOrEmptyRegex: RegExp;
2
+ export declare const isRangeWhitespaceOrEmpty: (range: Range) => boolean;
3
+ export declare const isNodeWhitespaceOrEmpty: (node: Node) => boolean;
@@ -0,0 +1 @@
1
+ export declare const mergeRanges: (ranges: Range[]) => Range[];
@@ -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,5 @@
1
+ /**
2
+ * Splits a DOM Range into one or more ranges that span annotatable content only.
3
+ */
4
+ export declare const splitAnnotatableRanges: (container: Node, range: Range) => Range[];
5
+ export declare const getRangeAnnotatableContents: (range: Range) => DocumentFragment;
@@ -0,0 +1 @@
1
+ export declare const trimRangeToContainer: (range: Range, container: HTMLElement) => Range;
@@ -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,3 @@
1
+ export * from './cancel-single-click-events';
2
+ export * from './clone-events';
3
+ export * from './debounce';
@@ -0,0 +1,3 @@
1
+ import type { Highlight } from '../../rendering';
2
+ import type { Rect } from '../../state';
3
+ export declare const computeZIndex: (rect: Rect, all: Highlight[]) => number;
@@ -0,0 +1 @@
1
+ export declare const getHighlightClientRects: (range: Range) => DOMRect[];
@@ -0,0 +1,4 @@
1
+ export * from './compute-z-index';
2
+ export * from './get-highlight-client-rects';
3
+ export * from './merge-client-rects';
4
+ export * from './rects-to-bounds';
@@ -0,0 +1,2 @@
1
+ export declare const mergeClientRects: (rects: DOMRect[], hTolerance?: number, vTolerance?: number) => DOMRect[];
2
+ export declare const toDomRectList: (rects: DOMRect[]) => DOMRectList;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soomo/text-annotator",
3
- "version": "3.4.14-staging.0",
3
+ "version": "4.1.0-staging.0",
4
4
  "description": "A JavaScript text annotation library",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -26,23 +26,23 @@
26
26
  "./text-annotator.css": "./dist/text-annotator.css"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/jsdom": "^27.0.0",
29
+ "@types/jsdom": "^28.0.3",
30
30
  "@types/rbush": "^4.0.0",
31
- "jsdom": "^27.2.0",
31
+ "jsdom": "^29.1.1",
32
32
  "typescript": "^5.9.3",
33
- "vite": "^7.2.2",
33
+ "vite": "^7.3.3",
34
34
  "vite-plugin-externalize-deps": "^0.10.0",
35
- "vitest": "^4.0.10"
35
+ "vitest": "^4.1.7"
36
36
  },
37
37
  "dependencies": {
38
- "@annotorious/core": "^3.7.13",
38
+ "@annotorious/core": "^3.8.2",
39
39
  "colord": "^2.9.3",
40
40
  "debounce": "^3.0.0",
41
41
  "dequal": "^2.0.3",
42
- "hotkeys-js": "^3.13.15",
42
+ "hotkeys-js": "^4.0.4",
43
43
  "poll": "^3.2.2",
44
44
  "nanoevents": "^9.1.0",
45
45
  "rbush": "^4.0.1",
46
- "uuid": "^13.0.0"
46
+ "uuid": "^14.0.0"
47
47
  }
48
48
  }