react-cheminfo 0.55.1 → 0.57.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/bin/check-deploy.mjs +7 -1
- package/lib/credits/core/credits.d.ts +30 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +35 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/deploy/core/checkDeploy.d.ts.map +1 -1
- package/lib/deploy/core/checkDeploy.js +4 -1
- package/lib/deploy/core/checkDeploy.js.map +1 -1
- package/lib/deploy/core/types.d.ts +7 -0
- package/lib/deploy/core/types.d.ts.map +1 -1
- package/lib/deploy/core/types.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +1 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.js +16 -0
- package/lib/ecosystem/core/unlistedSites.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +4 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +1 -0
- package/lib/locales/en.json +1 -0
- package/lib/locales/es.json +1 -0
- package/lib/locales/fr.json +1 -0
- package/lib/locales/it.json +1 -0
- package/lib/molecule3d/core/settings.d.ts +6 -0
- package/lib/molecule3d/core/settings.d.ts.map +1 -1
- package/lib/molecule3d/core/settings.js +1 -0
- package/lib/molecule3d/core/settings.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DStage.d.ts +29 -0
- package/lib/molecule3d/ui/Molecule3DStage.d.ts.map +1 -0
- package/lib/molecule3d/ui/Molecule3DStage.js +40 -0
- package/lib/molecule3d/ui/Molecule3DStage.js.map +1 -0
- package/lib/molecule3d/ui/Molecule3DToolbar.d.ts +14 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.js +5 -3
- package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts +2 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +7 -6
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.d.ts +2 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.js +2 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.js.map +1 -1
- package/lib/molecule3d/ui/index.d.ts +1 -1
- package/lib/molecule3d/ui/index.d.ts.map +1 -1
- package/lib/molecule3d/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/src/credits/core/credits.ts +38 -0
- package/src/deploy/core/checkDeploy.ts +4 -1
- package/src/deploy/core/types.ts +7 -0
- package/src/ecosystem/core/types.ts +2 -1
- package/src/ecosystem/core/unlistedSites.ts +16 -0
- package/src/ecosystem/ui/glyphs.tsx +16 -0
- package/src/locales/de.json +1 -0
- package/src/locales/en.json +1 -0
- package/src/locales/es.json +1 -0
- package/src/locales/fr.json +1 -0
- package/src/locales/it.json +1 -0
- package/src/molecule3d/core/settings.ts +7 -0
- package/src/molecule3d/ui/Molecule3DStage.tsx +80 -0
- package/src/molecule3d/ui/Molecule3DToolbar.tsx +28 -1
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +48 -37
- package/src/molecule3d/ui/MoleculeViewer3D.tsx +2 -1
- package/src/molecule3d/ui/index.ts +4 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box the molecule canvas and its toolbars are drawn in, which is also the
|
|
3
|
+
* box that fills the screen.
|
|
4
|
+
*
|
|
5
|
+
* A box filling the screen hides everything outside it, and the popovers and
|
|
6
|
+
* tooltips of the toolbars are portalled to `document.body`: while the box
|
|
7
|
+
* fills the screen they are portalled into it instead, the way react-science's
|
|
8
|
+
* `RootLayout` keeps its own menus visible. Otherwise the portal options of the
|
|
9
|
+
* page around the viewer are passed through untouched.
|
|
10
|
+
*/
|
|
11
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
12
|
+
import type { Molecule3DFullscreen } from './Molecule3DToolbar.tsx';
|
|
13
|
+
/** Props of {@link Molecule3DStage}. */
|
|
14
|
+
export interface Molecule3DStageProps {
|
|
15
|
+
/** Style of the box. */
|
|
16
|
+
style: CSSProperties;
|
|
17
|
+
/**
|
|
18
|
+
* What is drawn in the box, handed whether it fills the screen and the
|
|
19
|
+
* toggle, or `undefined` where the browser cannot fill the screen.
|
|
20
|
+
*/
|
|
21
|
+
children: (fullscreen: Molecule3DFullscreen | undefined) => ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The box of the canvas, able to fill the screen.
|
|
25
|
+
* @param props - See {@link Molecule3DStageProps}.
|
|
26
|
+
* @returns The box.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Molecule3DStage(props: Molecule3DStageProps): ReactElement;
|
|
29
|
+
//# sourceMappingURL=Molecule3DStage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Molecule3DStage.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/Molecule3DStage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,wCAAwC;AACxC,MAAM,WAAW,oBAAoB;IACnC,wBAAwB;IACxB,KAAK,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,QAAQ,EAAE,CAAC,UAAU,EAAE,oBAAoB,GAAG,SAAS,KAAK,SAAS,CAAC;CACvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAMzE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The box the molecule canvas and its toolbars are drawn in, which is also the
|
|
4
|
+
* box that fills the screen.
|
|
5
|
+
*
|
|
6
|
+
* A box filling the screen hides everything outside it, and the popovers and
|
|
7
|
+
* tooltips of the toolbars are portalled to `document.body`: while the box
|
|
8
|
+
* fills the screen they are portalled into it instead, the way react-science's
|
|
9
|
+
* `RootLayout` keeps its own menus visible. Otherwise the portal options of the
|
|
10
|
+
* page around the viewer are passed through untouched.
|
|
11
|
+
*/
|
|
12
|
+
import { PortalContext, PortalProvider } from '@blueprintjs/core';
|
|
13
|
+
import { useCallback, useContext, useState } from 'react';
|
|
14
|
+
import { FullScreenProvider, useFullscreen } from 'react-science/ui';
|
|
15
|
+
/**
|
|
16
|
+
* The box of the canvas, able to fill the screen.
|
|
17
|
+
* @param props - See {@link Molecule3DStageProps}.
|
|
18
|
+
* @returns The box.
|
|
19
|
+
*/
|
|
20
|
+
export function Molecule3DStage(props) {
|
|
21
|
+
return (_jsx(FullScreenProvider, { children: (fullscreenRef) => _jsx(Stage, { ...props, fullscreenRef: fullscreenRef }) }));
|
|
22
|
+
}
|
|
23
|
+
function Stage(props) {
|
|
24
|
+
const { style, children, fullscreenRef } = props;
|
|
25
|
+
const { isFullScreen, toggle } = useFullscreen();
|
|
26
|
+
const portal = useContext(PortalContext);
|
|
27
|
+
const [canFillScreen] = useState(isFullscreenEnabled);
|
|
28
|
+
const [stage, setStage] = useState(null);
|
|
29
|
+
const stageRef = useCallback((element) => {
|
|
30
|
+
fullscreenRef.current = element;
|
|
31
|
+
setStage(element);
|
|
32
|
+
}, [fullscreenRef]);
|
|
33
|
+
// The provider is always there, so entering full screen changes a value
|
|
34
|
+
// rather than the tree, and the canvas inside is never mounted again.
|
|
35
|
+
return (_jsx("div", { ref: stageRef, style: style, children: _jsx(PortalProvider, { portalClassName: portal.portalClassName, portalContainer: isFullScreen && stage !== null ? stage : portal.portalContainer, children: children(canFillScreen ? { active: isFullScreen, toggle } : undefined) }) }));
|
|
36
|
+
}
|
|
37
|
+
function isFullscreenEnabled() {
|
|
38
|
+
return typeof document !== 'undefined' && document.fullscreenEnabled;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Molecule3DStage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Molecule3DStage.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/Molecule3DStage.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAerE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,OAAO,CACL,KAAC,kBAAkB,cAChB,CAAC,aAAa,EAAE,EAAE,CAAC,KAAC,KAAK,OAAK,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,GACnD,CACtB,CAAC;AACJ,CAAC;AAOD,SAAS,KAAK,CAAC,KAAiB;IAC9B,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;IACjD,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACzC,MAAM,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,OAA8B,EAAE,EAAE;QACjC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;QAChC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,wEAAwE;IACxE,sEAAsE;IACtE,OAAO,CACL,cAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAC9B,KAAC,cAAc,IACb,eAAe,EAAE,MAAM,CAAC,eAAe,EACvC,eAAe,EACb,YAAY,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,YAGhE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GACxD,GACb,CACP,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,iBAAiB,CAAC;AACvE,CAAC"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The toolbars floating over the molecule canvas: the view — reset, spin,
|
|
3
|
-
* surface,
|
|
3
|
+
* surface, the options and export popovers, full screen and help — in one vertical
|
|
4
4
|
* react-science `Toolbar`, and the measuring tools with their own clear button
|
|
5
5
|
* in a second one under it.
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactElement } from 'react';
|
|
8
8
|
import type { MeasurementKind } from '../core/measurement.ts';
|
|
9
9
|
import type { Molecule3DTools } from '../core/settings.ts';
|
|
10
|
+
/** Whether the canvas fills the screen, and how to change that. */
|
|
11
|
+
export interface Molecule3DFullscreen {
|
|
12
|
+
/** Whether the canvas and its toolbars fill the screen. */
|
|
13
|
+
active: boolean;
|
|
14
|
+
/** Fill the screen, or leave it. */
|
|
15
|
+
toggle: () => void;
|
|
16
|
+
}
|
|
10
17
|
/** Props of {@link Molecule3DToolbar}. */
|
|
11
18
|
export interface Molecule3DToolbarProps {
|
|
12
19
|
/** Which tools to show; every one it does not name is on. */
|
|
@@ -25,6 +32,12 @@ export interface Molecule3DToolbarProps {
|
|
|
25
32
|
options?: ReactElement;
|
|
26
33
|
/** Content of the export popover; its tool is left out without one. */
|
|
27
34
|
exportPanel?: ReactElement;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the canvas fills the screen, and the toggle; its tool is left out
|
|
37
|
+
* without one, which is what a browser that cannot fill the screen gets.
|
|
38
|
+
* @default undefined
|
|
39
|
+
*/
|
|
40
|
+
fullscreen?: Molecule3DFullscreen;
|
|
28
41
|
}
|
|
29
42
|
/**
|
|
30
43
|
* The two toolbars; either is left out when none of its tools is on.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Molecule3DToolbar.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/Molecule3DToolbar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAU3D,0CAA0C;AAC1C,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,mBAAmB,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,OAAO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;IACrD,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,wEAAwE;IACxE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uEAAuE;IACvE,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CA4J7E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* The toolbars floating over the molecule canvas: the view — reset, spin,
|
|
4
|
-
* surface,
|
|
4
|
+
* surface, the options and export popovers, full screen and help — in one vertical
|
|
5
5
|
* react-science `Toolbar`, and the measuring tools with their own clear button
|
|
6
6
|
* in a second one under it.
|
|
7
7
|
*/
|
|
@@ -18,17 +18,19 @@ import { ClearMeasurementsIcon, MeasureIcon, SurfaceIcon, } from "./molecule3dIc
|
|
|
18
18
|
* @returns The toolbars, stacked.
|
|
19
19
|
*/
|
|
20
20
|
export function Molecule3DToolbar(props) {
|
|
21
|
-
const { tools: toolsProp, measureKind, onMeasureKindChange, measurementCount, onClearMeasurements, spinning, onSpinningChange, showSurface, onShowSurfaceChange, onResetView, options, exportPanel, } = props;
|
|
21
|
+
const { tools: toolsProp, measureKind, onMeasureKindChange, measurementCount, onClearMeasurements, spinning, onSpinningChange, showSurface, onShowSurfaceChange, onResetView, options, exportPanel, fullscreen, } = props;
|
|
22
22
|
const t = useChromeT();
|
|
23
23
|
const tools = resolveMolecule3DTools(toolsProp);
|
|
24
24
|
const showOptions = tools.options && options !== undefined;
|
|
25
25
|
const showSurfaceTool = tools.surface && onShowSurfaceChange !== undefined;
|
|
26
26
|
const showExport = tools.export && exportPanel !== undefined;
|
|
27
|
+
const showFullscreen = tools.fullscreen && fullscreen !== undefined;
|
|
27
28
|
const hasView = tools.spin ||
|
|
28
29
|
tools.surface ||
|
|
29
30
|
tools.reset ||
|
|
30
31
|
showOptions ||
|
|
31
32
|
showExport ||
|
|
33
|
+
showFullscreen ||
|
|
32
34
|
tools.help;
|
|
33
35
|
return (_jsxs("div", { className: "no-print", style: COLUMN_STYLE, children: [hasView && (_jsx(Card, { elevation: 1, style: CARD_STYLE, children: _jsxs(Toolbar, { vertical: true, "aria-label": t('molecule3d.view'), children: [tools.reset && (_jsx(Toolbar.Item, { icon: "zoom-to-fit", "aria-label": t('molecule3d.resetView'), tooltip: t('molecule3d.resetView'), tooltipProps: TOOLTIP_PROPS, onClick: onResetView })), tools.spin && (_jsx(Toolbar.Item, { icon: "refresh", active: spinning, "aria-label": t('molecule3d.spin'), tooltip: t('molecule3d.spin'), tooltipProps: TOOLTIP_PROPS, onClick: () => {
|
|
34
36
|
onSpinningChange(!spinning);
|
|
@@ -44,7 +46,7 @@ export function Molecule3DToolbar(props) {
|
|
|
44
46
|
'aria-label': t('molecule3d.exportImage'),
|
|
45
47
|
tooltip: t('molecule3d.exportImage'),
|
|
46
48
|
tooltipProps: TOOLTIP_PROPS,
|
|
47
|
-
} })), tools.help && (_jsx(Toolbar.PopoverItem, { placement: "right-start", content: _jsx(Molecule3DHelp, {}), itemProps: {
|
|
49
|
+
} })), showFullscreen && (_jsx(Toolbar.Item, { icon: fullscreen.active ? 'minimize' : 'fullscreen', active: fullscreen.active, "aria-label": t('molecule3d.fullScreen'), tooltip: t('molecule3d.fullScreen'), tooltipProps: TOOLTIP_PROPS, onClick: fullscreen.toggle })), tools.help && (_jsx(Toolbar.PopoverItem, { placement: "right-start", content: _jsx(Molecule3DHelp, {}), itemProps: {
|
|
48
50
|
icon: 'help',
|
|
49
51
|
'aria-label': t('structure.mouseAndKeyboard'),
|
|
50
52
|
tooltip: t('structure.mouseAndKeyboard'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Molecule3DToolbar.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/Molecule3DToolbar.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,WAAW,GACZ,MAAM,sBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Molecule3DToolbar.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/Molecule3DToolbar.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,WAAW,GACZ,MAAM,sBAAuB,CAAC;AAoC/B;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,KAAK,EAAE,SAAS,EAChB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,OAAO,EACP,WAAW,E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EAAE,KAAC,qBAAqB,KAAG,EAC/B,QAAQ,EAAE,gBAAgB,KAAK,CAAC,gBACpB,CAAC,CAAC,8BAA8B,CAAC,EAC7C,OAAO,EAAE,CAAC,CAAC,8BAA8B,CAAC,EAC1C,YAAY,EAAE,aAAa,EAC3B,OAAO,EAAE,mBAAmB,GAC5B,IACM,GACL,CACR,IACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,EAAE,SAAS,EAAE,OAAO,EAAW,CAAC;AAEtD,MAAM,YAAY,GAAkB;IAClC,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,CAAC;IACN,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,MAAM,UAAU,GAAkB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The molstar canvas of `MoleculeViewer3D`, with its toolbars over it
|
|
2
|
+
* The molstar canvas of `MoleculeViewer3D`, with its toolbars over it, in a
|
|
3
|
+
* box that can fill the screen.
|
|
3
4
|
*
|
|
4
5
|
* Reached through `React.lazy`, so a page that never shows a molecule never
|
|
5
6
|
* downloads molstar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeCanvas3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MoleculeCanvas3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAezD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOxE,yCAAyC;AACzC,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,qBAAqB,EACrB,UAAU,GAAG,mBAAmB,CACjC;IACC,2EAA2E;IAC3E,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CA8J3E"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { DEFAULT_SPIN_SPEED } from "../../molstar/core/index.js";
|
|
4
4
|
import { normalizeMolecule3DSettings, resolveMolecule3DTools, } from "../core/settings.js";
|
|
5
5
|
import { Molecule3DExport } from "./Molecule3DExport.js";
|
|
6
6
|
import { Molecule3DOptions } from "./Molecule3DOptions.js";
|
|
7
|
+
import { Molecule3DStage } from "./Molecule3DStage.js";
|
|
7
8
|
import { Molecule3DToolbar } from "./Molecule3DToolbar.js";
|
|
8
9
|
import { createMolecule3DViewer } from "./createViewer.js";
|
|
9
10
|
import { useControlledState } from "./useControlledState.js";
|
|
@@ -82,11 +83,11 @@ export function MoleculeCanvas3D(props) {
|
|
|
82
83
|
camera: props,
|
|
83
84
|
});
|
|
84
85
|
const { canvasSize, exportImage, copyImage } = useImageExport(container, viewerRef, fileName);
|
|
85
|
-
return (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
return (_jsx(Molecule3DStage, { style: { ...STAGE_STYLE, minHeight }, children: (fullscreen) => (_jsxs(_Fragment, { children: [_jsx("div", { ref: setContainer, style: CANVAS_STYLE, "data-testid": "molecule3d" }), molfile !== null && (_jsx("div", { style: OVERLAY_STYLE, children: _jsx(Molecule3DToolbar, { tools: tools, fullscreen: fullscreen, measureKind: measureKind, onMeasureKindChange: setMeasureKind, measurementCount: measurements.length, onClearMeasurements: () => {
|
|
87
|
+
setMeasurements(NO_MEASUREMENTS);
|
|
88
|
+
}, spinning: spinning, onSpinningChange: setSpinning, showSurface: settings.showSurface, onShowSurfaceChange: (showSurface) => {
|
|
89
|
+
setSettings({ ...settings, showSurface });
|
|
90
|
+
}, onResetView: resetView, options: _jsx(Molecule3DOptions, { settings: settings, onChange: setSettings, polarSurfaceArea: polarSurfaceArea, defaults: initialSettings }), exportPanel: _jsx(Molecule3DExport, { getSize: canvasSize, onExport: exportImage, onCopy: copyImage }) }) }))] })) }));
|
|
90
91
|
}
|
|
91
92
|
const NO_MEASUREMENTS = [];
|
|
92
93
|
const STAGE_STYLE = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeCanvas3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MoleculeCanvas3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,E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C;wBAC5C,CAAC,EACD,WAAW,EAAE,SAAS,EACtB,OAAO,EACL,KAAC,iBAAiB,IAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,WAAW,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,eAAe,GACzB,EAEJ,WAAW,EACT,KAAC,gBAAgB,IACf,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,SAAS,GACjB,GAEJ,GACE,CACP,IACA,CACJ,GACe,CACnB,CAAC;AACJ,CAAC;AAED,MAAM,eAAe,GAA2B,EAAE,CAAC;AAEnD,MAAM,WAAW,GAAkB;IACjC,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,MAAM;IACb,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,YAAY,GAAkB,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEvE,MAAM,aAAa,GAAkB;IACnC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,CAAC;IACN,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A molecule in three dimensions, with a toolbar to measure it, turn it, wrap
|
|
3
|
-
* it in its surface and
|
|
3
|
+
* it in its surface, restyle it and fill the screen with it — and what to say
|
|
4
|
+
* when there cannot be one.
|
|
4
5
|
*
|
|
5
6
|
* The WebGL probe runs before molstar is touched, so a machine without WebGL
|
|
6
7
|
* gets an explanation instead of a blank rectangle, and the canvas sits behind
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeViewer3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeViewer3D.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MoleculeViewer3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeViewer3D.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAQzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOxE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAiC3E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* A molecule in three dimensions, with a toolbar to measure it, turn it, wrap
|
|
4
|
-
* it in its surface and
|
|
4
|
+
* it in its surface, restyle it and fill the screen with it — and what to say
|
|
5
|
+
* when there cannot be one.
|
|
5
6
|
*
|
|
6
7
|
* The WebGL probe runs before molstar is touched, so a machine without WebGL
|
|
7
8
|
* gets an explanation instead of a blank rectangle, and the canvas sits behind
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeViewer3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeViewer3D.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"MoleculeViewer3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeViewer3D.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,4EAA4E;AAC5E,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD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,CACX,IACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,EAAE;CACb,CAAC"}
|
|
@@ -10,7 +10,7 @@ export { Molecule3DExport } from './Molecule3DExport.tsx';
|
|
|
10
10
|
export type { Molecule3DExportProps } from './Molecule3DExport.tsx';
|
|
11
11
|
export { Molecule3DHelp } from './Molecule3DHelp.tsx';
|
|
12
12
|
export { Molecule3DToolbar } from './Molecule3DToolbar.tsx';
|
|
13
|
-
export type { Molecule3DToolbarProps } from './Molecule3DToolbar.tsx';
|
|
13
|
+
export type { Molecule3DFullscreen, Molecule3DToolbarProps, } from './Molecule3DToolbar.tsx';
|
|
14
14
|
export type { MoleculeImageRequest, SceneCapture, } from './exportMoleculeImage.ts';
|
|
15
15
|
export { exportMoleculeImage } from './exportMoleculeImage.ts';
|
|
16
16
|
export type { ImageExport } from './useImageExport.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,oBAAoB,EACpB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAS5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.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",
|
|
@@ -77,6 +77,13 @@ export const CREDITS = [
|
|
|
77
77
|
description: 'the structure helpers built on top of OpenChemLib.',
|
|
78
78
|
license: 'MIT',
|
|
79
79
|
},
|
|
80
|
+
{
|
|
81
|
+
id: 'openchemlib-sqlite',
|
|
82
|
+
name: 'openchemlib-sqlite',
|
|
83
|
+
href: 'https://github.com/cheminfo/openchemlib-sqlite',
|
|
84
|
+
description: 'the substructure and similarity search, inside SQLite.',
|
|
85
|
+
license: 'MIT',
|
|
86
|
+
},
|
|
80
87
|
{
|
|
81
88
|
id: 'osiris-property-explorer',
|
|
82
89
|
name: 'OSIRIS Property Explorer',
|
|
@@ -293,6 +300,37 @@ export const CREDITS = [
|
|
|
293
300
|
href: 'https://www.chemexper.com/',
|
|
294
301
|
description: 'the catalogue the compounds and their spectra come from.',
|
|
295
302
|
},
|
|
303
|
+
{
|
|
304
|
+
id: 'wikipedia',
|
|
305
|
+
name: 'Wikipedia',
|
|
306
|
+
href: 'https://en.wikipedia.org/',
|
|
307
|
+
description:
|
|
308
|
+
'the articles, and the Chembox and Drugbox infoboxes every value is read from.',
|
|
309
|
+
license: 'CC-BY-SA-4.0',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: 'wikidata',
|
|
313
|
+
name: 'Wikidata',
|
|
314
|
+
href: 'https://www.wikidata.org/',
|
|
315
|
+
description:
|
|
316
|
+
'the name of every compound in every language, and its article in each Wikipedia.',
|
|
317
|
+
license: 'CC0-1.0',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: 'country-flag-icons',
|
|
321
|
+
name: 'country-flag-icons',
|
|
322
|
+
href: 'https://gitlab.com/catamphetamine/country-flag-icons',
|
|
323
|
+
description: 'the flag each language is picked by.',
|
|
324
|
+
license: 'MIT',
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
id: 'wtf-wikipedia',
|
|
328
|
+
name: 'wtf_wikipedia',
|
|
329
|
+
href: 'https://github.com/spencermountain/wtf_wikipedia',
|
|
330
|
+
description:
|
|
331
|
+
'reads the wikitext of an article and its templates into plain values.',
|
|
332
|
+
license: 'MIT',
|
|
333
|
+
},
|
|
296
334
|
{
|
|
297
335
|
id: 'react',
|
|
298
336
|
name: 'React',
|
|
@@ -95,7 +95,10 @@ export function findDeployProblems(
|
|
|
95
95
|
problems,
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const workflow = byPath.get(DOCKER_IMAGE_WORKFLOW);
|
|
99
|
+
if (workflow !== undefined || (options.requirePublishedImage ?? true)) {
|
|
100
|
+
readPublishedImage(workflow, problems);
|
|
101
|
+
}
|
|
99
102
|
|
|
100
103
|
const gitignore = byPath.get('.gitignore');
|
|
101
104
|
if (gitignore === undefined || !/^\s*\/?\.deploy\/?\s*$/m.test(gitignore)) {
|
package/src/deploy/core/types.ts
CHANGED
|
@@ -71,6 +71,13 @@ export interface CheckDeployOptions {
|
|
|
71
71
|
* @default true
|
|
72
72
|
*/
|
|
73
73
|
requireHealthcheck?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a workflow must publish the image. A private repository with no
|
|
76
|
+
* CI minutes builds it on the deploy host on purpose; a workflow it does
|
|
77
|
+
* ship is still checked.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
requirePublishedImage?: boolean;
|
|
74
81
|
/**
|
|
75
82
|
* A comment carrying this marker inside a service waives the healthcheck for
|
|
76
83
|
* it, for a worker with no HTTP surface to probe. The reason is written next
|
|
@@ -34,4 +34,20 @@ export const UNLISTED_SITES: readonly EcosystemSite[] = [
|
|
|
34
34
|
// apart from the white ring at 16 px.
|
|
35
35
|
mark: { plate: '#c2410c', accent: '#a3e635' },
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
id: 'wikidata',
|
|
39
|
+
name: { lead: 'wikidata', alt: 'cheminfo', dot: true },
|
|
40
|
+
host: 'wikidata.cheminfo.org',
|
|
41
|
+
tagline: 'The chemistry of Wikipedia’s infoboxes, searchable by structure.',
|
|
42
|
+
group: 'research',
|
|
43
|
+
// A leather-binding brown, the bound encyclopedia, 7.3 Oklab units from the
|
|
44
|
+
// nearest lead of the family (database) and 9.4:1 on white.
|
|
45
|
+
brand: '#5c4033',
|
|
46
|
+
// Wikipedia's own link blue answers it, 5.4:1 on white, so it is also the
|
|
47
|
+
// text half of the wordmark.
|
|
48
|
+
brandAlt: '#3366cc',
|
|
49
|
+
// On the brown plate that blue sits 24.5 apart, under the family's floor,
|
|
50
|
+
// so the link row of the mark takes a lighter blue of the same hue.
|
|
51
|
+
mark: { plate: '#5c4033', accent: '#6b9bf2' },
|
|
52
|
+
},
|
|
37
53
|
];
|
|
@@ -530,4 +530,20 @@ export const GLYPHS: Record<SiteId, (alt: string) => ReactNode> = {
|
|
|
530
530
|
/>
|
|
531
531
|
</>
|
|
532
532
|
),
|
|
533
|
+
// An infobox: the structure at its top, a ring, and two rows of data under
|
|
534
|
+
// it. The second row carries the answering colour, the blue of a link. Both
|
|
535
|
+
// rows and the gap between them fall on whole pixels at 16 px.
|
|
536
|
+
wikidata: (alt) => (
|
|
537
|
+
<>
|
|
538
|
+
<path
|
|
539
|
+
d="M16 5.4 20.85 8.2 20.85 13.8 16 16.6 11.15 13.8 11.15 8.2Z"
|
|
540
|
+
fill="none"
|
|
541
|
+
stroke="#ffffff"
|
|
542
|
+
strokeWidth="2.2"
|
|
543
|
+
strokeLinejoin="round"
|
|
544
|
+
/>
|
|
545
|
+
<rect x="6" y="20" width="20" height="2" rx="1" fill="#ffffff" />
|
|
546
|
+
<rect x="6" y="24" width="14" height="4" rx="2" fill={alt} />
|
|
547
|
+
</>
|
|
548
|
+
),
|
|
533
549
|
};
|
package/src/locales/de.json
CHANGED
|
@@ -484,6 +484,7 @@
|
|
|
484
484
|
"molecule3d.molecularSurface": "Moleküloberfläche",
|
|
485
485
|
"molecule3d.displayOptions": "Anzeigeoptionen",
|
|
486
486
|
"molecule3d.exportImage": "Bild exportieren",
|
|
487
|
+
"molecule3d.fullScreen": "Vollbild",
|
|
487
488
|
"molecule3d.measure": "Messen",
|
|
488
489
|
"molecule3d.clearMeasurements": "Alle Messungen entfernen",
|
|
489
490
|
"molecule3d.measurement.distance": "Abstand",
|
package/src/locales/en.json
CHANGED
|
@@ -460,6 +460,7 @@
|
|
|
460
460
|
"molecule3d.molecularSurface": "Molecular surface",
|
|
461
461
|
"molecule3d.displayOptions": "Display options",
|
|
462
462
|
"molecule3d.exportImage": "Export image",
|
|
463
|
+
"molecule3d.fullScreen": "Full screen",
|
|
463
464
|
"molecule3d.measure": "Measure",
|
|
464
465
|
"molecule3d.clearMeasurements": "Remove all measurements",
|
|
465
466
|
"molecule3d.measurement.distance": "Distance",
|
package/src/locales/es.json
CHANGED
|
@@ -484,6 +484,7 @@
|
|
|
484
484
|
"molecule3d.molecularSurface": "Superficie molecular",
|
|
485
485
|
"molecule3d.displayOptions": "Opciones de presentación",
|
|
486
486
|
"molecule3d.exportImage": "Exportar la imagen",
|
|
487
|
+
"molecule3d.fullScreen": "Pantalla completa",
|
|
487
488
|
"molecule3d.measure": "Medir",
|
|
488
489
|
"molecule3d.clearMeasurements": "Quitar todas las medidas",
|
|
489
490
|
"molecule3d.measurement.distance": "Distancia",
|
package/src/locales/fr.json
CHANGED
|
@@ -484,6 +484,7 @@
|
|
|
484
484
|
"molecule3d.molecularSurface": "Surface moléculaire",
|
|
485
485
|
"molecule3d.displayOptions": "Options d'affichage",
|
|
486
486
|
"molecule3d.exportImage": "Exporter l'image",
|
|
487
|
+
"molecule3d.fullScreen": "Plein écran",
|
|
487
488
|
"molecule3d.measure": "Mesurer",
|
|
488
489
|
"molecule3d.clearMeasurements": "Retirer toutes les mesures",
|
|
489
490
|
"molecule3d.measurement.distance": "Distance",
|
package/src/locales/it.json
CHANGED
|
@@ -460,6 +460,7 @@
|
|
|
460
460
|
"molecule3d.molecularSurface": "Superficie molecolare",
|
|
461
461
|
"molecule3d.displayOptions": "Opzioni di visualizzazione",
|
|
462
462
|
"molecule3d.exportImage": "Esporta l'immagine",
|
|
463
|
+
"molecule3d.fullScreen": "Schermo intero",
|
|
463
464
|
"molecule3d.measure": "Misura",
|
|
464
465
|
"molecule3d.clearMeasurements": "Togli tutte le misure",
|
|
465
466
|
"molecule3d.measurement.distance": "Distanza",
|
|
@@ -105,6 +105,12 @@ export interface Molecule3DTools {
|
|
|
105
105
|
reset: boolean;
|
|
106
106
|
/** A popover saving the picture as a PNG or an SVG. */
|
|
107
107
|
export: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* A toggle filling the screen with the canvas and its toolbars. It is left
|
|
110
|
+
* out where the browser cannot fill the screen, as on an iPhone or in a
|
|
111
|
+
* frame not allowed to.
|
|
112
|
+
*/
|
|
113
|
+
fullscreen: boolean;
|
|
108
114
|
/** A popover listing what the mouse and the keyboard do on the canvas. */
|
|
109
115
|
help: boolean;
|
|
110
116
|
}
|
|
@@ -117,6 +123,7 @@ export const DEFAULT_MOLECULE_3D_TOOLS: Molecule3DTools = {
|
|
|
117
123
|
surface: true,
|
|
118
124
|
reset: true,
|
|
119
125
|
export: true,
|
|
126
|
+
fullscreen: true,
|
|
120
127
|
help: true,
|
|
121
128
|
};
|
|
122
129
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box the molecule canvas and its toolbars are drawn in, which is also the
|
|
3
|
+
* box that fills the screen.
|
|
4
|
+
*
|
|
5
|
+
* A box filling the screen hides everything outside it, and the popovers and
|
|
6
|
+
* tooltips of the toolbars are portalled to `document.body`: while the box
|
|
7
|
+
* fills the screen they are portalled into it instead, the way react-science's
|
|
8
|
+
* `RootLayout` keeps its own menus visible. Otherwise the portal options of the
|
|
9
|
+
* page around the viewer are passed through untouched.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { PortalContext, PortalProvider } from '@blueprintjs/core';
|
|
13
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
14
|
+
import { useCallback, useContext, useState } from 'react';
|
|
15
|
+
import { FullScreenProvider, useFullscreen } from 'react-science/ui';
|
|
16
|
+
|
|
17
|
+
import type { Molecule3DFullscreen } from './Molecule3DToolbar.tsx';
|
|
18
|
+
|
|
19
|
+
/** Props of {@link Molecule3DStage}. */
|
|
20
|
+
export interface Molecule3DStageProps {
|
|
21
|
+
/** Style of the box. */
|
|
22
|
+
style: CSSProperties;
|
|
23
|
+
/**
|
|
24
|
+
* What is drawn in the box, handed whether it fills the screen and the
|
|
25
|
+
* toggle, or `undefined` where the browser cannot fill the screen.
|
|
26
|
+
*/
|
|
27
|
+
children: (fullscreen: Molecule3DFullscreen | undefined) => ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The box of the canvas, able to fill the screen.
|
|
32
|
+
* @param props - See {@link Molecule3DStageProps}.
|
|
33
|
+
* @returns The box.
|
|
34
|
+
*/
|
|
35
|
+
export function Molecule3DStage(props: Molecule3DStageProps): ReactElement {
|
|
36
|
+
return (
|
|
37
|
+
<FullScreenProvider>
|
|
38
|
+
{(fullscreenRef) => <Stage {...props} fullscreenRef={fullscreenRef} />}
|
|
39
|
+
</FullScreenProvider>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface StageProps extends Molecule3DStageProps {
|
|
44
|
+
/** Where `FullScreenProvider` expects the element that fills the screen. */
|
|
45
|
+
fullscreenRef: { current: HTMLDivElement | null };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function Stage(props: StageProps): ReactElement {
|
|
49
|
+
const { style, children, fullscreenRef } = props;
|
|
50
|
+
const { isFullScreen, toggle } = useFullscreen();
|
|
51
|
+
const portal = useContext(PortalContext);
|
|
52
|
+
const [canFillScreen] = useState(isFullscreenEnabled);
|
|
53
|
+
const [stage, setStage] = useState<HTMLDivElement | null>(null);
|
|
54
|
+
const stageRef = useCallback(
|
|
55
|
+
(element: HTMLDivElement | null) => {
|
|
56
|
+
fullscreenRef.current = element;
|
|
57
|
+
setStage(element);
|
|
58
|
+
},
|
|
59
|
+
[fullscreenRef],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// The provider is always there, so entering full screen changes a value
|
|
63
|
+
// rather than the tree, and the canvas inside is never mounted again.
|
|
64
|
+
return (
|
|
65
|
+
<div ref={stageRef} style={style}>
|
|
66
|
+
<PortalProvider
|
|
67
|
+
portalClassName={portal.portalClassName}
|
|
68
|
+
portalContainer={
|
|
69
|
+
isFullScreen && stage !== null ? stage : portal.portalContainer
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
{children(canFillScreen ? { active: isFullScreen, toggle } : undefined)}
|
|
73
|
+
</PortalProvider>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isFullscreenEnabled(): boolean {
|
|
79
|
+
return typeof document !== 'undefined' && document.fullscreenEnabled;
|
|
80
|
+
}
|