react-cheminfo 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/lib/download/core/downloadFigure.d.ts +7 -5
- package/lib/download/core/downloadFigure.d.ts.map +1 -1
- package/lib/download/core/downloadFigure.js +7 -6
- package/lib/download/core/downloadFigure.js.map +1 -1
- package/lib/download/core/figureLayout.d.ts +55 -0
- package/lib/download/core/figureLayout.d.ts.map +1 -0
- package/lib/download/core/figureLayout.js +89 -0
- package/lib/download/core/figureLayout.js.map +1 -0
- package/lib/download/core/figureScale.d.ts +9 -0
- package/lib/download/core/figureScale.d.ts.map +1 -1
- package/lib/download/core/figureScale.js +10 -0
- package/lib/download/core/figureScale.js.map +1 -1
- package/lib/download/core/figureSettle.d.ts +51 -0
- package/lib/download/core/figureSettle.d.ts.map +1 -0
- package/lib/download/core/figureSettle.js +81 -0
- package/lib/download/core/figureSettle.js.map +1 -0
- package/lib/download/core/figureSvg.d.ts +7 -1
- package/lib/download/core/figureSvg.d.ts.map +1 -1
- package/lib/download/core/figureSvg.js +1 -0
- package/lib/download/core/figureSvg.js.map +1 -1
- package/lib/download/core/figureSvgDocument.d.ts +7 -0
- package/lib/download/core/figureSvgDocument.d.ts.map +1 -1
- package/lib/download/core/figureSvgDocument.js +11 -2
- package/lib/download/core/figureSvgDocument.js.map +1 -1
- package/lib/download/core/index.d.ts +5 -1
- package/lib/download/core/index.d.ts.map +1 -1
- package/lib/download/core/index.js +3 -1
- package/lib/download/core/index.js.map +1 -1
- package/lib/download/ui/FigureDownload.d.ts +18 -4
- package/lib/download/ui/FigureDownload.d.ts.map +1 -1
- package/lib/download/ui/FigureDownload.js +35 -9
- package/lib/download/ui/FigureDownload.js.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts +17 -7
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +30 -22
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/download/ui/FigureSizeField.d.ts +27 -0
- package/lib/download/ui/FigureSizeField.d.ts.map +1 -0
- package/lib/download/ui/FigureSizeField.js +87 -0
- package/lib/download/ui/FigureSizeField.js.map +1 -0
- package/lib/download/ui/FigureSizeRows.d.ts +34 -0
- package/lib/download/ui/FigureSizeRows.d.ts.map +1 -0
- package/lib/download/ui/FigureSizeRows.js +54 -0
- package/lib/download/ui/FigureSizeRows.js.map +1 -0
- package/lib/download/ui/index.d.ts +2 -0
- package/lib/download/ui/index.d.ts.map +1 -1
- package/lib/download/ui/index.js.map +1 -1
- package/lib/download/ui/useFigureRedraw.d.ts +27 -0
- package/lib/download/ui/useFigureRedraw.d.ts.map +1 -0
- package/lib/download/ui/useFigureRedraw.js +78 -0
- package/lib/download/ui/useFigureRedraw.js.map +1 -0
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +10 -2
- package/lib/locales/en.json +10 -2
- package/lib/locales/es.json +10 -2
- package/lib/locales/fr.json +10 -2
- package/lib/overlay/ui/OverlayValueMenu.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayValueMenu.js +7 -1
- package/lib/overlay/ui/OverlayValueMenu.js.map +1 -1
- package/package.json +1 -1
- package/src/download/core/downloadFigure.ts +12 -9
- package/src/download/core/figureLayout.ts +114 -0
- package/src/download/core/figureScale.ts +13 -0
- package/src/download/core/figureSettle.ts +112 -0
- package/src/download/core/figureSvg.ts +8 -1
- package/src/download/core/figureSvgDocument.ts +19 -2
- package/src/download/core/index.ts +13 -0
- package/src/download/ui/FigureDownload.tsx +88 -35
- package/src/download/ui/FigureDownloadPanel.tsx +45 -22
- package/src/download/ui/FigureSizeField.tsx +153 -0
- package/src/download/ui/FigureSizeRows.tsx +108 -0
- package/src/download/ui/index.ts +2 -0
- package/src/download/ui/useFigureRedraw.tsx +115 -0
- package/src/locales/de.json +10 -2
- package/src/locales/en.json +10 -2
- package/src/locales/es.json +10 -2
- package/src/locales/fr.json +10 -2
- package/src/overlay/ui/OverlayValueMenu.tsx +7 -1
|
@@ -2,8 +2,10 @@ export { cssTokenNames, resolveCssTokens } from "./cssTokens.js";
|
|
|
2
2
|
export { downloadBlob } from "./downloadBlob.js";
|
|
3
3
|
export { downloadFigure } from "./downloadFigure.js";
|
|
4
4
|
export { downloadText } from "./downloadText.js";
|
|
5
|
+
export { FIGURE_COLUMN_WIDTH, FIGURE_LAYOUTS, FIGURE_LAYOUT_MAX, FIGURE_LAYOUT_MIN, figureLayoutRedraws, figureLayoutSide, figureLayoutSize, } from "./figureLayout.js";
|
|
5
6
|
export { FIGURE_PNG_TYPE, figurePng } from "./figurePng.js";
|
|
6
|
-
export {
|
|
7
|
+
export { whenFigureSettles } from "./figureSettle.js";
|
|
8
|
+
export { DEFAULT_FIGURE_SCALE, FIGURE_MAX_PIXELS, FIGURE_SCALES, defaultFigureScale, figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, } from "./figureScale.js";
|
|
7
9
|
export { FIGURE_SVG_TYPE, figureSvg } from "./figureSvg.js";
|
|
8
10
|
export { figureSvgDocument } from "./figureSvgDocument.js";
|
|
9
11
|
export { figureLegendMarkup } from "./figureLegend.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/download/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/download/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,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,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IconName } from '@blueprintjs/core';
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
3
|
import type { FigureFormat } from '../core/downloadFigure.ts';
|
|
4
|
+
import type { FigureRenderer } from './useFigureRedraw.tsx';
|
|
4
5
|
/** What {@link FigureDownload} needs. */
|
|
5
6
|
export interface FigureDownloadProps {
|
|
6
7
|
/**
|
|
@@ -22,7 +23,9 @@ export interface FigureDownloadProps {
|
|
|
22
23
|
*/
|
|
23
24
|
defaultFormat?: FigureFormat;
|
|
24
25
|
/**
|
|
25
|
-
* The resolution
|
|
26
|
+
* The resolution a PNG opens on, as a multiple of the figure on screen. An
|
|
27
|
+
* SVG opens at 1×, the size it has on screen, and each format keeps the
|
|
28
|
+
* multiple the reader last picked for it.
|
|
26
29
|
* @default 2
|
|
27
30
|
*/
|
|
28
31
|
defaultScale?: number;
|
|
@@ -57,6 +60,16 @@ export interface FigureDownloadProps {
|
|
|
57
60
|
* @default undefined
|
|
58
61
|
*/
|
|
59
62
|
testId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Draws the figure at a size, for a file. When it is given the panel offers
|
|
65
|
+
* a size — as shown, 4:3, 16:9, a journal column, or typed — and a figure
|
|
66
|
+
* saved at a size other than its own is drawn again at that size, off the
|
|
67
|
+
* page, so its axes and labels are laid out for the new shape rather than
|
|
68
|
+
* stretched into it. Draw exactly what is on screen, with the same data,
|
|
69
|
+
* zoom and colours; only the box changes.
|
|
70
|
+
* @default undefined — the figure is saved at the size it has on screen
|
|
71
|
+
*/
|
|
72
|
+
renderFigure?: FigureRenderer;
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
62
75
|
* The glyph that takes the figure off the page as a file.
|
|
@@ -71,9 +84,10 @@ export interface FigureDownloadProps {
|
|
|
71
84
|
* Both formats are offered because they answer different questions. An SVG is
|
|
72
85
|
* the figure itself, sharp at any size and still editable, which is what a
|
|
73
86
|
* paper wants; a PNG is a picture of it, which is what every chat window and
|
|
74
|
-
* slide deck accepts. The resolution
|
|
75
|
-
* panel writes out the
|
|
76
|
-
* what `3×` means for the figure in front of
|
|
87
|
+
* slide deck accepts. The resolution paints a PNG with more pixels and makes
|
|
88
|
+
* an SVG open larger, and the panel writes out the size it is about to
|
|
89
|
+
* produce so nobody has to guess what `3×` means for the figure in front of
|
|
90
|
+
* them.
|
|
77
91
|
* @param props - See {@link FigureDownloadProps}.
|
|
78
92
|
* @returns The glyph and its panel.
|
|
79
93
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigureDownload.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureDownload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"FigureDownload.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureDownload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAa9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAmGvE"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PopoverNext } from '@blueprintjs/core';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
5
5
|
import { OverlayIconButton } from "../../overlay/ui/OverlayIconButton.js";
|
|
6
6
|
import { downloadFigure } from "../core/downloadFigure.js";
|
|
7
|
-
import {
|
|
7
|
+
import { figureLayoutRedraws, figureLayoutSize } from "../core/figureLayout.js";
|
|
8
|
+
import { DEFAULT_FIGURE_SCALE, FIGURE_SCALES, defaultFigureScale, } from "../core/figureScale.js";
|
|
8
9
|
import { figureSize } from "../core/figureTarget.js";
|
|
9
10
|
import { FigureDownloadPanel } from "./FigureDownloadPanel.js";
|
|
11
|
+
import { useFigureRedraw } from "./useFigureRedraw.js";
|
|
10
12
|
/**
|
|
11
13
|
* The glyph that takes the figure off the page as a file.
|
|
12
14
|
*
|
|
@@ -20,9 +22,10 @@ import { FigureDownloadPanel } from "./FigureDownloadPanel.js";
|
|
|
20
22
|
* Both formats are offered because they answer different questions. An SVG is
|
|
21
23
|
* the figure itself, sharp at any size and still editable, which is what a
|
|
22
24
|
* paper wants; a PNG is a picture of it, which is what every chat window and
|
|
23
|
-
* slide deck accepts. The resolution
|
|
24
|
-
* panel writes out the
|
|
25
|
-
* what `3×` means for the figure in front of
|
|
25
|
+
* slide deck accepts. The resolution paints a PNG with more pixels and makes
|
|
26
|
+
* an SVG open larger, and the panel writes out the size it is about to
|
|
27
|
+
* produce so nobody has to guess what `3×` means for the figure in front of
|
|
28
|
+
* them.
|
|
26
29
|
* @param props - See {@link FigureDownloadProps}.
|
|
27
30
|
* @returns The glyph and its panel.
|
|
28
31
|
*/
|
|
@@ -30,14 +33,21 @@ export function FigureDownload(props) {
|
|
|
30
33
|
const { targetId, fileName, background, scales = FIGURE_SCALES } = props;
|
|
31
34
|
const { defaultFormat = 'png', defaultScale = DEFAULT_FIGURE_SCALE } = props;
|
|
32
35
|
const { label, title } = props;
|
|
33
|
-
const { icon = 'download', testId } = props;
|
|
36
|
+
const { icon = 'download', testId, renderFigure } = props;
|
|
34
37
|
const t = useChromeT();
|
|
35
38
|
const [open, setOpen] = useState(false);
|
|
36
39
|
const [format, setFormat] = useState(defaultFormat);
|
|
37
|
-
const [
|
|
40
|
+
const [picked, setPicked] = useState(() => ({
|
|
41
|
+
png: defaultScale,
|
|
42
|
+
svg: defaultFigureScale('svg'),
|
|
43
|
+
}));
|
|
44
|
+
const scale = picked[format];
|
|
38
45
|
const [size, setSize] = useState(null);
|
|
39
46
|
const [failure, setFailure] = useState(null);
|
|
40
47
|
const [saving, setSaving] = useState(false);
|
|
48
|
+
const [layout, setLayout] = useState('screen');
|
|
49
|
+
const [custom, setCustom] = useState(null);
|
|
50
|
+
const { redraw, portal } = useFigureRedraw(renderFigure);
|
|
41
51
|
// The panel is held open from here rather than left to itself, because the
|
|
42
52
|
// figure has to be measured at the moment it opens: its size is what the
|
|
43
53
|
// panel writes out, and reading a bounding box on every render would cost a
|
|
@@ -52,7 +62,16 @@ export function FigureDownload(props) {
|
|
|
52
62
|
async function save() {
|
|
53
63
|
setSaving(true);
|
|
54
64
|
try {
|
|
55
|
-
|
|
65
|
+
const options = { format, scale, fileName, background };
|
|
66
|
+
if (renderFigure !== undefined &&
|
|
67
|
+
size !== null &&
|
|
68
|
+
figureLayoutRedraws(layout, size, custom ?? size)) {
|
|
69
|
+
const drawn = figureLayoutSize(layout, size, custom ?? size);
|
|
70
|
+
await redraw(targetId, drawn, (box) => downloadFigure(box, options));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await downloadFigure(targetId, options);
|
|
74
|
+
}
|
|
56
75
|
setFailure(null);
|
|
57
76
|
}
|
|
58
77
|
catch (error) {
|
|
@@ -62,6 +81,13 @@ export function FigureDownload(props) {
|
|
|
62
81
|
setSaving(false);
|
|
63
82
|
}
|
|
64
83
|
}
|
|
65
|
-
return (_jsx(PopoverNext, { isOpen: open, placement: "bottom-end", onInteraction: interact, content: _jsx(FigureDownloadPanel, { title: title ?? t('download.saveFigure'), format: format, scale: scale, scales: scales, size: size, failure: failure, saving: saving, onFormatChange: setFormat, onScaleChange:
|
|
84
|
+
return (_jsxs(_Fragment, { children: [_jsx(PopoverNext, { isOpen: open, placement: "bottom-end", onInteraction: interact, content: _jsx(FigureDownloadPanel, { title: title ?? t('download.saveFigure'), format: format, scale: scale, scales: scales, size: size, failure: failure, saving: saving, onFormatChange: setFormat, onScaleChange: (next) => setPicked((current) => ({ ...current, [format]: next })), onSave: () => void save(), sizing: renderFigure === undefined
|
|
85
|
+
? undefined
|
|
86
|
+
: {
|
|
87
|
+
layout,
|
|
88
|
+
custom,
|
|
89
|
+
onLayoutChange: setLayout,
|
|
90
|
+
onCustomChange: setCustom,
|
|
91
|
+
} }), children: _jsx(OverlayIconButton, { icon: icon, label: label ?? t('download.saveThisFigure'), value: format.toUpperCase(), active: open, testId: testId, opensMenu: true }) }), portal] }));
|
|
66
92
|
}
|
|
67
93
|
//# sourceMappingURL=FigureDownload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigureDownload.js","sourceRoot":"","sources":["../../../src/download/ui/FigureDownload.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAwC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"FigureDownload.js","sourceRoot":"","sources":["../../../src/download/ui/FigureDownload.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAwC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAC;AAwExD;;;;;;;;;;;;;;;;;;;GAmBG;A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AAO,CACL,8BACE,KAAC,WAAW,IACV,MAAM,EAAE,IAAI,EACZ,SAAS,EAAC,YAAY,EACtB,aAAa,EAAE,QAAQ,EACvB,OAAO,EACL,KAAC,mBAAmB,IAClB,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,qBAAqB,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,SAAS,EACzB,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CACtB,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAE1D,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EACzB,MAAM,EACJ,YAAY,KAAK,SAAS;wBACxB,CAAC,CAAC,SAAS;wBACX,CAAC,CAAC;4BACE,MAAM;4BACN,MAAM;4BACN,cAAc,EAAE,SAAS;4BACzB,cAAc,EAAE,SAAS;yBAC1B,GAEP,YAGJ,KAAC,iBAAiB,IAChB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,yBAAyB,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,EAC3B,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,SACT,GACU,EACb,MAAM,IACN,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { FigureFormat } from '../core/downloadFigure.ts';
|
|
3
3
|
import type { FigurePixels } from '../core/figureScale.ts';
|
|
4
|
+
import type { FigureSizing } from './FigureSizeRows.tsx';
|
|
4
5
|
/** What {@link FigureDownloadPanel} is drawn from. */
|
|
5
6
|
export interface FigureDownloadPanelProps {
|
|
6
7
|
/** What the panel is called. */
|
|
@@ -25,20 +26,29 @@ export interface FigureDownloadPanelProps {
|
|
|
25
26
|
onSave: () => void;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the SVG holds a rendered picture rather than vector drawings, as
|
|
28
|
-
* for a WebGL scene: its resolution then
|
|
29
|
+
* for a WebGL scene: its resolution is then the pixels of that picture, it
|
|
30
|
+
* meets the same ceiling as a PNG, and the hint says so.
|
|
29
31
|
* @default false
|
|
30
32
|
*/
|
|
31
33
|
rasterSvg?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The shape the figure is drawn at, for a figure that can be drawn again at
|
|
36
|
+
* another size. Without it the figure is saved at the size it has on screen,
|
|
37
|
+
* and no size is offered.
|
|
38
|
+
* @default undefined
|
|
39
|
+
*/
|
|
40
|
+
sizing?: FigureSizing;
|
|
32
41
|
}
|
|
33
42
|
/**
|
|
34
|
-
* The
|
|
43
|
+
* The choices behind the save glyph, and the button that writes the file.
|
|
35
44
|
*
|
|
36
|
-
* The resolution
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
45
|
+
* The resolution applies to both formats, and means what the reader needs it
|
|
46
|
+
* to: a PNG is painted with that many more pixels, and an SVG, drawn the same,
|
|
47
|
+
* opens that many times larger in the slide or the document it is dropped
|
|
48
|
+
* into. Only a PNG meets the ceiling of what a browser can paint, so only its
|
|
49
|
+
* choices past that ceiling are greyed.
|
|
40
50
|
*
|
|
41
|
-
*
|
|
51
|
+
* The sentence at the foot is the panel's own hint line rather than a row of its own: it
|
|
42
52
|
* is not a setting, it is what the two settings above it currently amount to,
|
|
43
53
|
* and it is the only thing here that answers the question a reader actually
|
|
44
54
|
* has, which is how big the file is going to be. Saving itself is a command
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigureDownloadPanel.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureDownloadPanel.tsx"],"names":[],"mappings":"AAAA,OAA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,CAyDd"}
|
|
@@ -3,16 +3,19 @@ import { useChromeT } from "../../i18n/ui/useT.js";
|
|
|
3
3
|
import { OverlayAction } from "../../overlay/ui/OverlayAction.js";
|
|
4
4
|
import { OverlayPanel } from "../../overlay/ui/OverlayPanel.js";
|
|
5
5
|
import { OverlaySegmented } from "../../overlay/ui/OverlaySegmented.js";
|
|
6
|
+
import { figureLayoutSize } from "../core/figureLayout.js";
|
|
6
7
|
import { figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, } from "../core/figureScale.js";
|
|
8
|
+
import { FigureSizeRows } from "./FigureSizeRows.js";
|
|
7
9
|
/**
|
|
8
|
-
* The
|
|
10
|
+
* The choices behind the save glyph, and the button that writes the file.
|
|
9
11
|
*
|
|
10
|
-
* The resolution
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* The resolution applies to both formats, and means what the reader needs it
|
|
13
|
+
* to: a PNG is painted with that many more pixels, and an SVG, drawn the same,
|
|
14
|
+
* opens that many times larger in the slide or the document it is dropped
|
|
15
|
+
* into. Only a PNG meets the ceiling of what a browser can paint, so only its
|
|
16
|
+
* choices past that ceiling are greyed.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
18
|
+
* The sentence at the foot is the panel's own hint line rather than a row of its own: it
|
|
16
19
|
* is not a setting, it is what the two settings above it currently amount to,
|
|
17
20
|
* and it is the only thing here that answers the question a reader actually
|
|
18
21
|
* has, which is how big the file is going to be. Saving itself is a command
|
|
@@ -24,19 +27,24 @@ import { figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, }
|
|
|
24
27
|
export function FigureDownloadPanel(props) {
|
|
25
28
|
const { title, format, scale, scales, size, failure, saving } = props;
|
|
26
29
|
const { onFormatChange, onScaleChange, onSave, rasterSvg = false } = props;
|
|
30
|
+
const { sizing } = props;
|
|
27
31
|
const t = useChromeT();
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
// What the file is drawn at: the figure on screen, or the shape picked.
|
|
33
|
+
const drawn = size === null || sizing === undefined
|
|
34
|
+
? size
|
|
35
|
+
: figureLayoutSize(sizing.layout, size, sizing.custom ?? size);
|
|
36
|
+
const painted = format === 'png' || rasterSvg;
|
|
37
|
+
return (_jsxs(OverlayPanel, { title: title, hint: hintOf(format, drawn, scale, failure, rasterSvg, t), actions: _jsx(OverlayAction, { text: t('download.save'), icon: "download", intent: "primary", disabled: saving || size === null, onClick: onSave }), children: [_jsx(OverlaySegmented, { label: t('download.format'), help: {
|
|
30
38
|
title: t('download.format'),
|
|
31
39
|
body: t('download.formatHelp'),
|
|
32
|
-
}, value: format, options: FORMAT_CHOICES, onChange: onFormatChange }), _jsx(OverlaySegmented, { label: t('download.resolution'), help: {
|
|
40
|
+
}, value: format, options: FORMAT_CHOICES, onChange: onFormatChange }), sizing === undefined ? null : (_jsx(FigureSizeRows, { sizing: sizing, size: size })), _jsx(OverlaySegmented, { label: t('download.resolution'), help: {
|
|
33
41
|
title: t('download.resolution'),
|
|
34
42
|
body: t('download.resolutionHelp'),
|
|
35
43
|
example: {
|
|
36
44
|
code: '2×',
|
|
37
45
|
note: t('download.resolutionExample'),
|
|
38
46
|
},
|
|
39
|
-
}, value: String(scale), options: scaleChoices(scales,
|
|
47
|
+
}, value: String(scale), options: scaleChoices(scales, drawn, painted), onChange: (picked) => onScaleChange(Number(picked)) })] }));
|
|
40
48
|
}
|
|
41
49
|
/** The two files a figure can leave the page as. */
|
|
42
50
|
const FORMAT_CHOICES = [
|
|
@@ -47,12 +55,14 @@ const FORMAT_CHOICES = [
|
|
|
47
55
|
* The multiples offered, each saying what it would actually produce.
|
|
48
56
|
*
|
|
49
57
|
* One too large for the browser to paint is greyed rather than dropped, so the
|
|
50
|
-
* reader learns the ceiling exists before they meet it as a blank file.
|
|
58
|
+
* reader learns the ceiling exists before they meet it as a blank file. An SVG
|
|
59
|
+
* is not painted, so it has no such ceiling.
|
|
51
60
|
* @param scales - The multiples the caller offers.
|
|
52
|
-
* @param size - How big the figure is
|
|
61
|
+
* @param size - How big the figure is drawn for the file.
|
|
62
|
+
* @param painted - Whether the file is painted into pixels.
|
|
53
63
|
* @returns The choices, in the order offered.
|
|
54
64
|
*/
|
|
55
|
-
function scaleChoices(scales, size) {
|
|
65
|
+
function scaleChoices(scales, size, painted) {
|
|
56
66
|
const choices = [];
|
|
57
67
|
for (const scale of scales) {
|
|
58
68
|
const pixels = size === null ? null : figurePixels(size, scale);
|
|
@@ -60,7 +70,7 @@ function scaleChoices(scales, size) {
|
|
|
60
70
|
value: String(scale),
|
|
61
71
|
label: figureScaleLabel(scale),
|
|
62
72
|
title: pixels === null ? undefined : formatFigurePixels(pixels),
|
|
63
|
-
disabled: size !== null && !figureScaleFits(size, scale),
|
|
73
|
+
disabled: painted && size !== null && !figureScaleFits(size, scale),
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
return choices;
|
|
@@ -68,8 +78,8 @@ function scaleChoices(scales, size) {
|
|
|
68
78
|
/**
|
|
69
79
|
* The line at the foot of the panel: what pressing save is about to do.
|
|
70
80
|
* @param format - Which file the reader is about to write.
|
|
71
|
-
* @param size - How big the figure is
|
|
72
|
-
* @param scale - The multiple it is
|
|
81
|
+
* @param size - How big the figure is drawn for the file.
|
|
82
|
+
* @param scale - The multiple it is saved at.
|
|
73
83
|
* @param failure - What went wrong last time, if anything.
|
|
74
84
|
* @param rasterSvg - Whether the SVG embeds a rendered picture.
|
|
75
85
|
* @param t - The chrome's formatter, so the sentence is in the language of
|
|
@@ -86,11 +96,9 @@ function hintOf(format, size, scale, failure, rasterSvg, t) {
|
|
|
86
96
|
pixels: formatFigurePixels(figurePixels(size, scale)),
|
|
87
97
|
});
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
pixels: formatFigurePixels(figurePixels(size, scale)),
|
|
94
|
-
});
|
|
99
|
+
const pixels = formatFigurePixels(figurePixels(size, scale));
|
|
100
|
+
return format === 'svg'
|
|
101
|
+
? t('download.hintSvg', { pixels })
|
|
102
|
+
: t('download.hintPng', { pixels });
|
|
95
103
|
}
|
|
96
104
|
//# sourceMappingURL=FigureDownloadPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigureDownloadPanel.js","sourceRoot":"","sources":["../../../src/download/ui/FigureDownloadPanel.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAmC,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"FigureDownloadPanel.js","sourceRoot":"","sources":["../../../src/download/ui/FigureDownloadPanel.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAmC,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAuC,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAwCtD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAA+B;IAE/B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IAC3E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AAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,MAAM,CACb,MAAoB,EACpB,IAAyB,EACzB,KAAa,EACb,OAAsB,EACtB,SAAkB,EAClB,CAAuB;IAEvB,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IACrC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC;IACjD,IAAI,MAAM,KAAK,KAAK,IAAI,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC,wBAAwB,EAAE;YACjC,MAAM,EAAE,kBAAkB,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IACD,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7D,OAAO,MAAM,KAAK,KAAK;QACrB,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FigurePixels } from '../core/figureScale.ts';
|
|
3
|
+
/** What {@link FigureSizeField} needs. */
|
|
4
|
+
export interface FigureSizeFieldProps {
|
|
5
|
+
/** What the row is called. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** What the first box is called, for a screen reader. */
|
|
8
|
+
widthLabel: string;
|
|
9
|
+
/** What the second box is called. */
|
|
10
|
+
heightLabel: string;
|
|
11
|
+
/** The size typed so far. */
|
|
12
|
+
value: FigurePixels;
|
|
13
|
+
/** Called with the size, each side already held to the range. */
|
|
14
|
+
onChange: (size: FigurePixels) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The two sides of a figure, typed in pixels.
|
|
18
|
+
*
|
|
19
|
+
* These are typed rather than stepped: a reader asking for 1920 × 1080 knows
|
|
20
|
+
* the numbers, and a stepper would take a hundred presses to reach them. A side
|
|
21
|
+
* is taken when the reader leaves its box or presses Enter, never on each key,
|
|
22
|
+
* since the `1` of a `1200` on its way in is not a width anybody asked for.
|
|
23
|
+
* @param props - See {@link FigureSizeFieldProps}.
|
|
24
|
+
* @returns The row.
|
|
25
|
+
*/
|
|
26
|
+
export declare function FigureSizeField(props: FigureSizeFieldProps): ReactElement;
|
|
27
|
+
//# sourceMappingURL=FigureSizeField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigureSizeField.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureSizeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgC,YAAY,EAAE,MAAM,OAAO,CAAC;AAQxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,iEAAiE;IACjE,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAwBzE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { OverlayRow } from "../../overlay/ui/OverlayRow.js";
|
|
4
|
+
import { useOverlaySurface } from "../../overlay/ui/overlaySurface.js";
|
|
5
|
+
import { overlayFocusRing } from "../../overlay/ui/overlayValueStyles.js";
|
|
6
|
+
import { figureLayoutSide } from "../core/figureLayout.js";
|
|
7
|
+
/**
|
|
8
|
+
* The two sides of a figure, typed in pixels.
|
|
9
|
+
*
|
|
10
|
+
* These are typed rather than stepped: a reader asking for 1920 × 1080 knows
|
|
11
|
+
* the numbers, and a stepper would take a hundred presses to reach them. A side
|
|
12
|
+
* is taken when the reader leaves its box or presses Enter, never on each key,
|
|
13
|
+
* since the `1` of a `1200` on its way in is not a width anybody asked for.
|
|
14
|
+
* @param props - See {@link FigureSizeFieldProps}.
|
|
15
|
+
* @returns The row.
|
|
16
|
+
*/
|
|
17
|
+
export function FigureSizeField(props) {
|
|
18
|
+
const { label, widthLabel, heightLabel, value, onChange } = props;
|
|
19
|
+
const { metrics } = useOverlaySurface();
|
|
20
|
+
return (_jsx(OverlayRow, { label: label, children: _jsxs("span", { style: { ...FIELD_STYLE, fontSize: metrics.fontSize }, children: [_jsx(SideInput, { label: widthLabel, value: value.width, metrics: metrics, onCommit: (width) => onChange({ ...value, width }) }), _jsx("span", { "aria-hidden": "true", children: "\u00D7" }), _jsx(SideInput, { label: heightLabel, value: value.height, metrics: metrics, onCommit: (height) => onChange({ ...value, height }) }), _jsx("span", { style: UNIT_STYLE, children: "px" })] }) }));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One side, typed.
|
|
24
|
+
* @param props - See {@link SideInputProps}.
|
|
25
|
+
* @returns The box.
|
|
26
|
+
*/
|
|
27
|
+
function SideInput(props) {
|
|
28
|
+
const { label, value, metrics, onCommit } = props;
|
|
29
|
+
const [draft, setDraft] = useState(String(value));
|
|
30
|
+
const [taken, setTaken] = useState(value);
|
|
31
|
+
const [focused, setFocused] = useState(false);
|
|
32
|
+
// A side changed from outside — another shape picked, a clamp — replaces
|
|
33
|
+
// whatever was being typed.
|
|
34
|
+
if (taken !== value) {
|
|
35
|
+
setTaken(value);
|
|
36
|
+
setDraft(String(value));
|
|
37
|
+
}
|
|
38
|
+
function commit() {
|
|
39
|
+
const typed = Number.parseFloat(draft);
|
|
40
|
+
const side = Number.isFinite(typed) ? figureLayoutSide(typed) : value;
|
|
41
|
+
setDraft(String(side));
|
|
42
|
+
if (side !== value)
|
|
43
|
+
onCommit(side);
|
|
44
|
+
}
|
|
45
|
+
function onKeyDown(event) {
|
|
46
|
+
if (event.key !== 'Enter')
|
|
47
|
+
return;
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
commit();
|
|
50
|
+
}
|
|
51
|
+
return (_jsx("input", { type: "text", inputMode: "numeric", "aria-label": label, value: draft, style: { ...sideStyle(metrics), ...overlayFocusRing(focused) }, onChange: (event) => setDraft(event.currentTarget.value), onFocus: () => setFocused(true), onBlur: () => {
|
|
52
|
+
setFocused(false);
|
|
53
|
+
commit();
|
|
54
|
+
}, onKeyDown: onKeyDown }));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A box as tall as every other control of the panel, and wide enough for four
|
|
58
|
+
* digits.
|
|
59
|
+
* @param metrics - The measurements the panel is drawn from.
|
|
60
|
+
* @returns The box's rules.
|
|
61
|
+
*/
|
|
62
|
+
function sideStyle(metrics) {
|
|
63
|
+
return {
|
|
64
|
+
boxSizing: 'border-box',
|
|
65
|
+
width: '5em',
|
|
66
|
+
height: metrics.controlHeight,
|
|
67
|
+
padding: '0 6px',
|
|
68
|
+
border: '1px solid var(--border)',
|
|
69
|
+
borderRadius: metrics.controlRadius,
|
|
70
|
+
background: 'var(--surface)',
|
|
71
|
+
color: 'var(--text)',
|
|
72
|
+
font: 'inherit',
|
|
73
|
+
fontSize: metrics.fontSize,
|
|
74
|
+
fontVariantNumeric: 'tabular-nums',
|
|
75
|
+
textAlign: 'right',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const FIELD_STYLE = {
|
|
79
|
+
display: 'inline-flex',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
gap: 6,
|
|
82
|
+
color: 'var(--text-muted)',
|
|
83
|
+
};
|
|
84
|
+
const UNIT_STYLE = {
|
|
85
|
+
color: 'var(--text-faint)',
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=FigureSizeField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigureSizeField.js","sourceRoot":"","sources":["../../../src/download/ui/FigureSizeField.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAiB3D;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAExC,OAAO,CACL,KAAC,UAAU,IAAC,KAAK,EAAE,KAAK,YACtB,gBAAM,KAAK,EAAE,EAAE,GAAG,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,aACzD,KAAC,SAAS,IACR,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,GAClD,EACF,8BAAkB,MAAM,uBAAS,EACjC,KAAC,SAAS,IACR,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,KAAK,CAAC,MAAM,EACnB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GA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,SAAS,EAAC,SAAS,gBACP,KAAK,EACjB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,EAAE,EAC9D,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,EACxD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,GAAG,EAAE;YACX,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,MAAM,EAAE,CAAC;QACX,CAAC,EACD,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAuB;IACxC,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,OAAO,CAAC,aAAa;QAC7B,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,yBAAyB;QACjC,YAAY,EAAE,OAAO,CAAC,aAAa;QACnC,UAAU,EAAE,gBAAgB;QAC5B,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,kBAAkB,EAAE,cAAc;QAClC,SAAS,EAAE,OAAO;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,mBAAmB;CACM,CAAC;AAEnC,MAAM,UAAU,GAAG;IACjB,KAAK,EAAE,mBAAmB;CACM,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FigureLayout } from '../core/figureLayout.ts';
|
|
3
|
+
import type { FigurePixels } from '../core/figureScale.ts';
|
|
4
|
+
/** The shape a figure is saved at, and what changes it. */
|
|
5
|
+
export interface FigureSizing {
|
|
6
|
+
/** The shape picked. */
|
|
7
|
+
layout: FigureLayout;
|
|
8
|
+
/**
|
|
9
|
+
* The size typed for `custom`, or `null` before anything was typed, when it
|
|
10
|
+
* starts from the figure on screen.
|
|
11
|
+
*/
|
|
12
|
+
custom: FigurePixels | null;
|
|
13
|
+
/** Called with the shape picked. */
|
|
14
|
+
onLayoutChange: (layout: FigureLayout) => void;
|
|
15
|
+
/** Called with the size typed. */
|
|
16
|
+
onCustomChange: (size: FigurePixels) => void;
|
|
17
|
+
}
|
|
18
|
+
/** What {@link FigureSizeRows} needs. */
|
|
19
|
+
export interface FigureSizeRowsProps {
|
|
20
|
+
/** The shape and what changes it. */
|
|
21
|
+
sizing: FigureSizing;
|
|
22
|
+
/** How big the figure is on the page, or `null` where there is none. */
|
|
23
|
+
size: FigurePixels | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The shape the figure is drawn at, and the two sides of a custom one.
|
|
27
|
+
*
|
|
28
|
+
* Each shape says the pixels it would produce, so choosing `16:9` for a figure
|
|
29
|
+
* already close to it is visibly a choice that changes little.
|
|
30
|
+
* @param props - See {@link FigureSizeRowsProps}.
|
|
31
|
+
* @returns The rows.
|
|
32
|
+
*/
|
|
33
|
+
export declare function FigureSizeRows(props: FigureSizeRowsProps): ReactElement;
|
|
34
|
+
//# sourceMappingURL=FigureSizeRows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigureSizeRows.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureSizeRows.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK3D,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,oCAAoC;IACpC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,kCAAkC;IAClC,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CAC9C;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,wEAAwE;IACxE,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAsCvE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
3
|
+
import { OverlaySelect } from "../../overlay/ui/OverlaySelect.js";
|
|
4
|
+
import { FIGURE_LAYOUTS, figureLayoutSize } from "../core/figureLayout.js";
|
|
5
|
+
import { formatFigurePixels } from "../core/figureScale.js";
|
|
6
|
+
import { FigureSizeField } from "./FigureSizeField.js";
|
|
7
|
+
/**
|
|
8
|
+
* The shape the figure is drawn at, and the two sides of a custom one.
|
|
9
|
+
*
|
|
10
|
+
* Each shape says the pixels it would produce, so choosing `16:9` for a figure
|
|
11
|
+
* already close to it is visibly a choice that changes little.
|
|
12
|
+
* @param props - See {@link FigureSizeRowsProps}.
|
|
13
|
+
* @returns The rows.
|
|
14
|
+
*/
|
|
15
|
+
export function FigureSizeRows(props) {
|
|
16
|
+
const { sizing, size } = props;
|
|
17
|
+
const { layout, custom, onLayoutChange, onCustomChange } = sizing;
|
|
18
|
+
const t = useChromeT();
|
|
19
|
+
const options = [];
|
|
20
|
+
for (const shape of FIGURE_LAYOUTS) {
|
|
21
|
+
options.push({
|
|
22
|
+
value: shape,
|
|
23
|
+
label: layoutLabel(shape, t),
|
|
24
|
+
title: size === null
|
|
25
|
+
? undefined
|
|
26
|
+
: formatFigurePixels(figureLayoutSize(shape, size, custom ?? size)),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return (_jsxs(_Fragment, { children: [_jsx(OverlaySelect, { label: t('download.size'), help: { title: t('download.size'), body: t('download.sizeHelp') }, value: layout, options: options, disabled: size === null, onChange: onLayoutChange }), layout === 'custom' && size !== null ? (_jsx(FigureSizeField, { label: t('download.customSize'), widthLabel: t('download.width'), heightLabel: t('download.height'), value: figureLayoutSize('custom', size, custom ?? size), onChange: onCustomChange })) : null] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What a shape reads in the picker. A ratio is written as a ratio in every
|
|
33
|
+
* language.
|
|
34
|
+
* @param layout - The shape.
|
|
35
|
+
* @param t - The chrome's formatter.
|
|
36
|
+
* @returns Its label.
|
|
37
|
+
*/
|
|
38
|
+
function layoutLabel(layout, t) {
|
|
39
|
+
switch (layout) {
|
|
40
|
+
case 'standard':
|
|
41
|
+
return '4:3';
|
|
42
|
+
case 'wide':
|
|
43
|
+
return '16:9';
|
|
44
|
+
case 'column':
|
|
45
|
+
return t('download.sizeColumn');
|
|
46
|
+
case 'custom':
|
|
47
|
+
return t('download.sizeCustom');
|
|
48
|
+
case 'screen':
|
|
49
|
+
return t('download.sizeScreen');
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`unknown figure layout: ${String(layout)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=FigureSizeRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigureSizeRows.js","sourceRoot":"","sources":["../../../src/download/ui/FigureSizeRows.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EA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K,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAC/B,UAAU,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAC/B,WAAW,EAAE,CAAC,CAAC,iBAAiB,CAAC,EACjC,KAAK,EAAE,gBAAgB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,EACvD,QAAQ,EAAE,cAAc,GACxB,CACH,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,MAAoB,EAAE,CAAuB;IAChE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,UAAU;YACb,OAAO,KAAK,CAAC;QACf,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC;QAClC;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -10,6 +10,8 @@ export type { FigureDownloadProps } from './FigureDownload.tsx';
|
|
|
10
10
|
export { FigureDownload } from './FigureDownload.tsx';
|
|
11
11
|
export type { FigureDownloadPanelProps } from './FigureDownloadPanel.tsx';
|
|
12
12
|
export { FigureDownloadPanel } from './FigureDownloadPanel.tsx';
|
|
13
|
+
export type { FigureSizing } from './FigureSizeRows.tsx';
|
|
14
|
+
export type { FigureRenderer } from './useFigureRedraw.tsx';
|
|
13
15
|
export type { ExportDialogFrameProps } from './ExportDialogFrame.tsx';
|
|
14
16
|
export { ExportDialogFrame } from './ExportDialogFrame.tsx';
|
|
15
17
|
export type { ExportImageDialogProps } from './ExportImageDialog.tsx';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/download/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/download/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|