react-cheminfo 0.132.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 (198) hide show
  1. package/lib/drawing/captionEditor/CaptionEditor.d.ts +3 -3
  2. package/lib/drawing/captionEditor/CaptionEditor.d.ts.map +1 -1
  3. package/lib/drawing/captionEditor/CaptionEditor.js +8 -4
  4. package/lib/drawing/captionEditor/CaptionEditor.js.map +1 -1
  5. package/lib/drawing/captionEditor/CaptionToolbar.d.ts +4 -2
  6. package/lib/drawing/captionEditor/CaptionToolbar.d.ts.map +1 -1
  7. package/lib/drawing/captionEditor/CaptionToolbar.js +6 -4
  8. package/lib/drawing/captionEditor/CaptionToolbar.js.map +1 -1
  9. package/lib/drawing/captionEditor/index.d.ts +2 -0
  10. package/lib/drawing/captionEditor/index.d.ts.map +1 -1
  11. package/lib/drawing/captionEditor/index.js +1 -0
  12. package/lib/drawing/captionEditor/index.js.map +1 -1
  13. package/lib/drawing/captionEditor/toolbarInView.d.ts +40 -0
  14. package/lib/drawing/captionEditor/toolbarInView.d.ts.map +1 -0
  15. package/lib/drawing/captionEditor/toolbarInView.js +53 -0
  16. package/lib/drawing/captionEditor/toolbarInView.js.map +1 -0
  17. package/lib/drawing/core/camera.d.ts +2 -0
  18. package/lib/drawing/core/camera.d.ts.map +1 -1
  19. package/lib/drawing/core/camera.js +2 -0
  20. package/lib/drawing/core/camera.js.map +1 -1
  21. package/lib/drawing/core/index.d.ts +1 -1
  22. package/lib/drawing/core/index.d.ts.map +1 -1
  23. package/lib/drawing/core/index.js +1 -1
  24. package/lib/drawing/core/index.js.map +1 -1
  25. package/lib/drawing/render/index.d.ts +1 -1
  26. package/lib/drawing/render/index.d.ts.map +1 -1
  27. package/lib/drawing/render/index.js +1 -1
  28. package/lib/drawing/render/index.js.map +1 -1
  29. package/lib/drawing/render/pageGrid.d.ts +16 -0
  30. package/lib/drawing/render/pageGrid.d.ts.map +1 -1
  31. package/lib/drawing/render/pageGrid.js +28 -10
  32. package/lib/drawing/render/pageGrid.js.map +1 -1
  33. package/lib/drawing/ui/PageField.d.ts +29 -0
  34. package/lib/drawing/ui/PageField.d.ts.map +1 -0
  35. package/lib/drawing/ui/PageField.js +38 -0
  36. package/lib/drawing/ui/PageField.js.map +1 -0
  37. package/lib/drawing/ui/PageGrid.d.ts +20 -0
  38. package/lib/drawing/ui/PageGrid.d.ts.map +1 -0
  39. package/lib/drawing/ui/PageGrid.js +26 -0
  40. package/lib/drawing/ui/PageGrid.js.map +1 -0
  41. package/lib/drawing/ui/PageSideInput.d.ts +28 -0
  42. package/lib/drawing/ui/PageSideInput.d.ts.map +1 -0
  43. package/lib/drawing/ui/PageSideInput.js +47 -0
  44. package/lib/drawing/ui/PageSideInput.js.map +1 -0
  45. package/lib/drawing/ui/PageToolbar.d.ts +16 -0
  46. package/lib/drawing/ui/PageToolbar.d.ts.map +1 -0
  47. package/lib/drawing/ui/PageToolbar.js +16 -0
  48. package/lib/drawing/ui/PageToolbar.js.map +1 -0
  49. package/lib/drawing/ui/PrintSheets.d.ts +32 -0
  50. package/lib/drawing/ui/PrintSheets.d.ts.map +1 -0
  51. package/lib/drawing/ui/PrintSheets.js +17 -0
  52. package/lib/drawing/ui/PrintSheets.js.map +1 -0
  53. package/lib/drawing/ui/TextToolIcon.d.ts +19 -0
  54. package/lib/drawing/ui/TextToolIcon.d.ts.map +1 -0
  55. package/lib/drawing/ui/TextToolIcon.js +21 -0
  56. package/lib/drawing/ui/TextToolIcon.js.map +1 -0
  57. package/lib/drawing/ui/ZoomControl.d.ts +25 -0
  58. package/lib/drawing/ui/ZoomControl.d.ts.map +1 -0
  59. package/lib/drawing/ui/ZoomControl.js +27 -0
  60. package/lib/drawing/ui/ZoomControl.js.map +1 -0
  61. package/lib/drawing/ui/index.d.ts +10 -0
  62. package/lib/drawing/ui/index.d.ts.map +1 -1
  63. package/lib/drawing/ui/index.js +7 -0
  64. package/lib/drawing/ui/index.js.map +1 -1
  65. package/lib/guide/ui/EmptyGuide.d.ts +5 -2
  66. package/lib/guide/ui/EmptyGuide.d.ts.map +1 -1
  67. package/lib/guide/ui/EmptyGuide.js +8 -3
  68. package/lib/guide/ui/EmptyGuide.js.map +1 -1
  69. package/lib/guide/ui/GuideFigures.d.ts +6 -0
  70. package/lib/guide/ui/GuideFigures.d.ts.map +1 -1
  71. package/lib/guide/ui/GuideFigures.js +5 -5
  72. package/lib/guide/ui/GuideFigures.js.map +1 -1
  73. package/lib/mass/core/index.d.ts +1 -0
  74. package/lib/mass/core/index.d.ts.map +1 -1
  75. package/lib/mass/core/index.js +1 -0
  76. package/lib/mass/core/index.js.map +1 -1
  77. package/lib/mass/core/massDomain.d.ts.map +1 -1
  78. package/lib/mass/core/massDomain.js +9 -5
  79. package/lib/mass/core/massDomain.js.map +1 -1
  80. package/lib/mass/core/massSpectrum.d.ts +9 -0
  81. package/lib/mass/core/massSpectrum.d.ts.map +1 -1
  82. package/lib/mass/core/massSpectrum.js.map +1 -1
  83. package/lib/mass/core/verticalScale.d.ts +30 -0
  84. package/lib/mass/core/verticalScale.d.ts.map +1 -0
  85. package/lib/mass/core/verticalScale.js +40 -0
  86. package/lib/mass/core/verticalScale.js.map +1 -0
  87. package/lib/mass/ui/MassChart.d.ts.map +1 -1
  88. package/lib/mass/ui/MassChart.js +4 -38
  89. package/lib/mass/ui/MassChart.js.map +1 -1
  90. package/lib/mass/ui/massChartLayers.d.ts +31 -0
  91. package/lib/mass/ui/massChartLayers.d.ts.map +1 -0
  92. package/lib/mass/ui/massChartLayers.js +57 -0
  93. package/lib/mass/ui/massChartLayers.js.map +1 -0
  94. package/lib/structure/core/index.d.ts +1 -1
  95. package/lib/structure/core/index.d.ts.map +1 -1
  96. package/lib/structure/core/index.js.map +1 -1
  97. package/lib/structure/core/structurePicture.d.ts +32 -1
  98. package/lib/structure/core/structurePicture.d.ts.map +1 -1
  99. package/lib/structure/core/structurePicture.js +29 -2
  100. package/lib/structure/core/structurePicture.js.map +1 -1
  101. package/lib/structure/ui/StructureEditor.d.ts +2 -1
  102. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  103. package/lib/structure/ui/StructureEditor.js +9 -3
  104. package/lib/structure/ui/StructureEditor.js.map +1 -1
  105. package/lib/structure/ui/StructureEditorGuide.d.ts +15 -0
  106. package/lib/structure/ui/StructureEditorGuide.d.ts.map +1 -0
  107. package/lib/structure/ui/StructureEditorGuide.js +26 -0
  108. package/lib/structure/ui/StructureEditorGuide.js.map +1 -0
  109. package/lib/structure/ui/structureEditorProps.d.ts +11 -1
  110. package/lib/structure/ui/structureEditorProps.d.ts.map +1 -1
  111. package/lib/structure/ui/useCanvasPress.d.ts +23 -0
  112. package/lib/structure/ui/useCanvasPress.d.ts.map +1 -0
  113. package/lib/structure/ui/useCanvasPress.js +53 -0
  114. package/lib/structure/ui/useCanvasPress.js.map +1 -0
  115. package/lib/xps/core/detectFormat.d.ts +6 -0
  116. package/lib/xps/core/detectFormat.d.ts.map +1 -1
  117. package/lib/xps/core/detectFormat.js +8 -0
  118. package/lib/xps/core/detectFormat.js.map +1 -1
  119. package/lib/xps/core/xpsEditorApi.d.ts +16 -0
  120. package/lib/xps/core/xpsEditorApi.d.ts.map +1 -1
  121. package/lib/xps/ui/XpsCanvas.d.ts +10 -1
  122. package/lib/xps/ui/XpsCanvas.d.ts.map +1 -1
  123. package/lib/xps/ui/XpsCanvas.js +14 -3
  124. package/lib/xps/ui/XpsCanvas.js.map +1 -1
  125. package/lib/xps/ui/XpsChart.d.ts.map +1 -1
  126. package/lib/xps/ui/XpsChart.js +12 -43
  127. package/lib/xps/ui/XpsChart.js.map +1 -1
  128. package/lib/xps/ui/XpsEditor.d.ts +8 -0
  129. package/lib/xps/ui/XpsEditor.d.ts.map +1 -1
  130. package/lib/xps/ui/XpsEditor.js +2 -2
  131. package/lib/xps/ui/XpsEditor.js.map +1 -1
  132. package/lib/xps/ui/XpsShell.d.ts +5 -0
  133. package/lib/xps/ui/XpsShell.d.ts.map +1 -1
  134. package/lib/xps/ui/XpsShell.js +18 -4
  135. package/lib/xps/ui/XpsShell.js.map +1 -1
  136. package/lib/xps/ui/dropEvents.d.ts +8 -1
  137. package/lib/xps/ui/dropEvents.d.ts.map +1 -1
  138. package/lib/xps/ui/dropEvents.js +15 -1
  139. package/lib/xps/ui/dropEvents.js.map +1 -1
  140. package/lib/xps/ui/useSpectrumDrop.d.ts +6 -0
  141. package/lib/xps/ui/useSpectrumDrop.d.ts.map +1 -1
  142. package/lib/xps/ui/useSpectrumDrop.js +1 -1
  143. package/lib/xps/ui/useSpectrumDrop.js.map +1 -1
  144. package/lib/xps/ui/useXpsEditorHandle.d.ts +4 -1
  145. package/lib/xps/ui/useXpsEditorHandle.d.ts.map +1 -1
  146. package/lib/xps/ui/useXpsEditorHandle.js +6 -2
  147. package/lib/xps/ui/useXpsEditorHandle.js.map +1 -1
  148. package/lib/xps/ui/useXpsReadout.d.ts +43 -0
  149. package/lib/xps/ui/useXpsReadout.d.ts.map +1 -0
  150. package/lib/xps/ui/useXpsReadout.js +59 -0
  151. package/lib/xps/ui/useXpsReadout.js.map +1 -0
  152. package/lib/xps/ui/xpsChartProps.d.ts +9 -0
  153. package/lib/xps/ui/xpsChartProps.d.ts.map +1 -1
  154. package/package.json +1 -1
  155. package/src/drawing/captionEditor/CaptionEditor.tsx +8 -3
  156. package/src/drawing/captionEditor/CaptionToolbar.tsx +18 -2
  157. package/src/drawing/captionEditor/index.ts +2 -0
  158. package/src/drawing/captionEditor/toolbarInView.ts +73 -0
  159. package/src/drawing/core/camera.ts +3 -0
  160. package/src/drawing/core/index.ts +1 -0
  161. package/src/drawing/render/index.ts +2 -0
  162. package/src/drawing/render/pageGrid.ts +29 -11
  163. package/src/drawing/ui/PageField.tsx +104 -0
  164. package/src/drawing/ui/PageGrid.tsx +48 -0
  165. package/src/drawing/ui/PageSideInput.tsx +81 -0
  166. package/src/drawing/ui/PageToolbar.tsx +45 -0
  167. package/src/drawing/ui/PrintSheets.tsx +57 -0
  168. package/src/drawing/ui/TextToolIcon.tsx +48 -0
  169. package/src/drawing/ui/ZoomControl.tsx +112 -0
  170. package/src/drawing/ui/index.ts +10 -0
  171. package/src/guide/ui/EmptyGuide.tsx +20 -13
  172. package/src/guide/ui/GuideFigures.tsx +15 -4
  173. package/src/mass/core/index.ts +1 -0
  174. package/src/mass/core/massDomain.ts +9 -3
  175. package/src/mass/core/massSpectrum.ts +9 -0
  176. package/src/mass/core/verticalScale.ts +48 -0
  177. package/src/mass/ui/MassChart.tsx +12 -43
  178. package/src/mass/ui/massChartLayers.ts +66 -0
  179. package/src/structure/core/index.ts +1 -0
  180. package/src/structure/core/structurePicture.ts +78 -4
  181. package/src/structure/ui/StructureEditor.tsx +13 -2
  182. package/src/structure/ui/StructureEditorGuide.tsx +35 -0
  183. package/src/structure/ui/structureEditorProps.ts +11 -1
  184. package/src/structure/ui/useCanvasPress.ts +69 -0
  185. package/src/xps/core/detectFormat.ts +9 -0
  186. package/src/xps/core/xpsEditorApi.ts +16 -0
  187. package/src/xps/ui/XpsCanvas.tsx +26 -3
  188. package/src/xps/ui/XpsChart.tsx +12 -56
  189. package/src/xps/ui/XpsEditor.tsx +10 -0
  190. package/src/xps/ui/XpsShell.tsx +37 -7
  191. package/src/xps/ui/dropEvents.ts +16 -1
  192. package/src/xps/ui/useSpectrumDrop.ts +7 -1
  193. package/src/xps/ui/useXpsEditorHandle.ts +12 -2
  194. package/src/xps/ui/useXpsReadout.ts +104 -0
  195. package/src/xps/ui/xpsChartProps.ts +9 -0
  196. package/styles/caption-editor.css +15 -1
  197. package/styles/chrome.css +130 -9
  198. package/styles/drawing.css +100 -0
