@insync-stageplayer/annotations 0.5.37 → 0.6.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 (60) hide show
  1. package/lib/components/AnnotationContent.d.ts +37 -37
  2. package/lib/components/AnnotationContent.d.ts.map +1 -1
  3. package/lib/components/AnnotationContent.js +59 -59
  4. package/lib/components/AnnotationEditForm.d.ts +26 -26
  5. package/lib/components/AnnotationEditForm.js +146 -146
  6. package/lib/components/AnnotationsModuleProvider.d.ts +36 -36
  7. package/lib/components/AnnotationsModuleProvider.js +20 -20
  8. package/lib/components/AnnotationsViewer.d.ts +15 -15
  9. package/lib/components/AnnotationsViewer.js +107 -107
  10. package/lib/components/DraggablePosition.d.ts +31 -31
  11. package/lib/components/DraggablePosition.js +62 -62
  12. package/lib/components/MeasurementDisplayDataContext.d.ts +10 -10
  13. package/lib/components/MeasurementDisplayDataContext.js +2 -2
  14. package/lib/components/MeasurementDisplayDataProvider.d.ts +15 -15
  15. package/lib/components/MeasurementDisplayDataProvider.d.ts.map +1 -1
  16. package/lib/components/MeasurementDisplayDataProvider.js +45 -45
  17. package/lib/components/MeasurementDisplayDataProvider.js.map +1 -1
  18. package/lib/components/MeasurementDisplayEditor.d.ts +19 -19
  19. package/lib/components/MeasurementDisplayEditor.js +136 -136
  20. package/lib/components/MeasurementDisplayElement.d.ts +18 -18
  21. package/lib/components/MeasurementDisplayElement.d.ts.map +1 -1
  22. package/lib/components/MeasurementDisplayElement.js +65 -97
  23. package/lib/components/MeasurementDisplayElement.js.map +1 -1
  24. package/lib/components/ModalAnnotationEditor.d.ts +12 -12
  25. package/lib/components/ModalAnnotationEditor.js +37 -37
  26. package/lib/formatNumber.d.ts +29 -29
  27. package/lib/formatNumber.js +12 -12
  28. package/lib/hooks/useMeasurementDisplayData.d.ts +14 -14
  29. package/lib/hooks/useMeasurementDisplayData.js +39 -39
  30. package/lib/index.d.ts +8 -7
  31. package/lib/index.d.ts.map +1 -1
  32. package/lib/index.js +8 -7
  33. package/lib/index.js.map +1 -1
  34. package/lib/redux/actions.d.ts +1 -1
  35. package/lib/redux/actions.js +1 -1
  36. package/lib/redux/annotationEditor.slice.d.ts +40 -37
  37. package/lib/redux/annotationEditor.slice.d.ts.map +1 -1
  38. package/lib/redux/annotationEditor.slice.js +123 -122
  39. package/lib/redux/annotationEditor.slice.js.map +1 -1
  40. package/lib/redux/annotations.slice.d.ts +34 -31
  41. package/lib/redux/annotations.slice.d.ts.map +1 -1
  42. package/lib/redux/annotations.slice.js +67 -65
  43. package/lib/redux/annotations.slice.js.map +1 -1
  44. package/lib/redux/measurementDisplayEditor.slice.d.ts +16 -25
  45. package/lib/redux/measurementDisplayEditor.slice.d.ts.map +1 -1
  46. package/lib/redux/measurementDisplayEditor.slice.js +37 -36
  47. package/lib/redux/measurementDisplayEditor.slice.js.map +1 -1
  48. package/lib/redux/measurementDisplays.slice.d.ts +28 -25
  49. package/lib/redux/measurementDisplays.slice.d.ts.map +1 -1
  50. package/lib/redux/measurementDisplays.slice.js +24 -22
  51. package/lib/redux/measurementDisplays.slice.js.map +1 -1
  52. package/lib/redux/reducer.d.ts +11 -51
  53. package/lib/redux/reducer.d.ts.map +1 -1
  54. package/lib/redux/reducer.js +65 -65
  55. package/lib/redux/reducer.js.map +1 -1
  56. package/lib/useBoundingRect.d.ts +8 -8
  57. package/lib/useBoundingRect.js +27 -27
  58. package/lib/util.d.ts +5 -5
  59. package/lib/util.js +7 -7
  60. package/package.json +7 -7
