react-cheminfo 0.34.0 → 0.35.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.
Files changed (171) hide show
  1. package/README.md +28 -28
  2. package/lib/about/core/about.d.ts +1 -30
  3. package/lib/about/core/about.d.ts.map +1 -1
  4. package/lib/about/core/about.js +0 -16
  5. package/lib/about/core/about.js.map +1 -1
  6. package/lib/about/core/index.d.ts +0 -1
  7. package/lib/about/core/index.d.ts.map +1 -1
  8. package/lib/about/core/index.js +0 -1
  9. package/lib/about/core/index.js.map +1 -1
  10. package/lib/about/ui/AboutBuild.d.ts +2 -5
  11. package/lib/about/ui/AboutBuild.d.ts.map +1 -1
  12. package/lib/about/ui/AboutBuild.js +7 -19
  13. package/lib/about/ui/AboutBuild.js.map +1 -1
  14. package/lib/about/ui/AboutPage.d.ts +2 -2
  15. package/lib/about/ui/AboutPage.d.ts.map +1 -1
  16. package/lib/about/ui/AboutPage.js +3 -14
  17. package/lib/about/ui/AboutPage.js.map +1 -1
  18. package/lib/about/ui/AboutVersion.d.ts +0 -4
  19. package/lib/about/ui/AboutVersion.d.ts.map +1 -1
  20. package/lib/about/ui/AboutVersion.js +3 -31
  21. package/lib/about/ui/AboutVersion.js.map +1 -1
  22. package/lib/download/core/index.d.ts +0 -5
  23. package/lib/download/core/index.d.ts.map +1 -1
  24. package/lib/download/core/index.js +0 -3
  25. package/lib/download/core/index.js.map +1 -1
  26. package/lib/download/ui/FigureDownload.d.ts +4 -55
  27. package/lib/download/ui/FigureDownload.d.ts.map +1 -1
  28. package/lib/download/ui/FigureDownload.js +6 -66
  29. package/lib/download/ui/FigureDownload.js.map +1 -1
  30. package/lib/download/ui/FigureDownloadPanel.d.ts +16 -2
  31. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  32. package/lib/download/ui/FigureDownloadPanel.js +11 -30
  33. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  34. package/lib/download/ui/figureDownloadHint.d.ts +30 -0
  35. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -0
  36. package/lib/download/ui/figureDownloadHint.js +33 -0
  37. package/lib/download/ui/figureDownloadHint.js.map +1 -0
  38. package/lib/download/ui/index.d.ts +3 -10
  39. package/lib/download/ui/index.d.ts.map +1 -1
  40. package/lib/download/ui/index.js +1 -5
  41. package/lib/download/ui/index.js.map +1 -1
  42. package/lib/download/ui/useFigureActions.d.ts +50 -0
  43. package/lib/download/ui/useFigureActions.d.ts.map +1 -0
  44. package/lib/download/ui/useFigureActions.js +58 -0
  45. package/lib/download/ui/useFigureActions.js.map +1 -0
  46. package/lib/download/ui/useFigureDownload.d.ts +85 -0
  47. package/lib/download/ui/useFigureDownload.d.ts.map +1 -0
  48. package/lib/download/ui/useFigureDownload.js +75 -0
  49. package/lib/download/ui/useFigureDownload.js.map +1 -0
  50. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  51. package/lib/ecosystem/core/sites.js +0 -40
  52. package/lib/ecosystem/core/sites.js.map +1 -1
  53. package/lib/ecosystem/core/types.d.ts +0 -10
  54. package/lib/ecosystem/core/types.d.ts.map +1 -1
  55. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  56. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  57. package/lib/ir/core/irCommands.d.ts +2 -2
  58. package/lib/ir/core/irCommands.js +2 -2
  59. package/lib/ir/core/irCommands.js.map +1 -1
  60. package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
  61. package/lib/ir/ui/IrAboutDialog.js +1 -1
  62. package/lib/ir/ui/IrAboutDialog.js.map +1 -1
  63. package/lib/ir/ui/IrCanvas.d.ts +6 -0
  64. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  65. package/lib/ir/ui/IrCanvas.js +2 -2
  66. package/lib/ir/ui/IrCanvas.js.map +1 -1
  67. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  68. package/lib/ir/ui/IrShell.js +16 -11
  69. package/lib/ir/ui/IrShell.js.map +1 -1
  70. package/lib/ir/ui/IrToolbar.d.ts +11 -1
  71. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  72. package/lib/ir/ui/IrToolbar.js +12 -2
  73. package/lib/ir/ui/IrToolbar.js.map +1 -1
  74. package/lib/ir/ui/index.d.ts +1 -0
  75. package/lib/ir/ui/index.d.ts.map +1 -1
  76. package/lib/ir/ui/index.js.map +1 -1
  77. package/lib/locales/de.json +2 -4
  78. package/lib/locales/en.json +2 -4
  79. package/lib/locales/es.json +2 -4
  80. package/lib/locales/fr.json +2 -4
  81. package/lib/locales/it.json +2 -4
  82. package/lib/overlay/ui/OverlayPanel.d.ts +6 -0
  83. package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
  84. package/lib/overlay/ui/OverlayPanel.js +2 -2
  85. package/lib/overlay/ui/OverlayPanel.js.map +1 -1
  86. package/lib/overlay/ui/overlayPanelStyles.d.ts +2 -1
  87. package/lib/overlay/ui/overlayPanelStyles.d.ts.map +1 -1
  88. package/lib/overlay/ui/overlayPanelStyles.js +3 -1
  89. package/lib/overlay/ui/overlayPanelStyles.js.map +1 -1
  90. package/lib/periodic/ui/ElementCell.d.ts +0 -6
  91. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  92. package/lib/periodic/ui/ElementCell.js +34 -30
  93. package/lib/periodic/ui/ElementCell.js.map +1 -1
  94. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  95. package/lib/periodic/ui/PeriodicTable.js +12 -15
  96. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  97. package/package.json +1 -1
  98. package/src/about/core/about.ts +1 -51
  99. package/src/about/core/index.ts +0 -1
  100. package/src/about/ui/AboutBuild.tsx +8 -37
  101. package/src/about/ui/AboutPage.tsx +8 -64
  102. package/src/about/ui/AboutVersion.tsx +5 -45
  103. package/src/download/core/index.ts +0 -25
  104. package/src/download/ui/FigureDownload.tsx +11 -148
  105. package/src/download/ui/FigureDownloadPanel.tsx +46 -45
  106. package/src/download/ui/figureDownloadHint.ts +52 -0
  107. package/src/download/ui/index.ts +6 -10
  108. package/src/download/ui/useFigureActions.ts +113 -0
  109. package/src/download/ui/useFigureDownload.tsx +191 -0
  110. package/src/ecosystem/core/sites.ts +0 -40
  111. package/src/ecosystem/core/types.ts +0 -10
  112. package/src/ir/core/irCommands.ts +2 -2
  113. package/src/ir/ui/IrAboutDialog.tsx +0 -13
  114. package/src/ir/ui/IrCanvas.tsx +8 -2
  115. package/src/ir/ui/IrShell.tsx +23 -25
  116. package/src/ir/ui/IrToolbar.tsx +36 -6
  117. package/src/ir/ui/index.ts +1 -0
  118. package/src/locales/de.json +2 -4
  119. package/src/locales/en.json +2 -4
  120. package/src/locales/es.json +2 -4
  121. package/src/locales/fr.json +2 -4
  122. package/src/locales/it.json +2 -4
  123. package/src/overlay/ui/OverlayPanel.tsx +8 -2
  124. package/src/overlay/ui/overlayPanelStyles.ts +3 -0
  125. package/src/periodic/ui/ElementCell.tsx +34 -37
  126. package/src/periodic/ui/PeriodicTable.tsx +12 -17
  127. package/lib/about/core/repository.d.ts +0 -14
  128. package/lib/about/core/repository.d.ts.map +0 -1
  129. package/lib/about/core/repository.js +0 -21
  130. package/lib/about/core/repository.js.map +0 -1
  131. package/lib/download/core/exportStyles.d.ts +0 -22
  132. package/lib/download/core/exportStyles.d.ts.map +0 -1
  133. package/lib/download/core/exportStyles.js +0 -19
  134. package/lib/download/core/exportStyles.js.map +0 -1
  135. package/lib/download/core/imageResolution.d.ts +0 -88
  136. package/lib/download/core/imageResolution.d.ts.map +0 -1
  137. package/lib/download/core/imageResolution.js +0 -77
  138. package/lib/download/core/imageResolution.js.map +0 -1
  139. package/lib/download/core/pictureExport.d.ts +0 -93
  140. package/lib/download/core/pictureExport.d.ts.map +0 -1
  141. package/lib/download/core/pictureExport.js +0 -116
  142. package/lib/download/core/pictureExport.js.map +0 -1
  143. package/lib/download/ui/ExportDialogFrame.d.ts +0 -46
  144. package/lib/download/ui/ExportDialogFrame.d.ts.map +0 -1
  145. package/lib/download/ui/ExportDialogFrame.js +0 -24
  146. package/lib/download/ui/ExportDialogFrame.js.map +0 -1
  147. package/lib/download/ui/ExportImageDialog.d.ts +0 -47
  148. package/lib/download/ui/ExportImageDialog.d.ts.map +0 -1
  149. package/lib/download/ui/ExportImageDialog.js +0 -25
  150. package/lib/download/ui/ExportImageDialog.js.map +0 -1
  151. package/lib/download/ui/ExportNameField.d.ts +0 -29
  152. package/lib/download/ui/ExportNameField.d.ts.map +0 -1
  153. package/lib/download/ui/ExportNameField.js +0 -99
  154. package/lib/download/ui/ExportNameField.js.map +0 -1
  155. package/lib/download/ui/ExportPictureSection.d.ts +0 -38
  156. package/lib/download/ui/ExportPictureSection.d.ts.map +0 -1
  157. package/lib/download/ui/ExportPictureSection.js +0 -48
  158. package/lib/download/ui/ExportPictureSection.js.map +0 -1
  159. package/lib/download/ui/useDrawingBox.d.ts +0 -23
  160. package/lib/download/ui/useDrawingBox.d.ts.map +0 -1
  161. package/lib/download/ui/useDrawingBox.js +0 -21
  162. package/lib/download/ui/useDrawingBox.js.map +0 -1
  163. package/src/about/core/repository.ts +0 -22
  164. package/src/download/core/exportStyles.ts +0 -20
  165. package/src/download/core/imageResolution.ts +0 -118
  166. package/src/download/core/pictureExport.ts +0 -207
  167. package/src/download/ui/ExportDialogFrame.tsx +0 -86
  168. package/src/download/ui/ExportImageDialog.tsx +0 -91
  169. package/src/download/ui/ExportNameField.tsx +0 -148
  170. package/src/download/ui/ExportPictureSection.tsx +0 -142
  171. package/src/download/ui/useDrawingBox.ts +0 -37
