react-cheminfo 0.17.0 → 0.19.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/about/core/about.d.ts +9 -0
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +1 -0
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/core/index.d.ts +1 -0
- package/lib/about/core/index.d.ts.map +1 -1
- package/lib/about/core/index.js +1 -0
- package/lib/about/core/index.js.map +1 -1
- package/lib/about/core/repository.d.ts +14 -0
- package/lib/about/core/repository.d.ts.map +1 -0
- package/lib/about/core/repository.js +21 -0
- package/lib/about/core/repository.js.map +1 -0
- package/lib/about/ui/AboutBuild.d.ts +5 -4
- package/lib/about/ui/AboutBuild.d.ts.map +1 -1
- package/lib/about/ui/AboutBuild.js +10 -10
- package/lib/about/ui/AboutBuild.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +7 -8
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutVersion.d.ts +25 -0
- package/lib/about/ui/AboutVersion.d.ts.map +1 -0
- package/lib/about/ui/AboutVersion.js +31 -0
- package/lib/about/ui/AboutVersion.js.map +1 -0
- package/lib/about/ui/index.d.ts +2 -0
- package/lib/about/ui/index.d.ts.map +1 -1
- package/lib/about/ui/index.js +1 -0
- package/lib/about/ui/index.js.map +1 -1
- package/lib/build/core/buildInfo.d.ts +16 -0
- package/lib/build/core/buildInfo.d.ts.map +1 -1
- package/lib/build/core/buildInfo.js +21 -0
- package/lib/build/core/buildInfo.js.map +1 -1
- package/lib/build/core/index.d.ts +1 -1
- package/lib/build/core/index.d.ts.map +1 -1
- package/lib/build/core/index.js +1 -1
- package/lib/build/core/index.js.map +1 -1
- package/lib/build/vite/buildInfo.d.ts.map +1 -1
- package/lib/build/vite/buildInfo.js +2 -2
- package/lib/build/vite/buildInfo.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +12 -0
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +8 -0
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/molecule3d/core/camera.d.ts +89 -0
- package/lib/molecule3d/core/camera.d.ts.map +1 -0
- package/lib/molecule3d/core/camera.js +172 -0
- package/lib/molecule3d/core/camera.js.map +1 -0
- package/lib/molecule3d/core/index.d.ts +2 -0
- package/lib/molecule3d/core/index.d.ts.map +1 -1
- package/lib/molecule3d/core/index.js +1 -0
- package/lib/molecule3d/core/index.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +14 -37
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molecule3d/ui/camera.d.ts +35 -2
- package/lib/molecule3d/ui/camera.d.ts.map +1 -1
- package/lib/molecule3d/ui/camera.js +113 -4
- package/lib/molecule3d/ui/camera.js.map +1 -1
- package/lib/molecule3d/ui/captureScene.d.ts +14 -0
- package/lib/molecule3d/ui/captureScene.d.ts.map +1 -0
- package/lib/molecule3d/ui/captureScene.js +24 -0
- package/lib/molecule3d/ui/captureScene.js.map +1 -0
- package/lib/molecule3d/ui/createViewer.d.ts +18 -0
- package/lib/molecule3d/ui/createViewer.d.ts.map +1 -0
- package/lib/molecule3d/ui/createViewer.js +19 -0
- package/lib/molecule3d/ui/createViewer.js.map +1 -0
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +21 -0
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
- package/lib/molecule3d/ui/useMoleculeScene.d.ts +47 -0
- package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -0
- package/lib/molecule3d/ui/useMoleculeScene.js +82 -0
- package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -0
- package/lib/molecule3d/ui/useSharedCamera.d.ts +52 -0
- package/lib/molecule3d/ui/useSharedCamera.d.ts.map +1 -0
- package/lib/molecule3d/ui/useSharedCamera.js +82 -0
- package/lib/molecule3d/ui/useSharedCamera.js.map +1 -0
- package/lib/molecule3d/ui/viewer.d.ts +21 -15
- package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
- package/lib/molecule3d/ui/viewer.js +41 -47
- package/lib/molecule3d/ui/viewer.js.map +1 -1
- package/lib/molecule3d/ui/viewerSpec.d.ts +17 -0
- package/lib/molecule3d/ui/viewerSpec.d.ts.map +1 -0
- package/lib/molecule3d/ui/viewerSpec.js +34 -0
- package/lib/molecule3d/ui/viewerSpec.js.map +1 -0
- 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/about/core/about.ts +11 -0
- package/src/about/core/index.ts +1 -0
- package/src/about/core/repository.ts +22 -0
- package/src/about/ui/AboutBuild.tsx +13 -20
- package/src/about/ui/AboutPage.tsx +30 -22
- package/src/about/ui/AboutVersion.tsx +67 -0
- package/src/about/ui/index.ts +2 -0
- package/src/build/core/buildInfo.ts +24 -0
- package/src/build/core/index.ts +6 -1
- package/src/build/vite/buildInfo.ts +2 -2
- package/src/ecosystem/core/sites.ts +12 -0
- package/src/ecosystem/core/types.ts +8 -0
- package/src/molecule3d/core/camera.ts +212 -0
- package/src/molecule3d/core/index.ts +14 -0
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +14 -43
- package/src/molecule3d/ui/camera.ts +128 -7
- package/src/molecule3d/ui/captureScene.ts +31 -0
- package/src/molecule3d/ui/createViewer.ts +24 -0
- package/src/molecule3d/ui/moleculeViewer3DProps.ts +21 -0
- package/src/molecule3d/ui/useMoleculeScene.ts +141 -0
- package/src/molecule3d/ui/useSharedCamera.ts +121 -0
- package/src/molecule3d/ui/viewer.ts +45 -50
- package/src/molecule3d/ui/viewerSpec.ts +38 -0
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAmB1D,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,qBAAa,gBAAgB;;IAK3B,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;;;OAIG;gBACS,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,uBAA4B;IAczE;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3E;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;;OAIG;IACH,WAAW,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;OAIG;IACH,gBAAgB,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI1D;;;;;OAKG;IACH,WAAW,CACT,oBAAoB,SAA0B,EAC9C,SAAS,UAAQ,GAChB,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,oBAAoB,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5E;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAa5E;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE,kEAAkE;IAClE,YAAY,IAAI,IAAI;IAKpB,sEAAsE;IACtE,OAAO,IAAI,IAAI;CAwBhB"}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lifecycle of one molstar molecule viewer
|
|
2
|
+
* Lifecycle of one molstar molecule viewer: `createMolecule3DViewer` builds
|
|
3
|
+
* one, and every operation a component performs on it is a method here.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* always be called; the work is queued behind `ready`.
|
|
9
|
-
*
|
|
10
|
-
* molstar's own UI is not mounted: every control is the component's.
|
|
5
|
+
* The constructor returns before the canvas exists — see `createViewer.ts` —
|
|
6
|
+
* so every method queues its work behind `ready` and resolves to nothing once
|
|
7
|
+
* the viewer has been disposed. molstar's own UI is not mounted: every control
|
|
8
|
+
* is the component's.
|
|
11
9
|
*/
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import { DefaultPluginSpec as defaultPluginSpec } from 'molstar/lib/mol-plugin/spec.js';
|
|
15
|
-
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
16
|
-
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, resetCamera, setSpin, } from "./camera.js";
|
|
10
|
+
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, applyCamera, resetCamera, setSpin, watchCamera, } from "./camera.js";
|
|
11
|
+
import { captureScene } from "./captureScene.js";
|
|
17
12
|
import { MeasurementPicker, clearMeasurements, renderMeasurements, } from "./measurements.js";
|
|
18
13
|
import { clearMolecule, renderMolecule } from "./renderMolecule.js";
|
|
19
14
|
import { clearSurface, renderSurface } from "./renderSurface.js";
|
|
20
|
-
|
|
21
|
-
* Create a viewer inside `container` and start initialising it.
|
|
22
|
-
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
23
|
-
* @param options - See {@link Molecule3DViewerOptions}.
|
|
24
|
-
* @returns A handle that is safe to dispose immediately.
|
|
25
|
-
*/
|
|
26
|
-
export function createMolecule3DViewer(container, options = {}) {
|
|
27
|
-
return new Molecule3DViewer(container, options);
|
|
28
|
-
}
|
|
15
|
+
import { mountMolecule3DPlugin } from "./viewerSpec.js";
|
|
29
16
|
/**
|
|
30
17
|
* One molstar canvas, and every operation the component performs on it. Every
|
|
31
18
|
* method resolves to nothing once `dispose` has been called.
|
|
@@ -44,18 +31,7 @@ export class Molecule3DViewer {
|
|
|
44
31
|
constructor(container, options = {}) {
|
|
45
32
|
const { background = '#ffffff', // tokens-ok: a WebGL clear colour
|
|
46
33
|
onMeasure = ignore, } = options;
|
|
47
|
-
|
|
48
|
-
this.#model = new PluginViewModel({
|
|
49
|
-
spec: {
|
|
50
|
-
...spec,
|
|
51
|
-
canvas3d: {
|
|
52
|
-
...spec.canvas3d,
|
|
53
|
-
renderer: { backgroundColor: Color.fromHexStyle(background) },
|
|
54
|
-
camera: { helper: { axes: { name: 'off', params: {} } } },
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
this.#model.mount(container);
|
|
34
|
+
this.#model = mountMolecule3DPlugin(container, background);
|
|
59
35
|
this.ready = this.#model.initialized;
|
|
60
36
|
// Registered before any `#run`, so the picker exists by the time one runs.
|
|
61
37
|
this.ready.then(() => {
|
|
@@ -128,19 +104,7 @@ export class Molecule3DViewer {
|
|
|
128
104
|
* @throws {Error} When the plugin has no screenshot helper.
|
|
129
105
|
*/
|
|
130
106
|
captureImage(size) {
|
|
131
|
-
return this.#run(
|
|
132
|
-
const helper = plugin.helpers.viewportScreenshot;
|
|
133
|
-
if (helper === undefined) {
|
|
134
|
-
throw new Error('This viewer cannot take a picture of its scene.');
|
|
135
|
-
}
|
|
136
|
-
helper.behaviors.values.next({
|
|
137
|
-
...helper.values,
|
|
138
|
-
resolution: { name: 'custom', params: size },
|
|
139
|
-
axes: { name: 'off', params: {} },
|
|
140
|
-
transparent: false,
|
|
141
|
-
});
|
|
142
|
-
return helper.getImageDataUri();
|
|
143
|
-
});
|
|
107
|
+
return this.#run((plugin) => captureScene(plugin, size));
|
|
144
108
|
}
|
|
145
109
|
/**
|
|
146
110
|
* Frame everything on screen.
|
|
@@ -153,6 +117,36 @@ export class Molecule3DViewer {
|
|
|
153
117
|
resetCamera(plugin, durationMilliseconds, fromFront);
|
|
154
118
|
});
|
|
155
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Put the camera where a link says it stood.
|
|
122
|
+
* @param camera - Where to stand.
|
|
123
|
+
* @param durationMilliseconds - Transition length; 0 jumps.
|
|
124
|
+
* @returns Nothing; resolves once the move has been ordered.
|
|
125
|
+
*/
|
|
126
|
+
setCamera(camera, durationMilliseconds = 0) {
|
|
127
|
+
return this.#run((plugin) => {
|
|
128
|
+
applyCamera(plugin, camera, durationMilliseconds);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Follow the camera, however it moves.
|
|
133
|
+
* @param listener - Called after every move.
|
|
134
|
+
* @returns A function that stops calling the listener; safe to call before
|
|
135
|
+
* the canvas exists.
|
|
136
|
+
*/
|
|
137
|
+
watchCamera(listener) {
|
|
138
|
+
let stop = null;
|
|
139
|
+
let cancelled = false;
|
|
140
|
+
void this.#run((plugin) => {
|
|
141
|
+
if (!cancelled)
|
|
142
|
+
stop = watchCamera(plugin, listener);
|
|
143
|
+
});
|
|
144
|
+
return () => {
|
|
145
|
+
cancelled = true;
|
|
146
|
+
stop?.();
|
|
147
|
+
stop = null;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
156
150
|
/**
|
|
157
151
|
* Turn the automatic spin on or off.
|
|
158
152
|
* @param spinning - Whether the scene should keep turning.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAOxD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAkB;IACjC,OAAO,CAAgC;IACvC,SAAS,GAAG,KAAK,CAAC;IAElB,0EAA0E;IACjE,KAAK,CAAgB;IAE9B;;;;OAIG;IACH,YAAY,SAAsB,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,MAAM,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,SAAS;gBAAE,OAAO,SAAS,CAAC;YACrC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,SAAS,MAAM;IACb,iBAAiB;AACnB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the molecule viewer configures molstar: the plugin spec it mounts with.
|
|
3
|
+
*
|
|
4
|
+
* molstar's own UI is not mounted — every control is the component's — and the
|
|
5
|
+
* axes helper is off, since a molecule is read from its own shape rather than
|
|
6
|
+
* from the world axes.
|
|
7
|
+
*/
|
|
8
|
+
import { PluginViewModel } from 'molstar/lib/extensions/plugin/view-model.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a view model for one canvas and mount it.
|
|
11
|
+
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
12
|
+
* @param background - Scene background as `#rrggbb`; a WebGL clear colour, so
|
|
13
|
+
* it cannot be a CSS custom property.
|
|
14
|
+
* @returns The mounted view model, still initialising.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountMolecule3DPlugin(container: HTMLElement, background: string): PluginViewModel;
|
|
17
|
+
//# sourceMappingURL=viewerSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerSpec.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewerSpec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK9E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,WAAW,EACtB,UAAU,EAAE,MAAM,GACjB,eAAe,CAcjB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the molecule viewer configures molstar: the plugin spec it mounts with.
|
|
3
|
+
*
|
|
4
|
+
* molstar's own UI is not mounted — every control is the component's — and the
|
|
5
|
+
* axes helper is off, since a molecule is read from its own shape rather than
|
|
6
|
+
* from the world axes.
|
|
7
|
+
*/
|
|
8
|
+
import { PluginViewModel } from 'molstar/lib/extensions/plugin/view-model.js';
|
|
9
|
+
// Lowercased on import: it is a factory, not a constructor.
|
|
10
|
+
import { DefaultPluginSpec as defaultPluginSpec } from 'molstar/lib/mol-plugin/spec.js';
|
|
11
|
+
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build a view model for one canvas and mount it.
|
|
14
|
+
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
15
|
+
* @param background - Scene background as `#rrggbb`; a WebGL clear colour, so
|
|
16
|
+
* it cannot be a CSS custom property.
|
|
17
|
+
* @returns The mounted view model, still initialising.
|
|
18
|
+
*/
|
|
19
|
+
export function mountMolecule3DPlugin(container, background) {
|
|
20
|
+
const spec = defaultPluginSpec();
|
|
21
|
+
const model = new PluginViewModel({
|
|
22
|
+
spec: {
|
|
23
|
+
...spec,
|
|
24
|
+
canvas3d: {
|
|
25
|
+
...spec.canvas3d,
|
|
26
|
+
renderer: { backgroundColor: Color.fromHexStyle(background) },
|
|
27
|
+
camera: { helper: { axes: { name: 'off', params: {} } } },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
model.mount(container);
|
|
32
|
+
return model;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=viewerSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerSpec.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewerSpec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAsB,EACtB,UAAkB;IAElB,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC;QAChC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE;gBACR,GAAG,IAAI,CAAC,QAAQ;gBAChB,QAAQ,EAAE,EAAE,eAAe,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;gBAC7D,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE;aAC1D;SACF;KACF,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the keyboard and the mouse do in the openchemlib canvas editor, beyond
|
|
3
|
+
* what its toolbar shows: the keys that change the atom or the bond under the
|
|
4
|
+
* pointer, the selection gestures and the stereo conventions.
|
|
5
|
+
*/
|
|
6
|
+
/** A key, drawn as a key cap. `Mod` is ⌘ on a Mac and Ctrl elsewhere. */
|
|
7
|
+
export interface EditorGuideKey {
|
|
8
|
+
key: string;
|
|
9
|
+
}
|
|
10
|
+
/** Which editors a gesture applies to. */
|
|
11
|
+
export type EditorGuideScope = 'fragment' | 'molecule' | 'reaction';
|
|
12
|
+
/** One gesture and what it does. */
|
|
13
|
+
export interface EditorGesture {
|
|
14
|
+
/** Keys, and plain text for the mouse part; unique within one gesture. */
|
|
15
|
+
input: ReadonlyArray<string | EditorGuideKey>;
|
|
16
|
+
action: string;
|
|
17
|
+
/**
|
|
18
|
+
* The only editor the gesture works in.
|
|
19
|
+
* @default undefined — every editor
|
|
20
|
+
*/
|
|
21
|
+
only?: EditorGuideScope;
|
|
22
|
+
}
|
|
23
|
+
/** Gestures that share a context, such as the pointer resting on an atom. */
|
|
24
|
+
export interface EditorGuideSection {
|
|
25
|
+
title: string;
|
|
26
|
+
gestures: readonly EditorGesture[];
|
|
27
|
+
/**
|
|
28
|
+
* A sentence read after the gestures.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
note?: string;
|
|
32
|
+
}
|
|
33
|
+
/** A page of the full documentation. */
|
|
34
|
+
export interface EditorGuideLink {
|
|
35
|
+
title: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}
|
|
38
|
+
/** The sections, in the order the guide lists them. */
|
|
39
|
+
export declare const STRUCTURE_EDITOR_GUIDE: readonly EditorGuideSection[];
|
|
40
|
+
/** The documentation this guide summarises. */
|
|
41
|
+
export declare const STRUCTURE_EDITOR_DOCS: readonly EditorGuideLink[];
|
|
42
|
+
/** The editor a guide is written for. */
|
|
43
|
+
export interface EditorGuideOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Whether the editor draws one structure or a reaction.
|
|
46
|
+
* @default 'molecule'
|
|
47
|
+
*/
|
|
48
|
+
mode?: 'molecule' | 'reaction';
|
|
49
|
+
/**
|
|
50
|
+
* Whether the editor draws a query fragment.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
fragment?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The guide for one editor: gestures that do nothing there are left out, and so
|
|
57
|
+
* is a section left with nothing to say.
|
|
58
|
+
* @param options - The editor the guide is for.
|
|
59
|
+
* @returns The sections to show.
|
|
60
|
+
*/
|
|
61
|
+
export declare function editorGuideSections(options?: EditorGuideOptions): EditorGuideSection[];
|
|
62
|
+
/**
|
|
63
|
+
* The text of a key cap.
|
|
64
|
+
* @param key - The key, `Mod` standing for the platform's shortcut modifier.
|
|
65
|
+
* @param isMac - Whether the page runs on a Mac.
|
|
66
|
+
* @returns What the cap shows.
|
|
67
|
+
*/
|
|
68
|
+
export declare function editorKeyLabel(key: string, isMac: boolean): string;
|
|
69
|
+
//# sourceMappingURL=editorGuide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorGuide.d.ts","sourceRoot":"","sources":["../../../src/structure/core/editorGuide.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpE,oCAAoC;AACpC,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,EAAE,SAAS,kBAAkB,EA2G/D,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,EAAE,SAAS,eAAe,EAU3D,CAAC;AAEF,yCAAyC;AACzC,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,kBAAuB,GAC/B,kBAAkB,EAAE,CAWtB;AAYD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAGlE"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the keyboard and the mouse do in the openchemlib canvas editor, beyond
|
|
3
|
+
* what its toolbar shows: the keys that change the atom or the bond under the
|
|
4
|
+
* pointer, the selection gestures and the stereo conventions.
|
|
5
|
+
*/
|
|
6
|
+
/** The sections, in the order the guide lists them. */
|
|
7
|
+
export const STRUCTURE_EDITOR_GUIDE = [
|
|
8
|
+
{
|
|
9
|
+
title: 'Pointer on an atom',
|
|
10
|
+
gestures: [
|
|
11
|
+
{ input: ['Type', { key: 'n' }, { key: 'a' }], action: 'Make it Na' },
|
|
12
|
+
{
|
|
13
|
+
input: ['Type', { key: 'p' }, { key: 'h' }],
|
|
14
|
+
action: 'Attach a phenyl; Me, Et, Boc, TMS… work too',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
input: [{ key: 'Enter' }, 'or', { key: 'Esc' }],
|
|
18
|
+
action: 'Apply or forget what was typed',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
input: [{ key: '1' }, '…', { key: '9' }],
|
|
22
|
+
action: 'Attach a chain of that many carbons',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
input: [{ key: '+' }, 'or', { key: '-' }],
|
|
26
|
+
action: 'Raise or lower the charge',
|
|
27
|
+
},
|
|
28
|
+
{ input: [{ key: '.' }], action: 'Add or remove a radical' },
|
|
29
|
+
{ input: [{ key: ':' }], action: 'Make it a triplet, then a singlet' },
|
|
30
|
+
{ input: [{ key: '?' }], action: 'Make it a connection point' },
|
|
31
|
+
{
|
|
32
|
+
input: [{ key: 'q' }],
|
|
33
|
+
action: 'Edit its query features',
|
|
34
|
+
only: 'fragment',
|
|
35
|
+
},
|
|
36
|
+
{ input: [{ key: 'x' }], action: 'Accept any halogen', only: 'fragment' },
|
|
37
|
+
{ input: [{ key: 'Delete' }], action: 'Delete it' },
|
|
38
|
+
],
|
|
39
|
+
note: 'What is typed shows black for an element, blue for a group, grey while incomplete and red when unknown.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Pointer on a bond',
|
|
43
|
+
gestures: [
|
|
44
|
+
{
|
|
45
|
+
input: [{ key: '1' }, { key: '2' }, { key: '3' }],
|
|
46
|
+
action: 'Single, double or triple',
|
|
47
|
+
},
|
|
48
|
+
{ input: [{ key: '0' }], action: 'Zero-order (metal–ligand) bond' },
|
|
49
|
+
{
|
|
50
|
+
input: [{ key: 'u' }, 'or', { key: 'd' }],
|
|
51
|
+
action: 'Up or down stereo bond',
|
|
52
|
+
},
|
|
53
|
+
{ input: [{ key: 'c' }], action: 'Double bond of unknown geometry' },
|
|
54
|
+
{ input: [{ key: 'v' }], action: 'Fuse a 3-membered ring' },
|
|
55
|
+
{
|
|
56
|
+
input: [{ key: '4' }, '…', { key: '7' }],
|
|
57
|
+
action: 'Fuse a ring of that size',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
input: [{ key: 'a' }, 'or', { key: 'b' }],
|
|
61
|
+
action: 'Fuse a benzene ring',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
input: [{ key: 'q' }],
|
|
65
|
+
action: 'Edit its query features',
|
|
66
|
+
only: 'fragment',
|
|
67
|
+
},
|
|
68
|
+
{ input: [{ key: 'Delete' }], action: 'Delete it' },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: 'Anywhere',
|
|
73
|
+
gestures: [
|
|
74
|
+
{ input: [{ key: 'Mod' }, { key: 'Z' }], action: 'Undo' },
|
|
75
|
+
{ input: [{ key: 'Mod' }, { key: 'C' }], action: 'Copy the structure' },
|
|
76
|
+
{
|
|
77
|
+
input: [{ key: 'Mod' }, { key: 'V' }],
|
|
78
|
+
action: 'Paste a molfile, a SMILES or an idCode',
|
|
79
|
+
},
|
|
80
|
+
{ input: [{ key: 'Delete' }], action: 'Delete the selection' },
|
|
81
|
+
{
|
|
82
|
+
input: [{ key: 'h' }, 'or', { key: 'v' }],
|
|
83
|
+
action: 'Flip horizontally or vertically',
|
|
84
|
+
only: 'molecule',
|
|
85
|
+
},
|
|
86
|
+
{ input: [{ key: 'F1' }], action: 'Open this guide' },
|
|
87
|
+
],
|
|
88
|
+
note: 'Keys act once the drawing has been clicked. On empty canvas, a key picks the tool whose tooltip shows it.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: 'Selecting',
|
|
92
|
+
gestures: [
|
|
93
|
+
{ input: ['Drag'], action: 'Select what the lasso encloses' },
|
|
94
|
+
{ input: [{ key: 'Alt' }, '+ drag'], action: 'Select a rectangle' },
|
|
95
|
+
{ input: [{ key: 'Shift' }, '+ drag'], action: 'Add to the selection' },
|
|
96
|
+
{ input: ['Drag the selection'], action: 'Move it' },
|
|
97
|
+
{
|
|
98
|
+
input: [{ key: 'Shift' }, '+ drag the selection'],
|
|
99
|
+
action: 'Copy it',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
input: ['Double-click'],
|
|
103
|
+
action: 'Edit the query features of an atom, a bond or the selection',
|
|
104
|
+
only: 'fragment',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
note: 'These need the Select tool, which Space picks.',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: 'Stereochemistry',
|
|
111
|
+
gestures: [],
|
|
112
|
+
note: 'Pink bonds flag a stereocentre with too little or too much information. Draw an up or down bond with its narrow end on the centre, then use the enhanced stereo tool to say whether the drawing is this enantiomer (abs), both of them (&) or one of the two (or).',
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
/** The documentation this guide summarises. */
|
|
116
|
+
export const STRUCTURE_EDITOR_DOCS = [
|
|
117
|
+
{ title: 'Tools and keys', url: 'https://docs.nmrium.org/help/ocl/' },
|
|
118
|
+
{
|
|
119
|
+
title: 'Atom properties',
|
|
120
|
+
url: 'https://docs.nmrium.org/chemical_structure/ocl/atom-properties/',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
title: 'Stereochemistry',
|
|
124
|
+
url: 'https://docs.nmrium.org/ocl/stereochemistry/',
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* The guide for one editor: gestures that do nothing there are left out, and so
|
|
129
|
+
* is a section left with nothing to say.
|
|
130
|
+
* @param options - The editor the guide is for.
|
|
131
|
+
* @returns The sections to show.
|
|
132
|
+
*/
|
|
133
|
+
export function editorGuideSections(options = {}) {
|
|
134
|
+
const { mode = 'molecule', fragment = false } = options;
|
|
135
|
+
const sections = [];
|
|
136
|
+
for (const section of STRUCTURE_EDITOR_GUIDE) {
|
|
137
|
+
const gestures = section.gestures.filter(({ only }) => appliesTo(only, mode, fragment));
|
|
138
|
+
if (gestures.length === 0 && section.note === undefined)
|
|
139
|
+
continue;
|
|
140
|
+
sections.push({ ...section, gestures });
|
|
141
|
+
}
|
|
142
|
+
return sections;
|
|
143
|
+
}
|
|
144
|
+
function appliesTo(only, mode, fragment) {
|
|
145
|
+
if (only === undefined)
|
|
146
|
+
return true;
|
|
147
|
+
if (only === 'fragment')
|
|
148
|
+
return fragment;
|
|
149
|
+
return only === mode;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The text of a key cap.
|
|
153
|
+
* @param key - The key, `Mod` standing for the platform's shortcut modifier.
|
|
154
|
+
* @param isMac - Whether the page runs on a Mac.
|
|
155
|
+
* @returns What the cap shows.
|
|
156
|
+
*/
|
|
157
|
+
export function editorKeyLabel(key, isMac) {
|
|
158
|
+
if (key !== 'Mod')
|
|
159
|
+
return key;
|
|
160
|
+
return isMac ? '⌘' : 'Ctrl';
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=editorGuide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorGuide.js","sourceRoot":"","sources":["../../../src/structure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AAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACpD,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAChC,CAAC;QACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,SAAS;QAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAChB,IAAkC,EAClC,IAA6B,EAC7B,QAAiB;IAEjB,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,QAAQ,CAAC;IACzC,OAAO,IAAI,KAAK,IAAI,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,KAAc;IACxD,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each button of the openchemlib canvas editor's toolbar does.
|
|
3
|
+
*
|
|
4
|
+
* The toolbar is one canvas painted from a sprite, so there is no element per
|
|
5
|
+
* button to carry a title: the button under the pointer is found from where
|
|
6
|
+
* the pointer is (see `editorToolbarGeometry.ts`) and its entry here is what
|
|
7
|
+
* the tooltip says.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Which editor a button works in. The reaction-only button is drawn greyed in
|
|
11
|
+
* a molecule editor, and the text tool is greyed in every editor react-ocl
|
|
12
|
+
* builds, since neither enables drawing objects.
|
|
13
|
+
*/
|
|
14
|
+
export type EditorToolbarAvailability = 'always' | 'reaction' | 'never';
|
|
15
|
+
/** One button of the toolbar. */
|
|
16
|
+
export interface EditorToolbarButton {
|
|
17
|
+
/** What the button is called. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** What it does, in a sentence or two. */
|
|
20
|
+
description: string;
|
|
21
|
+
/**
|
|
22
|
+
* Keys that pick the tool, pressed while the pointer is over empty canvas.
|
|
23
|
+
* `Mod` stands for ⌘ on a Mac and Ctrl elsewhere.
|
|
24
|
+
* @default undefined — no key
|
|
25
|
+
*/
|
|
26
|
+
keys?: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Which editor the button works in.
|
|
29
|
+
* @default 'always'
|
|
30
|
+
*/
|
|
31
|
+
availability?: EditorToolbarAvailability;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The buttons, in the order the toolbar numbers them: down the first column,
|
|
35
|
+
* then down the second.
|
|
36
|
+
*/
|
|
37
|
+
export declare const EDITOR_TOOLBAR_BUTTONS: readonly EditorToolbarButton[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether a button can be used in an editor of the given kind.
|
|
40
|
+
* @param button - The button.
|
|
41
|
+
* @param mode - The kind of editor.
|
|
42
|
+
* @returns True when pressing the button selects its tool.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isEditorToolbarButtonAvailable(button: EditorToolbarButton, mode: 'molecule' | 'reaction'): boolean;
|
|
45
|
+
//# sourceMappingURL=editorToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorToolbar.d.ts","sourceRoot":"","sources":["../../../src/structure/core/editorToolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAExE,iCAAiC;AACjC,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,mBAAmB,EAwGhE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,UAAU,GAAG,UAAU,GAC5B,OAAO,CAIT"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each button of the openchemlib canvas editor's toolbar does.
|
|
3
|
+
*
|
|
4
|
+
* The toolbar is one canvas painted from a sprite, so there is no element per
|
|
5
|
+
* button to carry a title: the button under the pointer is found from where
|
|
6
|
+
* the pointer is (see `editorToolbarGeometry.ts`) and its entry here is what
|
|
7
|
+
* the tooltip says.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The buttons, in the order the toolbar numbers them: down the first column,
|
|
11
|
+
* then down the second.
|
|
12
|
+
*/
|
|
13
|
+
export const EDITOR_TOOLBAR_BUTTONS = [
|
|
14
|
+
{ name: 'Clear', description: 'Erase the whole drawing.' },
|
|
15
|
+
{
|
|
16
|
+
name: 'Clean up',
|
|
17
|
+
description: 'Redraw the structure with fresh 2D coordinates. With part of it selected, the rest keeps its layout.',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Select',
|
|
21
|
+
description: 'Drag around atoms to select them: hold Alt for a rectangle, Shift to add to the selection. Drag a selection to move it, Shift-drag to copy it.',
|
|
22
|
+
keys: ['Space'],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Unknown configuration',
|
|
26
|
+
description: 'Click a stereocentre to mark its configuration as unknown; click again to undo it.',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Delete',
|
|
30
|
+
description: 'Click an atom or a bond to delete it.',
|
|
31
|
+
keys: ['0'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Single bond',
|
|
35
|
+
description: 'Click empty space for a new bond, or drag from an atom. Clicking a bond again makes it double, then triple.',
|
|
36
|
+
keys: ['1'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Up bond',
|
|
40
|
+
description: 'Wedged stereo bond, pointing toward the viewer. Its narrow end goes on the stereocentre.',
|
|
41
|
+
keys: ['u'],
|
|
42
|
+
},
|
|
43
|
+
ring('3-membered ring', '3'),
|
|
44
|
+
ring('5-membered ring', '5'),
|
|
45
|
+
ring('7-membered ring', '7'),
|
|
46
|
+
{
|
|
47
|
+
name: 'Positive charge',
|
|
48
|
+
description: 'Click an atom to raise its charge by one.',
|
|
49
|
+
keys: ['+'],
|
|
50
|
+
},
|
|
51
|
+
atom('Carbon', 'C', 'c'),
|
|
52
|
+
atom('Nitrogen', 'N', 'n'),
|
|
53
|
+
atom('Oxygen', 'O', 'o'),
|
|
54
|
+
atom('Fluorine', 'F', 'f'),
|
|
55
|
+
atom('Bromine', 'Br', 'b'),
|
|
56
|
+
atom('Hydrogen', 'H'),
|
|
57
|
+
{ name: 'Undo', description: 'Revert the last change.', keys: ['Mod', 'Z'] },
|
|
58
|
+
{
|
|
59
|
+
name: 'Zoom and rotate',
|
|
60
|
+
description: 'Press where the centre should be, then drag up or down to zoom and sideways to rotate. With a selection, only that part moves.',
|
|
61
|
+
keys: ['z'],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Atom mapping',
|
|
65
|
+
description: 'Drag from a reactant atom to the same atom in a product: both get the same number. Click a mapped atom to unmap it.',
|
|
66
|
+
keys: ['m'],
|
|
67
|
+
availability: 'reaction',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Enhanced stereo',
|
|
71
|
+
description: 'Click a stereo bond to say what its centre means: abs, this enantiomer; &, both (racemic); or, one of the two. Press the button again to switch between the three.',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Text',
|
|
75
|
+
description: 'Place a text label in the drawing.',
|
|
76
|
+
availability: 'never',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'Chain',
|
|
80
|
+
description: 'Drag from empty space or from an atom to draw a zigzag carbon chain.',
|
|
81
|
+
keys: ['2'],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'Down bond',
|
|
85
|
+
description: 'Hashed stereo bond, pointing away from the viewer. Its narrow end goes on the stereocentre.',
|
|
86
|
+
keys: ['d'],
|
|
87
|
+
},
|
|
88
|
+
ring('4-membered ring', '4'),
|
|
89
|
+
ring('6-membered ring', '6'),
|
|
90
|
+
ring('Benzene ring', 'a'),
|
|
91
|
+
{
|
|
92
|
+
name: 'Negative charge',
|
|
93
|
+
description: 'Click an atom to lower its charge by one.',
|
|
94
|
+
keys: ['-'],
|
|
95
|
+
},
|
|
96
|
+
atom('Silicon', 'Si'),
|
|
97
|
+
atom('Phosphorus', 'P', 'p'),
|
|
98
|
+
atom('Sulfur', 'S', 's'),
|
|
99
|
+
atom('Chlorine', 'Cl', 'l'),
|
|
100
|
+
atom('Iodine', 'I', 'i'),
|
|
101
|
+
{
|
|
102
|
+
name: 'Any atom',
|
|
103
|
+
description: 'Pick any element, isotope, valence or radical in a dialog, then click to place it or to change an atom. Alt-click an atom to edit its own properties.',
|
|
104
|
+
keys: ['.'],
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
/**
|
|
108
|
+
* Whether a button can be used in an editor of the given kind.
|
|
109
|
+
* @param button - The button.
|
|
110
|
+
* @param mode - The kind of editor.
|
|
111
|
+
* @returns True when pressing the button selects its tool.
|
|
112
|
+
*/
|
|
113
|
+
export function isEditorToolbarButtonAvailable(button, mode) {
|
|
114
|
+
const { availability = 'always' } = button;
|
|
115
|
+
if (availability === 'always')
|
|
116
|
+
return true;
|
|
117
|
+
return availability === 'reaction' && mode === 'reaction';
|
|
118
|
+
}
|
|
119
|
+
function ring(name, key) {
|
|
120
|
+
return {
|
|
121
|
+
name,
|
|
122
|
+
description: 'Click empty space for a new ring, a bond to fuse one onto it, or an atom for a spiro ring.',
|
|
123
|
+
keys: [key],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function atom(name, symbol, key) {
|
|
127
|
+
const description = `Click empty space for a new ${symbol} atom, or an atom to turn it into ${symbol}.`;
|
|
128
|
+
return key === undefined
|
|
129
|
+
? { name, description }
|
|
130
|
+
: { name, description, keys: [key] };
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=editorToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorToolbar.js","sourceRoot":"","sources":["../../../src/structure/core/editorToolbar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4BH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAmC;IACpE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE;IAC1D;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,sGAAsG;KACzG;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,gJAAgJ;QAClJ,IAAI,EAAE,CAAC,OAAO,CAAC;KAChB;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EACT,oFAAoF;KACvF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,CAAC,GAAG,CAAC;KACZ;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,6GAA6G;QAC/G,IAAI,EAAE,CAAC,GAAG,CAAC;KACZ;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EACT,0FAA0F;QAC5F,IAAI,EAAE,CAAC,GAAG,CAAC;KACZ;IACD,IAAI,CAAC,iBAAiB,EAAE,GAAG,CAAC;IAC5B,IAAI,CAAC,iBAAiB,EAAE,GAAG,CAAC;IAC5B,IAAI,CAAC,iBAA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