@@ -1,26 +1,29 @@
1
- /**
2
- * An annotation that can be placed on a 2D surface
3
- */
4
- export declare type MeasurementDisplay = {
5
- /**
6
- * Id of
7
- */
8
- id: string;
9
- showX: boolean;
10
- showY: boolean;
11
- showSignal: boolean;
12
- showSigColor: boolean;
13
- padXTo?: number;
14
- padXChar?: string;
15
- padYTo?: number;
16
- padYChar?: string;
17
- decimalsX?: number;
18
- decimalsY?: number;
19
- measurementId: string;
20
- };
21
- export declare const measurementDisplaysAdapter: import("@reduxjs/toolkit").EntityAdapter<MeasurementDisplay>;
22
- export declare const selectAllMeasurementDisplays: MeasurementDisplay[];
23
- export declare const createMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<MeasurementDisplay, string>, updateMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<MeasurementDisplay>, string>, deleteMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId, string>, deleteMeasurementDisplays: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId[], string>;
24
- declare const _default: import("redux").Reducer<import("@reduxjs/toolkit").EntityState<MeasurementDisplay>, import("redux").AnyAction>;
25
- export default _default;
1
+ import { Reducer } from "redux";
2
+ /**
3
+ * An annotation that can be placed on a 2D surface
4
+ */
5
+ export declare type MeasurementDisplay = {
6
+ /**
7
+ * Id of
8
+ */
9
+ id: string;
10
+ showX: boolean;
11
+ showY: boolean;
12
+ showSignal: boolean;
13
+ showSigColor: boolean;
14
+ padXTo?: number;
15
+ padXChar?: string;
16
+ padYTo?: number;
17
+ padYChar?: string;
18
+ decimalsX?: number;
19
+ decimalsY?: number;
20
+ measurementId: string;
21
+ };
22
+ export declare const measurementDisplaysAdapter: import("@reduxjs/toolkit").EntityAdapter<MeasurementDisplay, string>;
23
+ declare const initialState: import("@reduxjs/toolkit").EntityState<MeasurementDisplay, string>;
24
+ export declare const selectAllMeasurementDisplays: MeasurementDisplay[];
25
+ export declare const createMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<MeasurementDisplay, "measurementDisplays/createMeasurementDisplay">, updateMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<MeasurementDisplay, string>, "measurementDisplays/updateMeasurementDisplay">, deleteMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "measurementDisplays/deleteMeasurementDisplay">, deleteMeasurementDisplays: import("@reduxjs/toolkit").ActionCreatorWithPayload<readonly string[], "measurementDisplays/deleteMeasurementDisplays">;
26
+ export declare type MeasurementDisplaysState = typeof initialState;
27
+ declare const measurementDisplaysReducer: Reducer<MeasurementDisplaysState>;
28
+ export default measurementDisplaysReducer;
26
29
  //# sourceMappingURL=measurementDisplays.slice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measurementDisplays.slice.d.ts","sourceRoot":"","sources":["../../src/redux/measurementDisplays.slice.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,oBAAY,kBAAkB,GAAG;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,0BAA0B,8DACI,CAAC;AA0B5C,eAAO,MAAM,4BAA4B,sBACgB,CAAC;AAE1D,eAAO,MACL,wBAAwB,mFACxB,wBAAwB,sHACxB,wBAAwB,oGACxB,yBAAyB,oGACS,CAAC;;AAErC,wBAAgD"}
