nmrium 1.10.1 → 1.11.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/BrushTracker1D.d.ts.map +1 -1
- package/lib/component/1d/BrushTracker1D.js +7 -0
- package/lib/component/1d/BrushTracker1D.js.map +1 -1
- package/lib/component/1d/FloatPublicationString.d.ts.map +1 -1
- package/lib/component/1d/FloatPublicationString.js +1 -1
- package/lib/component/1d/FloatPublicationString.js.map +1 -1
- package/lib/component/1d/FloatingRanges.d.ts.map +1 -1
- package/lib/component/1d/FloatingRanges.js +1 -1
- package/lib/component/1d/FloatingRanges.js.map +1 -1
- package/lib/component/1d/inset/DraggableInset.d.ts.map +1 -1
- package/lib/component/1d/inset/DraggableInset.js +1 -1
- package/lib/component/1d/inset/DraggableInset.js.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +11 -2
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js.map +1 -1
- package/lib/component/elements/NextPrev.d.ts.map +1 -1
- package/lib/component/elements/NextPrev.js +23 -4
- package/lib/component/elements/NextPrev.js.map +1 -1
- package/lib/component/elements/export/utilities/exportOptionValidationSchema.d.ts +1 -1
- package/lib/component/hooks/useExport.d.ts +7 -7
- package/lib/component/hooks/useExport.d.ts.map +1 -1
- package/lib/component/hooks/useExport.js +22 -42
- package/lib/component/hooks/useExport.js.map +1 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts.map +1 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.js +3 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.js.map +1 -1
- package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
- package/lib/component/loader/useLoadFiles.js +81 -86
- package/lib/component/loader/useLoadFiles.js.map +1 -1
- package/lib/component/main/ErrorOverlay.d.ts.map +1 -1
- package/lib/component/main/ErrorOverlay.js +6 -1
- package/lib/component/main/ErrorOverlay.js.map +1 -1
- package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
- package/lib/component/main/InnerNMRiumContents.js +1 -2
- package/lib/component/main/InnerNMRiumContents.js.map +1 -1
- package/lib/component/main/NMRiumViewer.js +1 -1
- package/lib/component/main/NMRiumViewer.js.map +1 -1
- package/lib/component/main/NMRiumViewerWrapper.d.ts.map +1 -1
- package/lib/component/main/NMRiumViewerWrapper.js +11 -3
- package/lib/component/main/NMRiumViewerWrapper.js.map +1 -1
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts +6 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts.map +1 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js +127 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js.map +1 -0
- package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
- package/lib/component/modal/SaveAsModal.js +4 -8
- package/lib/component/modal/SaveAsModal.js.map +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js.map +1 -1
- package/lib/component/modal/changeSum/SelectMolecule.js +4 -1
- package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +71 -16
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
- package/lib/component/panels/Panels.d.ts +0 -9
- package/lib/component/panels/Panels.d.ts.map +1 -1
- package/lib/component/panels/Panels.js +1 -29
- package/lib/component/panels/Panels.js.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.js +4 -3
- package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
- package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
- package/lib/component/reducer/actions/LoadAction.js +6 -0
- package/lib/component/reducer/actions/LoadAction.js.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts +23 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/RangesActions.js.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.js +2 -2
- package/lib/component/reducer/actions/SpectraActions.js.map +1 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts +2 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts.map +1 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js +10 -0
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js.map +1 -1
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts +4 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts.map +1 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js +9 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js.map +1 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +8 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +6 -1
- package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
- package/lib/component/toolbar/ToolBar.d.ts.map +1 -1
- package/lib/component/toolbar/ToolBar.js +6 -7
- package/lib/component/toolbar/ToolBar.js.map +1 -1
- package/lib/component/toolbar/toolbarMenu.d.ts +5 -1
- package/lib/component/toolbar/toolbarMenu.d.ts.map +1 -1
- package/lib/component/toolbar/toolbarMenu.js +1 -1
- package/lib/component/toolbar/toolbarMenu.js.map +1 -1
- package/lib/component/utility/export.d.ts +2 -1
- package/lib/component/utility/export.d.ts.map +1 -1
- package/lib/component/utility/export.js +5 -1
- package/lib/component/utility/export.js.map +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -0
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts.map +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +14 -0
- package/lib/data/data1d/multipleSpectraAnalysis.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +13 -6
- package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
- package/lib/data/molecules/MoleculeManager.d.ts +6 -1
- package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
- package/lib/data/molecules/MoleculeManager.js +3 -2
- package/lib/data/molecules/MoleculeManager.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +36 -36
- package/src/component/1d/BrushTracker1D.tsx +8 -0
- package/src/component/1d/FloatPublicationString.tsx +0 -1
- package/src/component/1d/FloatingRanges.tsx +0 -1
- package/src/component/1d/inset/DraggableInset.tsx +0 -1
- package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +11 -2
- package/src/component/EventsTrackers/KeysListenerTracker.tsx +3 -3
- package/src/component/elements/NextPrev.tsx +28 -4
- package/src/component/hooks/useExport.tsx +34 -64
- package/src/component/hooks/useSetActiveSpectrumAction.ts +3 -2
- package/src/component/loader/useLoadFiles.ts +134 -111
- package/src/component/main/ErrorOverlay.tsx +11 -2
- package/src/component/main/InnerNMRiumContents.tsx +6 -9
- package/src/component/main/NMRiumViewer.tsx +2 -2
- package/src/component/main/NMRiumViewerWrapper.tsx +14 -6
- package/src/component/modal/MoleculeAutoLabelsDatabaseModal.tsx +219 -0
- package/src/component/modal/SaveAsModal.tsx +14 -41
- package/src/component/modal/changeSum/ChangeSumModal.tsx +1 -1
- package/src/component/modal/changeSum/SelectMolecule.tsx +23 -23
- package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +94 -15
- package/src/component/panels/Panels.tsx +1 -53
- package/src/component/panels/hooks/useTogglePanel.ts +4 -3
- package/src/component/reducer/actions/LoadAction.ts +15 -1
- package/src/component/reducer/actions/MoleculeActions.ts +4 -2
- package/src/component/reducer/actions/RangesActions.ts +1 -1
- package/src/component/reducer/actions/SpectraActions.ts +6 -2
- package/src/component/reducer/preferences/actions/analyzeSpectra.ts +16 -0
- package/src/component/reducer/preferences/actions/toggleOpenSplitPanel.ts +18 -0
- package/src/component/reducer/preferences/preferencesReducer.ts +22 -1
- package/src/component/toolbar/ToolBar.tsx +9 -9
- package/src/component/toolbar/toolbarMenu.tsx +13 -2
- package/src/component/utility/export.ts +6 -0
- package/src/data/data1d/multipleSpectraAnalysis.ts +20 -0
- package/src/data/data2d/Spectrum2D/contours.ts +16 -6
- package/src/data/molecules/MoleculeManager.ts +7 -2
- package/src/versionInfo.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import type { NMRiumPanelPreferences } from '@zakodium/nmrium-core';
|
|
3
|
-
import
|
|
4
|
-
import { createContext, memo, useContext, useMemo, useState } from 'react';
|
|
3
|
+
import { memo } from 'react';
|
|
5
4
|
import { FaRegEdit } from 'react-icons/fa';
|
|
6
5
|
import type { ToolbarItemProps } from 'react-science/ui';
|
|
7
6
|
import { Accordion, Toolbar } from 'react-science/ui';
|
|
@@ -21,57 +20,6 @@ const Container = styled.div`
|
|
|
21
20
|
height: 100%;
|
|
22
21
|
width: 100%;
|
|
23
22
|
`;
|
|
24
|
-
interface PanelStateContext {
|
|
25
|
-
openSplitPane: () => void;
|
|
26
|
-
closeSplitPane: () => void;
|
|
27
|
-
isSplitPaneOpen: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const AccordionContext = createContext<PanelStateContext | null>(null);
|
|
31
|
-
|
|
32
|
-
export function usePanelOpenState() {
|
|
33
|
-
const context = useContext(AccordionContext);
|
|
34
|
-
|
|
35
|
-
if (!context) {
|
|
36
|
-
throw new Error('Panel open context must be used within PanelOpenProvider');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return context;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function PanelOpenProviderProvider({
|
|
43
|
-
children,
|
|
44
|
-
}: Required<PropsWithChildren>) {
|
|
45
|
-
const { current } = usePreferences();
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
display: { general = {} },
|
|
49
|
-
} = current;
|
|
50
|
-
// TODO: make sure to move this state to the workspace once the refactoring of nmrium-core is finished.
|
|
51
|
-
const [isSplitPaneOpen, setIsSplitPaneOpen] = useState(
|
|
52
|
-
!general?.hidePanelOnLoad,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const state = useMemo(() => {
|
|
56
|
-
function openSplitPane() {
|
|
57
|
-
setIsSplitPaneOpen(true);
|
|
58
|
-
}
|
|
59
|
-
function closeSplitPane() {
|
|
60
|
-
setIsSplitPaneOpen(false);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
openSplitPane,
|
|
64
|
-
closeSplitPane,
|
|
65
|
-
isSplitPaneOpen,
|
|
66
|
-
};
|
|
67
|
-
}, [isSplitPaneOpen]);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<AccordionContext.Provider value={state}>
|
|
71
|
-
{children}
|
|
72
|
-
</AccordionContext.Provider>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
23
|
|
|
76
24
|
function PanelsInner() {
|
|
77
25
|
const getPanelPreferences = useGetPanelOptions();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { NMRiumPanelPreferences } from '@zakodium/nmrium-core';
|
|
2
2
|
|
|
3
3
|
import { usePreferences } from '../../context/PreferencesContext.js';
|
|
4
|
-
import { usePanelOpenState } from '../Panels.js';
|
|
5
4
|
|
|
6
5
|
export function useTogglePanel() {
|
|
7
6
|
const { dispatch, current } = usePreferences();
|
|
8
|
-
const { isSplitPaneOpen, openSplitPane } = usePanelOpenState();
|
|
9
7
|
|
|
10
8
|
function togglePanel(id: keyof NMRiumPanelPreferences) {
|
|
11
9
|
// TODO: make sure current is not a lie and remove the optional chaining.
|
|
12
10
|
const flag = current?.display?.panels?.[id]?.display;
|
|
11
|
+
const isSplitPaneOpen = !current.display.general?.hidePanelOnLoad;
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
if (!isSplitPaneOpen) {
|
|
14
|
+
dispatch({ type: 'TOGGLE_SPLIT_PANEL', payload: { isOpen: true } });
|
|
15
|
+
}
|
|
15
16
|
|
|
16
17
|
if ((!isSplitPaneOpen && !flag) || isSplitPaneOpen) {
|
|
17
18
|
dispatch({
|
|
@@ -129,7 +129,10 @@ function setData(draft: Draft<State>, input: InputProps | InitiateProps) {
|
|
|
129
129
|
|
|
130
130
|
if (view) {
|
|
131
131
|
const defaultViewState = getDefaultViewState();
|
|
132
|
-
|
|
132
|
+
// TODO: Refactor to find the spectrum index in each call rather than saving it in state.
|
|
133
|
+
// For now, we will clear the activeSpectra and selectReferences
|
|
134
|
+
view.spectra.activeSpectra = {};
|
|
135
|
+
view.spectra.selectReferences = {};
|
|
133
136
|
draft.view = lodashMerge(defaultViewState, view);
|
|
134
137
|
}
|
|
135
138
|
|
|
@@ -289,6 +292,11 @@ function initData(
|
|
|
289
292
|
if (view) {
|
|
290
293
|
const defaultViewState = getDefaultViewState();
|
|
291
294
|
draft.view = lodashMerge(defaultViewState, view);
|
|
295
|
+
draft.view.molecules = Object.fromEntries(
|
|
296
|
+
Object.entries(draft.view.molecules).filter(([id]) =>
|
|
297
|
+
draft.molecules.some((molecule) => molecule.id === id),
|
|
298
|
+
),
|
|
299
|
+
);
|
|
292
300
|
}
|
|
293
301
|
draft.actionType = action.type;
|
|
294
302
|
draft.isLoading = false;
|
|
@@ -332,6 +340,12 @@ function handleLoadDropFiles(draft: Draft<State>, action: LoadDropFilesAction) {
|
|
|
332
340
|
draft.sources = {};
|
|
333
341
|
}
|
|
334
342
|
|
|
343
|
+
draft.view.molecules = Object.fromEntries(
|
|
344
|
+
Object.entries(draft.view.molecules).filter(([id]) =>
|
|
345
|
+
draft.molecules.some((molecule) => molecule.id === id),
|
|
346
|
+
),
|
|
347
|
+
);
|
|
348
|
+
|
|
335
349
|
draft.actionType = type;
|
|
336
350
|
draft.isLoading = false;
|
|
337
351
|
return undefined;
|
|
@@ -33,6 +33,7 @@ interface AddMoleculeProps {
|
|
|
33
33
|
id?: string;
|
|
34
34
|
floatMoleculeOnSave?: boolean;
|
|
35
35
|
defaultMoleculeSettings?: MoleculeView;
|
|
36
|
+
label?: string;
|
|
36
37
|
}
|
|
37
38
|
type AddMoleculeAction = ActionType<'ADD_MOLECULE', AddMoleculeProps>;
|
|
38
39
|
type AddMoleculesAction = ActionType<
|
|
@@ -105,9 +106,10 @@ export type MoleculeActions =
|
|
|
105
106
|
| ToggleMoleculeLabelAction;
|
|
106
107
|
|
|
107
108
|
function addMolecule(draft: Draft<State>, props: AddMoleculeProps) {
|
|
108
|
-
const { molfile, id, floatMoleculeOnSave, defaultMoleculeSettings } =
|
|
109
|
+
const { molfile, id, label, floatMoleculeOnSave, defaultMoleculeSettings } =
|
|
110
|
+
props;
|
|
109
111
|
const isEmpty = draft.molecules.length === 0;
|
|
110
|
-
MoleculeManager.addMolfile(draft.molecules, molfile, id);
|
|
112
|
+
MoleculeManager.addMolfile(draft.molecules, molfile, { id, label });
|
|
111
113
|
|
|
112
114
|
/**
|
|
113
115
|
* if it's the first creation of a molecule after the molecules list was empty,
|
|
@@ -465,7 +465,7 @@ function handleChangeRangesAssignmentLabelsByDiaIds(
|
|
|
465
465
|
for (const signal of signals) {
|
|
466
466
|
if (
|
|
467
467
|
previousAssignment === signal.assignment &&
|
|
468
|
-
uniqueDiaIds.has(
|
|
468
|
+
signal.diaIDs?.some((id) => uniqueDiaIds.has(id))
|
|
469
469
|
) {
|
|
470
470
|
signal.assignment = assignment;
|
|
471
471
|
}
|
|
@@ -82,6 +82,7 @@ type ChangeActiveSpectrumAction = ActionType<
|
|
|
82
82
|
| (string & {});
|
|
83
83
|
|
|
84
84
|
id?: string; // spectrum id
|
|
85
|
+
sortedSpectra?: Spectrum[];
|
|
85
86
|
}
|
|
86
87
|
>;
|
|
87
88
|
type ChangeSpectrumSettingAction = ActionType<
|
|
@@ -292,11 +293,14 @@ function handleChangeActiveSpectrum(
|
|
|
292
293
|
data,
|
|
293
294
|
toolOptions,
|
|
294
295
|
} = draft;
|
|
295
|
-
const { modifier, id } = action.payload;
|
|
296
|
+
const { modifier, id, sortedSpectra } = action.payload;
|
|
296
297
|
const spectra = getActiveSpectra(draft);
|
|
297
298
|
|
|
298
299
|
//get the spectra that its nucleus match the active tab
|
|
299
|
-
const spectraPerNucleus = getSpectraByNucleus(
|
|
300
|
+
const spectraPerNucleus = getSpectraByNucleus(
|
|
301
|
+
activeTab,
|
|
302
|
+
sortedSpectra ?? data,
|
|
303
|
+
);
|
|
300
304
|
|
|
301
305
|
//set of the current active spectra
|
|
302
306
|
let spectraIds = spectra?.map((s) => s.id) || [];
|
|
@@ -6,6 +6,7 @@ import { getMultipleSpectraAnalysisDefaultValues } from '../panelsPreferencesDef
|
|
|
6
6
|
import type {
|
|
7
7
|
AnalyzeSpectraAction,
|
|
8
8
|
ChangeAnalysisColumnValueKeyAction,
|
|
9
|
+
CutSpectraAnalysisAction,
|
|
9
10
|
DeleteAnalysisColumn,
|
|
10
11
|
PreferencesState,
|
|
11
12
|
SetSpectraAnalysisPanelPreferencesAction,
|
|
@@ -34,6 +35,21 @@ export function analyzeSpectra(
|
|
|
34
35
|
columnKey,
|
|
35
36
|
});
|
|
36
37
|
}
|
|
38
|
+
export function cutSpectraAnalysis(
|
|
39
|
+
draft: Draft<PreferencesState>,
|
|
40
|
+
action: CutSpectraAnalysisAction,
|
|
41
|
+
) {
|
|
42
|
+
const currentWorkspacePreferences = getActiveWorkspace(draft);
|
|
43
|
+
const panels = currentWorkspacePreferences.panels;
|
|
44
|
+
const { x, nucleus } = action.payload;
|
|
45
|
+
|
|
46
|
+
if (!panels.multipleSpectraAnalysis) {
|
|
47
|
+
panels.multipleSpectraAnalysis =
|
|
48
|
+
getMultipleSpectraAnalysisDefaultValues(nucleus);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
MultipleAnalysis.cutAnalysis(panels.multipleSpectraAnalysis, nucleus, x);
|
|
52
|
+
}
|
|
37
53
|
|
|
38
54
|
export function changeAnalysisColumnValueKey(
|
|
39
55
|
draft: Draft<PreferencesState>,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Draft } from 'immer';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
PreferencesState,
|
|
5
|
+
ToggleSplitPanelAction,
|
|
6
|
+
} from '../preferencesReducer.ts';
|
|
7
|
+
import { getActiveWorkspace } from '../utilities/getActiveWorkspace.ts';
|
|
8
|
+
|
|
9
|
+
export function toggleOpenSplitPanel(
|
|
10
|
+
draft: Draft<PreferencesState>,
|
|
11
|
+
action: ToggleSplitPanelAction,
|
|
12
|
+
) {
|
|
13
|
+
const currentWorkspacePreferences = getActiveWorkspace(draft);
|
|
14
|
+
const { isOpen } = action.payload || {};
|
|
15
|
+
const generalPreferences = currentWorkspacePreferences.display.general || {};
|
|
16
|
+
generalPreferences.hidePanelOnLoad =
|
|
17
|
+
isOpen ?? !generalPreferences.hidePanelOnLoad;
|
|
18
|
+
}
|
|
@@ -27,6 +27,7 @@ import { addWorkspace } from './actions/addWorkspace.js';
|
|
|
27
27
|
import {
|
|
28
28
|
analyzeSpectra,
|
|
29
29
|
changeAnalysisColumnValueKey,
|
|
30
|
+
cutSpectraAnalysis,
|
|
30
31
|
deleteAnalysisColumn,
|
|
31
32
|
setSpectraAnalysisPanelsPreferences,
|
|
32
33
|
} from './actions/analyzeSpectra.js';
|
|
@@ -54,6 +55,7 @@ import { setPreferences } from './actions/setPreferences.js';
|
|
|
54
55
|
import { setVerticalSplitterPosition } from './actions/setVerticalSplitterPosition.js';
|
|
55
56
|
import { setWorkspace } from './actions/setWorkspace.js';
|
|
56
57
|
import { toggleInformationBlock } from './actions/toggleInformationBlock.js';
|
|
58
|
+
import { toggleOpenSplitPanel } from './actions/toggleOpenSplitPanel.ts';
|
|
57
59
|
import { togglePanel } from './actions/togglePanel.js';
|
|
58
60
|
import { mapWorkspaces } from './utilities/mapWorkspaces.js';
|
|
59
61
|
|
|
@@ -111,6 +113,12 @@ export type AnalyzeSpectraAction = ActionType<
|
|
|
111
113
|
'ANALYZE_SPECTRA',
|
|
112
114
|
{ start: number; end: number; nucleus: string; columnKey?: string }
|
|
113
115
|
>;
|
|
116
|
+
|
|
117
|
+
export type CutSpectraAnalysisAction = ActionType<
|
|
118
|
+
'CUT_SPECTRA_ANALYSIS',
|
|
119
|
+
{ x: number; nucleus: string }
|
|
120
|
+
>;
|
|
121
|
+
|
|
114
122
|
export type ChangeAnalysisColumnValueKeyAction = ActionType<
|
|
115
123
|
'CHANGE_ANALYSIS_COLUMN_VALUE_KEY',
|
|
116
124
|
{ columnKey: string; valueKey: string; nucleus: string }
|
|
@@ -177,6 +185,13 @@ export type ChangeDefaultMoleculeSettingsAction = ActionType<
|
|
|
177
185
|
MoleculeView
|
|
178
186
|
>;
|
|
179
187
|
|
|
188
|
+
export type ToggleSplitPanelAction = ActionType<
|
|
189
|
+
'TOGGLE_SPLIT_PANEL',
|
|
190
|
+
{
|
|
191
|
+
isOpen?: boolean;
|
|
192
|
+
}
|
|
193
|
+
>;
|
|
194
|
+
|
|
180
195
|
export type PreferencesActions =
|
|
181
196
|
| InitPreferencesAction
|
|
182
197
|
| SetPreferencesAction
|
|
@@ -198,7 +213,9 @@ export type PreferencesActions =
|
|
|
198
213
|
| ChangePeaksLabelPositionAction
|
|
199
214
|
| TogglePanelAction
|
|
200
215
|
| ChangeExportACSSettingsAction
|
|
201
|
-
| ChangeDefaultMoleculeSettingsAction
|
|
216
|
+
| ChangeDefaultMoleculeSettingsAction
|
|
217
|
+
| CutSpectraAnalysisAction
|
|
218
|
+
| ToggleSplitPanelAction;
|
|
202
219
|
|
|
203
220
|
export type WorkspaceWithSource = Workspace & { source: WorkSpaceSource };
|
|
204
221
|
type WorkspacesWithSource = Record<string, WorkspaceWithSource>;
|
|
@@ -294,6 +311,8 @@ function innerPreferencesReducer(
|
|
|
294
311
|
return deleteAnalysisColumn(draft, action);
|
|
295
312
|
case 'SET_SPECTRA_ANALYSIS_PREFERENCES':
|
|
296
313
|
return setSpectraAnalysisPanelsPreferences(draft, action);
|
|
314
|
+
case 'CUT_SPECTRA_ANALYSIS':
|
|
315
|
+
return cutSpectraAnalysis(draft, action);
|
|
297
316
|
case 'SET_MATRIX_GENERATION_OPTIONS':
|
|
298
317
|
return setMatrixGenerationOptions(draft, action);
|
|
299
318
|
case 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE':
|
|
@@ -324,6 +343,8 @@ function innerPreferencesReducer(
|
|
|
324
343
|
return changeExportAcsSettings(draft, action);
|
|
325
344
|
case 'CHANGE_DEFAULT_MOLECULE_SETTINGS':
|
|
326
345
|
return changeDefaultMoleculeSettings(draft, action);
|
|
346
|
+
case 'TOGGLE_SPLIT_PANEL':
|
|
347
|
+
return toggleOpenSplitPanel(draft, action);
|
|
327
348
|
|
|
328
349
|
default:
|
|
329
350
|
return draft;
|
|
@@ -53,6 +53,7 @@ import { MetaImportationModal } from '../modal/metaImportation/MetaImportationMo
|
|
|
53
53
|
|
|
54
54
|
import type { MainTool } from './ToolTypes.js';
|
|
55
55
|
import { options } from './ToolTypes.js';
|
|
56
|
+
import type { ExportMenuItems } from './toolbarMenu.js';
|
|
56
57
|
import { EXPORT_MENU, IMPORT_MENU } from './toolbarMenu.js';
|
|
57
58
|
|
|
58
59
|
interface BaseToolItem extends Pick<ToolbarItemProps, 'icon' | 'disabled'> {
|
|
@@ -161,7 +162,7 @@ export default function ToolBar() {
|
|
|
161
162
|
});
|
|
162
163
|
}, [dispatch]);
|
|
163
164
|
|
|
164
|
-
const {
|
|
165
|
+
const { defaultSaveAsHandler } = useExport();
|
|
165
166
|
|
|
166
167
|
const exportViewportAPI = useExportManagerAPI();
|
|
167
168
|
|
|
@@ -183,16 +184,16 @@ export default function ToolBar() {
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
function exportHandler(data:
|
|
187
|
-
|
|
187
|
+
function exportHandler(data: ExportMenuItems[number]['data']) {
|
|
188
|
+
const id = data?.id;
|
|
189
|
+
|
|
190
|
+
switch (id) {
|
|
188
191
|
case 'svg':
|
|
189
|
-
exportViewportAPI.current?.export({ format: 'svg' });
|
|
190
|
-
break;
|
|
191
192
|
case 'png':
|
|
192
|
-
exportViewportAPI.current?.export({ format:
|
|
193
|
+
exportViewportAPI.current?.export({ format: id });
|
|
193
194
|
break;
|
|
194
|
-
case '
|
|
195
|
-
|
|
195
|
+
case 'nmrium_archive':
|
|
196
|
+
defaultSaveAsHandler();
|
|
196
197
|
break;
|
|
197
198
|
case 'advance_save':
|
|
198
199
|
openDialog('saveAs');
|
|
@@ -206,7 +207,6 @@ export default function ToolBar() {
|
|
|
206
207
|
case 'exportAsJcamp':
|
|
207
208
|
openDialog('exportAsJcamp');
|
|
208
209
|
break;
|
|
209
|
-
|
|
210
210
|
default:
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
@@ -39,7 +39,18 @@ const IMPORT_MENU: ToolbarPopoverMenuItem[] = [
|
|
|
39
39
|
},
|
|
40
40
|
] as const;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
type ExportMenuItemsId =
|
|
43
|
+
| 'nmrium_archive'
|
|
44
|
+
| 'advance_save'
|
|
45
|
+
| 'svg'
|
|
46
|
+
| 'png'
|
|
47
|
+
| 'copy'
|
|
48
|
+
| 'nmre'
|
|
49
|
+
| 'exportAsJcamp';
|
|
50
|
+
export type ExportMenuItems = Array<
|
|
51
|
+
ToolbarPopoverMenuItem<{ id: ExportMenuItemsId }>
|
|
52
|
+
>;
|
|
53
|
+
const EXPORT_MENU: ExportMenuItems = [
|
|
43
54
|
{
|
|
44
55
|
icon: <FaFileDownload />,
|
|
45
56
|
text: 'Save data',
|
|
@@ -48,7 +59,7 @@ const EXPORT_MENU: ToolbarPopoverMenuItem[] = [
|
|
|
48
59
|
shortcuts: ['CTRL', 's'],
|
|
49
60
|
},
|
|
50
61
|
data: {
|
|
51
|
-
id: '
|
|
62
|
+
id: 'nmrium_archive',
|
|
52
63
|
},
|
|
53
64
|
},
|
|
54
65
|
{
|
|
@@ -420,10 +420,16 @@ function getBlob(targetElementID: string, options: GetBlobOptions): BlobObject {
|
|
|
420
420
|
return { blob, width, height };
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
function exportAsMolfile(molText: string, fileName: string) {
|
|
424
|
+
const blob = new Blob([molText], { type: 'text/plain' });
|
|
425
|
+
saveAs({ blob, name: fileName, extension: '.mol' });
|
|
426
|
+
}
|
|
427
|
+
|
|
423
428
|
export {
|
|
424
429
|
copyPNGToClipboard,
|
|
425
430
|
exportAsJsonBlob,
|
|
426
431
|
exportAsMatrix,
|
|
432
|
+
exportAsMolfile,
|
|
427
433
|
exportAsPng,
|
|
428
434
|
exportAsSVG,
|
|
429
435
|
getBlob,
|
|
@@ -33,6 +33,26 @@ export interface SpectraAnalysisData {
|
|
|
33
33
|
values: Array<Record<string, AnalyzeSpectraCalculateResult>>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function cutAnalysis(
|
|
37
|
+
spectraAnalysis: PanelsPreferences['multipleSpectraAnalysis'],
|
|
38
|
+
nucleus: string,
|
|
39
|
+
x: number,
|
|
40
|
+
) {
|
|
41
|
+
const cutColumns: Record<string, SpectraAnalysisColumn> = {};
|
|
42
|
+
|
|
43
|
+
const analysisOptions = spectraAnalysis[nucleus].analysisOptions;
|
|
44
|
+
for (const [columnKey, column] of Object.entries(analysisOptions.columns)) {
|
|
45
|
+
const { to, from } = column;
|
|
46
|
+
if (x > from && x < to) {
|
|
47
|
+
cutColumns[columnKey] = { ...column, from: x, to };
|
|
48
|
+
const newKey = generateChar(analysisOptions.columnIndex).toUpperCase();
|
|
49
|
+
cutColumns[newKey] = { ...column, from, to: x };
|
|
50
|
+
analysisOptions.columnIndex++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
analysisOptions.columns = { ...analysisOptions.columns, ...cutColumns };
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
function addColumnKey(
|
|
37
57
|
spectraAnalysis: PanelsPreferences['multipleSpectraAnalysis'],
|
|
38
58
|
nucleus: string,
|
|
@@ -66,16 +66,26 @@ function getDefaultContoursLevel(spectrum: Spectrum2D, quadrant = 'rr') {
|
|
|
66
66
|
const minAllowed = 3 * xMaxAbsoluteValue([positive, negative]);
|
|
67
67
|
|
|
68
68
|
const minLevel = Math.max(minAbsPeakBase, minAllowed);
|
|
69
|
-
const minContourLevel =
|
|
69
|
+
const minContourLevel = Math.min(
|
|
70
|
+
calculateValueOfLevel(minLevel, max, true),
|
|
71
|
+
DEFAULT_CONTOURS_OPTIONS.positive.contourLevels[1] -
|
|
72
|
+
DEFAULT_CONTOURS_OPTIONS.positive.numberOfLayers,
|
|
73
|
+
);
|
|
70
74
|
|
|
71
75
|
const defaultLevel: ContourOptions = {
|
|
72
76
|
negative: {
|
|
73
|
-
numberOfLayers:
|
|
74
|
-
contourLevels: [
|
|
77
|
+
numberOfLayers: DEFAULT_CONTOURS_OPTIONS.negative.numberOfLayers,
|
|
78
|
+
contourLevels: [
|
|
79
|
+
minContourLevel,
|
|
80
|
+
DEFAULT_CONTOURS_OPTIONS.negative.contourLevels[1],
|
|
81
|
+
],
|
|
75
82
|
},
|
|
76
83
|
positive: {
|
|
77
|
-
numberOfLayers:
|
|
78
|
-
contourLevels: [
|
|
84
|
+
numberOfLayers: DEFAULT_CONTOURS_OPTIONS.positive.numberOfLayers,
|
|
85
|
+
contourLevels: [
|
|
86
|
+
minContourLevel,
|
|
87
|
+
DEFAULT_CONTOURS_OPTIONS.positive.contourLevels[1],
|
|
88
|
+
],
|
|
79
89
|
},
|
|
80
90
|
};
|
|
81
91
|
return defaultLevel;
|
|
@@ -154,7 +164,7 @@ function prepareCheckLevel(options: ContourOptions) {
|
|
|
154
164
|
}
|
|
155
165
|
|
|
156
166
|
function getRange(min: number, max: number, length: number, exp?: number) {
|
|
157
|
-
if (exp !== undefined) {
|
|
167
|
+
if (exp !== undefined && length > 0) {
|
|
158
168
|
const factors = new Float64Array(length + 1);
|
|
159
169
|
|
|
160
170
|
for (let i = 1; i < length + 1; i++) {
|
|
@@ -35,11 +35,16 @@ export function fromJSON(
|
|
|
35
35
|
return molecules;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
interface AddMolfileOptions {
|
|
39
|
+
id?: string;
|
|
40
|
+
label?: string;
|
|
41
|
+
}
|
|
38
42
|
export function addMolfile(
|
|
39
43
|
molecules: StateMoleculeExtended[],
|
|
40
44
|
molfile: string,
|
|
41
|
-
|
|
45
|
+
options: AddMolfileOptions,
|
|
42
46
|
) {
|
|
47
|
+
const { id, label } = options;
|
|
43
48
|
const reservedNumbers = extractLabelsNumbers(molecules);
|
|
44
49
|
|
|
45
50
|
// try to parse molfile
|
|
@@ -48,7 +53,7 @@ export function addMolfile(
|
|
|
48
53
|
molecules.push(
|
|
49
54
|
initMolecule({
|
|
50
55
|
molfile: molecule.toMolfileV3(),
|
|
51
|
-
label: `P${getLabelNumber(reservedNumbers)}`,
|
|
56
|
+
label: label ?? `P${getLabelNumber(reservedNumbers)}`,
|
|
52
57
|
id,
|
|
53
58
|
}),
|
|
54
59
|
);
|
package/src/versionInfo.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v1.
|
|
1
|
+
export default { version: 'v1.11.0' };
|