react-cheminfo 0.34.0 → 0.36.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 (225) hide show
  1. package/README.md +28 -28
  2. package/bin/check-seo.mjs +333 -0
  3. package/lib/about/core/about.d.ts +1 -30
  4. package/lib/about/core/about.d.ts.map +1 -1
  5. package/lib/about/core/about.js +0 -16
  6. package/lib/about/core/about.js.map +1 -1
  7. package/lib/about/core/index.d.ts +0 -1
  8. package/lib/about/core/index.d.ts.map +1 -1
  9. package/lib/about/core/index.js +0 -1
  10. package/lib/about/core/index.js.map +1 -1
  11. package/lib/about/ui/AboutBuild.d.ts +2 -5
  12. package/lib/about/ui/AboutBuild.d.ts.map +1 -1
  13. package/lib/about/ui/AboutBuild.js +7 -19
  14. package/lib/about/ui/AboutBuild.js.map +1 -1
  15. package/lib/about/ui/AboutPage.d.ts +2 -2
  16. package/lib/about/ui/AboutPage.d.ts.map +1 -1
  17. package/lib/about/ui/AboutPage.js +3 -14
  18. package/lib/about/ui/AboutPage.js.map +1 -1
  19. package/lib/about/ui/AboutVersion.d.ts +0 -4
  20. package/lib/about/ui/AboutVersion.d.ts.map +1 -1
  21. package/lib/about/ui/AboutVersion.js +3 -31
  22. package/lib/about/ui/AboutVersion.js.map +1 -1
  23. package/lib/download/core/index.d.ts +0 -5
  24. package/lib/download/core/index.d.ts.map +1 -1
  25. package/lib/download/core/index.js +0 -3
  26. package/lib/download/core/index.js.map +1 -1
  27. package/lib/download/ui/FigureDownload.d.ts +4 -55
  28. package/lib/download/ui/FigureDownload.d.ts.map +1 -1
  29. package/lib/download/ui/FigureDownload.js +6 -66
  30. package/lib/download/ui/FigureDownload.js.map +1 -1
  31. package/lib/download/ui/FigureDownloadPanel.d.ts +16 -2
  32. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  33. package/lib/download/ui/FigureDownloadPanel.js +11 -30
  34. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  35. package/lib/download/ui/figureDownloadHint.d.ts +30 -0
  36. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -0
  37. package/lib/download/ui/figureDownloadHint.js +33 -0
  38. package/lib/download/ui/figureDownloadHint.js.map +1 -0
  39. package/lib/download/ui/index.d.ts +3 -10
  40. package/lib/download/ui/index.d.ts.map +1 -1
  41. package/lib/download/ui/index.js +1 -5
  42. package/lib/download/ui/index.js.map +1 -1
  43. package/lib/download/ui/useFigureActions.d.ts +50 -0
  44. package/lib/download/ui/useFigureActions.d.ts.map +1 -0
  45. package/lib/download/ui/useFigureActions.js +58 -0
  46. package/lib/download/ui/useFigureActions.js.map +1 -0
  47. package/lib/download/ui/useFigureDownload.d.ts +85 -0
  48. package/lib/download/ui/useFigureDownload.d.ts.map +1 -0
  49. package/lib/download/ui/useFigureDownload.js +75 -0
  50. package/lib/download/ui/useFigureDownload.js.map +1 -0
  51. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  52. package/lib/ecosystem/core/sites.js +0 -40
  53. package/lib/ecosystem/core/sites.js.map +1 -1
  54. package/lib/ecosystem/core/types.d.ts +0 -10
  55. package/lib/ecosystem/core/types.d.ts.map +1 -1
  56. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  57. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  58. package/lib/ir/core/irCommands.d.ts +2 -2
  59. package/lib/ir/core/irCommands.js +2 -2
  60. package/lib/ir/core/irCommands.js.map +1 -1
  61. package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
  62. package/lib/ir/ui/IrAboutDialog.js +1 -1
  63. package/lib/ir/ui/IrAboutDialog.js.map +1 -1
  64. package/lib/ir/ui/IrCanvas.d.ts +6 -0
  65. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  66. package/lib/ir/ui/IrCanvas.js +2 -2
  67. package/lib/ir/ui/IrCanvas.js.map +1 -1
  68. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  69. package/lib/ir/ui/IrShell.js +16 -11
  70. package/lib/ir/ui/IrShell.js.map +1 -1
  71. package/lib/ir/ui/IrToolbar.d.ts +11 -1
  72. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  73. package/lib/ir/ui/IrToolbar.js +12 -2
  74. package/lib/ir/ui/IrToolbar.js.map +1 -1
  75. package/lib/ir/ui/index.d.ts +1 -0
  76. package/lib/ir/ui/index.d.ts.map +1 -1
  77. package/lib/ir/ui/index.js.map +1 -1
  78. package/lib/language/core/index.d.ts +2 -0
  79. package/lib/language/core/index.d.ts.map +1 -1
  80. package/lib/language/core/index.js +1 -0
  81. package/lib/language/core/index.js.map +1 -1
  82. package/lib/language/core/languagePath.d.ts +52 -0
  83. package/lib/language/core/languagePath.d.ts.map +1 -0
  84. package/lib/language/core/languagePath.js +65 -0
  85. package/lib/language/core/languagePath.js.map +1 -0
  86. package/lib/locales/de.json +2 -4
  87. package/lib/locales/en.json +2 -4
  88. package/lib/locales/es.json +2 -4
  89. package/lib/locales/fr.json +2 -4
  90. package/lib/locales/it.json +2 -4
  91. package/lib/overlay/ui/OverlayPanel.d.ts +6 -0
  92. package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
  93. package/lib/overlay/ui/OverlayPanel.js +2 -2
  94. package/lib/overlay/ui/OverlayPanel.js.map +1 -1
  95. package/lib/overlay/ui/overlayPanelStyles.d.ts +2 -1
  96. package/lib/overlay/ui/overlayPanelStyles.d.ts.map +1 -1
  97. package/lib/overlay/ui/overlayPanelStyles.js +3 -1
  98. package/lib/overlay/ui/overlayPanelStyles.js.map +1 -1
  99. package/lib/periodic/ui/ElementCell.d.ts +0 -6
  100. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  101. package/lib/periodic/ui/ElementCell.js +34 -30
  102. package/lib/periodic/ui/ElementCell.js.map +1 -1
  103. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  104. package/lib/periodic/ui/PeriodicTable.js +12 -15
  105. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  106. package/lib/seo/core/alternates.d.ts +40 -0
  107. package/lib/seo/core/alternates.d.ts.map +1 -0
  108. package/lib/seo/core/alternates.js +42 -0
  109. package/lib/seo/core/alternates.js.map +1 -0
  110. package/lib/seo/core/index.d.ts +3 -0
  111. package/lib/seo/core/index.d.ts.map +1 -1
  112. package/lib/seo/core/index.js +2 -0
  113. package/lib/seo/core/index.js.map +1 -1
  114. package/lib/seo/core/noscript.d.ts +9 -0
  115. package/lib/seo/core/noscript.d.ts.map +1 -1
  116. package/lib/seo/core/noscript.js +7 -2
  117. package/lib/seo/core/noscript.js.map +1 -1
  118. package/lib/seo/core/pageMeta.d.ts +23 -0
  119. package/lib/seo/core/pageMeta.d.ts.map +1 -1
  120. package/lib/seo/core/pageMeta.js +52 -3
  121. package/lib/seo/core/pageMeta.js.map +1 -1
  122. package/lib/seo/core/pageProse.d.ts +76 -0
  123. package/lib/seo/core/pageProse.d.ts.map +1 -0
  124. package/lib/seo/core/pageProse.js +92 -0
  125. package/lib/seo/core/pageProse.js.map +1 -0
  126. package/lib/seo/core/routeProblems.d.ts +33 -0
  127. package/lib/seo/core/routeProblems.d.ts.map +1 -0
  128. package/lib/seo/core/routeProblems.js +89 -0
  129. package/lib/seo/core/routeProblems.js.map +1 -0
  130. package/lib/seo/core/routes.d.ts +14 -0
  131. package/lib/seo/core/routes.d.ts.map +1 -1
  132. package/lib/seo/core/routes.js.map +1 -1
  133. package/lib/seo/core/siteFiles.d.ts.map +1 -1
  134. package/lib/seo/core/siteFiles.js +2 -1
  135. package/lib/seo/core/siteFiles.js.map +1 -1
  136. package/lib/seo/vite/prerender.d.ts +13 -0
  137. package/lib/seo/vite/prerender.d.ts.map +1 -1
  138. package/lib/seo/vite/prerender.js +17 -10
  139. package/lib/seo/vite/prerender.js.map +1 -1
  140. package/package.json +2 -1
  141. package/src/about/core/about.ts +1 -51
  142. package/src/about/core/index.ts +0 -1
  143. package/src/about/ui/AboutBuild.tsx +8 -37
  144. package/src/about/ui/AboutPage.tsx +8 -64
  145. package/src/about/ui/AboutVersion.tsx +5 -45
  146. package/src/download/core/index.ts +0 -25
  147. package/src/download/ui/FigureDownload.tsx +11 -148
  148. package/src/download/ui/FigureDownloadPanel.tsx +46 -45
  149. package/src/download/ui/figureDownloadHint.ts +52 -0
  150. package/src/download/ui/index.ts +6 -10
  151. package/src/download/ui/useFigureActions.ts +113 -0
  152. package/src/download/ui/useFigureDownload.tsx +191 -0
  153. package/src/ecosystem/core/sites.ts +0 -40
  154. package/src/ecosystem/core/types.ts +0 -10
  155. package/src/ir/core/irCommands.ts +2 -2
  156. package/src/ir/ui/IrAboutDialog.tsx +0 -13
  157. package/src/ir/ui/IrCanvas.tsx +8 -2
  158. package/src/ir/ui/IrShell.tsx +23 -25
  159. package/src/ir/ui/IrToolbar.tsx +36 -6
  160. package/src/ir/ui/index.ts +1 -0
  161. package/src/language/core/index.ts +2 -0
  162. package/src/language/core/languagePath.ts +78 -0
  163. package/src/locales/de.json +2 -4
  164. package/src/locales/en.json +2 -4
  165. package/src/locales/es.json +2 -4
  166. package/src/locales/fr.json +2 -4
  167. package/src/locales/it.json +2 -4
  168. package/src/overlay/ui/OverlayPanel.tsx +8 -2
  169. package/src/overlay/ui/overlayPanelStyles.ts +3 -0
  170. package/src/periodic/ui/ElementCell.tsx +34 -37
  171. package/src/periodic/ui/PeriodicTable.tsx +12 -17
  172. package/src/seo/core/alternates.ts +65 -0
  173. package/src/seo/core/index.ts +3 -0
  174. package/src/seo/core/noscript.ts +18 -2
  175. package/src/seo/core/pageMeta.ts +74 -3
  176. package/src/seo/core/pageProse.ts +146 -0
  177. package/src/seo/core/routeProblems.ts +111 -0
  178. package/src/seo/core/routes.ts +14 -0
  179. package/src/seo/core/siteFiles.ts +2 -1
  180. package/src/seo/vite/prerender.ts +30 -11
  181. package/lib/about/core/repository.d.ts +0 -14
  182. package/lib/about/core/repository.d.ts.map +0 -1
  183. package/lib/about/core/repository.js +0 -21
  184. package/lib/about/core/repository.js.map +0 -1
  185. package/lib/download/core/exportStyles.d.ts +0 -22
  186. package/lib/download/core/exportStyles.d.ts.map +0 -1
  187. package/lib/download/core/exportStyles.js +0 -19
  188. package/lib/download/core/exportStyles.js.map +0 -1
  189. package/lib/download/core/imageResolution.d.ts +0 -88
  190. package/lib/download/core/imageResolution.d.ts.map +0 -1
  191. package/lib/download/core/imageResolution.js +0 -77
  192. package/lib/download/core/imageResolution.js.map +0 -1
  193. package/lib/download/core/pictureExport.d.ts +0 -93
  194. package/lib/download/core/pictureExport.d.ts.map +0 -1
  195. package/lib/download/core/pictureExport.js +0 -116
  196. package/lib/download/core/pictureExport.js.map +0 -1
  197. package/lib/download/ui/ExportDialogFrame.d.ts +0 -46
  198. package/lib/download/ui/ExportDialogFrame.d.ts.map +0 -1
  199. package/lib/download/ui/ExportDialogFrame.js +0 -24
  200. package/lib/download/ui/ExportDialogFrame.js.map +0 -1
  201. package/lib/download/ui/ExportImageDialog.d.ts +0 -47
  202. package/lib/download/ui/ExportImageDialog.d.ts.map +0 -1
  203. package/lib/download/ui/ExportImageDialog.js +0 -25
  204. package/lib/download/ui/ExportImageDialog.js.map +0 -1
  205. package/lib/download/ui/ExportNameField.d.ts +0 -29
  206. package/lib/download/ui/ExportNameField.d.ts.map +0 -1
  207. package/lib/download/ui/ExportNameField.js +0 -99
  208. package/lib/download/ui/ExportNameField.js.map +0 -1
  209. package/lib/download/ui/ExportPictureSection.d.ts +0 -38
  210. package/lib/download/ui/ExportPictureSection.d.ts.map +0 -1
  211. package/lib/download/ui/ExportPictureSection.js +0 -48
  212. package/lib/download/ui/ExportPictureSection.js.map +0 -1
  213. package/lib/download/ui/useDrawingBox.d.ts +0 -23
  214. package/lib/download/ui/useDrawingBox.d.ts.map +0 -1
  215. package/lib/download/ui/useDrawingBox.js +0 -21
  216. package/lib/download/ui/useDrawingBox.js.map +0 -1
  217. package/src/about/core/repository.ts +0 -22
  218. package/src/download/core/exportStyles.ts +0 -20
  219. package/src/download/core/imageResolution.ts +0 -118
  220. package/src/download/core/pictureExport.ts +0 -207
  221. package/src/download/ui/ExportDialogFrame.tsx +0 -86
  222. package/src/download/ui/ExportImageDialog.tsx +0 -91
  223. package/src/download/ui/ExportNameField.tsx +0 -148
  224. package/src/download/ui/ExportPictureSection.tsx +0 -142
  225. package/src/download/ui/useDrawingBox.ts +0 -37
