@bobfrankston/rmfmail 1.2.230 → 1.2.232

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.
@@ -2256,13 +2256,9 @@ var init_edit_menu = __esm({
2256
2256
  // client/compose/edit-commands.js
2257
2257
  var edit_commands_exports = {};
2258
2258
  __export(edit_commands_exports, {
2259
- runClipboardCommand: () => runClipboardCommand,
2260
2259
  runFormatCommand: () => runFormatCommand,
2261
2260
  standardEditItems: () => standardEditItems
2262
2261
  });
2263
- function runClipboardCommand(ne, id) {
2264
- return runClipboard({ engine: ne }, id);
2265
- }
2266
2262
  function isTinyEditor(ne) {
2267
2263
  return !!ne && typeof ne.execCommand === "function" && !!ne.selection;
2268
2264
  }
@@ -2367,6 +2363,182 @@ var init_edit_commands = __esm({
2367
2363
  }
2368
2364
  });
2369
2365
 
2366
+ // client/components/context-menu.js
2367
+ var context_menu_exports = {};
2368
+ __export(context_menu_exports, {
2369
+ closeContextMenu: () => closeContextMenu,
2370
+ showContextMenu: () => showContextMenu
2371
+ });
2372
+ function closeSubmenu() {
2373
+ if (activeSubmenu) {
2374
+ activeSubmenu.remove();
2375
+ activeSubmenu = null;
2376
+ }
2377
+ }
2378
+ function closeContextMenu() {
2379
+ closeSubmenu();
2380
+ if (activeMenu) {
2381
+ activeMenu.remove();
2382
+ activeMenu = null;
2383
+ }
2384
+ if (dismissListener) {
2385
+ document.removeEventListener("pointerdown", dismissListener, true);
2386
+ dismissListener = null;
2387
+ }
2388
+ if (escapeListener) {
2389
+ document.removeEventListener("keydown", escapeListener, true);
2390
+ escapeListener = null;
2391
+ }
2392
+ }
2393
+ function openSubmenu(parentRow, items) {
2394
+ closeSubmenu();
2395
+ const sub = document.createElement("div");
2396
+ sub.className = "ctx-menu";
2397
+ for (const item of items) {
2398
+ if (item.separator) {
2399
+ const sep = document.createElement("div");
2400
+ sep.className = "ctx-sep";
2401
+ sub.appendChild(sep);
2402
+ continue;
2403
+ }
2404
+ const el = document.createElement("div");
2405
+ el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "");
2406
+ el.textContent = item.label;
2407
+ if (item.tooltip)
2408
+ el.title = item.tooltip;
2409
+ if (!item.disabled) {
2410
+ el.addEventListener("click", () => {
2411
+ closeContextMenu();
2412
+ item.action();
2413
+ });
2414
+ }
2415
+ sub.appendChild(el);
2416
+ }
2417
+ document.body.appendChild(sub);
2418
+ const anchor = parentRow.getBoundingClientRect();
2419
+ const vw = window.visualViewport?.width ?? window.innerWidth;
2420
+ const vh = window.visualViewport?.height ?? window.innerHeight;
2421
+ const rect = sub.getBoundingClientRect();
2422
+ let left = anchor.right - 2;
2423
+ if (left + rect.width > vw)
2424
+ left = anchor.left - rect.width + 2;
2425
+ let top = anchor.top;
2426
+ if (top + rect.height > vh)
2427
+ top = vh - rect.height - 4;
2428
+ sub.style.left = `${Math.max(4, left)}px`;
2429
+ sub.style.top = `${Math.max(4, top)}px`;
2430
+ activeSubmenu = sub;
2431
+ }
2432
+ function showContextMenu(x, y, items, opts = {}) {
2433
+ closeContextMenu();
2434
+ if (opts.editTarget !== void 0 || opts.editEngine) {
2435
+ const edit = editMenuItems({ target: opts.editTarget, engine: opts.editEngine }, { onError: opts.onEditError });
2436
+ if (edit.length > 0) {
2437
+ items = items.length > 0 ? [...edit, { label: "", action: () => {
2438
+ }, separator: true }, ...items] : edit;
2439
+ }
2440
+ }
2441
+ const menu = document.createElement("div");
2442
+ menu.className = "ctx-menu";
2443
+ for (const item of items) {
2444
+ if (item.separator) {
2445
+ const sep = document.createElement("div");
2446
+ sep.className = "ctx-sep";
2447
+ menu.appendChild(sep);
2448
+ continue;
2449
+ }
2450
+ const el = document.createElement("div");
2451
+ el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "") + (item.emphasized ? " ctx-emphasized" : "");
2452
+ if (item.emphasized)
2453
+ el.style.fontWeight = "600";
2454
+ el.textContent = item.label;
2455
+ if (item.tooltip)
2456
+ el.title = item.tooltip;
2457
+ if (item.submenu && item.submenu.length > 0 && !item.disabled) {
2458
+ el.style.display = "flex";
2459
+ el.style.justifyContent = "space-between";
2460
+ el.style.gap = "12px";
2461
+ const caret = document.createElement("span");
2462
+ caret.textContent = "\u25B8";
2463
+ caret.style.opacity = "0.6";
2464
+ el.appendChild(caret);
2465
+ const open = () => openSubmenu(el, item.submenu);
2466
+ el.addEventListener("mouseenter", open);
2467
+ el.addEventListener("click", (e) => {
2468
+ e.stopPropagation();
2469
+ open();
2470
+ });
2471
+ menu.appendChild(el);
2472
+ continue;
2473
+ }
2474
+ el.addEventListener("mouseenter", closeSubmenu);
2475
+ if (!item.disabled) {
2476
+ el.addEventListener("click", () => {
2477
+ closeContextMenu();
2478
+ item.action();
2479
+ });
2480
+ }
2481
+ menu.appendChild(el);
2482
+ }
2483
+ menu.style.left = `${x}px`;
2484
+ menu.style.top = `${y}px`;
2485
+ document.body.appendChild(menu);
2486
+ const vw = window.visualViewport?.width ?? window.innerWidth;
2487
+ const vh = window.visualViewport?.height ?? window.innerHeight;
2488
+ let rect = menu.getBoundingClientRect();
2489
+ if (rect.height > vh - 8) {
2490
+ menu.style.maxHeight = `${vh - 8}px`;
2491
+ menu.style.overflowY = "auto";
2492
+ rect = menu.getBoundingClientRect();
2493
+ }
2494
+ let left = x, top = y;
2495
+ if (left + rect.width > vw)
2496
+ left = x - rect.width;
2497
+ if (top + rect.height > vh)
2498
+ top = y - rect.height;
2499
+ left = Math.max(4, Math.min(left, vw - rect.width - 4));
2500
+ top = Math.max(4, Math.min(top, vh - rect.height - 4));
2501
+ menu.style.left = `${left}px`;
2502
+ menu.style.top = `${top}px`;
2503
+ activeMenu = menu;
2504
+ requestAnimationFrame(() => {
2505
+ dismissListener = (e) => {
2506
+ if (activeSubmenu?.contains(e.target))
2507
+ return;
2508
+ if (activeMenu && !activeMenu.contains(e.target)) {
2509
+ closeContextMenu();
2510
+ }
2511
+ };
2512
+ document.addEventListener("pointerdown", dismissListener, true);
2513
+ escapeListener = (e) => {
2514
+ if (e.key === "Escape") {
2515
+ e.preventDefault();
2516
+ e.stopPropagation();
2517
+ closeContextMenu();
2518
+ }
2519
+ };
2520
+ document.addEventListener("keydown", escapeListener, true);
2521
+ });
2522
+ }
2523
+ var activeMenu, dismissListener, escapeListener, activeSubmenu;
2524
+ var init_context_menu = __esm({
2525
+ "client/components/context-menu.js"() {
2526
+ "use strict";
2527
+ init_edit_menu();
2528
+ activeMenu = null;
2529
+ dismissListener = null;
2530
+ escapeListener = null;
2531
+ activeSubmenu = null;
2532
+ document.addEventListener("scroll", closeContextMenu, true);
2533
+ document.addEventListener("contextmenu", () => {
2534
+ });
2535
+ window.addEventListener("message", (e) => {
2536
+ if (e.data && e.data.type === "iframePointerDown")
2537
+ closeContextMenu();
2538
+ });
2539
+ }
2540
+ });
2541
+
2370
2542
  // client/lib/rmf-tiny.js