1
+ {"version":3,"file":"measurementDisplays.slice.d.ts","sourceRoot":"","sources":["../../src/redux/measurementDisplays.slice.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC;;GAEG;AACH,oBAAY,kBAAkB,GAAG;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,0BAA0B,sEACI,CAAC;AAC5C,QAAA,MAAM,YAAY,oEAA+C,CAAC;AA2BlE,eAAO,MAAM,4BAA4B,sBACgB,CAAC;AAE1D,eAAO,MACL,wBAAwB,2HACxB,wBAAwB,sKACxB,wBAAwB,+GACxB,yBAAyB,yHACS,CAAC;AAErC,oBAAY,wBAAwB,GAAG,OAAO,YAAY,CAAC;AAE3D,QAAA,MAAM,0BAA0B,EAAE,OAAO,CAAC,wBAAwB,CAChC,CAAC;AAEnC,eAAe,0BAA0B,CAAC"}
@@ -1,23 +1,25 @@
1
- import { createEntityAdapter, createSlice, configureStore, } from "@reduxjs/toolkit";
2
- export const measurementDisplaysAdapter = createEntityAdapter();
3
- const measurementDisplaysSlice = createSlice({
4
- name: "measurementDisplays",
5
- initialState: measurementDisplaysAdapter.getInitialState(),
6
- reducers: {
7
- createMeasurementDisplay: measurementDisplaysAdapter.addOne,
8
- updateMeasurementDisplay: measurementDisplaysAdapter.updateOne,
9
- deleteMeasurementDisplay: measurementDisplaysAdapter.removeOne,
10
- deleteMeasurementDisplays: measurementDisplaysAdapter.removeMany,
11
- },
12
- });
13
- const store = configureStore({
14
- reducer: {
15
- measurementDisplays: measurementDisplaysSlice.reducer,
16
- },
17
- });
18
- const measurementDisplaySelectors = measurementDisplaysAdapter.getSelectors((state) => state.measurementDisplays);
19
- // And then use the selectors to retrieve values
20
- export const selectAllMeasurementDisplays = measurementDisplaySelectors.selectAll(store.getState());
21
- export const { createMeasurementDisplay, updateMeasurementDisplay, deleteMeasurementDisplay, deleteMeasurementDisplays, } = measurementDisplaysSlice.actions;
22
- export default measurementDisplaysSlice.reducer;
1
+ import { createEntityAdapter, createSlice, configureStore, } from "@reduxjs/toolkit";
2
+ export const measurementDisplaysAdapter = createEntityAdapter();
3
+ const initialState = measurementDisplaysAdapter.getInitialState();
4
+ const measurementDisplaysSlice = createSlice({
5
+ name: "measurementDisplays",
6
+ initialState,
7
+ reducers: {
8
+ createMeasurementDisplay: measurementDisplaysAdapter.addOne,
9
+ updateMeasurementDisplay: measurementDisplaysAdapter.updateOne,
10
+ deleteMeasurementDisplay: measurementDisplaysAdapter.removeOne,
11
+ deleteMeasurementDisplays: measurementDisplaysAdapter.removeMany,
12
+ },
13
+ });
14
+ const store = configureStore({
15
+ reducer: {
16
+ measurementDisplays: measurementDisplaysSlice.reducer,
17
+ },
18
+ });
19
+ const measurementDisplaySelectors = measurementDisplaysAdapter.getSelectors((state) => state.measurementDisplays);
20
+ // And then use the selectors to retrieve values
21
+ export const selectAllMeasurementDisplays = measurementDisplaySelectors.selectAll(store.getState());
22
+ export const { createMeasurementDisplay, updateMeasurementDisplay, deleteMeasurementDisplay, deleteMeasurementDisplays, } = measurementDisplaysSlice.actions;
23
+ const measurementDisplaysReducer = measurementDisplaysSlice.reducer;
24
+ export default measurementDisplaysReducer;
23
25
  //# sourceMappingURL=measurementDisplays.slice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"measurementDisplays.slice.js","sourceRoot":"","sources":["../../src/redux/measurementDisplays.slice.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,cAAc,GACf,MAAM,kBAAkB,CAAC;AAuB1B,MAAM,CAAC,MAAM,0BAA0B,GACrC,mBAAmB,EAAsB,CAAC;AAC5C,MAAM,wBAAwB,GAAG,WAAW,CAAC;IAC3C,IAAI,EAAE,qBAAqB;IAC3B,YAAY,E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,EAAE,0BAA0B,CAAC,SAAS;QAC9D,yBAAyB,EAAE,0BAA0B,CAAC,UAAU;KACjE;CACF,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,cAAc,CAAC;IAC3B,OAAO,EAAE;QACP,mBAAmB,EAAE,wBAAwB,CAAC,OAAO;KACtD;CACF,CAAC,CAAC;AAIH,MAAM,2BAA2B,GAC/B,0BAA0B,CAAC,YAAY,CACrC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,CACrC,CAAC;AAEJ,gDAAgD;AAChD,MAAM,CAAC,MAAM,4BAA4B,GACvC,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,EACX,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,GAC1B,GAAG,wBAAwB,CAAC,OAAO,CAAC;AAIrC,MAAM,0BAA0B,GAC9B,wBAAwB,CAAC,OAAO,CAAC;AAEnC,eAAe,0BAA0B,CAAC"}
@@ -1,52 +1,12 @@
1
- import { Annotation } from "./annotations.slice";
2
- export declare type AnnotationsModuleState = ReturnType<typeof slicesReducer>;
3
- declare const slicesReducer: import("redux").Reducer<import("redux").CombinedState<{
4
- annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
5
- editingAnnotation: string | undefined;
6
- };
7
- measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
8
- annotationEditor: {
9
- annotation: Omit<Annotation, "id"> & {
10
- id: string | undefined;
11
- };
12
- displays: {
13
- added: string[];
14
- deleted: string[];
15
- };
16
- pickingMeasurement: boolean;
17
- chosenMeasurement: string | null;
18
- pickingMeasurementError: Error | null;
19
- editingMeasurementDisplay: string | null;
20
- };
21
- measurementDisplayEditor: {
22
- editingDisplay: string | undefined;
23
- deletedDisplays: string[];
24
- createdDisplays: string[];
25
- };
26
- }>, import("redux").AnyAction>;
27
- export declare const annotationsModuleReducer: import("reduce-reducers").Reducer<import("redux").CombinedState<{
28
- annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
29
- editingAnnotation: string | undefined;
30
- };
31
- measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
32
- annotationEditor: {
33
- annotation: Omit<Annotation, "id"> & {
34
- id: string | undefined;
35
- };
36
- displays: {
37
- added: string[];
38
- deleted: string[];
39
- };
40
- pickingMeasurement: boolean;
41
- chosenMeasurement: string | null;
42
- pickingMeasurementError: Error | null;
43
- editingMeasurementDisplay: string | null;
44
- };
45
- measurementDisplayEditor: {
46
- editingDisplay: string | undefined;
47
- deletedDisplays: string[];
48
- createdDisplays: string[];
49
- };
50
- }>>;
51
- export {};
1
+ import annotationEditorSlice from "./annotationEditor.slice";
2
+ import annotationsSlice from "./annotations.slice";
3
+ import measurementDisplayEditorSlice from "./measurementDisplayEditor.slice";
4
+ import measurementDisplaysSlice from "./measurementDisplays.slice";
5
+ export declare type AnnotationsModuleState = {
6
+ annotations: ReturnType<typeof annotationsSlice>;
7
+ measurementDisplays: ReturnType<typeof measurementDisplaysSlice>;
8
+ annotationEditor: ReturnType<typeof annotationEditorSlice>;
9
+ measurementDisplayEditor: ReturnType<typeof measurementDisplayEditorSlice>;
10
+ };
11
+ export declare const annotationsModuleReducer: import("reduce-reducers").Reducer<AnnotationsModuleState>;
52
12
  //# sourceMappingURL=reducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/redux/reducer.ts"],"names":[],"mappings":"AAKA,OAAyB,EACvB,UAAU,EAIX,MAAM,qBAAqB,CAAC;AAM7B,oBAAY,sBAAsB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAEtE,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;8BAKjB,CAAC;AAmEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;GAGpC,CAAC"}
