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
|
@@ -47,9 +47,10 @@ function getMaxLevelLogs(logs, lastReadLogId) {
|
|
|
47
47
|
}
|
|
48
48
|
return { backgroundColor, count: logsCounts[maxLevel] };
|
|
49
49
|
}
|
|
50
|
-
export function
|
|
50
|
+
export function LogsHistoryModal(props) {
|
|
51
|
+
const { autoOpen = false, onClose } = props;
|
|
51
52
|
const { logsHistory, logger, markAsRead, lastReadLogId } = useLogger();
|
|
52
|
-
const [isOpenDialog, openDialog, closeDialog] = useOnOff(
|
|
53
|
+
const [isOpenDialog, openDialog, closeDialog] = useOnOff(autoOpen);
|
|
53
54
|
const { count, backgroundColor } = getMaxLevelLogs(logsHistory, lastReadLogId);
|
|
54
55
|
const COLUMNS = useMemo(() => [
|
|
55
56
|
{
|
|
@@ -88,7 +89,7 @@ export function LogsHistory() {
|
|
|
88
89
|
},
|
|
89
90
|
], [lastReadLogId]);
|
|
90
91
|
const sortedLogs = logsHistory.slice().sort((a, b) => b.time - a.time);
|
|
91
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: () => {
|
|
92
|
+
return (_jsxs(_Fragment, { children: [!autoOpen && (_jsx(Button.BarButton, { onClick: () => {
|
|
92
93
|
openDialog();
|
|
93
94
|
}, children: _jsxs("div", { style: { position: 'relative' }, children: [_jsx(IoBugOutline, { fontSize: "1.4em" }), count && (_jsx("span", { style: {
|
|
94
95
|
position: 'absolute',
|
|
@@ -99,8 +100,9 @@ export function LogsHistory() {
|
|
|
99
100
|
minWidth: '14px',
|
|
100
101
|
fontSize: '0.75em',
|
|
101
102
|
color: 'white',
|
|
102
|
-
}, children: count }))] }) }), _jsxs(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: () => {
|
|
103
|
+
}, children: count }))] }) })), _jsxs(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: () => {
|
|
103
104
|
markAsRead();
|
|
104
105
|
closeDialog();
|
|
106
|
+
onClose?.();
|
|
105
107
|
}, children: [_jsx(Modal.Header, { children: "Logs History " }), _jsx(Modal.Body, { children: _jsx("div", { style: { width: '50vw', height: '50vh', padding: '0.5em' }, children: _jsx(ReactTable, { columns: COLUMNS, data: sortedLogs, emptyDataRowText: "No Logs", rowStyle: handleRowStyle }) }) }), _jsx(Modal.Footer, { children: _jsx(Button.Danger, { onClick: () => logger.clear(), fill: "outline", children: _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(FaRegTrashAlt, {}), _jsx("span", { style: { paddingLeft: '5px' }, children: "Clear Logs" })] }) }) })] })] }));
|
|
106
108
|
}
|
|
@@ -5,6 +5,7 @@ import { useCallback, useRef, useState, useMemo } from 'react';
|
|
|
5
5
|
import { defaultPredictionOptions, predictSpectra, } from '../../data/PredictionManager';
|
|
6
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
7
|
import { useDispatch } from '../context/DispatchContext';
|
|
8
|
+
import { useLogger } from '../context/LoggerContext';
|
|
8
9
|
import Button from '../elements/Button';
|
|
9
10
|
import CheckBox from '../elements/CheckBox';
|
|
10
11
|
import CloseButton from '../elements/CloseButton';
|
|
@@ -53,6 +54,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
53
54
|
name: `Prediction ${predictionIndex + 1}`,
|
|
54
55
|
});
|
|
55
56
|
}, [predictionPreferences, predictionIndex]);
|
|
57
|
+
const { logger } = useLogger();
|
|
56
58
|
const submitHandler = useCallback((values) => {
|
|
57
59
|
void (async () => {
|
|
58
60
|
if (molecule) {
|
|
@@ -66,7 +68,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
66
68
|
}
|
|
67
69
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
68
70
|
try {
|
|
69
|
-
const data = await predictSpectra(molfile);
|
|
71
|
+
const data = await predictSpectra(molfile, logger);
|
|
70
72
|
dispatch({
|
|
71
73
|
type: 'PREDICT_SPECTRA',
|
|
72
74
|
payload: {
|
|
@@ -85,7 +87,15 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
})();
|
|
88
|
-
}, [
|
|
90
|
+
}, [
|
|
91
|
+
alert,
|
|
92
|
+
dispatch,
|
|
93
|
+
isApproved,
|
|
94
|
+
molecule,
|
|
95
|
+
onClose,
|
|
96
|
+
logger,
|
|
97
|
+
setPredictionPreferences,
|
|
98
|
+
]);
|
|
89
99
|
const approveCheckHandler = useCallback((e) => {
|
|
90
100
|
setApproved(e.target.checked);
|
|
91
101
|
}, []);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Range } from 'nmr-processing';
|
|
1
2
|
interface EditRangeModalProps {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
onSave: (value: any) => Promise<void> | null | void;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
onRest: (originalRange: Range) => void;
|
|
6
|
+
onZoom: (value: any) => void;
|
|
7
|
+
rangeId: string;
|
|
7
8
|
}
|
|
8
|
-
declare function EditRangeModal({
|
|
9
|
+
declare function EditRangeModal({ onSave, onClose, onZoom, onRest, rangeId, }: EditRangeModalProps): import("@emotion/react/jsx-runtime").JSX.Element | undefined;
|
|
9
10
|
export default EditRangeModal;
|
|
@@ -4,7 +4,7 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { v4 } from '@lukeed/uuid';
|
|
5
5
|
import { Formik } from 'formik';
|
|
6
6
|
import { splitPatterns, translateMultiplet } from 'nmr-processing';
|
|
7
|
-
import { useMemo, useCallback, useRef } from 'react';
|
|
7
|
+
import { useMemo, useCallback, useRef, useEffect } from 'react';
|
|
8
8
|
import { FaSearchPlus } from 'react-icons/fa';
|
|
9
9
|
import { useChartData } from '../../context/ChartContext';
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
@@ -52,18 +52,36 @@ const styles = css `
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
|
-
function EditRangeModal({
|
|
55
|
+
function EditRangeModal({ onSave, onClose, onZoom, onRest, rangeId, }) {
|
|
56
56
|
const formRef = useRef(null);
|
|
57
57
|
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
58
58
|
const dispatch = useDispatch();
|
|
59
|
+
const range = useRange(rangeId);
|
|
60
|
+
const originalRangeRef = useRef(range);
|
|
59
61
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
60
|
-
const range = useRange(originRange, manualRange);
|
|
61
62
|
const handleOnZoom = useCallback(() => {
|
|
62
|
-
|
|
63
|
-
}, [
|
|
63
|
+
onZoom(range);
|
|
64
|
+
}, [onZoom, range]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: 'SET_SELECTED_TOOL',
|
|
68
|
+
payload: {
|
|
69
|
+
selectedTool: 'zoom',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
if (!range) {
|
|
73
|
+
onClose?.();
|
|
74
|
+
}
|
|
75
|
+
}, [activeTab, dispatch, onClose, range]);
|
|
64
76
|
const handleOnClose = useCallback(() => {
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
dispatch({
|
|
78
|
+
type: 'SET_SELECTED_TOOL',
|
|
79
|
+
payload: {
|
|
80
|
+
selectedTool: 'zoom',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
onRest(originalRangeRef.current);
|
|
84
|
+
}, [dispatch, onRest]);
|
|
67
85
|
const getCouplings = useCallback((couplings) => couplings
|
|
68
86
|
.filter((coupling) => coupling.coupling !== '')
|
|
69
87
|
.map((coupling) => {
|
|
@@ -88,9 +106,9 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
88
106
|
void (async () => {
|
|
89
107
|
const _range = { ...range };
|
|
90
108
|
_range.signals = getSignals(formValues.signals);
|
|
91
|
-
await
|
|
109
|
+
await onSave(_range);
|
|
92
110
|
})();
|
|
93
|
-
}, [getSignals,
|
|
111
|
+
}, [getSignals, onSave, range]);
|
|
94
112
|
const data = useMemo(() => {
|
|
95
113
|
const signals = range?.signals.map((signal) => {
|
|
96
114
|
// counter within j array to access to right j values
|
|
@@ -114,7 +132,7 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
114
132
|
return { ...signal, js: couplings };
|
|
115
133
|
});
|
|
116
134
|
return { activeTab: '0', signals };
|
|
117
|
-
}, [range?.signals, rangesPreferences
|
|
135
|
+
}, [range?.signals, rangesPreferences]);
|
|
118
136
|
const changeHandler = useCallback((values) => {
|
|
119
137
|
const signals = getSignals(values.signals);
|
|
120
138
|
if (JSON.stringify(range?.signals, (key, value) => {
|
|
@@ -131,14 +149,16 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
131
149
|
});
|
|
132
150
|
}
|
|
133
151
|
}, [dispatch, getSignals, range]);
|
|
152
|
+
if (!rangesPreferences || !range) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
134
155
|
return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "header handle", children: [_jsx(Button.Action, { onClick: handleOnZoom, fill: "outline", style: { fontSize: '14' }, color: { base: '#5f5f5f', hover: 'white' }, children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { className: "title", children: ` Range and Signal edition: ${formatNumber(range?.from, rangesPreferences.from.format)} ppm to ${formatNumber(range?.to, rangesPreferences.to.format)} ppm` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), popupTitle: "Save and Exit" }), _jsx(CloseButton, { onClick: handleOnClose })] }), _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: editRangeFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsx(SignalsForm, { range: range, preferences: rangesPreferences }), _jsx(FormikOnChange, { onChange: changeHandler })] }) })] }));
|
|
135
156
|
}
|
|
136
|
-
function useRange(
|
|
157
|
+
function useRange(rangeId) {
|
|
137
158
|
const { ranges } = useSpectrum({
|
|
138
159
|
ranges: { values: [] },
|
|
139
160
|
});
|
|
140
|
-
const
|
|
141
|
-
const index = ranges.values.findIndex((rangeRecord) => rangeRecord.id === id);
|
|
161
|
+
const index = ranges.values.findIndex((rangeRecord) => rangeRecord.id === rangeId);
|
|
142
162
|
return ranges.values[index];
|
|
143
163
|
}
|
|
144
164
|
export default EditRangeModal;
|
|
@@ -5,6 +5,8 @@ import { Formik } from 'formik';
|
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { FaBolt, FaPaste, FaRegCopy, FaWrench } from 'react-icons/fa';
|
|
7
7
|
import { Modal, Toolbar, useOnOff } from 'react-science/ui';
|
|
8
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
9
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
8
10
|
import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
|
|
9
11
|
import ActionButtons from '../../elements/ActionButtons';
|
|
10
12
|
import Button from '../../elements/Button';
|
|
@@ -15,7 +17,6 @@ import DropDownButton from '../../elements/dropDownButton/DropDownButton';
|
|
|
15
17
|
import { useAlert } from '../../elements/popup/Alert';
|
|
16
18
|
import { useSaveSettings } from '../../hooks/useSaveSettings';
|
|
17
19
|
import { getPreferencesByWorkspace } from '../../reducer/preferences/utilities/getPreferencesByWorkspace';
|
|
18
|
-
import { copyTextToClipboard } from '../../utility/export';
|
|
19
20
|
import PredefinedWorkspaces from '../../workspaces';
|
|
20
21
|
import WorkspaceItem from './WorkspaceItem';
|
|
21
22
|
import DatabasesTabContent from './settings-tabs/DatabasesTabContent';
|
|
@@ -28,7 +29,8 @@ import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabConte
|
|
|
28
29
|
import ToolsTabContent from './settings-tabs/ToolsTabContent';
|
|
29
30
|
import { validation } from './settingsValidation';
|
|
30
31
|
const styles = css `
|
|
31
|
-
width:
|
|
32
|
+
width: 50vw;
|
|
33
|
+
min-width: 800px;
|
|
32
34
|
|
|
33
35
|
.main-content {
|
|
34
36
|
width: 100%;
|
|
@@ -133,7 +135,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
133
135
|
dispatch({
|
|
134
136
|
type: 'ADD_WORKSPACE',
|
|
135
137
|
payload: {
|
|
136
|
-
|
|
138
|
+
workspaceKey: name,
|
|
137
139
|
data: refForm.current?.values,
|
|
138
140
|
},
|
|
139
141
|
});
|
|
@@ -175,20 +177,16 @@ function GeneralSettingsModal({ height }) {
|
|
|
175
177
|
function handleDisabledRestButton(values) {
|
|
176
178
|
setRestDisabled(isRestButtonDisable(values, workspaceName, originalWorkspaces));
|
|
177
179
|
}
|
|
180
|
+
const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = useClipboard();
|
|
178
181
|
function handleCopyWorkspace() {
|
|
179
182
|
const data = { [workspaceName]: refForm.current?.values };
|
|
180
|
-
void
|
|
181
|
-
|
|
182
|
-
alert.success('Workspace copied to clipboard');
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
alert.error('copied not completed');
|
|
186
|
-
}
|
|
183
|
+
void rawWriteWithType(JSON.stringify(data)).then(() => {
|
|
184
|
+
alert.success('Workspace copied to clipboard');
|
|
187
185
|
});
|
|
188
186
|
}
|
|
189
187
|
const setWorkspaceSetting = useCallback((inputWorkspace) => {
|
|
190
188
|
const parseWorkspaceName = Object.keys(inputWorkspace)[0];
|
|
191
|
-
if (preferences
|
|
189
|
+
if (preferences.workspace.current === parseWorkspaceName) {
|
|
192
190
|
refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
193
191
|
}
|
|
194
192
|
else if (preferences.workspaces[parseWorkspaceName]) {
|
|
@@ -201,41 +199,44 @@ function GeneralSettingsModal({ height }) {
|
|
|
201
199
|
},
|
|
202
200
|
});
|
|
203
201
|
}
|
|
204
|
-
}, [dispatch, preferences
|
|
205
|
-
function handlePastWorkspace() {
|
|
206
|
-
void navigator.clipboard.readText().then((text) => {
|
|
207
|
-
try {
|
|
208
|
-
const parseWorkspaces = JSON.parse(text);
|
|
209
|
-
setWorkspaceSetting(parseWorkspaces);
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
alert.error('object parse error');
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
202
|
+
}, [dispatch, preferences.workspace, preferences.workspaces]);
|
|
216
203
|
useEffect(() => {
|
|
217
204
|
if (pastRef.current) {
|
|
218
205
|
setWorkspaceSetting(pastRef.current);
|
|
219
206
|
pastRef.current = null;
|
|
220
207
|
}
|
|
221
208
|
}, [setWorkspaceSetting]);
|
|
222
|
-
|
|
209
|
+
function handlePastWorkspace(text) {
|
|
210
|
+
if (!text)
|
|
211
|
+
return;
|
|
212
|
+
try {
|
|
213
|
+
const parseWorkspaces = JSON.parse(text);
|
|
214
|
+
setWorkspaceSetting(parseWorkspaces);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
alert.error('object parse error');
|
|
218
|
+
}
|
|
219
|
+
cleanShouldFallback();
|
|
220
|
+
}
|
|
221
|
+
function handlePastWorkspaceAction() {
|
|
222
|
+
void readText().then(handlePastWorkspace);
|
|
223
|
+
}
|
|
224
|
+
return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings", children: _jsx(FaWrench, {}) }), _jsxs(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, maxWidth: 1000, children: [_jsx(Modal.Header, { children: _jsxs("div", { style: {
|
|
223
225
|
display: 'flex',
|
|
224
226
|
flexDirection: 'column',
|
|
225
|
-
width: '100%',
|
|
226
227
|
}, children: [_jsx("span", { children: "General Settings" }), _jsxs("div", { style: {
|
|
227
228
|
display: 'flex',
|
|
228
229
|
alignItems: 'center',
|
|
229
230
|
cursor: 'default',
|
|
230
231
|
paddingTop: '10px',
|
|
231
|
-
}, children: [_jsx(Label, { title: "Workspace", children: _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences
|
|
232
|
+
}, children: [_jsx(Label, { title: "Workspace", children: _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences.workspace.current, onSelect: ChangeWorkspaceHandler }) }), _jsx(Button.Action, { size: "xSmall", onClick: handleReset, toolTip: "Reset workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
232
233
|
marginLeft: '10px',
|
|
233
234
|
}, disabled: isRestDisabled, children: _jsx(FaBolt, {}) }), _jsx(Button.Done, { size: "xSmall", fill: "outline", onClick: handleCopyWorkspace, toolTip: "Copy workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
234
235
|
marginLeft: '10px',
|
|
235
|
-
}, children: _jsx(FaRegCopy, {}) }), _jsx(Button.Action, { size: "xSmall", fill: "outline", onClick:
|
|
236
|
+
}, children: _jsx(FaRegCopy, {}) }), _jsx(Button.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspaceAction, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
236
237
|
marginLeft: '10px',
|
|
237
238
|
}, children: _jsx(FaPaste, {}) })] })] }) }), _jsx(Modal.Body, { children: _jsx("div", { css: styles, style: { height }, children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { title: "General", tabid: "general", children: _jsx("div", { className: "inner-content", children: _jsx(GeneralTabContent, {}) }) }), _jsx(Tab, { title: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { title: "Panels", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, {}) }) }), _jsx(Tab, { title: "Tools", tabid: "tools", children: _jsx("div", { className: "inner-content", children: _jsx(ToolsTabContent, {}) }) }), _jsx(Tab, { title: "Databases", tabid: "databases", children: _jsx("div", { className: "inner-content", children: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }) }), _jsx(Tab, { title: "Import filters", tabid: "importation-filters", children: _jsx("div", { className: "inner-content", children: _jsx(ImportationFiltersTabContent, {}) }) }), _jsx(Tab, { title: "Title Block", tabid: "title-block", children: _jsx("div", { className: "inner-content", children: _jsx(InfoBlockTabContent, {}) }) }), _jsx(Tab, { title: "On Load Processing", tabid: "on-load-processing", children: _jsx("div", { className: "inner-content", children: _jsx(OnLoadProcessingTabContent, {}) }) })] }) }) }) }), _jsx(Modal.Footer, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
|
|
238
239
|
closeDialog?.();
|
|
239
|
-
} }), _jsx(Button.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), _jsx(SaveSettingsModal, {})] }));
|
|
240
|
+
} }), _jsx(Button.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), _jsx(SaveSettingsModal, {}), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
|
|
240
241
|
}
|
|
241
242
|
export default GeneralSettingsModal;
|
|
@@ -5,6 +5,8 @@ import { useCallback } from 'react';
|
|
|
5
5
|
import { FaCog, FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
|
|
6
6
|
import { IoOpenOutline } from 'react-icons/io5';
|
|
7
7
|
import { DropdownMenu } from 'react-science/ui';
|
|
8
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
9
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
8
10
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
9
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
12
|
import { useGlobal } from '../../context/GlobalContext';
|
|
@@ -13,7 +15,7 @@ import Button from '../../elements/Button';
|
|
|
13
15
|
import { useAlert } from '../../elements/popup/Alert';
|
|
14
16
|
import AboutPredictionModal from '../../modal/AboutPredictionModal';
|
|
15
17
|
import { usePredictSpectraModal } from '../../modal/PredictSpectraModal';
|
|
16
|
-
import { copyPNGToClipboard,
|
|
18
|
+
import { copyPNGToClipboard, exportAsSVG } from '../../utility/export';
|
|
17
19
|
import PanelHeader from '../header/PanelHeader';
|
|
18
20
|
const styles = {
|
|
19
21
|
counter: {
|
|
@@ -87,16 +89,12 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
87
89
|
copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
|
|
88
90
|
alert.success('MOL copied as PNG to clipboard');
|
|
89
91
|
}, [rootRef, alert, currentIndex]);
|
|
92
|
+
const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = useClipboard();
|
|
90
93
|
const saveAsMolHandler = useCallback((molfile) => {
|
|
91
|
-
void
|
|
92
|
-
|
|
93
|
-
alert.success('MOLFile copied to clipboard');
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
alert.error('copied not completed');
|
|
97
|
-
}
|
|
94
|
+
void rawWriteWithType(molfile).then(() => {
|
|
95
|
+
alert.success('MOLFile copied to clipboard');
|
|
98
96
|
});
|
|
99
|
-
}, [alert]);
|
|
97
|
+
}, [alert, rawWriteWithType]);
|
|
100
98
|
const exportHandler = useCallback((selected) => {
|
|
101
99
|
const molecule = molecules?.[currentIndex];
|
|
102
100
|
if (molecule) {
|
|
@@ -125,11 +123,15 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
125
123
|
saveAsPNGHandler,
|
|
126
124
|
saveAsSVGHandler,
|
|
127
125
|
]);
|
|
128
|
-
|
|
129
|
-
void
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
function handlePasteMolfileAction() {
|
|
127
|
+
void readText().then(handlePasteMolfile);
|
|
128
|
+
}
|
|
129
|
+
function handlePasteMolfile(molfile) {
|
|
130
|
+
if (!molfile)
|
|
131
|
+
return;
|
|
132
|
+
dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
|
|
133
|
+
cleanShouldFallback();
|
|
134
|
+
}
|
|
133
135
|
const handleDelete = useCallback(() => {
|
|
134
136
|
if (molecules[currentIndex]?.id) {
|
|
135
137
|
onMoleculeIndexChange?.(0);
|
|
@@ -158,7 +160,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
158
160
|
});
|
|
159
161
|
}
|
|
160
162
|
const hasMolecules = molecules && molecules.length > 0;
|
|
161
|
-
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick:
|
|
163
|
+
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(Button.BarButton, { color: { base: '#4e4e4e', hover: '#4e4e4e' }, onClick: () => openPredictSpectraModal(molecules[currentIndex]), toolTip: "Predict spectra", tooltipOrientation: "horizontal", children: _jsx(SvgNmrFt, {}) }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), _jsxs("p", { style: styles.counter, children: [molecules &&
|
|
162
164
|
molecules.length > 0 &&
|
|
163
|
-
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) }))] }));
|
|
165
|
+
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
164
166
|
}
|
|
@@ -6,6 +6,8 @@ import { useCallback, useState, useRef, memo } from 'react';
|
|
|
6
6
|
import { FaFileExport } from 'react-icons/fa';
|
|
7
7
|
import { IoPulseOutline } from 'react-icons/io5';
|
|
8
8
|
import { getDataAsString, generateAnalyzeSpectra, } from '../../../data/data1d/multipleSpectraAnalysis';
|
|
9
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
10
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
9
11
|
import { useChartData } from '../../context/ChartContext';
|
|
10
12
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
13
|
import Button from '../../elements/ButtonToolTip';
|
|
@@ -14,7 +16,6 @@ import { positions, useAlert } from '../../elements/popup/Alert';
|
|
|
14
16
|
import { useModal } from '../../elements/popup/Modal';
|
|
15
17
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
16
18
|
import AlignSpectraModal from '../../modal/AlignSpectraModal';
|
|
17
|
-
import { copyTextToClipboard } from '../../utility/export';
|
|
18
19
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
19
20
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
20
21
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
@@ -50,18 +51,13 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
|
|
|
50
51
|
width: 500,
|
|
51
52
|
});
|
|
52
53
|
}, [activeTab, modal, dispatch]);
|
|
54
|
+
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = useClipboard();
|
|
53
55
|
const copyToClipboardHandler = useCallback(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
alert.error('copy to clipboard failed');
|
|
62
|
-
}
|
|
63
|
-
})();
|
|
64
|
-
}, [alert, spectra, spectraAnalysis, spectraPreferences]);
|
|
56
|
+
const data = getDataAsString(spectraAnalysis, spectra, spectraPreferences);
|
|
57
|
+
if (!data)
|
|
58
|
+
return;
|
|
59
|
+
void rawWriteWithType(data).then(() => alert.success('Data copied to clipboard'));
|
|
60
|
+
}, [alert, rawWriteWithType, spectra, spectraAnalysis, spectraPreferences]);
|
|
65
61
|
return (_jsxs("div", { css: [
|
|
66
62
|
tablePanelStyle,
|
|
67
63
|
isFlipped &&
|
|
@@ -70,7 +66,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
|
|
|
70
66
|
position: relative;
|
|
71
67
|
}
|
|
72
68
|
`,
|
|
73
|
-
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [_jsx(Button, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: _jsx(FaFileExport, {}) }), _jsx(Button, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: _jsx(SvgNmrOverlay, { style: { fontSize: '18px' } }) }), _jsx(ToggleButton, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: _jsx(IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) })] }));
|
|
69
|
+
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [_jsx(Button, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: _jsx(FaFileExport, {}) }), _jsx(Button, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: _jsx(SvgNmrOverlay, { style: { fontSize: '18px' } }) }), _jsx(ToggleButton, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: _jsx(IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
|
|
74
70
|
}
|
|
75
71
|
const MemoizedMultipleSpectraAnalysisPanel = memo(MultipleSpectraAnalysisPanelInner);
|
|
76
72
|
export default function MultipleSpectraAnalysisPanel() {
|
package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useFormikContext } from 'formik';
|
|
3
|
+
import { AnalysisColumnsTypes } from 'nmr-load-save';
|
|
3
4
|
import { useMemo, useCallback } from 'react';
|
|
4
5
|
import { FaPlus, FaTimes } from 'react-icons/fa';
|
|
5
6
|
import Button from '../../../elements/Button';
|
|
6
7
|
import ReactTable from '../../../elements/ReactTable/ReactTable';
|
|
7
8
|
import FormikInput from '../../../elements/formik/FormikInput';
|
|
8
|
-
import { AnalysisColumnsTypes } from 'nmr-load-save';
|
|
9
9
|
const inputStyle = { input: { width: '100%', fontSize: '1.15em' } };
|
|
10
10
|
export function AnalysisTablePreferences() {
|
|
11
11
|
const { values: { analysisOptions: { columns }, }, setFieldValue, } = useFormikContext();
|
|
@@ -38,7 +38,7 @@ const accordionItems = [
|
|
|
38
38
|
title: 'Peaks',
|
|
39
39
|
component: _jsx(PeaksPanel, {}),
|
|
40
40
|
hidePreferenceKey: 'peaksPanel',
|
|
41
|
-
mode:
|
|
41
|
+
mode: DISPLAYER_MODE.DM_1D,
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
title: 'Processings',
|
|
@@ -50,7 +50,7 @@ const accordionItems = [
|
|
|
50
50
|
title: 'Integrals',
|
|
51
51
|
component: _jsx(IntegralPanel, {}),
|
|
52
52
|
hidePreferenceKey: 'integralsPanel',
|
|
53
|
-
mode:
|
|
53
|
+
mode: DISPLAYER_MODE.DM_1D,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
title: 'Ranges',
|
|
@@ -6,6 +6,8 @@ import lodashGet from 'lodash/get';
|
|
|
6
6
|
import { rangesToACS } from 'nmr-processing';
|
|
7
7
|
import { FaFileExport, FaUnlink, FaSitemap, FaChartBar } from 'react-icons/fa';
|
|
8
8
|
import { ImLink } from 'react-icons/im';
|
|
9
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
10
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
9
11
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
10
12
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
13
|
import ActiveButton from '../../elements/ActiveButton';
|
|
@@ -15,7 +17,6 @@ import { useModal } from '../../elements/popup/Modal';
|
|
|
15
17
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
16
18
|
import CopyClipboardModal from '../../modal/CopyClipboardModal';
|
|
17
19
|
import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
|
|
18
|
-
import { copyHTMLToClipboard } from '../../utility/export';
|
|
19
20
|
import { getNumberOfDecimals } from '../../utility/formatNumber';
|
|
20
21
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
21
22
|
const style = css `
|
|
@@ -87,16 +88,9 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
|
|
|
87
88
|
function handleShowJGraph() {
|
|
88
89
|
dispatch({ type: 'SHOW_J_GRAPH', payload: { id } });
|
|
89
90
|
}
|
|
91
|
+
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = useClipboard();
|
|
90
92
|
function saveToClipboardHandler(value) {
|
|
91
|
-
void (
|
|
92
|
-
const success = await copyHTMLToClipboard(value);
|
|
93
|
-
if (success) {
|
|
94
|
-
alert.success('Data copied to clipboard');
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
alert.error('copy to clipboard failed');
|
|
98
|
-
}
|
|
99
|
-
})();
|
|
93
|
+
void rawWriteWithType(value, 'text/html').then(() => alert.success('Data copied to clipboard'));
|
|
100
94
|
}
|
|
101
95
|
function saveAsHTMLHandler() {
|
|
102
96
|
if (Array.isArray(ranges?.values) && ranges.values.length > 0) {
|
|
@@ -118,10 +112,10 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
|
|
|
118
112
|
});
|
|
119
113
|
}
|
|
120
114
|
const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
|
|
121
|
-
return (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
return (_jsxs("div", { css: style, children: [_jsxs(DefaultPanelHeader, { counter: ranges?.values?.length || 0, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', filterIsActive: isFilterActive, counterFiltered: filterCounter, showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: _jsx(FaFileExport, {}) }), _jsx(Button, { popupTitle: currentSum
|
|
116
|
+
? `Change ranges sum (${Number(currentSum).toFixed(2)})`
|
|
117
|
+
: 'Change ranges sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: _jsx(SvgNmrSum, {}) }), _jsx(Button, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
|
|
118
|
+
? 'Hide multiplicity trees in spectrum'
|
|
119
|
+
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: _jsx(ImLink, {}) })] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
|
|
126
120
|
}
|
|
127
121
|
export default RangesHeader;
|
|
@@ -4,6 +4,8 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { xGetFromToIndex } from 'ml-spectra-processing';
|
|
5
5
|
import { useCallback, useMemo, memo, useState, useRef } from 'react';
|
|
6
6
|
import { FaCopy } from 'react-icons/fa';
|
|
7
|
+
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
8
|
+
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
7
9
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
8
10
|
import { useChartData } from '../../context/ChartContext';
|
|
9
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
@@ -11,7 +13,6 @@ import { useAlert } from '../../elements/popup/Alert';
|
|
|
11
13
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
12
14
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
15
|
import { rangeStateInit } from '../../reducer/Reducer';
|
|
14
|
-
import { copyTextToClipboard } from '../../utility/export';
|
|
15
16
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
16
17
|
import NoTableData from '../extra/placeholder/NoTableData';
|
|
17
18
|
import PreferencesHeader from '../header/PreferencesHeader';
|
|
@@ -68,6 +69,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
68
69
|
},
|
|
69
70
|
});
|
|
70
71
|
}, [assignmentData, dispatch]);
|
|
72
|
+
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = useClipboard();
|
|
71
73
|
const saveJSONToClipboardHandler = useCallback(async (value) => {
|
|
72
74
|
if (data.x && data.re) {
|
|
73
75
|
const { x, re } = data;
|
|
@@ -81,15 +83,10 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
81
83
|
y: Array.from(re.slice(fromIndex, toIndex)),
|
|
82
84
|
...value,
|
|
83
85
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
alert.show('Data copied to clipboard');
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
alert.error('copy to clipboard failed');
|
|
90
|
-
}
|
|
86
|
+
await rawWriteWithType(JSON.stringify(dataToClipboard, undefined, 2));
|
|
87
|
+
alert.show('Data copied to clipboard');
|
|
91
88
|
}
|
|
92
|
-
}, [data, alert]);
|
|
89
|
+
}, [data, rawWriteWithType, alert]);
|
|
93
90
|
const contextMenuSelectHandler = useCallback((option, data) => {
|
|
94
91
|
void saveJSONToClipboardHandler(data);
|
|
95
92
|
}, [saveJSONToClipboardHandler]);
|
|
@@ -119,7 +116,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
119
116
|
showRangesIntegrals,
|
|
120
117
|
showMultiplicityTrees,
|
|
121
118
|
showJGraph,
|
|
122
|
-
isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? (_jsx(RangesTable, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : (_jsx(NoTableData, {})) })) : (_jsx(RangesPreferences, { ref: settingRef })) })] }));
|
|
119
|
+
isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? (_jsx(RangesTable, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : (_jsx(NoTableData, {})) })) : (_jsx(RangesPreferences, { ref: settingRef })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Range" })] }));
|
|
123
120
|
}
|
|
124
121
|
const MemoizedRangesTablePanel = memo(RangesTablePanelInner);
|
|
125
122
|
const emptyData = { ranges: {}, data: {}, info: {} };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RangeData } from './useMapRanges';
|
|
2
2
|
export default function useEditRangeModal(range?: RangeData): {
|
|
3
|
-
editRange: (
|
|
3
|
+
editRange: () => void;
|
|
4
4
|
deleteRange: (id?: string, resetSelectTool?: boolean) => void;
|
|
5
5
|
zoomRange: (modalRange?: RangeData) => void;
|
|
6
6
|
changeRangeSignalKind: (kind: any) => void;
|