nmrium 1.7.0 → 1.8.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 (210) hide show
  1. package/lib/component/1d/ranges/Atoms.d.ts.map +1 -1
  2. package/lib/component/1d/ranges/Atoms.js +24 -9
  3. package/lib/component/1d/ranges/Atoms.js.map +1 -1
  4. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts +2 -1
  5. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
  6. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +32 -42
  7. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
  8. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.d.ts.map +1 -1
  9. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.js.map +1 -1
  10. package/lib/component/2d/zones/SignalsGuideLines.js +1 -1
  11. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  12. package/lib/component/hooks/useExport.js +1 -1
  13. package/lib/component/hooks/useExport.js.map +1 -1
  14. package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
  15. package/lib/component/loader/useLoadFiles.js +17 -7
  16. package/lib/component/loader/useLoadFiles.js.map +1 -1
  17. package/lib/component/main/NMRiumStateProvider.d.ts.map +1 -1
  18. package/lib/component/main/NMRiumStateProvider.js +2 -3
  19. package/lib/component/main/NMRiumStateProvider.js.map +1 -1
  20. package/lib/component/modal/LoadJCAMPModal.js +7 -2
  21. package/lib/component/modal/LoadJCAMPModal.js.map +1 -1
  22. package/lib/component/modal/MoleculeStructureEditorModal.d.ts.map +1 -1
  23. package/lib/component/modal/MoleculeStructureEditorModal.js +7 -3
  24. package/lib/component/modal/MoleculeStructureEditorModal.js.map +1 -1
  25. package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
  26. package/lib/component/modal/SaveAsModal.js +6 -2
  27. package/lib/component/modal/SaveAsModal.js.map +1 -1
  28. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.d.ts.map +1 -1
  29. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +16 -0
  30. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js.map +1 -1
  31. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts +6 -0
  32. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts.map +1 -0
  33. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js +87 -0
  34. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js.map +1 -0
  35. package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
  36. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +18 -26
  37. package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
  38. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  39. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +32 -25
  40. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  41. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts +13 -0
  42. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts.map +1 -0
  43. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js +66 -0
  44. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js.map +1 -0
  45. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.d.ts → hooks/useAtomAssignment.d.ts} +1 -1
  46. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.d.ts.map +1 -0
  47. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.js → hooks/useAtomAssignment.js} +32 -16
  48. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -0
  49. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts +12 -0
  50. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts.map +1 -0
  51. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js +58 -0
  52. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js.map +1 -0
  53. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts +5 -0
  54. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts.map +1 -0
  55. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js +2 -0
  56. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js.map +1 -0
  57. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts +16 -0
  58. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts.map +1 -0
  59. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js +47 -0
  60. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js.map +1 -0
  61. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts +18 -0
  62. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts.map +1 -0
  63. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js +31 -0
  64. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js.map +1 -0
  65. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts +3 -0
  66. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts.map +1 -0
  67. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js +12 -0
  68. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js.map +1 -0
  69. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts +4 -0
  70. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts.map +1 -0
  71. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js +25 -0
  72. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js.map +1 -0
  73. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts +6 -0
  74. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts.map +1 -0
  75. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js +18 -0
  76. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js.map +1 -0
  77. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts +9 -0
  78. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts.map +1 -0
  79. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js +27 -0
  80. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js.map +1 -0
  81. package/lib/component/reducer/IgnoreActions.d.ts.map +1 -1
  82. package/lib/component/reducer/IgnoreActions.js +2 -1
  83. package/lib/component/reducer/IgnoreActions.js.map +1 -1
  84. package/lib/component/reducer/Reducer.d.ts +11 -5
  85. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  86. package/lib/component/reducer/Reducer.js +8 -3
  87. package/lib/component/reducer/Reducer.js.map +1 -1
  88. package/lib/component/reducer/actions/LoadAction.d.ts +7 -4
  89. package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
  90. package/lib/component/reducer/actions/LoadAction.js +35 -26
  91. package/lib/component/reducer/actions/LoadAction.js.map +1 -1
  92. package/lib/component/reducer/actions/MoleculeActions.d.ts +20 -5
  93. package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
  94. package/lib/component/reducer/actions/MoleculeActions.js +42 -28
  95. package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
  96. package/lib/component/reducer/actions/RangesActions.d.ts +10 -4
  97. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  98. package/lib/component/reducer/actions/RangesActions.js +24 -3
  99. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  100. package/lib/component/reducer/actions/ZonesActions.d.ts +1 -1
  101. package/lib/component/reducer/actions/ZonesActions.d.ts.map +1 -1
  102. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts +4 -0
  103. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts.map +1 -0
  104. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js +7 -0
  105. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js.map +1 -0
  106. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  107. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  108. package/lib/component/reducer/preferences/preferencesReducer.js +3 -0
  109. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  110. package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
  111. package/lib/component/toolbar/ToolTypes.js +1 -0
  112. package/lib/component/toolbar/ToolTypes.js.map +1 -1
  113. package/lib/component/workspaces/assignment.d.ts.map +1 -1
  114. package/lib/component/workspaces/assignment.js +7 -0
  115. package/lib/component/workspaces/assignment.js.map +1 -1
  116. package/lib/component/workspaces/basic.d.ts.map +1 -1
  117. package/lib/component/workspaces/basic.js +5 -0
  118. package/lib/component/workspaces/basic.js.map +1 -1
  119. package/lib/component/workspaces/embedded.d.ts.map +1 -1
  120. package/lib/component/workspaces/embedded.js +5 -0
  121. package/lib/component/workspaces/embedded.js.map +1 -1
  122. package/lib/component/workspaces/exercise.d.ts.map +1 -1
  123. package/lib/component/workspaces/exercise.js +5 -0
  124. package/lib/component/workspaces/exercise.js.map +1 -1
  125. package/lib/component/workspaces/prediction.d.ts.map +1 -1
  126. package/lib/component/workspaces/prediction.js +5 -0
  127. package/lib/component/workspaces/prediction.js.map +1 -1
  128. package/lib/component/workspaces/process1D.d.ts.map +1 -1
  129. package/lib/component/workspaces/process1D.js +6 -0
  130. package/lib/component/workspaces/process1D.js.map +1 -1
  131. package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
  132. package/lib/component/workspaces/workspaceDefaultProperties.js +18 -0
  133. package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
  134. package/lib/data/SpectraManager.d.ts +1 -1
  135. package/lib/data/SpectraManager.d.ts.map +1 -1
  136. package/lib/data/SpectraManager.js.map +1 -1
  137. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +0 -1
  138. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
  139. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +17 -16
  140. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
  141. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +0 -1
  142. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  143. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +7 -6
  144. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  145. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
  146. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
  147. package/lib/data/molecules/Molecule.d.ts +1 -17
  148. package/lib/data/molecules/Molecule.d.ts.map +1 -1
  149. package/lib/data/molecules/Molecule.js +3 -7
  150. package/lib/data/molecules/Molecule.js.map +1 -1
  151. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  152. package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
  153. package/lib/data/molecules/MoleculeManager.js +1 -4
  154. package/lib/data/molecules/MoleculeManager.js.map +1 -1
  155. package/lib/versionInfo.js +1 -1
  156. package/package.json +27 -27
  157. package/src/component/1d/ranges/Atoms.tsx +36 -13
  158. package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +38 -79
  159. package/src/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.tsx +5 -2
  160. package/src/component/2d/zones/SignalsGuideLines.tsx +1 -1
  161. package/src/component/hooks/useExport.tsx +1 -1
  162. package/src/component/loader/useLoadFiles.ts +19 -7
  163. package/src/component/main/NMRiumStateProvider.tsx +2 -3
  164. package/src/component/modal/LoadJCAMPModal.tsx +10 -4
  165. package/src/component/modal/MoleculeStructureEditorModal.tsx +10 -3
  166. package/src/component/modal/SaveAsModal.tsx +8 -2
  167. package/src/component/modal/setting/settings-tabs/ToolsTabContent.tsx +16 -0
  168. package/src/component/panels/MoleculesPanel/MoleculeOptionsPanel.tsx +160 -0
  169. package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +77 -101
  170. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +54 -35
  171. package/src/component/panels/MoleculesPanel/MoleculeStructure.tsx +117 -0
  172. package/src/component/panels/MoleculesPanel/{useAtomAssignment.tsx → hooks/useAtomAssignment.tsx} +47 -25
  173. package/src/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.ts +74 -0
  174. package/src/component/panels/MoleculesPanel/utilities/AtomData.ts +4 -0
  175. package/src/component/panels/MoleculesPanel/utilities/extractFromAtom.ts +63 -0
  176. package/src/component/panels/MoleculesPanel/utilities/getAssignIds.ts +59 -0
  177. package/src/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.ts +12 -0
  178. package/src/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.ts +36 -0
  179. package/src/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.ts +20 -0
  180. package/src/component/panels/hooks/useMoleculeAnnotationCore.ts +36 -0
  181. package/src/component/reducer/IgnoreActions.ts +2 -1
  182. package/src/component/reducer/Reducer.ts +21 -8
  183. package/src/component/reducer/actions/LoadAction.ts +51 -38
  184. package/src/component/reducer/actions/MoleculeActions.ts +85 -37
  185. package/src/component/reducer/actions/RangesActions.ts +50 -5
  186. package/src/component/reducer/actions/ZonesActions.ts +1 -1
  187. package/src/component/reducer/preferences/actions/changeDefaultMoleculeSettings.ts +16 -0
  188. package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
  189. package/src/component/toolbar/ToolTypes.ts +1 -0
  190. package/src/component/workspaces/assignment.ts +7 -0
  191. package/src/component/workspaces/basic.ts +5 -0
  192. package/src/component/workspaces/embedded.ts +5 -0
  193. package/src/component/workspaces/exercise.ts +5 -0
  194. package/src/component/workspaces/prediction.ts +5 -0
  195. package/src/component/workspaces/process1D.ts +6 -0
  196. package/src/component/workspaces/workspaceDefaultProperties.ts +18 -0
  197. package/src/data/SpectraManager.ts +1 -7
  198. package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +17 -19
  199. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +7 -10
  200. package/src/data/molecules/Molecule.ts +5 -25
  201. package/src/data/molecules/MoleculeManager.ts +0 -4
  202. package/src/index.tsx +0 -3
  203. package/src/versionInfo.ts +1 -1
  204. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +0 -43
  205. package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +0 -1
  206. package/lib/component/panels/MoleculesPanel/Utilities.js +0 -129
  207. package/lib/component/panels/MoleculesPanel/Utilities.js.map +0 -1
  208. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +0 -1
  209. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +0 -1
  210. package/src/component/panels/MoleculesPanel/Utilities.ts +0 -188
