- Device breakpoint toggles (mobile 375px / tablet 768px / desktop 100%) - Editor theme selector with 6 themes (VS Dark/Light, High Contrast, Monokai, Dracula, GitHub Dark) - Starter template gallery with 8 pre-built templates (Todo, API Fetch, CSS Animation, etc.) - Code autocomplete with DOM/React type definitions and snippet completions - Devtools panels: console, network, elements, performance - Code formatter (Prettier), diff view, and linter integration
26 lines
582 B
JavaScript
26 lines
582 B
JavaScript
const PREFIX = 'fiddle_';
|
|
|
|
const DEFAULTS = {
|
|
autoRun: true,
|
|
layout: 'default',
|
|
keybindings: 'default',
|
|
panelSizes: null,
|
|
previewTheme: 'light',
|
|
previewDevice: 'desktop',
|
|
editorTheme: 'vs-dark',
|
|
};
|
|
|
|
export function getPref(key) {
|
|
const raw = localStorage.getItem(PREFIX + key);
|
|
if (raw === null) return DEFAULTS[key] ?? null;
|
|
try { return JSON.parse(raw); } catch { return raw; }
|
|
}
|
|
|
|
export function setPref(key, value) {
|
|
localStorage.setItem(PREFIX + key, JSON.stringify(value));
|
|
}
|
|
|
|
export function removePref(key) {
|
|
localStorage.removeItem(PREFIX + key);
|
|
}
|