@@ -34,14 +34,41 @@ const SIDE = /\b(?<side>width|height)="(?<pixels>\d+)px"/gu;
34
34
  * @returns The document and the size it came out at.
35
35
  */
36
36
  export function structurePicture(molecule, options = {}) {
37
- const { bondLength = STRUCTURE_BOND_LENGTH, background = '#ffffff' } = options;
38
- const markup = molecule.toSVG(CANVAS, CANVAS, undefined, {
37
+ const { bondLength = STRUCTURE_BOND_LENGTH, background = '#ffffff', id, stereoText = true, fontFamily, depictor, } = options;
38
+ const drawn = molecule.toSVG(CANVAS, CANVAS, id, {
39
+ ...depictor,
40
+ ...(stereoText ? undefined : NO_STEREO_TEXT),
39
41
  autoCrop: true,
40
42
  autoCropMargin: Math.max(2, Math.round(bondLength / 6)),
41
43
  maxAVBL: Math.max(1, Math.round(bondLength)),
42
44
  });
45
+ const markup = fontFamily === undefined ? drawn : withFontFamily(drawn, fontFamily);
43
46
  return { markup: painted(markup, background), ...sizeOf(markup) };
44
47
  }
48
+ /** What leaves the stereo text out of a picture, wedges kept. */
49
+ const NO_STEREO_TEXT = {
50
+ suppressChiralText: true,
51
+ suppressCIPParity: true,
52
+ suppressESR: true,
53
+ noStereoProblem: true,
54
+ };
55
+ /** The rule OpenChemLib sets the labels' type with, in the document's style. */
56
+ const FONT_RULE = /(?<rule> text \{font-family: )sans-serif;/u;
57
+ /**
58
+ * Set the labels in another type than the `sans-serif` OpenChemLib names.
59
+ *
60
+ * The family is written into a style element, so whatever could close the
61
+ * rule or the element is left out of it.
62
+ * @param markup - The document as OpenChemLib wrote it.
63
+ * @param fontFamily - The CSS `font-family`.
64
+ * @returns The document.
65
+ */
66
+ function withFontFamily(markup, fontFamily) {
67
+ const family = fontFamily.replaceAll(/[{};<>&]/gu, '').trim();
68
+ if (family === '')
69
+ return markup;
70
+ return markup.replace(FONT_RULE, (_match, rule) => `${rule}${family};`);
71
+ }
45
72
  /**
46
73
  * Paint a background into the document, so the file does not open
47
74
  * transparent.
@@ -1 +1 @@
1
- {"version":3,"file":"structurePicture.js","sourceRoot":"","sources":["../../../src/structure/core/structurePicture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA6BH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,6EAA6E;AAC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AAkB;IACjD,IAAI,UAAU,KAAK,aAAa;QAAE,OAAO,MAAM,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,wEAAwE;IACxE,6DAA6D;IAC7D,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,0CAA0C,UAAU,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/G,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,MAAM,CAAC,MAAc;IAC5B,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACnE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;AAC1E,CAAC"}
@@ -12,7 +12,8 @@ export type { StructureEditorProps } from './structureEditorProps.ts';
12
12
  /**
13
13
  * The canvas structure editor, sized to fill its container and never to hide
14
14
  * part of its toolbar, with a tooltip on every toolbar button, a guide to the
15
- * keys, and a splash on an empty canvas saying how to start.
15
+ * keys, and a splash on an empty canvas saying how to start — or the site's own
16
+ * guide in its place.
16
17
  * @param props - What to draw, when to reload it, and where to send it.
17
18
  * @returns The editor.
18
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAazD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOtE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAYtE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA4GzE"}
1
+ {"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAczD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQtE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAYtE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAoHzE"}
@@ -6,8 +6,10 @@ import { EditorHelpButton } from "./EditorHelpButton.js";
6
6
  import { EditorImportButton } from "./EditorImportButton.js";
7
7
  import { EditorImportProblem } from "./EditorImportProblem.js";
8
8
  import { StructureDropOverlay } from "./StructureDropOverlay.js";
9
+ import { StructureEditorGuide } from "./StructureEditorGuide.js";
9
10
  import { StructureEditorSplash } from "./StructureEditorSplash.js";
10
11
  import { ToolbarTooltip } from "./ToolbarTooltip.js";
12
+ import { useCanvasPress } from "./useCanvasPress.js";
11
13
  import { useDebouncedChange } from "./useDebouncedChange.js";
12
14
  import { useEditorStructure } from "./useEditorStructure.js";
13
15
  import { useStructureDrop } from "./useStructureDrop.js";
@@ -24,12 +26,13 @@ const EditorCanvas = lazy(async () => {
24
26
  /**
25
27
  * The canvas structure editor, sized to fill its container and never to hide
26
28
  * part of its toolbar, with a tooltip on every toolbar button, a guide to the
27
- * keys, and a splash on an empty canvas saying how to start.
29
+ * keys, and a splash on an empty canvas saying how to start — or the site's own
30
+ * guide in its place.
28
31
  * @param props - What to draw, when to reload it, and where to send it.
29
32
  * @returns The editor.
30
33
  */
31
34
  export function StructureEditor(props) {
32
- const { onChange, fragment = false, inputFormat = 'idcode', value = '', revision = 0, debounce = 300, minHeight = 320, mode = 'molecule', help = true, splash = true, exportable = true, importable = true, onImport, className, style, } = props;
35
+ const { onChange, fragment = false, inputFormat = 'idcode', value = '', revision = 0, debounce = 300, minHeight = 320, mode = 'molecule', help = true, splash = true, exportable = true, importable = true, onImport, guide, className, style, } = props;
33
36
  const t = useChromeT();
34
37
  const containerRef = useToolbarFloor({ minHeight, revision });
35
38
  const handleChange = useDebouncedChange(onChange, debounce, revision);
@@ -48,9 +51,12 @@ export function StructureEditor(props) {
48
51
  });
49
52
  const takesImports = importable && mode === 'molecule';
50
53
  const drop = useStructureDrop(takesImports ? imports.load : undefined);
54
+ const press = useCanvasPress();
55
+ const empty = mode === 'molecule' && drawing.empty && !drop.over;
56
+ const guided = guide !== undefined && empty;
51
57
  return (_jsxs("div", { ref: containerRef, className: className === undefined
52
58
  ? 'structure-editor'
53
- : `structure-editor ${className}`, style: { ...ROOT_STYLE, minHeight, ...style }, ...drop.targetProps, children: [_jsxs(Suspense, { fallback: _jsx("div", { style: LOADING_STYLE, children: t('structure.loadingEditor') }), children: [_jsx(EditorCanvas, { onChange: handleEdit, fragment: fragment, inputFormat: imports.idCode === null ? inputFormat : 'idcode', value: imports.idCode ?? value, mode: mode }, imports.canvasKey), splash && mode === 'molecule' && drawing.empty && !drop.over ? (_jsx(StructureEditorSplash, { importable: takesImports })) : null, help ? (_jsx(ToolbarTooltip, { containerRef: containerRef, mode: mode })) : null, _jsxs("div", { style: CORNER_STYLE, children: [takesImports ? (_jsx(EditorImportButton, { onImport: imports.load, accept: onImport === undefined ? STRUCTURE_FILES : undefined })) : null, exportable && mode === 'molecule' ? (_jsx(EditorExportButton, { source: drawing.source, fragment: fragment, empty: drawing.empty })) : null, help ? (_jsx(EditorHelpButton, { containerRef: containerRef, mode: mode, fragment: fragment })) : null] }), imports.problem === null ? null : (_jsx(EditorImportProblem, { problem: imports.problem, onDismiss: imports.dismiss }))] }), drop.over ? (_jsx(StructureDropOverlay, { label: t('structure.import.drop'), handlers: drop.overlayProps })) : null] }));
59
+ : `structure-editor ${className}`, style: { ...ROOT_STYLE, minHeight, ...style }, onPointerDownCapture: guided ? press.onPointerDownCapture : undefined, ...drop.targetProps, children: [_jsxs(Suspense, { fallback: _jsx("div", { style: LOADING_STYLE, children: t('structure.loadingEditor') }), children: [_jsx(EditorCanvas, { onChange: handleEdit, fragment: fragment, inputFormat: imports.idCode === null ? inputFormat : 'idcode', value: imports.idCode ?? value, mode: mode }, imports.canvasKey), guided && !press.pressed ? (_jsx(StructureEditorGuide, { children: guide })) : null, splash && guide === undefined && empty ? (_jsx(StructureEditorSplash, { importable: takesImports })) : null, help ? (_jsx(ToolbarTooltip, { containerRef: containerRef, mode: mode })) : null, _jsxs("div", { style: CORNER_STYLE, children: [takesImports ? (_jsx(EditorImportButton, { onImport: imports.load, accept: onImport === undefined ? STRUCTURE_FILES : undefined })) : null, exportable && mode === 'molecule' ? (_jsx(EditorExportButton, { source: drawing.source, fragment: fragment, empty: drawing.empty })) : null, help ? (_jsx(EditorHelpButton, { containerRef: containerRef, mode: mode, fragment: fragment })) : null] }), imports.problem === null ? null : (_jsx(EditorImportProblem, { problem: imports.problem, onDismiss: imports.dismiss }))] }), drop.over ? (_jsx(StructureDropOverlay, { label: t('structure.import.drop'), handlers: drop.overlayProps })) : null] }));
54
60
  }
