|
6 | 6 | import monacoThemeGithubLight from 'monaco-themes/themes/GitHub Light.json'; |
7 | 7 | import monacoThemeGithubDark from 'monaco-themes/themes/GitHub Dark.json'; |
8 | 8 | import type { LocalSettingsStore } from '$lib'; |
| 9 | + import type { JSONSaveData } from '$lib/json'; |
9 | 10 |
|
10 | | - let { accountData = $bindable() }: { accountData: any } = $props(); |
| 11 | + let { data = $bindable() }: { data: JSONSaveData } = $props(); |
11 | 12 |
|
12 | 13 | let parent: HTMLElement; |
13 | 14 | let editor: monaco.editor.IStandaloneCodeEditor; |
|
17 | 18 | const localSettings = getContext('localSettings') as LocalSettingsStore; |
18 | 19 |
|
19 | 20 | $effect(() => { |
20 | | - if (editor && accountData) { |
| 21 | + if (editor && data) { |
21 | 22 | const currentValue = editor.getValue(); |
22 | | - const newValue = JSON.stringify(accountData, null, 2); |
| 23 | + const newValue = JSON.stringify(data, null, 2); |
23 | 24 | if (currentValue !== newValue) { |
24 | 25 | editor.setValue(newValue); |
25 | 26 | } |
|
63 | 64 | }); |
64 | 65 |
|
65 | 66 | editor = Monaco.editor.create(parent, { |
66 | | - value: JSON.stringify(accountData, null, 2), |
| 67 | + value: JSON.stringify(data, null, 2), |
67 | 68 | language: 'json', |
68 | 69 | theme: localSettings.theme === 'dark' ? 'github-dark' : 'github-light', |
69 | 70 | automaticLayout: true |
|
78 | 79 | editor.onDidChangeModelContent(() => { |
79 | 80 | const newValue = editor.getValue(); |
80 | 81 | try { |
81 | | - accountData = JSON.parse(newValue); |
| 82 | + data = JSON.parse(newValue); |
82 | 83 | } catch (e) { |
83 | 84 | console.error('Invalid JSON:', e); |
84 | 85 | } |
85 | | - console.log('Account Data Updated:', accountData); |
| 86 | + console.log('Account Data Updated:', data); |
86 | 87 | }); |
87 | 88 |
|
88 | 89 | return () => { |
|
0 commit comments