Add line wrap toggle for editor and paste viewer (#130)
Shared client-side preference in localStorage 'palette-wrap', default off. Toggle button on /new editor head and paste title bar, plus a Line wrap checkbox in the settings menu; all read/write the same preference. Active state uses the accent treatment like other toggles. No em dashes in UI text.
This commit is contained in:
@@ -46,6 +46,37 @@
|
||||
// do not persist anything here: URL theme is a one-off override
|
||||
document.documentElement.dataset.preset = dark ? PAIRS[t].dark : PAIRS[t].light;
|
||||
})();
|
||||
// #130: shared line wrap preference (localStorage 'palette-wrap', default off)
|
||||
(function () {
|
||||
function wrapOn() {
|
||||
try { return localStorage.getItem('palette-wrap') === '1'; } catch (e) { return false; }
|
||||
}
|
||||
function wrapApply(on) {
|
||||
if (on) document.documentElement.setAttribute('data-wrap', '1');
|
||||
else document.documentElement.removeAttribute('data-wrap');
|
||||
document.querySelectorAll('.wrap-toggle').forEach(function (b) {
|
||||
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
||||
});
|
||||
var s = document.getElementById('wrap-setting');
|
||||
if (s) s.checked = on;
|
||||
}
|
||||
window.paletteWrapToggle = function () {
|
||||
var on = !wrapOn();
|
||||
try { localStorage.setItem('palette-wrap', on ? '1' : '0'); } catch (e) {}
|
||||
wrapApply(on);
|
||||
return on;
|
||||
};
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
wrapApply(wrapOn());
|
||||
document.querySelectorAll('.wrap-toggle').forEach(function (b) {
|
||||
b.addEventListener('click', function () { window.paletteWrapToggle(); });
|
||||
});
|
||||
var s = document.getElementById('wrap-setting');
|
||||
if (s) s.addEventListener('change', function () {
|
||||
if (s.checked !== wrapOn()) window.paletteWrapToggle();
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user