nmrium 0.39.0 → 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.
Files changed (47) hide show
  1. package/lib/component/context/LoggerContext.js +11 -6
  2. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +7 -0
  3. package/lib/component/elements/popup/Alert/AlertBlock.js +24 -0
  4. package/lib/component/elements/popup/Alert/Provider.js +2 -20
  5. package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  6. package/lib/component/header/Header.js +2 -2
  7. package/lib/component/modal/AboutUsModal.js +4 -2
  8. package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
  9. package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
  10. package/lib/component/modal/setting/GeneralSettings.js +28 -27
  11. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -16
  12. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  13. package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
  14. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
  15. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
  16. package/lib/component/utility/export.d.ts +5 -4
  17. package/lib/component/utility/export.js +24 -52
  18. package/lib/utils/clipboard/clipboard.d.ts +12 -0
  19. package/lib/utils/clipboard/clipboard.js +15 -0
  20. package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
  21. package/lib/utils/clipboard/clipboardComponents.js +150 -0
  22. package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
  23. package/lib/utils/clipboard/clipboardHooks.js +142 -0
  24. package/lib/utils/clipboard/types.d.ts +1 -0
  25. package/lib/utils/clipboard/types.js +1 -0
  26. package/lib/versionInfo.js +1 -1
  27. package/lib-cjs/component/context/LoggerContext.js +10 -5
  28. package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +30 -0
  29. package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -20
  30. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  31. package/lib-cjs/component/header/Header.js +2 -2
  32. package/lib-cjs/component/modal/AboutUsModal.js +4 -2
  33. package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
  34. package/lib-cjs/component/modal/setting/GeneralSettings.js +28 -27
  35. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +17 -15
  36. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  37. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
  38. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
  39. package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
  40. package/lib-cjs/component/utility/export.js +24 -54
  41. package/lib-cjs/utils/clipboard/clipboard.js +23 -0
  42. package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
  43. package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
  44. package/lib-cjs/utils/clipboard/types.js +2 -0
  45. package/lib-cjs/versionInfo.js +1 -1
  46. package/package.json +13 -13
  47. package/lib/component/header/LogsHistory.d.ts +0 -1
@@ -4,6 +4,7 @@ exports.LoggerProvider = exports.useLogger = exports.LoggerContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const fifo_logger_1 = require("fifo-logger");
6
6
  const react_1 = require("react");
7
+ const LogsHistoryModal_1 = require("../modal/LogsHistoryModal");
7
8
  const PreferencesContext_1 = require("./PreferencesContext");
8
9
  exports.LoggerContext = (0, react_1.createContext)(null);
9
10
  function useLogger() {
@@ -18,12 +19,16 @@ function LoggerProvider({ children }) {
18
19
  const { current: { general: { loggingLevel }, }, } = (0, PreferencesContext_1.usePreferences)();
19
20
  const [lastReadLogId, setLastLogId] = (0, react_1.useState)(0);
20
21
  const [logsHistory, setLogsHistory] = (0, react_1.useState)([]);
22
+ const [isLogHistoryOpened, openLogHistory] = (0, react_1.useState)(false);
21
23
  const loggerRef = (0, react_1.useRef)(new fifo_logger_1.FifoLogger({
22
24
  onChange: (log, logs) => {
23
- if (log?.error &&
24
- (log?.levelLabel === 'error' || log?.levelLabel === 'fatal')) {
25
- // eslint-disable-next-line no-console
26
- console.error(log.error);
25
+ if (log && ['warn', 'error', 'fatal'].includes(log.levelLabel)) {
26
+ //open the log history automatically if we have warn,error, or fatal
27
+ openLogHistory(true);
28
+ if (log?.error) {
29
+ // eslint-disable-next-line no-console
30
+ console.error(log.error);
31
+ }
27
32
  }
28
33
  setLogsHistory(logs.slice());
29
34
  },
@@ -47,6 +52,6 @@ function LoggerProvider({ children }) {
47
52
  lastReadLogId,
48
53
  };
49
54
  }, [lastReadLogId, logsHistory, markAsRead]);
50
- return ((0, jsx_runtime_1.jsx)(exports.LoggerContext.Provider, { value: loggerState, children: children }));
55
+ return ((0, jsx_runtime_1.jsxs)(exports.LoggerContext.Provider, { value: loggerState, children: [isLogHistoryOpened && ((0, jsx_runtime_1.jsx)(LogsHistoryModal_1.LogsHistoryModal, { autoOpen: true, onClose: () => openLogHistory(false) })), children] }));
51
56
  }
52
57
  exports.LoggerProvider = LoggerProvider;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const fa_1 = require("react-icons/fa");
8
+ const options_1 = require("../options");
9
+ const ProgressIndicator_1 = __importDefault(require("./ProgressIndicator"));
10
+ function AlertBlock(props) {
11
+ const { offset, alert, onClose } = props;
12
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
13
+ margin: offset,
14
+ padding: '25px',
15
+ borderRadius: '10px',
16
+ pointerEvents: 'all',
17
+ backgroundColor: alert.options.backgroundColor,
18
+ color: alert.options.color,
19
+ minHeight: '60px',
20
+ position: 'relative',
21
+ }, children: [(0, jsx_runtime_1.jsx)("button", { style: {
22
+ position: 'absolute',
23
+ right: '5px',
24
+ top: '5px',
25
+ border: 'none',
26
+ backgroundColor: 'transparent',
27
+ color: 'white',
28
+ }, type: "button", onClick: onClose, children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }), (0, jsx_runtime_1.jsx)("span", { children: alert.message }), alert.options.type === options_1.types.PROGRESS_INDICATOR && (0, jsx_runtime_1.jsx)(ProgressIndicator_1.default, {})] }, alert.id));
29
+ }
30
+ exports.default = AlertBlock;
@@ -7,13 +7,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const groupBy_1 = __importDefault(require("lodash/groupBy"));
8
8
  const react_1 = require("react");
