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.
- package/lib/component/1d/FooterBanner.js +5 -4
- package/lib/component/1d/Viewer1D.js +121 -104
- package/lib/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +1 -1
- package/lib/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
- package/lib/component/1d/multiplicityTree/TreeColors.d.ts +1 -1
- package/lib/component/1d/multiplicityTree/TreeColors.js +1 -6
- package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +1 -1
- package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
- package/lib/component/1d/tool/BaseLineZones.js +7 -4
- package/lib/component/1d/tool/PeakPointer.js +1 -1
- package/lib/component/1d/utilities/scale.js +1 -3
- package/lib/component/1d-2d/components/FloatMoleculeStructures/index.d.ts +1 -1
- package/lib/component/1d-2d/tools/BrushXY.js +10 -7
- package/lib/component/1d-2d/tools/CrossLinePointer.js +1 -1
- package/lib/component/2d/FooterBanner.js +3 -2
- package/lib/component/2d/Viewer2D.js +51 -29
- package/lib/component/2d/XAxis.js +1 -1
- package/lib/component/2d/YAxis.js +1 -1
- package/lib/component/2d/utilities/SliceScale.d.ts +2 -2
- package/lib/component/2d/utilities/scale.d.ts +5 -5
- package/lib/component/2d/zones/Signal.js +1 -2
- package/lib/component/EventsTrackers/BrushTracker.d.ts +4 -1
- package/lib/component/EventsTrackers/BrushTracker.js +21 -6
- package/lib/component/NMRium.d.ts +2 -2
- package/lib/component/NMRium.js +39 -26
- package/lib/component/assignment/AssignmentsReducer.d.ts +1 -1
- package/lib/component/assignment/actions/setActiveAssignment.js +1 -1
- package/lib/component/context/LoggerContext.js +11 -6
- package/lib/component/elements/InputRange.js +1 -1
- package/lib/component/elements/MenuButton.d.ts +1 -1
- package/lib/component/elements/MoleculeSelection.d.ts +1 -1
- package/lib/component/elements/ReactTable/ReactTable.d.ts +1 -1
- package/lib/component/elements/Tab/DeleteButton.d.ts +1 -1
- package/lib/component/elements/ToolbarMenu.d.ts +1 -1
- package/lib/component/elements/accordion/Accordion.d.ts +1 -1
- package/lib/component/elements/draggable/SVGDraggable.d.ts +1 -1
- package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
- package/lib/component/elements/dropDownButton/DropDownButton.d.ts +1 -1
- package/lib/component/elements/dropDownButton/DropDownList.js +3 -1
- package/lib/component/elements/formik/SelectBox.d.ts +1 -1
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +8 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +30 -0
- package/lib/component/elements/popup/Alert/Context.d.ts +26 -2
- package/lib/component/elements/popup/Alert/Context.js +6 -2
- package/lib/component/elements/popup/Alert/Provider.d.ts +4 -3
- package/lib/component/elements/popup/Alert/Provider.js +5 -23
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib/component/elements/popup/Modal/Provider.js +3 -1
- package/lib/component/elements/popup/options.d.ts +22 -19
- package/lib/component/elements/resizer/Resizer.d.ts +2 -2
- package/lib/component/elements/toggle/ToggleButton.d.ts +2 -2
- package/lib/component/elements/toggle/ToggleButton.js +1 -1
- package/lib/component/header/Header.js +2 -2
- package/lib/component/header/ZeroFillingOptionsPanel.js +3 -8
- package/lib/component/highlight/index.d.ts +1 -1
- package/lib/component/hooks/useCheckToolsVisibility.js +2 -2
- package/lib/component/hooks/useExport.js +2 -1
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
- package/lib/component/hooks/usePanelPreferences.js +2 -2
- package/lib/component/hooks/useXScale.d.ts +1 -1
- package/lib/component/hooks/useXYReduce.d.ts +2 -2
- package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
- package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/AlignSpectraModal.js +11 -1
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- package/lib/component/modal/MultipletAnalysisModal.js +2 -1
- package/lib/component/modal/PredictSpectraModal.d.ts +1 -2
- package/lib/component/modal/PredictSpectraModal.js +25 -28
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -1
- package/lib/component/modal/editZone/SignalsForm.js +1 -1
- package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +28 -27
- package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
- package/lib/component/modal/setting/settingsValidation.js +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.js +4 -7
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +19 -19
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/Panels.js +13 -0
- package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
- package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +1 -1
- package/lib/component/panels/databasePanel/DatabasePanel.d.ts +1 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
- package/lib/component/panels/databasePanel/DatabaseTable.js +1 -1
- package/lib/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
- package/lib/component/panels/extra/utilities/UseToggleStatus.js +1 -1
- package/lib/component/panels/filtersPanel/FiltersTable.js +2 -2
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -2
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -2
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.d.ts +1 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +88 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +11 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +37 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.d.ts +4 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +25 -0
- package/lib/component/panels/spectrumSimulation/SpinSystemTable.d.ts +5 -0
- package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +60 -0
- package/lib/component/reducer/Reducer.d.ts +13 -12
- package/lib/component/reducer/Reducer.js +251 -239
- package/lib/component/reducer/actions/AssignmentsActions.d.ts +1 -1
- package/lib/component/reducer/actions/AssignmentsActions.js +1 -1
- package/lib/component/reducer/actions/DatabaseActions.js +2 -1
- package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
- package/lib/component/reducer/actions/DomainActions.js +30 -1
- package/lib/component/reducer/actions/FiltersActions.js +4 -4
- package/lib/component/reducer/actions/LoadActions.js +1 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -0
- package/lib/component/reducer/actions/MoleculeActions.js +51 -2
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -2
- package/lib/component/reducer/actions/SpectrumsActions.js +43 -4
- package/lib/component/reducer/actions/ToolsActions.js +2 -2
- package/lib/component/reducer/actions/ZonesActions.js +1 -1
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +4 -6
- package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +3 -4
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +5 -1
- package/lib/component/reducer/preferences/utilities/flatObject.js +1 -1
- package/lib/component/toolbar/ToolTypes.d.ts +4 -4
- package/lib/component/utility/export.d.ts +5 -4
- package/lib/component/utility/export.js +33 -61
- package/lib/component/utility/getSpectraObjectPaths.js +1 -1
- package/lib/component/utility/getUniqueNuclei.js +1 -1
- package/lib/component/utility/jpathToArray.js +1 -1
- package/lib/component/workspaces/index.d.ts +1 -0
- package/lib/component/workspaces/index.js +2 -0
- package/lib/component/workspaces/simulation.d.ts +2 -0
- package/lib/component/workspaces/simulation.js +68 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
- package/lib/data/PredictionManager.d.ts +8 -7
- package/lib/data/PredictionManager.js +95 -22
- package/lib/data/SpectraManager.js +1 -1
- package/lib/data/constants/DefaultPathLengths.d.ts +1 -3
- package/lib/data/constants/SignalsKinds.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
- package/lib/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
- package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
- package/lib/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
- package/lib/data/data1d/database.d.ts +5 -5
- package/lib/data/data1d/database.js +3 -3
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +1 -1
- package/lib/data/data1d/spectrumSimulation.d.ts +14 -0
- package/lib/data/data1d/spectrumSimulation.js +53 -0
- package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -4
- package/lib/data/data2d/Spectrum2D/contours.js +7 -1
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
- package/lib/data/data2d/Spectrum2D/getShift.js +1 -1
- package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
- package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
- package/lib/data/getDefaultMatrixFilters.d.ts +2 -2
- package/lib/data/matrixGeneration.js +1 -1
- package/lib/data/molecules/MoleculeManager.d.ts +1 -1
- package/lib/data/molecules/MoleculeManager.js +7 -7
- package/lib/data/parseMeta/linkMetaWithSpectra.js +2 -1
- package/lib/data/types/data1d/MatrixOptions.d.ts +2 -2
- package/lib/data/utilities/FindUtilities.js +4 -4
- package/lib/data/utilities/RangeUtilities.d.ts +1 -1
- package/lib/data/utilities/ZoneUtilities.d.ts +1 -1
- package/lib/data/utilities/calculateSanPlot.js +3 -3
- package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
- package/lib/utils/clipboard/clipboard.d.ts +12 -0
- package/lib/utils/clipboard/clipboard.js +15 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
- package/lib/utils/clipboard/clipboardComponents.js +150 -0
- package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
- package/lib/utils/clipboard/clipboardHooks.js +142 -0
- package/lib/utils/clipboard/types.d.ts +1 -0
- package/lib/utils/clipboard/types.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/FooterBanner.js +5 -4
- package/lib-cjs/component/1d/Viewer1D.js +120 -103
- package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
- package/lib-cjs/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
- package/lib-cjs/component/1d/multiplicityTree/TreeColors.js +1 -6
- package/lib-cjs/component/1d/tool/BaseLineZones.js +6 -3
- package/lib-cjs/component/1d/tool/PeakPointer.js +1 -1
- package/lib-cjs/component/1d/utilities/scale.js +1 -3
- package/lib-cjs/component/1d-2d/tools/BrushXY.js +10 -7
- package/lib-cjs/component/1d-2d/tools/CrossLinePointer.js +1 -1
- package/lib-cjs/component/2d/FooterBanner.js +3 -2
- package/lib-cjs/component/2d/Viewer2D.js +50 -28
- package/lib-cjs/component/2d/XAxis.js +1 -1
- package/lib-cjs/component/2d/YAxis.js +1 -1
- package/lib-cjs/component/2d/zones/Signal.js +1 -2
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +21 -6
- package/lib-cjs/component/NMRium.js +37 -24
- package/lib-cjs/component/assignment/actions/setActiveAssignment.js +1 -1
- package/lib-cjs/component/context/LoggerContext.js +10 -5
- package/lib-cjs/component/elements/InputRange.js +1 -1
- package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +36 -0
- package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
- package/lib-cjs/component/elements/popup/Alert/Provider.js +4 -22
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
- package/lib-cjs/component/header/Header.js +2 -2
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -8
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +2 -2
- package/lib-cjs/component/hooks/useExport.js +2 -1
- package/lib-cjs/component/hooks/usePanelPreferences.js +1 -1
- package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +54 -0
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- package/lib-cjs/component/modal/MultipletAnalysisModal.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +24 -27
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +1 -1
- package/lib-cjs/component/modal/editZone/SignalsForm.js +1 -1
- package/lib-cjs/component/modal/metaImportation/MetaImportationModal.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +28 -27
- package/lib-cjs/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
- package/lib-cjs/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/settingsValidation.js +2 -2
- package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -18
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/Panels.js +13 -0
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
- package/lib-cjs/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
- package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +1 -1
- package/lib-cjs/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
- package/lib-cjs/component/panels/extra/utilities/UseToggleStatus.js +1 -1
- package/lib-cjs/component/panels/filtersPanel/FiltersTable.js +2 -2
- package/lib-cjs/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -2
- package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -1
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +94 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +42 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +31 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpinSystemTable.js +67 -0
- package/lib-cjs/component/reducer/Reducer.js +251 -239
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +1 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -1
- package/lib-cjs/component/reducer/actions/DomainActions.js +31 -1
- package/lib-cjs/component/reducer/actions/FiltersActions.js +4 -4
- package/lib-cjs/component/reducer/actions/LoadActions.js +1 -1
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +54 -2
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +43 -3
- package/lib-cjs/component/reducer/actions/ToolsActions.js +2 -2
- package/lib-cjs/component/reducer/actions/ZonesActions.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +3 -4
- package/lib-cjs/component/reducer/preferences/preferencesReducer.js +5 -1
- package/lib-cjs/component/reducer/preferences/utilities/flatObject.js +1 -1
- package/lib-cjs/component/utility/export.js +33 -63
- package/lib-cjs/component/utility/getSpectraObjectPaths.js +1 -1
- package/lib-cjs/component/utility/getUniqueNuclei.js +1 -1
- package/lib-cjs/component/utility/jpathToArray.js +1 -1
- package/lib-cjs/component/workspaces/index.js +2 -0
- package/lib-cjs/component/workspaces/simulation.js +71 -0
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -0
- package/lib-cjs/data/PredictionManager.js +96 -22
- package/lib-cjs/data/SpectraManager.js +1 -1
- package/lib-cjs/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
- package/lib-cjs/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
- package/lib-cjs/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
- package/lib-cjs/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
- package/lib-cjs/data/data1d/database.js +3 -3
- package/lib-cjs/data/data1d/multipleSpectraAnalysis.js +1 -1
- package/lib-cjs/data/data1d/spectrumSimulation.js +58 -0
- package/lib-cjs/data/data2d/Spectrum2D/contours.js +7 -1
- package/lib-cjs/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
- package/lib-cjs/data/data2d/Spectrum2D/getShift.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/getSlice.js +4 -4
- package/lib-cjs/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
- package/lib-cjs/data/matrixGeneration.js +1 -1
- package/lib-cjs/data/molecules/MoleculeManager.js +7 -7
- package/lib-cjs/data/parseMeta/linkMetaWithSpectra.js +2 -1
- package/lib-cjs/data/utilities/FindUtilities.js +4 -4
- package/lib-cjs/data/utilities/calculateSanPlot.js +3 -3
- package/lib-cjs/data/utilities/generateNumbersPowerOfX.js +1 -1
- package/lib-cjs/utils/clipboard/clipboard.js +23 -0
- package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
- package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
- package/lib-cjs/utils/clipboard/types.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +26 -25
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
6
|
-
yDomain:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
6
|
+
const localData = getLocalStorage('nmr-general-settings');
|
|
7
7
|
const currentWorkspacePreferences = getActiveWorkspace(draft);
|
|
8
8
|
if (action.payload) {
|
|
9
|
-
|
|
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'
|
|
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
|
-
|
|
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');
|
|
@@ -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
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
73
|
+
const canvas = document.createElement('canvas');
|
|
102
74
|
canvas.width = width;
|
|
103
75
|
canvas.height = height;
|
|
104
|
-
|
|
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
|
-
|
|
110
|
-
|
|
81
|
+
const img = new Image();
|
|
82
|
+
const url = URL.createObjectURL(blob);
|
|
111
83
|
img.addEventListener('load', () => {
|
|
112
84
|
context?.drawImage(img, 0, 0);
|
|
113
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
}
|
|
147
|
-
|
|
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
|
-
|
|
135
|
+
const canvas = document.createElement('canvas');
|
|
156
136
|
canvas.width = width;
|
|
157
137
|
canvas.height = height;
|
|
158
|
-
|
|
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
|
-
|
|
143
|
+
const img = new Image();
|
|
164
144
|
const url = URL.createObjectURL(blob);
|
|
165
|
-
img.addEventListener('load',
|
|
145
|
+
img.addEventListener('load', () => {
|
|
166
146
|
context?.drawImage(img, 0, 0);
|
|
167
|
-
|
|
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
|
-
|
|
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,
|
|
209
|
+
export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, exportAsMol, exportAsMatrix, getBlob, };
|
|
@@ -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
|
};
|