- Auto-run toggle with localStorage persistence (toolbar checkbox) - Layout selector: default, top/bottom, editor-only, preview-only - Resizable panels via drag dividers with double-click reset - Emmet abbreviation expansion for HTML, CSS, and JSX - Vim and Emacs keybinding modes with lazy-loaded CDN libraries - Shared preferences module for localStorage management - Editor hooks for tab switch and mode change callbacks
23 lines
503 B
JavaScript
23 lines
503 B
JavaScript
const PREFIX = 'fiddle_';
|
|
|
|
const DEFAULTS = {
|
|
autoRun: true,
|
|
layout: 'default',
|
|
keybindings: 'default',
|
|
panelSizes: null,
|
|
};
|
|
|
|
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);
|
|
}
|