@bobfrankston/rmfmail 1.2.234 → 1.2.236

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.
@@ -6607,9 +6607,17 @@ var extEditHintClose = null;
6607
6607
  if (btn) btn.style.display = "none";
6608
6608
  }
6609
6609
  }
6610
+ var wordEditOpening = false;
6610
6611
  document.getElementById("btn-edit-in-word")?.addEventListener("click", async () => {
6612
+ const btn = document.getElementById("btn-edit-in-word");
6613
+ if (wordEditOpening) return;
6614
+ wordEditOpening = true;
6615
+ if (btn) {
6616
+ btn.disabled = true;
6617
+ btn.style.opacity = "0.6";
6618
+ }
6611
6619
  if (!wordEditId) wordEditId = `compose-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
6612
- showDraftStatus("Opening in Word\u2026", false);
6620
+ showDraftStatus("Opening in Word\u2026 (this takes a few seconds)", false);
6613
6621
  try {
6614
6622
  const result = await openInWord(wordEditId, editor.getHtml(), !!popoutInitId);
6615
6623
  if (!result.ok || result.opener === "none") {
@@ -6618,10 +6626,22 @@ document.getElementById("btn-edit-in-word")?.addEventListener("click", async ()
6618
6626
  }
6619
6627
  const label = result.opener === "word" ? "Word" : result.opener === "libreoffice" ? "LibreOffice" : "your default editor";
6620
6628
  const isDocx = /\.docx$/i.test(result.path || "");
6621
- showDraftStatus(`Editing in ${label} \u2014 Ctrl+S there and the message updates here automatically.`, false);
6622
- if (!isDocx) showExternalEditHint(label);
6629
+ if (result.reused) {
6630
+ showDraftStatus(`Already open in ${label} \u2014 brought that window to the front.`, false);
6631
+ } else if (result.superseded) {
6632
+ showDraftStatus(`Opened an updated copy in ${label}. Close the earlier ${label} window \u2014 changes made there no longer come back.`, true);
6633
+ } else {
6634
+ showDraftStatus(`Editing in ${label} \u2014 Ctrl+S there and the message updates here automatically.`, false);
6635
+ if (!isDocx) showExternalEditHint(label);
6636
+ }
6623
6637
  } catch (e) {
6624
6638
  showDraftStatus(`Edit-in-Word failed: ${e?.message || e}`, true);
6639
+ } finally {
6640
+ wordEditOpening = false;
6641
+ if (btn) {
6642
+ btn.disabled = false;
6643
+ btn.style.opacity = "";
6644
+ }
6625
6645
  }
6626
6646
  });
6627
6647
  document.getElementById("btn-compose-help")?.addEventListener("click", async () => {
@@ -6753,9 +6773,13 @@ function showExternalEditHint(editorLabel) {
6753
6773
  }
6754
6774
  onEvent((ev) => {
6755
6775
  if (ev?.type !== "wordEditUpdated") return;
6756
- if (!wordEditId || ev.editId !== wordEditId) return;
6776
+ if (!wordEditId || ev.editId !== wordEditId) {
6777
+ console.log(`[word-edit] ignoring save for ${ev.editId} \u2014 this window is ${wordEditId || "(no session)"}`);
6778
+ return;
6779
+ }
6757
6780
  try {
6758
6781
  extEditHintClose?.();
6782
+ console.log(`[word-edit] applying mirrored save: ${(ev.html || "").length} chars (editId ${ev.editId})`);
6759
6783
  editor.setHtml(ev.html || "");
6760
6784
  showDraftStatus("Reloaded edits from external editor.", false);
6761
6785
  scheduleDraftSave();