nmrium 0.39.0 → 0.41.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 (306) hide show
  1. package/lib/component/1d/FooterBanner.js +5 -4
  2. package/lib/component/1d/Viewer1D.js +121 -104
  3. package/lib/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
  4. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +1 -1
  5. package/lib/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
  6. package/lib/component/1d/multiplicityTree/TreeColors.d.ts +1 -1
  7. package/lib/component/1d/multiplicityTree/TreeColors.js +1 -6
  8. package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +1 -1
  9. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  10. package/lib/component/1d/tool/BaseLineZones.js +7 -4
  11. package/lib/component/1d/tool/PeakPointer.js +1 -1
  12. package/lib/component/1d/utilities/scale.js +1 -3
  13. package/lib/component/1d-2d/components/FloatMoleculeStructures/index.d.ts +1 -1
  14. package/lib/component/1d-2d/tools/BrushXY.js +10 -7
  15. package/lib/component/1d-2d/tools/CrossLinePointer.js +1 -1
  16. package/lib/component/2d/FooterBanner.js +3 -2
  17. package/lib/component/2d/Viewer2D.js +51 -29
  18. package/lib/component/2d/XAxis.js +1 -1
  19. package/lib/component/2d/YAxis.js +1 -1
  20. package/lib/component/2d/utilities/SliceScale.d.ts +2 -2
  21. package/lib/component/2d/utilities/scale.d.ts +5 -5
  22. package/lib/component/2d/zones/Signal.js +1 -2
  23. package/lib/component/EventsTrackers/BrushTracker.d.ts +4 -1
  24. package/lib/component/EventsTrackers/BrushTracker.js +21 -6
  25. package/lib/component/NMRium.d.ts +2 -2
  26. package/lib/component/NMRium.js +39 -26
  27. package/lib/component/assignment/AssignmentsReducer.d.ts +1 -1
  28. package/lib/component/assignment/actions/setActiveAssignment.js +1 -1
  29. package/lib/component/context/LoggerContext.js +11 -6
  30. package/lib/component/elements/InputRange.js +1 -1
  31. package/lib/component/elements/MenuButton.d.ts +1 -1
  32. package/lib/component/elements/MoleculeSelection.d.ts +1 -1
  33. package/lib/component/elements/ReactTable/ReactTable.d.ts +1 -1
  34. package/lib/component/elements/Tab/DeleteButton.d.ts +1 -1
  35. package/lib/component/elements/ToolbarMenu.d.ts +1 -1
  36. package/lib/component/elements/accordion/Accordion.d.ts +1 -1
  37. package/lib/component/elements/draggable/SVGDraggable.d.ts +1 -1
  38. package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
  39. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +1 -1
  40. package/lib/component/elements/dropDownButton/DropDownList.js +3 -1
  41. package/lib/component/elements/formik/SelectBox.d.ts +1 -1
  42. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +8 -0
  43. package/lib/component/elements/popup/Alert/AlertBlock.js +30 -0
  44. package/lib/component/elements/popup/Alert/Context.d.ts +26 -2
  45. package/lib/component/elements/popup/Alert/Context.js +6 -2
  46. package/lib/component/elements/popup/Alert/Provider.d.ts +4 -3
  47. package/lib/component/elements/popup/Alert/Provider.js +5 -23
  48. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
  49. package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  50. package/lib/component/elements/popup/Modal/Provider.js +3 -1
  51. package/lib/component/elements/popup/options.d.ts +22 -19
  52. package/lib/component/elements/resizer/Resizer.d.ts +2 -2
  53. package/lib/component/elements/toggle/ToggleButton.d.ts +2 -2
  54. package/lib/component/elements/toggle/ToggleButton.js +1 -1
  55. package/lib/component/header/Header.js +2 -2
  56. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -8
  57. package/lib/component/highlight/index.d.ts +1 -1
  58. package/lib/component/hooks/useCheckToolsVisibility.js +2 -2
  59. package/lib/component/hooks/useExport.js +2 -1
  60. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  61. package/lib/component/hooks/usePanelPreferences.js +2 -2
  62. package/lib/component/hooks/useXScale.d.ts +1 -1
  63. package/lib/component/hooks/useXYReduce.d.ts +2 -2
  64. package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
  65. package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
  66. package/lib/component/modal/AboutUsModal.js +4 -2
  67. package/lib/component/modal/AlignSpectraModal.js +11 -1
  68. package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
  69. package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
  70. package/lib/component/modal/MultipletAnalysisModal.js +2 -1
  71. package/lib/component/modal/PredictSpectraModal.d.ts +1 -2
  72. package/lib/component/modal/PredictSpectraModal.js +25 -28
  73. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  74. package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -1
  75. package/lib/component/modal/editZone/SignalsForm.js +1 -1
  76. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  77. package/lib/component/modal/setting/GeneralSettings.js +28 -27
  78. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
  79. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  80. package/lib/component/modal/setting/settingsValidation.js +2 -2
  81. package/lib/component/panels/IntegralsPanel/IntegralPanel.d.ts +1 -1
  82. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +1 -1
  83. package/lib/component/panels/IntegralsPanel/IntegralTable.js +4 -7
  84. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
  85. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +19 -19
  86. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +1 -1
  87. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
  88. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  89. package/lib/component/panels/Panels.js +13 -0
  90. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  91. package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
  92. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
  93. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
  94. package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  95. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  96. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -1
  97. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  98. package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +1 -1
  99. package/lib/component/panels/databasePanel/DatabasePanel.d.ts +1 -1
  100. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  101. package/lib/component/panels/databasePanel/DatabaseTable.js +1 -1
  102. package/lib/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  103. package/lib/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  104. package/lib/component/panels/filtersPanel/FiltersTable.js +2 -2
  105. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  106. package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -2
  107. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -2
  108. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.d.ts +1 -0
  109. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +88 -0
  110. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +11 -0
  111. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +37 -0
  112. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.d.ts +4 -0
  113. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +25 -0
  114. package/lib/component/panels/spectrumSimulation/SpinSystemTable.d.ts +5 -0
  115. package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +60 -0
  116. package/lib/component/reducer/Reducer.d.ts +13 -12
  117. package/lib/component/reducer/Reducer.js +251 -239
  118. package/lib/component/reducer/actions/AssignmentsActions.d.ts +1 -1
  119. package/lib/component/reducer/actions/AssignmentsActions.js +1 -1
  120. package/lib/component/reducer/actions/DatabaseActions.js +2 -1
  121. package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
  122. package/lib/component/reducer/actions/DomainActions.js +30 -1
  123. package/lib/component/reducer/actions/FiltersActions.js +4 -4
  124. package/lib/component/reducer/actions/LoadActions.js +1 -1
  125. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -0
  126. package/lib/component/reducer/actions/MoleculeActions.js +51 -2
  127. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -2
  128. package/lib/component/reducer/actions/SpectrumsActions.js +43 -4
  129. package/lib/component/reducer/actions/ToolsActions.js +2 -2
  130. package/lib/component/reducer/actions/ZonesActions.js +1 -1
  131. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +4 -6
  132. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  133. package/lib/component/reducer/preferences/actions/setPreferences.js +3 -4
  134. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  135. package/lib/component/reducer/preferences/preferencesReducer.js +5 -1
  136. package/lib/component/reducer/preferences/utilities/flatObject.js +1 -1
  137. package/lib/component/toolbar/ToolTypes.d.ts +4 -4
  138. package/lib/component/utility/export.d.ts +5 -4
  139. package/lib/component/utility/export.js +33 -61
  140. package/lib/component/utility/getSpectraObjectPaths.js +1 -1
  141. package/lib/component/utility/getUniqueNuclei.js +1 -1
  142. package/lib/component/utility/jpathToArray.js +1 -1
  143. package/lib/component/workspaces/index.d.ts +1 -0
  144. package/lib/component/workspaces/index.js +2 -0
  145. package/lib/component/workspaces/simulation.d.ts +2 -0
  146. package/lib/component/workspaces/simulation.js +68 -0
  147. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  148. package/lib/data/PredictionManager.d.ts +8 -7
  149. package/lib/data/PredictionManager.js +95 -22
  150. package/lib/data/SpectraManager.js +1 -1
  151. package/lib/data/constants/DefaultPathLengths.d.ts +1 -3
  152. package/lib/data/constants/SignalsKinds.d.ts +2 -2
  153. package/lib/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  154. package/lib/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  155. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.d.ts +1 -1
  156. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  157. package/lib/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  158. package/lib/data/data1d/database.d.ts +5 -5
  159. package/lib/data/data1d/database.js +3 -3
  160. package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -1
  161. package/lib/data/data1d/multipleSpectraAnalysis.js +1 -1
  162. package/lib/data/data1d/spectrumSimulation.d.ts +14 -0
  163. package/lib/data/data1d/spectrumSimulation.js +53 -0
  164. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -4
  165. package/lib/data/data2d/Spectrum2D/contours.js +7 -1
  166. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  167. package/lib/data/data2d/Spectrum2D/getShift.js +1 -1
  168. package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
  169. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  170. package/lib/data/getDefaultMatrixFilters.d.ts +2 -2
  171. package/lib/data/matrixGeneration.js +1 -1
  172. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  173. package/lib/data/molecules/MoleculeManager.js +7 -7
  174. package/lib/data/parseMeta/linkMetaWithSpectra.js +2 -1
  175. package/lib/data/types/data1d/MatrixOptions.d.ts +2 -2
  176. package/lib/data/utilities/FindUtilities.js +4 -4
  177. package/lib/data/utilities/RangeUtilities.d.ts +1 -1
  178. package/lib/data/utilities/ZoneUtilities.d.ts +1 -1
  179. package/lib/data/utilities/calculateSanPlot.js +3 -3
  180. package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
  181. package/lib/utils/clipboard/clipboard.d.ts +12 -0
  182. package/lib/utils/clipboard/clipboard.js +15 -0
  183. package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
  184. package/lib/utils/clipboard/clipboardComponents.js +150 -0
  185. package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
  186. package/lib/utils/clipboard/clipboardHooks.js +142 -0
  187. package/lib/utils/clipboard/types.d.ts +1 -0
  188. package/lib/utils/clipboard/types.js +1 -0
  189. package/lib/versionInfo.js +1 -1
  190. package/lib-cjs/component/1d/FooterBanner.js +5 -4
  191. package/lib-cjs/component/1d/Viewer1D.js +120 -103
  192. package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
  193. package/lib-cjs/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
  194. package/lib-cjs/component/1d/multiplicityTree/TreeColors.js +1 -6
  195. package/lib-cjs/component/1d/tool/BaseLineZones.js +6 -3
  196. package/lib-cjs/component/1d/tool/PeakPointer.js +1 -1
  197. package/lib-cjs/component/1d/utilities/scale.js +1 -3
  198. package/lib-cjs/component/1d-2d/tools/BrushXY.js +10 -7
  199. package/lib-cjs/component/1d-2d/tools/CrossLinePointer.js +1 -1
  200. package/lib-cjs/component/2d/FooterBanner.js +3 -2
  201. package/lib-cjs/component/2d/Viewer2D.js +50 -28
  202. package/lib-cjs/component/2d/XAxis.js +1 -1
  203. package/lib-cjs/component/2d/YAxis.js +1 -1
  204. package/lib-cjs/component/2d/zones/Signal.js +1 -2
  205. package/lib-cjs/component/EventsTrackers/BrushTracker.js +21 -6
  206. package/lib-cjs/component/NMRium.js +37 -24
  207. package/lib-cjs/component/assignment/actions/setActiveAssignment.js +1 -1
  208. package/lib-cjs/component/context/LoggerContext.js +10 -5
  209. package/lib-cjs/component/elements/InputRange.js +1 -1
  210. package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
  211. package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +36 -0
  212. package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
  213. package/lib-cjs/component/elements/popup/Alert/Provider.js +4 -22
  214. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  215. package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
  216. package/lib-cjs/component/header/Header.js +2 -2
  217. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -8
  218. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +2 -2
  219. package/lib-cjs/component/hooks/useExport.js +2 -1
  220. package/lib-cjs/component/hooks/usePanelPreferences.js +1 -1
  221. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +54 -0
  222. package/lib-cjs/component/modal/AboutUsModal.js +4 -2
  223. package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
  224. package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
  225. package/lib-cjs/component/modal/MultipletAnalysisModal.js +2 -1
  226. package/lib-cjs/component/modal/PredictSpectraModal.js +24 -27
  227. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +1 -1
  228. package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +1 -1
  229. package/lib-cjs/component/modal/editZone/SignalsForm.js +1 -1
  230. package/lib-cjs/component/modal/metaImportation/MetaImportationModal.js +1 -1
  231. package/lib-cjs/component/modal/setting/GeneralSettings.js +28 -27
  232. package/lib-cjs/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
  233. package/lib-cjs/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  234. package/lib-cjs/component/modal/setting/settingsValidation.js +2 -2
  235. package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
  236. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -18
  237. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
  238. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  239. package/lib-cjs/component/panels/Panels.js +13 -0
  240. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  241. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
  242. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
  243. package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
  244. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  245. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  246. package/lib-cjs/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  247. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  248. package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +1 -1
  249. package/lib-cjs/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  250. package/lib-cjs/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  251. package/lib-cjs/component/panels/filtersPanel/FiltersTable.js +2 -2
  252. package/lib-cjs/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  253. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -2
  254. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -1
  255. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +94 -0
  256. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +42 -0
  257. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +31 -0
  258. package/lib-cjs/component/panels/spectrumSimulation/SpinSystemTable.js +67 -0
  259. package/lib-cjs/component/reducer/Reducer.js +251 -239
  260. package/lib-cjs/component/reducer/actions/AssignmentsActions.js +1 -1
  261. package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -1
  262. package/lib-cjs/component/reducer/actions/DomainActions.js +31 -1
  263. package/lib-cjs/component/reducer/actions/FiltersActions.js +4 -4
  264. package/lib-cjs/component/reducer/actions/LoadActions.js +1 -1
  265. package/lib-cjs/component/reducer/actions/MoleculeActions.js +54 -2
  266. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +43 -3
  267. package/lib-cjs/component/reducer/actions/ToolsActions.js +2 -2
  268. package/lib-cjs/component/reducer/actions/ZonesActions.js +1 -1
  269. package/lib-cjs/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  270. package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +3 -4
  271. package/lib-cjs/component/reducer/preferences/preferencesReducer.js +5 -1
  272. package/lib-cjs/component/reducer/preferences/utilities/flatObject.js +1 -1
  273. package/lib-cjs/component/utility/export.js +33 -63
  274. package/lib-cjs/component/utility/getSpectraObjectPaths.js +1 -1
  275. package/lib-cjs/component/utility/getUniqueNuclei.js +1 -1
  276. package/lib-cjs/component/utility/jpathToArray.js +1 -1
  277. package/lib-cjs/component/workspaces/index.js +2 -0
  278. package/lib-cjs/component/workspaces/simulation.js +71 -0
  279. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -0
  280. package/lib-cjs/data/PredictionManager.js +96 -22
  281. package/lib-cjs/data/SpectraManager.js +1 -1
  282. package/lib-cjs/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  283. package/lib-cjs/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  284. package/lib-cjs/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  285. package/lib-cjs/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  286. package/lib-cjs/data/data1d/database.js +3 -3
  287. package/lib-cjs/data/data1d/multipleSpectraAnalysis.js +1 -1
  288. package/lib-cjs/data/data1d/spectrumSimulation.js +58 -0
  289. package/lib-cjs/data/data2d/Spectrum2D/contours.js +7 -1
  290. package/lib-cjs/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  291. package/lib-cjs/data/data2d/Spectrum2D/getShift.js +1 -1
  292. package/lib-cjs/data/data2d/Spectrum2D/getSlice.js +4 -4
  293. package/lib-cjs/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  294. package/lib-cjs/data/matrixGeneration.js +1 -1
  295. package/lib-cjs/data/molecules/MoleculeManager.js +7 -7
  296. package/lib-cjs/data/parseMeta/linkMetaWithSpectra.js +2 -1
  297. package/lib-cjs/data/utilities/FindUtilities.js +4 -4
  298. package/lib-cjs/data/utilities/calculateSanPlot.js +3 -3
  299. package/lib-cjs/data/utilities/generateNumbersPowerOfX.js +1 -1
  300. package/lib-cjs/utils/clipboard/clipboard.js +23 -0
  301. package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
  302. package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
  303. package/lib-cjs/utils/clipboard/types.js +2 -0
  304. package/lib-cjs/versionInfo.js +1 -1
  305. package/package.json +26 -25
  306. package/lib/component/header/LogsHistory.d.ts +0 -1
