Added Queued Pastes
Some checks failed
/ publish (push) Failing after 1m21s

This commit is contained in:
Leon Mika 2026-09-16 21:52:03 +10:00
parent 40e5379eb3
commit de63c48da2
9 changed files with 415 additions and 1 deletions

View file

@ -0,0 +1,27 @@
// Serialization for the Queued Pastes preferences stored in localStorage
// under the key 'queued-paste-prefs'. Pure functions so they can be unit
// tested under Node (see prefs.test.mjs).
const DEFAULTS = { newLines: false, advanceFocus: false };
export function serializePrefs(prefs) {
return JSON.stringify({
'new-lines': Boolean(prefs.newLines),
'advance-focus': Boolean(prefs.advanceFocus),
});
}
export function parsePrefs(json) {
try {
const obj = JSON.parse(json);
if (obj === null || typeof obj !== 'object') {
return { ...DEFAULTS };
}
return {
newLines: obj['new-lines'] === true,
advanceFocus: obj['advance-focus'] === true,
};
} catch {
return { ...DEFAULTS };
}
}