react-cheminfo 0.131.0 → 0.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +29 -0
  2. package/lib/core.d.ts +1 -0
  3. package/lib/core.d.ts.map +1 -1
  4. package/lib/core.js +1 -0
  5. package/lib/core.js.map +1 -1
  6. package/lib/drawing/captionEditor/CaptionEditor.d.ts +3 -3
  7. package/lib/drawing/captionEditor/CaptionEditor.d.ts.map +1 -1
  8. package/lib/drawing/captionEditor/CaptionEditor.js +8 -4
  9. package/lib/drawing/captionEditor/CaptionEditor.js.map +1 -1
  10. package/lib/drawing/captionEditor/CaptionToolbar.d.ts +4 -2
  11. package/lib/drawing/captionEditor/CaptionToolbar.d.ts.map +1 -1
  12. package/lib/drawing/captionEditor/CaptionToolbar.js +6 -4
  13. package/lib/drawing/captionEditor/CaptionToolbar.js.map +1 -1
  14. package/lib/drawing/captionEditor/index.d.ts +2 -0
  15. package/lib/drawing/captionEditor/index.d.ts.map +1 -1
  16. package/lib/drawing/captionEditor/index.js +1 -0
  17. package/lib/drawing/captionEditor/index.js.map +1 -1
  18. package/lib/drawing/captionEditor/toolbarInView.d.ts +40 -0
  19. package/lib/drawing/captionEditor/toolbarInView.d.ts.map +1 -0
  20. package/lib/drawing/captionEditor/toolbarInView.js +53 -0
  21. package/lib/drawing/captionEditor/toolbarInView.js.map +1 -0
  22. package/lib/drawing/core/camera.d.ts +2 -0
  23. package/lib/drawing/core/camera.d.ts.map +1 -1
  24. package/lib/drawing/core/camera.js +2 -0
  25. package/lib/drawing/core/camera.js.map +1 -1
  26. package/lib/drawing/core/index.d.ts +1 -1
  27. package/lib/drawing/core/index.d.ts.map +1 -1
  28. package/lib/drawing/core/index.js +1 -1
  29. package/lib/drawing/core/index.js.map +1 -1
  30. package/lib/drawing/render/index.d.ts +1 -1
  31. package/lib/drawing/render/index.d.ts.map +1 -1
  32. package/lib/drawing/render/index.js +1 -1
  33. package/lib/drawing/render/index.js.map +1 -1
  34. package/lib/drawing/render/pageGrid.d.ts +16 -0
  35. package/lib/drawing/render/pageGrid.d.ts.map +1 -1
  36. package/lib/drawing/render/pageGrid.js +28 -10
  37. package/lib/drawing/render/pageGrid.js.map +1 -1
  38. package/lib/drawing/ui/PageField.d.ts +29 -0
  39. package/lib/drawing/ui/PageField.d.ts.map +1 -0
  40. package/lib/drawing/ui/PageField.js +38 -0
  41. package/lib/drawing/ui/PageField.js.map +1 -0
  42. package/lib/drawing/ui/PageGrid.d.ts +20 -0
  43. package/lib/drawing/ui/PageGrid.d.ts.map +1 -0
  44. package/lib/drawing/ui/PageGrid.js +26 -0
  45. package/lib/drawing/ui/PageGrid.js.map +1 -0
  46. package/lib/drawing/ui/PageSideInput.d.ts +28 -0
  47. package/lib/drawing/ui/PageSideInput.d.ts.map +1 -0
  48. package/lib/drawing/ui/PageSideInput.js +47 -0
  49. package/lib/drawing/ui/PageSideInput.js.map +1 -0
  50. package/lib/drawing/ui/PageToolbar.d.ts +16 -0
  51. package/lib/drawing/ui/PageToolbar.d.ts.map +1 -0
  52. package/lib/drawing/ui/PageToolbar.js +16 -0
  53. package/lib/drawing/ui/PageToolbar.js.map +1 -0
  54. package/lib/drawing/ui/PrintSheets.d.ts +32 -0
  55. package/lib/drawing/ui/PrintSheets.d.ts.map +1 -0
  56. package/lib/drawing/ui/PrintSheets.js +17 -0
  57. package/lib/drawing/ui/PrintSheets.js.map +1 -0
  58. package/lib/drawing/ui/TextToolIcon.d.ts +19 -0
  59. package/lib/drawing/ui/TextToolIcon.d.ts.map +1 -0
  60. package/lib/drawing/ui/TextToolIcon.js +21 -0
  61. package/lib/drawing/ui/TextToolIcon.js.map +1 -0
  62. package/lib/drawing/ui/ZoomControl.d.ts +25 -0
  63. package/lib/drawing/ui/ZoomControl.d.ts.map +1 -0
  64. package/lib/drawing/ui/ZoomControl.js +27 -0
  65. package/lib/drawing/ui/ZoomControl.js.map +1 -0
  66. package/lib/drawing/ui/index.d.ts +10 -0
  67. package/lib/drawing/ui/index.d.ts.map +1 -1
  68. package/lib/drawing/ui/index.js +7 -0
  69. package/lib/drawing/ui/index.js.map +1 -1
  70. package/lib/guide/ui/EmptyGuide.d.ts +5 -2
  71. package/lib/guide/ui/EmptyGuide.d.ts.map +1 -1
  72. package/lib/guide/ui/EmptyGuide.js +8 -3
  73. package/lib/guide/ui/EmptyGuide.js.map +1 -1
  74. package/lib/guide/ui/GuideFigures.d.ts +6 -0
  75. package/lib/guide/ui/GuideFigures.d.ts.map +1 -1
  76. package/lib/guide/ui/GuideFigures.js +5 -5
  77. package/lib/guide/ui/GuideFigures.js.map +1 -1
  78. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  79. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  80. package/lib/locales/de.json +4 -0
  81. package/lib/locales/en.json +4 -0
  82. package/lib/locales/es.json +4 -0
  83. package/lib/locales/fr.json +4 -0
  84. package/lib/locales/it.json +4 -0
  85. package/lib/log/core/index.d.ts +4 -0
  86. package/lib/log/core/index.d.ts.map +1 -0
  87. package/lib/log/core/index.js +3 -0
  88. package/lib/log/core/index.js.map +1 -0
  89. package/lib/log/core/logGroups.d.ts +87 -0
  90. package/lib/log/core/logGroups.d.ts.map +1 -0
  91. package/lib/log/core/logGroups.js +85 -0
  92. package/lib/log/core/logGroups.js.map +1 -0
  93. package/lib/log/core/logLines.d.ts +19 -0
  94. package/lib/log/core/logLines.d.ts.map +1 -0
  95. package/lib/log/core/logLines.js +36 -0
  96. package/lib/log/core/logLines.js.map +1 -0
  97. package/lib/log/ui/LogBadge.d.ts +39 -0
  98. package/lib/log/ui/LogBadge.d.ts.map +1 -0
  99. package/lib/log/ui/LogBadge.js +28 -0
  100. package/lib/log/ui/LogBadge.js.map +1 -0
  101. package/lib/log/ui/LogCallouts.d.ts +55 -0
  102. package/lib/log/ui/LogCallouts.d.ts.map +1 -0
  103. package/lib/log/ui/LogCallouts.js +38 -0
  104. package/lib/log/ui/LogCallouts.js.map +1 -0
  105. package/lib/log/ui/index.d.ts +7 -0
  106. package/lib/log/ui/index.d.ts.map +1 -0
  107. package/lib/log/ui/index.js +5 -0
  108. package/lib/log/ui/index.js.map +1 -0
  109. package/lib/log/ui/logIcon.d.ts +9 -0
  110. package/lib/log/ui/logIcon.d.ts.map +1 -0
  111. package/lib/log/ui/logIcon.js +17 -0
  112. package/lib/log/ui/logIcon.js.map +1 -0
  113. package/lib/log/ui/useLogEntries.d.ts +15 -0
  114. package/lib/log/ui/useLogEntries.d.ts.map +1 -0
  115. package/lib/log/ui/useLogEntries.js +47 -0
  116. package/lib/log/ui/useLogEntries.js.map +1 -0
  117. package/lib/mass/core/index.d.ts +1 -0
  118. package/lib/mass/core/index.d.ts.map +1 -1
  119. package/lib/mass/core/index.js +1 -0
  120. package/lib/mass/core/index.js.map +1 -1
  121. package/lib/mass/core/massDomain.d.ts.map +1 -1
  122. package/lib/mass/core/massDomain.js +9 -5
  123. package/lib/mass/core/massDomain.js.map +1 -1
  124. package/lib/mass/core/massSpectrum.d.ts +9 -0
  125. package/lib/mass/core/massSpectrum.d.ts.map +1 -1
  126. package/lib/mass/core/massSpectrum.js.map +1 -1
  127. package/lib/mass/core/verticalScale.d.ts +30 -0
  128. package/lib/mass/core/verticalScale.d.ts.map +1 -0
  129. package/lib/mass/core/verticalScale.js +40 -0
  130. package/lib/mass/core/verticalScale.js.map +1 -0
  131. package/lib/mass/ui/MassChart.d.ts.map +1 -1
  132. package/lib/mass/ui/MassChart.js +4 -38
  133. package/lib/mass/ui/MassChart.js.map +1 -1
  134. package/lib/mass/ui/massChartLayers.d.ts +31 -0
  135. package/lib/mass/ui/massChartLayers.d.ts.map +1 -0
  136. package/lib/mass/ui/massChartLayers.js +57 -0
  137. package/lib/mass/ui/massChartLayers.js.map +1 -0
  138. package/lib/structure/core/conformerMinimise.d.ts +13 -4
  139. package/lib/structure/core/conformerMinimise.d.ts.map +1 -1
  140. package/lib/structure/core/conformerMinimise.js +23 -6
  141. package/lib/structure/core/conformerMinimise.js.map +1 -1
  142. package/lib/structure/core/conformerRefine.d.ts +2 -2
  143. package/lib/structure/core/conformerRefine.d.ts.map +1 -1
  144. package/lib/structure/core/conformerRefine.js +23 -7
  145. package/lib/structure/core/conformerRefine.js.map +1 -1
  146. package/lib/structure/core/conformers.d.ts +8 -3
  147. package/lib/structure/core/conformers.d.ts.map +1 -1
  148. package/lib/structure/core/conformers.js +10 -7
  149. package/lib/structure/core/conformers.js.map +1 -1
  150. package/lib/structure/core/geometryRelaxer.d.ts +10 -3
  151. package/lib/structure/core/geometryRelaxer.d.ts.map +1 -1
  152. package/lib/structure/core/index.d.ts +1 -1
  153. package/lib/structure/core/index.d.ts.map +1 -1
  154. package/lib/structure/core/index.js.map +1 -1
  155. package/lib/structure/core/relaxerLogLines.d.ts +16 -0
  156. package/lib/structure/core/relaxerLogLines.d.ts.map +1 -0
  157. package/lib/structure/core/relaxerLogLines.js +33 -0
  158. package/lib/structure/core/relaxerLogLines.js.map +1 -0
  159. package/lib/structure/core/structurePicture.d.ts +32 -1
  160. package/lib/structure/core/structurePicture.d.ts.map +1 -1
  161. package/lib/structure/core/structurePicture.js +29 -2
  162. package/lib/structure/core/structurePicture.js.map +1 -1
  163. package/lib/structure/ui/StructureEditor.d.ts +2 -1
  164. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  165. package/lib/structure/ui/StructureEditor.js +9 -3
  166. package/lib/structure/ui/StructureEditor.js.map +1 -1
  167. package/lib/structure/ui/StructureEditorGuide.d.ts +15 -0
  168. package/lib/structure/ui/StructureEditorGuide.d.ts.map +1 -0
  169. package/lib/structure/ui/StructureEditorGuide.js +26 -0
  170. package/lib/structure/ui/StructureEditorGuide.js.map +1 -0
  171. package/lib/structure/ui/structureEditorProps.d.ts +11 -1
  172. package/lib/structure/ui/structureEditorProps.d.ts.map +1 -1
  173. package/lib/structure/ui/useCanvasPress.d.ts +23 -0
  174. package/lib/structure/ui/useCanvasPress.d.ts.map +1 -0
  175. package/lib/structure/ui/useCanvasPress.js +53 -0
  176. package/lib/structure/ui/useCanvasPress.js.map +1 -0
  177. package/lib/ui.d.ts +1 -0
  178. package/lib/ui.d.ts.map +1 -1
  179. package/lib/ui.js +1 -0
  180. package/lib/ui.js.map +1 -1
  181. package/lib/xps/core/detectFormat.d.ts +6 -0
  182. package/lib/xps/core/detectFormat.d.ts.map +1 -1
  183. package/lib/xps/core/detectFormat.js +8 -0
  184. package/lib/xps/core/detectFormat.js.map +1 -1
  185. package/lib/xps/core/xpsEditorApi.d.ts +16 -0
  186. package/lib/xps/core/xpsEditorApi.d.ts.map +1 -1
  187. package/lib/xps/ui/XpsCanvas.d.ts +10 -1
  188. package/lib/xps/ui/XpsCanvas.d.ts.map +1 -1
  189. package/lib/xps/ui/XpsCanvas.js +14 -3
  190. package/lib/xps/ui/XpsCanvas.js.map +1 -1
  191. package/lib/xps/ui/XpsChart.d.ts.map +1 -1
  192. package/lib/xps/ui/XpsChart.js +12 -43
  193. package/lib/xps/ui/XpsChart.js.map +1 -1
  194. package/lib/xps/ui/XpsEditor.d.ts +8 -0
  195. package/lib/xps/ui/XpsEditor.d.ts.map +1 -1
  196. package/lib/xps/ui/XpsEditor.js +2 -2
  197. package/lib/xps/ui/XpsEditor.js.map +1 -1
  198. package/lib/xps/ui/XpsShell.d.ts +5 -0
  199. package/lib/xps/ui/XpsShell.d.ts.map +1 -1
  200. package/lib/xps/ui/XpsShell.js +18 -4
  201. package/lib/xps/ui/XpsShell.js.map +1 -1
  202. package/lib/xps/ui/dropEvents.d.ts +8 -1
  203. package/lib/xps/ui/dropEvents.d.ts.map +1 -1
  204. package/lib/xps/ui/dropEvents.js +15 -1
  205. package/lib/xps/ui/dropEvents.js.map +1 -1
  206. package/lib/xps/ui/useSpectrumDrop.d.ts +6 -0
  207. package/lib/xps/ui/useSpectrumDrop.d.ts.map +1 -1
  208. package/lib/xps/ui/useSpectrumDrop.js +1 -1
  209. package/lib/xps/ui/useSpectrumDrop.js.map +1 -1
  210. package/lib/xps/ui/useXpsEditorHandle.d.ts +4 -1
  211. package/lib/xps/ui/useXpsEditorHandle.d.ts.map +1 -1
  212. package/lib/xps/ui/useXpsEditorHandle.js +6 -2
  213. package/lib/xps/ui/useXpsEditorHandle.js.map +1 -1
  214. package/lib/xps/ui/useXpsReadout.d.ts +43 -0
  215. package/lib/xps/ui/useXpsReadout.d.ts.map +1 -0
  216. package/lib/xps/ui/useXpsReadout.js +59 -0
  217. package/lib/xps/ui/useXpsReadout.js.map +1 -0
  218. package/lib/xps/ui/xpsChartProps.d.ts +9 -0
  219. package/lib/xps/ui/xpsChartProps.d.ts.map +1 -1
  220. package/lib/xtb/core/taggedLogger.d.ts +11 -0
  221. package/lib/xtb/core/taggedLogger.d.ts.map +1 -0
  222. package/lib/xtb/core/taggedLogger.js +31 -0
  223. package/lib/xtb/core/taggedLogger.js.map +1 -0
  224. package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -1
  225. package/lib/xtb/core/xtbRelaxer.js +13 -5
  226. package/lib/xtb/core/xtbRelaxer.js.map +1 -1
  227. package/package.json +4 -3
  228. package/src/core.ts +1 -0
  229. package/src/drawing/captionEditor/CaptionEditor.tsx +8 -3
  230. package/src/drawing/captionEditor/CaptionToolbar.tsx +18 -2
  231. package/src/drawing/captionEditor/index.ts +2 -0
  232. package/src/drawing/captionEditor/toolbarInView.ts +73 -0
  233. package/src/drawing/core/camera.ts +3 -0
  234. package/src/drawing/core/index.ts +1 -0
  235. package/src/drawing/render/index.ts +2 -0
  236. package/src/drawing/render/pageGrid.ts +29 -11
  237. package/src/drawing/ui/PageField.tsx +104 -0
  238. package/src/drawing/ui/PageGrid.tsx +48 -0
  239. package/src/drawing/ui/PageSideInput.tsx +81 -0
  240. package/src/drawing/ui/PageToolbar.tsx +45 -0
  241. package/src/drawing/ui/PrintSheets.tsx +57 -0
  242. package/src/drawing/ui/TextToolIcon.tsx +48 -0
  243. package/src/drawing/ui/ZoomControl.tsx +112 -0
  244. package/src/drawing/ui/index.ts +10 -0
  245. package/src/guide/ui/EmptyGuide.tsx +20 -13
  246. package/src/guide/ui/GuideFigures.tsx +15 -4
  247. package/src/locales/de.json +4 -0
  248. package/src/locales/en.json +4 -0
  249. package/src/locales/es.json +4 -0
  250. package/src/locales/fr.json +4 -0
  251. package/src/locales/it.json +4 -0
  252. package/src/log/core/index.ts +9 -0
  253. package/src/log/core/logGroups.ts +159 -0
  254. package/src/log/core/logLines.ts +44 -0
  255. package/src/log/ui/LogBadge.tsx +89 -0
  256. package/src/log/ui/LogCallouts.tsx +103 -0
  257. package/src/log/ui/index.ts +6 -0
  258. package/src/log/ui/logIcon.ts +21 -0
  259. package/src/log/ui/useLogEntries.ts +57 -0
  260. package/src/mass/core/index.ts +1 -0
  261. package/src/mass/core/massDomain.ts +9 -3
  262. package/src/mass/core/massSpectrum.ts +9 -0
  263. package/src/mass/core/verticalScale.ts +48 -0
  264. package/src/mass/ui/MassChart.tsx +12 -43
  265. package/src/mass/ui/massChartLayers.ts +66 -0
  266. package/src/structure/core/conformerMinimise.ts +34 -8
  267. package/src/structure/core/conformerRefine.ts +29 -13
  268. package/src/structure/core/conformers.ts +23 -12
  269. package/src/structure/core/geometryRelaxer.ts +11 -3
  270. package/src/structure/core/index.ts +1 -0
  271. package/src/structure/core/relaxerLogLines.ts +39 -0
  272. package/src/structure/core/structurePicture.ts +78 -4
  273. package/src/structure/ui/StructureEditor.tsx +13 -2
  274. package/src/structure/ui/StructureEditorGuide.tsx +35 -0
  275. package/src/structure/ui/structureEditorProps.ts +11 -1
  276. package/src/structure/ui/useCanvasPress.ts +69 -0
  277. package/src/ui.ts +1 -0
  278. package/src/xps/core/detectFormat.ts +9 -0
  279. package/src/xps/core/xpsEditorApi.ts +16 -0
  280. package/src/xps/ui/XpsCanvas.tsx +26 -3
  281. package/src/xps/ui/XpsChart.tsx +12 -56
  282. package/src/xps/ui/XpsEditor.tsx +10 -0
  283. package/src/xps/ui/XpsShell.tsx +37 -7
  284. package/src/xps/ui/dropEvents.ts +16 -1
  285. package/src/xps/ui/useSpectrumDrop.ts +7 -1
  286. package/src/xps/ui/useXpsEditorHandle.ts +12 -2
  287. package/src/xps/ui/useXpsReadout.ts +104 -0
  288. package/src/xps/ui/xpsChartProps.ts +9 -0
  289. package/src/xtb/core/taggedLogger.ts +35 -0
  290. package/src/xtb/core/xtbRelaxer.ts +15 -5
  291. package/styles/caption-editor.css +15 -1
  292. package/styles/chrome.css +164 -9
  293. package/styles/drawing.css +100 -0
