box-annotations 5.3.0 → 5.3.1-beta.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 (94) hide show
  1. package/dist/annotations.css +1 -1
  2. package/dist/annotations.js +1 -1
  3. package/dist/annotations.js.LICENSE.txt +0 -9
  4. package/i18n/bn-IN.js +6 -0
  5. package/i18n/bn-IN.properties +12 -0
  6. package/i18n/da-DK.js +6 -0
  7. package/i18n/da-DK.properties +12 -0
  8. package/i18n/de-DE.js +6 -0
  9. package/i18n/de-DE.properties +12 -0
  10. package/i18n/en-AU.js +6 -0
  11. package/i18n/en-AU.properties +12 -0
  12. package/i18n/en-CA.js +6 -0
  13. package/i18n/en-CA.properties +12 -0
  14. package/i18n/en-GB.js +6 -0
  15. package/i18n/en-GB.properties +12 -0
  16. package/i18n/es-419.js +6 -0
  17. package/i18n/es-419.properties +12 -0
  18. package/i18n/es-ES.js +6 -0
  19. package/i18n/es-ES.properties +12 -0
  20. package/i18n/fi-FI.js +6 -0
  21. package/i18n/fi-FI.properties +12 -0
  22. package/i18n/fr-CA.js +6 -0
  23. package/i18n/fr-CA.properties +12 -0
  24. package/i18n/fr-FR.js +6 -0
  25. package/i18n/fr-FR.properties +12 -0
  26. package/i18n/hi-IN.js +6 -0
  27. package/i18n/hi-IN.properties +12 -0
  28. package/i18n/it-IT.js +6 -0
  29. package/i18n/it-IT.properties +12 -0
  30. package/i18n/ja-JP.js +7 -1
  31. package/i18n/ja-JP.properties +13 -1
  32. package/i18n/ko-KR.js +6 -0
  33. package/i18n/ko-KR.properties +12 -0
  34. package/i18n/nb-NO.js +6 -0
  35. package/i18n/nb-NO.properties +12 -0
  36. package/i18n/nl-NL.js +6 -0
  37. package/i18n/nl-NL.properties +12 -0
  38. package/i18n/pl-PL.js +6 -0
  39. package/i18n/pl-PL.properties +12 -0
  40. package/i18n/pt-BR.js +6 -0
  41. package/i18n/pt-BR.properties +12 -0
  42. package/i18n/ru-RU.js +6 -0
  43. package/i18n/ru-RU.properties +12 -0
  44. package/i18n/sv-SE.js +6 -0
  45. package/i18n/sv-SE.properties +12 -0
  46. package/i18n/tr-TR.js +6 -0
  47. package/i18n/tr-TR.properties +12 -0
  48. package/i18n/zh-CN.js +6 -0
  49. package/i18n/zh-CN.properties +12 -0
  50. package/i18n/zh-TW.js +6 -0
  51. package/i18n/zh-TW.properties +12 -0
  52. package/package.json +23 -22
  53. package/src/BoxAnnotations.ts +1 -1
  54. package/src/adapters/threadedAnnotationsAdapters.ts +10 -2
  55. package/src/boundingBoxHighlight/BoundingBoxHighlightContainer.tsx +4 -1
  56. package/src/common/BaseAnnotator.scss +1 -1
  57. package/src/common/DeselectListener.tsx +1 -1
  58. package/src/components/BoundingBoxHighlight/BoundingBoxHighlightNav.scss +3 -3
  59. package/src/components/BoundingBoxHighlight/BoundingBoxHighlightRect.scss +11 -6
  60. package/src/components/Popups/PopupBase.scss +2 -2
  61. package/src/components/Popups/PopupDrawingToolbar.scss +4 -4
  62. package/src/components/Popups/PopupList.scss +1 -1
  63. package/src/components/Popups/PopupV2.scss +2 -2
  64. package/src/components/Popups/PopupV2.tsx +30 -43
  65. package/src/components/ReplyForm/ReplyForm.tsx +1 -8
  66. package/src/constants.ts +2 -3
  67. package/src/document/DocumentAnnotator.ts +28 -5
  68. package/src/document/docUtil.ts +7 -1
  69. package/src/drawing/DrawingAnnotations.tsx +24 -24
  70. package/src/drawing/DrawingCursor.ts +2 -1
  71. package/src/drawing/DrawingManager.tsx +9 -1
  72. package/src/highlight/HighlightAnnotations.tsx +23 -22
  73. package/src/highlight/HighlightCreator.scss +9 -2
  74. package/src/media/MediaAnnotator.ts +38 -16
  75. package/src/popup/PopupLayer.tsx +1 -5
  76. package/src/region/RegionAnnotations.tsx +2 -3
  77. package/src/region/RegionCreation.tsx +4 -1
  78. package/src/region/RegionCreationManager.tsx +8 -1
  79. package/src/region/RegionCreator.scss +9 -3
  80. package/src/region/RegionManager.tsx +8 -1
  81. package/src/region/RegionRect.scss +17 -9
  82. package/src/store/annotations/actions.ts +86 -104
  83. package/src/store/annotations/reducer.ts +4 -4
  84. package/src/store/creator/selectors.ts +6 -6
  85. package/src/store/eventing/create.ts +4 -2
  86. package/src/store/eventing/delete.ts +4 -5
  87. package/src/store/eventing/middleware.ts +13 -11
  88. package/src/store/eventing/replyCreate.ts +6 -10
  89. package/src/store/eventing/replyDelete.ts +5 -9
  90. package/src/store/eventing/replyUpdate.ts +6 -10
  91. package/src/store/eventing/update.ts +5 -6
  92. package/src/store/highlight/actions.ts +43 -41
  93. package/src/test-utils/videoAnnotations.tsx +11 -11
  94. package/src/utils/useVideoTiming.ts +9 -13