1
+ {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/redux/reducer.ts"],"names":[],"mappings":"AAGA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,OAAO,gBAKN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,6BAA6B,MAAM,kCAAkC,CAAC;AAC7E,OAAO,wBAEN,MAAM,6BAA6B,CAAC;AAErC,oBAAY,sBAAsB,GAAG;IACnC,WAAW,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACjD,mBAAmB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;IACjE,gBAAgB,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAC3D,wBAAwB,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC;CAC5E,CAAC;AA0EF,eAAO,MAAM,wBAAwB,2DAGpC,CAAC"}
@@ -1,66 +1,66 @@
1
- import { combineReducers } from "redux";
2
- import { createReducer } from "@reduxjs/toolkit";
3
- import reduceReducers from "reduce-reducers";
4
- import annotationEditorSlice from "./annotationEditor.slice";
5
- import annotationsSlice, { editAnnotationCancel, editAnnotationDelete, editAnnotationSubmit, } from "./annotations.slice";
6
- import measurementDisplayEditorSlice from "./measurementDisplayEditor.slice";
7
- import measurementDisplaysSlice, { measurementDisplaysAdapter, } from "./measurementDisplays.slice";
8
- const slicesReducer = combineReducers({
9
- annotations: annotationsSlice,
10
- measurementDisplays: measurementDisplaysSlice,
11
- annotationEditor: annotationEditorSlice,
12
- measurementDisplayEditor: measurementDisplayEditorSlice,
13
- });
14
- /**
15
- * An annotation can contain measurementDisplay elements in its content. The content consists of SlateJS nodes which
16
- * is a nested structure. This function returns a list of all measurementDisplays contained in this annotation.
17
- * @param annotation
18
- * @returns The ids of the measurementDisplays contained in this Annotation.
19
- */
20
- const getMeasurementDisplaysForAnnotation = (annotation) => {
21
- // The recursive function that goes through the nodes.
22
- const go = (node) => {
23
- if (node.type === "measurementDisplay") {
24
- return [node.measurementDisplayId];
25
- }
26
- if (Array.isArray(node.children)) {
27
- return node.children.reduce((acc, c) => [...acc, ...go(c)], []);
28
- }
29
- return [];
30
- };
31
- // Transforming the Annotation to a SlateJS node.
32
- return go({ children: annotation.content });
33
- };
34
- /**
35
- * This reducer is in charge of cascading changes between entities.
36
- */
37
- const moduleReducer = createReducer({}, (builder) => {
38
- // When editing an annotation is canceled, any added measurement displays during editing should be deleted
39
- builder.addCase(editAnnotationCancel, (state) => {
40
- if (state.annotationEditor.displays.added.length > 0) {
41
- measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.added);
42
- }
43
- });
44
- //When submitting an annotation after editing, any deletions of measurement displays during editing should be persisted.
45
- builder.addCase(editAnnotationSubmit, (state) => {
46
- if (state.annotationEditor.displays.deleted.length > 0) {
47
- measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.deleted);
48
- }
49
- });
50
- // When an annotation is deleted, any measurement displays associated with it should also be deleted.
51
- builder.addCase(editAnnotationDelete, (state) => {
52
- if (!state.annotations.editingAnnotation)
53
- return;
54
- const annotation = state.annotations.entities[state.annotations.editingAnnotation];
55
- if (!annotation)
56
- return;
57
- const annotationDisplays = getMeasurementDisplaysForAnnotation(annotation);
58
- const allDisplays = [
59
- ...state.annotationEditor.displays.added,
60
- ...annotationDisplays,
61
- ];
62
- measurementDisplaysAdapter.removeMany(state.measurementDisplays, allDisplays);
63
- });
64
- });
65
- export const annotationsModuleReducer = reduceReducers(moduleReducer, slicesReducer);
1
+ import { combineReducers } from "redux";
2
+ import { createReducer } from "@reduxjs/toolkit";
3
+ import reduceReducers from "reduce-reducers";
4
+ import annotationEditorSlice from "./annotationEditor.slice";
5
+ import annotationsSlice, { editAnnotationCancel, editAnnotationDelete, editAnnotationSubmit, } from "./annotations.slice";
6
+ import measurementDisplayEditorSlice from "./measurementDisplayEditor.slice";
7
+ import measurementDisplaysSlice, { measurementDisplaysAdapter, } from "./measurementDisplays.slice";
8
+ const slicesReducer = combineReducers({
9
+ annotations: annotationsSlice,
10
+ measurementDisplays: measurementDisplaysSlice,
11
+ annotationEditor: annotationEditorSlice,
12
+ measurementDisplayEditor: measurementDisplayEditorSlice,
13
+ });
14
+ /**
15
+ * An annotation can contain measurementDisplay elements in its content. The content consists of SlateJS nodes which
16
+ * is a nested structure. This function returns a list of all measurementDisplays contained in this annotation.
17
+ * @param annotation
18
+ * @returns The ids of the measurementDisplays contained in this Annotation.
19
+ */
20
+ const getMeasurementDisplaysForAnnotation = (annotation) => {
21
+ // The recursive function that goes through the nodes.
22
+ const go = (node) => {
23
+ if (node.type === "measurementDisplay") {
24
+ return [node.measurementDisplayId];
25
+ }
26
+ if (Array.isArray(node.children)) {
27
+ return node.children.reduce((acc, c) => [...acc, ...go(c)], []);
28
+ }
29
+ return [];
30
+ };
31
+ // Transforming the Annotation to a SlateJS node.
32
+ return go({ children: annotation.content });
33
+ };
34
+ /**
35
+ * This reducer is in charge of cascading changes between entities.
36
+ */
37
+ const moduleReducer = createReducer({}, (builder) => {
38
+ // When editing an annotation is canceled, any added measurement displays during editing should be deleted
39
+ builder.addCase(editAnnotationCancel, (state) => {
40
+ if (state.annotationEditor.displays.added.length > 0) {
41
+ measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.added);
42
+ }
43
+ });
44
+ //When submitting an annotation after editing, any deletions of measurement displays during editing should be persisted.
45
+ builder.addCase(editAnnotationSubmit, (state) => {
46
+ if (state.annotationEditor.displays.deleted.length > 0) {
47
+ measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.deleted);
48
+ }
49
+ });
50
+ // When an annotation is deleted, any measurement displays associated with it should also be deleted.
51
+ builder.addCase(editAnnotationDelete, (state) => {
52
+ if (!state.annotations.editingAnnotation)
53
+ return;
54
+ const annotation = state.annotations.entities[state.annotations.editingAnnotation];
55
+ if (!annotation)
56
+ return;
57
+ const annotationDisplays = getMeasurementDisplaysForAnnotation(annotation);
58
+ const allDisplays = [
59
+ ...state.annotationEditor.displays.added,
60
+ ...annotationDisplays,
61
+ ];
62
+ measurementDisplaysAdapter.removeMany(state.measurementDisplays, allDisplays);
63
+ });
64
+ });
65
+ export const annotationsModuleReducer = reduceReducers(moduleReducer, slicesReducer);
66
66
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../src/redux/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,OAAO,gBAAgB,EAAE,EAEvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,6BAA6B,MAAM,kCAAkC,CAAC;AAC7E,OAAO,wBAAwB,EAAE,EAC/B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AAIrC,MAAM,aAAa,GAAG,eAAe,CAAC;IACpC,WAAW,EAAE,gBAAgB;IAC7B,mBAAmB,EAAE,wBAAwB;IAC7C,gBAAgB,EAAE,qBAAqB;IACvC,wBAAwB,EAAE,6BAA6B;CACxD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,mCAAmC,GAAG,CAC1C,UAAsB,EACZ,EAAE;IACZ,sDAAsD;IACtD,MAAM,EAAE,GAAG,CAAC,IAAU,EAAY,EAAE;QAClC,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,oBAA8B,CAAC,CAAC;SAC9C;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC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E,CAAC,KAAK,EAAE,EAAE;QAC9C,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB;YAAE,OAAO;QACjD,MAAM,UAAU,GACd,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAClE,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,MAAM,kBAAkB,GAAG,mCAAmC,CAAC,UAAU,CAAC,CAAC;QAC3E,MAAM,WAAW,GAAG;YAClB,GAAG,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK;YACxC,GAAG,kBAAkB;SACtB,CAAC;QACF,0BAA0B,CAAC,UAAU,CACnC,KAAK,CAAC,mBAAmB,EACzB,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CACpD,aAAa,EACb,aAAa,CACd,CAAC"}
@@ -1,9 +1,9 @@
1
- declare type MeasureCallback = (el: HTMLElement | null) => void;
2
- declare type UseMeasureHookValue = [MeasureCallback, DOMRect | undefined];
3
- /**
4
- * React hook that uses ResizeObserver to keep track of size of element.
5
- * @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
6
- */
7
- export declare const useBoundingRect: () => UseMeasureHookValue;
8
- export {};
1
+ declare type MeasureCallback = (el: HTMLElement | null) => void;
2
+ declare type UseMeasureHookValue = [MeasureCallback, DOMRect | undefined];
3
+ /**
4
+ * React hook that uses ResizeObserver to keep track of size of element.
5
+ * @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
6
+ */
7
+ export declare const useBoundingRect: () => UseMeasureHookValue;
8
+ export {};
9
9
  //# sourceMappingURL=useBoundingRect.d.ts.map
