aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/graph/export/ExportSettingsStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/graph/export/ExportSettingsStore.ts')
-rw-r--r--subprojects/frontend/src/graph/export/ExportSettingsStore.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/subprojects/frontend/src/graph/export/ExportSettingsStore.ts b/subprojects/frontend/src/graph/export/ExportSettingsStore.ts
new file mode 100644
index 00000000..53a161ab
--- /dev/null
+++ b/subprojects/frontend/src/graph/export/ExportSettingsStore.ts
@@ -0,0 +1,67 @@
1/*
2 * SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/>
3 *
4 * SPDX-License-Identifier: EPL-2.0
5 */
6
7import { makeAutoObservable } from 'mobx';
8
9export type ExportFormat = 'svg' | 'pdf' | 'png';
10export type ExportTheme = 'light' | 'dark';
11
12export default class ExportSettingsStore {
13 format: ExportFormat = 'svg';
14
15 theme: ExportTheme = 'light';
16
17 transparent = true;
18
19 embedSVGFonts = false;
20
21 embedPDFFonts = true;
22
23 scale = 100;
24
25 constructor() {
26 makeAutoObservable(this);
27 }
28
29 setFormat(format: ExportFormat): void {
30 this.format = format;
31 }
32
33 setTheme(theme: ExportTheme): void {
34 this.theme = theme;
35 }
36
37 toggleTransparent(): void {
38 this.transparent = !this.transparent;
39 }
40
41 toggleEmbedFonts(): void {
42 this.embedFonts = !this.embedFonts;
43 }
44
45 setScale(scale: number): void {
46 this.scale = scale;
47 }
48
49 get embedFonts(): boolean {
50 return this.format === 'pdf' ? this.embedPDFFonts : this.embedSVGFonts;
51 }
52
53 private set embedFonts(embedFonts: boolean) {
54 if (this.format === 'pdf') {
55 this.embedPDFFonts = embedFonts;
56 }
57 this.embedSVGFonts = embedFonts;
58 }
59
60 get canEmbedFonts(): boolean {
61 return this.format === 'svg' || this.format === 'pdf';
62 }
63
64 get canScale(): boolean {
65 return this.format === 'png';
66 }
67}