@@ -1,93 +0,0 @@
1
- import type { ImageSize } from './imageResolution.ts';
2
- /**
3
- * Room left around a drawing in a written-out picture, in drawing units.
4
- *
5
- * Enough that a name written under the bottom of the drawing, and the stroke
6
- * around its outermost mark, are inside the picture rather than against its
7
- * edge.
8
- */
9
- export declare const PICTURE_PADDING = 12;
10
- /**
11
- * What the picture is of: the drawing, or the element it is drawn in.
12
- *
13
- * `content` measures the drawing and ignores the canvas around it, which is
14
- * what a drawing surface wants — it is mostly empty space, panned and zoomed to
15
- * wherever it was last left, and none of that belongs in a file. `element`
16
- * takes the element as it is laid out, which is what a chart wants: its axes
17
- * are drawn to the box it was given, so the box *is* the picture and measuring
18
- * the marks inside it would crop the frame to wherever the data happens to
19
- * reach.
20
- */
21
- export type PictureFrame = 'content' | 'element';
22
- export interface PictureOptions {
23
- /**
24
- * How many pixels each drawing unit becomes.
25
- * @default 2
26
- */
27
- scale?: number;
28
- /**
29
- * The name saved files take, without their extension.
30
- * @default 'picture'
31
- */
32
- filename?: string;
33
- /**
34
- * What the picture is read out as, in place of the instructions the element
35
- * carries for whoever is working it.
36
- * @default 'Drawing'
37
- */
38
- label?: string;
39
- /**
40
- * What the picture is of.
41
- * @default 'content'
42
- */
43
- frame?: PictureFrame;
44
- /**
45
- * Room left around the drawing, in drawing units. Ignored when the picture is
46
- * the element, which is already the size it wants to be.
47
- * @default PICTURE_PADDING
48
- */
49
- padding?: number;
50
- }
51
- /**
52
- * How big the drawing comes out at a resolution, before it is written out.
53
- *
54
- * What is measured is what the picture will be of rather than whatever is on
55
- * screen, so the answer does not change when the window is resized or the
56
- * drawing panned — the size shown next to the resolution is the size of the
57
- * file that is about to be written.
58
- * @param svg - The element, as it is rendered.
59
- * @param scale - How many pixels each drawing unit becomes.
60
- * @param options - What the picture is of.
61
- * @returns The size, or `null` when nothing is drawn.
62
- */
63
- export declare function pictureSize(svg: SVGSVGElement | null, scale: number, options?: Pick<PictureOptions, 'frame' | 'padding'>): ImageSize | null;
64
- /**
65
- * Put the drawing on the clipboard as a PNG.
66
- *
67
- * The rasterization is handed to the clipboard as a promise rather than awaited
68
- * first: Safari only allows a clipboard write the click itself started.
69
- * @param svg - The element, as it is rendered.
70
- * @param options - How big to make it.
71
- * @returns Whether it was copied. `false` when nothing is drawn, and in a
72
- * browser whose clipboard takes text only.
73
- */
74
- export declare function copyPicture(svg: SVGSVGElement | null, options?: PictureOptions): Promise<boolean>;
75
- /**
76
- * Save the drawing as a PNG.
77
- * @param svg - The element, as it is rendered.
78
- * @param options - How big to make it, and what to call it.
79
- * @returns Whether it was saved. `false` when nothing is drawn.
80
- */
81
- export declare function savePngPicture(svg: SVGSVGElement | null, options?: PictureOptions): Promise<boolean>;
82
- /**
83
- * Save the drawing as an SVG.
84
- *
85
- * The resolution is carried into the file as the size it opens at, but the
86
- * shapes stay shapes: an SVG printed at any size is drawn again rather than
87
- * enlarged, which is the reason to prefer it wherever it can go.
88
- * @param svg - The element, as it is rendered.
89
- * @param options - How big to make it, and what to call it.
90
- * @returns Whether it was saved. `false` when nothing is drawn.
91
- */
92
- export declare function saveSvgPicture(svg: SVGSVGElement | null, options?: PictureOptions): boolean;
93
- //# sourceMappingURL=pictureExport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pictureExport.d.ts","sourceRoot":"","sources":["../../../src/download/core/pictureExport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOtD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,aAAa,GAAG,IAAI,EACzB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,SAAS,CAAM,GACtD,SAAS,GAAG,IAAI,CAGlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,aAAa,GAAG,IAAI,EACzB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAIlB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,aAAa,GAAG,IAAI,EACzB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,GAAG,IAAI,EACzB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAST"}
@@ -1,116 +0,0 @@
1
- import { writeImageToClipboard } from "../../clipboard/core/copyPng.js";
2
- import { downloadBlob } from "./downloadBlob.js";
3
- import { downloadText } from "./downloadText.js";
4
- import { imageSize } from "./imageResolution.js";
5
- import { contentBox, elementBox } from "./svgBounds.js";
6
- import { svgToPng } from "./svgToPng.js";
7
- import { svgToString } from "./svgToString.js";
8
- /**
9
- * Room left around a drawing in a written-out picture, in drawing units.
10
- *
11
- * Enough that a name written under the bottom of the drawing, and the stroke
12
- * around its outermost mark, are inside the picture rather than against its
13
- * edge.
14
- */
15
- export const PICTURE_PADDING = 12;
16
- /**
17
- * How big the drawing comes out at a resolution, before it is written out.
18
- *
19
- * What is measured is what the picture will be of rather than whatever is on
20
- * screen, so the answer does not change when the window is resized or the
21
- * drawing panned — the size shown next to the resolution is the size of the
22
- * file that is about to be written.
23
- * @param svg - The element, as it is rendered.
24
- * @param scale - How many pixels each drawing unit becomes.
25
- * @param options - What the picture is of.
26
- * @returns The size, or `null` when nothing is drawn.
27
- */
28
- export function pictureSize(svg, scale, options = {}) {
29
- const box = svg && pictureBox(svg, options);
30
- return box && imageSize(box, scale);
31
- }
32
- /**
33
- * Put the drawing on the clipboard as a PNG.
34
- *
35
- * The rasterization is handed to the clipboard as a promise rather than awaited
36
- * first: Safari only allows a clipboard write the click itself started.
37
- * @param svg - The element, as it is rendered.
38
- * @param options - How big to make it.
39
- * @returns Whether it was copied. `false` when nothing is drawn, and in a
40
- * browser whose clipboard takes text only.
41
- */
42
- export async function copyPicture(svg, options = {}) {
43
- const written = describe(svg, options);
44
- if (!written)
45
- return false;
46
- return await writeImageToClipboard(svgToPng(written.svg, written.png));
47
- }
48
- /**
49
- * Save the drawing as a PNG.
50
- * @param svg - The element, as it is rendered.
51
- * @param options - How big to make it, and what to call it.
52
- * @returns Whether it was saved. `false` when nothing is drawn.
53
- */
54
- export async function savePngPicture(svg, options = {}) {
55
- const written = describe(svg, options);
56
- if (!written)
57
- return false;
58
- downloadBlob(await svgToPng(written.svg, written.png), `${written.name}.png`);
59
- return true;
60
- }
61
- /**
62
- * Save the drawing as an SVG.
63
- *
64
- * The resolution is carried into the file as the size it opens at, but the
65
- * shapes stay shapes: an SVG printed at any size is drawn again rather than
66
- * enlarged, which is the reason to prefer it wherever it can go.
67
- * @param svg - The element, as it is rendered.
68
- * @param options - How big to make it, and what to call it.
69
- * @returns Whether it was saved. `false` when nothing is drawn.
70
- */
71
- export function saveSvgPicture(svg, options = {}) {
72
- const written = describe(svg, options);
73
- if (!written)
74
- return false;
75
- downloadText(svgToString(written.svg, written.png), `${written.name}.svg`, 'image/svg+xml');
76
- return true;
77
- }
78
- /**
79
- * The rectangle a picture of the element would cover, in drawing units.
80
- * @param svg - The element, as it is rendered.
81
- * @param options - What the picture is of.
82
- * @returns The rectangle, or `null` when nothing is drawn.
83
- */
84
- function pictureBox(svg, options) {
85
- const { frame = 'content', padding = PICTURE_PADDING } = options;
86
- return frame === 'content' ? contentBox(svg, padding) : elementBox(svg);
87
- }
88
- /**
89
- * Work out what a picture of the element would be.
90
- * @param svg - The element, as it is rendered.
91
- * @param options - How big to make it, and what to call it.
92
- * @returns The element and the rectangle to write out, or `null` when nothing
93
- * is drawn.
94
- */
95
- function describe(svg, options) {
96
- const { scale = 2, filename = 'picture', label = 'Drawing', frame = 'content', } = options;
97
- if (!svg)
98
- return null;
99
- const box = pictureBox(svg, options);
100
- if (!box)
101
- return null;
102
- const size = imageSize(box, scale);
103
- return {
104
- svg,
105
- // A picture of the element keeps the `viewBox` the element was drawn with,
106
- // which is the one thing that makes its own scaling come out right.
107
- png: {
108
- box: frame === 'content' ? box : null,
109
- width: size.width,
110
- height: size.height,
111
- label,
112
- },
113
- name: filename,
114
- };
115
- }
116
- //# sourceMappingURL=pictureExport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pictureExport.js","sourceRoot":"","sources":["../../../src/download/core/pictureExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAA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AAC,GAAG,CAAC,EACrC,GAAG,OAAO,CAAC,IAAI,MAAM,EACrB,eAAe,CAChB,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAgBD;;;;;GAKG;AACH,SAAS,UAAU,CACjB,GAAkB,EAClB,OAAkD;IAElD,MAAM,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IACjE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,SAAS,QAAQ,CACf,GAAyB,EACzB,OAAuB;IAEvB,MAAM,EACJ,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,SAAS,EACpB,KAAK,GAAG,SAAS,EACjB,KAAK,GAAG,SAAS,GAClB,GAAG,OAAO,CAAC;IACZ,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAEtB,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAEtB,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACnC,OAAO;QACL,GAAG;QACH,2EAA2E;QAC3E,oEAAoE;QACpE,GAAG,EAAE;YACH,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK;SACN;QACD,IAAI,EAAE,QAAQ;KACf,CAAC;AACJ,CAAC"}
@@ -1,46 +0,0 @@
1
- import type { IconName } from '@blueprintjs/core';
2
- import type { ReactNode } from 'react';
3
- export interface ExportDialogFrameProps {
4
- /** Whether the dialog is showing. */
5
- isOpen: boolean;
6
- /** What it is about, along the top. */
7
- title: string;
8
- /** The icon beside that title. */
9
- icon: IconName;
10
- /**
11
- * The name saved files take, without their extension; the section is keyed on
12
- * it, so a file saved under a new name is what the name box opens on next
13
- * time rather than what was typed and then thought better of.
14
- */
15
- filename: string;
16
- /**
17
- * How wide the dialog opens, in pixels. A section showing text needs the room
18
- * to show a molfile line whole; one showing controls does not.
19
- * @default 560
20
- */
21
- width?: number;
22
- /**
23
- * Whether the section is mounted only while the dialog is open, for a section
24
- * whose work — measuring a picture off the page — is only worth doing while
25
- * it is being looked at.
26
- * @default false
27
- */
28
- mountWhileOpen?: boolean;
29
- /** The section, built with the status setter the footer reads. */
30
- children: (onStatus: (status: string) => void) => ReactNode;
31
- /** Called when the dialog is dismissed. */
32
- onClose: () => void;
33
- }
34
- /**
35
- * The frame every export dialog shares: the section, and what it last did.
36
- *
37
- * Each thing the editor writes out gets a dialog of its own rather than one
38
- * shared dialog of tabs, since a picture, a structure and a sequence are asked
39
- * for at different moments; what they have in common is only the frame, which
40
- * is here so the three cannot come to differ in how they close or where they
41
- * say what they wrote.
42
- * @param props - Component props.
43
- * @returns The dialog.
44
- */
45
- export declare function ExportDialogFrame(props: ExportDialogFrameProps): import("react").JSX.Element;
46
- //# sourceMappingURL=ExportDialogFrame.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportDialogFrame.d.ts","sourceRoot":"","sources":["../../../src/download/ui/ExportDialogFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,IAAI,EAAE,QAAQ,CAAC;IACf;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kEAAkE;IAClE,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,KAAK,SAAS,CAAC;IAC5D,2CAA2C;IAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BAgC9D"}
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
3
- import { useState } from 'react';
4
- import { useConfirmOnEnter } from "../../panel/ui/useConfirmOnEnter.js";
5
- import { exportNoteStyle } from "../core/exportStyles.js";
6
- /**
7
- * The frame every export dialog shares: the section, and what it last did.
8
- *
9
- * Each thing the editor writes out gets a dialog of its own rather than one
10
- * shared dialog of tabs, since a picture, a structure and a sequence are asked
11
- * for at different moments; what they have in common is only the frame, which
12
- * is here so the three cannot come to differ in how they close or where they
13
- * say what they wrote.
14
- * @param props - Component props.
15
- * @returns The dialog.
16
- */
17
- export function ExportDialogFrame(props) {
18
- const { isOpen, title, icon, filename, width = DEFAULT_WIDTH, mountWhileOpen = false, children, onClose, } = props;
19
- const [status, setStatus] = useState(null);
20
- useConfirmOnEnter(isOpen, onClose);
21
- return (_jsxs(Dialog, { isOpen: isOpen, title: title, icon: icon, style: { width, maxWidth: '92vw' }, onClose: onClose, children: [_jsx(DialogBody, { children: mountWhileOpen && !isOpen ? null : children(setStatus) }, filename), _jsx(DialogFooter, { actions: _jsx(Button, { text: "Close", onClick: onClose }), children: _jsx("span", { style: exportNoteStyle, children: status }) })] }));
22
- }
23
- const DEFAULT_WIDTH = 560;
24
- //# sourceMappingURL=ExportDialogFrame.js.map
@@ -1 +0,0 @@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 +0,0 @@
1
- import type { PictureFrame } from '../core/pictureExport.ts';
2
- export interface ExportImageDialogProps {
3
- /** Whether the dialog is showing. */
4
- isOpen: boolean;
5
- /**
6
- * The drawing the picture is taken of, as it is rendered. Read when a button
7
- * is pressed rather than passed in, since a drawing is laid out again on
8
- * every resize. `null` when nothing is drawn.
9
- */
10
- getDrawing: () => SVGSVGElement | null;
11
- /**
12
- * The name saved files take, without their extension.
13
- * @default 'picture'
14
- */
15
- filename?: string;
16
- /**
17
- * What the picture is read out as in the file it is written to, in place of
18
- * the instructions the element carries for whoever is working it.
19
- * @default 'Drawing'
20
- */
21
- label?: string;
22
- /**
23
- * Whether the picture is the drawing inside the element — a canvas, which is
24
- * mostly the empty space around what is on it — or the element as it is laid
25
- * out, which is what a chart drawn to the box it was given is.
26
- * @default 'content'
27
- */
28
- frame?: PictureFrame;
29
- /** Called when the dialog is dismissed. */
30
- onClose: () => void;
31
- }
32
- /**
33
- * A drawing as a picture: PNG at a chosen resolution, or SVG.
34
- *
35
- * How big it comes out is asked rather than guessed, since only one size could
36
- * be the default and neither a figure nor a thumbnail is it. SVG is the honest
37
- * answer wherever it is accepted — it is drawn again at whatever size it is
38
- * printed — so the resolution there is only the size the file opens at.
39
- *
40
- * The same dialog writes out a glycan, a molecule and a spectrum, because none
41
- * of what it does depends on what is drawn: it is handed an SVG element that is
42
- * already on the page, and asks it how big it is.
43
- * @param props - Component props.
44
- * @returns The dialog.
45
- */
46
- export declare function ExportImageDialog(props: ExportImageDialogProps): import("react").JSX.Element;
47
- //# sourceMappingURL=ExportImageDialog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportImageDialog.d.ts","sourceRoot":"","sources":["../../../src/download/ui/ExportImageDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BAqC9D"}
@@ -1,25 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { DEFAULT_IMAGE_RESOLUTION } from "../core/imageResolution.js";
4
- import { ExportDialogFrame } from "./ExportDialogFrame.js";
5
- import { ExportPictureSection } from "./ExportPictureSection.js";
6
- /**
7
- * A drawing as a picture: PNG at a chosen resolution, or SVG.
8
- *
9
- * How big it comes out is asked rather than guessed, since only one size could
10
- * be the default and neither a figure nor a thumbnail is it. SVG is the honest
11
- * answer wherever it is accepted — it is drawn again at whatever size it is
12
- * printed — so the resolution there is only the size the file opens at.
13
- *
14
- * The same dialog writes out a glycan, a molecule and a spectrum, because none
15
- * of what it does depends on what is drawn: it is handed an SVG element that is
16
- * already on the page, and asks it how big it is.
17
- * @param props - Component props.
18
- * @returns The dialog.
19
- */
20
- export function ExportImageDialog(props) {
21
- const { isOpen, getDrawing, filename = 'picture', label = 'Drawing', frame, onClose, } = props;
22
- const [resolutionId, setResolutionId] = useState(DEFAULT_IMAGE_RESOLUTION.id);
23
- return (_jsx(ExportDialogFrame, { isOpen: isOpen, title: "Export as an image", icon: "media", filename: filename, width: 460, mountWhileOpen: true, onClose: onClose, children: (onStatus) => (_jsx(ExportPictureSection, { getDrawing: getDrawing, resolutionId: resolutionId, onResolutionChange: setResolutionId, filename: filename, label: label, frame: frame, onStatus: onStatus })) }));
24
- }
25
- //# sourceMappingURL=ExportImageDialog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportImageDialog.js","sourceRoot":"","sources":["../../../src/download/ui/ExportImageDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA4B,CAAC;AAiClE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,MAAM,EACN,UAAU,EACV,QAAQ,GAAG,SAAS,EACpB,KAAK,GAAG,SAAS,EACjB,KAAK,EACL,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,wBAAwB,CAAC,EAAE,CAC5B,CAAC;IAEF,OAAO,CACL,KAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAC,oBAAoB,EAC1B,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,GAAG,EACV,cAAc,QACd,OAAO,EAAE,OAAO,YAEf,CAAC,QAAQ,EAAE,EAAE,CAAC,CACb,KAAC,oBAAoB,IACnB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAAE,eAAe,EACnC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAClB,CACH,GACiB,CACrB,CAAC;AACJ,CAAC"}
@@ -1,29 +0,0 @@
1
- export interface ExportNameFieldProps {
2
- /** What is in the box, without an extension. */
3
- name: string;
4
- /**
5
- * The extension the file is about to take, shown after what is typed.
6
- * @default ''
7
- */
8
- extension?: string;
9
- /** Called with what was typed. */
10
- onChange: (name: string) => void;
11
- }
12
- /**
13
- * What the file about to be written out is called.
14
- *
15
- * It sits at the right of the row of buttons, against the one that writes the
16
- * file, because that is what it is about — copying takes no name, and puts
17
- * itself at the other end of the row. The name the editor came in with is
18
- * offered, since that is what a glycan is usually saved under, but a picture
19
- * for a slide and a molfile for a docking run are rarely wanted under it.
20
- *
21
- * The box grows with what is typed, so the extension sits directly against the
22
- * name and the two read as the one filename they are about to become. Held to a
23
- * fixed width instead, the extension hangs at the far edge with the gap between
24
- * them reading as part of neither.
25
- * @param props - Component props.
26
- * @returns The field.
27
- */
28
- export declare function ExportNameField(props: ExportNameFieldProps): import("react").JSX.Element;
29
- //# sourceMappingURL=ExportNameField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportNameField.d.ts","sourceRoot":"","sources":["../../../src/download/ui/ExportNameField.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,+BAmD1D"}
@@ -1,99 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useLayoutEffect, useRef } from 'react';
3
- import { TOKEN } from "../../tokens/core/familyTokens.js";
4
- /**
5
- * What the file about to be written out is called.
6
- *
7
- * It sits at the right of the row of buttons, against the one that writes the
8
- * file, because that is what it is about — copying takes no name, and puts
9
- * itself at the other end of the row. The name the editor came in with is
10
- * offered, since that is what a glycan is usually saved under, but a picture
11
- * for a slide and a molfile for a docking run are rarely wanted under it.
12
- *
13
- * The box grows with what is typed, so the extension sits directly against the
14
- * name and the two read as the one filename they are about to become. Held to a
15
- * fixed width instead, the extension hangs at the far edge with the gap between
16
- * them reading as part of neither.
17
- * @param props - Component props.
18
- * @returns The field.
19
- */
20
- export function ExportNameField(props) {
21
- const { name, extension = '', onChange } = props;
22
- const input = useRef(null);
23
- const mirror = useRef(null);
24
- const ruler = useRef(null);
25
- // Measured off a copy of the text in the same font rather than counted in
26
- // characters, which only holds for a monospace one. The width is set on the
27
- // element instead of kept in state: it is what the browser has just measured,
28
- // so rendering again to store it would measure the same thing twice.
29
- useLayoutEffect(() => {
30
- if (!input.current || !mirror.current || !ruler.current)
31
- return;
32
- const measured = mirror.current.offsetWidth + CARET;
33
- const floor = ruler.current.offsetWidth;
34
- input.current.style.width = `${Math.min(Math.max(measured, floor), MAXIMUM)}px`;
35
- });
36
- return (_jsx("div", { style: fieldStyle, children: _jsxs("div", { className: "bp6-input", style: boxStyle, children: [_jsx("input", { ref: input, value: name, "aria-label": "File name", placeholder: PLACEHOLDER, spellCheck: false, autoComplete: "off", style: inputStyle, onChange: (event) => onChange(event.target.value),
37
- // The name is in force as it is typed, so Enter has nothing left to
38
- // confirm — and is kept off the dialog, whose answer is to close.
39
- onKeyDown: (event) => {
40
- if (event.key === 'Enter')
41
- event.stopPropagation();
42
- } }), extension === '' ? null : (_jsx("span", { style: extensionStyle, children: extension })), _jsx("span", { ref: mirror, style: mirrorStyle, "aria-hidden": "true", children: name === '' ? PLACEHOLDER : name }), _jsx("span", { ref: ruler, style: mirrorStyle, "aria-hidden": "true", children: FLOOR_SAMPLE })] }) }));
43
- }
44
- /** What the box says when nothing has been typed into it. */
45
- const PLACEHOLDER = 'File name';
46
- /** Room for the caret past the last character, so it is never clipped. */
47
- const CARET = 2;
48
- /**
49
- * Twenty characters, which the box is never narrower than.
50
- *
51
- * A name is typed into this box as often as it is read out of it, and a box cut
52
- * to `glycan` leaves no room to do that in — so the floor is a name of the
53
- * length one usually is, measured in the box's own font rather than counted at
54
- * some assumed character width. `n` is about the average width of a lowercase
55
- * letter, which is what a filename is mostly made of.
56
- */
57
- const FLOOR_SAMPLE = 'n'.repeat(20);
58
- /** Past this a name scrolls inside the box rather than pushing the dialog. */
59
- const MAXIMUM = 260;
60
- // Held against the right of the row beside the button that writes the file, so
61
- // the space in the row falls between copying and saving rather than inside the
62
- // name.
63
- const fieldStyle = { marginLeft: 'auto', flexShrink: 0 };
64
- // Blueprint's own input chrome, worn by the box rather than by the field inside
65
- // it, so the name and the extension sit within one border. Positioned, so the
66
- // hidden copy the width is measured off can be taken out of the layout without
67
- // leaving the box it takes its font from.
68
- const boxStyle = {
69
- position: 'relative',
70
- display: 'flex',
71
- alignItems: 'center',
72
- width: 'fit-content',
73
- };
74
- // The field itself brings nothing of its own: the box around it is what is
75
- // seen, and the text has to be in the font the width was measured in.
76
- const inputStyle = {
77
- font: 'inherit',
78
- border: 'none',
79
- outline: 'none',
80
- padding: 0,
81
- margin: 0,
82
- background: 'transparent',
83
- color: 'inherit',
84
- };
85
- const extensionStyle = {
86
- color: TOKEN.textMuted,
87
- whiteSpace: 'pre',
88
- };
89
- // A copy of what is typed, in the same font, laid out but never painted.
90
- const mirrorStyle = {
91
- position: 'absolute',
92
- top: 0,
93
- left: 0,
94
- visibility: 'hidden',
95
- pointerEvents: 'none',
96
- whiteSpace: 'pre',
97
- font: 'inherit',
98
- };
99
- //# sourceMappingURL=ExportNameField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportNameField.js","sourceRoot":"","sources":["../../../src/download/ui/ExportNameField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAc1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEjD,MAAM,KAAK,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;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AW,GAAG;IAClB,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,QAAQ;IACpB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,SAAS;CACP,CAAC"}
@@ -1,38 +0,0 @@
1
- import type { PictureFrame } from '../core/pictureExport.ts';
2
- export interface ExportPictureSectionProps {
3
- /** The drawing a picture is taken of, as it is rendered. */
4
- getDrawing: () => SVGSVGElement | null;
5
- /** Which of the resolutions is picked. */
6
- resolutionId: string;
7
- /** Called with the resolution that was picked. */
8
- onResolutionChange: (id: string) => void;
9
- /**
10
- * The name the name box opens on, and falls back to when it is cleared,
11
- * without its extension.
12
- */
13
- filename: string;
14
- /** What the picture is read out as in the file it is written to. */
15
- label: string;
16
- /**
17
- * Whether the picture is the drawing inside the element or the element as it
18
- * is laid out.
19
- * @default 'content'
20
- */
21
- frame?: PictureFrame;
22
- /** Called with what became of the last thing written out. */
23
- onStatus: (status: string) => void;
24
- }
25
- /**
26
- * The drawing as a picture: how big it comes out, and where it goes.
27
- *
28
- * The size the file will be is shown beside the resolution rather than after
29
- * the fact, since that is the number the choice is made on — a figure for a
30
- * paper and a thumbnail for a slide are the same drawing at very different
31
- * sizes. What is measured is what the picture will be of and not whatever is on
32
- * screen, so the answer does not change when the window is resized or the
33
- * drawing panned.
34
- * @param props - Component props.
35
- * @returns The section.
36
- */
37
- export declare function ExportPictureSection(props: ExportPictureSectionProps): import("react").JSX.Element;
38
- //# sourceMappingURL=ExportPictureSection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportPictureSection.d.ts","sourceRoot":"","sources":["../../../src/download/ui/ExportPictureSection.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAW7D,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,UAAU,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IACvC,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,+BA2EpE"}
@@ -1,48 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, HTMLSelect } from '@blueprintjs/core';
3
- import { useState } from 'react';
4
- import { exportButtonsStyle, exportNoteStyle, exportSectionStyle, } from "../core/exportStyles.js";
5
- import { IMAGE_RESOLUTIONS, formatImageSize, imageResolution, } from "../core/imageResolution.js";
6
- import { copyPicture, pictureSize, savePngPicture, saveSvgPicture, } from "../core/pictureExport.js";
7
- import { sanitizeFileName } from "../core/sanitizeFileName.js";
8
- import { ExportNameField } from "./ExportNameField.js";
9
- /**
10
- * The drawing as a picture: how big it comes out, and where it goes.
11
- *
12
- * The size the file will be is shown beside the resolution rather than after
13
- * the fact, since that is the number the choice is made on — a figure for a
14
- * paper and a thumbnail for a slide are the same drawing at very different
15
- * sizes. What is measured is what the picture will be of and not whatever is on
16
- * screen, so the answer does not change when the window is resized or the
17
- * drawing panned.
18
- * @param props - Component props.
19
- * @returns The section.
20
- */
21
- export function ExportPictureSection(props) {
22
- const { getDrawing, resolutionId, onResolutionChange, filename, label, frame, onStatus, } = props;
23
- const [name, setName] = useState(filename);
24
- const savedName = sanitizeFileName(name, filename);
25
- const { scale } = imageResolution(resolutionId);
26
- const size = pictureSize(getDrawing(), scale, { frame });
27
- const options = { scale, filename: savedName, label, frame };
28
- return (_jsxs("section", { style: exportSectionStyle, children: [_jsxs("div", { style: resolutionStyle, children: [_jsx(HTMLSelect, { value: resolutionId, "aria-label": "Resolution", onChange: (event) => onResolutionChange(event.currentTarget.value), children: IMAGE_RESOLUTIONS.map((resolution) => (_jsx("option", { value: resolution.id, children: resolution.label }, resolution.id))) }), _jsx("span", { style: exportNoteStyle, children: formatImageSize(size) })] }), _jsxs("div", { style: exportButtonsStyle, children: [_jsx(Button, { icon: "duplicate", disabled: size === null, text: "Copy PNG", onClick: () => {
29
- // The rasterization is started here rather than awaited: Safari
30
- // only allows a clipboard write the click itself started.
31
- void copyPicture(getDrawing(), options).then((copied) => onStatus(copied ? 'Picture copied.' : 'Nothing was copied.'), () => onStatus('Nothing was copied.'));
32
- } }), _jsx(ExportNameField, { name: name, onChange: setName }), _jsx(Button, { icon: "download", disabled: size === null, text: "Save PNG", title: `Save as ${savedName}.png`, onClick: () => {
33
- void savePngPicture(getDrawing(), options).then((saved) => {
34
- if (saved)
35
- onStatus(`Saved as ${savedName}.png.`);
36
- });
37
- } }), _jsx(Button, { icon: "download", disabled: size === null, text: "Save SVG", title: `Save as ${savedName}.svg`, onClick: () => {
38
- if (saveSvgPicture(getDrawing(), options)) {
39
- onStatus(`Saved as ${savedName}.svg.`);
40
- }
41
- } })] })] }));
42
- }
43
- const resolutionStyle = {
44
- display: 'flex',
45
- alignItems: 'center',
46
- gap: 8,
47
- };
48
- //# sourceMappingURL=ExportPictureSection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExportPictureSection.js","sourceRoot":"","sources":["../../../src/download/ui/ExportPictureSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC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