@@ -1,28 +1,28 @@
1
- import { useRef, useEffect, useCallback, useState } from "react";
2
- /**
3
- * React hook that uses ResizeObserver to keep track of size of element.
4
- * @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
5
- */
6
- export const useBoundingRect = () => {
7
- const resizeObserver = useRef();
8
- const [boundingRect, setBoundingRect] = useState();
9
- useEffect(() => () => {
10
- if (resizeObserver.current != undefined)
11
- resizeObserver.current.disconnect();
12
- resizeObserver.current = undefined;
13
- }, []);
14
- const ref = useCallback((node) => {
15
- if (!node || !node.getBoundingClientRect)
16
- return;
17
- if (resizeObserver.current) {
18
- resizeObserver.current.disconnect();
19
- resizeObserver.current = undefined;
20
- }
21
- resizeObserver.current = new ResizeObserver(() => {
22
- setBoundingRect(node.getBoundingClientRect());
23
- });
24
- resizeObserver.current.observe(node);
25
- }, []);
26
- return [ref, boundingRect];
27
- };
1
+ import { useRef, useEffect, useCallback, useState } from "react";
2
+ /**
3
+ * React hook that uses ResizeObserver to keep track of size of element.
4
+ * @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
5
+ */
6
+ export const useBoundingRect = () => {
7
+ const resizeObserver = useRef();
8
+ const [boundingRect, setBoundingRect] = useState();
9
+ useEffect(() => () => {
10
+ if (resizeObserver.current != undefined)
11
+ resizeObserver.current.disconnect();
12
+ resizeObserver.current = undefined;
13
+ }, []);
14
+ const ref = useCallback((node) => {
15
+ if (!node || !node.getBoundingClientRect)
16
+ return;
17
+ if (resizeObserver.current) {
18
+ resizeObserver.current.disconnect();
19
+ resizeObserver.current = undefined;
20
+ }
21
+ resizeObserver.current = new ResizeObserver(() => {
22
+ setBoundingRect(node.getBoundingClientRect());
23
+ });
24
+ resizeObserver.current.observe(node);
25
+ }, []);
26
+ return [ref, boundingRect];
27
+ };
28
28
  //# sourceMappingURL=useBoundingRect.js.map