9
9
  const react_dom_1 = require("react-dom");
10
- const fa_1 = require("react-icons/fa");
11
10
  const react_transition_group_1 = require("react-transition-group");
12
11
  const Transition_1 = __importDefault(require("../Transition"));
13
12
  const Wrapper_1 = __importDefault(require("../Wrapper"));
14
13
  const options_1 = require("../options");
14
+ const AlertBlock_1 = __importDefault(require("./AlertBlock"));
15
15
  const Context_1 = require("./Context");
16
- const ProgressIndicator_1 = __importDefault(require("./ProgressIndicator"));
17
16
  function Provider({ children, wrapperRef = null, offset = '5px', position = options_1.positions.BOTTOM_CENTER, timeout = 3000, type, transition = options_1.transitions.FADE, ...props }) {
18
17
  const root = (0, react_1.useRef)(null);
19
18
  const timersId = (0, react_1.useRef)([]);
@@ -126,24 +125,7 @@ function Provider({ children, wrapperRef = null, offset = '5px', position = opti
126
125
  (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: Object.keys(options_1.positions).map((key) => {
127
126
  const position = options_1.positions[key];
128
127
  return ((0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { appear: true, options: { position, zIndex: 999999 }, component: Wrapper_1.default, containerStyle: parentStyle, ...props, children: alertsByPosition[position]
129
- ? alertsByPosition[position].map((alert) => ((0, jsx_runtime_1.jsx)(Transition_1.default, { type: transition, children: (0, jsx_runtime_1.jsxs)("div", { style: {
130
- margin: offset,
131
- padding: '25px',
132
- borderRadius: '10px',
133
- pointerEvents: 'all',
134
- backgroundColor: alert.options.backgroundColor,
135
- color: alert.options.color,
136
- minHeight: '60px',
137
- position: 'relative',
138
- }, children: [(0, jsx_runtime_1.jsx)("button", { style: {
139
- position: 'absolute',
140
- right: '5px',
141
- top: '5px',
142
- border: 'none',
143
- backgroundColor: 'transparent',
144
- color: 'white',
145
- }, type: "button", onClick: () => closeHandler(alert), children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }), (0, jsx_runtime_1.jsx)("span", { children: alert.message }), alert.options.type ===
146
- options_1.types.PROGRESS_INDICATOR && (0, jsx_runtime_1.jsx)(ProgressIndicator_1.default, {})] }, alert.id) }, alert.id)))
128
+ ? alertsByPosition[position].map((alert) => ((0, jsx_runtime_1.jsx)(Transition_1.default, { type: transition, children: (0, jsx_runtime_1.jsx)(AlertBlock_1.default, { offset: offset, alert: alert, onClose: () => closeHandler(alert) }) }, alert.id)))
147
129
  : null }, position));
148
130
  }) }), root.current)] }));
149
131
  }