@@ -1,55 +1,13 @@
1
1
  import type { IconName } from '@blueprintjs/core';
2
2
  import type { ReactElement } from 'react';
3
- import type { FigureFormat } from '../core/downloadFigure.ts';
4
- import type { FigureRenderer } from './useFigureRedraw.tsx';
3
+ import type { FigureDownloadOptions } from './useFigureDownload.tsx';
5
4
  /** What {@link FigureDownload} needs. */
6
- export interface FigureDownloadProps {
7
- /**
8
- * The `id` of the box the figure is mounted in. Everything drawn inside it
9
- * is saved — sixteen charts of a pair grid as readily as one scatter plot —
10
- * and the controls floating over it are left behind.
11
- */
12
- targetId: string;
13
- /**
14
- * What the saved file is called, without its extension. Name it after the
15
- * data rather than after the tool: a reader with four of these in a
16
- * downloads folder cannot tell four `figure.png` apart.
17
- * @default 'figure'
18
- */
19
- fileName?: string;
20
- /**
21
- * The format it opens on.
22
- * @default 'png'
23
- */
24
- defaultFormat?: FigureFormat;
25
- /**
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.
29
- * @default 2
30
- */
31
- defaultScale?: number;
32
- /**
33
- * The resolutions offered.
34
- * @default [1, 2, 3, 4]
35
- */
36
- scales?: readonly number[];
37
- /**
38
- * What is painted under the figure. `transparent` leaves it unpainted, for a
39
- * figure going onto a coloured slide.
40
- * @default the surface the figure is drawn on
41
- */
42
- background?: string;
5
+ export interface FigureDownloadProps extends FigureDownloadOptions {
43
6
  /**
44
7
  * What the glyph is called, for the pointer and for a screen reader.
45
8
  * @default the chrome's own line, in the language of the page
46
9
  */
47
10
  label?: string;
48
- /**
49
- * What the panel behind it is called.
50
- * @default the chrome's own line, in the language of the page
51
- */
52
- title?: string;
53
11
  /**
54
12
  * Its glyph.
55
13
  * @default 'download'
@@ -60,19 +18,10 @@ export interface FigureDownloadProps {
60
18
  * @default undefined
61
19
  */
62
20
  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;
73
21
  }
74
22
  /**
75
- * The glyph that takes the figure off the page as a file.
23
+ * The glyph that takes the figure off the page, as a file or onto the
24
+ * clipboard.
76
25
  *
77
26
  * It works from the `id` of the box the figure is mounted in rather than from
78
27
  * the figure itself, so the control is free to sit in the bar above the
@@ -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;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
+ {"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,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,yCAAyC;AACzC,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAyBvE"}
@@ -1,16 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PopoverNext } from '@blueprintjs/core';
3
- import { useState } from 'react';
4
3
  import { useChromeT } from "../../i18n/ui/useT.js";
5
4
  import { OverlayIconButton } from "../../overlay/ui/OverlayIconButton.js";
6
- import { downloadFigure } from "../core/downloadFigure.js";
7
- import { figureLayoutRedraws, figureLayoutSize } from "../core/figureLayout.js";
8
- import { DEFAULT_FIGURE_SCALE, FIGURE_SCALES, defaultFigureScale, } from "../core/figureScale.js";
9
- import { figureSize } from "../core/figureTarget.js";
10
- import { FigureDownloadPanel } from "./FigureDownloadPanel.js";
11
- import { useFigureRedraw } from "./useFigureRedraw.js";
5
+ import { useFigureDownload } from "./useFigureDownload.js";
12
6
  /**
13
- * The glyph that takes the figure off the page as a file.
7
+ * The glyph that takes the figure off the page, as a file or onto the
8
+ * clipboard.
14
9
  *
15
10
  * It works from the `id` of the box the figure is mounted in rather than from
16
11
  * the figure itself, so the control is free to sit in the bar above the
@@ -30,64 +25,9 @@ import { useFigureRedraw } from "./useFigureRedraw.js";
30
25
  * @returns The glyph and its panel.
31
26
  */
32
27
  export function FigureDownload(props) {
33
- const { targetId, fileName, background, scales = FIGURE_SCALES } = props;
34
- const { defaultFormat = 'png', defaultScale = DEFAULT_FIGURE_SCALE } = props;
35
- const { label, title } = props;
36
- const { icon = 'download', testId, renderFigure } = props;
28
+ const { label, icon = 'download', testId, ...options } = props;
37
29
  const t = useChromeT();
38
- const [open, setOpen] = useState(false);
39
- const [format, setFormat] = useState(defaultFormat);
40
- const [picked, setPicked] = useState(() => ({
41
- png: defaultScale,
42
- svg: defaultFigureScale('svg'),
43
- }));
44
- const scale = picked[format];
45
- const [size, setSize] = useState(null);
46
- const [failure, setFailure] = useState(null);
47
- const [saving, setSaving] = useState(false);
48
- const [layout, setLayout] = useState('screen');
49
- const [custom, setCustom] = useState(null);
50
- const { redraw, portal } = useFigureRedraw(renderFigure);
51
- // The panel is held open from here rather than left to itself, because the
52
- // figure has to be measured at the moment it opens: its size is what the
53
- // panel writes out, and reading a bounding box on every render would cost a
54
- // layout pass on a bar that is re-rendered on every pointer move.
55
- function interact(next) {
56
- setOpen(next);
57
- if (!next)
58
- return;
59
- setSize(figureSize(targetId));
60
- setFailure(null);
61
- }
62
- async function save() {
63
- setSaving(true);
64
- try {
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
- }
75
- setFailure(null);
76
- }
77
- catch (error) {
78
- setFailure(error instanceof Error ? error.message : String(error));
79
- }
80
- finally {
81
- setSaving(false);
82
- }
83
- }
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] }));
30
+ const { isOpen, setOpen, panel, format, portal } = useFigureDownload(options);
31
+ return (_jsxs(_Fragment, { children: [_jsx(PopoverNext, { isOpen: isOpen, placement: "bottom-end", onInteraction: setOpen, content: panel, children: _jsx(OverlayIconButton, { icon: icon, label: label ?? t('download.saveThisFigure'), value: format.toUpperCase(), active: isOpen, testId: testId, opensMenu: true }) }), portal] }));
92
32
  }
