nmrium 0.47.0 → 0.49.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/Chart1D.js +1 -1
- package/lib/component/1d/Line.js +1 -1
- package/lib/component/1d/LinesSeries.d.ts +1 -1
- package/lib/component/1d/LinesSeries.js +24 -3
- package/lib/component/1d/SpectraLegends.js +1 -1
- package/lib/component/1d/Viewer1D.js +144 -124
- package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/ranges/Atoms.d.ts +7 -0
- package/lib/component/1d/ranges/Atoms.js +43 -0
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/BaseLine.d.ts +2 -0
- package/lib/component/1d/tool/BaseLine.js +26 -0
- package/lib/component/1d/tool/BaseLineZones.js +18 -3
- package/lib/component/1d/utilities/scale.d.ts +1 -0
- package/lib/component/1d/utilities/scale.js +2 -1
- package/lib/component/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +14 -3
- package/lib/component/context/KeyModifierContext.js +35 -4
- package/lib/component/context/LoggerContext.d.ts +9 -0
- package/lib/component/context/LoggerContext.js +21 -7
- package/lib/component/context/PreferencesContext.d.ts +1 -108
- package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
- package/lib/component/context/TopicMoleculeContext.js +30 -0
- package/lib/component/elements/Input.js +4 -1
- package/lib/component/elements/ResizerWithScale.js +19 -2
- package/lib/component/elements/SVGGroup.js +2 -2
- package/lib/component/elements/formik/FormikTextarea.js +8 -9
- package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
- package/lib/component/elements/resizer/SVGResizer.js +1 -1
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib/component/hooks/useExport.js +2 -2
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
- package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
- package/lib/component/hooks/useToolsFunctions.js +4 -2
- package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
- package/lib/component/main/InnerNMRium.js +3 -2
- package/lib/component/modal/ExportAsJcampModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +76 -32
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +28 -40
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
- package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
- package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/DomainActions.js +2 -2
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +93 -57
- package/lib/component/reducer/actions/LoadActions.js +10 -8
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +8 -4
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +45 -26
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +1 -16
- package/lib/component/workspaces/simulation.js +1 -2
- package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
- package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/index.js +0 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { BaselineCorrectionZone } from 'nmr-processing';
|
|
2
3
|
import { Nucleus } from '../../../data/types/common/Nucleus';
|
|
3
4
|
import { Layout } from '../../2d/utilities/DimensionLayout';
|
|
4
5
|
import { Tool } from '../../toolbar/ToolTypes';
|
|
@@ -25,6 +26,7 @@ type AddBaseLineZoneAction = ActionType<'ADD_BASE_LINE_ZONE', {
|
|
|
25
26
|
startX: number;
|
|
26
27
|
endX: number;
|
|
27
28
|
}>;
|
|
29
|
+
type ResizeBaseLineZoneAction = ActionType<'RESIZE_BASE_LINE_ZONE', BaselineCorrectionZone>;
|
|
28
30
|
type DeleteBaseLineZoneAction = ActionType<'DELETE_BASE_LINE_ZONE', {
|
|
29
31
|
id: string;
|
|
30
32
|
}>;
|
|
@@ -45,18 +47,19 @@ type LevelChangeAction = ActionType<'SET_2D_LEVEL', {
|
|
|
45
47
|
deltaY: number;
|
|
46
48
|
shiftKey: boolean;
|
|
47
49
|
}>;
|
|
48
|
-
export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
|
|
50
|
+
export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | ResizeBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
|
|
49
51
|
declare function handleResetSelectedTool(draft: Draft<State>): void;
|
|
50
|
-
declare function resetSelectedTool(draft: Draft<State
|
|
52
|
+
declare function resetSelectedTool(draft: Draft<State>): void;
|
|
51
53
|
interface ActivateToolOptions {
|
|
52
|
-
toolId:
|
|
54
|
+
toolId: Tool;
|
|
53
55
|
reset?: boolean;
|
|
54
56
|
}
|
|
55
|
-
declare function activateTool(draft:
|
|
57
|
+
declare function activateTool(draft: Draft<State>, options: ActivateToolOptions): void;
|
|
56
58
|
declare function setSelectedTool(draft: Draft<State>, action: SetSelectedToolAction): void;
|
|
57
59
|
declare function setSpectrumsVerticalAlign(draft: Draft<State>): void;
|
|
58
60
|
declare function handleChangeSpectrumDisplayMode(draft: Draft<State>): void;
|
|
59
61
|
declare function handleAddBaseLineZone(draft: Draft<State>, action: AddBaseLineZoneAction): void;
|
|
62
|
+
declare function handleResizeBaseLineZone(draft: Draft<State>, action: ResizeBaseLineZoneAction): void;
|
|
60
63
|
declare function handleDeleteBaseLineZone(draft: Draft<State>, action: DeleteBaseLineZoneAction): void;
|
|
61
64
|
declare function handleToggleRealImaginaryVisibility(draft: Draft<State>): void;
|
|
62
65
|
declare function handleBrushEnd(draft: Draft<State>, action: BrushEndAction): void;
|
|
@@ -69,4 +72,4 @@ declare function handelSetActiveTab(draft: Draft<State>, action: SetActiveTabAct
|
|
|
69
72
|
declare function levelChangeHandler(draft: Draft<State>, action: LevelChangeAction): void;
|
|
70
73
|
declare function setSpectraSameTopHandler(draft: Draft<State>): void;
|
|
71
74
|
declare function resetSpectraScale(draft: Draft<State>): void;
|
|
72
|
-
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
75
|
+
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
|
-
import { original } from 'immer';
|
|
3
2
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
4
3
|
import { getYScale, getXScale } from '../../1d/utilities/scale';
|
|
5
4
|
import { LAYOUT } from '../../2d/utilities/DimensionLayout';
|
|
@@ -18,10 +17,10 @@ import { getVerticalAlign } from '../helper/getVerticalAlign';
|
|
|
18
17
|
import { setIntegralsViewProperty } from '../helper/setIntegralsViewProperty';
|
|
19
18
|
import { setRangesViewProperty } from '../helper/setRangesViewProperty';
|
|
20
19
|
import { setDomain, setMode } from './DomainActions';
|
|
21
|
-
import { calculateBaseLineCorrection,
|
|
20
|
+
import { calculateBaseLineCorrection, rollbackSpectrum, } from './FiltersActions';
|
|
22
21
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
23
22
|
function resetTool(draft, options = {}) {
|
|
24
|
-
const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom',
|
|
23
|
+
const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom', reset, toolId, } = options;
|
|
25
24
|
// reset temp range
|
|
26
25
|
if (resetFiltersOptionPanel) {
|
|
27
26
|
draft.toolOptions.selectedOptionPanel = null;
|
|
@@ -29,58 +28,58 @@ function resetTool(draft, options = {}) {
|
|
|
29
28
|
if (resetToDefaultTool) {
|
|
30
29
|
draft.toolOptions.selectedTool = defaultToolId;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let rollOptions = { reset: true };
|
|
32
|
+
if (toolId && Tools?.[toolId]?.isFilter) {
|
|
33
|
+
rollOptions = { filterKey: toolId, reset };
|
|
35
34
|
}
|
|
35
|
+
rollbackSpectrum(draft, rollOptions);
|
|
36
36
|
}
|
|
37
37
|
function handleResetSelectedTool(draft) {
|
|
38
38
|
resetSelectedTool(draft);
|
|
39
39
|
}
|
|
40
|
-
function resetSelectedTool(draft
|
|
41
|
-
if (
|
|
42
|
-
Tools[draft.toolOptions.selectedTool].isFilter)
|
|
43
|
-
|
|
44
|
-
resetTool(draft, { resetSpectrum: true });
|
|
40
|
+
function resetSelectedTool(draft) {
|
|
41
|
+
if (draft.toolOptions.selectedTool &&
|
|
42
|
+
Tools[draft.toolOptions.selectedTool].isFilter) {
|
|
43
|
+
resetTool(draft, { reset: true, toolId: draft.toolOptions.selectedTool });
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
//utility
|
|
48
47
|
function activateTool(draft, options) {
|
|
49
48
|
const { toolId, reset = false } = options;
|
|
50
|
-
if (draft?.data.length
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
draft.
|
|
72
|
-
if (
|
|
73
|
-
|
|
49
|
+
if (draft?.data.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!toolId || toolId !== draft.toolOptions.selectedTool || reset) {
|
|
53
|
+
resetTool(draft, { resetToDefaultTool: false, toolId, reset });
|
|
54
|
+
}
|
|
55
|
+
if (!toolId || reset) {
|
|
56
|
+
draft.toolOptions.selectedOptionPanel = null;
|
|
57
|
+
draft.toolOptions.selectedTool = 'zoom';
|
|
58
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
draft.toolOptions.selectedTool = toolId;
|
|
62
|
+
if (Tools[toolId]?.hasOptionPanel) {
|
|
63
|
+
draft.toolOptions.selectedOptionPanel = toolId;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// start Range edit mode
|
|
67
|
+
if (toolId === Tools.editRange.id) {
|
|
68
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
69
|
+
if (activeSpectrum) {
|
|
70
|
+
const range = draft.view.ranges?.[activeSpectrum?.id];
|
|
71
|
+
if (range) {
|
|
72
|
+
range.showMultiplicityTrees = true;
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
else {
|
|
75
|
+
draft.view.ranges[activeSpectrum.id] = {
|
|
76
|
+
...defaultRangesViewState,
|
|
77
|
+
showMultiplicityTrees: true,
|
|
78
|
+
};
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
else {
|
|
80
|
-
resetTool(draft, { resetToDefaultTool: false });
|
|
81
|
-
}
|
|
82
|
-
setMargin(draft);
|
|
83
81
|
}
|
|
82
|
+
setMargin(draft);
|
|
84
83
|
}
|
|
85
84
|
function setSelectedTool(draft, action) {
|
|
86
85
|
const { selectedTool } = action.payload;
|
|
@@ -128,11 +127,19 @@ function handleAddBaseLineZone(draft, action) {
|
|
|
128
127
|
draft.toolOptions.data.baselineCorrection.zones = zones.slice();
|
|
129
128
|
calculateBaseLineCorrection(draft);
|
|
130
129
|
}
|
|
130
|
+
function handleResizeBaseLineZone(draft, action) {
|
|
131
|
+
const { from, to, id } = action.payload;
|
|
132
|
+
const zones = draft.toolOptions.data.baselineCorrection.zones;
|
|
133
|
+
const zoneIndex = zones.findIndex((zone) => zone.id === id);
|
|
134
|
+
if (zoneIndex !== -1) {
|
|
135
|
+
zones[zoneIndex] = { id, from, to };
|
|
136
|
+
}
|
|
137
|
+
calculateBaseLineCorrection(draft);
|
|
138
|
+
}
|
|
131
139
|
function handleDeleteBaseLineZone(draft, action) {
|
|
132
140
|
const { id } = action.payload;
|
|
133
|
-
const state = original(draft);
|
|
134
141
|
draft.toolOptions.data.baselineCorrection.zones =
|
|
135
|
-
|
|
142
|
+
draft.toolOptions.data.baselineCorrection.zones.filter((zone) => zone.id !== id);
|
|
136
143
|
calculateBaseLineCorrection(draft);
|
|
137
144
|
}
|
|
138
145
|
function handleToggleRealImaginaryVisibility(draft) {
|
|
@@ -437,4 +444,4 @@ function resetSpectraScale(draft) {
|
|
|
437
444
|
draft.yDomain = draft.originDomain.yDomain;
|
|
438
445
|
setZoom(draft, { scale: 0.8 });
|
|
439
446
|
}
|
|
440
|
-
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
447
|
+
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
2
|
import { State, VerticalAlignment } from '../Reducer';
|
|
3
|
-
export declare function getVerticalAlign(state: State | Draft<State>, defaultAlign?: VerticalAlignment):
|
|
3
|
+
export declare function getVerticalAlign(state: State | Draft<State>, defaultAlign?: VerticalAlignment): VerticalAlignment;
|
|
@@ -12,16 +12,12 @@ const getSpectraDefaultValues = (nucleus) => {
|
|
|
12
12
|
visible: true,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
name: 'name',
|
|
16
15
|
label: 'Spectrum Name',
|
|
17
|
-
description: 'Spectrum Name',
|
|
18
16
|
jpath: ['info', 'name'],
|
|
19
17
|
visible: true,
|
|
20
18
|
},
|
|
21
19
|
{
|
|
22
|
-
name: 'solvent',
|
|
23
20
|
label: 'Solvent',
|
|
24
|
-
description: 'Solvent',
|
|
25
21
|
jpath: ['info', 'solvent'],
|
|
26
22
|
visible: true,
|
|
27
23
|
},
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { SvgNmrRealImag, SvgNmrOverlay3, SvgNmrOverlay3Aligned, SvgNmrAlignBottom, SvgNmrAlignCenter, } from 'cheminfo-font';
|
|
3
|
-
import {
|
|
3
|
+
import { memo } from 'react';
|
|
4
4
|
import { FaDownload, FaFileDownload, FaFileImage, FaCopy, FaFileExport, FaFile, FaFileImport, } from 'react-icons/fa';
|
|
5
5
|
import { Toolbar, useOnOff } from 'react-science/ui';
|
|
6
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
7
|
import { useLoader } from '../context/LoaderContext';
|
|
8
8
|
import { DropdownMenu } from '../elements/DropdownMenu';
|
|
9
|
-
import { useModal } from '../elements/popup/Modal';
|
|
10
9
|
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
11
10
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
12
11
|
import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
|
|
@@ -34,7 +33,7 @@ const IMPORT_MENU = [
|
|
|
34
33
|
},
|
|
35
34
|
{
|
|
36
35
|
icon: _jsx(FaFile, {}),
|
|
37
|
-
text: '
|
|
36
|
+
text: 'Generate spectrum from publication string',
|
|
38
37
|
data: {
|
|
39
38
|
id: 'importPublicationString',
|
|
40
39
|
},
|
|
@@ -92,12 +91,12 @@ const EXPORT_MENU = [
|
|
|
92
91
|
},
|
|
93
92
|
];
|
|
94
93
|
function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
95
|
-
const modal = useModal();
|
|
96
94
|
const openLoader = useLoader();
|
|
97
95
|
const openMetaInformationModal = useMetaInformationImportationModal();
|
|
98
96
|
const isExperimentalFeature = useCheckExperimentalFeature();
|
|
99
97
|
const isButtonVisible = useCheckToolsVisibility();
|
|
100
|
-
const [
|
|
98
|
+
const [isLoadJCAMPModalOpened, openLoadJCAMPModal, closeLoadJCAMPModal] = useOnOff(false);
|
|
99
|
+
const [isPublicationStringModalOpened, openPublicationStringModal, closePublicationStringModal,] = useOnOff(false);
|
|
101
100
|
const importMenu = isExperimentalFeature
|
|
102
101
|
? IMPORT_MENU
|
|
103
102
|
: IMPORT_MENU.filter((item) => item.id !== 'importPublicationString');
|
|
@@ -106,35 +105,24 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
|
106
105
|
: EXPORT_MENU.filter((item) => item.id !== 'nmre');
|
|
107
106
|
const { isRealSpectrumShown, changeSpectrumViewHandler, changeDisplayViewModeHandler, alignSpectrumsVerticallyHandler, } = useToolsFunctions();
|
|
108
107
|
const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, saveAsHandler, } = useExport();
|
|
109
|
-
|
|
110
|
-
openLoadModal();
|
|
111
|
-
}, [openLoadModal]);
|
|
112
|
-
const openImportPublicationStringModal = useCallback(() => {
|
|
113
|
-
modal.show(_jsx(ImportPublicationStringModal, { onClose: () => modal.close() }), {});
|
|
114
|
-
}, [modal]);
|
|
115
|
-
const importHandler = useCallback((data) => {
|
|
108
|
+
function importHandler(data) {
|
|
116
109
|
switch (data?.id) {
|
|
117
110
|
case 'importFile':
|
|
118
111
|
openLoader();
|
|
119
112
|
break;
|
|
120
113
|
case 'importJDX':
|
|
121
|
-
|
|
114
|
+
openLoadJCAMPModal();
|
|
122
115
|
break;
|
|
123
116
|
case 'importPublicationString':
|
|
124
|
-
|
|
117
|
+
openPublicationStringModal();
|
|
125
118
|
break;
|
|
126
119
|
case 'importMetaInformation':
|
|
127
120
|
openMetaInformationModal();
|
|
128
121
|
break;
|
|
129
122
|
default:
|
|
130
123
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
importJCAMPFile,
|
|
134
|
-
openImportPublicationStringModal,
|
|
135
|
-
openMetaInformationModal,
|
|
136
|
-
]);
|
|
137
|
-
const exportHandler = useCallback((data) => {
|
|
124
|
+
}
|
|
125
|
+
function exportHandler(data) {
|
|
138
126
|
switch (data?.id) {
|
|
139
127
|
case 'svg':
|
|
140
128
|
void saveAsSVGHandler();
|
|
@@ -154,14 +142,8 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
|
154
142
|
default:
|
|
155
143
|
break;
|
|
156
144
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
saveAsPNGHandler,
|
|
160
|
-
saveAsJSONHandler,
|
|
161
|
-
saveAsHandler,
|
|
162
|
-
saveToClipboardHandler,
|
|
163
|
-
]);
|
|
164
|
-
return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
|
|
145
|
+
}
|
|
146
|
+
return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadJCAMPModalOpened, onCloseDialog: closeLoadJCAMPModal }), _jsx(ImportPublicationStringModal, { isOpen: isPublicationStringModalOpened, onClose: closePublicationStringModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
|
|
165
147
|
importHandler(data);
|
|
166
148
|
}, targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: importMenu, children: _jsx(Toolbar.Item, { id: options.import.id, title: options.import.label, icon: _jsx(FaFileImport, {}) }) })), isButtonVisible('exportAs') && (_jsx(DropdownMenu, { onSelect: (data) => {
|
|
167
149
|
exportHandler(data);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import { SpectraTableColumn } from 'nmr-load-save';
|
|
2
3
|
/**
|
|
3
4
|
* export the experiments result in JSON format
|
|
4
5
|
* @param data
|
|
@@ -7,7 +8,7 @@ import { SerializedStyles } from '@emotion/react';
|
|
|
7
8
|
* @param isCompressed
|
|
8
9
|
*/
|
|
9
10
|
declare function exportAsJSON(data: any, fileName?: string, spaceIndent?: number, isCompressed?: boolean): Promise<void>;
|
|
10
|
-
declare function exportAsMatrix(data: any, fileName?: string): void;
|
|
11
|
+
declare function exportAsMatrix(data: any, spectraColumns: SpectraTableColumn[], fileName?: string): void;
|
|
11
12
|
declare function exportAsNMRE(data: any, fileName?: string): void;
|
|
12
13
|
declare function exportAsMol(data: any, fileName?: string): void;
|
|
13
14
|
/**
|
|
@@ -15,7 +16,7 @@ declare function exportAsMol(data: any, fileName?: string): void;
|
|
|
15
16
|
*/
|
|
16
17
|
declare function exportAsSVG(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
17
18
|
declare function exportAsPng(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
18
|
-
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): void
|
|
19
|
+
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): Promise<void>;
|
|
19
20
|
export interface BlobObject {
|
|
20
21
|
blob: Blob;
|
|
21
22
|
width: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveAs } from 'file-saver';
|
|
2
2
|
import JSZip from 'jszip';
|
|
3
|
-
import
|
|
3
|
+
import lodashGet from 'lodash/get';
|
|
4
4
|
/**
|
|
5
5
|
* export the experiments result in JSON format
|
|
6
6
|
* @param data
|
|
@@ -33,16 +33,29 @@ async function exportAsJSON(data, fileName = 'experiment', spaceIndent = 0, isCo
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function exportAsMatrix(data, fileName = 'experiment') {
|
|
36
|
+
function exportAsMatrix(data, spectraColumns, fileName = 'experiment') {
|
|
37
37
|
//columns labels
|
|
38
|
-
const
|
|
38
|
+
const columnsLabels = [];
|
|
39
|
+
// listed the spectra panel columns
|
|
40
|
+
for (const col of spectraColumns) {
|
|
41
|
+
if (col.visible && 'jpath' in col) {
|
|
42
|
+
columnsLabels.push(col.label);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
39
45
|
for (const value of data[0].data.x) {
|
|
40
|
-
|
|
46
|
+
columnsLabels.push(value);
|
|
41
47
|
}
|
|
42
|
-
let matrix = `${
|
|
48
|
+
let matrix = `${columnsLabels.join('\t')}\n`;
|
|
43
49
|
for (const spectrum of data) {
|
|
44
|
-
const { data: { re },
|
|
45
|
-
const cellsValues = [
|
|
50
|
+
const { data: { re }, } = spectrum;
|
|
51
|
+
const cellsValues = [];
|
|
52
|
+
// listed the spectra cell values
|
|
53
|
+
for (const col of spectraColumns) {
|
|
54
|
+
if (col.visible && 'jpath' in col) {
|
|
55
|
+
const jpath = col?.jpath;
|
|
56
|
+
cellsValues.push(lodashGet(spectrum, jpath, `null`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
46
59
|
for (const value of re) {
|
|
47
60
|
cellsValues.push(value);
|
|
48
61
|
}
|
|
@@ -107,29 +120,32 @@ function copyDataURLClipboardFireFox(image) {
|
|
|
107
120
|
document.execCommand('Copy');
|
|
108
121
|
img.remove();
|
|
109
122
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
123
|
+
async function resolveBlob(b) {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
resolve(b);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function writeImageToClipboard(image, isSafari = false) {
|
|
129
|
+
await navigator.clipboard.write([
|
|
130
|
+
new ClipboardItem({ [image.type]: isSafari ? resolveBlob(image) : image }),
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
async function copyBlobToClipboard(canvas) {
|
|
134
|
+
canvas.toBlob(async (b) => {
|
|
112
135
|
if (!b)
|
|
113
136
|
return;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})()
|
|
120
|
-
.catch(() => {
|
|
137
|
+
const isSafari = /^(?<safari>(?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
138
|
+
if (typeof ClipboardItem !== 'undefined') {
|
|
139
|
+
await writeImageToClipboard(b, isSafari).catch(reportError);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
121
142
|
const png = canvas.toDataURL('image/png', 1);
|
|
122
143
|
copyDataURLClipboardFireFox(png);
|
|
123
144
|
URL.revokeObjectURL(png);
|
|
124
|
-
}
|
|
125
|
-
.then(() => {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
|
-
console.log('experiment copied.');
|
|
128
|
-
})
|
|
129
|
-
.catch(reportError);
|
|
145
|
+
}
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
function copyPNGToClipboard(rootRef, elementID, css) {
|
|
148
|
+
async function copyPNGToClipboard(rootRef, elementID, css) {
|
|
133
149
|
const { blob, width, height } = getBlob(rootRef, elementID, css);
|
|
134
150
|
try {
|
|
135
151
|
const canvas = document.createElement('canvas');
|
|
@@ -142,16 +158,16 @@ function copyPNGToClipboard(rootRef, elementID, css) {
|
|
|
142
158
|
}
|
|
143
159
|
const img = new Image();
|
|
144
160
|
const url = URL.createObjectURL(blob);
|
|
145
|
-
img.addEventListener('load', () => {
|
|
161
|
+
img.addEventListener('load', async () => {
|
|
146
162
|
context?.drawImage(img, 0, 0);
|
|
147
|
-
copyBlobToClipboard(canvas);
|
|
163
|
+
await copyBlobToClipboard(canvas);
|
|
148
164
|
});
|
|
149
165
|
img.src = url;
|
|
150
166
|
}
|
|
151
167
|
catch (error) {
|
|
152
168
|
if (error instanceof ReferenceError) {
|
|
153
169
|
// eslint-disable-next-line no-alert
|
|
154
|
-
alert('Your browser does not support this feature, please use Google Chrome');
|
|
170
|
+
alert('Your browser does not support this feature, please use Google Chrome or Firefox');
|
|
155
171
|
}
|
|
156
172
|
// TODO: handle error.
|
|
157
173
|
reportError(error);
|
|
@@ -170,6 +186,9 @@ function getBlob(rootRef, elementID, css) {
|
|
|
170
186
|
const floatingMoleculesGroup = getMoleculesElement(rootRef);
|
|
171
187
|
_svg.append(floatingMoleculesGroup);
|
|
172
188
|
const nmrCss = `
|
|
189
|
+
* {
|
|
190
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
191
|
+
}
|
|
173
192
|
.grid line,.grid path{stroke:none;} .peaks-text{fill:#730000} .x path{stroke-width:1px} .x text{
|
|
174
193
|
font-size: 12px;
|
|
175
194
|
font-weight: bold;
|
|
@@ -7,6 +7,7 @@ export const prediction = {
|
|
|
7
7
|
verticalSplitterCloseThreshold: 600,
|
|
8
8
|
spectraRendering: 'auto',
|
|
9
9
|
loggingLevel: 'info',
|
|
10
|
+
popupLoggingLevel: 'error',
|
|
10
11
|
invert: false,
|
|
11
12
|
},
|
|
12
13
|
display: {
|
|
@@ -59,9 +60,7 @@ export const prediction = {
|
|
|
59
60
|
visible: true,
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
|
-
name: 'name',
|
|
63
63
|
label: 'Spectrum Name',
|
|
64
|
-
description: 'Spectrum Name',
|
|
65
64
|
jpath: ['info', 'name'],
|
|
66
65
|
visible: true,
|
|
67
66
|
},
|
|
@@ -72,9 +71,7 @@ export const prediction = {
|
|
|
72
71
|
visible: true,
|
|
73
72
|
},
|
|
74
73
|
{
|
|
75
|
-
name: 'solvent',
|
|
76
74
|
label: 'Solvent',
|
|
77
|
-
description: 'Solvent',
|
|
78
75
|
jpath: ['info', 'solvent'],
|
|
79
76
|
visible: false,
|
|
80
77
|
},
|
|
@@ -105,9 +102,7 @@ export const prediction = {
|
|
|
105
102
|
visible: true,
|
|
106
103
|
},
|
|
107
104
|
{
|
|
108
|
-
name: 'name',
|
|
109
105
|
label: 'Spectrum Name',
|
|
110
|
-
description: 'Spectrum Name',
|
|
111
106
|
jpath: ['info', 'name'],
|
|
112
107
|
visible: true,
|
|
113
108
|
},
|
|
@@ -118,9 +113,7 @@ export const prediction = {
|
|
|
118
113
|
visible: true,
|
|
119
114
|
},
|
|
120
115
|
{
|
|
121
|
-
name: 'solvent',
|
|
122
116
|
label: 'Solvent',
|
|
123
|
-
description: 'Solvent',
|
|
124
117
|
jpath: ['info', 'solvent'],
|
|
125
118
|
visible: false,
|
|
126
119
|
},
|
|
@@ -151,9 +144,7 @@ export const prediction = {
|
|
|
151
144
|
visible: true,
|
|
152
145
|
},
|
|
153
146
|
{
|
|
154
|
-
name: 'name',
|
|
155
147
|
label: 'Spectrum Name',
|
|
156
|
-
description: 'Spectrum Name',
|
|
157
148
|
jpath: ['info', 'name'],
|
|
158
149
|
visible: true,
|
|
159
150
|
},
|
|
@@ -164,9 +155,7 @@ export const prediction = {
|
|
|
164
155
|
visible: true,
|
|
165
156
|
},
|
|
166
157
|
{
|
|
167
|
-
name: 'solvent',
|
|
168
158
|
label: 'Solvent',
|
|
169
|
-
description: 'Solvent',
|
|
170
159
|
jpath: ['info', 'solvent'],
|
|
171
160
|
visible: false,
|
|
172
161
|
},
|
|
@@ -197,9 +186,7 @@ export const prediction = {
|
|
|
197
186
|
visible: true,
|
|
198
187
|
},
|
|
199
188
|
{
|
|
200
|
-
name: 'name',
|
|
201
189
|
label: 'Spectrum Name',
|
|
202
|
-
description: 'Spectrum Name',
|
|
203
190
|
jpath: ['info', 'name'],
|
|
204
191
|
visible: true,
|
|
205
192
|
},
|
|
@@ -210,9 +197,7 @@ export const prediction = {
|
|
|
210
197
|
visible: true,
|
|
211
198
|
},
|
|
212
199
|
{
|
|
213
|
-
name: 'solvent',
|
|
214
200
|
label: 'Solvent',
|
|
215
|
-
description: 'Solvent',
|
|
216
201
|
jpath: ['info', 'solvent'],
|
|
217
202
|
visible: false,
|
|
218
203
|
},
|
|
@@ -7,6 +7,7 @@ export const simulation = {
|
|
|
7
7
|
verticalSplitterCloseThreshold: 600,
|
|
8
8
|
spectraRendering: 'auto',
|
|
9
9
|
loggingLevel: 'info',
|
|
10
|
+
popupLoggingLevel: 'error',
|
|
10
11
|
invert: false,
|
|
11
12
|
},
|
|
12
13
|
display: {
|
|
@@ -42,9 +43,7 @@ export const simulation = {
|
|
|
42
43
|
visible: true,
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
|
-
name: 'name',
|
|
46
46
|
label: 'Spectrum Name',
|
|
47
|
-
description: 'Spectrum Name',
|
|
48
47
|
jpath: ['info', 'name'],
|
|
49
48
|
visible: true,
|
|
50
49
|
},
|
|
@@ -57,6 +57,7 @@ export const workspaceDefaultProperties = {
|
|
|
57
57
|
verticalSplitterCloseThreshold: 600,
|
|
58
58
|
spectraRendering: 'auto',
|
|
59
59
|
loggingLevel: 'info',
|
|
60
|
+
popupLoggingLevel: 'error',
|
|
60
61
|
invert: false,
|
|
61
62
|
},
|
|
62
63
|
formatting: {
|
|
@@ -95,15 +96,15 @@ export const workspaceDefaultProperties = {
|
|
|
95
96
|
infoBlock: {
|
|
96
97
|
visible: false,
|
|
97
98
|
fields: [
|
|
98
|
-
{ label: '
|
|
99
|
+
{ label: 'Name', jpath: ['info', 'name'], visible: true, format: '' },
|
|
99
100
|
{
|
|
100
|
-
label: 'Number
|
|
101
|
+
label: 'Number of scans',
|
|
101
102
|
jpath: ['info', 'numberOfScans'],
|
|
102
103
|
visible: true,
|
|
103
104
|
format: '0',
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
|
-
label: 'Pulse
|
|
107
|
+
label: 'Pulse sequence',
|
|
107
108
|
jpath: ['info', 'pulseSequence'],
|
|
108
109
|
visible: true,
|
|
109
110
|
format: '',
|