@bobfrankston/rmfmail 1.2.231 → 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.
@@ -2363,6 +2363,182 @@ var init_edit_commands = __esm({
2363
2363
  }
2364
2364
  });
2365
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
+
2366
2542
  // client/lib/rmf-tiny.js
2367
2543
  var rmf_tiny_exports = {};
2368
2544
  __export(rmf_tiny_exports, {
@@ -4356,38 +4532,26 @@ function createQuillEditor(container2) {
4356
4532
  if (!text.trim())
4357
4533
  return;
4358
4534
  e.preventDefault();
4359
- const menu = document.createElement("div");
4360
- 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;`;
4361
- menu.style.left = `${e.clientX}px`;
4362
- menu.style.top = `${e.clientY}px`;
4363
- const item = document.createElement("div");
4364
- item.textContent = "Proofread selection";
4365
- item.style.cssText = `padding:6px 12px;cursor:pointer;`;
4366
- item.addEventListener("mouseenter", () => item.style.background = "var(--color-bg-hover)");
4367
- item.addEventListener("mouseleave", () => item.style.background = "");
4368
- item.addEventListener("click", async () => {
4369
- menu.remove();
4370
- try {
4371
- const { aiTransform: aiTransform2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
4372
- const r = await aiTransform2({ action: "proofread", text });
4373
- if (r?.text && r.text !== text) {
4374
- q.deleteText(sel.index, sel.length);
4375
- q.insertText(sel.index, r.text);
4376
- q.setSelection(sel.index, r.text.length);
4377
- } else if (r?.reason) {
4378
- 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}`);
4379
4551
  }
4380
- } catch (err) {
4381
- alert(`Proofread failed: ${err?.message || err}`);
4382
- }
4383
- });
4384
- menu.appendChild(item);
4385
- document.body.appendChild(menu);
4386
- const dismiss2 = () => {
4387
- menu.remove();
4388
- document.removeEventListener("mousedown", dismiss2);
4389
- };
4390
- setTimeout(() => document.addEventListener("mousedown", dismiss2), 0);
4552
+ } },
4553
+ ...standardEditItems2(() => q)
4554
+ ]);
4391
4555
  } catch {
4392
4556
  }
4393
4557
  });
