(value: string | null | undefined, fallback = "")
| 22 | ] as const; |
| 23 | |
| 24 | export function normalizeThemeColor(value: string | null | undefined, fallback = ""): string { |
| 25 | const trimmed = value?.trim() ?? ""; |
| 26 | if (!trimmed) return fallback; |
| 27 | |
| 28 | const lower = trimmed.toLowerCase(); |
| 29 | if (OBSIDIAN_THEME_COLOR_SET.has(lower)) { |
| 30 | return `var(--color-${lower})`; |
| 31 | } |
| 32 | if (lower === "accent") { |
| 33 | return "var(--color-accent)"; |
| 34 | } |
| 35 | if (lower.startsWith("color-")) { |
| 36 | const colorName = lower.slice("color-".length); |
| 37 | if (OBSIDIAN_THEME_COLOR_SET.has(colorName) || colorName === "accent") { |
| 38 | return `var(--${lower})`; |
| 39 | } |
| 40 | } |
| 41 | if (lower.startsWith("--")) { |
| 42 | return `var(${trimmed})`; |
| 43 | } |
| 44 | |
| 45 | return trimmed; |
| 46 | } |
| 47 | |
| 48 | export function colorValueToInputValue(value: string | null | undefined): string { |
| 49 | const trimmed = value?.trim() ?? ""; |
no test coverage detected