Ver código fonte

feat: save exportScale in AppState (#3580)

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
vanilla_orig
David Laban 3 anos atrás
pai
commit
abfc58eb24
Nenhuma conta vinculada ao e-mail do autor do commit

+ 52
- 0
src/actions/actionExport.tsx Ver arquivo

@@ -13,6 +13,10 @@ import { KEYS } from "../keys";
13 13
 import { register } from "./register";
14 14
 import { supported as fsSupported } from "browser-fs-access";
15 15
 import { CheckboxItem } from "../components/CheckboxItem";
16
+import { getExportSize } from "../scene/export";
17
+import { DEFAULT_EXPORT_PADDING, EXPORT_SCALES } from "../constants";
18
+import { getSelectedElements, isSomeElementSelected } from "../scene";
19
+import { getNonDeletedElements } from "../element";
16 20
 
17 21
 export const actionChangeProjectName = register({
18 22
   name: "changeProjectName",
@@ -32,6 +36,54 @@ export const actionChangeProjectName = register({
32 36
   ),
33 37
 });
34 38
 
39
+export const actionChangeExportScale = register({
40
+  name: "changeExportScale",
41
+  perform: (_elements, appState, value) => {
42
+    return {
43
+      appState: { ...appState, exportScale: value },
44
+      commitToHistory: false,
45
+    };
46
+  },
47
+  PanelComponent: ({ elements: allElements, appState, updateData }) => {
48
+    const elements = getNonDeletedElements(allElements);
49
+    const exportSelected = isSomeElementSelected(elements, appState);
50
+    const exportedElements = exportSelected
51
+      ? getSelectedElements(elements, appState)
52
+      : elements;
53
+
54
+    return (
55
+      <>
56
+        {EXPORT_SCALES.map((s) => {
57
+          const [width, height] = getExportSize(
58
+            exportedElements,
59
+            DEFAULT_EXPORT_PADDING,
60
+            s,
61
+          );
62
+
63
+          const scaleButtonTitle = `${t(
64
+            "buttons.scale",
65
+          )} ${s}x (${width}x${height})`;
66
+
67
+          return (
68
+            <ToolButton
69
+              key={s}
70
+              size="s"
71
+              type="radio"
72
+              icon={`${s}x`}
73
+              name="export-canvas-scale"
74
+              title={scaleButtonTitle}
75
+              aria-label={scaleButtonTitle}
76
+              id="export-canvas-scale"
77
+              checked={s === appState.exportScale}
78
+              onChange={() => updateData(s)}
79
+            />
80
+          );
81
+        })}
82
+      </>
83
+    );
84
+  },
85
+});
86
+
35 87
 export const actionChangeExportBackground = register({
36 88
   name: "changeExportBackground",
37 89
   perform: (_elements, appState, value) => {

+ 1
- 0
src/actions/types.ts Ver arquivo

@@ -66,6 +66,7 @@ export type ActionName =
66 66
   | "changeProjectName"
67 67
   | "changeExportBackground"
68 68
   | "changeExportEmbedScene"
69
+  | "changeExportScale"
69 70
   | "saveToActiveFile"
70 71
   | "saveFileToDisk"
71 72
   | "loadScene"

+ 7
- 0
src/appState.ts Ver arquivo

@@ -3,11 +3,16 @@ import {
3 3
   DEFAULT_FONT_FAMILY,
4 4
   DEFAULT_FONT_SIZE,
5 5
   DEFAULT_TEXT_ALIGN,
6
+  EXPORT_SCALES,
6 7
 } from "./constants";
7 8
 import { t } from "./i18n";
8 9
 import { AppState, NormalizedZoomValue } from "./types";
9 10
 import { getDateTime } from "./utils";
10 11
 
12
+const defaultExportScale = EXPORT_SCALES.includes(devicePixelRatio)
13
+  ? devicePixelRatio
14
+  : 1;
15
+
11 16
 export const getDefaultAppState = (): Omit<
12 17
   AppState,
13 18
   "offsetTop" | "offsetLeft" | "width" | "height"
@@ -39,6 +44,7 @@ export const getDefaultAppState = (): Omit<
39 44
     elementType: "selection",
40 45
     errorMessage: null,
41 46
     exportBackground: true,
47
+    exportScale: defaultExportScale,
42 48
     exportEmbedScene: false,
43 49
     exportWithDarkMode: false,
44 50
     fileHandle: null,
@@ -117,6 +123,7 @@ const APP_STATE_STORAGE_CONF = (<
117 123
   errorMessage: { browser: false, export: false },
118 124
   exportBackground: { browser: true, export: false },
119 125
   exportEmbedScene: { browser: true, export: false },
126
+  exportScale: { browser: true, export: false },
120 127
   exportWithDarkMode: { browser: true, export: false },
121 128
   fileHandle: { browser: false, export: false },
122 129
   gridSize: { browser: true, export: true },

+ 9
- 40
src/components/ImageExportDialog.tsx Ver arquivo

@@ -8,20 +8,17 @@ import { CanvasError } from "../errors";
8 8
 import { t } from "../i18n";
9 9
 import { useIsMobile } from "./App";
10 10
 import { getSelectedElements, isSomeElementSelected } from "../scene";
11
-import { exportToCanvas, getExportSize } from "../scene/export";
11
+import { exportToCanvas } from "../scene/export";
12 12
 import { AppState } from "../types";
13 13
 import { Dialog } from "./Dialog";
14 14
 import { clipboard, exportImage } from "./icons";
15 15
 import Stack from "./Stack";
16 16
 import { ToolButton } from "./ToolButton";
17
-
18 17
 import "./ExportDialog.scss";
19 18
 import { supported as fsSupported } from "browser-fs-access";
20 19
 import OpenColor from "open-color";
21 20
 import { CheckboxItem } from "./CheckboxItem";
22
-
23
-const scales = [1, 2, 3];
24
-const defaultScale = scales.includes(devicePixelRatio) ? devicePixelRatio : 1;
21
+import { DEFAULT_EXPORT_PADDING } from "../constants";
25 22
 
26 23
 const supportsContextFilters =
27 24
   "filter" in document.createElement("canvas").getContext("2d")!;
@@ -82,7 +79,7 @@ const ExportButton: React.FC<{
82 79
 const ImageExportModal = ({
83 80
   elements,
84 81
   appState,
85
-  exportPadding = 10,
82
+  exportPadding = DEFAULT_EXPORT_PADDING,
86 83
   actionManager,
87 84
   onExportToPng,
88 85
   onExportToSvg,
@@ -98,7 +95,6 @@ const ImageExportModal = ({
98 95
   onCloseRequest: () => void;
99 96
 }) => {
100 97
   const someElementIsSelected = isSomeElementSelected(elements, appState);
101
-  const [scale, setScale] = useState(defaultScale);
102 98
   const [exportSelected, setExportSelected] = useState(someElementIsSelected);
103 99
   const previewRef = useRef<HTMLDivElement>(null);
104 100
   const { exportBackground, viewBackgroundColor } = appState;
@@ -121,7 +117,6 @@ const ImageExportModal = ({
121 117
         exportBackground,
122 118
         viewBackgroundColor,
123 119
         exportPadding,
124
-        scale,
125 120
       });
126 121
 
127 122
       // if converting to blob fails, there's some problem that will
@@ -144,7 +139,6 @@ const ImageExportModal = ({
144 139
     exportBackground,
145 140
     exportPadding,
146 141
     viewBackgroundColor,
147
-    scale,
148 142
   ]);
149 143
 
150 144
   return (
@@ -175,33 +169,8 @@ const ImageExportModal = ({
175 169
         </div>
176 170
       </div>
177 171
       <div style={{ display: "flex", alignItems: "center", marginTop: ".6em" }}>
178
-        <Stack.Row gap={2} justifyContent={"center"}>
179
-          {scales.map((_scale) => {
180
-            const [width, height] = getExportSize(
181
-              exportedElements,
182
-              exportPadding,
183
-              _scale,
184
-            );
185
-
186
-            const scaleButtonTitle = `${t(
187
-              "buttons.scale",
188
-            )} ${_scale}x (${width}x${height})`;
189
-
190
-            return (
191
-              <ToolButton
192
-                key={_scale}
193
-                size="s"
194
-                type="radio"
195
-                icon={`${_scale}x`}
196
-                name="export-canvas-scale"
197
-                title={scaleButtonTitle}
198
-                aria-label={scaleButtonTitle}
199
-                id="export-canvas-scale"
200
-                checked={_scale === scale}
201
-                onChange={() => setScale(_scale)}
202
-              />
203
-            );
204
-          })}
172
+        <Stack.Row gap={2}>
173
+          {actionManager.renderAction("changeExportScale")}
205 174
         </Stack.Row>
206 175
         <p style={{ marginLeft: "1em", userSelect: "none" }}>Scale</p>
207 176
       </div>
@@ -220,7 +189,7 @@ const ImageExportModal = ({
220 189
           color="indigo"
221 190
           title={t("buttons.exportToPng")}
222 191
           aria-label={t("buttons.exportToPng")}
223
-          onClick={() => onExportToPng(exportedElements, scale)}
192
+          onClick={() => onExportToPng(exportedElements)}
224 193
         >
225 194
           PNG
226 195
         </ExportButton>
@@ -228,14 +197,14 @@ const ImageExportModal = ({
228 197
           color="red"
229 198
           title={t("buttons.exportToSvg")}
230 199
           aria-label={t("buttons.exportToSvg")}
231
-          onClick={() => onExportToSvg(exportedElements, scale)}
200
+          onClick={() => onExportToSvg(exportedElements)}
232 201
         >
233 202
           SVG
234 203
         </ExportButton>
235 204
         {probablySupportsClipboardBlob && (
236 205
           <ExportButton
237 206
             title={t("buttons.copyPngToClipboard")}
238
-            onClick={() => onExportToClipboard(exportedElements, scale)}
207
+            onClick={() => onExportToClipboard(exportedElements)}
239 208
             color="gray"
240 209
             shade={7}
241 210
           >
@@ -250,7 +219,7 @@ const ImageExportModal = ({
250 219
 export const ImageExportDialog = ({
251 220
   elements,
252 221
   appState,
253
-  exportPadding = 10,
222
+  exportPadding = DEFAULT_EXPORT_PADDING,
254 223
   actionManager,
255 224
   onExportToPng,
256 225
   onExportToSvg,

+ 0
- 2
src/components/LayerUI.tsx Ver arquivo

@@ -400,13 +400,11 @@ const LayerUI = ({
400 400
 
401 401
     const createExporter = (type: ExportType): ExportCB => async (
402 402
       exportedElements,
403
-      scale,
404 403
     ) => {
405 404
       await exportCanvas(type, exportedElements, appState, {
406 405
         exportBackground: appState.exportBackground,
407 406
         name: appState.name,
408 407
         viewBackgroundColor: appState.viewBackgroundColor,
409
-        scale,
410 408
       })
411 409
         .catch(muteFSAbortError)
412 410
         .catch((error) => {

+ 3
- 0
src/constants.ts Ver arquivo

@@ -144,3 +144,6 @@ export const MQ_MAX_WIDTH_LANDSCAPE = 1000;
144 144
 export const MQ_MAX_HEIGHT_LANDSCAPE = 500;
145 145
 
146 146
 export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
147
+
148
+export const EXPORT_SCALES = [1, 2, 3];
149
+export const DEFAULT_EXPORT_PADDING = 10; // px

+ 3
- 5
src/data/index.ts Ver arquivo

@@ -3,6 +3,7 @@ import {
3 3
   copyBlobToClipboardAsPng,
4 4
   copyTextToSystemClipboard,
5 5
 } from "../clipboard";
6
+import { DEFAULT_EXPORT_PADDING } from "../constants";
6 7
 import { NonDeletedExcalidrawElement } from "../element/types";
7 8
 import { t } from "../i18n";
8 9
 import { exportToCanvas, exportToSvg } from "../scene/export";
@@ -20,16 +21,14 @@ export const exportCanvas = async (
20 21
   appState: AppState,
21 22
   {
22 23
     exportBackground,
23
-    exportPadding = 10,
24
+    exportPadding = DEFAULT_EXPORT_PADDING,
24 25
     viewBackgroundColor,
25 26
     name,
26
-    scale = 1,
27 27
   }: {
28 28
     exportBackground: boolean;
29 29
     exportPadding?: number;
30 30
     viewBackgroundColor: string;
31 31
     name: string;
32
-    scale?: number;
33 32
   },
34 33
 ) => {
35 34
   if (elements.length === 0) {
@@ -41,7 +40,7 @@ export const exportCanvas = async (
41 40
       exportWithDarkMode: appState.exportWithDarkMode,
42 41
       viewBackgroundColor,
43 42
       exportPadding,
44
-      scale,
43
+      exportScale: appState.exportScale,
45 44
       metadata:
46 45
         appState.exportEmbedScene && type === "svg"
47 46
           ? await (
@@ -67,7 +66,6 @@ export const exportCanvas = async (
67 66
     exportBackground,
68 67
     viewBackgroundColor,
69 68
     exportPadding,
70
-    scale,
71 69
   });
72 70
   tempCanvas.style.display = "none";
73 71
   document.body.appendChild(tempCanvas);

+ 0
- 1
src/index-node.ts Ver arquivo

@@ -69,7 +69,6 @@ const canvas = exportToCanvas(
69 69
   {
70 70
     exportBackground: true,
71 71
     viewBackgroundColor: "#ffffff",
72
-    scale: 1,
73 72
   },
74 73
   createCanvas,
75 74
 );

+ 16
- 21
src/scene/export.ts Ver arquivo

@@ -4,7 +4,7 @@ import { getCommonBounds } from "../element/bounds";
4 4
 import { renderScene, renderSceneToSvg } from "../renderer/renderScene";
5 5
 import { distance, SVG_NS } from "../utils";
6 6
 import { AppState } from "../types";
7
-import { THEME_FILTER } from "../constants";
7
+import { DEFAULT_EXPORT_PADDING, THEME_FILTER } from "../constants";
8 8
 import { getDefaultAppState } from "../appState";
9 9
 
10 10
 export const SVG_EXPORT_TAG = `<!-- svg-source:excalidraw -->`;
@@ -14,39 +14,34 @@ export const exportToCanvas = (
14 14
   appState: AppState,
15 15
   {
16 16
     exportBackground,
17
-    exportPadding = 10,
17
+    exportPadding = DEFAULT_EXPORT_PADDING,
18 18
     viewBackgroundColor,
19
-    scale = 1,
20 19
   }: {
21 20
     exportBackground: boolean;
22 21
     exportPadding?: number;
23
-    scale?: number;
24 22
     viewBackgroundColor: string;
25 23
   },
26 24
   createCanvas: (
27 25
     width: number,
28 26
     height: number,
29 27
   ) => { canvas: HTMLCanvasElement; scale: number } = (width, height) => {
30
-    const tempCanvas = document.createElement("canvas");
31
-    tempCanvas.width = width * scale;
32
-    tempCanvas.height = height * scale;
33
-    return { canvas: tempCanvas, scale };
28
+    const canvas = document.createElement("canvas");
29
+    canvas.width = width * appState.exportScale;
30
+    canvas.height = height * appState.exportScale;
31
+    return { canvas, scale: appState.exportScale };
34 32
   },
35 33
 ) => {
36 34
   const [minX, minY, width, height] = getCanvasSize(elements, exportPadding);
37 35
 
38
-  const { canvas: tempCanvas, scale: newScale = scale } = createCanvas(
39
-    width,
40
-    height,
41
-  );
36
+  const { canvas, scale = 1 } = createCanvas(width, height);
42 37
 
43 38
   renderScene(
44 39
     elements,
45 40
     appState,
46 41
     null,
47
-    newScale,
48
-    rough.canvas(tempCanvas),
49
-    tempCanvas,
42
+    scale,
43
+    rough.canvas(canvas),
44
+    canvas,
50 45
     {
51 46
       viewBackgroundColor: exportBackground ? viewBackgroundColor : null,
52 47
       exportWithDarkMode: appState.exportWithDarkMode,
@@ -67,22 +62,22 @@ export const exportToCanvas = (
67 62
     },
68 63
   );
69 64
 
70
-  return tempCanvas;
65
+  return canvas;
71 66
 };
72 67
 
73 68
 export const exportToSvg = (
74 69
   elements: readonly NonDeletedExcalidrawElement[],
75 70
   {
76 71
     exportBackground,
77
-    exportPadding = 10,
72
+    exportPadding = DEFAULT_EXPORT_PADDING,
78 73
     viewBackgroundColor,
79 74
     exportWithDarkMode,
80
-    scale = 1,
75
+    exportScale = 1,
81 76
     metadata = "",
82 77
   }: {
83 78
     exportBackground: boolean;
84 79
     exportPadding?: number;
85
-    scale?: number;
80
+    exportScale?: number;
86 81
     viewBackgroundColor: string;
87 82
     exportWithDarkMode?: boolean;
88 83
     metadata?: string;
@@ -95,8 +90,8 @@ export const exportToSvg = (
95 90
   svgRoot.setAttribute("version", "1.1");
96 91
   svgRoot.setAttribute("xmlns", SVG_NS);
97 92
   svgRoot.setAttribute("viewBox", `0 0 ${width} ${height}`);
98
-  svgRoot.setAttribute("width", `${width * scale}`);
99
-  svgRoot.setAttribute("height", `${height * scale}`);
93
+  svgRoot.setAttribute("width", `${width * exportScale}`);
94
+  svgRoot.setAttribute("height", `${height * exportScale}`);
100 95
   if (exportWithDarkMode) {
101 96
     svgRoot.setAttribute("filter", THEME_FILTER);
102 97
   }

+ 16
- 0
src/tests/__snapshots__/contextmenu.test.tsx.snap Ver arquivo

@@ -28,6 +28,7 @@ Object {
28 28
   "errorMessage": null,
29 29
   "exportBackground": true,
30 30
   "exportEmbedScene": false,
31
+  "exportScale": 1,
31 32
   "exportWithDarkMode": false,
32 33
   "fileHandle": null,
33 34
   "gridSize": null,
@@ -194,6 +195,7 @@ Object {
194 195
   "errorMessage": null,
195 196
   "exportBackground": true,
196 197
   "exportEmbedScene": false,
198
+  "exportScale": 1,
197 199
   "exportWithDarkMode": false,
198 200
   "fileHandle": null,
199 201
   "gridSize": null,
@@ -506,6 +508,7 @@ Object {
506 508
   "errorMessage": null,
507 509
   "exportBackground": true,
508 510
   "exportEmbedScene": false,
511
+  "exportScale": 1,
509 512
   "exportWithDarkMode": false,
510 513
   "fileHandle": null,
511 514
   "gridSize": null,
@@ -818,6 +821,7 @@ Object {
818 821
   "errorMessage": null,
819 822
   "exportBackground": true,
820 823
   "exportEmbedScene": false,
824
+  "exportScale": 1,
821 825
   "exportWithDarkMode": false,
822 826
   "fileHandle": null,
823 827
   "gridSize": null,
@@ -984,6 +988,7 @@ Object {
984 988
   "errorMessage": null,
985 989
   "exportBackground": true,
986 990
   "exportEmbedScene": false,
991
+  "exportScale": 1,
987 992
   "exportWithDarkMode": false,
988 993
   "fileHandle": null,
989 994
   "gridSize": null,
@@ -1183,6 +1188,7 @@ Object {
1183 1188
   "errorMessage": null,
1184 1189
   "exportBackground": true,
1185 1190
   "exportEmbedScene": false,
1191
+  "exportScale": 1,
1186 1192
   "exportWithDarkMode": false,
1187 1193
   "fileHandle": null,
1188 1194
   "gridSize": null,
@@ -1435,6 +1441,7 @@ Object {
1435 1441
   "errorMessage": null,
1436 1442
   "exportBackground": true,
1437 1443
   "exportEmbedScene": false,
1444
+  "exportScale": 1,
1438 1445
   "exportWithDarkMode": false,
1439 1446
   "fileHandle": null,
1440 1447
   "gridSize": null,
@@ -1765,6 +1772,7 @@ Object {
1765 1772
   "errorMessage": null,
1766 1773
   "exportBackground": true,
1767 1774
   "exportEmbedScene": false,
1775
+  "exportScale": 1,
1768 1776
   "exportWithDarkMode": false,
1769 1777
   "fileHandle": null,
1770 1778
   "gridSize": null,
@@ -2497,6 +2505,7 @@ Object {
2497 2505
   "errorMessage": null,
2498 2506
   "exportBackground": true,
2499 2507
   "exportEmbedScene": false,
2508
+  "exportScale": 1,
2500 2509
   "exportWithDarkMode": false,
2501 2510
   "fileHandle": null,
2502 2511
   "gridSize": null,
@@ -2809,6 +2818,7 @@ Object {
2809 2818
   "errorMessage": null,
2810 2819
   "exportBackground": true,
2811 2820
   "exportEmbedScene": false,
2821
+  "exportScale": 1,
2812 2822
   "exportWithDarkMode": false,
2813 2823
   "fileHandle": null,
2814 2824
   "gridSize": null,
@@ -3121,6 +3131,7 @@ Object {
3121 3131
   "errorMessage": null,
3122 3132
   "exportBackground": true,
3123 3133
   "exportEmbedScene": false,
3134
+  "exportScale": 1,
3124 3135
   "exportWithDarkMode": false,
3125 3136
   "fileHandle": null,
3126 3137
   "gridSize": null,
@@ -3507,6 +3518,7 @@ Object {
3507 3518
   "errorMessage": null,
3508 3519
   "exportBackground": true,
3509 3520
   "exportEmbedScene": false,
3521
+  "exportScale": 1,
3510 3522
   "exportWithDarkMode": false,
3511 3523
   "fileHandle": null,
3512 3524
   "gridSize": null,
@@ -3765,6 +3777,7 @@ Object {
3765 3777
   "errorMessage": null,
3766 3778
   "exportBackground": true,
3767 3779
   "exportEmbedScene": false,
3780
+  "exportScale": 1,
3768 3781
   "exportWithDarkMode": false,
3769 3782
   "fileHandle": null,
3770 3783
   "gridSize": null,
@@ -4098,6 +4111,7 @@ Object {
4098 4111
   "errorMessage": null,
4099 4112
   "exportBackground": true,
4100 4113
   "exportEmbedScene": false,
4114
+  "exportScale": 1,
4101 4115
   "exportWithDarkMode": false,
4102 4116
   "fileHandle": null,
4103 4117
   "gridSize": null,
@@ -4199,6 +4213,7 @@ Object {
4199 4213
   "errorMessage": null,
4200 4214
   "exportBackground": true,
4201 4215
   "exportEmbedScene": false,
4216
+  "exportScale": 1,
4202 4217
   "exportWithDarkMode": false,
4203 4218
   "fileHandle": null,
4204 4219
   "gridSize": null,
@@ -4278,6 +4293,7 @@ Object {
4278 4293
   "errorMessage": null,
4279 4294
   "exportBackground": true,
4280 4295
   "exportEmbedScene": false,
4296
+  "exportScale": 1,
4281 4297
   "exportWithDarkMode": false,
4282 4298
   "fileHandle": null,
4283 4299
   "gridSize": null,

+ 52
- 0
src/tests/__snapshots__/regressionTests.test.tsx.snap Ver arquivo

@@ -28,6 +28,7 @@ Object {
28 28
   "errorMessage": null,
29 29
   "exportBackground": true,
30 30
   "exportEmbedScene": false,
31
+  "exportScale": 1,
31 32
   "exportWithDarkMode": false,
32 33
   "fileHandle": null,
33 34
   "gridSize": null,
@@ -496,6 +497,7 @@ Object {
496 497
   "errorMessage": null,
497 498
   "exportBackground": true,
498 499
   "exportEmbedScene": false,
500
+  "exportScale": 1,
499 501
   "exportWithDarkMode": false,
500 502
   "fileHandle": null,
501 503
   "gridSize": null,
@@ -970,6 +972,7 @@ Object {
970 972
   "errorMessage": null,
971 973
   "exportBackground": true,
972 974
   "exportEmbedScene": false,
975
+  "exportScale": 1,
973 976
   "exportWithDarkMode": false,
974 977
   "fileHandle": null,
975 978
   "gridSize": null,
@@ -1759,6 +1762,7 @@ Object {
1759 1762
   "errorMessage": null,
1760 1763
   "exportBackground": true,
1761 1764
   "exportEmbedScene": false,
1765
+  "exportScale": 1,
1762 1766
   "exportWithDarkMode": false,
1763 1767
   "fileHandle": null,
1764 1768
   "gridSize": null,
@@ -1966,6 +1970,7 @@ Object {
1966 1970
   "errorMessage": null,
1967 1971
   "exportBackground": true,
1968 1972
   "exportEmbedScene": false,
1973
+  "exportScale": 1,
1969 1974
   "exportWithDarkMode": false,
1970 1975
   "fileHandle": null,
1971 1976
   "gridSize": null,
@@ -2431,6 +2436,7 @@ Object {
2431 2436
   "errorMessage": null,
2432 2437
   "exportBackground": true,
2433 2438
   "exportEmbedScene": false,
2439
+  "exportScale": 1,
2434 2440
   "exportWithDarkMode": false,
2435 2441
   "fileHandle": null,
2436 2442
   "gridSize": null,
@@ -2687,6 +2693,7 @@ Object {
2687 2693
   "errorMessage": null,
2688 2694
   "exportBackground": true,
2689 2695
   "exportEmbedScene": false,
2696
+  "exportScale": 1,
2690 2697
   "exportWithDarkMode": false,
2691 2698
   "fileHandle": null,
2692 2699
   "gridSize": null,
@@ -2853,6 +2860,7 @@ Object {
2853 2860
   "errorMessage": null,
2854 2861
   "exportBackground": true,
2855 2862
   "exportEmbedScene": false,
2863
+  "exportScale": 1,
2856 2864
   "exportWithDarkMode": false,
2857 2865
   "fileHandle": null,
2858 2866
   "gridSize": null,
@@ -3301,6 +3309,7 @@ Object {
3301 3309
   "errorMessage": null,
3302 3310
   "exportBackground": true,
3303 3311
   "exportEmbedScene": false,
3312
+  "exportScale": 1,
3304 3313
   "exportWithDarkMode": false,
3305 3314
   "fileHandle": null,
3306 3315
   "gridSize": null,
@@ -3541,6 +3550,7 @@ Object {
3541 3550
   "errorMessage": null,
3542 3551
   "exportBackground": true,
3543 3552
   "exportEmbedScene": false,
3553
+  "exportScale": 1,
3544 3554
   "exportWithDarkMode": false,
3545 3555
   "fileHandle": null,
3546 3556
   "gridSize": null,
@@ -3748,6 +3758,7 @@ Object {
3748 3758
   "errorMessage": null,
3749 3759
   "exportBackground": true,
3750 3760
   "exportEmbedScene": false,
3761
+  "exportScale": 1,
3751 3762
   "exportWithDarkMode": false,
3752 3763
   "fileHandle": null,
3753 3764
   "gridSize": null,
@@ -3996,6 +4007,7 @@ Object {
3996 4007
   "errorMessage": null,
3997 4008
   "exportBackground": true,
3998 4009
   "exportEmbedScene": false,
4010
+  "exportScale": 1,
3999 4011
   "exportWithDarkMode": false,
4000 4012
   "fileHandle": null,
4001 4013
   "gridSize": null,
@@ -4251,6 +4263,7 @@ Object {
4251 4263
   "errorMessage": null,
4252 4264
   "exportBackground": true,
4253 4265
   "exportEmbedScene": false,
4266
+  "exportScale": 1,
4254 4267
   "exportWithDarkMode": false,
4255 4268
   "fileHandle": null,
4256 4269
   "gridSize": null,
@@ -4638,6 +4651,7 @@ Object {
4638 4651
   "errorMessage": null,
4639 4652
   "exportBackground": true,
4640 4653
   "exportEmbedScene": false,
4654
+  "exportScale": 1,
4641 4655
   "exportWithDarkMode": false,
4642 4656
   "fileHandle": null,
4643 4657
   "gridSize": null,
@@ -4936,6 +4950,7 @@ Object {
4936 4950
   "errorMessage": null,
4937 4951
   "exportBackground": true,
4938 4952
   "exportEmbedScene": false,
4953
+  "exportScale": 1,
4939 4954
   "exportWithDarkMode": false,
4940 4955
   "fileHandle": null,
4941 4956
   "gridSize": null,
@@ -5212,6 +5227,7 @@ Object {
5212 5227
   "errorMessage": null,
5213 5228
   "exportBackground": true,
5214 5229
   "exportEmbedScene": false,
5230
+  "exportScale": 1,
5215 5231
   "exportWithDarkMode": false,
5216 5232
   "fileHandle": null,
5217 5233
   "gridSize": null,
@@ -5422,6 +5438,7 @@ Object {
5422 5438
   "errorMessage": null,
5423 5439
   "exportBackground": true,
5424 5440
   "exportEmbedScene": false,
5441
+  "exportScale": 1,
5425 5442
   "exportWithDarkMode": false,
5426 5443
   "fileHandle": null,
5427 5444
   "gridSize": null,
@@ -5588,6 +5605,7 @@ Object {
5588 5605
   "errorMessage": null,
5589 5606
   "exportBackground": true,
5590 5607
   "exportEmbedScene": false,
5608
+  "exportScale": 1,
5591 5609
   "exportWithDarkMode": false,
5592 5610
   "fileHandle": null,
5593 5611
   "gridSize": null,
@@ -6048,6 +6066,7 @@ Object {
6048 6066
   "errorMessage": null,
6049 6067
   "exportBackground": true,
6050 6068
   "exportEmbedScene": false,
6069
+  "exportScale": 1,
6051 6070
   "exportWithDarkMode": false,
6052 6071
   "fileHandle": null,
6053 6072
   "gridSize": null,
@@ -6370,6 +6389,7 @@ Object {
6370 6389
   "errorMessage": null,
6371 6390
   "exportBackground": true,
6372 6391
   "exportEmbedScene": false,
6392
+  "exportScale": 1,
6373 6393
   "exportWithDarkMode": false,
6374 6394
   "fileHandle": null,
6375 6395
   "gridSize": null,
@@ -8427,6 +8447,7 @@ Object {
8427 8447
   "errorMessage": null,
8428 8448
   "exportBackground": true,
8429 8449
   "exportEmbedScene": false,
8450
+  "exportScale": 1,
8430 8451
   "exportWithDarkMode": false,
8431 8452
   "fileHandle": null,
8432 8453
   "gridSize": null,
@@ -8793,6 +8814,7 @@ Object {
8793 8814
   "errorMessage": null,
8794 8815
   "exportBackground": true,
8795 8816
   "exportEmbedScene": false,
8817
+  "exportScale": 1,
8796 8818
   "exportWithDarkMode": false,
8797 8819
   "fileHandle": null,
8798 8820
   "gridSize": null,
@@ -9049,6 +9071,7 @@ Object {
9049 9071
   "errorMessage": null,
9050 9072
   "exportBackground": true,
9051 9073
   "exportEmbedScene": false,
9074
+  "exportScale": 1,
9052 9075
   "exportWithDarkMode": false,
9053 9076
   "fileHandle": null,
9054 9077
   "gridSize": null,
@@ -9269,6 +9292,7 @@ Object {
9269 9292
   "errorMessage": null,
9270 9293
   "exportBackground": true,
9271 9294
   "exportEmbedScene": false,
9295
+  "exportScale": 1,
9272 9296
   "exportWithDarkMode": false,
9273 9297
   "fileHandle": null,
9274 9298
   "gridSize": null,
@@ -9552,6 +9576,7 @@ Object {
9552 9576
   "errorMessage": null,
9553 9577
   "exportBackground": true,
9554 9578
   "exportEmbedScene": false,
9579
+  "exportScale": 1,
9555 9580
   "exportWithDarkMode": false,
9556 9581
   "fileHandle": null,
9557 9582
   "gridSize": null,
@@ -9718,6 +9743,7 @@ Object {
9718 9743
   "errorMessage": null,
9719 9744
   "exportBackground": true,
9720 9745
   "exportEmbedScene": false,
9746
+  "exportScale": 1,
9721 9747
   "exportWithDarkMode": false,
9722 9748
   "fileHandle": null,
9723 9749
   "gridSize": null,
@@ -9884,6 +9910,7 @@ Object {
9884 9910
   "errorMessage": null,
9885 9911
   "exportBackground": true,
9886 9912
   "exportEmbedScene": false,
9913
+  "exportScale": 1,
9887 9914
   "exportWithDarkMode": false,
9888 9915
   "fileHandle": null,
9889 9916
   "gridSize": null,
@@ -10050,6 +10077,7 @@ Object {
10050 10077
   "errorMessage": null,
10051 10078
   "exportBackground": true,
10052 10079
   "exportEmbedScene": false,
10080
+  "exportScale": 1,
10053 10081
   "exportWithDarkMode": false,
10054 10082
   "fileHandle": null,
10055 10083
   "gridSize": null,
@@ -10246,6 +10274,7 @@ Object {
10246 10274
   "errorMessage": null,
10247 10275
   "exportBackground": true,
10248 10276
   "exportEmbedScene": false,
10277
+  "exportScale": 1,
10249 10278
   "exportWithDarkMode": false,
10250 10279
   "fileHandle": null,
10251 10280
   "gridSize": null,
@@ -10442,6 +10471,7 @@ Object {
10442 10471
   "errorMessage": null,
10443 10472
   "exportBackground": true,
10444 10473
   "exportEmbedScene": false,
10474
+  "exportScale": 1,
10445 10475
   "exportWithDarkMode": false,
10446 10476
   "fileHandle": null,
10447 10477
   "gridSize": null,
@@ -10650,6 +10680,7 @@ Object {
10650 10680
   "errorMessage": null,
10651 10681
   "exportBackground": true,
10652 10682
   "exportEmbedScene": false,
10683
+  "exportScale": 1,
10653 10684
   "exportWithDarkMode": false,
10654 10685
   "fileHandle": null,
10655 10686
   "gridSize": null,
@@ -10846,6 +10877,7 @@ Object {
10846 10877
   "errorMessage": null,
10847 10878
   "exportBackground": true,
10848 10879
   "exportEmbedScene": false,
10880
+  "exportScale": 1,
10849 10881
   "exportWithDarkMode": false,
10850 10882
   "fileHandle": null,
10851 10883
   "gridSize": null,
@@ -11012,6 +11044,7 @@ Object {
11012 11044
   "errorMessage": null,
11013 11045
   "exportBackground": true,
11014 11046
   "exportEmbedScene": false,
11047
+  "exportScale": 1,
11015 11048
   "exportWithDarkMode": false,
11016 11049
   "fileHandle": null,
11017 11050
   "gridSize": null,
@@ -11178,6 +11211,7 @@ Object {
11178 11211
   "errorMessage": null,
11179 11212
   "exportBackground": true,
11180 11213
   "exportEmbedScene": false,
11214
+  "exportScale": 1,
11181 11215
   "exportWithDarkMode": false,
11182 11216
   "fileHandle": null,
11183 11217
   "gridSize": null,
@@ -11374,6 +11408,7 @@ Object {
11374 11408
   "errorMessage": null,
11375 11409
   "exportBackground": true,
11376 11410
   "exportEmbedScene": false,
11411
+  "exportScale": 1,
11377 11412
   "exportWithDarkMode": false,
11378 11413
   "fileHandle": null,
11379 11414
   "gridSize": null,
@@ -11540,6 +11575,7 @@ Object {
11540 11575
   "errorMessage": null,
11541 11576
   "exportBackground": true,
11542 11577
   "exportEmbedScene": false,
11578
+  "exportScale": 1,
11543 11579
   "exportWithDarkMode": false,
11544 11580
   "fileHandle": null,
11545 11581
   "gridSize": null,
@@ -11748,6 +11784,7 @@ Object {
11748 11784
   "errorMessage": null,
11749 11785
   "exportBackground": true,
11750 11786
   "exportEmbedScene": false,
11787
+  "exportScale": 1,
11751 11788
   "exportWithDarkMode": false,
11752 11789
   "fileHandle": null,
11753 11790
   "gridSize": null,
@@ -12474,6 +12511,7 @@ Object {
12474 12511
   "errorMessage": null,
12475 12512
   "exportBackground": true,
12476 12513
   "exportEmbedScene": false,
12514
+  "exportScale": 1,
12477 12515
   "exportWithDarkMode": false,
12478 12516
   "fileHandle": null,
12479 12517
   "gridSize": null,
@@ -12730,6 +12768,7 @@ Object {
12730 12768
   "errorMessage": null,
12731 12769
   "exportBackground": true,
12732 12770
   "exportEmbedScene": false,
12771
+  "exportScale": 1,
12733 12772
   "exportWithDarkMode": false,
12734 12773
   "fileHandle": null,
12735 12774
   "gridSize": null,
@@ -12833,6 +12872,7 @@ Object {
12833 12872
   "errorMessage": null,
12834 12873
   "exportBackground": true,
12835 12874
   "exportEmbedScene": false,
12875
+  "exportScale": 1,
12836 12876
   "exportWithDarkMode": false,
12837 12877
   "fileHandle": null,
12838 12878
   "gridSize": null,
@@ -12934,6 +12974,7 @@ Object {
12934 12974
   "errorMessage": null,
12935 12975
   "exportBackground": true,
12936 12976
   "exportEmbedScene": false,
12977
+  "exportScale": 1,
12937 12978
   "exportWithDarkMode": false,
12938 12979
   "fileHandle": null,
12939 12980
   "gridSize": null,
@@ -13103,6 +13144,7 @@ Object {
13103 13144
   "errorMessage": null,
13104 13145
   "exportBackground": true,
13105 13146
   "exportEmbedScene": false,
13147
+  "exportScale": 1,
13106 13148
   "exportWithDarkMode": false,
13107 13149
   "fileHandle": null,
13108 13150
   "gridSize": null,
@@ -13428,6 +13470,7 @@ Object {
13428 13470
   "errorMessage": null,
13429 13471
   "exportBackground": true,
13430 13472
   "exportEmbedScene": false,
13473
+  "exportScale": 1,
13431 13474
   "exportWithDarkMode": false,
13432 13475
   "fileHandle": null,
13433 13476
   "gridSize": null,
@@ -13631,6 +13674,7 @@ Object {
13631 13674
   "errorMessage": null,
13632 13675
   "exportBackground": true,
13633 13676
   "exportEmbedScene": false,
13677
+  "exportScale": 1,
13634 13678
   "exportWithDarkMode": false,
13635 13679
   "fileHandle": null,
13636 13680
   "gridSize": null,
@@ -14466,6 +14510,7 @@ Object {
14466 14510
   "errorMessage": null,
14467 14511
   "exportBackground": true,
14468 14512
   "exportEmbedScene": false,
14513
+  "exportScale": 1,
14469 14514
   "exportWithDarkMode": false,
14470 14515
   "fileHandle": null,
14471 14516
   "gridSize": null,
@@ -14567,6 +14612,7 @@ Object {
14567 14612
   "errorMessage": null,
14568 14613
   "exportBackground": true,
14569 14614
   "exportEmbedScene": false,
14615
+  "exportScale": 1,
14570 14616
   "exportWithDarkMode": false,
14571 14617
   "fileHandle": null,
14572 14618
   "gridSize": null,
@@ -15335,6 +15381,7 @@ Object {
15335 15381
   "errorMessage": null,
15336 15382
   "exportBackground": true,
15337 15383
   "exportEmbedScene": false,
15384
+  "exportScale": 1,
15338 15385
   "exportWithDarkMode": false,
15339 15386
   "fileHandle": null,
15340 15387
   "gridSize": null,
@@ -15744,6 +15791,7 @@ Object {
15744 15791
   "errorMessage": null,
15745 15792
   "exportBackground": true,
15746 15793
   "exportEmbedScene": false,
15794
+  "exportScale": 1,
15747 15795
   "exportWithDarkMode": false,
15748 15796
   "fileHandle": null,
15749 15797
   "gridSize": null,
@@ -16020,6 +16068,7 @@ Object {
16020 16068
   "errorMessage": null,
16021 16069
   "exportBackground": true,
16022 16070
   "exportEmbedScene": false,
16071
+  "exportScale": 1,
16023 16072
   "exportWithDarkMode": false,
16024 16073
   "fileHandle": null,
16025 16074
   "gridSize": null,
@@ -16123,6 +16172,7 @@ Object {
16123 16172
   "errorMessage": null,
16124 16173
   "exportBackground": true,
16125 16174
   "exportEmbedScene": false,
16175
+  "exportScale": 1,
16126 16176
   "exportWithDarkMode": false,
16127 16177
   "fileHandle": null,
16128 16178
   "gridSize": null,
@@ -16626,6 +16676,7 @@ Object {
16626 16676
   "errorMessage": null,
16627 16677
   "exportBackground": true,
16628 16678
   "exportEmbedScene": false,
16679
+  "exportScale": 1,
16629 16680
   "exportWithDarkMode": false,
16630 16681
   "fileHandle": null,
16631 16682
   "gridSize": null,
@@ -16727,6 +16778,7 @@ Object {
16727 16778
   "errorMessage": null,
16728 16779
   "exportBackground": true,
16729 16780
   "exportEmbedScene": false,
16781
+  "exportScale": 1,
16730 16782
   "exportWithDarkMode": false,
16731 16783
   "fileHandle": null,
16732 16784
   "gridSize": null,

+ 1
- 0
src/tests/packages/__snapshots__/utils.test.ts.snap Ver arquivo

@@ -29,6 +29,7 @@ Object {
29 29
   "exportBackground": true,
30 30
   "exportEmbedScene": false,
31 31
   "exportPadding": undefined,
32
+  "exportScale": 1,
32 33
   "exportWithDarkMode": false,
33 34
   "fileHandle": null,
34 35
   "gridSize": null,

+ 1
- 1
src/tests/scene/export.test.ts Ver arquivo

@@ -69,7 +69,7 @@ describe("exportToSvg", () => {
69 69
     const svgElement = exportUtils.exportToSvg(ELEMENTS, {
70 70
       ...DEFAULT_OPTIONS,
71 71
       exportPadding: 0,
72
-      scale: SCALE,
72
+      exportScale: SCALE,
73 73
     });
74 74
 
75 75
     expect(svgElement).toHaveAttribute(

+ 1
- 0
src/types.ts Ver arquivo

@@ -58,6 +58,7 @@ export type AppState = {
58 58
   exportBackground: boolean;
59 59
   exportEmbedScene: boolean;
60 60
   exportWithDarkMode: boolean;
61
+  exportScale: number;
61 62
   currentItemStrokeColor: string;
62 63
   currentItemBackgroundColor: string;
63 64
   currentItemFillStyle: ExcalidrawElement["fillStyle"];

Carregando…
Cancelar
Salvar