react-cheminfo 0.132.0 → 0.134.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/lib/drawing/captionEditor/CaptionEditor.d.ts +3 -3
- package/lib/drawing/captionEditor/CaptionEditor.d.ts.map +1 -1
- package/lib/drawing/captionEditor/CaptionEditor.js +8 -4
- package/lib/drawing/captionEditor/CaptionEditor.js.map +1 -1
- package/lib/drawing/captionEditor/CaptionToolbar.d.ts +4 -2
- package/lib/drawing/captionEditor/CaptionToolbar.d.ts.map +1 -1
- package/lib/drawing/captionEditor/CaptionToolbar.js +6 -4
- package/lib/drawing/captionEditor/CaptionToolbar.js.map +1 -1
- package/lib/drawing/captionEditor/index.d.ts +2 -0
- package/lib/drawing/captionEditor/index.d.ts.map +1 -1
- package/lib/drawing/captionEditor/index.js +1 -0
- package/lib/drawing/captionEditor/index.js.map +1 -1
- package/lib/drawing/captionEditor/toolbarInView.d.ts +40 -0
- package/lib/drawing/captionEditor/toolbarInView.d.ts.map +1 -0
- package/lib/drawing/captionEditor/toolbarInView.js +53 -0
- package/lib/drawing/captionEditor/toolbarInView.js.map +1 -0
- package/lib/drawing/core/camera.d.ts +2 -0
- package/lib/drawing/core/camera.d.ts.map +1 -1
- package/lib/drawing/core/camera.js +2 -0
- package/lib/drawing/core/camera.js.map +1 -1
- package/lib/drawing/core/index.d.ts +1 -1
- package/lib/drawing/core/index.d.ts.map +1 -1
- package/lib/drawing/core/index.js +1 -1
- package/lib/drawing/core/index.js.map +1 -1
- package/lib/drawing/render/index.d.ts +1 -1
- package/lib/drawing/render/index.d.ts.map +1 -1
- package/lib/drawing/render/index.js +1 -1
- package/lib/drawing/render/index.js.map +1 -1
- package/lib/drawing/render/pageGrid.d.ts +16 -0
- package/lib/drawing/render/pageGrid.d.ts.map +1 -1
- package/lib/drawing/render/pageGrid.js +28 -10
- package/lib/drawing/render/pageGrid.js.map +1 -1
- package/lib/drawing/ui/PageField.d.ts +29 -0
- package/lib/drawing/ui/PageField.d.ts.map +1 -0
- package/lib/drawing/ui/PageField.js +38 -0
- package/lib/drawing/ui/PageField.js.map +1 -0
- package/lib/drawing/ui/PageGrid.d.ts +20 -0
- package/lib/drawing/ui/PageGrid.d.ts.map +1 -0
- package/lib/drawing/ui/PageGrid.js +26 -0
- package/lib/drawing/ui/PageGrid.js.map +1 -0
- package/lib/drawing/ui/PageSideInput.d.ts +28 -0
- package/lib/drawing/ui/PageSideInput.d.ts.map +1 -0
- package/lib/drawing/ui/PageSideInput.js +47 -0
- package/lib/drawing/ui/PageSideInput.js.map +1 -0
- package/lib/drawing/ui/PageToolbar.d.ts +16 -0
- package/lib/drawing/ui/PageToolbar.d.ts.map +1 -0
- package/lib/drawing/ui/PageToolbar.js +16 -0
- package/lib/drawing/ui/PageToolbar.js.map +1 -0
- package/lib/drawing/ui/PrintSheets.d.ts +32 -0
- package/lib/drawing/ui/PrintSheets.d.ts.map +1 -0
- package/lib/drawing/ui/PrintSheets.js +17 -0
- package/lib/drawing/ui/PrintSheets.js.map +1 -0
- package/lib/drawing/ui/TextToolIcon.d.ts +19 -0
- package/lib/drawing/ui/TextToolIcon.d.ts.map +1 -0
- package/lib/drawing/ui/TextToolIcon.js +21 -0
- package/lib/drawing/ui/TextToolIcon.js.map +1 -0
- package/lib/drawing/ui/ZoomControl.d.ts +25 -0
- package/lib/drawing/ui/ZoomControl.d.ts.map +1 -0
- package/lib/drawing/ui/ZoomControl.js +27 -0
- package/lib/drawing/ui/ZoomControl.js.map +1 -0
- package/lib/drawing/ui/index.d.ts +10 -0
- package/lib/drawing/ui/index.d.ts.map +1 -1
- package/lib/drawing/ui/index.js +7 -0
- package/lib/drawing/ui/index.js.map +1 -1
- package/lib/guide/ui/EmptyGuide.d.ts +5 -2
- package/lib/guide/ui/EmptyGuide.d.ts.map +1 -1
- package/lib/guide/ui/EmptyGuide.js +8 -3
- package/lib/guide/ui/EmptyGuide.js.map +1 -1
- package/lib/guide/ui/GuideFigures.d.ts +6 -0
- package/lib/guide/ui/GuideFigures.d.ts.map +1 -1
- package/lib/guide/ui/GuideFigures.js +5 -5
- package/lib/guide/ui/GuideFigures.js.map +1 -1
- package/lib/host/core/index.d.ts +2 -0
- package/lib/host/core/index.d.ts.map +1 -1
- package/lib/host/core/index.js +1 -0
- package/lib/host/core/index.js.map +1 -1
- package/lib/host/core/kinds.d.ts +6 -1
- package/lib/host/core/kinds.d.ts.map +1 -1
- package/lib/host/core/kinds.js +4 -1
- package/lib/host/core/kinds.js.map +1 -1
- package/lib/host/core/recordKinds.d.ts +165 -0
- package/lib/host/core/recordKinds.d.ts.map +1 -0
- package/lib/host/core/recordKinds.js +68 -0
- package/lib/host/core/recordKinds.js.map +1 -0
- package/lib/mass/core/index.d.ts +1 -0
- package/lib/mass/core/index.d.ts.map +1 -1
- package/lib/mass/core/index.js +1 -0
- package/lib/mass/core/index.js.map +1 -1
- package/lib/mass/core/massDomain.d.ts.map +1 -1
- package/lib/mass/core/massDomain.js +9 -5
- package/lib/mass/core/massDomain.js.map +1 -1
- package/lib/mass/core/massSpectrum.d.ts +9 -0
- package/lib/mass/core/massSpectrum.d.ts.map +1 -1
- package/lib/mass/core/massSpectrum.js.map +1 -1
- package/lib/mass/core/verticalScale.d.ts +30 -0
- package/lib/mass/core/verticalScale.d.ts.map +1 -0
- package/lib/mass/core/verticalScale.js +40 -0
- package/lib/mass/core/verticalScale.js.map +1 -0
- package/lib/mass/ui/MassChart.d.ts.map +1 -1
- package/lib/mass/ui/MassChart.js +4 -38
- package/lib/mass/ui/MassChart.js.map +1 -1
- package/lib/mass/ui/massChartLayers.d.ts +31 -0
- package/lib/mass/ui/massChartLayers.d.ts.map +1 -0
- package/lib/mass/ui/massChartLayers.js +57 -0
- package/lib/mass/ui/massChartLayers.js.map +1 -0
- package/lib/structure/core/index.d.ts +1 -1
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/core/structurePicture.d.ts +32 -1
- package/lib/structure/core/structurePicture.d.ts.map +1 -1
- package/lib/structure/core/structurePicture.js +29 -2
- package/lib/structure/core/structurePicture.js.map +1 -1
- package/lib/structure/ui/StructureEditor.d.ts +2 -1
- package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
- package/lib/structure/ui/StructureEditor.js +9 -3
- package/lib/structure/ui/StructureEditor.js.map +1 -1
- package/lib/structure/ui/StructureEditorGuide.d.ts +15 -0
- package/lib/structure/ui/StructureEditorGuide.d.ts.map +1 -0
- package/lib/structure/ui/StructureEditorGuide.js +26 -0
- package/lib/structure/ui/StructureEditorGuide.js.map +1 -0
- package/lib/structure/ui/structureEditorProps.d.ts +11 -1
- package/lib/structure/ui/structureEditorProps.d.ts.map +1 -1
- package/lib/structure/ui/useCanvasPress.d.ts +23 -0
- package/lib/structure/ui/useCanvasPress.d.ts.map +1 -0
- package/lib/structure/ui/useCanvasPress.js +53 -0
- package/lib/structure/ui/useCanvasPress.js.map +1 -0
- package/lib/xps/core/detectFormat.d.ts +6 -0
- package/lib/xps/core/detectFormat.d.ts.map +1 -1
- package/lib/xps/core/detectFormat.js +8 -0
- package/lib/xps/core/detectFormat.js.map +1 -1
- package/lib/xps/core/xpsEditorApi.d.ts +16 -0
- package/lib/xps/core/xpsEditorApi.d.ts.map +1 -1
- package/lib/xps/ui/XpsCanvas.d.ts +10 -1
- package/lib/xps/ui/XpsCanvas.d.ts.map +1 -1
- package/lib/xps/ui/XpsCanvas.js +14 -3
- package/lib/xps/ui/XpsCanvas.js.map +1 -1
- package/lib/xps/ui/XpsChart.d.ts.map +1 -1
- package/lib/xps/ui/XpsChart.js +12 -43
- package/lib/xps/ui/XpsChart.js.map +1 -1
- package/lib/xps/ui/XpsEditor.d.ts +8 -0
- package/lib/xps/ui/XpsEditor.d.ts.map +1 -1
- package/lib/xps/ui/XpsEditor.js +2 -2
- package/lib/xps/ui/XpsEditor.js.map +1 -1
- package/lib/xps/ui/XpsShell.d.ts +5 -0
- package/lib/xps/ui/XpsShell.d.ts.map +1 -1
- package/lib/xps/ui/XpsShell.js +18 -4
- package/lib/xps/ui/XpsShell.js.map +1 -1
- package/lib/xps/ui/dropEvents.d.ts +8 -1
- package/lib/xps/ui/dropEvents.d.ts.map +1 -1
- package/lib/xps/ui/dropEvents.js +15 -1
- package/lib/xps/ui/dropEvents.js.map +1 -1
- package/lib/xps/ui/useSpectrumDrop.d.ts +6 -0
- package/lib/xps/ui/useSpectrumDrop.d.ts.map +1 -1
- package/lib/xps/ui/useSpectrumDrop.js +1 -1
- package/lib/xps/ui/useSpectrumDrop.js.map +1 -1
- package/lib/xps/ui/useXpsEditorHandle.d.ts +4 -1
- package/lib/xps/ui/useXpsEditorHandle.d.ts.map +1 -1
- package/lib/xps/ui/useXpsEditorHandle.js +6 -2
- package/lib/xps/ui/useXpsEditorHandle.js.map +1 -1
- package/lib/xps/ui/useXpsReadout.d.ts +43 -0
- package/lib/xps/ui/useXpsReadout.d.ts.map +1 -0
- package/lib/xps/ui/useXpsReadout.js +59 -0
- package/lib/xps/ui/useXpsReadout.js.map +1 -0
- package/lib/xps/ui/xpsChartProps.d.ts +9 -0
- package/lib/xps/ui/xpsChartProps.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/drawing/captionEditor/CaptionEditor.tsx +8 -3
- package/src/drawing/captionEditor/CaptionToolbar.tsx +18 -2
- package/src/drawing/captionEditor/index.ts +2 -0
- package/src/drawing/captionEditor/toolbarInView.ts +73 -0
- package/src/drawing/core/camera.ts +3 -0
- package/src/drawing/core/index.ts +1 -0
- package/src/drawing/render/index.ts +2 -0
- package/src/drawing/render/pageGrid.ts +29 -11
- package/src/drawing/ui/PageField.tsx +104 -0
- package/src/drawing/ui/PageGrid.tsx +48 -0
- package/src/drawing/ui/PageSideInput.tsx +81 -0
- package/src/drawing/ui/PageToolbar.tsx +45 -0
- package/src/drawing/ui/PrintSheets.tsx +57 -0
- package/src/drawing/ui/TextToolIcon.tsx +48 -0
- package/src/drawing/ui/ZoomControl.tsx +112 -0
- package/src/drawing/ui/index.ts +10 -0
- package/src/guide/ui/EmptyGuide.tsx +20 -13
- package/src/guide/ui/GuideFigures.tsx +15 -4
- package/src/host/core/index.ts +7 -0
- package/src/host/core/kinds.ts +7 -2
- package/src/host/core/recordKinds.ts +144 -0
- package/src/mass/core/index.ts +1 -0
- package/src/mass/core/massDomain.ts +9 -3
- package/src/mass/core/massSpectrum.ts +9 -0
- package/src/mass/core/verticalScale.ts +48 -0
- package/src/mass/ui/MassChart.tsx +12 -43
- package/src/mass/ui/massChartLayers.ts +66 -0
- package/src/structure/core/index.ts +1 -0
- package/src/structure/core/structurePicture.ts +78 -4
- package/src/structure/ui/StructureEditor.tsx +13 -2
- package/src/structure/ui/StructureEditorGuide.tsx +35 -0
- package/src/structure/ui/structureEditorProps.ts +11 -1
- package/src/structure/ui/useCanvasPress.ts +69 -0
- package/src/xps/core/detectFormat.ts +9 -0
- package/src/xps/core/xpsEditorApi.ts +16 -0
- package/src/xps/ui/XpsCanvas.tsx +26 -3
- package/src/xps/ui/XpsChart.tsx +12 -56
- package/src/xps/ui/XpsEditor.tsx +10 -0
- package/src/xps/ui/XpsShell.tsx +37 -7
- package/src/xps/ui/dropEvents.ts +16 -1
- package/src/xps/ui/useSpectrumDrop.ts +7 -1
- package/src/xps/ui/useXpsEditorHandle.ts +12 -2
- package/src/xps/ui/useXpsReadout.ts +104 -0
- package/src/xps/ui/xpsChartProps.ts +9 -0
- package/styles/caption-editor.css +15 -1
- package/styles/chrome.css +130 -9
- package/styles/drawing.css +100 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `data.zenodo.record`: a dataset about to be published on Zenodo — its
|
|
3
|
+
* metadata and its files — handed to a site that shows it before it is, as
|
|
4
|
+
* zenodo-submit.cheminfo.org hands one to fair.cheminfo.org.
|
|
5
|
+
*
|
|
6
|
+
* The files travel as `Blob`s: a window or a port hands a `Blob` over by
|
|
7
|
+
* reference, so a record of several gigabytes crosses without a copy, and the
|
|
8
|
+
* receiving site reads a file only when it needs it. The schema accepts any
|
|
9
|
+
* `content`, since JSON Schema cannot name a `Blob`: the receiving site checks
|
|
10
|
+
* `instanceof Blob` itself.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** One creator of a record, as Zenodo lists them. */
|
|
14
|
+
export interface ZenodoCreatorValue {
|
|
15
|
+
/** `Family, Given`, or an organisation's name. */
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Where they work.
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
affiliation?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Their ORCID iD, e.g. `0000-0002-1825-0097`.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
orcid?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The publication date of a record, `YYYY-MM-DD`, under the name Zenodo gives
|
|
31
|
+
* it, which is not camelCase.
|
|
32
|
+
* @default undefined
|
|
33
|
+
*/
|
|
34
|
+
type ZenodoPublicationDate = Partial<Record<'publication_date', string>>;
|
|
35
|
+
|
|
36
|
+
/** The metadata of a record, as Zenodo stores it, known before it is published. */
|
|
37
|
+
export interface ZenodoMetadataValue extends ZenodoPublicationDate {
|
|
38
|
+
/** The title. */
|
|
39
|
+
title: string;
|
|
40
|
+
/**
|
|
41
|
+
* The description, in HTML as Zenodo stores it.
|
|
42
|
+
* @default undefined
|
|
43
|
+
*/
|
|
44
|
+
description?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The creators, in the order they are cited.
|
|
47
|
+
* @default undefined
|
|
48
|
+
*/
|
|
49
|
+
creators?: ZenodoCreatorValue[];
|
|
50
|
+
/**
|
|
51
|
+
* The keywords.
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
keywords?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* The version the depositor gives the record.
|
|
57
|
+
* @default undefined
|
|
58
|
+
*/
|
|
59
|
+
version?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The licence, by its Zenodo id, e.g. `cc-by-4.0`.
|
|
62
|
+
* @default undefined
|
|
63
|
+
*/
|
|
64
|
+
license?: { id: string };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** One file of a record, exactly as it would be uploaded. */
|
|
68
|
+
export interface ZenodoFileValue {
|
|
69
|
+
/** Its name in the record, e.g. `toc.json`. */
|
|
70
|
+
key: string;
|
|
71
|
+
/** Its size, in bytes. */
|
|
72
|
+
size: number;
|
|
73
|
+
/** Its content. */
|
|
74
|
+
content: Blob;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** `data.zenodo.record`: a record not yet published, with its files. */
|
|
78
|
+
export interface ZenodoRecordValue {
|
|
79
|
+
/** Zenodo-style metadata of the record, as known before it is published. */
|
|
80
|
+
metadata: ZenodoMetadataValue;
|
|
81
|
+
/** The files of the record, exactly as they would be uploaded. */
|
|
82
|
+
files: ZenodoFileValue[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Zenodo's own name for the field, which is not camelCase.
|
|
86
|
+
const PUBLICATION_DATE = 'publication_date';
|
|
87
|
+
|
|
88
|
+
const CREATOR_SCHEMA = {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
name: { type: 'string' },
|
|
92
|
+
affiliation: { type: 'string' },
|
|
93
|
+
orcid: { type: 'string' },
|
|
94
|
+
},
|
|
95
|
+
required: ['name'],
|
|
96
|
+
additionalProperties: false,
|
|
97
|
+
} as const;
|
|
98
|
+
|
|
99
|
+
const METADATA_SCHEMA = {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
title: { type: 'string' },
|
|
103
|
+
description: { type: 'string' },
|
|
104
|
+
[PUBLICATION_DATE]: { type: 'string' },
|
|
105
|
+
creators: { type: 'array', items: CREATOR_SCHEMA },
|
|
106
|
+
keywords: { type: 'array', items: { type: 'string' } },
|
|
107
|
+
version: { type: 'string' },
|
|
108
|
+
license: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: { id: { type: 'string' } },
|
|
111
|
+
required: ['id'],
|
|
112
|
+
additionalProperties: false,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ['title'],
|
|
116
|
+
additionalProperties: false,
|
|
117
|
+
} as const;
|
|
118
|
+
|
|
119
|
+
const FILE_SCHEMA = {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
key: { type: 'string' },
|
|
123
|
+
size: { type: 'number' },
|
|
124
|
+
// Any value: a schema cannot name a `Blob`, which the reader checks.
|
|
125
|
+
content: {},
|
|
126
|
+
},
|
|
127
|
+
required: ['key', 'size', 'content'],
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
} as const;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The schema of `data.zenodo.record`. Written as a plain schema rather than
|
|
133
|
+
* `JSONSchemaType`, which cannot express a `Blob` and would demand `nullable`
|
|
134
|
+
* on every optional field.
|
|
135
|
+
*/
|
|
136
|
+
export const ZENODO_RECORD_SCHEMA = {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
metadata: METADATA_SCHEMA,
|
|
140
|
+
files: { type: 'array', items: FILE_SCHEMA },
|
|
141
|
+
},
|
|
142
|
+
required: ['metadata', 'files'],
|
|
143
|
+
additionalProperties: false,
|
|
144
|
+
} as const;
|
package/src/mass/core/index.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { xMaxValue } from 'ml-spectra-processing';
|
|
12
12
|
|
|
13
13
|
import type { MassDomain, MassSpectrum, MassTrace } from './massSpectrum.ts';
|
|
14
|
+
import { verticalScaleOf } from './verticalScale.ts';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* How much air is left either side of the outermost peak, as a fraction.
|
|
@@ -191,10 +192,13 @@ function traceExtent(
|
|
|
191
192
|
let extent: TraceExtent | null = null;
|
|
192
193
|
for (const spectrum of spectra) {
|
|
193
194
|
if (!includeExcluded && spectrum.excludeFromDomain) continue;
|
|
195
|
+
const scale = verticalScaleOf(spectrum);
|
|
194
196
|
if (spectrum.showProfile && spectrum.profile !== null) {
|
|
195
|
-
extent = widen(extent, spectrum.profile);
|
|
197
|
+
extent = widen(extent, spectrum.profile, scale);
|
|
198
|
+
}
|
|
199
|
+
if (spectrum.showCentroid) {
|
|
200
|
+
extent = widen(extent, spectrum.centroid, scale);
|
|
196
201
|
}
|
|
197
|
-
if (spectrum.showCentroid) extent = widen(extent, spectrum.centroid);
|
|
198
202
|
}
|
|
199
203
|
return extent;
|
|
200
204
|
}
|
|
@@ -207,17 +211,19 @@ function traceExtent(
|
|
|
207
211
|
* hundred thousand points of a profile to learn what index zero already says.
|
|
208
212
|
* @param extent - What has been covered so far, `null` for nothing.
|
|
209
213
|
* @param trace - The trace to cover as well.
|
|
214
|
+
* @param scale - How many times taller than measured it is drawn.
|
|
210
215
|
* @returns The grown extent, unchanged when the trace holds no point.
|
|
211
216
|
*/
|
|
212
217
|
function widen(
|
|
213
218
|
extent: TraceExtent | null,
|
|
214
219
|
trace: MassTrace,
|
|
220
|
+
scale: number,
|
|
215
221
|
): TraceExtent | null {
|
|
216
222
|
const { x, y } = trace;
|
|
217
223
|
if (x.length === 0 || y.length === 0) return extent;
|
|
218
224
|
const first = x[0] as number;
|
|
219
225
|
const last = x.at(-1) as number;
|
|
220
|
-
const tallest = xMaxValue(y);
|
|
226
|
+
const tallest = xMaxValue(y) * scale;
|
|
221
227
|
if (extent === null) {
|
|
222
228
|
return { xMinimum: first, xMaximum: last, yMaximum: tallest };
|
|
223
229
|
}
|
|
@@ -180,6 +180,15 @@ export interface MassSpectrum {
|
|
|
180
180
|
* @default false
|
|
181
181
|
*/
|
|
182
182
|
excludeFromDomain?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* How many times taller than measured the spectrum is drawn, so one spectrum
|
|
185
|
+
* can be brought up against another while the axis stays shared. It scales
|
|
186
|
+
* about the baseline, the fit covers the heights as drawn, and the labels
|
|
187
|
+
* still write the measured intensities. A value that is not a positive
|
|
188
|
+
* number draws it as measured.
|
|
189
|
+
* @default 1
|
|
190
|
+
*/
|
|
191
|
+
verticalScale?: number;
|
|
183
192
|
/**
|
|
184
193
|
* How finely the spectrum resolves masses, as it was decided when it was read.
|
|
185
194
|
*
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawing one spectrum taller or shorter than the others on a shared axis.
|
|
3
|
+
*
|
|
4
|
+
* The axis stays the measurement's, so a spectrum scaled up is a picture of
|
|
5
|
+
* the measurement and not a new one: every number written on the chart — the
|
|
6
|
+
* labels, the peak under the pointer — is still read off the measured trace.
|
|
7
|
+
* Only where a sample is drawn moves.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ChartScale } from '../../chart/core/chartScale.ts';
|
|
11
|
+
|
|
12
|
+
import type { MassSpectrum } from './massSpectrum.ts';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* How many times taller than measured a spectrum is drawn.
|
|
16
|
+
* @param spectrum - The spectrum.
|
|
17
|
+
* @returns Its `verticalScale`, `1` when that is not a positive finite number.
|
|
18
|
+
*/
|
|
19
|
+
export function verticalScaleOf(spectrum: MassSpectrum): number {
|
|
20
|
+
const { verticalScale } = spectrum;
|
|
21
|
+
return verticalScale !== undefined &&
|
|
22
|
+
Number.isFinite(verticalScale) &&
|
|
23
|
+
verticalScale > 0
|
|
24
|
+
? verticalScale
|
|
25
|
+
: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The intensity axis one spectrum is drawn against: the chart's, stretched by
|
|
30
|
+
* the spectrum's own scale about the baseline, so zero stays where every stick
|
|
31
|
+
* stands.
|
|
32
|
+
*
|
|
33
|
+
* A spectrum drawn as measured gets the chart's scale itself back rather than
|
|
34
|
+
* an equal copy, because the traces memoise their paths on the scale's
|
|
35
|
+
* identity and a copy per render would rebuild every path on every render.
|
|
36
|
+
* @param yScale - The chart's intensity axis.
|
|
37
|
+
* @param spectrum - The spectrum.
|
|
38
|
+
* @returns The axis to draw it against.
|
|
39
|
+
*/
|
|
40
|
+
export function spectrumYScale(
|
|
41
|
+
yScale: ChartScale,
|
|
42
|
+
spectrum: MassSpectrum,
|
|
43
|
+
): ChartScale {
|
|
44
|
+
const scale = verticalScaleOf(spectrum);
|
|
45
|
+
return scale === 1
|
|
46
|
+
? yScale
|
|
47
|
+
: { offset: yScale.offset, factor: yScale.factor * scale };
|
|
48
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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';
|
|
@@ -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 {
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
{
|
|
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 ? (
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { EDITOR_TOOLBAR_WIDTH } from '../core/editorToolbarGeometry.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The box a site's guide is drawn in over an empty canvas: beside the toolbar
|
|
7
|
+
* and under the buttons in the corner, so it never covers either.
|
|
8
|
+
*
|
|
9
|
+
* The box itself lets the pointer through; `<EmptyGuide>` takes it back only on
|
|
10
|
+
* its own buttons, links and figures, so a stroke can start on the words.
|
|
11
|
+
* @param props - What the guide shows.
|
|
12
|
+
* @param props.children - The site's guide.
|
|
13
|
+
* @returns The box and the guide in it.
|
|
14
|
+
*/
|
|
15
|
+
export function StructureEditorGuide(props: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): ReactElement {
|
|
18
|
+
return (
|
|
19
|
+
<div data-testid="structure-editor-guide" style={GUIDE_STYLE}>
|
|
20
|
+
{props.children}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Under the open, export and help buttons in the corner: 4 px from the top, a
|
|
27
|
+
* small button 24 px tall, and 4 px under it.
|
|
28
|
+
*/
|
|
29
|
+
const CORNER_CLEARANCE = 32;
|
|
30
|
+
|
|
31
|
+
const GUIDE_STYLE: CSSProperties = {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
inset: `${CORNER_CLEARANCE}px 0 0 ${EDITOR_TOOLBAR_WIDTH}px`,
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
};
|
|
@@ -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
|
|
|
4
4
|
import type { StructureTransfer } from '../core/structureTransfer.ts';
|
|
@@ -74,6 +74,16 @@ export interface StructureEditorProps {
|
|
|
74
74
|
* @default true
|
|
75
75
|
*/
|
|
76
76
|
splash?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* What an empty canvas shows in place of the splash: the site's
|
|
79
|
+
* `<EmptyGuide>`, drawn beside the toolbar and under the buttons in the
|
|
80
|
+
* corner. The pointer goes through it to the canvas except on its own
|
|
81
|
+
* buttons, links and figures; it goes at the press that starts a stroke, and
|
|
82
|
+
* comes back whenever the canvas is empty again. Shown whatever `splash`
|
|
83
|
+
* says. A reaction canvas shows none.
|
|
84
|
+
* @default undefined — the splash, when `splash` is on
|
|
85
|
+
*/
|
|
86
|
+
guide?: ReactNode;
|
|
77
87
|
/**
|
|
78
88
|
* Put a button in the corner that opens every notation of the drawing — its
|
|
79
89
|
* SMILES, its molfiles, its canonical identifiers — and the picture of it,
|