@@ -1,33 +1,26 @@
1
1
  import styled from '@emotion/styled';
2
+ import type { MoleculeView } from '@zakodium/nmrium-core';
2
3
  import { useEffect, useState } from 'react';
3
4
  import { ResponsiveChart } from 'react-d3-utils';
4
5
  import { BsArrowsMove } from 'react-icons/bs';
5
- import { FaTimes } from 'react-icons/fa';
6
- import type { MolfileSvgRendererProps } from 'react-ocl';
7
- import { MolfileSvgRenderer } from 'react-ocl';
8
- import OCLnmr from 'react-ocl-nmr';
6
+ import { FaRegBookmark, FaTimes } from 'react-icons/fa';
7
+ import { MdFormatColorText, MdNumbers } from 'react-icons/md';
9
8
  import { Rnd } from 'react-rnd';
10
9
 
11
10
  import type {
12
11
  MoleculeBoundingRect,
13
- MoleculeView,
14
12
  StateMoleculeExtended,
15
13
  } from '../../../../data/molecules/Molecule.js';
16
14
  import { useDispatch } from '../../../context/DispatchContext.js';
17
15
  import { useGlobal } from '../../../context/GlobalContext.js';
18
16
  import type { ActionsButtonsPopoverProps } from '../../../elements/ActionsButtonsPopover.js';