@@ -18,8 +18,8 @@ export interface VideoAnnotationTestConfig {
18
18
  componentName: string;
19
19
  getWrapper: (props: unknown) => ReactWrapper;
20
20
  findListComponent: (wrapper: ReactWrapper) => ListComponentWrapper;
21
- videoAnnotations: AnnotationDrawing[]|AnnotationRegion[] ;
22
- regularAnnotations: AnnotationDrawing[]|AnnotationRegion[];
21
+ videoAnnotations: AnnotationDrawing[] | AnnotationRegion[];
22
+ regularAnnotations: AnnotationDrawing[] | AnnotationRegion[];
23
23
  activeAnnotationId: string;
24
24
  nonExistentAnnotationId: string;
25
25
  }
@@ -43,7 +43,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
43
43
  describe('TARGET_TYPE.FRAME target type', () => {
44
44
  test('should show only active annotation when not seeking and active annotation exists', () => {
45
45
  mockVideoTimingReturn.isVideoSeeking = false;
46
-
46
+
47
47
  const wrapper = getWrapper({
48
48
  targetType: TARGET_TYPE.FRAME,
49
49
  annotations: videoAnnotations,
@@ -58,7 +58,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
58
58
 
59
59
  test('should show no annotations when seeking and active annotation exists', () => {
60
60
  mockVideoTimingReturn.isVideoSeeking = true;
61
-
61
+
62
62
  const wrapper = getWrapper({
63
63
  targetType: TARGET_TYPE.FRAME,
64
64
  annotations: videoAnnotations,
@@ -71,7 +71,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
71
71
 
72
72
  test('should show no annotations when not seeking but no active annotation', () => {
73
73
  mockVideoTimingReturn.isVideoSeeking = false;
74
-
74
+
75
75
  const wrapper = getWrapper({
76
76
  targetType: TARGET_TYPE.FRAME,
77
77
  annotations: videoAnnotations,
@@ -84,7 +84,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
84
84
 
85
85
  test('should show no annotations when seeking and no active annotation', () => {
86
86
  mockVideoTimingReturn.isVideoSeeking = true;
87
-
87
+
88
88
  const wrapper = getWrapper({
89
89
  targetType: TARGET_TYPE.FRAME,
90
90
  annotations: videoAnnotations,
@@ -97,7 +97,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
97
97
 
98
98
  test('should call useVideoTiming with correct parameters for TARGET_TYPE.FRAME type', () => {
99
99
  const referenceEl = document.createElement('video');
100
-
100
+
101
101
  getWrapper({
102
102
  targetType: TARGET_TYPE.FRAME,
103
103
  annotations: videoAnnotations,
@@ -117,7 +117,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
117
117
  describe('useVideoTiming integration', () => {
118
118
  test('should call useVideoTiming hook on component mount', () => {
119
119
  const referenceEl = document.createElement('video');
120
-
120
+
121
121
  getWrapper({
122
122
  targetType: TARGET_TYPE.FRAME,
123
123
  annotations: videoAnnotations,
@@ -130,7 +130,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
130
130
 
131
131
  test('should pass correct parameters to useVideoTiming for TARGET_TYPE.PAGE type', () => {
132
132
  const referenceEl = document.createElement('div');
133
-
133
+
134
134
  getWrapper({
135
135
  targetType: TARGET_TYPE.PAGE,
136
136
  annotations: regularAnnotations,
@@ -150,7 +150,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
150
150
  describe('annotation filtering edge cases', () => {
151
151
  test('should handle empty annotations array for TARGET_TYPE.FRAME type', () => {
152
152
  mockVideoTimingReturn.isVideoSeeking = false;
153
-
153
+
154
154
  const wrapper = getWrapper({
155
155
  targetType: TARGET_TYPE.FRAME,
156
156
  annotations: [],
@@ -163,7 +163,7 @@ export const createVideoAnnotationTests = (config: VideoAnnotationTestConfig): v
163
163
 
164
164
  test('should handle active annotation that does not exist in annotations array', () => {
165
165
  mockVideoTimingReturn.isVideoSeeking = false;
166
-
166
+
167
167
  const wrapper = getWrapper({
168
168
  targetType: TARGET_TYPE.FRAME,
169
169
  annotations: videoAnnotations,
@@ -1,7 +1,5 @@
1
- import { useState, useEffect, useCallback } from "react";
2
- import { TARGET_TYPE } from "../constants";
3
-
4
-
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { TARGET_TYPE } from '../constants';
5
3
 
6
4
  export interface UseVideoTimingProps {
7
5
  targetType: TARGET_TYPE;
@@ -22,7 +20,7 @@ export function getVideoCurrentTimeInMilliseconds(video: HTMLVideoElement): numb
22
20
  /**
23
21
  * This hook is used to keep track of when the video is currently seeking and when it has reached
24
22
  * the target time definined in the annotation. This is necessary because we cannot control how long it
25
- * takes for the video to seek to the target time and we do not want to display an annotation on the video player
23
+ * takes for the video to seek to the target time and we do not want to display an annotation on the video player
26
24
  * at the wrong time. For example, if an annotation is defined at being at 20 seconds into the video and
27
25
  * the video just loaded and needs to buffer in order to get to 20 seconds, we do not want the annotation
28
26
  * drawing or region to be shown until the video has finished seeking and is at the correct time. The hook
@@ -38,9 +36,8 @@ const useVideoTiming = ({
38
36
  const [isVideoSeeking, setIsVideoSeeking] = useState<boolean>(false);
39
37
  const [targetVideoTime, setTargetVideoTime] = useState<number | null>(null);
40
38
 
41
-
42
- const getCurrentVideoTimeStamp = useCallback((): number => {
43
- return getVideoCurrentTimeInMilliseconds(referenceEl as HTMLVideoElement);
39
+ const getCurrentVideoTimeStamp = useCallback((): number => {
40
+ return getVideoCurrentTimeInMilliseconds(referenceEl as HTMLVideoElement);
44
41
  }, [referenceEl]);
45
42
 
46
43
  // Handle video seeking events
@@ -48,7 +45,7 @@ const useVideoTiming = ({
48
45
  if (targetType !== TARGET_TYPE.FRAME || !referenceEl) {
49
46
  return undefined;
50
47
  }
51
-
48
+
52
49
  const handleSeeking = (): void => {
53
50
  setIsVideoSeeking(true);
54
51
  };
@@ -62,7 +59,7 @@ const useVideoTiming = ({
62
59
  if (isVideoSeeking && targetVideoTime !== null) {
63
60
  const currentVideoTimePosition = getCurrentVideoTimeStamp();
64
61
  const timeDiff = Math.abs(currentVideoTimePosition - targetVideoTime);
65
-
62
+
66
63
  // Consider the video has reached the target time if within 100ms
67
64
  if (timeDiff <= 100) {
68
65
  setIsVideoSeeking(false);
@@ -86,13 +83,13 @@ const useVideoTiming = ({
86
83
  useEffect(() => {
87
84
  if (targetType === TARGET_TYPE.FRAME && activeAnnotationId && referenceEl) {
88
85
  const currentVideoTimePosition = getCurrentVideoTimeStamp();
89
-
86
+
90
87
  // Find the annotation to get its target time
91
88
  const annotation = annotations.find(ann => ann.id === activeAnnotationId);
92
89
  if (annotation) {
93
90
  const annotationTimePosition = annotation.target.location.value;
94
91
  const timeDiff = Math.abs(currentVideoTimePosition - annotationTimePosition);
95
-
92
+
96
93
  // If the video is not at the annotation's time, set seeking state
97
94
  if (timeDiff > 100) {
98
95
  setTargetVideoTime(annotationTimePosition);
@@ -109,4 +106,3 @@ const useVideoTiming = ({
109
106
  };
110
107
 
111
108
  export default useVideoTiming;
112
-