nmrium 0.38.2 → 0.40.1
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/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib/component/NMRium.d.ts +1 -0
- package/lib/component/NMRium.js +4 -2
- package/lib/component/context/LoggerContext.js +12 -2
- package/lib/component/context/PreferencesContext.d.ts +4 -2
- package/lib/component/elements/formik/FormikError.d.ts +8 -0
- package/lib/component/elements/formik/FormikError.js +22 -0
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +7 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +24 -0
- package/lib/component/elements/popup/Alert/Provider.js +2 -20
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- package/lib/component/modal/PredictSpectraModal.js +12 -2
- package/lib/component/modal/editRange/EditRangeModal.d.ts +7 -6
- package/lib/component/modal/editRange/EditRangeModal.js +33 -13
- package/lib/component/modal/setting/GeneralSettings.js +29 -28
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -16
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +1 -1
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib/component/reducer/actions/DomainActions.js +3 -0
- package/lib/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib/component/reducer/actions/ToolsActions.js +3 -32
- package/lib/component/reducer/actions/ZonesActions.js +2 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +8 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +35 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/utility/export.d.ts +5 -4
- package/lib/component/utility/export.js +24 -52
- package/lib/data/PredictionManager.d.ts +3 -1
- package/lib/data/PredictionManager.js +27 -1
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- 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/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib-cjs/component/NMRium.js +4 -2
- package/lib-cjs/component/context/LoggerContext.js +11 -1
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +30 -0
- package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -20
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/header/Header.js +2 -2
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- package/lib-cjs/component/modal/PredictSpectraModal.js +12 -2
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +32 -12
- package/lib-cjs/component/modal/setting/GeneralSettings.js +29 -28
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +17 -15
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib-cjs/component/panels/Panels.js +2 -2
- 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/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -0
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib-cjs/component/reducer/actions/ToolsActions.js +26 -32
- package/lib-cjs/component/reducer/actions/ZonesActions.js +2 -4
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +37 -0
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/component/utility/export.js +24 -54
- package/lib-cjs/data/PredictionManager.js +27 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- 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 +17 -17
- package/lib/component/header/LogsHistory.d.ts +0 -1
|
@@ -57,31 +57,28 @@ export default function useEditRangeModal(range) {
|
|
|
57
57
|
modal.close();
|
|
58
58
|
}
|
|
59
59
|
}, [assignmentData, dispatch, modal]);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
deleteRange(range.id, true);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
saveEditRangeHandler(originalRange, false);
|
|
66
|
-
}
|
|
60
|
+
const resetHandler = useCallback((originalRange) => {
|
|
61
|
+
saveEditRangeHandler(originalRange, false);
|
|
67
62
|
modal.close();
|
|
68
|
-
}, [
|
|
69
|
-
const editRange = useCallback((
|
|
63
|
+
}, [modal, saveEditRangeHandler]);
|
|
64
|
+
const editRange = useCallback(() => {
|
|
65
|
+
if (!range?.id)
|
|
66
|
+
return;
|
|
70
67
|
dispatch({
|
|
71
68
|
type: 'SET_SELECTED_TOOL',
|
|
72
69
|
payload: { selectedTool: 'editRange' },
|
|
73
70
|
});
|
|
74
|
-
modal.show(_jsx(EditRangeModal, {
|
|
71
|
+
modal.show(_jsx(EditRangeModal, { onRest: resetHandler, onSave: saveEditRangeHandler, onZoom: zoomRange, rangeId: range?.id }), {
|
|
75
72
|
position: positions.MIDDLE_RIGHT,
|
|
76
73
|
transition: transitions.SCALE,
|
|
77
74
|
isBackgroundBlur: false,
|
|
78
75
|
});
|
|
79
76
|
zoomRange();
|
|
80
77
|
}, [
|
|
81
|
-
closeEditRangeHandler,
|
|
82
78
|
dispatch,
|
|
83
79
|
modal,
|
|
84
|
-
range,
|
|
80
|
+
range?.id,
|
|
81
|
+
resetHandler,
|
|
85
82
|
saveEditRangeHandler,
|
|
86
83
|
zoomRange,
|
|
87
84
|
]);
|
|
@@ -4,12 +4,13 @@ import { useMemo, useCallback, useState } from 'react';
|
|
|
4
4
|
import { FaCopy, FaRegTrashAlt, FaFileExport } from 'react-icons/fa';
|
|
5
5
|
import { IoColorPaletteOutline } from 'react-icons/io5';
|
|
6
6
|
import { DropdownMenu } from 'react-science/ui';
|
|
7
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
8
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
7
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
8
10
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
9
11
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
12
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
11
13
|
import ExportAsJcampModal from '../../modal/ExportAsJcampModal';
|
|
12
|
-
import { copyTextToClipboard } from '../../utility/export';
|
|
13
14
|
import ColorIndicator from './base/ColorIndicator';
|
|
14
15
|
import ShowHideSpectrumButton from './base/ShowHideSpectrumButton';
|
|
15
16
|
import { SpectrumName } from './base/SpectrumName';
|
|
@@ -130,19 +131,15 @@ export function SpectraTable(props) {
|
|
|
130
131
|
},
|
|
131
132
|
},
|
|
132
133
|
}), [onChangeVisibility, onOpenSettingModal]);
|
|
134
|
+
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = useClipboard();
|
|
133
135
|
const selectContextMenuHandler = useCallback((option, spectrum) => {
|
|
134
136
|
const { id } = option.data;
|
|
135
137
|
switch (id) {
|
|
136
138
|
case SpectraContextMenuOptionsKeys.CopyToClipboard: {
|
|
137
139
|
void (async () => {
|
|
138
140
|
const { data, info } = spectrum;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
alert.success('Data copied to clipboard');
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
alert.error('Copy to clipboard failed');
|
|
145
|
-
}
|
|
141
|
+
await rawWriteWithType(JSON.stringify({ data, info }, (_, value) => ArrayBuffer.isView(value) ? Array.from(value) : value, 2));
|
|
142
|
+
alert.success('Data copied to clipboard');
|
|
146
143
|
})();
|
|
147
144
|
break;
|
|
148
145
|
}
|
|
@@ -160,7 +157,7 @@ export function SpectraTable(props) {
|
|
|
160
157
|
break;
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
|
-
}, [alert, dispatch]);
|
|
160
|
+
}, [alert, dispatch, rawWriteWithType]);
|
|
164
161
|
function handleActiveRow(row) {
|
|
165
162
|
return activeSpectraObj?.[row?.original.id] || false;
|
|
166
163
|
}
|
|
@@ -214,7 +211,7 @@ export function SpectraTable(props) {
|
|
|
214
211
|
? Spectra1DContextMenuOptions
|
|
215
212
|
: Spectra2DContextMenuOptions, onContextMenuSelect: selectContextMenuHandler, onSortEnd: handleSortEnd, style: { 'table td': { paddingTop: 0, paddingBottom: 0 } } }), exportedSpectrum && (_jsx(ExportAsJcampModal, { spectrum: exportedSpectrum, closeDialog: () => {
|
|
216
213
|
setExportedSpectrum(null);
|
|
217
|
-
} }))] }));
|
|
214
|
+
} })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra" })] }));
|
|
218
215
|
}
|
|
219
216
|
const ColumnHeader = ({ label, col, }) => {
|
|
220
217
|
const dispatch = useDispatch();
|
|
@@ -6,6 +6,7 @@ import { useAccordionContext } from 'react-science/ui';
|
|
|
6
6
|
import { predictSpectra } from '../../../data/PredictionManager';
|
|
7
7
|
import { useChartData } from '../../context/ChartContext';
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
|
+
import { useLogger } from '../../context/LoggerContext';
|
|
9
10
|
import Button from '../../elements/Button';
|
|
10
11
|
import NextPrev from '../../elements/NextPrev';
|
|
11
12
|
import { useAlert } from '../../elements/popup/Alert';
|
|
@@ -31,6 +32,7 @@ export default function PredictionPanel() {
|
|
|
31
32
|
const { molecules, view: { molecules: moleculesView, predictions }, } = useChartData();
|
|
32
33
|
const dispatch = useDispatch();
|
|
33
34
|
const alert = useAlert();
|
|
35
|
+
const { logger } = useLogger();
|
|
34
36
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
35
37
|
const [molfile, setMolfile] = useState(null);
|
|
36
38
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
@@ -70,7 +72,7 @@ export default function PredictionPanel() {
|
|
|
70
72
|
}
|
|
71
73
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
72
74
|
try {
|
|
73
|
-
const data = await predictSpectra(molfile);
|
|
75
|
+
const data = await predictSpectra(molfile, logger);
|
|
74
76
|
dispatch({
|
|
75
77
|
type: 'PREDICT_SPECTRA',
|
|
76
78
|
payload: {
|
|
@@ -23,9 +23,11 @@ function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
|
23
23
|
function handleResurrectSpectrumFromRanges(draft, action) {
|
|
24
24
|
const { ranges, info } = action.payload;
|
|
25
25
|
const datum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (datum) {
|
|
27
|
+
draft.data.push(datum);
|
|
28
|
+
setDomain(draft, { isYDomainShared: false });
|
|
29
|
+
setIntegralsYDomain(draft, [datum]);
|
|
30
|
+
setZoom(draft, { scale: 0.8, spectrumID: datum.id });
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
|
|
@@ -3,6 +3,7 @@ import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY';
|
|
|
3
3
|
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
|
|
4
4
|
import nucleusToString from '../../utility/nucleusToString';
|
|
5
5
|
import { DISPLAYER_MODE } from '../core/Constants';
|
|
6
|
+
import { addToBrushHistory } from '../helper/ZoomHistoryManager';
|
|
6
7
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
7
8
|
function getActiveData(draft) {
|
|
8
9
|
let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab &&
|
|
@@ -185,10 +186,12 @@ function setMode(draft) {
|
|
|
185
186
|
function handleSetXDomain(draft, action) {
|
|
186
187
|
const xDomain = action.payload.xDomain;
|
|
187
188
|
draft.xDomain = xDomain;
|
|
189
|
+
addToBrushHistory(draft, { xDomain, yDomain: draft.yDomain });
|
|
188
190
|
}
|
|
189
191
|
//action
|
|
190
192
|
function handleSetYDomain(draft, action) {
|
|
191
193
|
const yDomain = action.payload.yDomain;
|
|
192
194
|
draft.yDomain = yDomain;
|
|
195
|
+
addToBrushHistory(draft, { xDomain: draft.xDomain, yDomain });
|
|
193
196
|
}
|
|
194
197
|
export { getDomain, setDomain, setMode, setIntegralsYDomain, handleSetXDomain, handleSetYDomain, };
|
|
@@ -26,13 +26,15 @@ function handleAddIntegral(draft, action) {
|
|
|
26
26
|
const datum = data[activeSpectrum.index];
|
|
27
27
|
const { x, re } = datum.data;
|
|
28
28
|
const shiftX = getShiftX(datum);
|
|
29
|
+
const integration = xyIntegration({ x, y: re }, { from, to, reverse: true });
|
|
29
30
|
const integral = {
|
|
30
31
|
id: v4(),
|
|
31
32
|
originFrom: from - shiftX,
|
|
32
33
|
originTo: to - shiftX,
|
|
33
34
|
from,
|
|
34
35
|
to,
|
|
35
|
-
|
|
36
|
+
integral: integration,
|
|
37
|
+
absolute: integration,
|
|
36
38
|
kind: 'signal',
|
|
37
39
|
};
|
|
38
40
|
datum.integrals.values.push(integral);
|
|
@@ -6,7 +6,6 @@ import { Filters, FiltersManager } from 'nmr-processing';
|
|
|
6
6
|
import { generateSpectrumFromPublicationString, getReferenceShift, isSpectrum1D, get1DColor, } from '../../../data/data1d/Spectrum1D';
|
|
7
7
|
import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
|
|
8
8
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
9
|
-
import { options } from '../../toolbar/ToolTypes';
|
|
10
9
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
11
10
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
12
11
|
import { setZoom } from '../helper/Zoom1DManager';
|
|
@@ -204,8 +203,7 @@ function handleChangeActiveSpectrum(draft, action) {
|
|
|
204
203
|
setMargin(draft);
|
|
205
204
|
setMode(draft);
|
|
206
205
|
}
|
|
207
|
-
if (
|
|
208
|
-
!toolOptions.data.activeFilterID) {
|
|
206
|
+
if (!toolOptions.data.activeFilterID) {
|
|
209
207
|
resetSelectedTool(draft);
|
|
210
208
|
}
|
|
211
209
|
}
|
|
@@ -292,9 +290,11 @@ function handleAlignSpectraHandler(draft, action) {
|
|
|
292
290
|
function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
|
|
293
291
|
const publicationString = action.payload.publicationText;
|
|
294
292
|
const spectrum = generateSpectrumFromPublicationString(publicationString, draft.usedColors);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
293
|
+
if (spectrum) {
|
|
294
|
+
draft.data.push(spectrum);
|
|
295
|
+
setActiveTab(draft);
|
|
296
|
+
setZoom(draft, { scale: 0.8, spectrumID: spectrum.id });
|
|
297
|
+
}
|
|
298
298
|
}
|
|
299
299
|
//action
|
|
300
300
|
function handleImportSpectraMetaInfo(draft, action) {
|
|
@@ -11,7 +11,7 @@ import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
|
11
11
|
import { rangeStateInit } from '../Reducer';
|
|
12
12
|
import { DISPLAYER_MODE, MARGIN } from '../core/Constants';
|
|
13
13
|
import { setZoom, wheelZoom, ZOOM_TYPES, } from '../helper/Zoom1DManager';
|
|
14
|
-
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
14
|
+
import zoomHistoryManager, { addToBrushHistory, } from '../helper/ZoomHistoryManager';
|
|
15
15
|
import { getActiveSpectra } from '../helper/getActiveSpectra';
|
|
16
16
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
17
17
|
import { getVerticalAlign } from '../helper/getVerticalAlign';
|
|
@@ -145,7 +145,7 @@ function handleToggleRealImaginaryVisibility(draft) {
|
|
|
145
145
|
}
|
|
146
146
|
function handleBrushEnd(draft, action) {
|
|
147
147
|
const is2D = draft.displayerMode === DISPLAYER_MODE.DM_2D;
|
|
148
|
-
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode
|
|
148
|
+
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode } = draft;
|
|
149
149
|
const xScale = getXScale({ width, xDomains, xDomain, mode, margin });
|
|
150
150
|
const verticalAlign = getVerticalAlign(draft);
|
|
151
151
|
const yScale = is2D
|
|
@@ -158,36 +158,7 @@ function handleBrushEnd(draft, action) {
|
|
|
158
158
|
const endY = yScale.invert(_endY);
|
|
159
159
|
const domainX = startX > endX ? [endX, startX] : [startX, endX];
|
|
160
160
|
const domainY = startY > endY ? [endY, startY] : [startY, endY];
|
|
161
|
-
|
|
162
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
163
|
-
draft.zoom.history,
|
|
164
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
165
|
-
draft.view.spectra.activeTab);
|
|
166
|
-
if (displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
167
|
-
switch (trackID) {
|
|
168
|
-
case 'CENTER_2D':
|
|
169
|
-
draft.xDomain = domainX;
|
|
170
|
-
draft.yDomain = domainY;
|
|
171
|
-
break;
|
|
172
|
-
case 'TOP_1D':
|
|
173
|
-
draft.xDomain = domainX;
|
|
174
|
-
break;
|
|
175
|
-
case 'LEFT_1D':
|
|
176
|
-
draft.yDomain = domainY;
|
|
177
|
-
break;
|
|
178
|
-
default:
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
if (brushHistory) {
|
|
182
|
-
brushHistory.push({ xDomain, yDomain });
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
draft.xDomain = domainX;
|
|
187
|
-
if (brushHistory) {
|
|
188
|
-
brushHistory.push({ xDomain: domainX, yDomain: domainY });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
161
|
+
addToBrushHistory(draft, { trackID, xDomain: domainX, yDomain: domainY });
|
|
191
162
|
}
|
|
192
163
|
function setVerticalIndicatorXPosition(draft, action) {
|
|
193
164
|
const { position } = action.payload;
|
|
@@ -53,10 +53,8 @@ function handleAutoZonesDetection(draft, action) {
|
|
|
53
53
|
function handleAutoSpectraZonesDetection(draft) {
|
|
54
54
|
for (const datum of draft.data) {
|
|
55
55
|
const { info, data } = datum;
|
|
56
|
-
if (info.dimension === 2) {
|
|
57
|
-
const { minX, maxX, minY, maxY } =
|
|
58
|
-
? data.re
|
|
59
|
-
: data.rr;
|
|
56
|
+
if (info.dimension === 2 && info.isFt) {
|
|
57
|
+
const { minX, maxX, minY, maxY } = data.rr;
|
|
60
58
|
const detectionOptions = {
|
|
61
59
|
selectedZone: { fromX: minX, toX: maxX, fromY: minY, toY: maxY },
|
|
62
60
|
thresholdFactor: 1,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { Layout } from '../../2d/utilities/DimensionLayout';
|
|
3
|
+
import { State } from '../Reducer';
|
|
1
4
|
interface HistoryItem {
|
|
2
5
|
xDomain: Array<number>;
|
|
3
6
|
yDomain: Array<number>;
|
|
@@ -13,4 +16,9 @@ interface ZoomHistoryManager {
|
|
|
13
16
|
clear: () => void;
|
|
14
17
|
}
|
|
15
18
|
export default function zoomHistoryManager(zoomHistory: ZoomHistory, nucleus: string, baseZoom?: HistoryItem): ZoomHistoryManager;
|
|
19
|
+
export declare function addToBrushHistory(draft: Draft<State>, options: {
|
|
20
|
+
trackID?: Layout | null;
|
|
21
|
+
xDomain: number[];
|
|
22
|
+
yDomain: number[];
|
|
23
|
+
}): void;
|
|
16
24
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DISPLAYER_MODE } from '../core/Constants';
|
|
1
2
|
export default function zoomHistoryManager(zoomHistory, nucleus, baseZoom) {
|
|
2
3
|
if (!zoomHistory[nucleus] && !Array.isArray(zoomHistory[nucleus])) {
|
|
3
4
|
zoomHistory[nucleus] = [];
|
|
@@ -29,3 +30,37 @@ function prepareGetLast(historyStack) {
|
|
|
29
30
|
return historyStack.at(-1);
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
export function addToBrushHistory(draft, options) {
|
|
34
|
+
const { displayerMode } = draft;
|
|
35
|
+
const { trackID, xDomain, yDomain } = options;
|
|
36
|
+
const brushHistory = zoomHistoryManager(
|
|
37
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
38
|
+
draft.zoom.history,
|
|
39
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
40
|
+
draft.view.spectra.activeTab);
|
|
41
|
+
if (displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
42
|
+
switch (trackID) {
|
|
43
|
+
case 'CENTER_2D':
|
|
44
|
+
draft.xDomain = xDomain;
|
|
45
|
+
draft.yDomain = yDomain;
|
|
46
|
+
break;
|
|
47
|
+
case 'TOP_1D':
|
|
48
|
+
draft.xDomain = xDomain;
|
|
49
|
+
break;
|
|
50
|
+
case 'LEFT_1D':
|
|
51
|
+
draft.yDomain = yDomain;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (brushHistory) {
|
|
57
|
+
brushHistory.push({ xDomain, yDomain });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
draft.xDomain = xDomain;
|
|
62
|
+
if (brushHistory) {
|
|
63
|
+
brushHistory.push({ xDomain, yDomain });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -3,12 +3,12 @@ import lodashMerge from 'lodash/merge';
|
|
|
3
3
|
import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
|
|
4
4
|
import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties';
|
|
5
5
|
export function addWorkspace(draft, action) {
|
|
6
|
-
const {
|
|
6
|
+
const { workspaceKey, data } = action.payload;
|
|
7
7
|
const newWorkSpace = lodashMerge({}, workspaceDefaultProperties,
|
|
8
8
|
// eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
|
|
9
9
|
data ? data : draft.workspaces[draft.workspace.current], {
|
|
10
10
|
version: 1,
|
|
11
|
-
label:
|
|
11
|
+
label: workspaceKey,
|
|
12
12
|
source: 'user',
|
|
13
13
|
});
|
|
14
14
|
const newWorkspaceKey = v4();
|
|
@@ -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
|
|
17
|
+
type SetPreferencesAction = ActionType<'SET_PREFERENCES', Partial<Workspace>> | ActionType<'SET_PREFERENCES', void>;
|
|
18
18
|
type SetPanelsPreferencesAction = ActionType<'SET_PANELS_PREFERENCES', {
|
|
19
19
|
key: string;
|
|
20
20
|
value: string;
|
|
@@ -30,7 +30,7 @@ export type WorkspaceAction = ActionType<'REMOVE_WORKSPACE' | 'SET_ACTIVE_WORKSP
|
|
|
30
30
|
workspace: string;
|
|
31
31
|
}>;
|
|
32
32
|
export type AddWorkspaceAction = ActionType<'ADD_WORKSPACE', {
|
|
33
|
-
|
|
33
|
+
workspaceKey: string;
|
|
34
34
|
data?: Omit<Workspace, 'version' | 'label'>;
|
|
35
35
|
}>;
|
|
36
36
|
export type ApplyGeneralPreferences = ActionType<'APPLY_General_PREFERENCES', {
|
|
@@ -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);
|
|
@@ -137,16 +109,24 @@ 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) {
|
|
@@ -162,17 +142,9 @@ function copyPNGToClipboard(rootRef, elementID) {
|
|
|
162
142
|
}
|
|
163
143
|
let 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
|
}
|
|
@@ -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, };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FifoLogger } from 'fifo-logger';
|
|
1
2
|
import { Spectrum } from 'nmr-load-save';
|
|
2
3
|
import { PredictedAll } from 'nmr-processing';
|
|
3
4
|
export type Experiment = 'proton' | 'carbon' | 'cosy' | 'hsqc' | 'hmbc';
|
|
@@ -25,11 +26,12 @@ export interface PredictionOptions {
|
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
spectra: SpectraPredictionOptions;
|
|
29
|
+
logger?: FifoLogger;
|
|
28
30
|
}
|
|
29
31
|
export declare const defaultPredictionOptions: PredictionOptions;
|
|
30
32
|
export declare const FREQUENCIES: Array<{
|
|
31
33
|
value: number;
|
|
32
34
|
label: string;
|
|
33
35
|
}>;
|
|
34
|
-
export declare function predictSpectra(molfile: string): Promise<PredictedAll>;
|
|
36
|
+
export declare function predictSpectra(molfile: string, logger: FifoLogger): Promise<PredictedAll>;
|
|
35
37
|
export declare function generateSpectra(predictedSpectra: PredictedSpectraResult, inputOptions: PredictionOptions, color: string): Spectrum[];
|
|
@@ -26,7 +26,10 @@ export const defaultPredictionOptions = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export const FREQUENCIES = [
|
|
29
|
+
{ value: 40, label: '40 MHz' },
|
|
29
30
|
{ value: 60, label: '60 MHz' },
|
|
31
|
+
{ value: 80, label: '80 MHz' },
|
|
32
|
+
{ value: 90, label: '90 MHz' },
|
|
30
33
|
{ value: 100, label: '100 MHz' },
|
|
31
34
|
{ value: 200, label: '200 MHz' },
|
|
32
35
|
{ value: 300, label: '300 MHz' },
|
|
@@ -38,9 +41,10 @@ export const FREQUENCIES = [
|
|
|
38
41
|
{ value: 1200, label: '1200 MHz' },
|
|
39
42
|
];
|
|
40
43
|
const baseURL = 'https://nmr-prediction.service.zakodium.com';
|
|
41
|
-
export async function predictSpectra(molfile) {
|
|
44
|
+
export async function predictSpectra(molfile, logger) {
|
|
42
45
|
const molecule = OCL.Molecule.fromMolfile(molfile);
|
|
43
46
|
return predictAll(molecule, {
|
|
47
|
+
logger,
|
|
44
48
|
predictOptions: {
|
|
45
49
|
C: {
|
|
46
50
|
webserviceURL: `${baseURL}/v1/predict/carbon`,
|
|
@@ -165,6 +169,7 @@ function generated2DSpectrum(params) {
|
|
|
165
169
|
frequency,
|
|
166
170
|
experiment,
|
|
167
171
|
});
|
|
172
|
+
const spectralWidth = getSpectralWidth(experiment, inputOptions);
|
|
168
173
|
const datum = initiateDatum2D({
|
|
169
174
|
data: { rr: { ...minMaxContent, noise: 0.01 } },
|
|
170
175
|
display: {
|
|
@@ -178,6 +183,7 @@ function generated2DSpectrum(params) {
|
|
|
178
183
|
originFrequency: frequency,
|
|
179
184
|
baseFrequency: frequency,
|
|
180
185
|
pulseSequence: 'prediction',
|
|
186
|
+
spectralWidth,
|
|
181
187
|
experiment,
|
|
182
188
|
},
|
|
183
189
|
}, []);
|
|
@@ -187,6 +193,26 @@ function generated2DSpectrum(params) {
|
|
|
187
193
|
function get2DWidth(nucleus) {
|
|
188
194
|
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
189
195
|
}
|
|
196
|
+
function getSpectralWidth(experiment, options) {
|
|
197
|
+
const formTo = options['1d'];
|
|
198
|
+
switch (experiment) {
|
|
199
|
+
case 'cosy': {
|
|
200
|
+
const { from, to } = formTo['1H'];
|
|
201
|
+
const diff = to - from;
|
|
202
|
+
return [diff, diff];
|
|
203
|
+
}
|
|
204
|
+
case 'hsqc':
|
|
205
|
+
case 'hmbc': {
|
|
206
|
+
const proton = formTo['1H'];
|
|
207
|
+
const carbon = formTo['13C'];
|
|
208
|
+
const protonDiff = proton.to - proton.from;
|
|
209
|
+
const carbonDiff = carbon.to - carbon.from;
|
|
210
|
+
return [protonDiff, carbonDiff];
|
|
211
|
+
}
|
|
212
|
+
default:
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
190
216
|
function calculateFrequency(nucleus, frequency) {
|
|
191
217
|
if (typeof nucleus === 'string') {
|
|
192
218
|
return getFrequency(nucleus, { nucleus: '1H', frequency });
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Spectrum1D } from 'nmr-load-save';
|
|
2
1
|
import { UsedColors } from '../../../types/UsedColors';
|
|
3
|
-
export declare function generateSpectrumFromPublicationString(publicationString: string, usedColors: UsedColors): Spectrum1D;
|
|
2
|
+
export declare function generateSpectrumFromPublicationString(publicationString: string, usedColors: UsedColors): import("nmr-load-save").Spectrum1D | undefined;
|
|
@@ -57,13 +57,20 @@ export default function detectSignal(data, options) {
|
|
|
57
57
|
}
|
|
58
58
|
function joinCouplings(result) {
|
|
59
59
|
const { chemShift: delta, js } = result;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
let jCouplings = js;
|
|
61
|
+
if (js.length > 1) {
|
|
62
|
+
try {
|
|
63
|
+
jCouplings = signalJoinCouplings({
|
|
64
64
|
delta,
|
|
65
65
|
js,
|
|
66
|
-
}, { tolerance: 0.6, ignoreDiaIDs: true }).js
|
|
67
|
-
|
|
66
|
+
}, { tolerance: 0.6, ignoreDiaIDs: true }).js;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
reportError(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
delta,
|
|
74
|
+
js: jCouplings,
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -8,4 +8,4 @@ export interface ResurrectSpectrumInfo {
|
|
|
8
8
|
frequency?: number;
|
|
9
9
|
color?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare function generateSpectrumFromRanges(ranges: NMRRange[], info: ResurrectSpectrumInfo, usedColors: UsedColors): Spectrum1D;
|
|
11
|
+
export declare function generateSpectrumFromRanges(ranges: NMRRange[], info: ResurrectSpectrumInfo, usedColors: UsedColors): Spectrum1D | undefined;
|