package/lib/util.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- /**
2
- * Creates a unique id.
3
- * @returns
4
- */
5
- export declare const createId: () => string;
1
+ /**
2
+ * Creates a unique id.
3
+ * @returns
4
+ */
5
+ export declare const createId: () => string;
6
6
  //# sourceMappingURL=util.d.ts.map
package/lib/util.js CHANGED
@@ -1,8 +1,8 @@
1
- /**
2
- * Creates a unique id.
3
- * @returns
4
- */
5
- export const createId = () => {
6
- return "_" + Math.random().toString(36).substr(2, 9);
7
- };
1
+ /**
2
+ * Creates a unique id.
3
+ * @returns
4
+ */
5
+ export const createId = () => {
6
+ return "_" + Math.random().toString(36).substr(2, 9);
7
+ };
8
8
  //# sourceMappingURL=util.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insync-stageplayer/annotations",
3
- "version": "0.5.37",
3
+ "version": "0.6.0",
4
4
  "description": "Annotations module for stageplayer",
5
5
  "author": "David Ammeraal <david.ammeraal@gmail.com>",
6
6
  "homepage": "https://github.com/Noterik/insync-stageplayer#readme",
@@ -32,10 +32,10 @@
32
32
  "url": "https://github.com/Noterik/insync-stageplayer/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@insync-stageplayer/measurements": "^0.5.37",
36
- "@insync-stageplayer/time": "^0.5.9",
37
- "@insync-stageplayer/ui-components": "^0.5.37",
38
- "@reduxjs/toolkit": "^1.5.0",
35
+ "@insync-stageplayer/measurements": "^0.6.0",
36
+ "@insync-stageplayer/time": "^0.6.0",
37
+ "@insync-stageplayer/ui-components": "^0.6.0",
38
+ "@reduxjs/toolkit": "^2.11.2",
39
39
  "@types/deep-diff": "^1.0.0",
40
40
  "classnames": "^2.3.1",
41
41
  "deep-diff": "^1.0.2",
@@ -47,10 +47,10 @@
47
47
  "reselect": "^4.0.0",
48
48
  "slate": "^0.59.0",
49
49
  "slate-react": "^0.59.0",
50
- "styled-components": "^5.1.1"
50
+ "styled-components": "^5.3.11"
51
51
  },
52
52
  "devDependencies": {
53
53
  "rxjs": "^6.6.6"
54
54
  },
55
- "gitHead": "8e2b1c35a61bfd8eb4796988d429f22019e8be43"
55
+ "gitHead": "7c3d8a81cc2ba118bf8572c3e1b8a1fe7f7409be"
56
56
  }