55
61
  /**
56
62
  * The canvas is positioned out of the height computation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AC,YAAY,GAC3B,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,GAAkB;IAChC,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,YAAY;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,YAAY,GAAkB;IAClC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,kEAAkE;AAClE,MAAM,aAAa,GAAkB;IACnC,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,sEAAsE;AACtE,MAAM,eAAe,GAAG,iCAAiC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * The box a site's guide is drawn in over an empty canvas: beside the toolbar
4
+ * and under the buttons in the corner, so it never covers either.
5
+ *
6
+ * The box itself lets the pointer through; `<EmptyGuide>` takes it back only on
7
+ * its own buttons, links and figures, so a stroke can start on the words.
8
+ * @param props - What the guide shows.
9
+ * @param props.children - The site's guide.
10
+ * @returns The box and the guide in it.
11
+ */
12
+ export declare function StructureEditorGuide(props: {
13
+ children: ReactNode;
14
+ }): ReactElement;
15
+ //# sourceMappingURL=StructureEditorGuide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructureEditorGuide.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditorGuide.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIpE;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,YAAY,CAMf"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { EDITOR_TOOLBAR_WIDTH } from "../core/editorToolbarGeometry.js";
3
+ /**
4
+ * The box a site's guide is drawn in over an empty canvas: beside the toolbar
5
+ * and under the buttons in the corner, so it never covers either.
6
+ *
7
+ * The box itself lets the pointer through; `<EmptyGuide>` takes it back only on
8
+ * its own buttons, links and figures, so a stroke can start on the words.
9
+ * @param props - What the guide shows.
10
+ * @param props.children - The site's guide.
11
+ * @returns The box and the guide in it.
12
+ */
13
+ export function StructureEditorGuide(props) {
14
+ return (_jsx("div", { "data-testid": "structure-editor-guide", style: GUIDE_STYLE, children: props.children }));
15
+ }
16
+ /**
17
+ * Under the open, export and help buttons in the corner: 4 px from the top, a
18
+ * small button 24 px tall, and 4 px under it.
19
+ */
20
+ const CORNER_CLEARANCE = 32;
21
+ const GUIDE_STYLE = {
22
+ position: 'absolute',
23
+ inset: `${CORNER_CLEARANCE}px 0 0 ${EDITOR_TOOLBAR_WIDTH}px`,
24
+ pointerEvents: 'none',
25
+ };
26
+ //# sourceMappingURL=StructureEditorGuide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructureEditorGuide.js","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditorGuide.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAEpC;IACC,OAAO,CACL,6BAAiB,wBAAwB,EAAC,KAAK,EAAE,WAAW,YACzD,KAAK,CAAC,QAAQ,GACX,CACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,WAAW,GAAkB;IACjC,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,GAAG,gBAAgB,UAAU,oBAAoB,IAAI;IAC5D,aAAa,EAAE,MAAM;CACtB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from 'react';
1
+ import type { CSSProperties, ReactNode } from 'react';
2
2
  import type { CanvasEditorInputFormat } from 'react-ocl';