@@ -8,7 +8,8 @@ const styles = (0, react_1.css) `
8
8
  display: block;
9
9
  border-radius: 5px;
10
10
  overflow: hidden;
11
- width: 350px;
11
+ width: 30vw;
12
+ min-width: 350px;
12
13
  border-top: 10px solid #ed0000;
13
14
 
14
15
  .message {
@@ -18,6 +18,7 @@ const Header_1 = require("../elements/Header");
18
18
  const DropDownButton_1 = __importDefault(require("../elements/dropDownButton/DropDownButton"));
19
19
  const useSaveSettings_1 = require("../hooks/useSaveSettings");
20
20
  const AboutUsModal_1 = __importDefault(require("../modal/AboutUsModal"));
21
+ const LogsHistoryModal_1 = require("../modal/LogsHistoryModal");
21
22
  const GeneralSettings_1 = __importDefault(require("../modal/setting/GeneralSettings"));
22
23
  const WorkspaceItem_1 = __importDefault(require("../modal/setting/WorkspaceItem"));
23
24
  const ToolTypes_1 = require("../toolbar/ToolTypes");
@@ -25,7 +26,6 @@ const ApodizationOptionsPanel_1 = __importDefault(require("./ApodizationOptionsP
25
26
  const AutoPeakPickingOptionPanel_1 = __importDefault(require("./AutoPeakPickingOptionPanel"));
26
27
  const BaseLineCorrectionPanel_1 = __importDefault(require("./BaseLineCorrectionPanel"));
27
28
  const HeaderContainer_1 = require("./HeaderContainer");
28
- const LogsHistory_1 = require("./LogsHistory");
29
29
  const PhaseCorrectionPanel_1 = __importDefault(require("./PhaseCorrectionPanel"));
30
30
  const RangesPickingOptionPanel_1 = __importDefault(require("./RangesPickingOptionPanel"));
31
31
  const ZeroFillingOptionsPanel_1 = __importDefault(require("./ZeroFillingOptionsPanel"));
@@ -106,7 +106,7 @@ function HeaderInner(props) {
106
106
  alignItems: 'center',
107
107
  }, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ui_1.Toolbar, { orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(AboutUsModal_1.default, {}) }) }), (0, jsx_runtime_1.jsx)("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), (0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { style: {
108
108
  alignItems: 'center',
109
- }, children: [!hideGeneralSettings && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem }), (0, jsx_runtime_1.jsx)(SaveButton, {})] })), !general?.hideLogs && (0, jsx_runtime_1.jsx)(LogsHistory_1.LogsHistory, {}), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(ui_1.Toolbar, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(constants_1.docsBaseUrl, '_blank'), children: (0, jsx_runtime_1.jsx)(fa_1.FaQuestionCircle, {}) }), !hideGeneralSettings && ((0, jsx_runtime_1.jsx)(GeneralSettings_1.default, { height: height / 2 })), !isFullscreen && ((0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "full-screen", onClick: onMaximize, title: "Full Screen", className: "windowButton", children: (0, jsx_runtime_1.jsx)(fa_1.FaRegWindowMaximize, {}) }))] }) })] })] }) }));
109
+ }, children: [!hideGeneralSettings && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem }), (0, jsx_runtime_1.jsx)(SaveButton, {})] })), !general?.hideLogs && (0, jsx_runtime_1.jsx)(LogsHistoryModal_1.LogsHistoryModal, {}), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(ui_1.Toolbar, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(constants_1.docsBaseUrl, '_blank'), children: (0, jsx_runtime_1.jsx)(fa_1.FaQuestionCircle, {}) }), !hideGeneralSettings && ((0, jsx_runtime_1.jsx)(GeneralSettings_1.default, { height: height / 2 })), !isFullscreen && ((0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "full-screen", onClick: onMaximize, title: "Full Screen", className: "windowButton", children: (0, jsx_runtime_1.jsx)(fa_1.FaRegWindowMaximize, {}) }))] }) })] })] }) }));
110
110
  }
111
111
  function SaveButton() {
112
112
  const { workspace, workspaces, originalWorkspaces } = (0, PreferencesContext_1.usePreferences)();
@@ -11,6 +11,9 @@ const ui_1 = require("react-science/ui");
11
11
  const versionInfo_1 = __importDefault(require("../../versionInfo"));
12
12
  const Logo_1 = __importDefault(require("../elements/Logo"));
13
13
  const styles = (0, react_1.css) `
14
+ width: 40vw;
15
+ min-width: 500px;
16
+
14
17
  button:focus {
15
18
  outline: none;
16
19
  }
@@ -87,7 +90,6 @@ const styles = (0, react_1.css) `
87
90
  display: flex;
88
91
  flex-direction: column;
89
92
  user-select: none;
90
- width: 500px;
91
93
  `;