@@ -214,7 +214,7 @@ function handleCalculateZeroFillingFilter(draft, action) {
214
214
  if (activeSpectrum) {
215
215
  const index = activeSpectrum.index;
216
216
  const { data: { x, re, im }, filters, info, } = draft.tempData[index];
217
- let _data = { data: { x, re, im }, filters, info };
217
+ const _data = { data: { x, re, im }, filters, info };
218
218
  zeroFilling.apply(_data, action.payload);
219
219
  const { im: newIm, re: newRe, x: newX } = _data.data;
220
220
  const datum = draft.data[index];
@@ -231,7 +231,7 @@ function handleCalculateApodizationFilter(draft, action) {
231
231
  const index = activeSpectrum.index;
232
232
  const options = action.payload;
233
233
  const { data: { x, re, im }, info, } = draft.tempData[index];
234
- let _data = { data: { x, re, im }, info };
234
+ const _data = { data: { x, re, im }, info };
235
235
  draft.toolOptions.data.apodizationOptions = options;
236
236
  apodization.apply(_data, options);
237
237
  const { im: newIm, re: newRe } = _data.data;
@@ -316,7 +316,7 @@ function handleCalculateManualPhaseCorrection(draft, action) {
316
316
  const { index } = activeSpectrum;
317
317
  const { data: { x, re, im }, info, } = draft.tempData[index];
318
318
  const { ph0, ph1 } = action.payload;
319
- let _data = { data: { x, re, im }, info };
319
+ const _data = { data: { x, re, im }, info };
320
320
  phaseCorrection.apply(_data, { ph0, ph1 });
321
321
  const { im: newIm, re: newRe } = _data.data;
322
322
  const datum = draft.data[index];
@@ -413,7 +413,7 @@ function calculateBaseLineCorrection(draft, baseLineOptions) {
413
413
  const { zones, options } = draft.toolOptions.data.baselineCorrection;
414
414
  const { livePreview, ...filterOptions } = options;
415
415
  if (livePreview) {
416
- let _data = { data: { x, re, im }, info };
416
+ const _data = { data: { x, re, im }, info };
417
417
  baselineCorrection.apply(_data, {
418
418
  zones,
419
419
  ...filterOptions,
@@ -16,7 +16,7 @@ function convertHybridizationStringValuesInCorrelations(correlations) {
16
16
  ...correlations,
17
17
  values: correlations.values.map((correlation) => {
18
18
  if (typeof correlation.hybridization === 'string') {
19
- let values = [];
19
+ const values = [];
20
20
  if (correlation.hybridization.length > 0) {
21
21
  const hybridizationString = correlation.hybridization.replaceAll('SP', '');
22
22
  const value = Number(hybridizationString);
@@ -1,3 +1,4 @@
1
+ import { FifoLogger } from 'fifo-logger';
1
2
  import { Draft } from 'immer';
2
3
  import { PredictedSpectraResult, PredictionOptions } from '../../../data/PredictionManager';
3
4
  import { MoleculeBoundingRect, StateMolecule } from '../../../data/molecules/Molecule';
@@ -15,6 +16,7 @@ type DeleteMoleculeAction = ActionType<'DELETE_MOLECULE', {
15
16
  assignmentData: AssignmentContext;
16
17
  }>;
17
18
  type PredictSpectraFromMoleculeAction = ActionType<'PREDICT_SPECTRA', {
19
+ logger: FifoLogger;
18
20
  options: PredictionOptions;
19
21
  predictedSpectra: PredictedSpectraResult;
20
22
  molecule: StateMolecule;
@@ -1,3 +1,5 @@
1
+ import OCL from 'openchemlib/full';
2
+ import { nbLabileH, getAtoms } from 'openchemlib-utils';
1
3
  import { generateSpectra, } from '../../../data/PredictionManager';
2
4
  import { changeSpectraRelativeSum } from '../../../data/data1d/Spectrum1D/SumManager';
3
5
  import { DRAGGABLE_STRUCTURE_INITIAL_BOUNDING_REACT, } from '../../../data/molecules/Molecule';
@@ -72,10 +74,11 @@ function handleDeleteMolecule(draft, action) {
72
74
  }
73
75
  //action
74
76
  function handlePredictSpectraFromMolecule(draft, action) {
75
- const { predictedSpectra, options, molecule, action: predictionAction = 'save', } = action.payload;
77
+ const { logger, predictedSpectra, options, molecule, action: predictionAction = 'save', } = action.payload;
78
+ checkPredictions(predictedSpectra, options, molecule.molfile, logger);
76
79
  const color = generateColor(false, draft.usedColors['1d']);
77
80
  const spectraIds = [];
78
- for (const spectrum of generateSpectra(predictedSpectra, options, color)) {
81
+ for (const spectrum of generateSpectra(predictedSpectra, options, color, logger)) {
79
82
  draft.data.push(spectrum);
80
83
  spectraIds.push(spectrum.id);
81
84
  }
@@ -100,6 +103,52 @@ function handlePredictSpectraFromMolecule(draft, action) {
100
103
  draft.toolOptions.data.predictionIndex++;
101
104
  setActiveTab(draft, { refreshActiveTab: true, tab: '1H' });
102
105
  }
106
+ function checkPredictions(predictedSpectra, inputOptions, molfile, logger) {
107
+ const { spectra } = inputOptions;
108
+ const missing2DPrediction = [];
109
+ const molecule = OCL.Molecule.fromMolfile(molfile);
110
+ molecule.addImplicitHydrogens();
111
+ const { atoms } = getAtoms(molecule);
112
+ for (const [experiment, required] of Object.entries(spectra)) {
113
+ if (!required || predictedSpectra[experiment])
114
+ continue;
115
+ let message = '';
116
+ switch (experiment) {
117
+ case 'proton': {
118
+ message =
119
+ atoms.H - nbLabileH(molecule) === 0
120
+ ? 'No non-labile hydrogen found in the molecule, the proton spectrum could not be predicted'
121
+ : `Proton was not predicted`;
122
+ break;
123
+ }
124
+ case 'carbon': {
125
+ message = `${experiment} was not predicted. ${!('C' in atoms) ? 'No carbons found in the molecule' : ''}`;
126
+ break;
127
+ }
128
+ case 'cosy':
129
+ message = !predictedSpectra.proton
130
+ ? `Proton prediction is missing, so COSY experiment can not be simulated`
131
+ : `There was a error in ${experiment.toUpperCase()} prediction`;
132
+ break;
133
+ case 'hsqc':
134
+ case 'hmbc':
135
+ if (!predictedSpectra[experiment]) {
136
+ missing2DPrediction.push(experiment);
137
+ }
138
+ break;
139
+ default:
140
+ break;
141
+ }
142
+ if (message.length > 0) {
143
+ logger.warn(message);
144
+ }
145
+ }
146
+ if (missing2DPrediction.length > 0) {
147
+ logger.warn(`Carbon or proton prediction are missing, so ${missing2DPrediction.length > 1
148
+ ? missing2DPrediction.join(' and ')
149
+ : missing2DPrediction[0]} can not be simulated`);
150
+ }
151
+ }
103
152
  function setPredictedSpectraReference(draft, moleculeId, spectraIds) {
104
153
  const predictedSpectraIds = draft.view.predictions?.[moleculeId];
105
154
  // check if the molecule predicted and return and the spectra Ids
@@ -1,5 +1,6 @@
1
1
  import { Draft } from 'immer';
2
2
  import { Spectrum, Display1D, Display2D } from 'nmr-load-save';
3
+ import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulation';
3
4
  import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
4
5
  import { State } from '../Reducer';
5
6
  import { ActionType } from '../types/ActionType';
@@ -43,7 +44,11 @@ type RecolorSpectraBasedOnDistinctValueAction = ActionType<'RECOLOR_SPECTRA_COLO
43
44
  type OrderSpectraAction = ActionType<'ORDER_SPECTRA', {
44
45
  data: Spectrum[];
45
46
  }>;
46
- export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | RecolorSpectraBasedOnDistinctValueAction | OrderSpectraAction;
47
+ type SimulateSpectrumAction = ActionType<'SIMULATE_SPECTRUM', {
48
+ keepSpectrum?: boolean;
49
+ spinSystem: string;
50
+ } & SpectrumSimulationOptions>;
51
+ export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | RecolorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction;
47
52
  declare function setSpectraMetaInfo(draft: Draft<State>, spectraMetaInfo: Record<string, Record<string, any>>): void;
48
53
  declare function handleChangeSpectrumVisibilityById(draft: Draft<State>, action: ChangeSpectrumVisibilityByIdAction): void;
49
54
  declare function handleChangeSpectraVisibilityByNucleus(draft: Draft<State>, action: ChangeSpectraVisibilityByNucleusAction): void;
@@ -57,4 +62,5 @@ declare function handleImportSpectraMetaInfo(draft: Draft<State>, action: Import
57
62
  declare function handleToggleSpectraLegend(draft: Draft<State>): void;
58
63
  declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: RecolorSpectraBasedOnDistinctValueAction): void;
59
64
  declare function handleOrderSpectra(draft: Draft<State>, action: OrderSpectraAction): void;
60
- export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, setSpectraMetaInfo, };
65
+ declare function handleSimulateSpectrum(draft: Draft<State>, simulateSpectrumOptions: SimulateSpectrumAction): void;
66
+ export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, handleSimulateSpectrum, setSpectraMetaInfo, };
@@ -3,7 +3,8 @@ import lodashGet from 'lodash/get';
3
3
  import omitBy from 'lodash/omitBy';
4
4
  import lodashSet from 'lodash/set';
5
5
  import { Filters, FiltersManager } from 'nmr-processing';
6
- import { generateSpectrumFromPublicationString, getReferenceShift, isSpectrum1D, get1DColor, } from '../../../data/data1d/Spectrum1D';
6
+ import { generateSpectrumFromPublicationString, getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D, } from '../../../data/data1d/Spectrum1D';
7
+ import { simulateSpectrum, } from '../../../data/data1d/spectrumSimulation';
7
8
  import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
8
9
  import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
9
10
  import groupByInfoKey from '../../utility/GroupByInfoKey';
@@ -255,7 +256,7 @@ function handleAddMissingProjectionHandler(draft, action) {
255
256
  const { index } = activeSpectrum;
256
257
  const Spectrum2D = state.data[index];
257
258
  const { info, data } = Spectrum2D;
258
- for (let n of nucleus) {
259
+ for (const n of nucleus) {
259
260
  const datum1D = getMissingProjection(info.isFid ? data.re : data.rr, n, info, draft.usedColors);
260
261
  draft.data.push(datum1D);
261
262
  }
@@ -269,7 +270,7 @@ function handleAddMissingProjectionHandler(draft, action) {
269
270
  //action
270
271
  function handleAlignSpectraHandler(draft, action) {
271
272
  if (draft.data && draft.data.length > 0) {
272
- for (let datum of draft.data) {
273
+ for (const datum of draft.data) {
273
274
  if (datum.info?.dimension === 1 &&
274
275
  datum.info.nucleus === draft.view.spectra.activeTab &&
275
276
  !datum.info?.isFid) {
@@ -367,4 +368,42 @@ function handleOrderSpectra(draft, action) {
367
368
  .filter((s) => !sortedSpectraKey[s.id])
368
369
  .concat(sortedSpectra);
369
370
  }
370
- export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, setSpectraMetaInfo, };
371
+ function handleSimulateSpectrum(draft, simulateSpectrumOptions) {
372
+ const { payload: { spinSystem, data, options, keepSpectrum = false }, } = simulateSpectrumOptions;
373
+ const { x, y } = simulateSpectrum(spinSystem, {
374
+ data,
375
+ options,
376
+ });
377
+ let spectrumIndex = -1;
378
+ if (!keepSpectrum && draft.view.currentSimulatedSpectrumKey) {
379
+ spectrumIndex = draft.data.findIndex((s) => s.id === draft.view.currentSimulatedSpectrumKey);
380
+ }
381
+ const { frequency, to, from } = options;
382
+ const info = {
383
+ originFrequency: frequency,
384
+ baseFrequency: frequency,
385
+ name: spinSystem,
386
+ };
387
+ if (spectrumIndex !== -1) {
388
+ const spectrum = draft.data[spectrumIndex];
389
+ spectrum.data = { x, re: y };
390
+ spectrum.info = { ...spectrum.info, ...info };
391
+ const [x1, x2] = draft.originDomain.xDomain;
392
+ const isInXDomain = to - from <= x2 - x1;
393
+ setDomain(draft, { updateYDomain: false, updateXDomain: !isInXDomain });
394
+ }
395
+ else {
396
+ const spectrum = initiateDatum1D({
397
+ data: { x, re: y },
398
+ info: {
399
+ isFt: true,
400
+ nucleus: '1H',
401
+ ...info,
402
+ },
403
+ }, { usedColors: draft.usedColors });
404
+ draft.data.push(spectrum);
405
+ draft.view.currentSimulatedSpectrumKey = spectrum.id;
406
+ setActiveTab(draft);
407
+ }
408
+ }
409
+ export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, handleSimulateSpectrum, setSpectraMetaInfo, };
@@ -307,10 +307,10 @@ function setDisplayerMode(draft, data) {
307
307
  }
308
308
  //utility
309
309
  function setTabActiveSpectrum(draft, dataGroupByTab) {
310
- let tabs2D = [];
310
+ const tabs2D = [];
311
311
  const tabActiveSpectrum = {};
312
312
  const tabkeys = Object.keys(dataGroupByTab).sort((a, b) => a.split(',').length > b.split(',').length ? -1 : 1);
313
- for (let tabKey of tabkeys) {
313
+ for (const tabKey of tabkeys) {
314
314
  const data = dataGroupByTab[tabKey];
315
315
  const nucleusLength = tabKey.split(',').length;
316
316
  if (nucleusLength === 2) {
@@ -72,7 +72,7 @@ function handleChangeZoneSignalDelta(draft, action) {
72
72
  if (activeSpectrum?.id) {
73
73
  const { index } = activeSpectrum;
74
74
  const { xShift, yShift } = changeZoneSignal(draft.data[index], zoneId, signal);
75
- let filters = [];
75
+ const filters = [];
76
76
  if (xShift !== 0) {
77
77
  filters.push({ name: Filters.shift2DX.id, value: { shift: xShift } });
78
78
  }
@@ -2,14 +2,12 @@ import { Draft } from 'immer';
2
2
  import { Layout } from '../../2d/utilities/DimensionLayout';
3
3
  import { State } from '../Reducer';
4
4
  interface HistoryItem {
5
- xDomain: Array<number>;
6
- yDomain: Array<number>;
7
- }
8
- export interface ZoomHistory {
9
- [key: string]: Array<HistoryItem>;
5
+ xDomain: number[];
6
+ yDomain: number[];
10
7
  }
8
+ export type ZoomHistory = Record<string, HistoryItem[]>;
11
9
  interface ZoomHistoryManager {
12
- historyStack: Array<HistoryItem>;
10
+ historyStack: HistoryItem[];
13
11
  push: (value: HistoryItem) => void;
14
12
  pop: () => HistoryItem;
15
13
  getLast: () => HistoryItem;
@@ -2,7 +2,7 @@ import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
2
2
  export function setActiveWorkspace(draft, action) {
3
3
  if (action.payload) {
4
4
  const { workspace } = action.payload;
5
- let localData = getLocalStorage('nmr-general-settings');
5
+ const localData = getLocalStorage('nmr-general-settings');
6
6
  draft.workspace.current = workspace;
7
7
  localData.currentWorkspace = workspace;
8
8
  storeData('nmr-general-settings', JSON.stringify(localData));
@@ -3,15 +3,14 @@ import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
3
3
  import { getActiveWorkspace } from '../utilities/getActiveWorkspace';
4
4
  import { mapNucleiFormatting } from '../utilities/mapNucleiFormatting';
5
5
  export function setPreferences(draft, action) {
6
- let localData = getLocalStorage('nmr-general-settings');
6
+ const localData = getLocalStorage('nmr-general-settings');
7
7
  const currentWorkspacePreferences = getActiveWorkspace(draft);
8
8
  if (action.payload) {
9
- let { formatting, ...restPreferences } = action.payload;
10
- formatting = mapNucleiFormatting(formatting);
9
+ const { formatting, ...restPreferences } = action.payload;
11
10
  draft.workspaces[draft.workspace.current] = {
12
11
  ...currentWorkspacePreferences,
13
12
  ...restPreferences,
14
- formatting,
13
+ formatting: mapNucleiFormatting(formatting),
15
14
  };
16
15
  }
17
16
  if (draft.workspaces[draft.workspace.current].source === 'user') {
@@ -14,7 +14,7 @@ type InitPreferencesAction = ActionType<'INIT_PREFERENCES', {
14
14
  customWorkspaces: Record<string, Workspace>;
15
15
  dispatch: any;
16
16
  }>;
17
- type SetPreferencesAction = ActionType<'SET_PREFERENCES', Partial<Workspace>> | ActionType<'SET_PREFERENCES', void>;
17
+ type SetPreferencesAction = ActionType<'SET_PREFERENCES', Partial<Workspace>> | ActionType<'SET_PREFERENCES'>;
18
18
  type SetPanelsPreferencesAction = ActionType<'SET_PANELS_PREFERENCES', {
19
19
  key: string;
20
20
  value: string;
@@ -43,6 +43,10 @@ export const WORKSPACES = [
43
43
  key: 'embedded',
44
44
  label: Workspaces.embedded.label,
45
45
  },
46
+ {
47
+ key: 'simulation',
48
+ label: Workspaces.simulation.label,
49
+ },
46
50
  ];
47
51
  export const preferencesInitialState = {
48
52
  version: LOCAL_STORAGE_VERSION,
@@ -56,7 +60,7 @@ export const preferencesInitialState = {
56
60
  };
57
61
  export function initPreferencesState(state) {
58
62
  const nmrLocalStorageVersion = getLocalStorage('nmr-local-storage-version', false);
59
- let localData = getLocalStorage('nmr-general-settings');
63
+ const localData = getLocalStorage('nmr-general-settings');
60
64
  // remove old nmr-local-storage-version key
61
65
  if (nmrLocalStorageVersion && localData?.version) {
62
66
  removeData('nmr-local-storage-version');
@@ -1,5 +1,5 @@
1
1
  export function flatObject(data) {
2
- let result = {};
2
+ const result = {};
3
3
  JSON.parse(JSON.stringify(data), (key, value) => {
4
4
  if (value?.hidden !== true && key) {
5
5
  result[key] = result[key]++ || 1;
@@ -6,15 +6,15 @@ export interface ToolOptionItem {
6
6
  id: string;
7
7
  label: string;
8
8
  mode?: DISPLAYER_MODE;
9
- spectraOptions?: ({
10
- info?: {
9
+ spectraOptions?: Array<{
10
+ info?: Array<{
11
11
  key: InfoKey;
12
12
  value: any;
13
- }[];
13
+ }>;
14
14
  active: true;
15
15
  } | {
16
16
  active: false;
17
- })[];
17
+ }>;
18
18
  isToggle: boolean;
19
19
  hasOptionPanel: boolean;
20
20
  isFilter: boolean;
@@ -1,8 +1,9 @@
1
- declare function copyHTMLToClipboard(data: any): Promise<boolean>;
2
- declare function copyTextToClipboard(data: any): Promise<boolean>;
3
1
  /**
4
2
  * export the experiments result in JSON format
5
- * @param {*} data
3
+ * @param data
4
+ * @param fileName
5
+ * @param spaceIndent
6
+ * @param isCompressed
6
7
  */
7
8
  declare function exportAsJSON(data: any, fileName?: string, spaceIndent?: number, isCompressed?: boolean): Promise<void>;
8
9
  declare function exportAsMatrix(data: any, fileName?: string): void;
@@ -20,4 +21,4 @@ export interface BlobObject {
20
21
  height: number;
21
22
  }
22
23
  declare function getBlob(rootRef: HTMLDivElement, elementID: string): BlobObject;
23
- export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, copyTextToClipboard, copyHTMLToClipboard, exportAsMol, exportAsMatrix, getBlob, };
24
+ export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, exportAsMol, exportAsMatrix, getBlob, };
@@ -1,40 +1,12 @@
1
1
  import { saveAs } from 'file-saver';
2
2
  import JSZip from 'jszip';
3
- async function copyHTMLToClipboard(data) {
4
- return copyToClipboard(data, 'text/html');
5
- }
6
- async function copyTextToClipboard(data) {
7
- return copyToClipboard(data, 'text/plain');
8
- }
9
- async function copyToClipboard(data, type) {
10
- try {
11
- if (typeof ClipboardItem !== 'undefined') {
12
- void navigator.clipboard.write([
13
- new ClipboardItem({
14
- [type]: new Promise((resolve) => {
15
- resolve(new Blob([data], { type }));
16
- }),
17
- }),
18
- ]);
19
- }
20
- else {
21
- const clipboard = await import('clipboard-polyfill');
22
- //TODO when Firefox team implement ClipboardItem this code should be removed
23
- // this library is used mainly to solve the problem of copy HTML to a clipboard in Firefox but we use it for both HTML and plain text
24
- const item = new clipboard.ClipboardItem({
25
- [type]: new Blob([data], { type }),
26
- });
27
- await clipboard.write([item]);
28
- }
29
- return true;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
3
+ import { newClipboardItem, write } from '../../utils/clipboard/clipboard';
35
4
  /**
36
5
  * export the experiments result in JSON format
37
- * @param {*} data
6
+ * @param data
7
+ * @param fileName
8
+ * @param spaceIndent
9
+ * @param isCompressed
38
10
  */
39
11
  async function exportAsJSON(data, fileName = 'experiment', spaceIndent = 0, isCompressed = false) {
40
12
  const fileData = JSON.stringify(data, (key, value) => ArrayBuffer.isView(value) ? Array.from(value) : value, spaceIndent);
@@ -98,19 +70,19 @@ function exportAsSVG(rootRef, elementID, fileName = 'experiment') {
98
70
  function exportAsPng(rootRef, elementID, fileName = 'experiment') {
99
71
  const { blob, width, height } = getBlob(rootRef, elementID);
100
72
  try {
101
- let canvas = document.createElement('canvas');
73
+ const canvas = document.createElement('canvas');
102
74
  canvas.width = width;
103
75
  canvas.height = height;
104
- let context = canvas.getContext('2d');
76
+ const context = canvas.getContext('2d');
105
77
  if (context) {
106
78
  context.fillStyle = 'white';
107
79
  context.fillRect(0, 0, canvas.width, canvas.height);
108
80
  }
109
- let img = new Image();
110
- let url = URL.createObjectURL(blob);
81
+ const img = new Image();
82
+ const url = URL.createObjectURL(blob);
111
83
  img.addEventListener('load', () => {
112
84
  context?.drawImage(img, 0, 0);
113
- let png = canvas.toDataURL('image/png', 1);
85
+ const png = canvas.toDataURL('image/png', 1);
114
86
  saveAs(png, `${fileName}.png`);
115
87
  URL.revokeObjectURL(png);
116
88
  });
@@ -137,42 +109,42 @@ function copyDataURLClipboardFireFox(image) {
137
109
  }
138
110
  function copyBlobToClipboard(canvas) {
139
111
  canvas.toBlob((b) => {
140
- const clip = new ClipboardItem({
141
- [b.type]: b,
142
- });
143
- navigator.clipboard.write([clip]).then(() => {
112
+ if (!b)
113
+ return;
114
+ (async () => {
115
+ const clip = await newClipboardItem({
116
+ [b.type]: b,
117
+ });
118
+ await write([clip]);
119
+ })()
120
+ .catch(() => {
121
+ const png = canvas.toDataURL('image/png', 1);
122
+ copyDataURLClipboardFireFox(png);
123
+ URL.revokeObjectURL(png);
124
+ })
125
+ .then(() => {
144
126
  // eslint-disable-next-line no-console
145
127
  console.log('experiment copied.');
146
- }, (error) => {
147
- // TODO: handle error;
148
- reportError(error);
149
- });
128
+ })
129
+ .catch(reportError);
150
130
  });
151
131
  }
152
132
  function copyPNGToClipboard(rootRef, elementID) {
153
133
  const { blob, width, height } = getBlob(rootRef, elementID);
154
134
  try {
155
- let canvas = document.createElement('canvas');
135
+ const canvas = document.createElement('canvas');
156
136
  canvas.width = width;
157
137
  canvas.height = height;
158
- let context = canvas.getContext('2d');
138
+ const context = canvas.getContext('2d');
159
139
  if (context) {
160
140
  context.fillStyle = 'white';
161
141
  context.fillRect(0, 0, canvas.width, canvas.height);
162
142
  }
163
- let img = new Image();
143
+ const img = new Image();
164
144
  const url = URL.createObjectURL(blob);
165
- img.addEventListener('load', async () => {
145
+ img.addEventListener('load', () => {
166
146
  context?.drawImage(img, 0, 0);
167
- const png = canvas.toDataURL('image/png', 1);
168
- // @ts-expect-error write exists in some browsers
169
- if (navigator.clipboard.write) {
170
- copyBlobToClipboard(canvas);
171
- }
172
- else {
173
- copyDataURLClipboardFireFox(png);
174
- }
175
- URL.revokeObjectURL(png);
147
+ copyBlobToClipboard(canvas);
176
148
  });
177
149
  img.src = url;
178
150
  }
@@ -186,7 +158,7 @@ function copyPNGToClipboard(rootRef, elementID) {
186
158
  }
187
159
  }
188
160
  function getBlob(rootRef, elementID) {
189
- let _svg = rootRef.getRootNode()
161
+ const _svg = rootRef.getRootNode()
190
162
  .querySelector(`#${elementID}`)
191
163
  ?.cloneNode(true);
192
164
  const width = Number(_svg?.getAttribute('width').replace('px', ''));
@@ -234,4 +206,4 @@ function getMoleculesElement(rootRef) {
234
206
  }
235
207
  return floatingMoleculesGroup;
236
208
  }
237
- export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, copyTextToClipboard, copyHTMLToClipboard, exportAsMol, exportAsMatrix, getBlob, };
209
+ export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, exportAsMol, exportAsMatrix, getBlob, };
@@ -15,7 +15,7 @@ function lookForObjectsPaths(obj, path, output) {
15
15
  path = [];
16
16
  }
17
17
  else {
18
- for (let key in obj) {
18
+ for (const key in obj) {
19
19
  lookForObjectsPaths(obj[key], [...path.slice(), key], output);
20
20
  }
21
21
  }
@@ -1,5 +1,5 @@
1
1
  export function getUniqueNuclei(nuclei) {
2
- let uniqueNuclei = {};
2
+ const uniqueNuclei = {};
3
3
  for (const nucleus of nuclei) {
4
4
  const _nuclei = nucleus.split(',');
5
5
  for (const _nucleus of _nuclei) {
@@ -1,5 +1,5 @@
1
1
  export function jpathToArray(jpath, separator = '.') {
2
- let keys = [];
2
+ const keys = [];
3
3
  let key = '';
4
4
  let findSeparator = false;
5
5
  const length = jpath.length;
@@ -5,5 +5,6 @@ declare const _default: {
5
5
  prediction: import("nmr-load-save").InnerWorkspace;
6
6
  assignment: import("nmr-load-save").InnerWorkspace;
7
7
  embedded: import("nmr-load-save").InnerWorkspace;
8
+ simulation: import("nmr-load-save").InnerWorkspace;
8
9
  };
9
10
  export default _default;
@@ -4,6 +4,7 @@ import { embedded } from './embedded';
4
4
  import { exercise } from './exercise';
5
5
  import { prediction } from './prediction';
6
6
  import { process1D } from './process1D';
7
+ import { simulation } from './simulation';
7
8
  export default {
8
9
  exercise,
9
10
  default: basic,
@@ -11,4 +12,5 @@ export default {
11
12
  prediction,
12
13
  assignment,
13
14
  embedded,
15
+ simulation,
14
16
  };
@@ -0,0 +1,2 @@
1
+ import { InnerWorkspace } from 'nmr-load-save';
2
+ export declare const simulation: InnerWorkspace;