2371
2543
  var rmf_tiny_exports = {};
2372
2544
  __export(rmf_tiny_exports, {
@@ -4360,38 +4532,26 @@ function createQuillEditor(container2) {
4360
4532
  if (!text.trim())
4361
4533
  return;
4362
4534
  e.preventDefault();
4363
- const menu = document.createElement("div");
4364
- menu.style.cssText = `position:fixed;z-index:2500;background:var(--color-bg);color:var(--color-text);border:1px solid var(--color-border);border-radius:6px;box-shadow:0 4px 16px rgba(0,0,0,0.2);padding:4px 0;font-size:13px;min-width:160px;`;
4365
- menu.style.left = `${e.clientX}px`;
4366
- menu.style.top = `${e.clientY}px`;
4367
- const item = document.createElement("div");
4368
- item.textContent = "Proofread selection";
4369
- item.style.cssText = `padding:6px 12px;cursor:pointer;`;
4370
- item.addEventListener("mouseenter", () => item.style.background = "var(--color-bg-hover)");
4371
- item.addEventListener("mouseleave", () => item.style.background = "");
4372
- item.addEventListener("click", async () => {
4373
- menu.remove();
4374
- try {
4375
- const { aiTransform: aiTransform2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
4376
- const r = await aiTransform2({ action: "proofread", text });
4377
- if (r?.text && r.text !== text) {
4378
- q.deleteText(sel.index, sel.length);
4379
- q.insertText(sel.index, r.text);
4380
- q.setSelection(sel.index, r.text.length);
4381
- } else if (r?.reason) {
4382
- alert(`Proofread: ${r.reason}`);
4535
+ const { showContextMenu: showContextMenu2 } = await Promise.resolve().then(() => (init_context_menu(), context_menu_exports));
4536
+ const { standardEditItems: standardEditItems2 } = await Promise.resolve().then(() => (init_edit_commands(), edit_commands_exports));
4537
+ showContextMenu2(e.clientX, e.clientY, [
4538
+ { label: "Proofread selection", action: async () => {
4539
+ try {
4540
+ const { aiTransform: aiTransform2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
4541
+ const r = await aiTransform2({ action: "proofread", text });
4542
+ if (r?.text && r.text !== text) {
4543
+ q.deleteText(sel.index, sel.length);
4544
+ q.insertText(sel.index, r.text);
4545
+ q.setSelection(sel.index, r.text.length);
4546
+ } else if (r?.reason) {
4547
+ alert(`Proofread: ${r.reason}`);
4548
+ }
4549
+ } catch (err) {
4550
+ alert(`Proofread failed: ${err?.message || err}`);
4383
4551
  }
4384
- } catch (err) {
4385
- alert(`Proofread failed: ${err?.message || err}`);
4386
- }
4387
- });
4388
- menu.appendChild(item);
4389
- document.body.appendChild(menu);
4390
- const dismiss2 = () => {
4391
- menu.remove();
4392
- document.removeEventListener("mousedown", dismiss2);
4393
- };
4394
- setTimeout(() => document.addEventListener("mousedown", dismiss2), 0);
4552
+ } },
4553
+ ...standardEditItems2(() => q)
4554
+ ]);
4395
4555
  } catch {
4396
4556
  }
4397
4557
  });
@@ -4820,173 +4980,7 @@ async function createTinyMceEditor2(container2, opts = {}) {
4820
4980
  // client/compose/compose.ts
4821
4981
  init_api_client();
4822
4982
  init_edit_commands();
4823
-
4824
- // client/components/context-menu.js
4825
- init_edit_menu();
4826
- var activeMenu = null;
4827
- var dismissListener = null;
4828
- var escapeListener = null;
4829
- var activeSubmenu = null;
4830
- function closeSubmenu() {
4831
- if (activeSubmenu) {
4832
- activeSubmenu.remove();
4833
- activeSubmenu = null;
4834
- }
4835
- }
4836
- function closeContextMenu() {
4837
- closeSubmenu();
4838
- if (activeMenu) {
4839
- activeMenu.remove();
4840
- activeMenu = null;
4841
- }
4842
- if (dismissListener) {
4843
- document.removeEventListener("pointerdown", dismissListener, true);
4844
- dismissListener = null;
4845
- }
4846
- if (escapeListener) {
4847
- document.removeEventListener("keydown", escapeListener, true);
4848
- escapeListener = null;
4849
- }
4850
- }
4851
- function openSubmenu(parentRow, items) {
4852
- closeSubmenu();
4853
- const sub = document.createElement("div");
4854
- sub.className = "ctx-menu";
4855
- for (const item of items) {
4856
- if (item.separator) {
4857
- const sep = document.createElement("div");
4858
- sep.className = "ctx-sep";
4859
- sub.appendChild(sep);
4860
- continue;
4861
- }
4862
- const el = document.createElement("div");
4863
- el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "");
4864
- el.textContent = item.label;
4865
- if (item.tooltip)
4866
- el.title = item.tooltip;
4867
- if (!item.disabled) {
4868
- el.addEventListener("click", () => {
4869
- closeContextMenu();
4870
- item.action();
4871
- });
4872
- }
4873
- sub.appendChild(el);
4874
- }
4875
- document.body.appendChild(sub);
4876
- const anchor = parentRow.getBoundingClientRect();
4877
- const vw = window.visualViewport?.width ?? window.innerWidth;
4878
- const vh = window.visualViewport?.height ?? window.innerHeight;
4879
- const rect = sub.getBoundingClientRect();
4880
- let left = anchor.right - 2;
4881
- if (left + rect.width > vw)
4882
- left = anchor.left - rect.width + 2;
4883
- let top = anchor.top;
4884
- if (top + rect.height > vh)
4885
- top = vh - rect.height - 4;
4886
- sub.style.left = `${Math.max(4, left)}px`;
4887
- sub.style.top = `${Math.max(4, top)}px`;
4888
- activeSubmenu = sub;
4889
- }
4890
- function showContextMenu(x, y, items, opts = {}) {
4891
- closeContextMenu();
4892
- if (opts.editTarget !== void 0 || opts.editEngine) {
4893
- const edit = editMenuItems({ target: opts.editTarget, engine: opts.editEngine }, { onError: opts.onEditError });
4894
- if (edit.length > 0) {
4895
- items = items.length > 0 ? [...edit, { label: "", action: () => {
4896
- }, separator: true }, ...items] : edit;
4897
- }
4898
- }
4899
- const menu = document.createElement("div");
4900
- menu.className = "ctx-menu";
4901
- for (const item of items) {
4902
- if (item.separator) {
4903
- const sep = document.createElement("div");
4904
- sep.className = "ctx-sep";
4905
- menu.appendChild(sep);
4906
- continue;
4907
- }
4908
- const el = document.createElement("div");
4909
- el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "") + (item.emphasized ? " ctx-emphasized" : "");
4910
- if (item.emphasized)
4911
- el.style.fontWeight = "600";
4912
- el.textContent = item.label;
4913
- if (item.tooltip)
4914
- el.title = item.tooltip;
4915
- if (item.submenu && item.submenu.length > 0 && !item.disabled) {
4916
- el.style.display = "flex";
4917
- el.style.justifyContent = "space-between";
4918
- el.style.gap = "12px";
4919
- const caret = document.createElement("span");
4920
- caret.textContent = "\u25B8";
4921
- caret.style.opacity = "0.6";
4922
- el.appendChild(caret);
4923
- const open = () => openSubmenu(el, item.submenu);
4924
- el.addEventListener("mouseenter", open);
4925
- el.addEventListener("click", (e) => {
4926
- e.stopPropagation();
4927
- open();
4928
- });
4929
- menu.appendChild(el);
4930
- continue;
4931
- }
4932
- el.addEventListener("mouseenter", closeSubmenu);
4933
- if (!item.disabled) {
4934
- el.addEventListener("click", () => {
4935
- closeContextMenu();
4936
- item.action();
4937
- });
4938
- }
4939
- menu.appendChild(el);
4940
- }
4941
- menu.style.left = `${x}px`;
4942
- menu.style.top = `${y}px`;
4943
- document.body.appendChild(menu);
4944
- const vw = window.visualViewport?.width ?? window.innerWidth;
4945
- const vh = window.visualViewport?.height ?? window.innerHeight;
4946
- let rect = menu.getBoundingClientRect();
4947
- if (rect.height > vh - 8) {
4948
- menu.style.maxHeight = `${vh - 8}px`;
4949
- menu.style.overflowY = "auto";
4950
- rect = menu.getBoundingClientRect();
4951
- }
4952
- let left = x, top = y;
4953
- if (left + rect.width > vw)
4954
- left = x - rect.width;
4955
- if (top + rect.height > vh)
4956
- top = y - rect.height;
4957
- left = Math.max(4, Math.min(left, vw - rect.width - 4));
4958
- top = Math.max(4, Math.min(top, vh - rect.height - 4));
4959
- menu.style.left = `${left}px`;
4960
- menu.style.top = `${top}px`;
4961
- activeMenu = menu;
4962
- requestAnimationFrame(() => {
4963
- dismissListener = (e) => {
4964
- if (activeSubmenu?.contains(e.target))
4965
- return;
4966
- if (activeMenu && !activeMenu.contains(e.target)) {
4967
- closeContextMenu();
4968
- }
4969
- };
4970
- document.addEventListener("pointerdown", dismissListener, true);
4971
- escapeListener = (e) => {
4972
- if (e.key === "Escape") {
4973
- e.preventDefault();
4974
- e.stopPropagation();
4975
- closeContextMenu();
4976
- }
4977
- };
4978
- document.addEventListener("keydown", escapeListener, true);
4979
- });
4980
- }
4981
- document.addEventListener("scroll", closeContextMenu, true);
4982
- document.addEventListener("contextmenu", () => {
4983
- });
4984
- window.addEventListener("message", (e) => {
4985
- if (e.data && e.data.type === "iframePointerDown")
4986
- closeContextMenu();
4987
- });
4988
-
4989
- // client/compose/compose.ts
4983
+ init_context_menu();
4990
4984
  installConsoleCapture();
4991
4985
  logClientEvent("compose-module-loaded", { href: location.href, version: window.mailxVersion || "?" });
4992
4986
  var _composeT0 = performance.now();
@@ -5458,7 +5452,7 @@ function showAutocompleteContextMenu(e, row) {
5458
5452
  window.open(`https://contacts.google.com/search/${encodeURIComponent(row.name || row.email)}`, "_blank");
5459
5453
  }
5460
5454
  }
5461
- ]);
5455
+ ], { editTarget: e.target });
5462
5456
  }
5463
5457
  function openAddToPreferredModal(prefill) {
5464
5458
  const overlay = document.createElement("div");