92
94
  function AboutUsModal() {
93
95
  const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
@@ -95,7 +97,7 @@ function AboutUsModal() {
95
97
  display: 'flex',
96
98
  alignItems: 'center',
97
99
  justifyContent: 'center',
98
- }, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgLogoNmrium, {}) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About NMRium" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "container", children: [(0, jsx_runtime_1.jsxs)("div", { className: "center-container", children: [(0, jsx_runtime_1.jsx)(Logo_1.default, { width: 160, height: 50 }), "Version ", (0, jsx_runtime_1.jsx)(VersionInfo, {}), (0, jsx_runtime_1.jsx)("span", { className: "separator" }), (0, jsx_runtime_1.jsx)("a", { href: "https://git.nmrium.org", target: "_blank", rel: "noreferrer", children: "GitHub ( https://git.nmrium.org )" })] }), (0, jsx_runtime_1.jsx)("div", { className: "center-container", children: (0, jsx_runtime_1.jsx)("span", { className: "separator" }) }), (0, jsx_runtime_1.jsx)("span", { className: "content", children: "This project is developed by Zakodium S\u00E0rl (Switzerland), the University of Cologne (Germany), Johannes Gutenberg University Mainz (Germany) and Universidad del Valle (Colombia)." }), (0, jsx_runtime_1.jsxs)("div", { className: "center-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "separator" }), (0, jsx_runtime_1.jsx)("span", { className: "title", children: "Funding is provided by" }), (0, jsx_runtime_1.jsx)("span", { className: "separator" })] }), (0, jsx_runtime_1.jsx)("div", { className: "content", children: (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsx)("li", { children: "IDNMR grant, which part of the Scientific Library Services and Information Systems (LIS) initiative of the DFG." }), (0, jsx_runtime_1.jsx)("li", { children: "Zakodium S\u00E0rl (Switzerland)." }), (0, jsx_runtime_1.jsx)("li", { children: "Universidad del Valle (Cali, Colombia)." })] }) })] })] }) })] }));
100
+ }, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgLogoNmrium, {}) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, maxWidth: 1000, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About NMRium" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "container", children: [(0, jsx_runtime_1.jsxs)("div", { className: "center-container", children: [(0, jsx_runtime_1.jsx)(Logo_1.default, { width: 160, height: 50 }), "Version ", (0, jsx_runtime_1.jsx)(VersionInfo, {}), (0, jsx_runtime_1.jsx)("span", { className: "separator" }), (0, jsx_runtime_1.jsx)("a", { href: "https://git.nmrium.org", target: "_blank", rel: "noreferrer", children: "GitHub ( https://git.nmrium.org )" })] }), (0, jsx_runtime_1.jsx)("div", { className: "center-container", children: (0, jsx_runtime_1.jsx)("span", { className: "separator" }) }), (0, jsx_runtime_1.jsx)("span", { className: "content", children: "This project is developed by Zakodium S\u00E0rl (Switzerland), the University of Cologne (Germany), Johannes Gutenberg University Mainz (Germany) and Universidad del Valle (Colombia)." }), (0, jsx_runtime_1.jsxs)("div", { className: "center-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "separator" }), (0, jsx_runtime_1.jsx)("span", { className: "title", children: "Funding is provided by" }), (0, jsx_runtime_1.jsx)("span", { className: "separator" })] }), (0, jsx_runtime_1.jsx)("div", { className: "content", children: (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsx)("li", { children: "IDNMR grant, which part of the Scientific Library Services and Information Systems (LIS) initiative of the DFG." }), (0, jsx_runtime_1.jsx)("li", { children: "Zakodium S\u00E0rl (Switzerland)." }), (0, jsx_runtime_1.jsx)("li", { children: "Universidad del Valle (Cali, Colombia)." })] }) })] })] }) })] }));
99
101
  }
100
102
  exports.default = AboutUsModal;
101
103
  function VersionInfo() {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LogsHistory = void 0;
6
+ exports.LogsHistoryModal = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
9
  const fa_1 = require("react-icons/fa");
@@ -53,9 +53,10 @@ function getMaxLevelLogs(logs, lastReadLogId) {
53
53
  }
54
54
  return { backgroundColor, count: logsCounts[maxLevel] };
55
55
  }
56
- function LogsHistory() {
56
+ function LogsHistoryModal(props) {
57
+ const { autoOpen = false, onClose } = props;
57
58
  const { logsHistory, logger, markAsRead, lastReadLogId } = (0, LoggerContext_1.useLogger)();
58
- const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
59
+ const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(autoOpen);
59
60
  const { count, backgroundColor } = getMaxLevelLogs(logsHistory, lastReadLogId);
60
61
  const COLUMNS = (0, react_1.useMemo)(() => [
61
62
  {
@@ -94,7 +95,7 @@ function LogsHistory() {
94
95
  },
95
96
  ], [lastReadLogId]);
96
97
  const sortedLogs = logsHistory.slice().sort((a, b) => b.time - a.time);
97
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: () => {
98
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!autoOpen && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: () => {
98
99
  openDialog();
99
100
  }, children: (0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)(io5_1.IoBugOutline, { fontSize: "1.4em" }), count && ((0, jsx_runtime_1.jsx)("span", { style: {
100
101
  position: 'absolute',
@@ -105,9 +106,10 @@ function LogsHistory() {
105
106
  minWidth: '14px',
106
107
  fontSize: '0.75em',
107
108
  color: 'white',
108
- }, children: count }))] }) }), (0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: () => {
109
+ }, children: count }))] }) })), (0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: () => {
109
110
  markAsRead();
110
111
  closeDialog();
112
+ onClose?.();
111
113
  }, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: "Logs History " }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)("div", { style: { width: '50vw', height: '50vh', padding: '0.5em' }, children: (0, jsx_runtime_1.jsx)(ReactTable_1.default, { columns: COLUMNS, data: sortedLogs, emptyDataRowText: "No Logs", rowStyle: handleRowStyle }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsx)(Button_1.default.Danger, { onClick: () => logger.clear(), fill: "outline", children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(fa_1.FaRegTrashAlt, {}), (0, jsx_runtime_1.jsx)("span", { style: { paddingLeft: '5px' }, children: "Clear Logs" })] }) }) })] })] }));
112
114
  }
113
- exports.LogsHistory = LogsHistory;
115
+ exports.LogsHistoryModal = LogsHistoryModal;
@@ -33,6 +33,8 @@ const formik_1 = require("formik");
33
33
  const react_2 = require("react");
34
34
  const fa_1 = require("react-icons/fa");
35
35
  const ui_1 = require("react-science/ui");
36
+ const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
37
+ const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
36
38
  const PreferencesContext_1 = require("../../context/PreferencesContext");
37
39
  const ActionButtons_1 = __importDefault(require("../../elements/ActionButtons"));
