@bobfrankston/rmfmail 1.0.519 → 1.0.521

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -2923,8 +2923,22 @@ async function openJsoncEditor(initialFile) {
2923
2923
  errorEl.hidden = true;
2924
2924
  btn.disabled = true;
2925
2925
  btn.textContent = "Saving...";
2926
+ // Auto-format before save: the service-side formatter does
2927
+ // whitespace-only edits via jsonc-parser, so // and /* */
2928
+ // comments survive. If the format call fails (network /
2929
+ // parse) we fall back to the raw text — better to save
2930
+ // something than lose the user's edit.
2931
+ let toWrite = textarea.value;
2926
2932
  try {
2927
- await writeJsoncFile(fileSelect.value, textarea.value);
2933
+ const r = await formatJsonc(textarea.value);
2934
+ if (r?.content !== undefined) {
2935
+ toWrite = r.content;
2936
+ textarea.value = r.content;
2937
+ }
2938
+ }
2939
+ catch { /* keep raw text */ }
2940
+ try {
2941
+ await writeJsoncFile(fileSelect.value, toWrite);
2928
2942
  close();
2929
2943
  const statusSync = document.getElementById("status-sync");
2930
2944
  if (statusSync)