@bobfrankston/rmfmail 1.2.118 → 1.2.120

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.ts CHANGED
@@ -5222,8 +5222,27 @@ getSettings().then((s: any) => {
5222
5222
  if (optEditorQuill) optEditorQuill.checked = ed === "quill";
5223
5223
  if (optEditorTiptap) optEditorTiptap.checked = ed === "tiptap";
5224
5224
  if (optEditorTinymce) optEditorTinymce.checked = ed === "tinymce";
5225
+ const fontEl = document.getElementById("opt-compose-font-size") as HTMLInputElement | null;
5226
+ if (fontEl) {
5227
+ const px = Number(s.ui?.composeFontSize);
5228
+ fontEl.value = String(Number.isFinite(px) && px >= 8 && px <= 32 ? px : 15);
5229
+ }
5225
5230
  }).catch(() => {});
5226
5231
 
5232
+ // Unified compose editing font size (px). Same sync-cache-then-persist shape
5233
+ // as saveEditorSetting: compose.ts reads `mailx-compose-font-size` from
5234
+ // localStorage at module load, so the very next compose-open is correct.
5235
+ document.getElementById("opt-compose-font-size")?.addEventListener("change", (e) => {
5236
+ const el = e.target as HTMLInputElement;
5237
+ const px = Number(el.value);
5238
+ if (!Number.isFinite(px) || px < 8 || px > 32) return;
5239
+ try { localStorage.setItem("mailx-compose-font-size", String(px)); } catch { /* */ }
5240
+ getSettings().then((settings: any) => {
5241
+ settings.ui = { ...settings.ui, composeFontSize: px };
5242
+ saveSettings(settings);
5243
+ }).catch(() => {});
5244
+ });
5245
+
5227
5246
  // Save editor choice to server settings
5228
5247
  function saveEditorSetting(editor: string): void {
5229
5248
  // Update the localStorage cache SYNCHRONOUSLY. compose.ts reads
@@ -2173,7 +2173,7 @@ async function createTinyMceEditor(container2, opts = {}) {
2173
2173
  // an undefined/oversized line-height plus per-line font-size
2174
2174
  // changes threw it off. A definite, tight line-height gives the
2175
2175
  // marker a stable baseline to sit under.
2176
- "body { font-family: system-ui, sans-serif; font-size: 14px; line-height: 1.3; caret-color: #0a2647; }",
2176
+ `body { font-family: system-ui, sans-serif; font-size: ${opts.fontSizePx ?? 14}px; line-height: 1.3; caret-color: #0a2647; }`,
2177
2177
  "blockquote { border-left: 3px solid #c0c8d0; margin: 0 0 0 4px; padding: 2px 0 2px 10px; color: #555; }",
2178
2178
  // Drop the 0.5em margin-gap above the reply block and the per-line
2179
2179
  // font-size shrink on the attribution line — both contributed to
@@ -2187,7 +2187,7 @@ async function createTinyMceEditor(container2, opts = {}) {
2187
2187
  setup: (ed) => {
2188
2188
  if (opts.initialHtml)
2189
2189
  ed.on("init", () => ed.setContent(opts.initialHtml));
2190
- const ZOOM_DEFAULT = 14;
2190
+ const ZOOM_DEFAULT = opts.fontSizePx ?? 14;
2191
2191
  const ZOOM_STEP = 2;
2192
2192
  const ZOOM_MIN = 8;
2193
2193
  const ZOOM_MAX = 32;
@@ -3404,6 +3404,31 @@ function createQuillEditor(container2) {
3404
3404
  }
3405
3405
  }
3406
3406
  }, true);
3407
+ q.on("text-change", (delta, _old, source) => {
3408
+ if (source !== "user")
3409
+ return;
3410
+ const inserted = (delta.ops || []).reduce((s, op) => typeof op.insert === "string" ? s + op.insert : s, "");
3411
+ if (!inserted || !/\s$/.test(inserted))
3412
+ return;
3413
+ const sel = q.getSelection();
3414
+ if (!sel)
3415
+ return;
3416
+ const boundary = sel.index - 1;
3417
+ const lookback = Math.min(boundary, 512);
3418
+ const before = q.getText(boundary - lookback, lookback);
3419
+ const m = before.match(/(?:https?:\/\/|www\.)\S+$/i);
3420
+ if (!m)
3421
+ return;
3422
+ const word = m[0].replace(/[),.;:!?\]]+$/, "");
3423
+ if (!looksLikeUrl(word))
3424
+ return;
3425
+ const start = boundary - m[0].length;
3426
+ if (q.getFormat(start, word.length).link)
3427
+ return;
3428
+ queueMicrotask(() => {
3429
+ q.formatText(start, word.length, "link", normalizeUrl(word), "api");
3430
+ });
3431
+ });
3407
3432
  let hoverTip = null;
3408
3433
  q.root.addEventListener("mouseover", (e) => {
3409
3434
  const a = e.target.closest("a[href]");
@@ -3647,7 +3672,8 @@ async function createTinyMceEditor2(container2, opts = {}) {
3647
3672
  } catch {
3648
3673
  }
3649
3674
  const m = await Promise.resolve().then(() => (init_rmf_tiny(), rmf_tiny_exports));
3650
- const ed = await m.createTinyMceEditor(container2, { cdnUrl, apiKey, onFiles: opts.onFiles });
3675
+ const cssPx = parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--compose-font-size"));
3676
+ const ed = await m.createTinyMceEditor(container2, { cdnUrl, apiKey, onFiles: opts.onFiles, fontSizePx: Number.isFinite(cssPx) ? cssPx : void 0 });
3651
3677
  return ed;
3652
3678
  }
3653
3679
 
@@ -3798,6 +3824,18 @@ try {
3798
3824
  if (cached === "tiptap" || cached === "quill" || cached === "tinymce") editorType = cached;
3799
3825
  } catch {
3800
3826
  }
3827
+ var COMPOSE_FONT_MIN_PX = 8;
3828
+ var COMPOSE_FONT_MAX_PX = 32;
3829
+ var COMPOSE_FONT_DEFAULT_PX = 15;
3830
+ function applyComposeFontSize(px) {
3831
+ if (!Number.isFinite(px) || px < COMPOSE_FONT_MIN_PX || px > COMPOSE_FONT_MAX_PX) px = COMPOSE_FONT_DEFAULT_PX;
3832
+ document.documentElement.style.setProperty("--compose-font-size", `${px}px`);
3833
+ }
3834
+ try {
3835
+ applyComposeFontSize(Number(localStorage.getItem("mailx-compose-font-size")));
3836
+ } catch {
3837
+ applyComposeFontSize(COMPOSE_FONT_DEFAULT_PX);
3838
+ }
3801
3839
  (async () => {
3802
3840
  try {
3803
3841
  appSettings = await getSettings();
@@ -3807,6 +3845,14 @@ try {
3807
3845
  localStorage.setItem("mailx-editor-type", next);
3808
3846
  } catch {
3809
3847
  }
3848
+ const fontPx = Number(appSettings?.ui?.composeFontSize);
3849
+ if (Number.isFinite(fontPx) && fontPx >= COMPOSE_FONT_MIN_PX && fontPx <= COMPOSE_FONT_MAX_PX) {
3850
+ try {
3851
+ localStorage.setItem("mailx-compose-font-size", String(fontPx));
3852
+ } catch {
3853
+ }
3854
+ applyComposeFontSize(fontPx);
3855
+ }
3810
3856
  } catch {
3811
3857
  }
3812
3858
  })();