@@ -8,13 +8,17 @@ import { AxisGuide } from '../../chart/ui/AxisGuide.tsx';
8
8
  import { SelectionRect } from '../../chart/ui/SelectionRect.tsx';
9
9
  import { chartSurfaceStyle } from '../../chart/ui/chartSurface.ts';
10
10
  import { useChartSize } from '../../chart/ui/useChartSize.ts';
11
- import type { MassSpectrum } from '../core/massSpectrum.ts';
12
11
  import { DEFAULT_LABEL_LIMIT } from '../core/massState.ts';
13
12
  import { mzDecimalsOf } from '../core/resolutionOf.ts';
14
13
 
15
14
  import { MassPointerTracker } from './MassPointerTracker.tsx';
16
15
  import { PeakLabels } from './PeakLabels.tsx';
17
16
  import { SpectrumTrace } from './SpectrumTrace.tsx';
17
+ import {
18
+ emphasisedLast,
19
+ labelledSpectrum,
20
+ spectrumYScales,
21
+ } from './massChartLayers.ts';
18
22
  import type { MassChartProps } from './massChartProps.ts';
19
23
  import { useMassPointer } from './useMassPointer.ts';
20
24
  import { useMassZoom } from './useMassZoom.ts';
@@ -120,6 +124,11 @@ export function MassChart(props: MassChartProps): ReactElement {
120
124
  () => emphasisedLast(spectra, emphasisedId),
121
125
  [spectra, emphasisedId],
122
126
  );