93
33
  //# 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,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,QAA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;AAqB5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE9E,OAAO,CACL,8BACE,KAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAC,YAAY,EACtB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,KAAK,YAEd,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,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,SACT,GACU,EACb,MAAM,IACN,CACJ,CAAC;AACJ,CAAC"}
@@ -2,6 +2,7 @@ import type { ReactElement } from 'react';
2
2
  import type { FigureFormat } from '../core/downloadFigure.ts';
3
3
  import type { FigurePixels } from '../core/figureScale.ts';
4
4
  import type { FigureSizing } from './FigureSizeRows.tsx';
5
+ import type { FigureNotice } from './useFigureActions.ts';
5
6
  /** What {@link FigureDownloadPanel} is drawn from. */
6
7
  export interface FigureDownloadPanelProps {
7
8
  /** What the panel is called. */
@@ -16,7 +17,13 @@ export interface FigureDownloadPanelProps {
16
17
  size: FigurePixels | null;
17
18
  /** What went wrong the last time save was pressed, if anything. */
18
19
  failure: string | null;
19
- /** Whether a file is being written right now. */
20
+ /**
21
+ * What the last copy came to, while the choices it was made with still
22
+ * stand.
23
+ * @default null
24
+ */
25
+ notice?: FigureNotice | null;
26
+ /** Whether a file or a copy is being written right now. */
20
27
  saving: boolean;
21
28
  /** Called with the format the reader picked. */
22
29
  onFormatChange: (format: FigureFormat) => void;
@@ -24,6 +31,12 @@ export interface FigureDownloadPanelProps {
24
31
  onScaleChange: (scale: number) => void;
25
32
  /** Called when they press save. */
26
33
  onSave: () => void;
34
+ /**
35
+ * Called when they press copy, which puts a PNG at the resolution picked on
36
+ * the clipboard.
37
+ * @default undefined — no copy is offered
38
+ */
39
+ onCopy?: () => void;
27
40
  /**
28
41
  * Whether the SVG holds a rendered picture rather than vector drawings, as
29
42
  * for a WebGL scene: its resolution is then the pixels of that picture, it
@@ -40,7 +53,8 @@ export interface FigureDownloadPanelProps {
40
53
  sizing?: FigureSizing;
41
54
  }
42
55
  /**
43
- * The choices behind the save glyph, and the button that writes the file.
56
+ * The choices behind the save glyph, and the buttons that write the file and
57
+ * copy the picture.
44
58
  *
45
59
  * The resolution applies to both formats, and means what the reader needs it
46
60
  * to: a PNG is painted with that many more pixels, and an SVG, drawn the same,
@@ -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;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQ3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,sDAAsD;AACtD,MAAM,WAAW,wBAAwB;IACvC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,YAAY,CAAC;IACrB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,wEAAwE;IACxE,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IA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,IAAI,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,2DAA2D;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,gDAAgD;IAChD,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,4CAA4C;IAC5C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,mCAAmC;IACnC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,YAAY,CAuEd"}
@@ -1,4 +1,4 @@
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 { useChromeT } from "../../i18n/ui/useT.js";
3
3
  import { OverlayAction } from "../../overlay/ui/OverlayAction.js";
4
4
  import { OverlayPanel } from "../../overlay/ui/OverlayPanel.js";
@@ -6,8 +6,10 @@ import { OverlaySegmented } from "../../overlay/ui/OverlaySegmented.js";
6
6
  import { figureLayoutSize } from "../core/figureLayout.js";
7
7
  import { figurePixels, figureScaleFits, figureScaleLabel, formatFigurePixels, } from "../core/figureScale.js";
8
8
  import { FigureSizeRows } from "./FigureSizeRows.js";
9
+ import { hintOf } from "./figureDownloadHint.js";
9
10
  /**
10
- * The choices behind the save glyph, and the button that writes the file.
11
+ * The choices behind the save glyph, and the buttons that write the file and
12
+ * copy the picture.
11
13
  *
12
14
  * The resolution applies to both formats, and means what the reader needs it
13
15
  * to: a PNG is painted with that many more pixels, and an SVG, drawn the same,
@@ -27,14 +29,14 @@ import { FigureSizeRows } from "./FigureSizeRows.js";
27
29
  export function FigureDownloadPanel(props) {
28
30
  const { title, format, scale, scales, size, failure, saving } = props;
29
31
  const { onFormatChange, onScaleChange, onSave, rasterSvg = false } = props;
30
- const { sizing } = props;
32
+ const { sizing, onCopy, notice = null } = props;
31
33
  const t = useChromeT();
32
34
  // What the file is drawn at: the figure on screen, or the shape picked.
33
35
  const drawn = size === null || sizing === undefined
34
36
  ? size
35
37
  : figureLayoutSize(sizing.layout, size, sizing.custom ?? size);
36
38
  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: {
39
+ return (_jsxs(OverlayPanel, { title: title, width: PANEL_WIDTH, hint: hintOf({ format, size: drawn, scale, failure, notice, rasterSvg }, t), actions: _jsxs(_Fragment, { children: [_jsx(OverlayAction, { text: t('download.save'), icon: "download", intent: "primary", disabled: saving || size === null, onClick: onSave }), onCopy === undefined ? null : (_jsx(OverlayAction, { text: t('clipboard.copy'), icon: "clipboard", disabled: saving || size === null, onClick: onCopy }))] }), children: [_jsx(OverlaySegmented, { label: t('download.format'), help: {
38
40
  title: t('download.format'),
39
41
  body: t('download.formatHelp'),
40
42
  }, value: format, options: FORMAT_CHOICES, onChange: onFormatChange }), sizing === undefined ? null : (_jsx(FigureSizeRows, { sizing: sizing, size: size })), _jsx(OverlaySegmented, { label: t('download.resolution'), help: {
@@ -46,6 +48,11 @@ export function FigureDownloadPanel(props) {
46
48
  },
47
49
  }, value: String(scale), options: scaleChoices(scales, drawn, painted), onChange: (picked) => onScaleChange(Number(picked)) })] }));
48
50
  }
51
+ /**
52
+ * Wide enough for the longest hint on one line in English, so switching
53
+ * between PNG and SVG — whose hints differ in length — never resizes the panel.
54
+ */
55
+ const PANEL_WIDTH = '27em';
49
56
  /** The two files a figure can leave the page as. */
50
57
  const FORMAT_CHOICES = [
51
58
  { value: 'png', label: 'PNG' },
@@ -75,30 +82,4 @@ function scaleChoices(scales, size, painted) {
75
82
  }
76
83
  return choices;
77
84
  }
78
- /**
79
- * The line at the foot of the panel: what pressing save is about to do.
80
- * @param format - Which file the reader is about to write.
81
- * @param size - How big the figure is drawn for the file.
82
- * @param scale - The multiple it is saved at.
83
- * @param failure - What went wrong last time, if anything.
84
- * @param rasterSvg - Whether the SVG embeds a rendered picture.
85
- * @param t - The chrome's formatter, so the sentence is in the language of
86
- * the page.
87
- * @returns The sentence.
88
- */
89
- function hintOf(format, size, scale, failure, rasterSvg, t) {
90
- if (failure !== null)
91
- return failure;
92
- if (size === null)
93
- return t('download.noFigure');
94
- if (format === 'svg' && rasterSvg) {
95
- return t('download.hintRasterSvg', {
96
- pixels: formatFigurePixels(figurePixels(size, scale)),
97
- });
98
- }
99
- const pixels = formatFigurePixels(figurePixels(size, scale));
100
- return format === 'svg'
101
- ? t('download.hintSvg', { pixels })
102
- : t('download.hintPng', { pixels });
103
- }
104
85
  //# 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;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,MAA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AAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAC7C,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GACnD,IACW,CAChB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG,MAAM,CAAC;AAE3B,oDAAoD;AACpD,MAAM,cAAc,GAA+C;IACjE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CAC/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,SAAS,YAAY,CACnB,MAAyB,EACzB,IAAyB,EACzB,OAAgB;IAEhB,MAAM,OAAO,GAAoB,EAAE,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC;YACX,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;YACpB,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;YAC9B,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC/D,QAAQ,EAAE,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;SACpE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { ChromeKey } from '../../i18n/core/chromeCatalog.ts';
2
+ import type { Translate } from '../../i18n/ui/useT.ts';
3
+ import type { FigureFormat } from '../core/downloadFigure.ts';
4
+ import type { FigurePixels } from '../core/figureScale.ts';
5
+ import type { FigureNotice } from './useFigureActions.ts';
6
+ /** What the line at the foot of the panel is written from. */
7
+ export interface HintState {
8
+ /** Which file the reader is about to write. */
9
+ format: FigureFormat;
10
+ /** How big the figure is drawn for the file. */
11
+ size: FigurePixels | null;
12
+ /** The multiple it is saved at. */
13
+ scale: number;
14
+ /** What went wrong last time, if anything. */
15
+ failure: string | null;
16
+ /** What the last copy came to, if anything. */
17
+ notice: FigureNotice | null;
18
+ /** Whether the SVG embeds a rendered picture. */
19
+ rasterSvg: boolean;
20
+ }
21
+ /**
22
+ * The line at the foot of the panel: what pressing save is about to do, or
23
+ * what the last copy did.
24
+ * @param state - See {@link HintState}.
25
+ * @param t - The chrome's formatter, so the sentence is in the language of
26
+ * the page.
27
+ * @returns The sentence.
28
+ */
29
+ export declare function hintOf(state: HintState, t: Translate<ChromeKey>): string;
30
+ //# sourceMappingURL=figureDownloadHint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figureDownloadHint.d.ts","sourceRoot":"","sources":["../../../src/download/ui/figureDownloadHint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,8DAA8D;AAC9D,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,MAAM,EAAE,YAAY,CAAC;IACrB,gDAAgD;IAChD,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,+CAA+C;IAC/C,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,MAAM,CAmBxE"}
@@ -0,0 +1,33 @@
1
+ import { figurePixels, formatFigurePixels } from "../core/figureScale.js";
2
+ /**
3
+ * The line at the foot of the panel: what pressing save is about to do, or
4
+ * what the last copy did.
5
+ * @param state - See {@link HintState}.
6
+ * @param t - The chrome's formatter, so the sentence is in the language of
7
+ * the page.
8
+ * @returns The sentence.
9
+ */
10
+ export function hintOf(state, t) {
11
+ const { format, size, scale, failure, notice, rasterSvg } = state;
12
+ if (failure !== null)
13
+ return failure;
14
+ if (size === null)
15
+ return t('download.noFigure');
16
+ if (notice === 'copyUnsupported')
17
+ return t('download.copyUnsupported');
18
+ if (notice === 'copied') {
19
+ return t('download.hintCopied', {
20
+ pixels: formatFigurePixels(figurePixels(size, scale)),
21
+ });
22
+ }
23
+ if (format === 'svg' && rasterSvg) {
24
+ return t('download.hintRasterSvg', {
25
+ pixels: formatFigurePixels(figurePixels(size, scale)),
26
+ });
27
+ }
28
+ const pixels = formatFigurePixels(figurePixels(size, scale));
29
+ return format === 'svg'
30
+ ? t('download.hintSvg', { pixels })
31
+ : t('download.hintPng', { pixels });
32
+ }
33
+ //# sourceMappingURL=figureDownloadHint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figureDownloadHint.js","sourceRoot":"","sources":["../../../src/download/ui/figureDownloadHint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAoB1E;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,KAAgB,EAAE,CAAuB;IAC9D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAClE,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IACrC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC;IACjD,IAAI,MAAM,KAAK,iBAAiB;QAAE,OAAO,CAAC,CAAC,0BAA0B,CAAC,CAAC;IACvE,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC,qBAAqB,EAAE;YAC9B,MAAM,EAAE,kBAAkB,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IACD,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"}
@@ -12,14 +12,7 @@ export type { FigureDownloadPanelProps } from './FigureDownloadPanel.tsx';
12
12
  export { FigureDownloadPanel } from './FigureDownloadPanel.tsx';
13
13
  export type { FigureSizing } from './FigureSizeRows.tsx';
14
14
  export type { FigureRenderer } from './useFigureRedraw.tsx';
15
- export type { ExportDialogFrameProps } from './ExportDialogFrame.tsx';
16
- export { ExportDialogFrame } from './ExportDialogFrame.tsx';
17
- export type { ExportImageDialogProps } from './ExportImageDialog.tsx';
18
- export { ExportImageDialog } from './ExportImageDialog.tsx';
19
- export type { ExportNameFieldProps } from './ExportNameField.tsx';
20
- export { ExportNameField } from './ExportNameField.tsx';
21
- export type { ExportPictureSectionProps } from './ExportPictureSection.tsx';
22
- export { ExportPictureSection } from './ExportPictureSection.tsx';
23
- export type { DrawingBox } from './useDrawingBox.ts';
24
- export { useDrawingBox } from './useDrawingBox.ts';
15
+ export type { FigureDownloadOptions, FigureDownloadState, } from './useFigureDownload.tsx';
16
+ export { useFigureDownload } from './useFigureDownload.tsx';
17
+ export type { FigureNotice } from './useFigureActions.ts';
25
18
  //# sourceMappingURL=index.d.ts.map
@@ -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;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"}
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,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
@@ -8,9 +8,5 @@
8
8
  */
9
9
  export { FigureDownload } from "./FigureDownload.js";
10
10
  export { FigureDownloadPanel } from "./FigureDownloadPanel.js";
11
- export { ExportDialogFrame } from "./ExportDialogFrame.js";
12
- export { ExportImageDialog } from "./ExportImageDialog.js";
13
- export { ExportNameField } from "./ExportNameField.js";
14
- export { ExportPictureSection } from "./ExportPictureSection.js";
15
- export { useDrawingBox } from "./useDrawingBox.js";
11
+ export { useFigureDownload } from "./useFigureDownload.js";
16
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/download/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAKhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA4B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/download/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAQhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { FigureFormat } from '../core/downloadFigure.ts';
2
+ import type { FigurePixels } from '../core/figureScale.ts';
3
+ import type { FigureRedraw } from './useFigureRedraw.tsx';
4
+ /** What the last copy came to, when it is worth a line of its own. */
5
+ export type FigureNotice = 'copied' | 'copyUnsupported';
6
+ /** What {@link useFigureActions} works from. */
7
+ export interface FigureActionsOptions {
8
+ /** The `id` of the box the figure is mounted in. */
9
+ targetId: string;
10
+ /** Which file save writes. */
11
+ format: FigureFormat;
12
+ /** The multiple of the figure on screen it is painted at. */
13
+ scale: number;
14
+ /** What the saved file is called, without its extension. */
15
+ fileName?: string;
16
+ /** What is painted under the figure. */
17
+ background?: string;
18
+ /**
19
+ * The size the figure is drawn again at, off the page, or `null` to take
20
+ * the figure as it is on screen.
21
+ */
22
+ redrawAt: FigurePixels | null;
23
+ /** Draws the figure again, from {@link FigureRedraw}. */
24
+ redraw: FigureRedraw['redraw'];
25
+ }
26
+ /** What {@link useFigureActions} hands back. */
27
+ export interface FigureActions {
28
+ /** Write the figure to a file, in the format picked. */
29
+ save: () => void;
30
+ /** Put the figure on the clipboard, as a PNG at the resolution picked. */
31
+ copy: () => void;
32
+ /** Whether a file or a copy is being written right now. */
33
+ busy: boolean;
34
+ /** What went wrong the last time, if anything. */
35
+ failure: string | null;
36
+ /** What the last copy came to, if it is still what the panel describes. */
37
+ notice: FigureNotice | null;
38
+ /** Forget the last outcome, once the choices it answered have changed. */
39
+ clear: () => void;
40
+ }
41
+ /**
42
+ * The two things the figure panel does: save the figure, and copy it.
43
+ *
44
+ * A copy is always a PNG, whatever format save is set to: a clipboard carries
45
+ * a picture, and the one every slide, chat window and issue accepts is a PNG.
46
+ * @param options - See {@link FigureActionsOptions}.
47
+ * @returns See {@link FigureActions}.
48
+ */
49
+ export declare function useFigureActions(options: FigureActionsOptions): FigureActions;
50
+ //# sourceMappingURL=useFigureActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFigureActions.d.ts","sourceRoot":"","sources":["../../../src/download/ui/useFigureActions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAExD,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,yDAAyD;IACzD,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,2DAA2D;IAC3D,IAAI,EAAE,OAAO,CAAC;IACd,kDAAkD;IAClD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAqD7E"}
@@ -0,0 +1,58 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { writeImageToClipboard } from "../../clipboard/core/copyPng.js";
3
+ import { downloadFigure } from "../core/downloadFigure.js";
4
+ import { figurePng } from "../core/figurePng.js";
5
+ import { figureSvg } from "../core/figureSvg.js";
6
+ /**
7
+ * The two things the figure panel does: save the figure, and copy it.
8
+ *
9
+ * A copy is always a PNG, whatever format save is set to: a clipboard carries
10
+ * a picture, and the one every slide, chat window and issue accepts is a PNG.
11
+ * @param options - See {@link FigureActionsOptions}.
12
+ * @returns See {@link FigureActions}.
13
+ */
14
+ export function useFigureActions(options) {
15
+ const { targetId, format, scale, fileName, background } = options;
16
+ const { redrawAt, redraw } = options;
17
+ const [busy, setBusy] = useState(false);
18
+ const [failure, setFailure] = useState(null);
19
+ const [notice, setNotice] = useState(null);
20
+ function withFigure(write) {
21
+ return redrawAt === null
22
+ ? write(targetId)
23
+ : redraw(targetId, redrawAt, write);
24
+ }
25
+ function run(task) {
26
+ setBusy(true);
27
+ setFailure(null);
28
+ setNotice(null);
29
+ void task
30
+ .then(setNotice, (error) => {
31
+ setFailure(error instanceof Error ? error.message : String(error));
32
+ })
33
+ .finally(() => setBusy(false));
34
+ }
35
+ function save() {
36
+ const options = { format, scale, fileName, background };
37
+ run(withFigure((box) => downloadFigure(box, options)).then(() => null));
38
+ }
39
+ function copy() {
40
+ // The clipboard is written before anything is awaited, with the picture
41
+ // still being painted: Safari only allows a write the click itself started.
42
+ const png = new Promise((resolve, reject) => {
43
+ withFigure(async (box) => {
44
+ resolve(await figurePng(figureSvg(box, { background }), scale));
45
+ }).catch(reject);
46
+ });
47
+ // A browser whose clipboard takes text only never reads the picture, so
48
+ // its failure would otherwise go unhandled.
49
+ png.catch(() => undefined);
50
+ run(writeImageToClipboard(png).then((copied) => copied ? 'copied' : 'copyUnsupported'));
51
+ }
52
+ const clear = useCallback(() => {
53
+ setFailure(null);
54
+ setNotice(null);
55
+ }, []);
56
+ return { save, copy, busy, failure, notice, clear };
57
+ }
58
+ //# sourceMappingURL=useFigureActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFigureActions.js","sourceRoot":"","sources":["../../../src/download/ui/useFigureActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA4CjD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA6B;IAC5D,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC5D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC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