react-cheminfo 0.17.0 → 0.18.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/lib/structure/core/editorGuide.d.ts +69 -0
- package/lib/structure/core/editorGuide.d.ts.map +1 -0
- package/lib/structure/core/editorGuide.js +162 -0
- package/lib/structure/core/editorGuide.js.map +1 -0
- package/lib/structure/core/editorToolbar.d.ts +45 -0
- package/lib/structure/core/editorToolbar.d.ts.map +1 -0
- package/lib/structure/core/editorToolbar.js +132 -0
- package/lib/structure/core/editorToolbar.js.map +1 -0
- package/lib/structure/core/editorToolbarGeometry.d.ts +36 -0
- package/lib/structure/core/editorToolbarGeometry.d.ts.map +1 -0
- package/lib/structure/core/editorToolbarGeometry.js +61 -0
- package/lib/structure/core/editorToolbarGeometry.js.map +1 -0
- package/lib/structure/core/index.d.ts +6 -0
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js +3 -0
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/core/pendingCall.d.ts +21 -0
- package/lib/structure/core/pendingCall.d.ts.map +1 -0
- package/lib/structure/core/pendingCall.js +37 -0
- package/lib/structure/core/pendingCall.js.map +1 -0
- package/lib/structure/ui/EditorCanvas.d.ts +1 -16
- package/lib/structure/ui/EditorCanvas.d.ts.map +1 -1
- package/lib/structure/ui/EditorCanvas.js +5 -18
- package/lib/structure/ui/EditorCanvas.js.map +1 -1
- package/lib/structure/ui/EditorHelpButton.d.ts +22 -0
- package/lib/structure/ui/EditorHelpButton.d.ts.map +1 -0
- package/lib/structure/ui/EditorHelpButton.js +38 -0
- package/lib/structure/ui/EditorHelpButton.js.map +1 -0
- package/lib/structure/ui/KeyCaps.d.ts +12 -0
- package/lib/structure/ui/KeyCaps.d.ts.map +1 -0
- package/lib/structure/ui/KeyCaps.js +29 -0
- package/lib/structure/ui/KeyCaps.js.map +1 -0
- package/lib/structure/ui/StructureEditor.d.ts +9 -2
- package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
- package/lib/structure/ui/StructureEditor.js +17 -24
- package/lib/structure/ui/StructureEditor.js.map +1 -1
- package/lib/structure/ui/StructureEditorHelp.d.ts +18 -0
- package/lib/structure/ui/StructureEditorHelp.d.ts.map +1 -0
- package/lib/structure/ui/StructureEditorHelp.js +68 -0
- package/lib/structure/ui/StructureEditorHelp.js.map +1 -0
- package/lib/structure/ui/ToolbarTooltip.d.ts +20 -0
- package/lib/structure/ui/ToolbarTooltip.d.ts.map +1 -0
- package/lib/structure/ui/ToolbarTooltip.js +49 -0
- package/lib/structure/ui/ToolbarTooltip.js.map +1 -0
- package/lib/structure/ui/editorChange.d.ts +52 -0
- package/lib/structure/ui/editorChange.d.ts.map +1 -0
- package/lib/structure/ui/editorChange.js +34 -0
- package/lib/structure/ui/editorChange.js.map +1 -0
- package/lib/structure/ui/index.d.ts +3 -1
- package/lib/structure/ui/index.d.ts.map +1 -1
- package/lib/structure/ui/index.js +1 -0
- package/lib/structure/ui/index.js.map +1 -1
- package/lib/structure/ui/useToolbarFloor.d.ts.map +1 -1
- package/lib/structure/ui/useToolbarFloor.js +6 -45
- package/lib/structure/ui/useToolbarFloor.js.map +1 -1
- package/lib/structure/ui/useToolbarHover.d.ts +28 -0
- package/lib/structure/ui/useToolbarHover.d.ts.map +1 -0
- package/lib/structure/ui/useToolbarHover.js +96 -0
- package/lib/structure/ui/useToolbarHover.js.map +1 -0
- package/lib/structure/ui/watchToolbar.d.ts +17 -0
- package/lib/structure/ui/watchToolbar.d.ts.map +1 -0
- package/lib/structure/ui/watchToolbar.js +56 -0
- package/lib/structure/ui/watchToolbar.js.map +1 -0
- package/package.json +1 -1
- package/src/structure/core/editorGuide.ts +221 -0
- package/src/structure/core/editorToolbar.ts +175 -0
- package/src/structure/core/editorToolbarGeometry.ts +80 -0
- package/src/structure/core/index.ts +29 -0
- package/src/structure/core/pendingCall.ts +59 -0
- package/src/structure/ui/EditorCanvas.tsx +9 -35
- package/src/structure/ui/EditorHelpButton.tsx +70 -0
- package/src/structure/ui/KeyCaps.tsx +40 -0
- package/src/structure/ui/StructureEditor.tsx +39 -21
- package/src/structure/ui/StructureEditorHelp.tsx +136 -0
- package/src/structure/ui/ToolbarTooltip.tsx +95 -0
- package/src/structure/ui/editorChange.ts +81 -0
- package/src/structure/ui/index.ts +5 -1
- package/src/structure/ui/useToolbarFloor.ts +7 -46
- package/src/structure/ui/useToolbarHover.ts +134 -0
- package/src/structure/ui/watchToolbar.ts +59 -0
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { CanvasEditorInputFormat } from 'react-ocl';
|
|
3
|
-
|
|
4
|
-
export type StructureEditorMode = 'molecule' | 'reaction';
|
|
5
|
-
/** Everything the editor holds at the moment it changed. */
|
|
6
|
-
export interface StructureEditorChange {
|
|
7
|
-
/** Which kind of editor produced it. */
|
|
8
|
-
mode: StructureEditorMode;
|
|
9
|
-
/**
|
|
10
|
-
* The idCode, with the coordinates the editor laid out written after a
|
|
11
|
-
* space. `splitIdCode` takes the two apart.
|
|
12
|
-
*/
|
|
13
|
-
idCode: string;
|
|
14
|
-
/** The V2000 molfile of a molecule, or the RXN file of a reaction. */
|
|
15
|
-
molfile: string;
|
|
16
|
-
/** The SMILES of a molecule, or the reaction SMILES. */
|
|
17
|
-
smiles: string;
|
|
18
|
-
}
|
|
3
|
+
import type { StructureEditorChange, StructureEditorMode } from './editorChange.ts';
|
|
19
4
|
interface EditorCanvasProps {
|
|
20
5
|
/** Called on every stroke, with the editor read out synchronously. */
|
|
21
6
|
onChange: (change: StructureEditorChange) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCanvas.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/EditorCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AAGnB,
|
|
1
|
+
{"version":3,"file":"EditorCanvas.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/EditorCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,UAAU,iBAAiB;IACzB,sEAAsE;IACtE,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;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA6CnE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
3
|
import { CanvasMoleculeEditor, CanvasReactionEditor } from 'react-ocl';
|
|
4
|
+
import { moleculeChange, reactionChange } from "./editorChange.js";
|
|
4
5
|
/**
|
|
5
6
|
* The react-ocl canvas, filling whatever box it is put in.
|
|
6
7
|
*
|
|
@@ -12,24 +13,10 @@ import { CanvasMoleculeEditor, CanvasReactionEditor } from 'react-ocl';
|
|
|
12
13
|
export function EditorCanvas(props) {
|
|
13
14
|
const { onChange, fragment = false, inputFormat = 'idcode', value = '', mode = 'molecule', } = props;
|
|
14
15
|
const [initialValue] = useState(value);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
mode: 'molecule',
|
|
20
|
-
idCode: event.getIdcode(),
|
|
21
|
-
molfile: event.getMolfile(),
|
|
22
|
-
smiles: event.getSmiles(),
|
|
23
|
-
});
|
|
24
|
-
}, [onChange]);
|
|
25
|
-
const handleReaction = useCallback((event) => {
|
|
26
|
-
onChange({
|
|
27
|
-
mode: 'reaction',
|
|
28
|
-
idCode: event.getIdcode(),
|
|
29
|
-
molfile: event.getRxn(),
|
|
30
|
-
smiles: event.getSmiles(),
|
|
31
|
-
});
|
|
32
|
-
}, [onChange]);
|
|
16
|
+
// The event describes the editor only while the callback runs, so it is read
|
|
17
|
+
// out now and whatever waiting there is happens afterwards.
|
|
18
|
+
const handleMolecule = useCallback((event) => onChange(moleculeChange(event)), [onChange]);
|
|
19
|
+
const handleReaction = useCallback((event) => onChange(reactionChange(event)), [onChange]);
|
|
33
20
|
return (_jsx("div", { style: CANVAS_STYLE, children: mode === 'reaction' ? (_jsx(CanvasReactionEditor, { width: "100%", height: "100%", fragment: fragment, inputFormat: inputFormat, inputValue: initialValue, onChange: handleReaction })) : (_jsx(CanvasMoleculeEditor, { width: "100%", height: "100%", fragment: fragment, inputFormat: inputFormat, inputValue: initialValue, onChange: handleMolecule })) }));
|
|
34
21
|
}
|
|
35
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCanvas.js","sourceRoot":"","sources":["../../../src/structure/ui/EditorCanvas.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAM9C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"EditorCanvas.js","sourceRoot":"","sources":["../../../src/structure/ui/EditorCanvas.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAM9C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAMv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CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactElement, RefObject } from 'react';
|
|
2
|
+
import type { StructureEditorMode } from './editorChange.ts';
|
|
3
|
+
/** What {@link EditorHelpButton} needs. */
|
|
4
|
+
export interface EditorHelpButtonProps {
|
|
5
|
+
/** The element wrapping the editor, which F1 is listened for on. */
|
|
6
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
7
|
+
/** Which editor the guide is written for. */
|
|
8
|
+
mode: StructureEditorMode;
|
|
9
|
+
/** Whether the editor draws a query fragment. */
|
|
10
|
+
fragment: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The editor's help button, in the corner of the drawing, opening the guide to
|
|
14
|
+
* the mouse and the keyboard.
|
|
15
|
+
*
|
|
16
|
+
* F1 opens it too: openchemlib binds that key to a help dialog it does not
|
|
17
|
+
* implement on the web.
|
|
18
|
+
* @param props - See {@link EditorHelpButtonProps}.
|
|
19
|
+
* @returns The button and its popover.
|
|
20
|
+
*/
|
|
21
|
+
export declare function EditorHelpButton(props: EditorHelpButtonProps): ReactElement;
|
|
22
|
+
//# sourceMappingURL=EditorHelpButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorHelpButton.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/EditorHelpButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,2CAA2C;AAC3C,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,6CAA6C;IAC7C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAmC3E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, PopoverNext, Tooltip } from '@blueprintjs/core';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { StructureEditorHelp } from "./StructureEditorHelp.js";
|
|
5
|
+
/**
|
|
6
|
+
* The editor's help button, in the corner of the drawing, opening the guide to
|
|
7
|
+
* the mouse and the keyboard.
|
|
8
|
+
*
|
|
9
|
+
* F1 opens it too: openchemlib binds that key to a help dialog it does not
|
|
10
|
+
* implement on the web.
|
|
11
|
+
* @param props - See {@link EditorHelpButtonProps}.
|
|
12
|
+
* @returns The button and its popover.
|
|
13
|
+
*/
|
|
14
|
+
export function EditorHelpButton(props) {
|
|
15
|
+
const { containerRef, mode, fragment } = props;
|
|
16
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const container = containerRef.current;
|
|
19
|
+
if (container === null)
|
|
20
|
+
return;
|
|
21
|
+
const onKeyDown = (event) => {
|
|
22
|
+
if (event.key !== 'F1')
|
|
23
|
+
return;
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
setIsOpen(true);
|
|
26
|
+
};
|
|
27
|
+
container.addEventListener('keydown', onKeyDown);
|
|
28
|
+
return () => container.removeEventListener('keydown', onKeyDown);
|
|
29
|
+
}, [containerRef]);
|
|
30
|
+
return (_jsx("div", { style: CORNER_STYLE, children: _jsx(PopoverNext, { isOpen: isOpen, onInteraction: setIsOpen, placement: "left-start", content: _jsx(StructureEditorHelp, { mode: mode, fragment: fragment }), children: _jsx(Tooltip, { content: LABEL, placement: "left", disabled: isOpen, children: _jsx(Button, { variant: "minimal", size: "small", icon: "help", "aria-label": LABEL }) }) }) }));
|
|
31
|
+
}
|
|
32
|
+
const LABEL = 'Mouse and keyboard';
|
|
33
|
+
const CORNER_STYLE = {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
top: 4,
|
|
36
|
+
right: 4,
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=EditorHelpButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorHelpButton.js","sourceRoot":"","sources":["../../../src/structure/ui/EditorHelpButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAahE;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO;QAC/B,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAQ,EAAE;YAC/C,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI;gBAAE,OAAO;YAC/B,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC;QACF,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACjD,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,cAAK,KAAK,EAAE,YAAY,YACtB,KAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,SAAS,EACxB,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,KAAC,mBAAmB,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAI,YAEhE,KAAC,OAAO,IAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,EAAC,QAAQ,EAAE,MAAM,YACxD,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,MAAM,gBACC,KAAK,GACjB,GACM,GACE,GACV,CACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAEnC,MAAM,YAAY,GAAkB;IAClC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACT,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Keys pressed together, each drawn as a key cap, `Mod` as the modifier the
|
|
4
|
+
* editor listens to on this platform.
|
|
5
|
+
* @param props - The keys.
|
|
6
|
+
* @param props.keys - The keys, unique within the list.
|
|
7
|
+
* @returns The key caps.
|
|
8
|
+
*/
|
|
9
|
+
export declare function KeyCaps(props: {
|
|
10
|
+
keys: readonly string[];
|
|
11
|
+
}): ReactElement;
|
|
12
|
+
//# sourceMappingURL=KeyCaps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyCaps.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/KeyCaps.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,YAAY,CAWxE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Classes } from '@blueprintjs/core';
|
|
3
|
+
import { editorKeyLabel } from "../core/editorGuide.js";
|
|
4
|
+
/**
|
|
5
|
+
* Keys pressed together, each drawn as a key cap, `Mod` as the modifier the
|
|
6
|
+
* editor listens to on this platform.
|
|
7
|
+
* @param props - The keys.
|
|
8
|
+
* @param props.keys - The keys, unique within the list.
|
|
9
|
+
* @returns The key caps.
|
|
10
|
+
*/
|
|
11
|
+
export function KeyCaps(props) {
|
|
12
|
+
const isMac = isMacPlatform();
|
|
13
|
+
return (_jsx("span", { style: KEYS_STYLE, children: props.keys.map((key) => (_jsx("kbd", { className: Classes.KEY, children: editorKeyLabel(key, isMac) }, key))) }));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether the page runs on a Mac, decided as openchemlib decides it, so the
|
|
17
|
+
* cap shown is the modifier the editor actually reads: ⌘ there, Ctrl elsewhere.
|
|
18
|
+
* @returns True on a Mac.
|
|
19
|
+
*/
|
|
20
|
+
function isMacPlatform() {
|
|
21
|
+
return typeof navigator !== 'undefined' && navigator.platform === 'MacIntel';
|
|
22
|
+
}
|
|
23
|
+
const KEYS_STYLE = {
|
|
24
|
+
display: 'inline-flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
gap: 3,
|
|
27
|
+
whiteSpace: 'nowrap',
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=KeyCaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyCaps.js","sourceRoot":"","sources":["../../../src/structure/ui/KeyCaps.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,KAAkC;IACxD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,OAAO,CACL,eAAM,KAAK,EAAE,UAAU,YACpB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACvB,cAAe,SAAS,EAAE,OAAO,CAAC,GAAG,YAClC,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,IADnB,GAAG,CAEP,CACP,CAAC,GACG,CACR,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa;IACpB,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,QAAQ;CACrB,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { CSSProperties, ReactElement } from 'react';
|
|
10
10
|
import type { CanvasEditorInputFormat } from 'react-ocl';
|
|
11
|
-
import type { StructureEditorChange, StructureEditorMode } from './
|
|
11
|
+
import type { StructureEditorChange, StructureEditorMode } from './editorChange.ts';
|
|
12
12
|
/** What {@link StructureEditor} needs. */
|
|
13
13
|
export interface StructureEditorProps {
|
|
14
14
|
/**
|
|
@@ -61,6 +61,12 @@ export interface StructureEditorProps {
|
|
|
61
61
|
* @default 'molecule'
|
|
62
62
|
*/
|
|
63
63
|
mode?: StructureEditorMode;
|
|
64
|
+
/**
|
|
65
|
+
* Explain each toolbar button in a tooltip, and put a button in the corner
|
|
66
|
+
* that opens a guide to the mouse and the keyboard, which F1 opens too.
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
help?: boolean;
|
|
64
70
|
/**
|
|
65
71
|
* Class the container carries, so a site can reach it from its stylesheet.
|
|
66
72
|
* @default undefined
|
|
@@ -74,7 +80,8 @@ export interface StructureEditorProps {
|
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
82
|
* The canvas structure editor, sized to fill its container and never to hide
|
|
77
|
-
* part of its toolbar
|
|
83
|
+
* part of its toolbar, with a tooltip on every toolbar button and a guide to
|
|
84
|
+
* the keys.
|
|
78
85
|
* @param props - What to draw, when to reload it, and where to send it.
|
|
79
86
|
* @returns The editor.
|
|
80
87
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AASzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAOzD,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAQ3B,0CAA0C;AAC1C,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;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA8CzE"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, lazy, useCallback, useEffect, useRef } from 'react';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, lazy, useCallback, useEffect, useRef, useState, } from 'react';
|
|
3
3
|
import { TOKEN } from "../../tokens/core/familyTokens.js";
|
|
4
|
+
import { createPendingCall } from "../core/pendingCall.js";
|
|
5
|
+
import { EditorHelpButton } from "./EditorHelpButton.js";
|
|
6
|
+
import { ToolbarTooltip } from "./ToolbarTooltip.js";
|
|
4
7
|
import { useToolbarFloor } from "./useToolbarFloor.js";
|
|
5
8
|
const EditorCanvas = lazy(async () => {
|
|
6
9
|
const module = await import("./EditorCanvas.js");
|
|
@@ -8,21 +11,24 @@ const EditorCanvas = lazy(async () => {
|
|
|
8
11
|
});
|
|
9
12
|
/**
|
|
10
13
|
* The canvas structure editor, sized to fill its container and never to hide
|
|
11
|
-
* part of its toolbar
|
|
14
|
+
* part of its toolbar, with a tooltip on every toolbar button and a guide to
|
|
15
|
+
* the keys.
|
|
12
16
|
* @param props - What to draw, when to reload it, and where to send it.
|
|
13
17
|
* @returns The editor.
|
|
14
18
|
*/
|
|
15
19
|
export function StructureEditor(props) {
|
|
16
|
-
const { onChange, fragment = false, inputFormat = 'idcode', value = '', revision = 0, debounce = 300, minHeight = 320, mode = 'molecule', className, style, } = props;
|
|
20
|
+
const { onChange, fragment = false, inputFormat = 'idcode', value = '', revision = 0, debounce = 300, minHeight = 320, mode = 'molecule', help = true, className, style, } = props;
|
|
17
21
|
const containerRef = useToolbarFloor({ minHeight, revision });
|
|
18
22
|
const handleChange = useDebounced(onChange, debounce, revision);
|
|
19
|
-
return (_jsx("div", { ref: containerRef, className: className, style: { ...ROOT_STYLE, minHeight, ...style }, children:
|
|
23
|
+
return (_jsx("div", { ref: containerRef, className: className, style: { ...ROOT_STYLE, minHeight, ...style }, children: _jsxs(Suspense, { fallback: _jsx("div", { style: LOADING_STYLE, children: "Loading the editor\u2026" }), children: [_jsx(EditorCanvas, { onChange: handleChange, fragment: fragment, inputFormat: inputFormat, value: value, mode: mode }, revision), help ? (_jsxs(_Fragment, { children: [_jsx(ToolbarTooltip, { containerRef: containerRef, mode: mode }), _jsx(EditorHelpButton, { containerRef: containerRef, mode: mode, fragment: fragment })] })) : null] }) }));
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Report the last edit of a burst rather than every one of them.
|
|
23
27
|
*
|
|
24
28
|
* The editor's own event is read out before the wait starts, so what arrives
|
|
25
29
|
* late is a plain object rather than a handle on an editor that has moved on.
|
|
30
|
+
* An editor removed mid-burst — a tab switched, a card folded — still reports
|
|
31
|
+
* its last edit, which would otherwise be lost with the timer.
|
|
26
32
|
* @param onChange - What the caller wants told.
|
|
27
33
|
* @param delay - How long the drawing has to be still, in milliseconds.
|
|
28
34
|
* @param resetKey - Dropped edits: a burst still waiting when the caller
|
|
@@ -30,31 +36,18 @@ export function StructureEditor(props) {
|
|
|
30
36
|
* @returns The handler to give the canvas.
|
|
31
37
|
*/
|
|
32
38
|
function useDebounced(onChange, delay, resetKey) {
|
|
33
|
-
const
|
|
39
|
+
const [pending] = useState((createPendingCall));
|
|
34
40
|
const onChangeRef = useRef(onChange);
|
|
35
41
|
useEffect(() => {
|
|
36
42
|
onChangeRef.current = onChange;
|
|
37
43
|
});
|
|
38
44
|
useEffect(() => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
timerRef.current = null;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}, [resetKey]);
|
|
45
|
+
pending.drop();
|
|
46
|
+
}, [pending, resetKey]);
|
|
47
|
+
useEffect(() => () => pending.flush(), [pending]);
|
|
46
48
|
return useCallback((change) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (delay <= 0) {
|
|
50
|
-
onChangeRef.current(change);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
timerRef.current = setTimeout(() => {
|
|
54
|
-
timerRef.current = null;
|
|
55
|
-
onChangeRef.current(change);
|
|
56
|
-
}, delay);
|
|
57
|
-
}, [delay]);
|
|
49
|
+
pending.push(change, delay, (value) => onChangeRef.current(value));
|
|
50
|
+
}, [pending, delay]);
|
|
58
51
|
}
|
|
59
52
|
/**
|
|
60
53
|
* The canvas is positioned out of the height computation, so the container's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.js","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":";AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"StructureEditor.js","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditor.tsx"],"names":[],"mappings":";AAUA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAKtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;IACnC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,mBAAoB,CAAC,CAAC;IAClD,OAAO,EAAE,OAAO,EAAE,MAAM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
|
|
1
|
+
/**
|
|
2
|
+
* What the keyboard and the mouse do in the structure editor, shown in the
|
|
3
|
+
* editor's help popover, and usable by a site on a page of its own.
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactElement } from 'react';
|
|
6
|
+
import type { EditorGuideOptions } from '../core/editorGuide.ts';
|
|
7
|
+
/** What {@link StructureEditorHelp} is written for. */
|
|
8
|
+
export type StructureEditorHelpProps = EditorGuideOptions;
|
|
9
|
+
/**
|
|
10
|
+
* The guide to the structure editor: the keys that change the atom or bond
|
|
11
|
+
* under the pointer, the selection gestures, the stereo conventions, and links
|
|
12
|
+
* to the full documentation. Gestures that do nothing in the given editor are
|
|
13
|
+
* left out.
|
|
14
|
+
* @param props - See {@link StructureEditorHelpProps}.
|
|
15
|
+
* @returns The guide.
|
|
16
|
+
*/
|
|
17
|
+
export declare function StructureEditorHelp(props: StructureEditorHelpProps): ReactElement;
|
|
18
|
+
//# sourceMappingURL=StructureEditorHelp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructureEditorHelp.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/StructureEditorHelp.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAiB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAQhF,uDAAuD;AACvD,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,YAAY,CAwCd"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* What the keyboard and the mouse do in the structure editor, shown in the
|
|
4
|
+
* editor's help popover, and usable by a site on a page of its own.
|
|
5
|
+
*/
|
|
6
|
+
import { Classes } from '@blueprintjs/core';
|
|
7
|
+
import { TOKEN } from "../../tokens/core/familyTokens.js";
|
|
8
|
+
import { STRUCTURE_EDITOR_DOCS, editorGuideSections, } from "../core/editorGuide.js";
|
|
9
|
+
import { KeyCaps } from "./KeyCaps.js";
|
|
10
|
+
/**
|
|
11
|
+
* The guide to the structure editor: the keys that change the atom or bond
|
|
12
|
+
* under the pointer, the selection gestures, the stereo conventions, and links
|
|
13
|
+
* to the full documentation. Gestures that do nothing in the given editor are
|
|
14
|
+
* left out.
|
|
15
|
+
* @param props - See {@link StructureEditorHelpProps}.
|
|
16
|
+
* @returns The guide.
|
|
17
|
+
*/
|
|
18
|
+
export function StructureEditorHelp(props) {
|
|
19
|
+
const sections = editorGuideSections(props);
|
|
20
|
+
return (_jsxs("div", { style: PANEL_STYLE, "data-testid": "structure-editor-help", children: [_jsx("p", { className: Classes.TEXT_MUTED, style: PARAGRAPH_STYLE, children: "Hover a toolbar button to see what it does and its key." }), _jsx("div", { style: GRID_STYLE, children: sections.map((section) => (_jsxs("section", { style: ROW_STYLE, children: [_jsx("h4", { style: HEADING_STYLE, children: section.title }), section.gestures.map((gesture) => (_jsxs("div", { style: ROW_STYLE, children: [_jsx(GestureInput, { input: gesture.input }), _jsx("span", { children: gesture.action })] }, gestureKey(gesture)))), section.note === undefined ? null : (_jsx("p", { className: Classes.TEXT_MUTED, style: NOTE_STYLE, children: section.note }))] }, section.title))) }), _jsxs("p", { style: PARAGRAPH_STYLE, children: ["Learn more:", ' ', STRUCTURE_EDITOR_DOCS.map((link, index) => (_jsxs("span", { children: [index === 0 ? null : ' · ', _jsx("a", { href: link.url, target: "_blank", rel: "noopener noreferrer", children: link.title })] }, link.url)))] })] }));
|
|
21
|
+
}
|
|
22
|
+
function GestureInput(props) {
|
|
23
|
+
return (_jsx("span", { style: INPUT_STYLE, children: props.input.map((part) => typeof part === 'string' ? (_jsx("span", { children: part }, part)) : (_jsx(KeyCaps, { keys: [part.key] }, part.key))) }));
|
|
24
|
+
}
|
|
25
|
+
function gestureKey(gesture) {
|
|
26
|
+
const input = gesture.input
|
|
27
|
+
.map((part) => (typeof part === 'string' ? part : part.key))
|
|
28
|
+
.join(' ');
|
|
29
|
+
return `${input} ${gesture.action}`;
|
|
30
|
+
}
|
|
31
|
+
const PANEL_STYLE = {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flexDirection: 'column',
|
|
34
|
+
gap: 10,
|
|
35
|
+
width: 400,
|
|
36
|
+
maxHeight: 'min(70vh, 36rem)',
|
|
37
|
+
overflowY: 'auto',
|
|
38
|
+
padding: 12,
|
|
39
|
+
fontSize: 12,
|
|
40
|
+
};
|
|
41
|
+
const GRID_STYLE = {
|
|
42
|
+
display: 'grid',
|
|
43
|
+
gridTemplateColumns: 'max-content minmax(0, 1fr)',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
columnGap: 12,
|
|
46
|
+
rowGap: 6,
|
|
47
|
+
};
|
|
48
|
+
const ROW_STYLE = { display: 'contents' };
|
|
49
|
+
const HEADING_STYLE = {
|
|
50
|
+
gridColumn: '1 / -1',
|
|
51
|
+
margin: '8px 0 0',
|
|
52
|
+
paddingBottom: 3,
|
|
53
|
+
borderBottom: `1px solid ${TOKEN.border}`,
|
|
54
|
+
color: TOKEN.textMuted,
|
|
55
|
+
fontSize: 11,
|
|
56
|
+
fontWeight: 700,
|
|
57
|
+
letterSpacing: '0.04em',
|
|
58
|
+
textTransform: 'uppercase',
|
|
59
|
+
};
|
|
60
|
+
const INPUT_STYLE = {
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
gap: 4,
|
|
64
|
+
whiteSpace: 'nowrap',
|
|
65
|
+
};
|
|
66
|
+
const PARAGRAPH_STYLE = { margin: 0, lineHeight: 1.45 };
|
|
67
|
+
const NOTE_STYLE = { ...PARAGRAPH_STYLE, gridColumn: '1 / -1' };
|
|
68
|
+
//# sourceMappingURL=StructureEditorHelp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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E,GAAG;IACV,SAAS,EAAE,kBAAkB;IAC7B,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,MAAM;IACf,mBAAmB,EAAE,4BAA4B;IACjD,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,EAAE;IACb,MAAM,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,SAAS,GAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAEzD,MAAM,aAAa,GAAkB;IACnC,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,aAAa,KAAK,CAAC,MAAM,EAAE;IACzC,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,GAAG;IACf,aAAa,EAAE,QAAQ;IACvB,aAAa,EAAE,WAAW;CAC3B,CAAC;AAEF,MAAM,WAAW,GAAkB;IACjC,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,MAAM,eAAe,GAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAEvE,MAAM,UAAU,GAAkB,EAAE,GAAG,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactElement, RefObject } from 'react';
|
|
2
|
+
import type { StructureEditorMode } from './editorChange.ts';
|
|
3
|
+
/** What {@link ToolbarTooltip} needs. */
|
|
4
|
+
export interface ToolbarTooltipProps {
|
|
5
|
+
/** The positioned element wrapping the editor. */
|
|
6
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
7
|
+
/** Which editor the toolbar belongs to, since some buttons are greyed. */
|
|
8
|
+
mode: StructureEditorMode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The name, key and purpose of the toolbar button under the pointer.
|
|
12
|
+
*
|
|
13
|
+
* The toolbar is a canvas, so the tooltip is anchored to an invisible box laid
|
|
14
|
+
* over the button rather than to the button itself; the box lets the pointer
|
|
15
|
+
* through, so the editor still sees every hover and click.
|
|
16
|
+
* @param props - See {@link ToolbarTooltipProps}.
|
|
17
|
+
* @returns The tooltip, or nothing before a button has been hovered.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ToolbarTooltip(props: ToolbarTooltipProps): ReactElement | null;
|
|
20
|
+
//# sourceMappingURL=ToolbarTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarTooltip.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/ToolbarTooltip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,mBAAmB,GACzB,YAAY,GAAG,IAAI,CAiBrB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Classes, Tooltip } from '@blueprintjs/core';
|
|
3
|
+
import { EDITOR_TOOLBAR_BUTTONS, isEditorToolbarButtonAvailable, } from "../core/editorToolbar.js";
|
|
4
|
+
import { KeyCaps } from "./KeyCaps.js";
|
|
5
|
+
import { useToolbarHover } from "./useToolbarHover.js";
|
|
6
|
+
/**
|
|
7
|
+
* The name, key and purpose of the toolbar button under the pointer.
|
|
8
|
+
*
|
|
9
|
+
* The toolbar is a canvas, so the tooltip is anchored to an invisible box laid
|
|
10
|
+
* over the button rather than to the button itself; the box lets the pointer
|
|
11
|
+
* through, so the editor still sees every hover and click.
|
|
12
|
+
* @param props - See {@link ToolbarTooltipProps}.
|
|
13
|
+
* @returns The tooltip, or nothing before a button has been hovered.
|
|
14
|
+
*/
|
|
15
|
+
export function ToolbarTooltip(props) {
|
|
16
|
+
const { containerRef, mode } = props;
|
|
17
|
+
const hover = useToolbarHover(containerRef);
|
|
18
|
+
if (hover === null)
|
|
19
|
+
return null;
|
|
20
|
+
const button = EDITOR_TOOLBAR_BUTTONS[hover.button];
|
|
21
|
+
if (button === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
return (_jsx(Tooltip, { isOpen: hover.open, placement: "right", content: _jsx(ButtonTip, { button: button, mode: mode }), renderTarget: ({ ref }) => (_jsx("span", { ref: ref, "aria-hidden": true, style: { ...TARGET_STYLE, ...hover.box } })) }));
|
|
24
|
+
}
|
|
25
|
+
function ButtonTip(props) {
|
|
26
|
+
const { button, mode } = props;
|
|
27
|
+
const available = isEditorToolbarButtonAvailable(button, mode);
|
|
28
|
+
return (_jsxs("div", { style: TIP_STYLE, "data-testid": "structure-editor-tooltip", children: [_jsxs("div", { style: HEAD_STYLE, children: [_jsx("strong", { children: button.name }), button.keys === undefined ? null : _jsx(KeyCaps, { keys: button.keys })] }), _jsx("div", { children: button.description }), available ? null : (_jsx("div", { className: Classes.TEXT_MUTED, children: button.availability === 'reaction'
|
|
29
|
+
? 'Only when drawing a reaction.'
|
|
30
|
+
: 'Not available in this editor.' }))] }));
|
|
31
|
+
}
|
|
32
|
+
const TARGET_STYLE = {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
};
|
|
36
|
+
const TIP_STYLE = {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
gap: 4,
|
|
40
|
+
maxWidth: 260,
|
|
41
|
+
lineHeight: 1.4,
|
|
42
|
+
};
|
|
43
|
+
const HEAD_STYLE = {
|
|
44
|
+
display: 'flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
gap: 12,
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=ToolbarTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarTooltip.js","sourceRoot":"","sources":["../../../src/structure/ui/ToolbarTooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAUvD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,KAA0B;IAE1B,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,KAAK,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEtC,OAAO,CACL,KAAC,OAAO,IACN,MAAM,EAAE,KAAK,CAAC,IAAI,EAClB,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,KAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,EAClD,YAAY,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CACzB,eAAM,GAAG,EAA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**
|
|
2
|
+
* What the structure editor reports after an edit.
|
|
3
|
+
*
|
|
4
|
+
* Only types are imported from react-ocl and openchemlib, so this module can be
|
|
5
|
+
* reached from the `react-cheminfo/structure` barrel without pulling either in.
|
|
6
|
+
*/
|
|
7
|
+
import type { Molecule } from 'openchemlib';
|
|
8
|
+
import type { CanvasEditorOnChangeMolecule, CanvasEditorOnChangeReaction } from 'react-ocl';
|
|
9
|
+
/** What the editor draws: one structure, or a reaction with its arrow. */
|
|
10
|
+
export type StructureEditorMode = 'molecule' | 'reaction';
|
|
11
|
+
/** The notations every change carries, whichever the editor. */
|
|
12
|
+
interface StructureEditorNotations {
|
|
13
|
+
/**
|
|
14
|
+
* The idCode, with the coordinates the editor laid out written after a
|
|
15
|
+
* space. `splitIdCode` takes the two apart.
|
|
16
|
+
*/
|
|
17
|
+
idCode: string;
|
|
18
|
+
/** The V2000 molfile of a molecule, or the RXN file of a reaction. */
|
|
19
|
+
molfile: string;
|
|
20
|
+
/** The SMILES of a molecule, or the reaction SMILES. */
|
|
21
|
+
smiles: string;
|
|
22
|
+
}
|
|
23
|
+
/** What a molecule editor holds at the moment it changed. */
|
|
24
|
+
export interface StructureEditorMoleculeChange extends StructureEditorNotations {
|
|
25
|
+
mode: 'molecule';
|
|
26
|
+
/**
|
|
27
|
+
* A copy of the drawn molecule, with its coordinates. It is taken when the
|
|
28
|
+
* edit happens, so it still describes that edit when it arrives after the
|
|
29
|
+
* debounce, and the caller may modify it without touching the canvas.
|
|
30
|
+
*/
|
|
31
|
+
molecule: Molecule;
|
|
32
|
+
}
|
|
33
|
+
/** What a reaction editor holds at the moment it changed. */
|
|
34
|
+
export interface StructureEditorReactionChange extends StructureEditorNotations {
|
|
35
|
+
mode: 'reaction';
|
|
36
|
+
}
|
|
37
|
+
/** Everything the editor holds at the moment it changed. */
|
|
38
|
+
export type StructureEditorChange = StructureEditorMoleculeChange | StructureEditorReactionChange;
|
|
39
|
+
/**
|
|
40
|
+
* Read a molecule editor's event out, while it still describes the edit.
|
|
41
|
+
* @param event - The event react-ocl passes to its callback.
|
|
42
|
+
* @returns The change, independent of the editor from then on.
|
|
43
|
+
*/
|
|
44
|
+
export declare function moleculeChange(event: CanvasEditorOnChangeMolecule): StructureEditorMoleculeChange;
|
|
45
|
+
/**
|
|
46
|
+
* Read a reaction editor's event out, while it still describes the edit.
|
|
47
|
+
* @param event - The event react-ocl passes to its callback.
|
|
48
|
+
* @returns The change, independent of the editor from then on.
|
|
49
|
+
*/
|
|
50
|
+
export declare function reactionChange(event: CanvasEditorOnChangeReaction): StructureEditorReactionChange;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=editorChange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorChange.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/editorChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,WAAW,CAAC;AAEnB,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1D,gEAAgE;AAChE,UAAU,wBAAwB;IAChC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,6DAA6D;AAC7D,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB;IAC7E,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,6DAA6D;AAC7D,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB;IAC7E,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,4DAA4D;AAC5D,MAAM,MAAM,qBAAqB,GAC/B,6BAA6B,GAAG,6BAA6B,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,4BAA4B,GAClC,6BAA6B,CAQ/B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,4BAA4B,GAClC,6BAA6B,CAO/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the structure editor reports after an edit.
|
|
3
|
+
*
|
|
4
|
+
* Only types are imported from react-ocl and openchemlib, so this module can be
|
|
5
|
+
* reached from the `react-cheminfo/structure` barrel without pulling either in.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Read a molecule editor's event out, while it still describes the edit.
|
|
9
|
+
* @param event - The event react-ocl passes to its callback.
|
|
10
|
+
* @returns The change, independent of the editor from then on.
|
|
11
|
+
*/
|
|
12
|
+
export function moleculeChange(event) {
|
|
13
|
+
return {
|
|
14
|
+
mode: 'molecule',
|
|
15
|
+
idCode: event.getIdcode(),
|
|
16
|
+
molfile: event.getMolfile(),
|
|
17
|
+
smiles: event.getSmiles(),
|
|
18
|
+
molecule: event.getMolecule(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Read a reaction editor's event out, while it still describes the edit.
|
|
23
|
+
* @param event - The event react-ocl passes to its callback.
|
|
24
|
+
* @returns The change, independent of the editor from then on.
|
|
25
|
+
*/
|
|
26
|
+
export function reactionChange(event) {
|
|
27
|
+
return {
|
|
28
|
+
mode: 'reaction',
|
|
29
|
+
idCode: event.getIdcode(),
|
|
30
|
+
molfile: event.getRxn(),
|
|
31
|
+
smiles: event.getSmiles(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=editorChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorChange.js","sourceRoot":"","sources":["../../../src/structure/ui/editorChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4CH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAmC;IAEnC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;QACzB,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE;QAC3B,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;QACzB,QAAQ,EAAE,KAAK,CAAC,WAAW,EAAE;KAC9B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAmC;IAEnC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;QACzB,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE;QACvB,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;KAC1B,CAAC;AACJ,CAAC"}
|