@bobfrankston/rmfmail 1.2.303 → 1.2.305

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.
@@ -2389,6 +2389,7 @@ var init_edit_commands = __esm({
2389
2389
  var context_menu_exports = {};
2390
2390
  __export(context_menu_exports, {
2391
2391
  closeContextMenu: () => closeContextMenu,
2392
+ confirmAt: () => confirmAt,
2392
2393
  showContextMenu: () => showContextMenu
2393
2394
  });
2394
2395
  function closeSubmenu() {
@@ -2403,6 +2404,11 @@ function closeContextMenu() {
2403
2404
  activeMenu.remove();
2404
2405
  activeMenu = null;
2405
2406
  }
2407
+ if (closeHandler) {
2408
+ const fn = closeHandler;
2409
+ closeHandler = null;
2410
+ fn();
2411
+ }
2406
2412
  if (dismissListener) {
2407
2413
  document.removeEventListener("pointerdown", dismissListener, true);
2408
2414
  dismissListener = null;
@@ -2453,6 +2459,7 @@ function openSubmenu(parentRow, items) {
2453
2459
  }
2454
2460
  function showContextMenu(x, y, items, opts = {}) {
2455
2461
  closeContextMenu();
2462
+ closeHandler = opts.onClose ?? null;
2456
2463
  if (opts.editTarget !== void 0 || opts.editEngine) {
2457
2464
  const edit = editMenuItems({ target: opts.editTarget, engine: opts.editEngine }, { onError: opts.onEditError });
2458
2465
  if (edit.length > 0) {
@@ -2542,7 +2549,29 @@ function showContextMenu(x, y, items, opts = {}) {
2542
2549
  document.addEventListener("keydown", escapeListener, true);
2543
2550
  });
2544
2551
  }
2545
- var activeMenu, dismissListener, escapeListener, activeSubmenu;
2552
+ function confirmAt(x, y, confirmLabel, opts = {}) {
2553
+ return new Promise((resolve) => {
2554
+ let settled = false;
2555
+ const done = (v) => {
2556
+ if (!settled) {
2557
+ settled = true;
2558
+ resolve(v);
2559
+ }
2560
+ };
2561
+ showContextMenu(x, y, [
2562
+ { label: confirmLabel, action: () => done(true), emphasized: true, tooltip: opts.tooltip },
2563
+ { label: "Cancel", action: () => done(false) }
2564
+ ], {
2565
+ // An item's click calls closeContextMenu() BEFORE item.action(), so
2566
+ // onClose always runs first. Defer the "cancelled" answer by one
2567
+ // microtask: the action is synchronous and finishes within this
2568
+ // task, so by the time the microtask drains, a chosen item has
2569
+ // already settled the promise and this call is a no-op.
2570
+ onClose: () => queueMicrotask(() => done(false))
2571
+ });
2572
+ });
2573
+ }
2574
+ var activeMenu, dismissListener, escapeListener, activeSubmenu, closeHandler;
2546
2575
  var init_context_menu = __esm({
2547
2576
  "client/components/context-menu.js"() {
2548
2577
  "use strict";
@@ -2551,6 +2580,7 @@ var init_context_menu = __esm({
2551
2580
  dismissListener = null;
2552
2581
  escapeListener = null;
2553
2582
  activeSubmenu = null;
2583
+ closeHandler = null;
2554
2584
  document.addEventListener("scroll", closeContextMenu, true);
2555
2585
  document.addEventListener("contextmenu", () => {
2556
2586
  });