|
1 | 1 | import { SnippngEditorConfigInterface } from "@/types"; |
| 2 | +import { LocalStorage } from "@/utils"; |
| 3 | + |
| 4 | +export const isBrowser = typeof window !== "undefined"; |
2 | 5 |
|
3 | 6 | export const THEMES = [ |
4 | 7 | { |
@@ -514,31 +517,40 @@ export const PEXELS_QUERY_STRINGS = [ |
514 | 517 | "technology", |
515 | 518 | ]; |
516 | 519 |
|
517 | | -export const defaultEditorConfig: SnippngEditorConfigInterface = { |
518 | | - code: DEFAULT_CODE_SNIPPET, |
519 | | - snippetsName: "", |
520 | | - editorFontSize: 16, |
521 | | - editorWindowControlsType: "mac-left", |
522 | | - fileName: "@utils/debounce.ts", |
523 | | - hasDropShadow: true, |
524 | | - lineHeight: 19, |
525 | | - paddingHorizontal: 70, |
526 | | - paddingVertical: 70, |
527 | | - rounded: true, |
528 | | - selectedLang: |
529 | | - LANGUAGES.find((language) => language.id === "typescript") || LANGUAGES[0], |
530 | | - selectedTheme: |
531 | | - THEMES.find((theme) => theme.id === "tokyoNightStorm") || THEMES[0], |
532 | | - showFileName: true, |
533 | | - showLineNumbers: true, |
534 | | - wrapperBg: "#eee811", |
535 | | - gradients: ["#ba68c8", "#ffa7c4", "#e57373"], |
536 | | - gradientAngle: 140, |
537 | | - editorWidth: 0, |
538 | | - bgImageVisiblePatch: null, |
539 | | - bgBlur: 0, |
| 520 | +const getConfig = (): SnippngEditorConfigInterface => { |
| 521 | + let persistedConfig = LocalStorage.get( |
| 522 | + "config" |
| 523 | + ) as SnippngEditorConfigInterface; |
| 524 | + if (persistedConfig) return persistedConfig; |
| 525 | + return { |
| 526 | + code: DEFAULT_CODE_SNIPPET, |
| 527 | + snippetsName: "", |
| 528 | + editorFontSize: 16, |
| 529 | + editorWindowControlsType: "mac-left", |
| 530 | + fileName: "@utils/debounce.ts", |
| 531 | + hasDropShadow: true, |
| 532 | + lineHeight: 19, |
| 533 | + paddingHorizontal: 70, |
| 534 | + paddingVertical: 70, |
| 535 | + rounded: true, |
| 536 | + selectedLang: |
| 537 | + LANGUAGES.find((language) => language.id === "typescript") || |
| 538 | + LANGUAGES[0], |
| 539 | + selectedTheme: |
| 540 | + THEMES.find((theme) => theme.id === "tokyoNightStorm") || THEMES[0], |
| 541 | + showFileName: true, |
| 542 | + showLineNumbers: true, |
| 543 | + wrapperBg: "#eee811", |
| 544 | + gradients: ["#ba68c8", "#ffa7c4", "#e57373"], |
| 545 | + gradientAngle: 140, |
| 546 | + editorWidth: 0, |
| 547 | + bgImageVisiblePatch: null, |
| 548 | + bgBlur: 0, |
| 549 | + }; |
540 | 550 | }; |
541 | 551 |
|
| 552 | +export const defaultEditorConfig: SnippngEditorConfigInterface = getConfig(); |
| 553 | + |
542 | 554 | export const DEFAULT_BASE_SETUP = { |
543 | 555 | foldGutter: false, |
544 | 556 | highlightActiveLine: false, |
|
0 commit comments