19
17
  import { ActionsButtonsPopover } from '../../../elements/ActionsButtonsPopover.js';
20
- import { useHighlightColor } from '../../../hooks/useHighlightColor.js';
21
18
  import { useSVGUnitConverter } from '../../../hooks/useSVGUnitConverter.js';
22
19
  import { useCheckExportStatus } from '../../../hooks/useViewportSize.js';
23
20
  import { useMoleculeEditor } from '../../../modal/MoleculeStructureEditorModal.js';
24
- import useAtomAssignment from '../../../panels/MoleculesPanel/useAtomAssignment.js';
25
-
26
- interface DraggableMoleculeProps extends DraggableStructureProps {
27
- width: number;
28
- height: number;
29
- renderAsSVG?: boolean;
30
- }
21
+ import { MoleculeStructure } from '../../../panels/MoleculesPanel/MoleculeStructure.tsx';
22
+ import { useMoleculeAnnotationCore } from '../../../panels/hooks/useMoleculeAnnotationCore.ts';
23
+ import { booleanToString } from '../../../utility/booleanToString.ts';
31
24
 
32
25
  interface DraggableStructureProps {
33
26
  moleculeView: MoleculeView;
@@ -103,6 +96,12 @@ export function DraggableStructure(props: DraggableStructureProps) {
103
96
  return { x: pixelToPercent(x, 'x'), y: pixelToPercent(y, 'y') };
104
97
  }
105
98
 
99
+ const {
100
+ handleChangeAtomAnnotation,
101
+ isAnnotation,
102
+ handleToggleMoleculeLabel,
103
+ } = useMoleculeAnnotationCore(molecule.id, moleculeView);
104
+
106
105
  if (!viewerRef) return null;
107
106
 
108
107
  const actionsButtons: ActionsButtonsPopoverProps['buttons'] = [
@@ -119,8 +118,31 @@ export function DraggableStructure(props: DraggableStructureProps) {
119
118
  title: 'Hide molecule',
120
119
  onClick: floatMoleculeHandler,
121
120
  },
121
+ {
122
+ elementType: 'separator',
123
+ },
124
+ {
125
+ icon: <MdFormatColorText />,
126
+ title: `${booleanToString(!moleculeView.showLabel)} molecule label`,
127
+ onClick: handleToggleMoleculeLabel,
128
+ active: moleculeView.showLabel,
129
+ },
130
+ {
131
+ elementType: 'separator',
132
+ },
133
+ {
134
+ icon: <MdNumbers />,
135
+ title: `${booleanToString(!isAnnotation('atom-numbers'))} atom number`,
136
+ onClick: () => handleChangeAtomAnnotation('atom-numbers'),
137
+ active: isAnnotation('atom-numbers'),
138
+ },
139
+ {
140
+ icon: <FaRegBookmark />,
141
+ title: `${booleanToString(!isAnnotation('custom-labels'))} custom labels`,
142
+ onClick: () => handleChangeAtomAnnotation('custom-labels'),
143
+ active: isAnnotation('custom-labels'),
144
+ },
122
145
  ];
123
-
124
146
  const { x: xInPercent, y: yInPercent, width, height } = bounding;
125
147
 
126
148
  const x = percentToPixel(xInPercent, 'x');
@@ -129,7 +151,7 @@ export function DraggableStructure(props: DraggableStructureProps) {
129
151
  if (isExportProcessStart) {
130
152
  return (
131
153
  <g transform={`translate(${x} ${y})`}>
132
- <DraggableMolecule renderAsSVG {...{ width, height }} {...props} />
154
+ <MoleculeStructure renderAsSVG {...{ width, height }} {...props} />
133
155
  </g>
134
156
  );
135
157
  }
@@ -176,7 +198,7 @@ export function DraggableStructure(props: DraggableStructureProps) {
176
198
  >
177
199
  <ResponsiveChart>
178
200
  {({ width, height }) => {
179
- return <DraggableMolecule {...{ width, height }} {...props} />;
201
+ return <MoleculeStructure {...{ width, height }} {...props} />;
180
202
  }}
181
203
  </ResponsiveChart>
182
204
  </div>
@@ -186,66 +208,3 @@ export function DraggableStructure(props: DraggableStructureProps) {
186
208
  </ReactRnd>
187
209
  );
188
210
  }
189
-
190
- function DraggableMolecule(props: DraggableMoleculeProps) {
191
- const {
192
- molecule,
193
- index,
194
- moleculeView,
195
- width,
196
- height,
197
- renderAsSVG = false,
198
- } = props;
199
- const {
200
- currentDiaIDsToHighlight,
201
- handleOnAtomHover,
202
- handleOnClickAtom,
203
- assignedDiaIDsMerged,
204
- } = useAtomAssignment();
205
- const highlightColor = useHighlightColor();
206
- const dispatch = useDispatch();
207
-
208
- const atomHighlightColor =
209
- currentDiaIDsToHighlight?.length > 0 ? '#ff000080' : highlightColor;
210
- const baseProps: MolfileSvgRendererProps = {
211
- id: `molSVG${index || ''}`,
212
- height,
213
- width,
214
- label: molecule.label,
215
- labelFontSize: 15,
216
- labelColor: 'rgb(0,0,0)',
217
- molfile: molecule.molfile,
218
- atomHighlightColor,
219
- atomHighlightOpacity: 1,
220
- showAtomNumber: moleculeView.showAtomNumber,
221
- noCarbonLabelWithCustomLabel: true,
222
- };
223
-
224
- if (renderAsSVG) {
225
- return <MolfileSvgRenderer {...baseProps} />;
226
- }
227
-
228
- return (
229
- <OCLnmr
230
- {...baseProps}
231
- setSelectedAtom={handleOnClickAtom}
232
- highlights={
233
- currentDiaIDsToHighlight?.length > 0
234
- ? currentDiaIDsToHighlight
235
- : assignedDiaIDsMerged
236
- }
237
- atomHighlightStrategy="prefer-editor-props"
238
- setHoverAtom={handleOnAtomHover}
239
- setMolfile={(molfile) => {
240
- dispatch({
241
- type: 'SET_MOLECULE',
242
- payload: {
243
- molfile,
244
- id: molecule.id,
245
- label: molecule.label,
246
- },
247
- });
248
- }}
249
- />
250
- );
251
- }
@@ -1,10 +1,13 @@
1
1
  import type { Ranges, Zones } from '@zakodium/nmr-types';
2
- import type { Spectrum1D, Spectrum2D } from '@zakodium/nmrium-core';
2
+ import type {
3
+ MoleculeView,
4
+ Spectrum1D,
5
+ Spectrum2D,
6
+ } from '@zakodium/nmrium-core';
3
7
  import { memo } from 'react';
4
8
  import { assert } from 'react-science/ui';
5
9
 
6
10
  import type {
7
- MoleculeView,
8
11
  MoleculesView,
9
12
  StateMoleculeExtended,
10
13
  } from '../../../../data/molecules/Molecule.js';
@@ -258,7 +258,7 @@ function IndicationLine(props: IndicationLineProps) {
258
258
 
259
259
  function assignHandler() {
260
260
  isAssignBtnTrigged.current = true;
261
- assignmentContext.activate('x');
261
+ assignmentContext.activate(axis);
262
262
  }
263
263
 
264
264
  function unAssignHandler() {
@@ -94,7 +94,7 @@ export function useExport() {
94
94
  const archive = await core.serializeNmriumArchive({
95
95
  molecules: state.molecules,
96
96
  spectra: state.data,
97
- fileCollections: state.fileCollections,
97
+ aggregator: state.aggregator,
98
98
  includeData: options.include.dataType === 'SELF_CONTAINED',
99
99
  serializedState: blob,
100
100
  });
@@ -40,24 +40,30 @@ export function useLoadFiles(onOpenMetaInformation?: (file: File) => void) {
40
40
  let nmriumState: Partial<NmriumState>;
41
41
  let containsNmrium: boolean;
42
42
  let parseMetaFileResult: ParseResult<any> | null = null;
43
- const { onLoadProcessing, spectraColors } = workspacePreferences;
44
- const { nmrLoaders: sourceSelector } = preferences.current;
43
+ const { onLoadProcessing, spectraColors, defaultMoleculeSettings } =
44
+ workspacePreferences;
45
+ const { nmrLoaders: selector } = preferences.current;
45
46
 
46
47
  const parsingOptions: Partial<ParsingOptions> = {
47
- sourceSelector,
48
+ selector,
48
49
  logger: logger.child({ context: 'nmr-processing' }),
49
50
  onLoadProcessing,
50
51
  experimentalFeatures,
51
52
  };
52
53
 
54
+ let aggregator: FileCollection | undefined;
53
55
  let fileCollection: FileCollection | undefined;
54
- let fileCollections: Map<string, FileCollection> | undefined;
56
+ let selectorRoot: string | undefined;
57
+ let resetSourceObject = false;
58
+
55
59
  if (files.length === 1 && files[0].name.endsWith('.nmrium.zip')) {
56
- [nmriumState, fileCollections] = await core.readNMRiumArchive(
60
+ const [state, ium] = await core.readNMRiumArchive(
57
61
  files[0].stream(),
58
62
  parsingOptions,
59
63
  );
64
+ nmriumState = state;
60
65
  containsNmrium = true;
66
+ aggregator = ium;
61
67
  } else {
62
68
  for (const file of files) {
63
69
  if (file.name.endsWith('.nmrium.zip')) {
@@ -84,10 +90,13 @@ export function useLoadFiles(onOpenMetaInformation?: (file: File) => void) {
84
90
  if (metaFile) {
85
91
  parseMetaFileResult = await parseMetaFile(metaFile);
86
92
  }
87
- ({ nmriumState, containsNmrium } = await core.read(
93
+ ({ nmriumState, containsNmrium, selectorRoot } = await core.read(
88
94
  fileCollection,
89
95
  parsingOptions,
90
96
  ));
97
+ if (containsNmrium) {
98
+ resetSourceObject = true;
99
+ }
91
100
  }
92
101
 
93
102
  if (nmriumState.settings) {
@@ -106,8 +115,11 @@ export function useLoadFiles(onOpenMetaInformation?: (file: File) => void) {
106
115
  containsNmrium,
107
116
  parseMetaFileResult,
108
117
  spectraColors,
118
+ aggregator,
109
119
  fileCollection,
110
- fileCollections,
120
+ selectorRoot,
121
+ resetSourceObject,
122
+ defaultMoleculeSettings,
111
123
  },
112
124
  });
113
125
  }
@@ -78,7 +78,6 @@ export default function NMRiumStateProvider(props: NMRiumStateProviderProps) {
78
78
  sources,
79
79
  view,
80
80
  actionType,
81
- fileCollections: {},
82
81
  },
83
82
  { current: workspaces[workspace.current] },
84
83
  { serialize: false, exportTarget: 'onChange' },
@@ -120,7 +119,7 @@ export default function NMRiumStateProvider(props: NMRiumStateProviderProps) {
120
119
  void core
121
120
  .readNMRiumObject(nmriumData)
122
121
  .then((result) => {
123
- const [nmriumState, fileCollections] = result;
122
+ const [nmriumState, aggregator] = result;
124
123
  if (nmriumState?.settings) {
125
124
  dispatchPreferences({
126
125
  type: 'SET_WORKSPACE',
@@ -132,7 +131,7 @@ export default function NMRiumStateProvider(props: NMRiumStateProviderProps) {
132
131
  }
133
132
  dispatch({
134
133
  type: 'INITIATE',
135
- payload: { nmriumState, fileCollections },
134
+ payload: { nmriumState, aggregator },
136
135
  });
137
136
  })
138
137
  .catch((error: unknown) => {
@@ -66,13 +66,19 @@ function InnerLoadJCAMPModal({ onCloseDialog }: InnerLoadJCAMPModalProps) {
66
66
  });
67
67
  const { pathname, origin } = new URL(url);
68
68
  try {
69
- const [nmriumState, fileCollection] = await core.readFromWebSource({
70
- entries: [{ relativePath: pathname, baseURL: origin }],
71
- });
69
+ const [nmriumState, fileCollection, selectorRoot] =
70
+ await core.readFromWebSource({
71
+ entries: [{ relativePath: pathname, baseURL: origin }],
72
+ });
72
73
 
73
74
  dispatch({
74
75
  type: 'LOAD_DROP_FILES',
75
- payload: { nmriumState, resetSourceObject: false, fileCollection },
76
+ payload: {
77
+ nmriumState,
78
+ resetSourceObject: false,
79
+ fileCollection,
80
+ selectorRoot,
81
+ },
76
82
  });
77
83
  } catch {
78
84
  toaster.show({ message: `Failed to load ${url}`, intent: 'danger' });
@@ -8,6 +8,7 @@ import { useOnOff } from 'react-science/ui';
8
8
 
9
9
  import type { StateMoleculeExtended } from '../../data/molecules/Molecule.js';
10
10
  import { useDispatch } from '../context/DispatchContext.js';
11
+ import { usePreferences } from '../context/PreferencesContext.tsx';
11
12
  import ActionButtons from '../elements/ActionButtons.js';
12
13
  import { StyledDialogBody } from '../elements/StyledDialogBody.js';
13
14
 
@@ -24,10 +25,14 @@ function MoleculeStructureEditorModal(
24
25
  const {
25
26
  onClose = () => null,
26
27
  selectedMolecule,
27
- floatMoleculeOnSave = false,
28
+ floatMoleculeOnSave,
28
29
  isOpen = false,
29
30
  } = props;
30
31
 
32
+ const {
33
+ current: { defaultMoleculeSettings },
34
+ } = usePreferences();
35
+
31
36
  const initialMolfile = selectedMolecule?.molfile;
32
37
  const initialEnhancedMolfile = useMemo(() => {
33
38
  if (!initialMolfile) {
@@ -92,6 +97,7 @@ function MoleculeStructureEditorModal(
92
97
  payload: {
93
98
  molfile,
94
99
  floatMoleculeOnSave,
100
+ defaultMoleculeSettings,
95
101
  },
96
102
  });
97
103
  onClose('new');
@@ -102,8 +108,9 @@ function MoleculeStructureEditorModal(
102
108
  selectedMolecule,
103
109
  initialEnhancedMolfile,
104
110
  dispatch,
105
- floatMoleculeOnSave,
106
111
  onClose,
112
+ floatMoleculeOnSave,
113
+ defaultMoleculeSettings,
107
114
  ]);
108
115
 
109
116
  return (
@@ -132,7 +139,7 @@ function MoleculeStructureEditorModal(
132
139
  );
133
140
  }
134
141
 
135
- export function useMoleculeEditor(floatMoleculeOnSave = false) {
142
+ export function useMoleculeEditor(floatMoleculeOnSave?: boolean) {
136
143
  const [isOpen, openModal, closeModal] = useOnOff(false);
137
144
  const [molecule, setMolecule] = useState<StateMoleculeExtended | undefined>();
138
145
  const modal = (
@@ -5,6 +5,7 @@ import {
5
5
  Radio,
6
6
  RadioGroup,
7
7
  } from '@blueprintjs/core';
8
+ import { useMemo } from 'react';
8
9
  import { Controller, useForm } from 'react-hook-form';
9
10
 
10
11
  import type { ExportOptions } from '../../data/SpectraManager.js';
@@ -58,7 +59,7 @@ function SaveAsModal(props: SaveAsModalProps) {
58
59
  }
59
60
  function InnerSaveAsModal(props: InnerSaveAsModalProps) {
60
61
  const { onCloseDialog } = props;
61
- const { sources, data } = useChartData();
62
+ const { sources, data, aggregator } = useChartData();
62
63
  const { saveHandler } = useExport();
63
64
  const experimentalFlagEnabled = useCheckExperimentalFeature();
64
65
 
@@ -72,6 +73,11 @@ function InnerSaveAsModal(props: InnerSaveAsModalProps) {
72
73
  const { handleSubmit, control, register } = useForm({
73
74
  defaultValues: { ...INITIAL_VALUE, name: fileName },
74
75
  });
76
+
77
+ const containsLinkedFiles = useMemo(() => {
78
+ return aggregator.sources.some((s) => !s.baseURL?.startsWith('ium:'));
79
+ }, [aggregator]);
80
+
75
81
  return (
76
82
  <Dialog
77
83
  isOpen
@@ -129,7 +135,7 @@ function InnerSaveAsModal(props: InnerSaveAsModalProps) {
129
135
  {experimentalFlagEnabled && (
130
136
  <Radio
131
137
  label="Full data (external data linked, experimental)"
132
- disabled={Object.keys(sources).length === 0}
138
+ disabled={!containsLinkedFiles}
133
139
  value={
134
140
  DataExportOptions.SELF_CONTAINED_EXTERNAL_DATASOURCE
135
141
  }
@@ -60,6 +60,10 @@ const LIST: ListItem[] = [
60
60
  label: 'Range picking',
61
61
  name: 'rangePicking',
62
62
  },
63
+ {
64
+ label: 'Inset',
65
+ name: 'inset',
66
+ },
63
67
  {
64
68
  label: 'Slicing',
65
69
  name: 'slicing',
@@ -92,10 +96,22 @@ const LIST: ListItem[] = [
92
96
  label: 'Fourier transform',
93
97
  name: 'fft',
94
98
  },
99
+ {
100
+ label: 'Fourier transform dimension one',
101
+ name: 'fftDimension1',
102
+ },
103
+ {
104
+ label: 'Fourier transform dimension two',
105
+ name: 'fftDimension2',
106
+ },
95
107
  {
96
108
  label: 'Phase correction',
97
109
  name: 'phaseCorrection',
98
110
  },
111
+ {
112
+ label: 'Two-Dimensional phase correction',
113
+ name: 'phaseCorrectionTwoDimensions',
114
+ },
99
115
  {
100
116
  label: 'Baseline correction',
101
117
  name: 'baselineCorrection',
@@ -0,0 +1,160 @@
1
+ import styled from '@emotion/styled';
2
+ import { yupResolver } from '@hookform/resolvers/yup';
3
+ import type { BoundingBox, MoleculeView } from '@zakodium/nmrium-core';
4
+ import { useForm } from 'react-hook-form';
5
+ import * as Yup from 'yup';
6
+
7
+ import { usePreferences } from '../../context/PreferencesContext.tsx';
8
+ import { CheckController } from '../../elements/CheckController.js';
9
+ import { GroupPane } from '../../elements/GroupPane.js';
10
+ import type { LabelStyle } from '../../elements/Label.js';
11
+ import Label from '../../elements/Label.js';
12
+ import { NumberInput2Controller } from '../../elements/NumberInput2Controller.js';
13
+ import { Select2Controller } from '../../elements/Select2Controller.js';
14
+ import PreferencesHeader from '../header/PreferencesHeader.tsx';
15
+
16
+ const atomAnnotations: Array<{
17
+ value: MoleculeView['atomAnnotation'];
18
+ label: string;
19
+ }> = [
20
+ { value: 'none', label: 'None' },
21
+ { value: 'atom-numbers', label: 'Atoms number' },
22
+ { value: 'custom-labels', label: 'Custom labels' },
23
+ ];
24
+ const Container = styled.div`
25
+ display: flex;
26
+ flex-direction: column;
27
+ height: 100%;
28
+ width: 100%;
29
+ `;
30
+ const InnerContainer = styled.div`
31
+ overflow: auto;
32
+ height: 100%;
33
+ display: block;
34
+ background-color: white;
35
+ `;
36
+ const boundingBoxSchema: Yup.ObjectSchema<BoundingBox> = Yup.object({
37
+ width: Yup.number().required().min(0, 'Width must be positive'),
38
+ height: Yup.number().required().min(0, 'Height must be positive'),
39
+ x: Yup.number().required(),
40
+ y: Yup.number().required(),
41
+ }).defined();
42
+
43
+ const moleculeViewSchema: Yup.ObjectSchema<MoleculeView> = Yup.object({
44
+ floating: Yup.object({
45
+ visible: Yup.boolean().required(),
46
+ bounding: boundingBoxSchema.required(),
47
+ }),
48
+ showLabel: Yup.boolean().required(),
49
+ atomAnnotation: Yup.mixed<'none' | 'atom-numbers' | 'custom-labels'>()
50
+ .oneOf(['none', 'atom-numbers', 'custom-labels'])
51
+ .required()
52
+ .default('none'),
53
+ }).defined();
54
+
55
+ const labelStyle: LabelStyle = {
56
+ label: { flex: 4, fontWeight: '500' },
57
+ wrapper: { flex: 8, display: 'flex', alignItems: 'center' },
58
+ container: { padding: '5px 0' },
59
+ };
60
+
61
+ const styles = {
62
+ select: {
63
+ width: '100%',
64
+ minWidth: '100px',
65
+ maxWidth: '280px',
66
+ height: 30,
67
+ margin: 0,
68
+ },
69
+ groupHeader: {
70
+ borderBottom: '1px solid #efefef',
71
+ paddingBottom: '5px',
72
+ fontWeight: '600',
73
+ color: '#005d9e',
74
+ },
75
+ };
76
+
77
+ interface MoleculeOptionsPanelProps {
78
+ onClose: () => void;
79
+ }
80
+
81
+ export function MoleculeOptionsPanel(props: MoleculeOptionsPanelProps) {
82
+ const { onClose } = props;
83
+ const {
84
+ current: { defaultMoleculeSettings },
85
+ } = usePreferences();
86
+ const { handleSubmit, control } = useForm<MoleculeView>({
87
+ defaultValues: defaultMoleculeSettings,
88
+ resolver: yupResolver(moleculeViewSchema),
89
+ });
90
+ const { dispatch } = usePreferences();
91
+
92
+ function handleSave() {
93
+ void handleSubmit((values) => {
94
+ dispatch({ type: 'CHANGE_DEFAULT_MOLECULE_SETTINGS', payload: values });
95
+ onClose();
96
+ })();
97
+ }
98
+ return (
99
+ <Container>
100
+ <PreferencesHeader onSave={handleSave} onClose={onClose} />
101
+ <InnerContainer>
102
+ <GroupPane
103
+ text="General"
104
+ style={{
105
+ header: styles.groupHeader,
106
+ }}
107
+ >
108
+ <Label title="Show label" style={labelStyle}>
109
+ <CheckController control={control} name="showLabel" />
110
+ </Label>
111
+ <Label title="Atom annotation" style={labelStyle}>
112
+ <Select2Controller
113
+ control={control}
114
+ items={atomAnnotations}
115
+ name="atomAnnotation"
116
+ />
117
+ </Label>
118
+ </GroupPane>
119
+ <GroupPane
120
+ text="Size & position"
121
+ style={{
122
+ header: styles.groupHeader,
123
+ }}
124
+ >
125
+ <Label title="Floating molecule" style={labelStyle}>
126
+ <CheckController control={control} name="floating.visible" />
127
+ </Label>
128
+ <Label title="X (%)" style={labelStyle}>
129
+ <NumberInput2Controller
130
+ control={control}
131
+ name="floating.bounding.x"
132
+ fill
133
+ />
134
+ </Label>
135
+ <Label title="Y (%)" style={labelStyle}>
136
+ <NumberInput2Controller
137
+ control={control}
138
+ name="floating.bounding.y"
139
+ fill
140
+ />
141
+ </Label>
142
+ <Label title="Width" style={labelStyle}>
143
+ <NumberInput2Controller
144
+ control={control}
145
+ name="floating.bounding.width"
146
+ fill
147
+ />
148
+ </Label>
149
+ <Label title="Height" style={labelStyle}>
150
+ <NumberInput2Controller
151
+ control={control}
152
+ name="floating.bounding.height"
153
+ fill
154
+ />
155
+ </Label>
156
+ </GroupPane>
157
+ </InnerContainer>
158
+ </Container>
159
+ );
160
+ }