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
package/lib/xps/ui/dropEvents.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a drag and a paste actually carry, and whether the viewer should take
|
|
2
|
+
* What a drag and a paste actually carry, and whether the viewer should take
|
|
3
|
+
* it — and, for a Paste button, what the clipboard holds.
|
|
3
4
|
*
|
|
4
5
|
* Kept apart from the hook because these are the decisions rather than the
|
|
5
6
|
* plumbing: a paste into the tolerance box is being typed, a drag of selected
|
|
@@ -46,4 +47,17 @@ export function takePaste(event, read, readText) {
|
|
|
46
47
|
event.preventDefault();
|
|
47
48
|
readText(text);
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The clipboard's text, for a Paste button: what a paste with the keys would
|
|
52
|
+
* have carried, read without one.
|
|
53
|
+
* @returns The text.
|
|
54
|
+
*/
|
|
55
|
+
export async function readClipboardText() {
|
|
56
|
+
const clipboard = globalThis.navigator
|
|
57
|
+
?.clipboard;
|
|
58
|
+
if (clipboard === undefined) {
|
|
59
|
+
throw new Error('This browser lets no page read the clipboard.');
|
|
60
|
+
}
|
|
61
|
+
return clipboard.readText();
|
|
62
|
+
}
|
|
49
63
|
//# sourceMappingURL=dropEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropEvents.js","sourceRoot":"","sources":["../../../src/xps/ui/dropEvents.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dropEvents.js","sourceRoot":"","sources":["../../../src/xps/ui/dropEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,OAAO,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CACvB,KAAqB,EACrB,IAA+B,EAC/B,QAAgC;IAEhC,IAAI,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC;IACtC,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO;IAC/B,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO;IAC/B,KAAK,CAAC,cAAc,EAAE,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,SAAS,GAAI,UAAU,CAAC,SAA4C;QACxE,EAAE,SAAS,CAAC;IACd,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -68,6 +68,12 @@ export interface SpectrumDrop {
|
|
|
68
68
|
* @param files - The files to read.
|
|
69
69
|
*/
|
|
70
70
|
read: (files: FileList | readonly File[]) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Read text as a paste is read — two columns of numbers, a VAMAS or a JCAMP
|
|
73
|
+
* file as text. Stable for the life of the viewer.
|
|
74
|
+
* @param text - The text.
|
|
75
|
+
*/
|
|
76
|
+
readText: (text: string) => void;
|
|
71
77
|
}
|
|
72
78
|
/** The `ref` to put on the viewer's root, and what that root is doing. */
|
|
73
79
|
export type SpectrumDropHandle = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpectrumDrop.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/useSpectrumDrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,SAAS,EAAE,C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WAAW,YAAY;IAC3B,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,IAAI,EAAE,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI;IAC1C,IAAI,EAAE,YAAY;CACnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,sBAAsB,GAC9B,kBAAkB,CAuIpB"}
|
|
@@ -151,6 +151,6 @@ export function useSpectrumDrop(options) {
|
|
|
151
151
|
page.removeEventListener('paste', onPaste);
|
|
152
152
|
};
|
|
153
153
|
}, [pasteFromPage, read, readText]);
|
|
154
|
-
return [attach, { isOver, isReading, read }];
|
|
154
|
+
return [attach, { isOver, isReading, read, readText }];
|
|
155
155
|
}
|
|
156
156
|
//# sourceMappingURL=useSpectrumDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpectrumDrop.js","sourceRoot":"","sources":["../../../src/xps/ui/useSpectrumDrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSpectrumDrop.js","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K,SAAS;YAAE,OAAO;QAEjD,SAAS,OAAO,CAAC,KAAY;YAC3B,yEAAyE;YACzE,uEAAuE;YACvE,IAAI,KAAK,CAAC,gBAAgB;gBAAE,OAAO;YACnC,SAAS,CAAC,KAAuB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Ref } from 'react';
|
|
12
12
|
import type { XpsEditorHandle } from '../core/xpsEditorApi.ts';
|
|
13
|
+
/** The ways in the viewer's screen owns: its file picker and its paste. */
|
|
14
|
+
export type XpsEntryPoints = Pick<XpsEditorHandle, 'openFiles' | 'paste'>;
|
|
13
15
|
/**
|
|
14
16
|
* Fill in the handle a host drives the viewer through.
|
|
15
17
|
* @param handle - Where to put it, `undefined` when the host asked for none.
|
|
18
|
+
* @param entry - The file picker and the paste, stable for the viewer's life.
|
|
16
19
|
*/
|
|
17
|
-
export declare function useXpsEditorHandle(handle: Ref<XpsEditorHandle> | undefined): void;
|
|
20
|
+
export declare function useXpsEditorHandle(handle: Ref<XpsEditorHandle> | undefined, entry: XpsEntryPoints): void;
|
|
18
21
|
//# sourceMappingURL=useXpsEditorHandle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useXpsEditorHandle.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/useXpsEditorHandle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AASjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK/D
|
|
1
|
+
{"version":3,"file":"useXpsEditorHandle.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/useXpsEditorHandle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AASjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK/D,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,SAAS,EACxC,KAAK,EAAE,cAAc,QAiDtB"}
|
|
@@ -16,8 +16,10 @@ import { useXpsActions, useXpsEditorState } from "./xpsStateContext.js";
|
|
|
16
16
|
/**
|
|
17
17
|
* Fill in the handle a host drives the viewer through.
|
|
18
18
|
* @param handle - Where to put it, `undefined` when the host asked for none.
|
|
19
|
+
* @param entry - The file picker and the paste, stable for the viewer's life.
|
|
19
20
|
*/
|
|
20
|
-
export function useXpsEditorHandle(handle) {
|
|
21
|
+
export function useXpsEditorHandle(handle, entry) {
|
|
22
|
+
const { openFiles, paste } = entry;
|
|
21
23
|
const { state } = useXpsEditorState();
|
|
22
24
|
const actions = useXpsActions();
|
|
23
25
|
const live = useRef(state);
|
|
@@ -34,6 +36,8 @@ export function useXpsEditorHandle(handle) {
|
|
|
34
36
|
actions.addSpectra(spectra);
|
|
35
37
|
},
|
|
36
38
|
clear: actions.clear,
|
|
39
|
+
openFiles,
|
|
40
|
+
paste,
|
|
37
41
|
zoomToEnergy(bindingEnergy, options) {
|
|
38
42
|
const current = live.current;
|
|
39
43
|
const half = options?.halfWidth ?? ENERGY_WINDOW;
|
|
@@ -51,6 +55,6 @@ export function useXpsEditorHandle(handle) {
|
|
|
51
55
|
actions.setDomain({ x: [centre - half, centre + half], y: shown.y });
|
|
52
56
|
},
|
|
53
57
|
getState: () => live.current,
|
|
54
|
-
}), [actions]);
|
|
58
|
+
}), [actions, openFiles, paste]);
|
|
55
59
|
}
|
|
56
60
|
//# sourceMappingURL=useXpsEditorHandle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useXpsEditorHandle.js","sourceRoot":"","sources":["../../../src/xps/ui/useXpsEditorHandle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"useXpsEditorHandle.js","sourceRoot":"","sources":["../../../src/xps/ui/useXpsEditorHandle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKxE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAwC,EACx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;gBAAE,OAAO;YAC3B,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO;KAC7B,CAAC,EACF,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the pointer reads off the XPS chart, and what of it the rest of the
|
|
3
|
+
* viewer hears: the crosshair follows every pixel, the viewer only the peak.
|
|
4
|
+
*/
|
|
5
|
+
import type { RefObject } from 'react';
|
|
6
|
+
import type { PlotRect } from '../../chart/core/chartGeometry.ts';
|
|
7
|
+
import type { ChartScale } from '../../chart/core/chartScale.ts';
|
|
8
|
+
import type { ChartPointer } from '../../chart/ui/useChartPointer.ts';
|
|
9
|
+
import type { XpsHighlight } from '../core/xpsHighlight.ts';
|
|
10
|
+
import type { EnergyAxis } from '../core/xpsSettings.ts';
|
|
11
|
+
import type { XpsSpectrum } from '../core/xpsSpectrum.ts';
|
|
12
|
+
import type { XpsReadout } from './XpsPointerTracker.tsx';
|
|
13
|
+
/** What {@link useXpsReadout} reads the pointer against. */
|
|
14
|
+
export interface XpsReadoutOptions {
|
|
15
|
+
/** The chart's SVG, which the pointer is heard on. */
|
|
16
|
+
svgRef: RefObject<SVGSVGElement | null>;
|
|
17
|
+
/** The plot, outside which the pointer reads nothing. */
|
|
18
|
+
plot: PlotRect;
|
|
19
|
+
/** The spectra drawn, whose peaks the pointer is nearest to. */
|
|
20
|
+
spectra: readonly XpsSpectrum[];
|
|
21
|
+
/** The energy axis the chart is drawn against. */
|
|
22
|
+
axis: EnergyAxis;
|
|
23
|
+
/** The energy scale on screen. */
|
|
24
|
+
xScale: ChartScale;
|
|
25
|
+
/** The counts scale on screen. */
|
|
26
|
+
yScale: ChartScale;
|
|
27
|
+
/**
|
|
28
|
+
* Told whenever the peak under the pointer changes.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
onHighlightChange?: (highlight: XpsHighlight) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Follow the pointer over the chart, and tell the viewer which peak it is on.
|
|
35
|
+
*
|
|
36
|
+
* Only a change of peak is reported, starting from none: the pointer coming
|
|
37
|
+
* onto the plot over no peak says nothing, so a guide a panel put on the chart
|
|
38
|
+
* stays until the pointer actually reaches a peak.
|
|
39
|
+
* @param options - See {@link XpsReadoutOptions}.
|
|
40
|
+
* @returns Where the pointer is and what it reads.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useXpsReadout(options: XpsReadoutOptions): ChartPointer<XpsReadout>;
|
|
43
|
+
//# sourceMappingURL=useXpsReadout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useXpsReadout.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/useXpsReadout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAItE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACxC,yDAAyD;IACzD,IAAI,EAAE,QAAQ,CAAC;IACf,gEAAgE;IAChE,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,kDAAkD;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB,kCAAkC;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;CACvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,iBAAiB,GACzB,YAAY,CAAC,UAAU,CAAC,CAqC1B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the pointer reads off the XPS chart, and what of it the rest of the
|
|
3
|
+
* viewer hears: the crosshair follows every pixel, the viewer only the peak.
|
|
4
|
+
*/
|
|
5
|
+
import { useCallback, useRef } from 'react';
|
|
6
|
+
import { chartValue } from "../../chart/core/chartScale.js";
|
|
7
|
+
import { useChartPointer } from "../../chart/ui/useChartPointer.js";
|
|
8
|
+
import { nearestPeakEnergy, sameNearestPeak } from "../core/nearestPeak.js";
|
|
9
|
+
import { NO_HIGHLIGHT } from "../core/xpsHighlight.js";
|
|
10
|
+
/**
|
|
11
|
+
* Follow the pointer over the chart, and tell the viewer which peak it is on.
|
|
12
|
+
*
|
|
13
|
+
* Only a change of peak is reported, starting from none: the pointer coming
|
|
14
|
+
* onto the plot over no peak says nothing, so a guide a panel put on the chart
|
|
15
|
+
* stays until the pointer actually reaches a peak.
|
|
16
|
+
* @param options - See {@link XpsReadoutOptions}.
|
|
17
|
+
* @returns Where the pointer is and what it reads.
|
|
18
|
+
*/
|
|
19
|
+
export function useXpsReadout(options) {
|
|
20
|
+
const { svgRef, plot, spectra, axis, xScale, yScale, onHighlightChange } = options;
|
|
21
|
+
const read = useCallback((point) => ({
|
|
22
|
+
energy: chartValue(xScale, point.x),
|
|
23
|
+
counts: chartValue(yScale, point.y),
|
|
24
|
+
peak: nearestPeakEnergy(spectra, axis, xScale, point.x),
|
|
25
|
+
}), [xScale, yScale, spectra, axis]);
|
|
26
|
+
const reportedPeak = useRef(null);
|
|
27
|
+
const onReadout = useCallback((readout) => {
|
|
28
|
+
const found = readout?.peak ?? null;
|
|
29
|
+
if (sameNearestPeak(reportedPeak.current, found))
|
|
30
|
+
return;
|
|
31
|
+
reportedPeak.current = found;
|
|
32
|
+
onHighlightChange?.(found === null
|
|
33
|
+
? NO_HIGHLIGHT
|
|
34
|
+
: {
|
|
35
|
+
spectrumId: found.spectrumId,
|
|
36
|
+
peakId: found.peak.id,
|
|
37
|
+
componentId: null,
|
|
38
|
+
bindingEnergy: found.peak.bindingEnergy,
|
|
39
|
+
});
|
|
40
|
+
}, [onHighlightChange]);
|
|
41
|
+
return useChartPointer({
|
|
42
|
+
svgRef,
|
|
43
|
+
plot,
|
|
44
|
+
read,
|
|
45
|
+
sameReadout: samePeakReadout,
|
|
46
|
+
onReadout,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether two readings are about the same peak, which is all the rest of the
|
|
51
|
+
* viewer hears about: the energy under the crosshair changes on every pixel.
|
|
52
|
+
* @param current - The reading last reported.
|
|
53
|
+
* @param next - The reading now.
|
|
54
|
+
* @returns Whether nothing needs reporting.
|
|
55
|
+
*/
|
|
56
|
+
function samePeakReadout(current, next) {
|
|
57
|
+
return sameNearestPeak(current.peak, next.peak);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useXpsReadout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useXpsReadout.js","sourceRoot":"","sources":["../../../src/xps/ui/useXpsReadout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MA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AAE,KAAK,CAAC,IAAI,CAAC,EAAE;gBACrB,WAAW,EAAE,IAAI;gBACjB,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa;aACxC,CACN,CAAC;IACJ,CAAC,EACD,CAAC,iBAAiB,CAAC,CACpB,CAAC;IACF,OAAO,eAAe,CAAa;QACjC,MAAM;QACN,IAAI;QACJ,IAAI;QACJ,WAAW,EAAE,eAAe;QAC5B,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAmB,EAAE,IAAgB;IAC5D,OAAO,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* serves the editor, a report page that only ever draws one spectrum, and a
|
|
12
12
|
* test.
|
|
13
13
|
*/
|
|
14
|
+
import type { ChartSize } from '../../chart/core/chartGeometry.ts';
|
|
14
15
|
import type { XpsHighlight } from '../core/xpsHighlight.ts';
|
|
15
16
|
import type { XpsDomain, XpsRegion, XpsSpectrum } from '../core/xpsSpectrum.ts';
|
|
16
17
|
import type { XpsSettings } from '../core/xpsState.ts';
|
|
@@ -64,6 +65,14 @@ export interface XpsChartProps {
|
|
|
64
65
|
* @default false
|
|
65
66
|
*/
|
|
66
67
|
isReading?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The size to draw at, in CSS pixels, instead of the box the chart is put in
|
|
70
|
+
* — for a chart drawn where nothing is laid out, as a figure written to a
|
|
71
|
+
* file by `renderToStaticMarkup`, which would otherwise come out at the
|
|
72
|
+
* smallest plot there is.
|
|
73
|
+
* @default undefined — the box the chart is put in, measured
|
|
74
|
+
*/
|
|
75
|
+
size?: ChartSize;
|
|
67
76
|
}
|
|
68
77
|
/** Windows shaded on the chart for one spectrum, beside the ones its file defines. */
|
|
69
78
|
export interface XpsChartWindows {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xpsChartProps.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/xpsChartProps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,0BAA0B;IAC1B,QAAQ,EAAE,WAAW,CAAC;IACtB,+CAA+C;IAC/C,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,uEAAuE;IACvE,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;IACtD;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"xpsChartProps.d.ts","sourceRoot":"","sources":["../../../src/xps/ui/xpsChartProps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EA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AAC;CAC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.134.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
|
|
6
6
|
"author": "Luc Patiny",
|
|
@@ -14,15 +14,16 @@ import { captionKeys, captionSelectionStyle } from './captionCommands.ts';
|
|
|
14
14
|
import type { CaptionEditorProps } from './captionEditorProps.ts';
|
|
15
15
|
import { captionPreview, setCaptionChemical } from './captionPreview.ts';
|
|
16
16
|
import { captionDocument, captionText } from './captionSchema.ts';
|
|
17
|
+
import { useToolbarInView } from './toolbarInView.ts';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* The box a caption is typed in, laid over a drawing where the caption goes,
|
|
20
21
|
* in its font and size, with what it will look like: bold, italic, scripts,
|
|
21
22
|
* sizes, and the digits and charges the chemical rules set. Its toolbar also
|
|
22
23
|
* turns those rules off, and sets the font and the alignment. It opens
|
|
23
|
-
* focused with everything selected; ⌘Enter or a click elsewhere
|
|
24
|
-
* Enter starts a line, Escape drops the change. A caption aligned
|
|
25
|
-
* its place on screen. `react-cheminfo/styles/caption-editor.css` draws it.
|
|
24
|
+
* focused with everything selected; the tick, ⌘Enter or a click elsewhere
|
|
25
|
+
* keeps it, Enter starts a line, Escape drops the change. A caption aligned
|
|
26
|
+
* anew keeps its place on screen. `react-cheminfo/styles/caption-editor.css` draws it.
|
|
26
27
|
* @param props - The caption, and where it is laid.
|
|
27
28
|
* @returns The box and its toolbar.
|
|
28
29
|
*/
|
|
@@ -40,6 +41,7 @@ export function CaptionEditor(props: CaptionEditorProps): ReactElement {
|
|
|
40
41
|
const host = useRef<HTMLDivElement>(null);
|
|
41
42
|
const view = useRef<EditorView | null>(null);
|
|
42
43
|
const closed = useRef(false);
|
|
44
|
+
useToolbarInView(frame);
|
|
43
45
|
// Seeded once: what is typed never comes back into the box as a new state.
|
|
44
46
|
const [opened] = useState(() => {
|
|
45
47
|
const plugins = captionKeys(base);
|
|
@@ -192,6 +194,9 @@ export function CaptionEditor(props: CaptionEditorProps): ReactElement {
|
|
|
192
194
|
onChemical={setChemical}
|
|
193
195
|
onAlign={realign}
|
|
194
196
|
onFamily={setFamily}
|
|
197
|
+
onDone={() => {
|
|
198
|
+
close(true);
|
|
199
|
+
}}
|
|
195
200
|
/>
|
|
196
201
|
<div
|
|
197
202
|
ref={host}
|
|
@@ -83,13 +83,15 @@ export interface CaptionToolbarProps {
|
|
|
83
83
|
onAlign: (align: TextAlign) => void;
|
|
84
84
|
/** Set the caption in another font. */
|
|
85
85
|
onFamily: (family: string) => void;
|
|
86
|
+
/** Keep the caption and close its box, as ⌘Enter does. */
|
|
87
|
+
onDone: () => void;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* The styles of a caption being typed, over the box it is typed in: bold,
|
|
90
92
|
* italic, subscript, superscript and the size of the selection, then the
|
|
91
|
-
* automatic formulas, the font and the alignment of the whole caption
|
|
92
|
-
* buttons leave the keys with the text.
|
|
93
|
+
* automatic formulas, the font and the alignment of the whole caption, and
|
|
94
|
+
* last the tick that keeps it. Its buttons leave the keys with the text.
|
|
93
95
|
* @param props - The styles of the selection, and how to change them.
|
|
94
96
|
* @returns The toolbar.
|
|
95
97
|
*/
|
|
@@ -105,6 +107,7 @@ export function CaptionToolbar(props: CaptionToolbarProps): ReactElement {
|
|
|
105
107
|
onChemical,
|
|
106
108
|
onAlign,
|
|
107
109
|
onFamily,
|
|
110
|
+
onDone,
|
|
108
111
|
} = props;
|
|
109
112
|
return (
|
|
110
113
|
<div
|
|
@@ -207,6 +210,19 @@ export function CaptionToolbar(props: CaptionToolbarProps): ReactElement {
|
|
|
207
210
|
/>
|
|
208
211
|
))}
|
|
209
212
|
</ButtonGroup>
|
|
213
|
+
<Button
|
|
214
|
+
className="caption-toolbar__done"
|
|
215
|
+
size="small"
|
|
216
|
+
variant="minimal"
|
|
217
|
+
intent="primary"
|
|
218
|
+
icon="tick"
|
|
219
|
+
aria-label="Done"
|
|
220
|
+
title={`Done (${shortcutText([MOD_KEY, 'Enter'])}, or click elsewhere). Escape drops the change.`}
|
|
221
|
+
onMouseDown={(event) => {
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
}}
|
|
224
|
+
onClick={onDone}
|
|
225
|
+
/>
|
|
210
226
|
</div>
|
|
211
227
|
);
|
|
212
228
|
}
|
|
@@ -20,3 +20,5 @@ export {
|
|
|
20
20
|
} from './captionSchema.ts';
|
|
21
21
|
export type { CaptionToolbarProps } from './CaptionToolbar.tsx';
|
|
22
22
|
export { CaptionToolbar } from './CaptionToolbar.tsx';
|
|
23
|
+
export type { ToolbarFit } from './toolbarInView.ts';
|
|
24
|
+
export { toolbarFit, useToolbarInView } from './toolbarInView.ts';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeping a caption's toolbar inside the area it is drawn over: the bar is
|
|
3
|
+
* centred over its caption, so a caption near an edge would leave part of the
|
|
4
|
+
* bar — its first buttons, or the tick that keeps the caption — outside a
|
|
5
|
+
* figure that clips what overflows it.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { RefObject } from 'react';
|
|
9
|
+
import { useLayoutEffect } from 'react';
|
|
10
|
+
|
|
11
|
+
/** How far the bar keeps from the area's edges, in pixels. */
|
|
12
|
+
const TOOLBAR_INSET = 4;
|
|
13
|
+
|
|
14
|
+
/** A box on screen, as `getBoundingClientRect` gives it. */
|
|
15
|
+
interface ScreenBox {
|
|
16
|
+
left: number;
|
|
17
|
+
right: number;
|
|
18
|
+
top: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Where a caption's toolbar is moved to stay in view. */
|
|
22
|
+
export interface ToolbarFit {
|
|
23
|
+
/** How far it is moved sideways, in pixels: positive to the right. */
|
|
24
|
+
shift: number;
|
|
25
|
+
/** Whether it goes under the caption, the area having no room above. */
|
|
26
|
+
below: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Where a toolbar centred over its caption goes to stay inside an area: moved
|
|
31
|
+
* sideways no more than it overflows, its left edge kept in view first, and
|
|
32
|
+
* under the caption when it would rise above the area.
|
|
33
|
+
* @param bar - The toolbar where it is centred.
|
|
34
|
+
* @param area - The area it must stay in.
|
|
35
|
+
* @returns The move.
|
|
36
|
+
*/
|
|
37
|
+
export function toolbarFit(bar: ScreenBox, area: ScreenBox): ToolbarFit {
|
|
38
|
+
let shift = 0;
|
|
39
|
+
if (bar.right > area.right - TOOLBAR_INSET) {
|
|
40
|
+
shift = area.right - TOOLBAR_INSET - bar.right;
|
|
41
|
+
}
|
|
42
|
+
if (bar.left + shift < area.left + TOOLBAR_INSET) {
|
|
43
|
+
shift = area.left + TOOLBAR_INSET - bar.left;
|
|
44
|
+
}
|
|
45
|
+
return { shift, below: bar.top < area.top + TOOLBAR_INSET };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Keep the toolbar of a caption being typed inside the box the caption is
|
|
50
|
+
* laid over (its offset parent), after every render: moved sideways through
|
|
51
|
+
* `--caption-toolbar-shift`, and under the caption with `data-below`.
|
|
52
|
+
* `react-cheminfo/styles/caption-editor.css` reads both.
|
|
53
|
+
* @param ref - The caption editor's frame (`.caption-editor`), or any element
|
|
54
|
+
* inside it, such as the box the text is typed in.
|
|
55
|
+
*/
|
|
56
|
+
export function useToolbarInView(ref: RefObject<HTMLElement | null>): void {
|
|
57
|
+
useLayoutEffect(() => {
|
|
58
|
+
const frame = ref.current?.closest<HTMLElement>('.caption-editor');
|
|
59
|
+
const toolbar = frame?.querySelector<HTMLElement>('.caption-toolbar');
|
|
60
|
+
const area = frame?.offsetParent;
|
|
61
|
+
if (!toolbar || !area) return;
|
|
62
|
+
toolbar.style.removeProperty('--caption-toolbar-shift');
|
|
63
|
+
delete toolbar.dataset.below;
|
|
64
|
+
const { shift, below } = toolbarFit(
|
|
65
|
+
toolbar.getBoundingClientRect(),
|
|
66
|
+
area.getBoundingClientRect(),
|
|
67
|
+
);
|
|
68
|
+
if (shift !== 0) {
|
|
69
|
+
toolbar.style.setProperty('--caption-toolbar-shift', `${shift}px`);
|
|
70
|
+
}
|
|
71
|
+
if (below) toolbar.dataset.below = '';
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -27,6 +27,9 @@ export const ZOOM_PRESETS: readonly number[] = [
|
|
|
27
27
|
0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4, 8, 16,
|
|
28
28
|
];
|
|
29
29
|
|
|
30
|
+
/** How much one press of `+` zooms in, and of `-` zooms out. */
|
|
31
|
+
export const ZOOM_STEP = 1.25;
|
|
32
|
+
|
|
30
33
|
/** How close the view starts on an empty page: a bond is 36 px long. */
|
|
31
34
|
export const START_CAMERA: Camera = { x: 0, y: 0, zoom: 2.5 };
|
|
32
35
|
|
|
@@ -73,10 +73,12 @@ export {
|
|
|
73
73
|
} from './motion.ts';
|
|
74
74
|
export {
|
|
75
75
|
MAX_SHEETS,
|
|
76
|
+
boxSheets,
|
|
76
77
|
enclosingBox,
|
|
77
78
|
figureBox,
|
|
78
79
|
paddedBox,
|
|
79
80
|
pageSheets,
|
|
81
|
+
pagesLine,
|
|
80
82
|
sheetLines,
|
|
81
83
|
} from './pageGrid.ts';
|
|
82
84
|
export type { ImagePrimitive } from './pictures.ts';
|
|
@@ -8,7 +8,7 @@ import { placedPage } from '../core/pages.ts';
|
|
|
8
8
|
import type { Box, DrawPage, FigureSize } from '../core/types.ts';
|
|
9
9
|
|
|
10
10
|
import { primitivesBounds } from './bounds.ts';
|
|
11
|
-
import type { Scene
|
|
11
|
+
import type { Scene } from './primitives.ts';
|
|
12
12
|
|
|
13
13
|
/** The most sheets a drawing goes on: past them, the rest does not print. */
|
|
14
14
|
export const MAX_SHEETS = 200;
|
|
@@ -25,6 +25,20 @@ interface Tile {
|
|
|
25
25
|
row: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* What the page lines mean for printing, said under the page setup.
|
|
30
|
+
* @param sheets - How many sheets hold something; null when the lines are
|
|
31
|
+
* hidden.
|
|
32
|
+
* @returns The line.
|
|
33
|
+
*/
|
|
34
|
+
export function pagesLine(sheets: number | null): string {
|
|
35
|
+
if (sheets === null) return 'The whole drawing prints on one page.';
|
|
36
|
+
if (sheets >= MAX_SHEETS) return `Only the first ${MAX_SHEETS} pages print.`;
|
|
37
|
+
const printed =
|
|
38
|
+
sheets === 1 ? 'One page prints' : `${sheets} pages print, one sheet each`;
|
|
39
|
+
return `Drag objects across the lines. ${printed}.`;
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
/**
|
|
29
43
|
* The box a scene is written in: its drawing, and the padding around it.
|
|
30
44
|
* @param scene - The scene.
|
|
@@ -48,7 +62,12 @@ export function paddedBox(scene: Scene, padding = 4) {
|
|
|
48
62
|
* @returns The sheets, in points.
|
|
49
63
|
*/
|
|
50
64
|
export function pageSheets(scene: Scene, page: DrawPage): Box[] {
|
|
51
|
-
|
|
65
|
+
const boxes: Box[] = [];
|
|
66
|
+
for (const item of scene.items) {
|
|
67
|
+
const box = primitivesBounds(item.primitives);
|
|
68
|
+
if (box) boxes.push(box);
|
|
69
|
+
}
|
|
70
|
+
return boxSheets(boxes, placedPage(page, paddedBox(scene)));
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
/**
|
|
@@ -71,21 +90,20 @@ export function figureBox(scene: Scene, figure?: FigureSize): Box {
|
|
|
71
90
|
}
|
|
72
91
|
|
|
73
92
|
/**
|
|
74
|
-
* The sheets of a grid that hold something,
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @param
|
|
93
|
+
* The sheets of a paper's grid that hold something, for an editor that knows
|
|
94
|
+
* its drawing as boxes rather than as a scene: the sheets any box reaches into,
|
|
95
|
+
* in reading order, and the first of the grid when there is none.
|
|
96
|
+
* @param boxes - What is drawn, one box per item, in points.
|
|
97
|
+
* @param page - The paper, with its place: `placedPage` over the drawing.
|
|
78
98
|
* @returns The sheets, in points, at most {@link MAX_SHEETS}.
|
|
79
99
|
*/
|
|
80
|
-
function
|
|
81
|
-
|
|
100
|
+
export function boxSheets(
|
|
101
|
+
boxes: readonly Box[],
|
|
82
102
|
page: Required<DrawPage>,
|
|
83
103
|
): Box[] {
|
|
84
104
|
const { x, y, width, height } = page;
|
|
85
105
|
const tiles = new Map<string, Tile>();
|
|
86
|
-
for (const
|
|
87
|
-
const box = primitivesBounds(item.primitives);
|
|
88
|
-
if (!box) continue;
|
|
106
|
+
for (const box of boxes) {
|
|
89
107
|
const columns = span(box.x, box.width, x, width);
|
|
90
108
|
const rows = span(box.y, box.height, y, height);
|
|
91
109
|
for (let row = rows.first; row <= rows.last; row++) {
|