38
40
  const Button_1 = __importDefault(require("../../elements/Button"));
@@ -43,7 +45,6 @@ const DropDownButton_1 = __importDefault(require("../../elements/dropDownButton/
43
45
  const Alert_1 = require("../../elements/popup/Alert");
44
46
  const useSaveSettings_1 = require("../../hooks/useSaveSettings");
45
47
  const getPreferencesByWorkspace_1 = require("../../reducer/preferences/utilities/getPreferencesByWorkspace");
46
- const export_1 = require("../../utility/export");
47
48
  const workspaces_1 = __importDefault(require("../../workspaces"));
48
49
  const WorkspaceItem_1 = __importDefault(require("./WorkspaceItem"));
49
50
  const DatabasesTabContent_1 = __importDefault(require("./settings-tabs/DatabasesTabContent"));
@@ -56,7 +57,8 @@ const OnLoadProcessingTabContent_1 = __importDefault(require("./settings-tabs/On
56
57
  const ToolsTabContent_1 = __importDefault(require("./settings-tabs/ToolsTabContent"));
57
58
  const settingsValidation_1 = require("./settingsValidation");
58
59
  const styles = (0, react_1.css) `
59
- width: 800px;
60
+ width: 50vw;
61
+ min-width: 800px;
60
62
 
61
63
  .main-content {
62
64
  width: 100%;
@@ -203,20 +205,16 @@ function GeneralSettingsModal({ height }) {
203
205
  function handleDisabledRestButton(values) {
204
206
  setRestDisabled(isRestButtonDisable(values, workspaceName, originalWorkspaces));
205
207
  }
208
+ const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = (0, clipboardHooks_1.useClipboard)();
206
209
  function handleCopyWorkspace() {
207
210
  const data = { [workspaceName]: refForm.current?.values };
208
- void (0, export_1.copyTextToClipboard)(JSON.stringify(data)).then((flag) => {
209
- if (flag) {
210
- alert.success('Workspace copied to clipboard');
211
- }
212
- else {
213
- alert.error('copied not completed');
214
- }
211
+ void rawWriteWithType(JSON.stringify(data)).then(() => {
212
+ alert.success('Workspace copied to clipboard');
215
213
  });
216
214
  }
217
215
  const setWorkspaceSetting = (0, react_2.useCallback)((inputWorkspace) => {
218
216
  const parseWorkspaceName = Object.keys(inputWorkspace)[0];
219
- if (preferences?.workspace.current === parseWorkspaceName) {
217
+ if (preferences.workspace.current === parseWorkspaceName) {
220
218
  refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
221
219
  }
222
220
  else if (preferences.workspaces[parseWorkspaceName]) {
@@ -229,41 +227,44 @@ function GeneralSettingsModal({ height }) {
229
227
  },
230
228
  });
231
229
  }
232
- }, [dispatch, preferences?.workspace, preferences.workspaces]);
233
- function handlePastWorkspace() {
234
- void navigator.clipboard.readText().then((text) => {
235
- try {
236
- const parseWorkspaces = JSON.parse(text);
237
- setWorkspaceSetting(parseWorkspaces);
238
- }
239
- catch {
240
- alert.error('object parse error');
241
- }
242
- });
243
- }
230
+ }, [dispatch, preferences.workspace, preferences.workspaces]);
244
231
  (0, react_2.useEffect)(() => {
245
232
  if (pastRef.current) {
246
233
  setWorkspaceSetting(pastRef.current);
247
234
  pastRef.current = null;
248
235
  }
249
236
  }, [setWorkspaceSetting]);
250
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings", children: (0, jsx_runtime_1.jsx)(fa_1.FaWrench, {}) }), (0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
237
+ function handlePastWorkspace(text) {
238
+ if (!text)
239
+ return;
240
+ try {
241
+ const parseWorkspaces = JSON.parse(text);
242
+ setWorkspaceSetting(parseWorkspaces);
243
+ }
244
+ catch {
245
+ alert.error('object parse error');
246
+ }
247
+ cleanShouldFallback();
248
+ }
249
+ function handlePastWorkspaceAction() {
250
+ void readText().then(handlePastWorkspace);
251
+ }
252
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings", children: (0, jsx_runtime_1.jsx)(fa_1.FaWrench, {}) }), (0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, maxWidth: 1000, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
251
253
  display: 'flex',
252
254
  flexDirection: 'column',
253
- width: '100%',
254
255
  }, children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsxs)("div", { style: {
255
256
  display: 'flex',
256
257
  alignItems: 'center',
257
258
  cursor: 'default',
258
259
  paddingTop: '10px',
259
- }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Workspace", children: (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler }) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", onClick: handleReset, toolTip: "Reset workspace preferences", tooltipOrientation: "horizontal", style: {
260
+ }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Workspace", children: (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences.workspace.current, onSelect: ChangeWorkspaceHandler }) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", onClick: handleReset, toolTip: "Reset workspace preferences", tooltipOrientation: "horizontal", style: {
260
261
  marginLeft: '10px',
261
262
  }, disabled: isRestDisabled, children: (0, jsx_runtime_1.jsx)(fa_1.FaBolt, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Done, { size: "xSmall", fill: "outline", onClick: handleCopyWorkspace, toolTip: "Copy workspace preferences", tooltipOrientation: "horizontal", style: {
262
263
  marginLeft: '10px',
263
- }, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegCopy, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspace, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
264
+ }, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegCopy, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspaceAction, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
264
265
  marginLeft: '10px',
265
266
  }, children: (0, jsx_runtime_1.jsx)(fa_1.FaPaste, {}) })] })] }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)("div", { css: styles, style: { height }, children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: settingsValidation_1.validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { position: Tabs_1.PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [(0, jsx_runtime_1.jsx)(Tab_1.default, { title: "General", tabid: "general", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(GeneralTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Formatting", tabid: "formatting", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(FormattingTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Panels", tabid: "display", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DisplayTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Tools", tabid: "tools", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ToolsTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Databases", tabid: "databases", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DatabasesTabContent_1.default, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Import filters", tabid: "importation-filters", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ImportationFiltersTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Title Block", tabid: "title-block", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(InfoBlockTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "On Load Processing", tabid: "on-load-processing", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(OnLoadProcessingTabContent_1.default, {}) }) })] }) }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [(0, jsx_runtime_1.jsx)(ActionButtons_1.default, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
266
267
  closeDialog?.();
267
- } }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), (0, jsx_runtime_1.jsx)(SaveSettingsModal, {})] }));
268
+ } }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), (0, jsx_runtime_1.jsx)(SaveSettingsModal, {}), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
268
269
  }
269
270
  exports.default = GeneralSettingsModal;
@@ -10,6 +10,8 @@ const react_1 = require("react");
10
10
  const fa_1 = require("react-icons/fa");
11
11
  const io5_1 = require("react-icons/io5");
12
12
  const ui_1 = require("react-science/ui");
13
+ const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
14
+ const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
13
15
  const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
14
16
  const DispatchContext_1 = require("../../context/DispatchContext");
15
17
  const GlobalContext_1 = require("../../context/GlobalContext");
@@ -92,16 +94,12 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
92
94
  (0, export_1.copyPNGToClipboard)(rootRef, `molSVG${currentIndex} `);
93
95
  alert.success('MOL copied as PNG to clipboard');
94
96
  }, [rootRef, alert, currentIndex]);
97
+ const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = (0, clipboardHooks_1.useClipboard)();
95
98
  const saveAsMolHandler = (0, react_1.useCallback)((molfile) => {
96
- void (0, export_1.copyTextToClipboard)(molfile).then((flag) => {
97
- if (flag) {
98
- alert.success('MOLFile copied to clipboard');
99
- }
100
- else {
101
- alert.error('copied not completed');
102
- }
99
+ void rawWriteWithType(molfile).then(() => {
100
+ alert.success('MOLFile copied to clipboard');
103
101
  });
104
- }, [alert]);
102
+ }, [alert, rawWriteWithType]);
105
103
  const exportHandler = (0, react_1.useCallback)((selected) => {
106
104
  const molecule = molecules?.[currentIndex];
107
105
  if (molecule) {
@@ -130,11 +128,15 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
130
128
  saveAsPNGHandler,
131
129
  saveAsSVGHandler,
132
130
  ]);
133
- const handlePaste = (0, react_1.useCallback)(() => {
134
- void navigator.clipboard.readText().then((molfile) => {
135
- dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
136
- });
137
- }, [dispatch]);
131
+ function handlePasteMolfileAction() {
132
+ void readText().then(handlePasteMolfile);
133
+ }
134
+ function handlePasteMolfile(molfile) {
135
+ if (!molfile)
136
+ return;
137
+ dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
138
+ cleanShouldFallback();
139
+ }
138
140
  const handleDelete = (0, react_1.useCallback)(() => {
139
141
  if (molecules[currentIndex]?.id) {
140
142
  onMoleculeIndexChange?.(0);
@@ -163,8 +165,8 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
163
165
  });
164
166
  }
165
167
  const hasMolecules = molecules && molecules.length > 0;
166
- return ((0, jsx_runtime_1.jsxs)(PanelHeader_1.default, { children: [renderSource === 'predictionPanel' && (0, jsx_runtime_1.jsx)(AboutPredictionModal_1.default, {}), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }) })), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handlePaste, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPaste, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegTrashAlt, {}) }), hasMolecules && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: '#4e4e4e', hover: '#4e4e4e' }, onClick: () => openPredictSpectraModal(molecules[currentIndex]), toolTip: "Predict spectra", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrFt, {}) }))] })), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(io5_1.IoOpenOutline, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)("p", { style: styles.atomLabel, children: "#" }) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: children }), (0, jsx_runtime_1.jsxs)("p", { style: styles.counter, children: [molecules &&
168
+ return ((0, jsx_runtime_1.jsxs)(PanelHeader_1.default, { children: [renderSource === 'predictionPanel' && (0, jsx_runtime_1.jsx)(AboutPredictionModal_1.default, {}), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }) })), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPaste, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegTrashAlt, {}) }), hasMolecules && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: '#4e4e4e', hover: '#4e4e4e' }, onClick: () => openPredictSpectraModal(molecules[currentIndex]), toolTip: "Predict spectra", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrFt, {}) }))] })), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(io5_1.IoOpenOutline, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)("p", { style: styles.atomLabel, children: "#" }) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: children }), (0, jsx_runtime_1.jsxs)("p", { style: styles.counter, children: [molecules &&
167
169
  molecules.length > 0 &&
168
- `${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: (0, jsx_runtime_1.jsx)(fa_1.FaCog, {}) }))] }));
170
+ `${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: (0, jsx_runtime_1.jsx)(fa_1.FaCog, {}) })), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
169
171
  }
170
172
  exports.default = MoleculePanelHeader;
@@ -11,6 +11,8 @@ const react_2 = require("react");
11
11
  const fa_1 = require("react-icons/fa");
12
12
  const io5_1 = require("react-icons/io5");
13
13
  const multipleSpectraAnalysis_1 = require("../../../data/data1d/multipleSpectraAnalysis");
14
+ const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
15
+ const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
14
16
  const ChartContext_1 = require("../../context/ChartContext");
15
17
  const DispatchContext_1 = require("../../context/DispatchContext");
16
18
  const ButtonToolTip_1 = __importDefault(require("../../elements/ButtonToolTip"));
@@ -19,7 +21,6 @@ const Alert_1 = require("../../elements/popup/Alert");
19
21
  const Modal_1 = require("../../elements/popup/Modal");
20
22
  const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
21
23
  const AlignSpectraModal_1 = __importDefault(require("../../modal/AlignSpectraModal"));
22
- const export_1 = require("../../utility/export");
23
24
  const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
24
25
  const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
25
26
  const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
@@ -55,18 +56,13 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
55
56
  width: 500,
56
57
  });
57
58
  }, [activeTab, modal, dispatch]);
59
+ const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
58
60
  const copyToClipboardHandler = (0, react_2.useCallback)(() => {
59
- void (async () => {
60
- const data = (0, multipleSpectraAnalysis_1.getDataAsString)(spectraAnalysis, spectra, spectraPreferences);
61
- const success = await (0, export_1.copyTextToClipboard)(data);
62
- if (success) {
63
- alert.success('Data copied to clipboard');
64
- }
65
- else {
66
- alert.error('copy to clipboard failed');
67
- }
68
- })();
69
- }, [alert, spectra, spectraAnalysis, spectraPreferences]);
61
+ const data = (0, multipleSpectraAnalysis_1.getDataAsString)(spectraAnalysis, spectra, spectraPreferences);
62
+ if (!data)
63
+ return;
64
+ void rawWriteWithType(data).then(() => alert.success('Data copied to clipboard'));
65
+ }, [alert, rawWriteWithType, spectra, spectraAnalysis, spectraPreferences]);
70
66
  return ((0, jsx_runtime_1.jsxs)("div", { css: [
71
67
  BasicPanelStyle_1.tablePanelStyle,
72
68
  isFlipped &&
@@ -75,7 +71,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
75
71
  position: relative;
76
72
  }
77
73
  `,