127
+ // Built once per window: the traces memoise their paths on their scale.
128
+ const yScales = useMemo(
129
+ () => spectrumYScales(spectra, yScale),
130
+ [spectra, yScale],
131
+ );
123
132
 
124
133
  // The crosshair reads every drawn spectrum, so it is written to what they
125
134
  // resolve together; the labels are of one spectrum, and written to its own.
@@ -178,7 +187,7 @@ export function MassChart(props: MassChartProps): ReactElement {
178
187
  spectrum={spectrum}
179
188
  plot={plot}
180
189
  xScale={xScale}
181
- yScale={yScale}
190
+ yScale={yScales.get(spectrum.id) ?? yScale}
182
191
  strokeWidth={
183
192
  spectrum.id === emphasisedId ? EMPHASISED_WIDTH : undefined
184
193
  }
@@ -192,7 +201,7 @@ export function MassChart(props: MassChartProps): ReactElement {
192
201
  spectrum={labelled}
193
202
  plot={plot}
194
203
  xScale={xScale}
195
- yScale={yScale}
204
+ yScale={yScales.get(labelled.id) ?? yScale}
196
205
  limit={labelLimit}
197
206
  showCharges={showCharges}
198
207
  mzDecimals={labelDecimals}
@@ -216,46 +225,6 @@ export function MassChart(props: MassChartProps): ReactElement {
216
225
  );
217
226
  }
218
227
 
219
- /**
220
- * The one spectrum whose peaks are labelled.
221
- * @param spectra - What the chart draws.
222
- * @param labelledId - The identity asked for, `null` for none, absent to let the
223
- * chart take the first.
224
- * @returns The spectrum, or `null` when none answers.
225
- */
226
- function labelledSpectrum(
227
- spectra: readonly MassSpectrum[],
228
- labelledId: string | null | undefined,
229
- ): MassSpectrum | null {
230
- if (labelledId === undefined) return spectra[0] ?? null;
231
- if (labelledId === null) return null;
232
- for (const spectrum of spectra) {
233
- if (spectrum.id === labelledId) return spectrum;
234
- }
235
- return null;
236
- }
237
-
238
- /**
239
- * The traces in painting order, with the emphasised one last — last is in
240
- * front, and in front is what lets a trace crossing a dozen others be followed.
241
- * @param spectra - The traces, in the order they were opened.
242
- * @param emphasisedId - Identity of the one to raise, `null` for none.
243
- * @returns The order to paint in — the array itself when nothing moves.
244
- */
245
- function emphasisedLast(
246
- spectra: readonly MassSpectrum[],
247
- emphasisedId: string | null,
248
- ): readonly MassSpectrum[] {
249
- if (emphasisedId === null) return spectra;
250
- const at = spectra.findIndex((spectrum) => spectrum.id === emphasisedId);
251
- if (at === -1 || at === spectra.length - 1) return spectra;
252
- return [
253
- ...spectra.slice(0, at),
254
- ...spectra.slice(at + 1),
255
- spectra[at] as MassSpectrum,
256
- ];
257
- }
258
-
259
228
  /** What the chart is, and what can be done to it, for whoever cannot see it. */
260
229
  const CHART_LABEL =
261
230
  'Mass spectrum. Drag across it to zoom the m/z axis, drag below the baseline to take the intensity axis with it, turn the wheel to scale the intensity, and double click to fit everything again.';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Which spectrum a mass chart writes its labels on, in what order it paints
3
+ * them, and against which intensity axis each one is drawn.
4
+ */
5
+
6
+ import type { ChartScale } from '../../chart/core/chartScale.ts';
7
+ import type { MassSpectrum } from '../core/massSpectrum.ts';
8
+ import { spectrumYScale } from '../core/verticalScale.ts';
9
+
10
+ /**
11
+ * The one spectrum whose peaks are labelled.
12
+ * @param spectra - What the chart draws.
13
+ * @param labelledId - The identity asked for, `null` for none, absent to let the
14
+ * chart take the first.
15
+ * @returns The spectrum, or `null` when none answers.
16
+ */
17
+ export function labelledSpectrum(
18
+ spectra: readonly MassSpectrum[],
19
+ labelledId: string | null | undefined,
20
+ ): MassSpectrum | null {
21
+ if (labelledId === undefined) return spectra[0] ?? null;
22
+ if (labelledId === null) return null;
23
+ for (const spectrum of spectra) {
24
+ if (spectrum.id === labelledId) return spectrum;
25
+ }
26
+ return null;
27
+ }
28
+
29
+ /**
30
+ * The traces in painting order, with the emphasised one last — last is in
31
+ * front, and in front is what lets a trace crossing a dozen others be followed.
32
+ * @param spectra - The traces, in the order they were opened.
33
+ * @param emphasisedId - Identity of the one to raise, `null` for none.
34
+ * @returns The order to paint in — the array itself when nothing moves.
35
+ */
36
+ export function emphasisedLast(
37
+ spectra: readonly MassSpectrum[],
38
+ emphasisedId: string | null,
39
+ ): readonly MassSpectrum[] {
40
+ if (emphasisedId === null) return spectra;
41
+ const at = spectra.findIndex((spectrum) => spectrum.id === emphasisedId);
42
+ if (at === -1 || at === spectra.length - 1) return spectra;
43
+ return [
44
+ ...spectra.slice(0, at),
45
+ ...spectra.slice(at + 1),
46
+ spectra[at] as MassSpectrum,
47
+ ];
48
+ }
49
+
50
+ /**
51
+ * The intensity axis each spectrum is drawn against, by identity.
52
+ * @param spectra - What the chart draws.
53
+ * @param yScale - The chart's intensity axis as it is currently zoomed.
54
+ * @returns The axis of each spectrum — the chart's own for every spectrum drawn
55
+ * as measured.
56
+ */
57
+ export function spectrumYScales(
58
+ spectra: readonly MassSpectrum[],
59
+ yScale: ChartScale,
60
+ ): Map<string, ChartScale> {
61
+ const scales = new Map<string, ChartScale>();
62
+ for (const spectrum of spectra) {
63
+ scales.set(spectrum.id, spectrumYScale(yScale, spectrum));
64
+ }
65
+ return scales;
66
+ }
@@ -2,6 +2,7 @@ import type { Molecule } from 'openchemlib';
2
2
  import { ForceFieldMMFF94 } from 'openchemlib';
3
3
 
4
4
  import { ordinal } from '../../format/core/words.ts';
5
+ import type { LogLine } from '../../log/core/logGroups.ts';
5
6
 
6
7
  import type { ConformerOptions } from './conformerOptions.ts';
7
8
 
@@ -13,19 +14,20 @@ import type { ConformerOptions } from './conformerOptions.ts';
13
14
  * than an exception. A non-zero return code from `minimise()` is *not* a
14
15
  * failure: ethyne returns 2 with a perfect geometry.
15
16
  *
16
- * Warnings count the conformers the generator handed back, kept or not, so one
17
- * number never means two things — a row number would, once one is dropped.
17
+ * A warning names its conformer by the count of conformers the generator
18
+ * handed back, kept or not, so one number never means two things — a row
19
+ * number would, once one is dropped.
18
20
  * @param conformer - The conformer to relax. Mutated.
19
21
  * @param options - Force field and iteration budget.
20
22
  * @param produced - 1-based position of the conformer in the generator's output.
21
- * @param warnings - Receives one sentence when the energy is unknown.
23
+ * @param logs - Receives one warning when the energy is unknown.
22
24
  * @returns Total energy in kcal/mol, or `null` when none was computed.
23
25
  */
24
26
  export function minimiseConformer(
25
27
  conformer: Molecule,
26
28
  options: ConformerOptions,
27
29
  produced: number,
28
- warnings: string[],
30
+ logs: LogLine[],
29
31
  ): number | null {
30
32
  const algorithm = options.minimisation;
31
33
  if (algorithm === 'none') return null;
@@ -35,20 +37,44 @@ export function minimiseConformer(
35
37
  forceField.minimise({ maxIts: options.maxIterations });
36
38
  energy = forceField.getTotalEnergy();
37
39
  } catch (error) {
38
- warnings.push(
39
- `The ${ordinal(produced)} conformer produced could not be minimised with ${algorithm} (${readable(error)}), so its energy is unknown.`,
40
+ logs.push(
41
+ producedWarning(
42
+ produced,
43
+ `It could not be minimised with ${algorithm} (${readable(error)}), so its energy is unknown.`,
44
+ ),
40
45
  );
41
46
  return null;
42
47
  }
43
48
  if (!Number.isFinite(energy)) {
44
- warnings.push(
45
- `The ${ordinal(produced)} conformer produced minimised to a non-finite ${algorithm} energy, so its energy is unknown.`,
49
+ logs.push(
50
+ producedWarning(
51
+ produced,
52
+ `It minimised to a non-finite ${algorithm} energy, so its energy is unknown.`,
53
+ ),
46
54
  );
47
55
  return null;
48
56
  }
49
57
  return energy;
50
58
  }
51
59
 
60
+ /**
61
+ * The label of a conformer as the generator handed it back, which a message
62
+ * about it is shown under.
63
+ * @param produced - 1-based position of the conformer in the generator's output.
64
+ * @returns E.g. `3rd conformer produced`.
65
+ */
66
+ export function producedSource(produced: number): string {
67
+ return `${ordinal(produced)} conformer produced`;
68
+ }
69
+
70
+ function producedWarning(produced: number, message: string): LogLine {
71
+ return {
72
+ levelLabel: 'warn',
73
+ message,
74
+ meta: { source: producedSource(produced) },
75
+ };
76
+ }
77
+
52
78
  /** What {@link rankByEnergy} reads and rewrites on a conformer. */
53
79
  export interface RankedConformer {
54
80
  id: number;
@@ -1,6 +1,8 @@
1
+ import { FifoLogger } from 'fifo-logger';
1
2
  import { Molecule } from 'openchemlib';
2
3
 
3
4
  import { ordinal } from '../../format/core/words.ts';
5
+ import type { LogLine } from '../../log/core/logGroups.ts';
4
6
 
5
7
  import type { RefinedMinimum } from './conformerRefineRank.ts';
6
8
  import {
@@ -20,6 +22,7 @@ import {
20
22
  writeRelaxedCoordinates,
21
23
  } from './moleculeCoordinates.ts';
22
24
  import { toMolfileExport } from './molfileExport.ts';
25
+ import { relaxerLogLines } from './relaxerLogLines.ts';
23
26
 
24
27
  /** What refining one conformer produced, on top of its force-field numbers. */
25
28
  export interface ConformerRefinement {
@@ -70,8 +73,11 @@ export interface ConformerSetRefinement {
70
73
  reordered: number;
71
74
  }
72
75
 
73
- /** How a refinement pass is tuned, watched and cancelled. */
74
- export interface RefineConformersOptions extends RelaxerOptions {
76
+ /** How a refinement is tuned and watched; what it logs is kept on the set. */
77
+ export interface RefineConformersOptions extends Omit<
78
+ RelaxerOptions,
79
+ 'logger'
80
+ > {
75
81
  /**
76
82
  * Name of the method, for the label the UI shows.
77
83
  * @default 'GFN2-xTB'
@@ -155,11 +161,13 @@ export async function refineConformers(
155
161
  });
156
162
  }
157
163
 
164
+ const relaxerLog = new FifoLogger({ level: 'info' });
158
165
  const relaxed = await relax(
159
166
  prepared.map((entry) => entry.geometry),
160
167
  {
161
168
  onSettled: options.onSettled,
162
169
  signal: options.signal,
170
+ logger: relaxerLog,
163
171
  },
164
172
  );
165
173
  if (relaxed.length !== set.conformers.length) {
@@ -170,7 +178,9 @@ export async function refineConformers(
170
178
 
171
179
  const tolerance =
172
180
  options.sameEnergyTolerance ?? REFINED_SAME_ENERGY_TOLERANCE;
173
- const warnings = [...set.warnings];
181
+ const own: LogLine[] = [];
182
+ // Each structure's label, `null` for one merged away with its messages.
183
+ const sources = new Array<string | null>(prepared.length).fill(null);
174
184
  const kept: Conformer[] = [];
175
185
  const minima: RefinedMinimum[] = [];
176
186
  let merged = 0;
@@ -188,13 +198,14 @@ export async function refineConformers(
188
198
  merged++;
189
199
  continue;
190
200
  }
191
- for (const warning of result.warnings) {
192
- warnings.push(`The ${ordinal(conformer.id)} conformer: ${warning}`);
193
- }
201
+ const source = `${ordinal(conformer.id)} conformer`;
202
+ sources[index] = source;
194
203
  if (!result.converged) {
195
- warnings.push(
196
- `The ${ordinal(conformer.id)} conformer did not reach a ${method} minimum in ${result.cycles} cycles, so its refined energy is an upper bound.`,
197
- );
204
+ own.push({
205
+ levelLabel: 'warn',
206
+ message: `It did not reach a ${method} minimum in ${result.cycles} cycles, so its refined energy is an upper bound.`,
207
+ meta: { source },
208
+ });
198
209
  }
199
210
  kept.push({
200
211
  ...conformer,
@@ -214,15 +225,20 @@ export async function refineConformers(
214
225
  }
215
226
 
216
227
  if (merged > 0) {
217
- warnings.push(
218
- `${merged} conformer(s) relaxed into a ${method} minimum the set already held, so they were dropped.`,
219
- );
228
+ own.push({
229
+ levelLabel: 'info',
230
+ message: `${merged} conformer(s) relaxed into a ${method} minimum the set already held, so they were dropped.`,
231
+ });
220
232
  }
221
233
  const ranked = rankByRefinedEnergy(kept);
222
234
  return {
223
235
  ...set,
224
236
  conformers: ranked.conformers,
225
- warnings,
237
+ logs: [
238
+ ...set.logs,
239
+ ...relaxerLogLines(relaxerLog.getLogs(), sources),
240
+ ...own,
241
+ ],
226
242
  rankedBy: REFINED_RANKING,
227
243
  refinement: {
228
244
  method,
@@ -1,8 +1,12 @@
1
1
  import type { Molecule } from 'openchemlib';
2
2
 
3
- import { ordinal } from '../../format/core/words.ts';
3
+ import type { LogLine } from '../../log/core/logGroups.ts';
4
4
 
5
- import { minimiseConformer, rankByEnergy } from './conformerMinimise.ts';
5
+ import {
6
+ minimiseConformer,
7
+ producedSource,
8
+ rankByEnergy,
9
+ } from './conformerMinimise.ts';
6
10
  import { isKeptMinimum, minimisedShapes } from './conformerMinimum.ts';
7
11
  import type {
8
12
  ConformerOptions,
@@ -62,8 +66,12 @@ export interface ConformerSet {
62
66
  stoppedBy: StopReason;
63
67
  /** Wall-clock duration of the run, initialisation and continuations included. */
64
68
  elapsedMilliseconds: number;
65
- /** Plain sentences about conformers that were dropped or left unminimised. */
66
- warnings: string[];
69
+ /**
70
+ * What the run has to say: conformers dropped (`error`), left without an
71
+ * energy (`warn`), merged by a refinement (`info`). Plain, so the set can be
72
+ * posted from a worker and saved in a figure with them.
73
+ */
74
+ logs: LogLine[];
67
75
  /** The force field that was asked for, echoed so a reader knows what the energies mean. */
68
76
  minimisation: MinimisationAlgorithm;
69
77
  /** Conformers the generator handed back, dropped ones included: where a continuation resumes. */
@@ -109,7 +117,7 @@ export type ConformerLimits = Pick<
109
117
  * @param molecule - Structure to embed. Not mutated.
110
118
  * @param options - Strategy, limits, seed and force field.
111
119
  * @param now - Clock used for the time budget, injectable for tests.
112
- * @returns Every conformer kept, most stable first, with relative energies and any warnings.
120
+ * @returns Every conformer kept, most stable first, with relative energies and what the run logged.
113
121
  * @throws {Error} When the structure is empty or OpenChemLib refuses to initialise it.
114
122
  */
115
123
  export function generateConformers(
@@ -162,7 +170,7 @@ interface Accumulator {
162
170
  conformers: Conformer[];
163
171
  /** Shape of each conformer, `null` for one without an energy. */
164
172
  shapes: Array<ConformerShape | null>;
165
- warnings: string[];
173
+ logs: LogLine[];
166
174
  }
167
175
 
168
176
  function runConformers(
@@ -197,7 +205,7 @@ function runConformers(
197
205
  const into: Accumulator = {
198
206
  conformers,
199
207
  shapes: minimisedShapes(conformers),
200
- warnings: previous === null ? [] : [...previous.warnings],
208
+ logs: previous === null ? [] : [...previous.logs],
201
209
  };
202
210
  const budget = Math.max(options.timeoutSeconds * 1000, 0);
203
211
  const stoppedBy = collect(
@@ -214,7 +222,7 @@ function runConformers(
214
222
  potentialConformerCount,
215
223
  stoppedBy,
216
224
  elapsedMilliseconds: (previous?.elapsedMilliseconds ?? 0) + now() - start,
217
- warnings: into.warnings,
225
+ logs: into.logs,
218
226
  minimisation: options.minimisation,
219
227
  produced: session.produced,
220
228
  options,
@@ -245,16 +253,19 @@ function collect(
245
253
  }
246
254
  session.produced++;
247
255
  if (!hasFiniteCoordinates(conformer)) {
248
- into.warnings.push(
249
- `The ${ordinal(session.produced)} conformer produced was dropped: the generator placed some of its atoms at non-finite coordinates.`,
250
- );
256
+ into.logs.push({
257
+ levelLabel: 'error',
258
+ message:
259
+ 'It was dropped: the generator placed some of its atoms at non-finite coordinates.',
260
+ meta: { source: producedSource(session.produced) },
261
+ });
251
262
  continue;
252
263
  }
253
264
  const energy = minimiseConformer(
254
265
  conformer,
255
266
  options,
256
267
  session.produced,
257
- into.warnings,
268
+ into.logs,
258
269
  );
259
270
  const shape = energy === null ? null : conformerShape(conformer);
260
271
  if (
@@ -1,3 +1,5 @@
1
+ import type { LightLogger } from 'cheminfo-types';
2
+
1
3
  /**
2
4
  * A geometry a relaxer is handed: element symbols plus flat Cartesian
3
5
  * coordinates in ångström, `x,y,z` per atom.
@@ -33,12 +35,18 @@ export interface RelaxedGeometry {
33
35
  cycles: number;
34
36
  /** Whether the optimizer met its convergence criteria. */
35
37
  converged: boolean;
36
- /** Plain sentences about anything the caller should know. */
37
- warnings: string[];
38
38
  }
39
39
 
40
- /** How a relaxation run is watched and cancelled. */
40
+ /** How a relaxation run is watched, cancelled and heard from. */
41
41
  export interface RelaxerOptions {
42
+ /**
43
+ * Receives what the relaxer has to say: `error` for something dropped while
44
+ * the rest went on, `warn` for what changes how a result must be read, `info`
45
+ * for context. An entry about one structure carries `structure`, its index
46
+ * in the batch; one without it is about the whole batch.
47
+ * @default nothing is reported
48
+ */
49
+ logger?: LightLogger;
42
50
  /**
43
51
  * Called as each structure finishes, so a caller can show progress over a
44
52
  * batch that runs for seconds.
@@ -90,6 +90,7 @@ export { looksLikeSmarts, readStructure } from './readStructure.ts';
90
90
  export type { StructureError } from './structureError.ts';
91
91
  export { structureError } from './structureError.ts';
92
92
  export type {
93
+ StructureDepictorOptions,
93
94
  StructurePicture,
94
95
  StructurePictureOptions,
95
96
  } from './structurePicture.ts';
@@ -0,0 +1,39 @@
1
+ import type { LogEntry } from 'fifo-logger';
2
+
3
+ import type { LogLine } from '../../log/core/logGroups.ts';
4
+
5
+ /**
6
+ * What a relaxer logged about a batch, as lines a conformer set keeps: an
7
+ * entry about one structure is labelled with that structure's source, an entry
8
+ * about a structure that was dropped is dropped with it, and an entry naming no
9
+ * structure is about the whole batch — or, in a batch of one, about its only
10
+ * structure.
11
+ * @param entries - What the relaxer logged, each entry about one structure
12
+ * carrying `structure`, its index in the batch.
13
+ * @param sources - The label of each structure, `null` for one that was
14
+ * dropped.
15
+ * @returns Plain lines, in the order they were logged.
16
+ */
17
+ export function relaxerLogLines(
18
+ entries: readonly LogEntry[],
19
+ sources: ReadonlyArray<string | null>,
20
+ ): LogLine[] {
21
+ const lines: LogLine[] = [];
22
+ for (const entry of entries) {
23
+ const { structure, ...meta } = entry.meta ?? {};
24
+ const index =
25
+ typeof structure === 'number'
26
+ ? structure
27
+ : sources.length === 1
28
+ ? 0
29
+ : null;
30
+ const source = index === null ? undefined : sources[index];
31
+ if (source === null) continue;
32
+ lines.push({
33
+ levelLabel: entry.levelLabel,
34
+ message: entry.error?.message ?? entry.message,
35
+ meta: source === undefined ? meta : { ...meta, source },
36
+ });
37
+ }
38
+ return lines;
39
+ }
@@ -9,7 +9,7 @@
9
9
  * times the drawing.
10
10
  */
11
11
 
12
- import type { Molecule } from 'openchemlib';
12
+ import type { Molecule, MoleculeToSVGOptions } from 'openchemlib';
13
13
 
14
14
  import type { FigurePixels } from '../../download/core/figureScale.ts';
15
15
 
@@ -28,8 +28,43 @@ export interface StructurePictureOptions {
28
28
  * @default '#ffffff'
29
29
  */
30
30
  background?: string;
31
+ /**
32
+ * The id of the document, which its own style rules are scoped to. Named, the
33
+ * same structure gives the same file on every run, which a figure kept in a
34
+ * repository needs.
35
+ * @default undefined — numbered by OpenChemLib, from a counter of its own
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Whether the stereo text is written: "abs" and the enantiomer note under
40
+ * the structure, the R and S of each centre, E and Z, and the "?" of a centre
41
+ * left undefined. The wedges are drawn either way; a figure read at a glance
42
+ * is clearer without the labels.
43
+ * @default true
44
+ */
45
+ stereoText?: boolean;
46
+ /**
47
+ * The type the atom labels are set in, as a CSS `font-family`. OpenChemLib
48
+ * writes `sans-serif` into the document's own style, which no stylesheet of
49
+ * a page reaches when the file is opened on its own.
50
+ * @default undefined — `sans-serif`, as OpenChemLib writes it
51
+ */
52
+ fontFamily?: string;
53
+ /**
54
+ * More of OpenChemLib's drawing options — atom numbers, grey bonds, no
55
+ * implicit hydrogens. The size and the crop are not among them: they follow
56
+ * `bondLength`.
57
+ * @default {}
58
+ */
59
+ depictor?: StructureDepictorOptions;
31
60
  }
32
61
 
62
+ /** OpenChemLib's drawing options a picture may set; the size is its own. */
63
+ export type StructureDepictorOptions = Omit<
64
+ MoleculeToSVGOptions,
65
+ 'autoCrop' | 'autoCropMargin' | 'maxAVBL'
66
+ >;
67
+
33
68
  /** A structure drawn, and how big it came out. */
34
69
  export interface StructurePicture extends FigurePixels {
35
70
  /** The SVG document, ready to be saved or rasterized. */
@@ -69,17 +104,56 @@ export function structurePicture(
69
104
  molecule: Molecule,
70
105
  options: StructurePictureOptions = {},
71
106
  ): StructurePicture {
72
- const { bondLength = STRUCTURE_BOND_LENGTH, background = '#ffffff' } =
73
- options;
74
- const markup = molecule.toSVG(CANVAS, CANVAS, undefined, {
107
+ const {
108
+ bondLength = STRUCTURE_BOND_LENGTH,
109
+ background = '#ffffff',
110
+ id,
111
+ stereoText = true,
112
+ fontFamily,
113
+ depictor,
114
+ } = options;
115
+ const drawn = molecule.toSVG(CANVAS, CANVAS, id, {
116
+ ...depictor,
117
+ ...(stereoText ? undefined : NO_STEREO_TEXT),
75
118
  autoCrop: true,
76
119
  autoCropMargin: Math.max(2, Math.round(bondLength / 6)),
77
120
  maxAVBL: Math.max(1, Math.round(bondLength)),
78
121
  });
122
+ const markup =
123
+ fontFamily === undefined ? drawn : withFontFamily(drawn, fontFamily);
79
124
 
80
125
  return { markup: painted(markup, background), ...sizeOf(markup) };
81
126
  }
82
127
 
128
+ /** What leaves the stereo text out of a picture, wedges kept. */
129
+ const NO_STEREO_TEXT: StructureDepictorOptions = {
130
+ suppressChiralText: true,
131
+ suppressCIPParity: true,
132
+ suppressESR: true,
133
+ noStereoProblem: true,
134
+ };
135
+
136
+ /** The rule OpenChemLib sets the labels' type with, in the document's style. */
137
+ const FONT_RULE = /(?<rule> text \{font-family: )sans-serif;/u;
138
+
139
+ /**
140
+ * Set the labels in another type than the `sans-serif` OpenChemLib names.
141
+ *
142
+ * The family is written into a style element, so whatever could close the
143
+ * rule or the element is left out of it.
144
+ * @param markup - The document as OpenChemLib wrote it.
145
+ * @param fontFamily - The CSS `font-family`.
146
+ * @returns The document.
147
+ */
148
+ function withFontFamily(markup: string, fontFamily: string): string {
149
+ const family = fontFamily.replaceAll(/[{};<>&]/gu, '').trim();
150
+ if (family === '') return markup;
151
+ return markup.replace(
152
+ FONT_RULE,
153
+ (_match, rule: string) => `${rule}${family};`,
154
+ );
155
+ }
156
+
83
157
  /**
84
158
  * Paint a background into the document, so the file does not open
85
159
  * transparent.
@@ -17,10 +17,12 @@ import { EditorHelpButton } from './EditorHelpButton.tsx';
17
17
  import { EditorImportButton } from './EditorImportButton.tsx';
18
18
  import { EditorImportProblem } from './EditorImportProblem.tsx';
19
19
  import { StructureDropOverlay } from './StructureDropOverlay.tsx';
20
+ import { StructureEditorGuide } from './StructureEditorGuide.tsx';
20
21
  import { StructureEditorSplash } from './StructureEditorSplash.tsx';
21
22
  import { ToolbarTooltip } from './ToolbarTooltip.tsx';
22
23
  import type { StructureEditorChange } from './editorChange.ts';
23
24
  import type { StructureEditorProps } from './structureEditorProps.ts';
25
+ import { useCanvasPress } from './useCanvasPress.ts';
24
26
  import { useDebouncedChange } from './useDebouncedChange.ts';
25
27
  import { useEditorStructure } from './useEditorStructure.ts';
26
28
  import { useStructureDrop } from './useStructureDrop.ts';
@@ -42,7 +44,8 @@ const EditorCanvas = lazy(async () => {
42
44
  /**
43
45
  * The canvas structure editor, sized to fill its container and never to hide
44
46
  * part of its toolbar, with a tooltip on every toolbar button, a guide to the
45
- * keys, and a splash on an empty canvas saying how to start.
47
+ * keys, and a splash on an empty canvas saying how to start — or the site's own
48
+ * guide in its place.
46
49
  * @param props - What to draw, when to reload it, and where to send it.
47
50
  * @returns The editor.
48
51
  */
@@ -61,6 +64,7 @@ export function StructureEditor(props: StructureEditorProps): ReactElement {
61
64
  exportable = true,
62
65
  importable = true,
63
66
  onImport,
67
+ guide,
64
68
  className,
65
69
  style,
66
70
  } = props;
@@ -86,6 +90,9 @@ export function StructureEditor(props: StructureEditorProps): ReactElement {
86
90
  });
87
91
  const takesImports = importable && mode === 'molecule';
88
92
  const drop = useStructureDrop(takesImports ? imports.load : undefined);
93
+ const press = useCanvasPress();
94
+ const empty = mode === 'molecule' && drawing.empty && !drop.over;
95
+ const guided = guide !== undefined && empty;
89
96
 
90
97
  return (
91
98
  <div
@@ -96,6 +103,7 @@ export function StructureEditor(props: StructureEditorProps): ReactElement {
96
103
  : `structure-editor ${className}`
97
104
  }
98
105
  style={{ ...ROOT_STYLE, minHeight, ...style }}
106
+ onPointerDownCapture={guided ? press.onPointerDownCapture : undefined}
99
107
  {...drop.targetProps}
100
108
  >
101
109
  <Suspense
@@ -111,7 +119,10 @@ export function StructureEditor(props: StructureEditorProps): ReactElement {
111
119
  value={imports.idCode ?? value}
112
120
  mode={mode}
113
121
  />
114
- {splash && mode === 'molecule' && drawing.empty && !drop.over ? (
122
+ {guided && !press.pressed ? (
123
+ <StructureEditorGuide>{guide}</StructureEditorGuide>
124
+ ) : null}
125
+ {splash && guide === undefined && empty ? (
115
126
  <StructureEditorSplash importable={takesImports} />
116
127
  ) : null}
117
128
  {help ? (