@@ -4816,173 +4980,7 @@ async function createTinyMceEditor2(container2, opts = {}) {
4816
4980
  // client/compose/compose.ts
4817
4981
  init_api_client();
4818
4982
  init_edit_commands();
4819
-
4820
- // client/components/context-menu.js
4821
- init_edit_menu();
4822
- var activeMenu = null;
4823
- var dismissListener = null;
4824
- var escapeListener = null;
4825
- var activeSubmenu = null;
4826
- function closeSubmenu() {
4827
- if (activeSubmenu) {
4828
- activeSubmenu.remove();
4829
- activeSubmenu = null;
4830
- }
4831
- }
4832
- function closeContextMenu() {
4833
- closeSubmenu();
4834
- if (activeMenu) {
4835
- activeMenu.remove();
4836
- activeMenu = null;
4837
- }
4838
- if (dismissListener) {
4839
- document.removeEventListener("pointerdown", dismissListener, true);
4840
- dismissListener = null;
4841
- }
4842
- if (escapeListener) {
4843
- document.removeEventListener("keydown", escapeListener, true);
4844
- escapeListener = null;
4845
- }
4846
- }
4847
- function openSubmenu(parentRow, items) {
4848
- closeSubmenu();
4849
- const sub = document.createElement("div");
4850
- sub.className = "ctx-menu";
4851
- for (const item of items) {
4852
- if (item.separator) {
4853
- const sep = document.createElement("div");
4854
- sep.className = "ctx-sep";
4855
- sub.appendChild(sep);
4856
- continue;
4857
- }
4858
- const el = document.createElement("div");
4859
- el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "");
4860
- el.textContent = item.label;
4861
- if (item.tooltip)
4862
- el.title = item.tooltip;
4863
- if (!item.disabled) {
4864
- el.addEventListener("click", () => {
4865
- closeContextMenu();
4866
- item.action();
4867
- });
4868
- }
4869
- sub.appendChild(el);
4870
- }
4871
- document.body.appendChild(sub);
4872
- const anchor = parentRow.getBoundingClientRect();
4873
- const vw = window.visualViewport?.width ?? window.innerWidth;
4874
- const vh = window.visualViewport?.height ?? window.innerHeight;
4875
- const rect = sub.getBoundingClientRect();
4876
- let left = anchor.right - 2;
4877
- if (left + rect.width > vw)
4878
- left = anchor.left - rect.width + 2;
4879
- let top = anchor.top;
4880
- if (top + rect.height > vh)
4881
- top = vh - rect.height - 4;
4882
- sub.style.left = `${Math.max(4, left)}px`;
4883
- sub.style.top = `${Math.max(4, top)}px`;
4884
- activeSubmenu = sub;
4885
- }
4886
- function showContextMenu(x, y, items, opts = {}) {
4887
- closeContextMenu();
4888
- if (opts.editTarget !== void 0 || opts.editEngine) {
4889
- const edit = editMenuItems({ target: opts.editTarget, engine: opts.editEngine }, { onError: opts.onEditError });
4890
- if (edit.length > 0) {
4891
- items = items.length > 0 ? [...edit, { label: "", action: () => {
4892
- }, separator: true }, ...items] : edit;
4893
- }
4894
- }
4895
- const menu = document.createElement("div");
4896
- menu.className = "ctx-menu";
4897
- for (const item of items) {
4898
- if (item.separator) {
4899
- const sep = document.createElement("div");
4900
- sep.className = "ctx-sep";
4901
- menu.appendChild(sep);
4902
- continue;
4903
- }
4904
- const el = document.createElement("div");
4905
- el.className = "ctx-item" + (item.disabled ? " ctx-disabled" : "") + (item.emphasized ? " ctx-emphasized" : "");
4906
- if (item.emphasized)
4907
- el.style.fontWeight = "600";
4908
- el.textContent = item.label;
4909
- if (item.tooltip)
4910
- el.title = item.tooltip;
4911
- if (item.submenu && item.submenu.length > 0 && !item.disabled) {
4912
- el.style.display = "flex";
4913
- el.style.justifyContent = "space-between";
4914
- el.style.gap = "12px";
4915
- const caret = document.createElement("span");
4916
- caret.textContent = "\u25B8";
4917
- caret.style.opacity = "0.6";
4918
- el.appendChild(caret);
4919
- const open = () => openSubmenu(el, item.submenu);
4920
- el.addEventListener("mouseenter", open);
4921
- el.addEventListener("click", (e) => {
4922
- e.stopPropagation();
4923
- open();
4924
- });
4925
- menu.appendChild(el);
4926
- continue;
4927
- }
4928
- el.addEventListener("mouseenter", closeSubmenu);
4929
- if (!item.disabled) {
4930
- el.addEventListener("click", () => {
4931
- closeContextMenu();
4932
- item.action();
4933
- });
4934
- }
4935
- menu.appendChild(el);
4936
- }
4937
- menu.style.left = `${x}px`;
4938
- menu.style.top = `${y}px`;
4939
- document.body.appendChild(menu);
4940
- const vw = window.visualViewport?.width ?? window.innerWidth;
4941
- const vh = window.visualViewport?.height ?? window.innerHeight;
4942
- let rect = menu.getBoundingClientRect();
4943
- if (rect.height > vh - 8) {
4944
- menu.style.maxHeight = `${vh - 8}px`;
4945
- menu.style.overflowY = "auto";
4946
- rect = menu.getBoundingClientRect();
4947
- }
4948
- let left = x, top = y;
4949
- if (left + rect.width > vw)
4950
- left = x - rect.width;
4951
- if (top + rect.height > vh)
4952
- top = y - rect.height;
4953
- left = Math.max(4, Math.min(left, vw - rect.width - 4));
4954
- top = Math.max(4, Math.min(top, vh - rect.height - 4));
4955
- menu.style.left = `${left}px`;
4956
- menu.style.top = `${top}px`;
4957
- activeMenu = menu;
4958
- requestAnimationFrame(() => {
4959
- dismissListener = (e) => {
4960
- if (activeSubmenu?.contains(e.target))
4961
- return;
4962
- if (activeMenu && !activeMenu.contains(e.target)) {
4963
- closeContextMenu();
4964
- }
4965
- };
4966
- document.addEventListener("pointerdown", dismissListener, true);
4967
- escapeListener = (e) => {
4968
- if (e.key === "Escape") {
4969
- e.preventDefault();
4970
- e.stopPropagation();
4971
- closeContextMenu();
4972
- }
4973
- };
4974
- document.addEventListener("keydown", escapeListener, true);
4975
- });
4976
- }
4977
- document.addEventListener("scroll", closeContextMenu, true);
4978
- document.addEventListener("contextmenu", () => {
4979
- });
4980
- window.addEventListener("message", (e) => {
4981
- if (e.data && e.data.type === "iframePointerDown")
4982
- closeContextMenu();
4983
- });
4984
-
4985
- // client/compose/compose.ts
4983
+ init_context_menu();
4986
4984
  installConsoleCapture();
4987
4985
  logClientEvent("compose-module-loaded", { href: location.href, version: window.mailxVersion || "?" });
4988
4986
  var _composeT0 = performance.now();
@@ -5454,7 +5452,7 @@ function showAutocompleteContextMenu(e, row) {
5454
5452
  window.open(`https://contacts.google.com/search/${encodeURIComponent(row.name || row.email)}`, "_blank");
5455
5453
  }
5456
5454
  }
5457
- ]);
5455
+ ], { editTarget: e.target });
5458
5456
  }
5459
5457
  function openAddToPreferredModal(prefill) {
5460
5458
  const overlay = document.createElement("div");