3
3
  import type { StructureTransfer } from '../core/structureTransfer.ts';
4
4
  import type { StructureEditorChange, StructureEditorMode } from './editorChange.ts';
@@ -68,6 +68,16 @@ export interface StructureEditorProps {
68
68
  * @default true
69
69
  */
70
70
  splash?: boolean;
71
+ /**
72
+ * What an empty canvas shows in place of the splash: the site's
73
+ * `<EmptyGuide>`, drawn beside the toolbar and under the buttons in the
74
+ * corner. The pointer goes through it to the canvas except on its own
75
+ * buttons, links and figures; it goes at the press that starts a stroke, and
76
+ * comes back whenever the canvas is empty again. Shown whatever `splash`
77
+ * says. A reaction canvas shows none.
78
+ * @default undefined — the splash, when `splash` is on
79
+ */
80
+ guide?: ReactNode;
71
81
  /**
72
82
  * Put a button in the corner that opens every notation of the drawing — its
73
83
  * SMILES, its molfiles, its canonical identifiers — and the picture of it,
@@ -1 +1 @@
1
- {"version":3,"file":"structureEditorProps.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/structureEditorProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"}
1
+ {"version":3,"file":"structureEditorProps.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/structureEditorProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The press that starts a stroke on the structure editor's canvas, which a
3
+ * site's guide makes way for.
4
+ */
5
+ import type { PointerEvent as ReactPointerEvent } from 'react';
6
+ /** Whether a stroke is being drawn, and how to hear the press that starts one. */
7
+ export interface CanvasPress {
8
+ /** Whether the drawing area is held down, which the guide makes way for. */
9
+ pressed: boolean;
10
+ /** Put on the editor's box, in the capture phase. */
11
+ onPointerDownCapture: (event: ReactPointerEvent<HTMLElement>) => void;
12
+ }
13
+ /**
14
+ * Hear a press on the drawing area, so the guide goes at the press that starts
15
+ * a stroke rather than once the stroke is reported.
16
+ *
17
+ * A press on the toolbar, on a corner button or on the guide's own buttons is
18
+ * not a stroke. The guide comes back after the release only when the editor
19
+ * has not reported a drawing by then.
20
+ * @returns See {@link CanvasPress}.
21
+ */
22
+ export declare function useCanvasPress(): CanvasPress;
23
+ //# sourceMappingURL=useCanvasPress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCanvasPress.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/useCanvasPress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK/D,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,oBAAoB,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAoB5C"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The press that starts a stroke on the structure editor's canvas, which a
3
+ * site's guide makes way for.
4
+ */
5
+ import { useCallback, useState } from 'react';
6
+ import { EDITOR_TOOLBAR_WIDTH } from "../core/editorToolbarGeometry.js";
7
+ /**
8
+ * Hear a press on the drawing area, so the guide goes at the press that starts
9
+ * a stroke rather than once the stroke is reported.
10
+ *
11
+ * A press on the toolbar, on a corner button or on the guide's own buttons is
12
+ * not a stroke. The guide comes back after the release only when the editor
13
+ * has not reported a drawing by then.
14
+ * @returns See {@link CanvasPress}.
15
+ */
16
+ export function useCanvasPress() {
17
+ const [pressed, setPressed] = useState(false);
18
+ const onPointerDownCapture = useCallback((event) => {
19
+ if (!onDrawingArea(event))
20
+ return;
21
+ setPressed(true);
22
+ function release() {
23
+ globalThis.removeEventListener('pointerup', release, true);
24
+ globalThis.removeEventListener('pointercancel', release, true);
25
+ // Once the editor has handled the release too: a stroke that drew
26
+ // something is reported by then, and the guide does not flash back.
27
+ setTimeout(() => setPressed(false), 0);
28
+ }
29
+ // Heard on the way down, which no handler of the canvas can stop.
30
+ globalThis.addEventListener('pointerup', release, true);
31
+ globalThis.addEventListener('pointercancel', release, true);
32
+ }, []);
33
+ return { pressed, onPointerDownCapture };
34
+ }
35
+ /**
36
+ * Whether a press landed on the drawing area: on the editor's canvas, and to
37
+ * the right of its toolbar. Both live in the editor's shadow root, so the event
38
+ * names the element holding it.
39
+ * @param event - The press, heard on the editor's box.
40
+ * @returns Whether it starts a stroke.
41
+ */
42
+ function onDrawingArea(event) {
43
+ const { target, currentTarget, clientX } = event;
44
+ if (!(target instanceof Element) || target.closest(CANVAS) === null) {
45
+ return false;
46
+ }
47
+ return clientX - currentTarget.getBoundingClientRect().left > TOOLBAR_EDGE;
48
+ }
49
+ /** The element the openchemlib editor is drawn in. */
50
+ const CANVAS = '[data-openchemlib-canvas-editor]';
51
+ /** The toolbar's right edge, inside the editor's one-pixel border. */
52
+ const TOOLBAR_EDGE = EDITOR_TOOLBAR_WIDTH + 1;
53
+ //# sourceMappingURL=useCanvasPress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCanvasPress.js","sourceRoot":"","sources":["../../../src/structure/ui/useCanvasPress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAUxE;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAC,KAAqC,EAAE,EAAE;QACxC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAAE,OAAO;QAClC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,SAAS,OAAO;YACd,UAAU,CAAC,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC3D,UAAU,CAAC,mBAAmB,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC/D,kEAAkE;YAClE,oEAAoE;YACpE,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,kEAAkE;QAClE,UAAU,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACxD,UAAU,CAAC,gBAAgB,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC,EACD,EAAE,CACH,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,KAAqC;IAC1D,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACjD,IAAI,CAAC,CAAC,MAAM,YAAY,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;QACpE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC,IAAI,GAAG,YAAY,CAAC;AAC7E,CAAC;AAED,sDAAsD;AACtD,MAAM,MAAM,GAAG,kCAAkC,CAAC;AAElD,sEAAsE;AACtE,MAAM,YAAY,GAAG,oBAAoB,GAAG,CAAC,CAAC"}
@@ -14,6 +14,12 @@
14
14
  * megabytes of digits that nothing would be learned from.
15
15
  */
16
16
  import type { XpsFormat } from './xpsSpectrum.ts';
17
+ /**
18
+ * The extensions the readers know, as a file picker's `accept`: what the
19
+ * picker offers first, while a file it does not name is still read by its
20
+ * content.
21
+ */
22
+ export declare const XPS_FILE_ACCEPT: string;
17
23
  /**
18
24
  * Decide what a dropped file is, from its first bytes and only then its name.
19
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"detectFormat.d.ts","sourceRoot":"","sources":["../../../src/xps/core/detectFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA0DlD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,EACvC,QAAQ,CAAC,EAAE,MAAM,GAChB,SAAS,GAAG,IAAI,CASlB"}
1
+ {"version":3,"file":"detectFormat.d.ts","sourceRoot":"","sources":["../../../src/xps/core/detectFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAuDlD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAEhB,CAAC;AAKb;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,EACvC,QAAQ,CAAC,EAAE,MAAM,GAChB,SAAS,GAAG,IAAI,CASlB"}
@@ -60,6 +60,14 @@ const EXTENSIONS = new Map([
60
60
  ['tsv', 'text'],
61
61
  ['xy', 'text'],
62
62
  ]);
63
+ /**
64
+ * The extensions the readers know, as a file picker's `accept`: what the
65
+ * picker offers first, while a file it does not name is still read by its
66
+ * content.
67
+ */
68
+ export const XPS_FILE_ACCEPT = [...EXTENSIONS.keys()]
69
+ .map((extension) => `.${extension}`)
70
+ .join(',');
63
71
  /** The one decoder the header is read through, kept rather than rebuilt. */
64
72
  const DECODER = new TextDecoder();
65
73
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"detectFormat.js","sourceRoot":"","sources":["../../../src/xps/core/detectFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,qDAAqD;AACrD,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,WAAW,GACf,+DAA+D,C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psSpectrum[]) => void;
56
56
  /** Close every spectrum and start again from an empty chart. */
57
57
  clear: () => void;
58
+ /**
59
+ * Open the viewer's file picker; what is chosen is read as a drop is,
60
+ * joining what is open. A browser opens a picker only for a click, so call
61
+ * it from one — an "Import data…" button of a guide.
62
+ */
63
+ openFiles: () => void;
64
+ /**
65
+ * Read the clipboard's text as a paste into the viewer is read, joining what
66
+ * is open; what cannot be read is said in the status bar, as for a paste.
67
+ * Call it from a click, which is when a browser lets a page read the
68
+ * clipboard.
69
+ * @returns Resolves once the text is handed to the reader, and rejects when
70
+ * the browser refuses to read the clipboard, so the caller can suggest the
71
+ * paste keys instead.
72
+ */
73
+ paste: () => Promise<void>;
58
74
  /**
59
75
  * Frame a binding energy on the chart, keeping the counts axis where it was.
60
76
  *
@@ -1 +1 @@
1
- {"version":3,"file":"xpsEditorApi.d.ts","sourceRoot":"","sources":["../../../src/xps/core/xpsEditorApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7C;;;;;;;;OAQG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7C,gEAAgE;IAChE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;;;;;;;;;OAaG;IACH,YAAY,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC7E;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,QAAQ,CAAC;CAC1B"}
1
+ {"version":3,"file":"xpsEditorApi.d.ts","sourceRoot":"","sources":["../../../src/xps/core/xpsEditorApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7C;;;;;;;;OAQG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7C,gEAAgE;IAChE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;;;;;;;;;;;OAaG;IACH,YAAY,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC7E;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,QAAQ,CAAC;CAC1B"}
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from 'react';
1
2
  export interface XpsCanvasProps {
2
3
  /**
3
4
  * The id of the box the chart is drawn in, which a picture of the chart is
@@ -15,6 +16,13 @@ export interface XpsCanvasProps {
15
16
  * @default false
16
17
  */
17
18
  isReading?: boolean;
19
+ /**
20
+ * What the empty chart shows in place of its own invitation to drop a
21
+ * spectrum: the site's `<EmptyGuide>`, over the whole chart. Gone while a
22
+ * file is dragged over the chart or read, and once anything is open.
23
+ * @default undefined — the chart's own invitation
24
+ */
25
+ guide?: ReactNode;
18
26
  }
19
27
  /**
20
28
  * The chart side of the split: the drawing, and the status bar under it.
@@ -28,7 +36,8 @@ export interface XpsCanvasProps {
28
36
  * The empty chart says what to do with it rather than showing an axis from 0 to
29
37
  * 1 and leaving the question open: the two ways in are a file and a paste, and
30
38
  * neither is discoverable from a blank plot. The invitation goes as soon as
31
- * anything is open, since from then on the axes are the answer.
39
+ * anything is open, since from then on the axes are the answer. A site with a
40
+ * guide of its own passes it as `guide`, and it is drawn instead.
32
41
  * @param props - Component props.
33
42
  * @returns The canvas side of the split.
34
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"XpsCanvas.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/XpsCanvas.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BA8E9C"}
1
+ {"version":3,"file":"XpsCanvas.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/XpsCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBvC,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BAkF9C"}
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useMemo } from 'react';
3
+ import { TOKEN } from "../../tokens/core/familyTokens.js";
3
4
  import { hasBindingAxis } from "../core/energyAxis.js";
4
5
  import { findSpectrum } from "../core/spectrumGroups.js";
5
6
  import { surveyLinesOf } from "../core/surveyElements.js";
@@ -22,12 +23,13 @@ import { useXpsActions, useXpsEditorState } from "./xpsStateContext.js";
22
23
  * The empty chart says what to do with it rather than showing an axis from 0 to
23
24
  * 1 and leaving the question open: the two ways in are a file and a paste, and
24
25
  * neither is discoverable from a blank plot. The invitation goes as soon as
25
- * anything is open, since from then on the axes are the answer.
26
+ * anything is open, since from then on the axes are the answer. A site with a
27
+ * guide of its own passes it as `guide`, and it is drawn instead.
26
28
  * @param props - Component props.
27
29
  * @returns The canvas side of the split.
28
30
  */
29
31
  export function XpsCanvas(props) {
30
- const { isOver = false, isReading = false, chartId } = props;
32
+ const { isOver = false, isReading = false, chartId, guide } = props;
31
33
  const { state } = useXpsEditorState();
32
34
  const actions = useXpsActions();
33
35
  const highlight = useXpsHighlight();
@@ -55,10 +57,11 @@ export function XpsCanvas(props) {
55
57
  const { selectedId, openPanelIds, domain } = view;
56
58
  const { instruments, instrumentId } = settings;
57
59
  const quantifying = openPanelIds.includes('quantification');
60
+ const empty = spectra.length === 0 && !isReading;
58
61
  const windows = useMemo(() => quantifying
59
62
  ? quantificationWindows(spectra, selectedId, instruments, instrumentId)
60
63
  : undefined, [quantifying, spectra, selectedId, instruments, instrumentId]);
61
- return (_jsxs("div", { style: sideStyle, children: [_jsxs("div", { id: chartId, style: chartStyle, children: [_jsx(XpsChart, { spectra: spectra, settings: settings, domain: domain, selectedId: selectedId, highlight: highlight, onDomainChange: onDomainChange, onHighlightChange: lookAt, onPickEnergy: onPickEnergy, onSelectSpectrum: actions.selectSpectrum, windows: windows, isOver: isOver, isReading: isReading }), spectra.length === 0 && !isReading ? (_jsxs("div", { style: inviteStyle, children: [_jsx("div", { style: inviteTitleStyle, children: "Drop a spectrum here" }), _jsx("div", { children: "Drop a VAMAS (.vms) file, or paste two columns of numbers \u2014 binding energy in eV, then counts." })] })) : null] }), _jsx(XpsStatusBar, { isReading: isReading })] }));
64
+ return (_jsxs("div", { style: sideStyle, children: [_jsxs("div", { id: chartId, style: chartStyle, children: [_jsx(XpsChart, { spectra: spectra, settings: settings, domain: domain, selectedId: selectedId, highlight: highlight, onDomainChange: onDomainChange, onHighlightChange: lookAt, onPickEnergy: onPickEnergy, onSelectSpectrum: actions.selectSpectrum, windows: windows, isOver: isOver, isReading: isReading }), empty && guide !== undefined && !isOver ? (_jsx("div", { style: guideStyle, children: guide })) : null, empty && guide === undefined ? (_jsxs("div", { style: inviteStyle, children: [_jsx("div", { style: inviteTitleStyle, children: "Drop a spectrum here" }), _jsx("div", { children: "Drop a VAMAS (.vms) file, or paste two columns of numbers \u2014 binding energy in eV, then counts." })] })) : null] }), _jsx(XpsStatusBar, { isReading: isReading })] }));
62
65
  }
63
66
  // The chart and whatever it has to say, stacked: the pane is the whole height of
64
67
  // the split, and the status bar takes what it needs off the bottom of it.
@@ -95,6 +98,14 @@ const inviteStyle = {
95
98
  opacity: 0.65,
96
99
  };
97
100
  const inviteTitleStyle = { fontSize: 15, fontWeight: 600 };
101
+ // Instead of the plot: faint figures over an empty frame of axes read as data
102
+ // drawn on it. The pointer goes through to the chart, which takes the drop.
103
+ const guideStyle = {
104
+ position: 'absolute',
105
+ inset: 0,
106
+ background: TOKEN.surface,
107
+ pointerEvents: 'none',
108
+ };
98
109
  /**
99
110
  * The windows the selected survey is quantified over, for the chart to shade
100
111
  * while the quantification panel is open.
@@ -1 +1 @@
1
- {"version":3,"file":"XpsCanvas.js","sourceRoot":"","sources":["../../../src/xps/ui/XpsCanvas.tsx"],"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7D,OAAO;QACL,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;KACzE,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"XpsChart.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/XpsChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA8BvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CA+KxD"}
1
+ {"version":3,"file":"XpsChart.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/XpsChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA0BvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAkJxD"}
@@ -1,20 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useId, useMemo, useRef } from 'react';
2
+ import { useId, useMemo, useRef } from 'react';
3
3
  import { MARGIN, plotRect } from "../../chart/core/chartGeometry.js";
4
- import { chartScale, chartValue } from "../../chart/core/chartScale.js";
4
+ import { chartScale } from "../../chart/core/chartScale.js";
5
5
  import { Axes } from "../../chart/ui/Axes.js";
6
6
  import { AxisGuide } from "../../chart/ui/AxisGuide.js";
7
7
  import { SelectionRect } from "../../chart/ui/SelectionRect.js";
8
- import { useChartPointer } from "../../chart/ui/useChartPointer.js";
9
8
  import { useChartSize } from "../../chart/ui/useChartSize.js";
10
9
  import { axisEnergy, axisTitle, chartEnergyAxis, chartSourceEnergy, countsTitle, isAxisReversed, } from "../core/energyAxis.js";
11
- import { nearestPeakEnergy, sameNearestPeak } from "../core/nearestPeak.js";
12
10
  import { fullDomain } from "../core/xpsDomain.js";
13
11
  import { NO_HIGHLIGHT } from "../core/xpsHighlight.js";
14
12
  import { ChartData } from "./ChartData.js";
15
13
  import { DropOverlay } from "./DropOverlay.js";
16
14
  import { XpsPointerTracker } from "./XpsPointerTracker.js";
17
15
  import { useXpsGestures } from "./useXpsGestures.js";
16
+ import { useXpsReadout } from "./useXpsReadout.js";
18
17
  /**
19
18
  * The chart: every layer of an XPS spectrum, in one SVG.
20
19
  *
@@ -44,10 +43,11 @@ import { useXpsGestures } from "./useXpsGestures.js";
44
43
  * @returns The chart.
45
44
  */
46
45
  export function XpsChart(props) {
47
- const { spectra, settings, domain, selectedId = null, highlight = NO_HIGHLIGHT, onDomainChange, onHighlightChange, onPickEnergy, onSelectSpectrum, windows, isOver = false, isReading = false, } = props;
46
+ const { spectra, settings, domain, selectedId = null, highlight = NO_HIGHLIGHT, onDomainChange, onHighlightChange, onPickEnergy, onSelectSpectrum, windows, isOver = false, isReading = false, size, } = props;
48
47
  const [containerRef, measured] = useChartSize();
49
48
  const svgRef = useRef(null);
50
- const plot = useMemo(() => plotRect({ width: measured.width, height: measured.height }), [measured.width, measured.height]);
49
+ const { width, height } = size ?? measured;
50
+ const plot = useMemo(() => plotRect({ width, height }), [width, height]);
51
51
  // Read back off the plot rather than off the measurement, so a chart briefly
52
52
  // laid out at nothing still draws its axes inside a box that holds them.
53
53
  const frameWidth = plot.right + MARGIN.right;
@@ -74,35 +74,14 @@ export function XpsChart(props) {
74
74
  onDomainChange,
75
75
  onPickEnergy,
76
76
  });
77
- const read = useCallback((point) => ({
78
- energy: chartValue(xScale, point.x),
79
- counts: chartValue(yScale, point.y),
80
- peak: nearestPeakEnergy(spectra, axis, xScale, point.x),
81
- }), [xScale, yScale, spectra, axis]);
82
- // Only a change of peak is reported, starting from none: the pointer coming
83
- // onto the plot over no peak says nothing, so a guide a panel put on the
84
- // chart stays until the pointer actually reaches a peak.
85
- const reportedPeak = useRef(null);
86
- const onReadout = useCallback((readout) => {
87
- const found = readout?.peak ?? null;
88
- if (sameNearestPeak(reportedPeak.current, found))
89
- return;
90
- reportedPeak.current = found;
91
- onHighlightChange?.(found === null
92
- ? NO_HIGHLIGHT
93
- : {
94
- spectrumId: found.spectrumId,
95
- peakId: found.peak.id,
96
- componentId: null,
97
- bindingEnergy: found.peak.bindingEnergy,
98
- });
99
- }, [onHighlightChange]);
100
- const pointer = useChartPointer({
77
+ const pointer = useXpsReadout({
101
78
  svgRef,
102
79
  plot,
103
- read,
104
- sameReadout: samePeakReadout,
105
- onReadout,
80
+ spectra,
81
+ axis,
82
+ xScale,
83
+ yScale,
84
+ onHighlightChange,
106
85
  });
107
86
  const guideEnergy = highlight.bindingEnergy === null
108
87
  ? null
@@ -112,16 +91,6 @@ export function XpsChart(props) {
112
91
  const clipId = `xps-plot-${useId().replaceAll(/\W/g, '')}`;
113
92
  return (_jsx("div", { ref: containerRef, style: containerStyle, children: _jsxs("svg", { ref: svgRef, role: "img", "aria-label": CHART_LABEL, width: frameWidth, height: frameHeight, viewBox: `0 0 ${frameWidth} ${frameHeight}`, style: svgStyle, ...gestures.handlers, children: [_jsx("defs", { children: _jsx("clipPath", { id: clipId, children: _jsx("rect", { x: plot.left, y: plot.top, width: plot.width, height: plot.height }) }) }), _jsx(Axes, { plot: plot, xDomain: shown.x, yDomain: shown.y, xScale: xScale, yScale: yScale, xTitle: axisTitle(axis), yTitle: countsTitle(settings.normalise), xTickSpacing: X_TICK_SPACING }), _jsx("g", { clipPath: `url(#${clipId})`, children: _jsx(ChartData, { spectra: spectra, settings: settings, axis: axis, plot: plot, xScale: xScale, yScale: yScale, selectedId: selectedId, highlight: highlight, onSelectSpectrum: onSelectSpectrum, windows: windows }) }), _jsx(AxisGuide, { value: guideEnergy, plot: plot, xScale: xScale }), _jsx(SelectionRect, { selection: gestures.selection, plot: plot }), _jsx(XpsPointerTracker, { position: pointer.position, readout: pointer.readout, plot: plot, xScale: xScale }), _jsx(DropOverlay, { isOver: isOver, isReading: isReading, plot: plot })] }) }));
114
93
  }
115
- /**
116
- * Whether two readings are about the same peak, which is all the rest of the
117
- * viewer hears about: the energy under the crosshair changes on every pixel.
118
- * @param current - The reading last reported.
119
- * @param next - The reading now.
120
- * @returns Whether nothing needs reporting.
121
- */
122
- function samePeakReadout(current, next) {
123
- return sameNearestPeak(current.peak, next.peak);
124
- }
125
94
  /**
126
95
  * The room an energy label wants along the bottom, at its widest: `1200` or
127
96
  * `284.8` with the space either side of it.