react-cheminfo 0.29.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 +62 -2
- package/lib/chrome/ui/AccountButton.d.ts +76 -0
- package/lib/chrome/ui/AccountButton.d.ts.map +1 -0
- package/lib/chrome/ui/AccountButton.js +66 -0
- package/lib/chrome/ui/AccountButton.js.map +1 -0
- package/lib/chrome/ui/index.d.ts +2 -0
- package/lib/chrome/ui/index.d.ts.map +1 -1
- package/lib/chrome/ui/index.js +1 -0
- package/lib/chrome/ui/index.js.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.d.ts +6 -0
- package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.js +3 -3
- package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
- 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 +13 -2
- package/lib/locales/en.json +13 -2
- package/lib/locales/es.json +13 -2
- package/lib/locales/fr.json +13 -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/lib/structure/core/conformerBoltzmann.d.ts +56 -0
- package/lib/structure/core/conformerBoltzmann.d.ts.map +1 -0
- package/lib/structure/core/conformerBoltzmann.js +96 -0
- package/lib/structure/core/conformerBoltzmann.js.map +1 -0
- package/lib/structure/core/conformerEnergy.d.ts +69 -0
- package/lib/structure/core/conformerEnergy.d.ts.map +1 -0
- package/lib/structure/core/conformerEnergy.js +47 -0
- package/lib/structure/core/conformerEnergy.js.map +1 -0
- package/lib/structure/core/index.d.ts +3 -0
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js +2 -0
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/ui/ConformerTable.d.ts +73 -0
- package/lib/structure/ui/ConformerTable.d.ts.map +1 -0
- package/lib/structure/ui/ConformerTable.js +259 -0
- package/lib/structure/ui/ConformerTable.js.map +1 -0
- package/lib/structure/ui/conformerColumns.d.ts +30 -0
- package/lib/structure/ui/conformerColumns.d.ts.map +1 -0
- package/lib/structure/ui/conformerColumns.js +37 -0
- package/lib/structure/ui/conformerColumns.js.map +1 -0
- package/lib/ui.d.ts +4 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +2 -0
- package/lib/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/chrome/ui/AccountButton.tsx +185 -0
- package/src/chrome/ui/index.ts +2 -0
- package/src/clipboard/ui/ClickToCopy.tsx +9 -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 +13 -2
- package/src/locales/en.json +13 -2
- package/src/locales/es.json +13 -2
- package/src/locales/fr.json +13 -2
- package/src/overlay/ui/OverlayValueMenu.tsx +7 -1
- package/src/structure/core/conformerBoltzmann.ts +102 -0
- package/src/structure/core/conformerEnergy.ts +97 -0
- package/src/structure/core/index.ts +15 -0
- package/src/structure/ui/ConformerTable.tsx +429 -0
- package/src/structure/ui/conformerColumns.ts +55 -0
- package/src/ui.ts +12 -0
- package/styles/chrome.css +55 -0
|
@@ -17,6 +17,16 @@ export const FIGURE_SCALES = [1, 2, 3, 4];
|
|
|
17
17
|
* of these files end up.
|
|
18
18
|
*/
|
|
19
19
|
export const DEFAULT_FIGURE_SCALE = 2;
|
|
20
|
+
/**
|
|
21
|
+
* The multiple a figure is saved at in this format unless the reader says
|
|
22
|
+
* otherwise. An SVG stays sharp however large it is shown, so it opens at the
|
|
23
|
+
* size it has on screen; a PNG is painted twice over, for a slide.
|
|
24
|
+
* @param format - The file being written.
|
|
25
|
+
* @returns The multiple.
|
|
26
|
+
*/
|
|
27
|
+
export function defaultFigureScale(format) {
|
|
28
|
+
return format === 'svg' ? 1 : DEFAULT_FIGURE_SCALE;
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* The longest side a browser will paint into one canvas.
|
|
22
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figureScale.js","sourceRoot":"","sources":["../../../src/download/core/figureScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"figureScale.js","sourceRoot":"","sources":["../../../src/download/core/figureScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;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|
|
2
|
+
* Knowing when a figure drawn for a file has finished drawing.
|
|
3
|
+
*
|
|
4
|
+
* A chart mounted off the page to be saved at another size does not arrive in
|
|
5
|
+
* one piece: it may render once at a guessed size, measure its box, and render
|
|
6
|
+
* again, and a chart behind a lazy import arrives whenever its chunk does. So
|
|
7
|
+
* nothing here waits a fixed time. The figure is watched frame by frame, and
|
|
8
|
+
* it is taken the moment it has stood still for two frames running.
|
|
9
|
+
*/
|
|
10
|
+
/** How the wait is run. */
|
|
11
|
+
export interface FigureSettleOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Stops the wait, for a panel closed or a page left while the figure is
|
|
14
|
+
* still drawing.
|
|
15
|
+
* @default undefined — the wait runs to its end
|
|
16
|
+
*/
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
/**
|
|
19
|
+
* How many frames the figure is given to settle before the save is given
|
|
20
|
+
* up, about ten seconds at sixty frames a second. It is how a figure that
|
|
21
|
+
* never draws is reported, not how long a slow one is expected to take.
|
|
22
|
+
* @default 600
|
|
23
|
+
*/
|
|
24
|
+
maxFrames?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves at the next frame.
|
|
27
|
+
* @default the browser's `requestAnimationFrame`
|
|
28
|
+
*/
|
|
29
|
+
nextFrame?: () => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wait until the figure mounted in a box has finished drawing.
|
|
33
|
+
* @param element - The box the figure is being drawn in.
|
|
34
|
+
* @param options - See {@link FigureSettleOptions}.
|
|
35
|
+
* @returns Resolves once the figure has stood still.
|
|
36
|
+
* @throws {Error} When the wait is stopped, or the figure never settles.
|
|
37
|
+
*/
|
|
38
|
+
export declare function whenFigureSettles(element: Element, options?: FigureSettleOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Wait until a reading of the figure comes back the same frames in a row.
|
|
41
|
+
*
|
|
42
|
+
* The reading is whatever says the figure has changed — for a drawing on the
|
|
43
|
+
* page, how many times it was touched and the size it came out at — and
|
|
44
|
+
* `null` while there is nothing drawn yet.
|
|
45
|
+
* @param read - Takes the reading.
|
|
46
|
+
* @param options - See {@link FigureSettleOptions}.
|
|
47
|
+
* @returns Resolves once the reading has held.
|
|
48
|
+
* @throws {Error} When the wait is stopped, or the reading never holds.
|
|
49
|
+
*/
|
|
50
|
+
export declare function settle(read: () => string | null, options?: FigureSettleOptions): Promise<void>;
|
|
51
|
+
//# sourceMappingURL=figureSettle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figureSettle.d.ts","sourceRoot":"","sources":["../../../src/download/core/figureSettle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,2BAA2B;AAC3B,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAQD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,MAAM,GAAG,IAAI,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowing when a figure drawn for a file has finished drawing.
|
|
3
|
+
*
|
|
4
|
+
* A chart mounted off the page to be saved at another size does not arrive in
|
|
5
|
+
* one piece: it may render once at a guessed size, measure its box, and render
|
|
6
|
+
* again, and a chart behind a lazy import arrives whenever its chunk does. So
|
|
7
|
+
* nothing here waits a fixed time. The figure is watched frame by frame, and
|
|
8
|
+
* it is taken the moment it has stood still for two frames running.
|
|
9
|
+
*/
|
|
10
|
+
import { figureSize } from "./figureTarget.js";
|
|
11
|
+
/** How many frames in a row the figure has to hold still. */
|
|
12
|
+
const STILL_FRAMES = 2;
|
|
13
|
+
/** What {@link FigureSettleOptions.maxFrames} is unless the caller says. */
|
|
14
|
+
const DEFAULT_MAX_FRAMES = 600;
|
|
15
|
+
/**
|
|
16
|
+
* Wait until the figure mounted in a box has finished drawing.
|
|
17
|
+
* @param element - The box the figure is being drawn in.
|
|
18
|
+
* @param options - See {@link FigureSettleOptions}.
|
|
19
|
+
* @returns Resolves once the figure has stood still.
|
|
20
|
+
* @throws {Error} When the wait is stopped, or the figure never settles.
|
|
21
|
+
*/
|
|
22
|
+
export async function whenFigureSettles(element, options = {}) {
|
|
23
|
+
let changes = 0;
|
|
24
|
+
const observer = new MutationObserver(() => {
|
|
25
|
+
changes++;
|
|
26
|
+
});
|
|
27
|
+
observer.observe(element, {
|
|
28
|
+
subtree: true,
|
|
29
|
+
childList: true,
|
|
30
|
+
attributes: true,
|
|
31
|
+
characterData: true,
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
await settle(() => {
|
|
35
|
+
const size = figureSize(element);
|
|
36
|
+
return size === null ? null : `${changes}:${size.width}×${size.height}`;
|
|
37
|
+
}, options);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
observer.disconnect();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Wait until a reading of the figure comes back the same frames in a row.
|
|
45
|
+
*
|
|
46
|
+
* The reading is whatever says the figure has changed — for a drawing on the
|
|
47
|
+
* page, how many times it was touched and the size it came out at — and
|
|
48
|
+
* `null` while there is nothing drawn yet.
|
|
49
|
+
* @param read - Takes the reading.
|
|
50
|
+
* @param options - See {@link FigureSettleOptions}.
|
|
51
|
+
* @returns Resolves once the reading has held.
|
|
52
|
+
* @throws {Error} When the wait is stopped, or the reading never holds.
|
|
53
|
+
*/
|
|
54
|
+
export async function settle(read, options = {}) {
|
|
55
|
+
const { signal, maxFrames = DEFAULT_MAX_FRAMES } = options;
|
|
56
|
+
const { nextFrame = animationFrame } = options;
|
|
57
|
+
let last = null;
|
|
58
|
+
let still = 0;
|
|
59
|
+
for (let frame = 0; frame < maxFrames; frame++) {
|
|
60
|
+
// eslint-disable-next-line no-await-in-loop -- each frame is compared with the one before it
|
|
61
|
+
await nextFrame();
|
|
62
|
+
if (signal?.aborted)
|
|
63
|
+
throw new Error('The figure was not saved.');
|
|
64
|
+
const reading = read();
|
|
65
|
+
still = reading !== null && reading === last ? still + 1 : 0;
|
|
66
|
+
if (still >= STILL_FRAMES)
|
|
67
|
+
return;
|
|
68
|
+
last = reading;
|
|
69
|
+
}
|
|
70
|
+
throw new Error('The figure did not finish drawing, so nothing was saved.');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The next frame the browser paints.
|
|
74
|
+
* @returns Resolves at that frame.
|
|
75
|
+
*/
|
|
76
|
+
function animationFrame() {
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
requestAnimationFrame(() => resolve());
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=figureSettle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figureSettle.js","sourceRoot":"","sources":["../../../src/download/core/figureSettle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAwB/C,6DAA6D;AAC7D,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAgB,EAChB,UAA+B,EAAE;IAEjC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE;QACzC,OAAO,EAAE,CA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,CAAC;QAC7D,IAAI,KAAK,IAAI,YAAY;YAAE,OAAO;QAClC,IAAI,GAAG,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,qBAAqB,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -14,12 +14,18 @@ export interface FigureSvgOptions {
|
|
|
14
14
|
* @default the surface the figure is drawn on, which is the page's own
|
|
15
15
|
*/
|
|
16
16
|
background?: string;
|
|
17
|
+
/**
|
|
18
|
+
* How many times the figure on screen the document says it is. The drawing
|
|
19
|
+
* is unchanged; only the size the file opens at grows.
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
scale?: number;
|
|
17
23
|
}
|
|
18
24
|
/** A figure, as the file that leaves the page. */
|
|
19
25
|
export interface FigureSvg {
|
|
20
26
|
/** The whole SVG document, tokens resolved. */
|
|
21
27
|
markup: string;
|
|
22
|
-
/** Its width in pixels, at the size the figure was drawn. */
|
|
28
|
+
/** Its width in pixels, at the size the figure was drawn on screen. */
|
|
23
29
|
width: number;
|
|
24
30
|
/** Its height. */
|
|
25
31
|
height: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figureSvg.d.ts","sourceRoot":"","sources":["../../../src/download/core/figureSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"figureSvg.d.ts","sourceRoot":"","sources":["../../../src/download/core/figureSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAQ7D;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,GAAG,OAAO,EACxB,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CA4CX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figureSvg.js","sourceRoot":"","sources":["../../../src/download/core/figureSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"figureSvg.js","sourceRoot":"","sources":["../../../src/download/core/figureSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;AA4B3B,gFAAgF;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own default
|
|
52
52
|
*/
|
|
53
53
|
fontSize?: number;
|
|
54
|
+
/**
|
|
55
|
+
* How many times the figure on screen the document says it is. Only the
|
|
56
|
+
* size it opens at changes — the drawing keeps its own coordinates, so every
|
|
57
|
+
* line and every word grows together and stays as sharp as before.
|
|
58
|
+
* @default 1
|
|
59
|
+
*/
|
|
60
|
+
scale?: number;
|
|
54
61
|
}
|
|
55
62
|
/**
|
|
56
63
|
* Every drawing of a figure, in one standalone SVG document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figureSvgDocument.d.ts","sourceRoot":"","sources":["../../../src/download/core/figureSvgDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,CAAC,EAAE,MAAM,CAAC;IACV,gEAAgE;IAChE,CAAC,EAAE,MAAM,CAAC;IACV;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC7B;AAED,mDAAmD;AACnD,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"figureSvgDocument.d.ts","sourceRoot":"","sources":["../../../src/download/core/figureSvgDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,CAAC,EAAE,MAAM,CAAC;IACV,gEAAgE;IAChE,CAAC,EAAE,MAAM,CAAC;IACV;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC7B;AAED,mDAAmD;AACnD,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,EAAE,wBAAwB,GAChC,MAAM,CAsBR"}
|
|
@@ -21,7 +21,8 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
|
21
21
|
* @returns The document, ready to be saved or rendered.
|
|
22
22
|
*/
|
|
23
23
|
export function figureSvgDocument(pieces, options) {
|
|
24
|
-
const { width, height, background, fontFamily, fontSize } = options;
|
|
24
|
+
const { width, height, background, fontFamily, fontSize, scale } = options;
|
|
25
|
+
const factor = positiveOrOne(scale);
|
|
25
26
|
const box = `0 0 ${round(width)} ${round(height)}`;
|
|
26
27
|
const style = documentStyle(fontFamily, fontSize);
|
|
27
28
|
let inside = background === undefined || background === ''
|
|
@@ -34,7 +35,7 @@ export function figureSvgDocument(pieces, options) {
|
|
|
34
35
|
`${piece.markup}</g>`;
|
|
35
36
|
}
|
|
36
37
|
return (`<?xml version="1.0" encoding="UTF-8"?>` +
|
|
37
|
-
`<svg xmlns="${SVG_NAMESPACE}" width="${round(width)}" height="${round(height)}" viewBox="${box}"${style}>` +
|
|
38
|
+
`<svg xmlns="${SVG_NAMESPACE}" width="${round(width * factor)}" height="${round(height * factor)}" viewBox="${box}"${style}>` +
|
|
38
39
|
`${inside}</svg>`);
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
@@ -55,6 +56,14 @@ function documentStyle(fontFamily, fontSize) {
|
|
|
55
56
|
? ''
|
|
56
57
|
: ` style="${escapeAttribute(rules.join(';'))}"`;
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* A multiple that makes sense, or one.
|
|
61
|
+
* @param value - The multiple asked for.
|
|
62
|
+
* @returns It, where it is a positive number; one otherwise.
|
|
63
|
+
*/
|
|
64
|
+
function positiveOrOne(value) {
|
|
65
|
+
return value !== undefined && Number.isFinite(value) && value > 0 ? value : 1;
|
|
66
|
+
}
|
|
58
67
|
/**
|
|
59
68
|
* A number as an attribute reads it: whole pixels where it is one, and two
|
|
60
69
|
* decimals otherwise, because a serialized figure carrying sixteen digits per
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figureSvgDocument.js","sourceRoot":"","sources":["../../../src/download/core/figureSvgDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"figureSvgDocument.js","sourceRoot":"","sources":["../../../src/download/core/figureSvgDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoDH,6CAA6C;AAC7C,uJAAuJ;AACvJ,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA8B,EAC9B,OAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC3E,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ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AAC;AACrD,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -3,9 +3,13 @@ export { downloadBlob } from './downloadBlob.ts';
|
|
|
3
3
|
export type { DownloadFigureOptions, FigureFormat } from './downloadFigure.ts';
|
|
4
4
|
export { downloadFigure } from './downloadFigure.ts';
|
|
5
5
|
export { downloadText } from './downloadText.ts';
|
|
6
|
+
export type { FigureLayout } from './figureLayout.ts';
|
|
7
|
+
export { FIGURE_COLUMN_WIDTH, FIGURE_LAYOUTS, FIGURE_LAYOUT_MAX, FIGURE_LAYOUT_MIN, figureLayoutRedraws, figureLayoutSide, figureLayoutSize, } from './figureLayout.ts';
|
|
6
8
|
export { FIGURE_PNG_TYPE, figurePng } from './figurePng.ts';
|
|
9
|
+
export type { FigureSettleOptions } from './figureSettle.ts';
|
|
10
|
+
export { whenFigureSettles } from './figureSettle.ts';
|
|
7
11
|
export type { FigurePixels } from './figureScale.ts';
|
|
8
|
-
export { DEFAULT_FIGURE_SCALE, FIGURE_MAX_PIXELS, FIGURE_SCALES, figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, } from './figureScale.ts';
|
|
12
|
+
export { DEFAULT_FIGURE_SCALE, FIGURE_MAX_PIXELS, FIGURE_SCALES, defaultFigureScale, figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, } from './figureScale.ts';
|
|
9
13
|
export type { FigureSvg, FigureSvgOptions } from './figureSvg.ts';
|
|
10
14
|
export { FIGURE_SVG_TYPE, figureSvg } from './figureSvg.ts';
|
|
11
15
|
export type { FigurePiece, FigureSvgDocumentOptions, } from './figureSvgDocument.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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;AACjD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC5D,YAAY,EACV,WAAW,EACX,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wB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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,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;AAEjD,OAAO,EACL,mBAAmB,EACnB,cAAc,E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AAkB,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;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC;IACzE,MAAM,EAAE,aAAa,GAAG,KAAK,EAAE,YAAY,GAAG,oBAAoB,EAAE,GAAG,KAAK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ACd,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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAS1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"FigureDownloadPanel.d.ts","sourceRoot":"","sources":["../../../src/download/ui/FigureDownloadPanel.tsx"],"names":[],"mappings":"AAAA,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