From 67648f06f948f70da24c71f1535f8e5e457de5cb Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Sat, 24 Jan 2026 08:04:37 -0500 Subject: [PATCH] Persist preview visibility state in localStorage --- remarkbox/static/js/custom.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/remarkbox/static/js/custom.js b/remarkbox/static/js/custom.js index cf83576..92c5df1 100644 --- a/remarkbox/static/js/custom.js +++ b/remarkbox/static/js/custom.js @@ -90,7 +90,7 @@ function toggle(target, button, off_text, on_text) { } } -// Animate
close for preview-details elements. +// Animate
close for preview-details elements and persist state in localStorage. if (typeof document.addEventListener === 'function') { document.addEventListener('click', function(e) { var summary = e.target.closest('.preview-toggle'); @@ -100,10 +100,13 @@ if (typeof document.addEventListener === 'function') { if (details.open && !details.classList.contains('closing')) { e.preventDefault(); details.classList.add('closing'); + localStorage.setItem('remarkbox-preview-hidden', 'true'); setTimeout(function() { details.open = false; details.classList.remove('closing'); }, 800); + } else if (!details.open) { + localStorage.removeItem('remarkbox-preview-hidden'); } }, true); } @@ -118,6 +121,13 @@ function autoGrow(el) { // Initialize on DOM ready document.addEventListener('DOMContentLoaded', function() { + // Restore preview state from localStorage + if (localStorage.getItem('remarkbox-preview-hidden') === 'true') { + document.querySelectorAll('.preview-details').forEach(function(details) { + details.open = false; + }); + } + // Auto-grow textareas on input document.querySelectorAll('.common-textarea').forEach(function(textarea) { textarea.addEventListener('input', function() {