78
- ], children: [!isFlipped && ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrOverlay, { style: { fontSize: '18px' } }) }), (0, jsx_runtime_1.jsx)(ToggleButton_1.default, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: (0, jsx_runtime_1.jsx)(io5_1.IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)(MultipleSpectraAnalysisTable_1.default, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : ((0, jsx_runtime_1.jsx)(preferences_1.default, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) })] }));
74
+ ], children: [!isFlipped && ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrOverlay, { style: { fontSize: '18px' } }) }), (0, jsx_runtime_1.jsx)(ToggleButton_1.default, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: (0, jsx_runtime_1.jsx)(io5_1.IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)(MultipleSpectraAnalysisTable_1.default, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : ((0, jsx_runtime_1.jsx)(preferences_1.default, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
79
75
  }
80
76
  const MemoizedMultipleSpectraAnalysisPanel = (0, react_2.memo)(MultipleSpectraAnalysisPanelInner);
81
77
  function MultipleSpectraAnalysisPanel() {
@@ -11,6 +11,8 @@ const get_1 = __importDefault(require("lodash/get"));
11
11
  const nmr_processing_1 = require("nmr-processing");
12
12
  const fa_1 = require("react-icons/fa");
13
13
  const im_1 = require("react-icons/im");
14
+ const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
15
+ const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
14
16
  const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
15
17
  const DispatchContext_1 = require("../../context/DispatchContext");
16
18
  const ActiveButton_1 = __importDefault(require("../../elements/ActiveButton"));
@@ -20,7 +22,6 @@ const Modal_1 = require("../../elements/popup/Modal");
20
22
  const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
21
23
  const CopyClipboardModal_1 = __importDefault(require("../../modal/CopyClipboardModal"));
22
24
  const ChangeSumModal_1 = __importDefault(require("../../modal/changeSum/ChangeSumModal"));
23
- const export_1 = require("../../utility/export");
24
25
  const formatNumber_1 = require("../../utility/formatNumber");
25
26
  const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
26
27
  const style = (0, react_1.css) `
@@ -92,16 +93,9 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
92
93
  function handleShowJGraph() {
93
94
  dispatch({ type: 'SHOW_J_GRAPH', payload: { id } });
94
95
  }
96
+ const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
95
97
  function saveToClipboardHandler(value) {
96
- void (async () => {
97
- const success = await (0, export_1.copyHTMLToClipboard)(value);
98
- if (success) {
99
- alert.success('Data copied to clipboard');
100
- }
101
- else {
102
- alert.error('copy to clipboard failed');
103
- }
104
- })();
98
+ void rawWriteWithType(value, 'text/html').then(() => alert.success('Data copied to clipboard'));
105
99
  }
106
100
  function saveAsHTMLHandler() {
107
101
  if (Array.isArray(ranges?.values) && ranges.values.length > 0) {
@@ -123,10 +117,10 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
123
117
  });
124
118
  }
125
119
  const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
126
- return ((0, jsx_runtime_1.jsx)("div", { css: style, children: (0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { 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: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: currentSum
127
- ? `Change ranges sum (${Number(currentSum).toFixed(2)})`
128
- : 'Change ranges sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrSum, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: (0, jsx_runtime_1.jsx)(fa_1.FaUnlink, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showMultiplicityTrees
129
- ? 'Hide multiplicity trees in spectrum'
130
- : 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: (0, jsx_runtime_1.jsx)(im_1.ImLink, {}) })] }) }));
120
+ return ((0, jsx_runtime_1.jsxs)("div", { css: style, children: [(0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { 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: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: currentSum
121
+ ? `Change ranges sum (${Number(currentSum).toFixed(2)})`
122
+ : 'Change ranges sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrSum, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: (0, jsx_runtime_1.jsx)(fa_1.FaUnlink, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showMultiplicityTrees
123
+ ? 'Hide multiplicity trees in spectrum'
124
+ : 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: (0, jsx_runtime_1.jsx)(im_1.ImLink, {}) })] }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
131
125
  }
132
126
  exports.default = RangesHeader;
@@ -9,6 +9,8 @@ const react_1 = require("@emotion/react");
9
9
  const ml_spectra_processing_1 = require("ml-spectra-processing");
10
10
  const react_2 = require("react");
11
11
  const fa_1 = require("react-icons/fa");
12
+ const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
13
+ const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
12
14
  const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
13
15
  const ChartContext_1 = require("../../context/ChartContext");
14
16
  const DispatchContext_1 = require("../../context/DispatchContext");
@@ -16,7 +18,6 @@ const Alert_1 = require("../../elements/popup/Alert");
16
18
  const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
17
19
  const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
18
20
  const Reducer_1 = require("../../reducer/Reducer");
19
- const export_1 = require("../../utility/export");
20
21
  const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
21
22
  const NoTableData_1 = __importDefault(require("../extra/placeholder/NoTableData"));
22
23
  const PreferencesHeader_1 = __importDefault(require("../header/PreferencesHeader"));
@@ -73,6 +74,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
73
74
  },
74
75
  });
75
76
  }, [assignmentData, dispatch]);
77
+ const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
76
78
  const saveJSONToClipboardHandler = (0, react_2.useCallback)(async (value) => {
77
79
  if (data.x && data.re) {
78
80
  const { x, re } = data;
@@ -86,15 +88,10 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
86
88
  y: Array.from(re.slice(fromIndex, toIndex)),
87
89
  ...value,
88
90
  };
89
- const success = await (0, export_1.copyTextToClipboard)(JSON.stringify(dataToClipboard, undefined, 2));
90
- if (success) {
91
- alert.show('Data copied to clipboard');
92
- }
93
- else {
94
- alert.error('copy to clipboard failed');
95
- }
91
+ await rawWriteWithType(JSON.stringify(dataToClipboard, undefined, 2));
92
+ alert.show('Data copied to clipboard');
96
93
  }
97
- }, [data, alert]);
94
+ }, [data, rawWriteWithType, alert]);
98
95
  const contextMenuSelectHandler = (0, react_2.useCallback)((option, data) => {
99
96
  void saveJSONToClipboardHandler(data);
100
97
  }, [saveJSONToClipboardHandler]);
@@ -124,7 +121,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
124
121
  showRangesIntegrals,
125
122
  showMultiplicityTrees,
126
123
  showJGraph,
127
- isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? ((0, jsx_runtime_1.jsx)(RangesTable_1.default, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {})) })) : ((0, jsx_runtime_1.jsx)(RangesPreferences_1.default, { ref: settingRef })) })] }));
124
+ isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? ((0, jsx_runtime_1.jsx)(RangesTable_1.default, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {})) })) : ((0, jsx_runtime_1.jsx)(RangesPreferences_1.default, { ref: settingRef })) }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Range" })] }));
128
125
  }
129
126
  const MemoizedRangesTablePanel = (0, react_2.memo)(RangesTablePanelInner);
130
127
  const emptyData = { ranges: {}, data: {}, info: {} };