Line wrap toggle for editor and paste viewer with remembered preference (#130)
- wrap toggle button on /new editor and paste view (accent active state) - flips white-space pre <-> pre-wrap on the code body - shared localStorage preference palette-wrap, default off - settings checkbox reads and writes the same preference
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
<svg class="icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
|
||||
<span>Dark mode</span>
|
||||
</button>
|
||||
<h3>Line wrap</h3>
|
||||
<label class="toggle"><input type="checkbox" id="settings-wrap-toggle"> Wrap lines in the editor and paste view</label>
|
||||
<p class="admin-link-row"><a class="admin-link" href="/admin">Admin</a></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,6 +97,15 @@
|
||||
if (btns.length) btns[0].click(); else document.dispatchEvent(new CustomEvent('palette-darkchange'));
|
||||
});
|
||||
document.addEventListener('palette-darkchange', sync);
|
||||
// #130: line wrap setting shares the palette-wrap preference with the
|
||||
// editor and paste view toggles.
|
||||
var wt = document.getElementById('settings-wrap-toggle');
|
||||
try { wt.checked = localStorage.getItem('palette-wrap') === 'true'; } catch (e) {}
|
||||
wt.addEventListener('change', function () {
|
||||
var on = wt.checked;
|
||||
try { localStorage.setItem('palette-wrap', on ? 'true' : 'false'); } catch (e) {}
|
||||
document.dispatchEvent(new CustomEvent('palette-wrapchange', { detail: on }));
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{{template "foot" .}}
|
||||
|
||||
Reference in New Issue
Block a user