domma-cms 1.72.0 → 1.73.0

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  4. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  5. package/plugins/_lib/admin/mail/compose-window.js +15 -1
  6. package/plugins/_lib/admin/mail/contacts.js +1 -1
  7. package/plugins/_lib/admin/mail/diagnostics-section.js +75 -41
  8. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  9. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  10. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  11. package/plugins/_lib/admin/mail/fonts.js +1 -1
  12. package/plugins/_lib/admin/mail/host-context.js +1 -1
  13. package/plugins/_lib/admin/mail/identity.js +1 -1
  14. package/plugins/_lib/admin/mail/image-senders-section.js +156 -99
  15. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  16. package/plugins/_lib/admin/mail/mail.css +1 -1
  17. package/plugins/_lib/admin/mail/mail.html +1 -1
  18. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  19. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  20. package/plugins/_lib/admin/mail/panes.js +1 -1
  21. package/plugins/_lib/admin/mail/reader-kit.js +12 -4
  22. package/plugins/_lib/admin/mail/reader-runtime.js +362 -95
  23. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  24. package/plugins/_lib/admin/mail/resizable.js +1 -1
  25. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  26. package/plugins/_lib/admin/mail/rules.js +1 -1
  27. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  28. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  29. package/plugins/_lib/admin/mail/security-note.js +1 -1
  30. package/plugins/_lib/admin/mail/settings-section.js +156 -99
  31. package/plugins/_lib/admin/mail/templates.js +1 -1
  32. package/plugins/_lib/admin/mail/threads.js +1 -1
  33. package/plugins/_lib/admin/mail/vacation.js +45 -1
  34. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  35. package/plugins/_lib/admin/ui/dates.js +1 -1
  36. package/plugins/_lib/admin/ui/resizable.js +1 -1
  37. package/plugins/_lib/admin/ui/rich-field.js +1 -1
  38. package/plugins/_lib/domma-mail.lock.json +83 -83
  39. package/plugins/_lib/mail/accountFileStore.js +1 -1
  40. package/plugins/_lib/mail/accountRepository.js +31 -3
  41. package/plugins/_lib/mail/accountRoutes.js +1 -1
  42. package/plugins/_lib/mail/accounts.js +1 -1
  43. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  44. package/plugins/_lib/mail/bodyTokens.js +1 -1
  45. package/plugins/_lib/mail/compose.js +1 -1
  46. package/plugins/_lib/mail/defaults.js +1 -1
  47. package/plugins/_lib/mail/envelope.js +1 -1
  48. package/plugins/_lib/mail/folderActions.js +1 -1
  49. package/plugins/_lib/mail/folderRuntime.js +1 -1
  50. package/plugins/_lib/mail/folders.js +1 -1
  51. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  52. package/plugins/_lib/mail/mbox.js +1 -1
  53. package/plugins/_lib/mail/message-action.js +1 -1
  54. package/plugins/_lib/mail/messageSecurity.js +1 -1
  55. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  56. package/plugins/_lib/mail/networkAddresses.js +1 -1
  57. package/plugins/_lib/mail/networkPolicy.js +1 -1
  58. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  59. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  60. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  61. package/plugins/_lib/mail/pollSchedule.js +1 -1
  62. package/plugins/_lib/mail/poller.js +1 -1
  63. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  64. package/plugins/_lib/mail/priority.js +1 -1
  65. package/plugins/_lib/mail/publicMailbox.js +1 -1
  66. package/plugins/_lib/mail/readRuntime.js +1 -1
  67. package/plugins/_lib/mail/render.js +1 -1
  68. package/plugins/_lib/mail/ruleRunner.js +1 -1
  69. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  70. package/plugins/_lib/mail/secretProvider.js +1 -1
  71. package/plugins/_lib/mail/secretbox.js +1 -1
  72. package/plugins/_lib/mail/senderAuth.js +1 -1
  73. package/plugins/_lib/mail/sieve.js +1 -1
  74. package/plugins/_lib/mail/smtpService.js +1 -1
  75. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  76. package/plugins/_lib/mail/store.js +1 -1
  77. package/plugins/_lib/mail/subscriptions.js +1 -1
  78. package/plugins/_lib/mail/syncPlan.js +1 -1
  79. package/plugins/_lib/mail/syncRuntime.js +1 -1
  80. package/plugins/_lib/mail/syncSelection.js +1 -1
  81. package/plugins/_lib/mail/unreadBadge.js +1 -1
  82. package/plugins/_lib/mail/unsubscribe.js +1 -1
  83. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  84. package/plugins/_lib/mail/write.js +1 -1
  85. package/plugins/_lib/public/rich-text.mjs +1 -1
  86. package/plugins/_lib/rich-text.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.73.0] - 2026-11-17
4
+
5
+ ### Added
6
+
7
+ - **Mail settings is its own screen** (Domma Mail core 0.32.0). Email settings open on a grouped screen with a left-hand list of sections, and the compose window offers an edition's sender identities. Email Pro uses these for identity cards and branding.
8
+ - **Several saved away messages.** The mail account store exports the saved away messages, so an edition can keep more than one and switch between them.
9
+
3
10
  ## [1.72.0] - 2026-11-17
4
11
 
5
12
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.72.0",
3
+ "version": "1.73.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/body-menu.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/body-menu.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reading pane's right-click menu - the pure parts.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/cms-host.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/cms-host.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** The CMS shell boundary. Standalone never imports this adapter. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/compose-window.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/compose-window.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -758,6 +758,20 @@ export function createComposeWindow(mailHost) {
758
758
  isReply: Boolean(draft.inReplyTo) || openedAs === 'forward',
759
759
  draft: opened,
760
760
  identity: () => currentIdentity,
761
+ // The senders the From picker offers (none when there is no choice), and a way
762
+ // to choose one - it goes through the picker, so the signature swap happens too.
763
+ identities: hasFrom ? identities.map(entry => ({id: entry.id, label: entry.label,
764
+ from: identityFrom(entry, mailboxAddress)})) : [],
765
+ setIdentity: (id) => {
766
+ if (!hasFrom || !findIdentity(identities, id) || fromSelect.value === id) return;
767
+ fromSelect.value = id;
768
+ fromSelect.dispatchEvent(new Event('change'));
769
+ },
770
+ // An extension that offers the senders itself may fold the From row away.
771
+ hideFrom: (on = true) => {
772
+ const row = fromSelect.closest('.form-group');
773
+ if (row) row.style.display = on ? 'none' : '';
774
+ },
761
775
  recipients,
762
776
  show: (on = true) => { slot.hidden = !on; },
763
777
  helpPopovers: (root) => helpPopovers?.(root)
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/contacts.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/contacts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Recipient suggestions from the host address book.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/diagnostics-section.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/diagnostics-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section that answers "which build is this, and what went wrong".
@@ -52,60 +52,94 @@ export function createDiagnosticsSection(host) {
52
52
  * @returns {Promise<void>}
53
53
  */
54
54
  async function render(container, ctx) {
55
- const kit = await import(`./section-kit.js?v=${ctx.assetVersion ?? '1'}`);
55
+ const M = ctx.host?.M ?? globalThis.M;
56
56
  const server = await ctx.api(`${ctx.base}/diagnostics`);
57
+ if (!container.isConnected) return;
57
58
  const loaded = loadedAssetVersions();
58
59
 
59
- const entryVersion = loaded['mail.js'] ?? '(unknown)';
60
- kit.heading(container, `${server.plugin.name} ${server.plugin.version ?? '?'} \u00b7 build ${entryVersion}`);
61
-
62
60
  // The comparison that matters: the token this page was served under
63
61
  // against the token the server would issue now. Comparing a module's
64
62
  // own mtime would be wrong - the shared files are fetched under the
65
63
  // entry's token, not their own.
66
64
  const served = server.assets.expectedStamp;
67
65
  const running = loaded['mail.js'];
68
- const stale = running && running !== '(unversioned)' && String(served) !== String(running);
69
-
70
- const verdict = kit.note(container, stale
71
- ? `This page is running an older build than the server has (${running} vs ${served}). Reload with a hard refresh before reporting anything else.`
72
- : 'This page is running the build the server is serving.');
73
- if (stale) verdict.classList.add('text-danger');
74
-
66
+ const stale = Boolean(running && running !== '(unversioned)' && String(served) !== String(running));
75
67
  const errors = host.recentErrors();
76
- kit.note(container, errors.length
77
- ? `${errors.length} error(s) captured since this view opened - included in the report.`
78
- : 'No errors captured since this view opened.');
79
68
 
80
- const bar = kit.actionBar(container);
81
- kit.button(bar.row, 'Copy diagnostics', async () => {
82
- const report = {
83
- page: {
84
- url: location.href,
85
- userAgent: navigator.userAgent,
86
- loadedAssets: loaded,
87
- view: host.state()
88
- },
89
- server,
90
- errors
91
- };
92
- const text = JSON.stringify(report, null, 2);
93
- try {
94
- await navigator.clipboard.writeText(text);
95
- bar.say('Copied. Paste it into the report.', 'ok');
96
- } catch {
97
- // Clipboard access can be refused; showing the text is still
98
- // better than losing it.
99
- const box = kit.box(container, 'form-textarea mail-diag-log', 'textarea');
100
- box.value = text;
101
- box.select();
102
- bar.say('Clipboard unavailable - select and copy the text below.');
103
- }
104
- }, {variant: 'primary'});
69
+ const report = () => JSON.stringify({
70
+ page: {url: location.href, userAgent: navigator.userAgent, loadedAssets: loaded, view: host.state()},
71
+ server,
72
+ errors
73
+ }, null, 2);
74
+
75
+ // Built with domma-reactive. Values reach the page through bindings, never markup.
76
+ const root = document.createElement('div');
77
+ root.className = 'mail-diagnostics';
78
+ root.innerHTML = `
79
+ <h4 class="mail-section-heading" data-bind-text="title"></h4>
80
+ <p class="text-sm" data-bind-class="stale ? 'text-danger' : 'text-muted'" data-bind-text="verdict"></p>
81
+ <p class="text-sm text-muted" data-bind-text="errorLine"></p>
82
+ <div class="mail-sender-list mb-2" data-bind-hidden="!errorRows.length" data-each="errorRows key=key">
83
+ <div class="mail-box-row"><span class="flex-1 text-sm mail-ellipsis" data-bind-text="text" data-bind-title="text"></span></div>
84
+ </div>
85
+ <details class="mb-2"><summary class="text-sm">What this page loaded <span data-help-title="Loaded files" data-help="Each shared file this page is running and the build token it was fetched with. A file older than the rest means the browser kept a cached copy."></span></summary>
86
+ <div class="mail-sender-list mt-1" data-each="assets key=name">
87
+ <div class="mail-box-row"><span class="flex-1 text-sm mail-ellipsis font-mono" data-bind-text="name"></span><span class="text-xs text-muted font-mono" data-bind-text="version"></span></div>
88
+ </div>
89
+ </details>
90
+ <div class="flex items-center gap-2">
91
+ <button type="button" class="btn btn-sm btn-primary" data-on-click="copy">Copy diagnostics</button>
92
+ <span data-help-title="Copy diagnostics" data-help="Puts a report on the clipboard: this page's build and loaded files, the mailbox and folder on screen, where the list came from, the server's versions and recent errors. Never a password or a message's content."></span>
93
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="reload" data-bind-hidden="!stale">Reload with a hard refresh</button>
94
+ <span class="text-sm flex-1" data-bind-class="tone.value" data-bind-text="status.value"></span>
95
+ </div>
96
+ <textarea class="form-textarea mail-diag-log" readonly data-bind-hidden="!fallback.value" data-model="fallbackText.value" aria-label="Diagnostics report"></textarea>`;
97
+ const m = {
98
+ title: `${server.plugin.name} ${server.plugin.version ?? '?'} \u00b7 build ${loaded['mail.js'] ?? '(unknown)'}`,
99
+ stale,
100
+ verdict: stale
101
+ ? `This page is running an older build than the server has (${running} vs ${served}). Reload with a hard refresh before reporting anything else.`
102
+ : 'This page is running the build the server is serving.',
103
+ errorLine: errors.length
104
+ ? `${errors.length} error(s) captured since this view opened - included in the report.`
105
+ : 'No errors captured since this view opened.',
106
+ errorRows: errors.slice(-10).map((e, i) => ({key: `e${i}`, text: String(e?.message ?? e?.text ?? e ?? '')})),
107
+ assets: Object.entries(loaded).sort(([a], [b]) => a.localeCompare(b)).map(([name, version]) => ({name, version})),
108
+ status: M.observable(''),
109
+ tone: M.observable('text-muted'),
110
+ fallback: M.observable(false),
111
+ fallbackText: M.observable(''),
112
+ async copy() {
113
+ const text = report();
114
+ try {
115
+ await navigator.clipboard.writeText(text);
116
+ m.status.value = 'Copied. Paste it into the report.';
117
+ m.tone.value = 'text-success';
118
+ } catch {
119
+ // Clipboard access can be refused; showing the text is still better than losing it.
120
+ m.fallbackText.value = text;
121
+ m.fallback.value = true;
122
+ m.status.value = 'Clipboard unavailable - select and copy the text below.';
123
+ m.tone.value = 'text-muted';
124
+ setTimeout(() => root.querySelector('.mail-diag-log')?.select(), 0);
125
+ }
126
+ },
127
+ reload() { location.reload(); }
128
+ };
129
+ container.appendChild(root);
130
+ const bindings = M.applyBindings(m, root);
131
+ ctx.onClose?.(() => { try { bindings?.dispose?.(); } catch { /* gone */ } });
105
132
  }
106
133
 
107
134
  return {
108
135
  id: 'diagnostics', label: 'Diagnostics', render,
109
- help: 'What this screen can see about itself - whether it runs the build the server is serving, the mailbox and folder, where the list came from, and recent errors. Copy diagnostics puts it on the clipboard for a report.'
136
+ help: 'What this screen can see about itself - whether it runs the build the server is serving, the mailbox and folder, where the list came from, and recent errors. Copy diagnostics puts it on the clipboard for a report.',
137
+ guide: `<p>For when something is not right: what this screen knows about itself, ready to send to whoever is helping.</p>
138
+ <h4>The build</h4>
139
+ <p>The first line compares the build this page is running with the one the server is serving. If they differ, the browser is using an old copy: reload with a hard refresh (Ctrl+Shift+R, or Cmd+Shift+R on a Mac) before anything else.</p>
140
+ <h4>Errors</h4>
141
+ <p>Errors this screen has hit since it opened are counted and the most recent are listed.</p>
142
+ <h4>Copy diagnostics</h4>
143
+ <p>Puts a report on the clipboard - the build, the files loaded, the mailbox and folder on screen, where the message list came from, the server's versions and recent errors. It never includes a password or the content of a message. Paste it into your report.</p>`
110
144
  };
111
145
  }
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/drag-drop.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/drag-drop.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Drag identities include the mailbox and source folder: UIDs alone are not unique. */
4
4
  const PROTECTED_USES = new Set(['\\Inbox', '\\Sent', '\\Drafts', '\\Trash', '\\Junk', '\\Archive', '\\All', '\\Flagged']);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/folder-tree.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/folder-tree.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Mail folder presentation, shared by the Mail Reader and Email Pro.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/font-controls.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/font-controls.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/fonts.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/fonts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The fonts and sizes the mail editor offers - pure, so both the compose
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/host-context.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/host-context.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Services supplied by the application that hosts the shared mail interface. */
4
4
  export function createMailApi({getToken, fetch: request = globalThis.fetch, onUnauthorized = () => {}}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/identity.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/identity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Who a mailbox sends as, and what it signs off with.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/image-senders-section.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/image-senders-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section for senders whose images always load.
@@ -10,6 +10,11 @@
10
10
  * find is one they cannot revoke, and this one decides whether a sender learns
11
11
  * that their mail was opened.
12
12
  *
13
+ * Built with domma-reactive. Each trusted sender is a row with a menu
14
+ * (right-click, its ⋮ or Shift+F10: Stop trusting, Copy address), and
15
+ * "+ Trust a sender" sits under a divider. Contacts whose images stay blocked
16
+ * (where the host has contacts) are rows too, with Allow again.
17
+ *
13
18
  * @module _lib/admin/mail/image-senders-section
14
19
  */
15
20
 
@@ -17,21 +22,51 @@
17
22
  const TONE = {ok: 'text-success', bad: 'text-danger', quiet: 'text-muted'};
18
23
 
19
24
  /**
20
- * The section's markup. Its own DOM, never passed through `_.render`, so the
21
- * row's `{{address}}` is the list's template and not eaten on the way in.
25
+ * The section's markup. Its own DOM, never passed through `_.render`; every value
26
+ * reaches the page through a binding, never interpolated.
22
27
  */
23
28
  const TEMPLATE = `
24
29
  <div class="mail-image-senders">
25
30
  <p class="text-sm text-muted mb-3">Remote images are blocked by default, because loading one tells the sender that the message was opened and who opened it. Senders listed here are trusted, and their images load without asking.</p>
26
31
  <label class="mail-toggle-row text-sm">
27
- <input type="checkbox" class="mail-remember" data-bind-checked="remember.value">
32
+ <input type="checkbox" data-model="remember.value" data-on-change="saveRemember">
28
33
  Offer to remember senders
34
+ <span data-help-title="Offer to remember senders" data-help="When a message's images are blocked, the reader offers 'Always from this sender'. Switched off, it never offers, and the senders below are kept but ignored until you switch it back on."></span>
29
35
  </label>
36
+ <h4 class="mail-section-heading">Trusted senders <span data-help-title="Trusted senders" data-help="Images from these addresses load as soon as you open the message. Right-click one, use its ⋮, or press Shift+F10 to stop trusting it."></span></h4>
30
37
  <p class="text-sm text-muted mail-none" data-bind-hidden="senders.value.length">No senders trusted yet.</p>
31
- <div class="mail-sender-list" data-each="senders.value key=address">
32
- <div class="mail-box-row" data-address="{{address}}">
33
- <span class="flex-1 text-sm mail-ellipsis">{{address}}</span>
34
- <button type="button" class="btn btn-sm btn-ghost text-danger mail-untrust" data-bind-disabled="busy">Stop trusting</button>
38
+ <div class="mail-sender-list" data-ref="list" data-each="senders.value key=address">
39
+ <div class="mail-box-row mail-sender-row" tabindex="0" data-bind-data-address="address"
40
+ data-bind-aria-label="address + ' - Shift+F10 for actions'">
41
+ <span class="flex-1 text-sm mail-ellipsis" data-bind-text="address"></span>
42
+ <button type="button" class="btn btn-sm btn-ghost mail-row-more" aria-label="More actions" aria-haspopup="menu" title="More actions"
43
+ data-bind-disabled="busy" data-on-click="$root.more($data)">⋮</button>
44
+ </div>
45
+ </div>
46
+ <hr class="mail-list-divider">
47
+ <div class="flex items-center gap-2 flex-wrap" data-bind-hidden="!adding.value">
48
+ <input type="email" class="form-input form-input-sm" style="max-width:20rem" placeholder="news@example.com" aria-label="Sender address" data-model="newAddress.value" data-ref="new">
49
+ <button type="button" class="btn btn-sm btn-primary" data-on-click="trust" data-bind-disabled="!newAddress.value">Trust</button>
50
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="cancelAdd">Cancel</button>
51
+ </div>
52
+ <div class="flex items-center gap-2" data-bind-hidden="adding.value">
53
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="startAdd" data-bind-disabled="!remember.value">+ Trust a sender</button>
54
+ <span data-help-title="Trust a sender" data-help="Type an address to load its images from now on, without waiting for a message. Needs 'Offer to remember senders' on."></span>
55
+ </div>
56
+ <div data-bind-hidden="!hasContacts">
57
+ <h4 class="mail-section-heading">People in my contacts</h4>
58
+ <label class="mail-toggle-row text-sm">
59
+ <input type="checkbox" data-model="contactImages.value" data-on-change="saveContacts" data-bind-disabled="contactBusy.value">
60
+ Load images from people in my contacts
61
+ <span data-help-title="Images from contacts" data-help="Pictures from anyone in your Contacts load straight away - but only when your mail server confirms the message really came from them, because anyone can put a contact's address on a message."></span>
62
+ </label>
63
+ <p class="text-sm text-muted mail-hint">Only when your mail server confirms the message really came from them, because anyone can put a contact's address on a message.</p>
64
+ <p class="text-sm text-muted mail-none" data-bind-hidden="!blocks.value.length">Contacts whose images stay blocked:</p>
65
+ <div class="mail-sender-list mt-2" data-each="blocks.value key=address">
66
+ <div class="mail-box-row">
67
+ <span class="flex-1 text-sm mail-ellipsis" data-bind-text="address"></span>
68
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="$root.allow($data)">Allow again</button>
69
+ </div>
35
70
  </div>
36
71
  </div>
37
72
  <div data-bind-class="'text-sm mail-status mt-2 ' + statusClass.value" data-bind-text="status.value"></div>
@@ -47,22 +82,72 @@ async function render(container, ctx) {
47
82
  container.textContent = 'Add a mailbox first.';
48
83
  return;
49
84
  }
85
+ const M = ctx.host?.M ?? globalThis.M;
86
+ const E = ctx.host?.E ?? globalThis.E;
87
+ const openMenuAt = ctx.host?.helpers?.openMenuAt ?? ((el) => {
88
+ const r = el.getBoundingClientRect();
89
+ el.dispatchEvent(new MouseEvent('contextmenu', {bubbles: true, cancelable: true, clientX: r.left, clientY: r.bottom, view: window}));
90
+ });
50
91
 
51
92
  const params = new URLSearchParams({account: ctx.account.id});
52
93
  const data = await ctx.api(`${ctx.base}/image-senders?${params}`);
94
+ if (!container.isConnected) return;
53
95
 
54
96
  // ---- State ----
55
97
  const busy = new Set();
56
- const list = M.observable((data.senders ?? []).map(address => ({address, busy: false})));
57
- const remember = M.observable(data.remember !== false);
58
- const status = M.observable('');
59
- const tone = M.observable('quiet');
60
- const say = (text, t = 'quiet') => { status.value = text ?? ''; tone.value = t; };
61
- const paint = (senders) => { list.value = senders.map(address => ({address, busy: busy.has(address)})); };
98
+ const rowsOf = (senders) => senders.map(address => ({address, busy: busy.has(address)}));
99
+ const m = {
100
+ senders: M.observable(rowsOf(data.senders ?? [])),
101
+ remember: M.observable(data.remember !== false),
102
+ hasContacts: typeof data.contactImages === 'boolean',
103
+ contactImages: M.observable(data.contactImages !== false),
104
+ contactBusy: M.observable(false),
105
+ blocks: M.observable((data.contactImageBlocks ?? []).map(address => ({address}))),
106
+ adding: M.observable(false),
107
+ newAddress: M.observable(''),
108
+ status: M.observable(''),
109
+ tone: M.observable('quiet'),
110
+ more(row, event) {
111
+ event?.stopPropagation?.();
112
+ openMenuAt(event?.currentTarget ?? root);
113
+ },
114
+ startAdd() { m.adding.value = true; setTimeout(() => root.querySelector('[data-ref="new"]')?.focus(), 0); },
115
+ cancelAdd() { m.adding.value = false; m.newAddress.value = ''; },
116
+ async trust() {
117
+ const address = m.newAddress.peek().trim();
118
+ if (!address) return;
119
+ try {
120
+ const result = await ctx.api(`${ctx.base}/image-senders?${params}`, 'POST', {address});
121
+ paint(result.senders ?? []);
122
+ m.adding.value = false;
123
+ m.newAddress.value = '';
124
+ say(`Images from ${address} will load straight away.`, 'ok');
125
+ } catch (err) { say(err.message, 'bad'); }
126
+ },
127
+ async saveRemember() {
128
+ const wanted = m.remember.peek();
129
+ try {
130
+ const result = await ctx.api(`${ctx.base}/image-senders/remember?${params}`, 'PUT', {remember: wanted});
131
+ say(result.remember ? 'Senders can be remembered.' : 'Remembering is off. The list is kept but ignored.');
132
+ } catch (err) {
133
+ m.remember.value = !wanted;
134
+ say(err.message, 'bad');
135
+ }
136
+ },
137
+ async saveContacts() {
138
+ const enabled = m.contactImages.peek();
139
+ await saveContactChange({enabled}, enabled ? 'Images from verified contacts load straight away.'
140
+ : 'Images from contacts are blocked like anyone else\'s.', () => { m.contactImages.value = !enabled; });
141
+ },
142
+ allow(row) { saveContactChange({unblock: row.address}, `Images from ${row.address} load again when verified.`); }
143
+ };
144
+ m.statusClass = M.computed(() => TONE[m.tone.value] ?? TONE.quiet);
145
+ const say = (text, t = 'quiet') => { m.status.value = text ?? ''; m.tone.value = t; };
146
+ const paint = (senders) => { m.senders.value = rowsOf(senders); };
62
147
 
63
148
  async function untrust(address) {
64
149
  busy.add(address);
65
- paint(list.peek().map(r => r.address));
150
+ paint(m.senders.peek().map(r => r.address));
66
151
  try {
67
152
  const query = new URLSearchParams({account: ctx.account.id, address});
68
153
  const result = await ctx.api(`${ctx.base}/image-senders?${query}`, 'DELETE');
@@ -71,109 +156,81 @@ async function render(container, ctx) {
71
156
  say(`Images from ${address} will be blocked again.`);
72
157
  } catch (err) {
73
158
  busy.delete(address);
74
- paint(list.peek().map(r => r.address));
159
+ paint(m.senders.peek().map(r => r.address));
75
160
  say(err.message, 'bad');
76
161
  }
77
162
  }
78
163
 
79
- async function saveRemember(wanted) {
80
- remember.value = wanted;
164
+ async function saveContactChange(change, done, undo = () => {}) {
165
+ m.contactBusy.value = true;
81
166
  try {
82
- const result = await ctx.api(`${ctx.base}/image-senders/remember?${params}`, 'PUT', {remember: wanted});
83
- say(result.remember ? 'Senders can be remembered.' : 'Remembering is off. The list is kept but ignored.');
167
+ const result = await ctx.api(`${ctx.base}/image-senders/contacts?${params}`, 'PUT', change);
168
+ m.contactImages.value = result.contactImages !== false;
169
+ m.blocks.value = (result.contactImageBlocks ?? []).map(address => ({address}));
170
+ say(done, 'ok');
84
171
  } catch (err) {
85
- remember.value = !wanted;
172
+ undo();
86
173
  say(err.message, 'bad');
87
- }
174
+ } finally { m.contactBusy.value = false; }
88
175
  }
89
176
 
90
177
  const holder = document.createElement('div');
91
178
  holder.innerHTML = TEMPLATE.trim();
92
179
  const root = holder.firstElementChild;
93
180
  container.appendChild(root);
94
- M.applyBindings({
95
- senders: list, remember, status,
96
- statusClass: M.computed(() => TONE[tone.value] ?? TONE.quiet)
97
- }, root);
98
- root.querySelector('.mail-remember').addEventListener('change', (event) => saveRemember(event.target.checked));
99
-
100
- if (typeof data.contactImages === 'boolean') drawContacts(root, ctx, params, data, say);
101
-
102
- // One listener for every row's button - the rows are re-rendered by the list.
103
- root.addEventListener('click', (event) => {
104
- const button = event.target.closest('.mail-untrust');
105
- const row = button?.closest('[data-address]');
106
- if (row && !button.disabled) untrust(row.dataset.address);
107
- });
108
- }
181
+ const listEl = root.querySelector('[data-ref="list"]');
182
+ const bindings = M.applyBindings(m, root);
109
183
 
110
- /**
111
- * "Load images from people in my contacts" - only where the host has contacts
112
- * (the server sends `contactImages` then). On by default; the server also
113
- * insists the receiving mail server verified the sender, so a forged From
114
- * line naming a contact loads nothing.
115
- *
116
- * @returns {void}
117
- */
118
- function drawContacts(root, ctx, params, data, say) {
119
- const box = document.createElement('div');
120
- box.className = 'mail-contact-images mt-3';
121
- const label = document.createElement('label');
122
- label.className = 'mail-toggle-row text-sm';
123
- const input = document.createElement('input');
124
- input.type = 'checkbox';
125
- input.checked = data.contactImages !== false;
126
- label.append(input, ' Load images from people in my contacts');
127
- const hint = document.createElement('p');
128
- hint.className = 'text-sm text-muted mail-hint';
129
- hint.textContent = 'Only when your mail server confirms the message really came from them, because anyone can put a contact\'s address on a message.';
130
- const list = document.createElement('div');
131
- list.className = 'mail-sender-list mt-2';
132
- box.append(label, hint, list);
133
- const status = root.querySelector('.mail-status');
134
- root.insertBefore(box, status);
135
-
136
- const drawBlocks = (blocks) => {
137
- list.replaceChildren();
138
- if (!blocks.length) return;
139
- const head = document.createElement('p');
140
- head.className = 'text-sm text-muted mail-none';
141
- head.textContent = 'Contacts whose images stay blocked:';
142
- list.appendChild(head);
143
- for (const address of blocks) {
144
- const row = document.createElement('div');
145
- row.className = 'mail-box-row';
146
- const name = document.createElement('span');
147
- name.className = 'flex-1 text-sm mail-ellipsis';
148
- name.textContent = address;
149
- const allow = document.createElement('button');
150
- allow.type = 'button';
151
- allow.className = 'btn btn-sm btn-ghost';
152
- allow.textContent = 'Allow again';
153
- allow.addEventListener('click', () => save({unblock: address}, `Images from ${address} load again when verified.`));
154
- row.append(name, allow);
155
- list.appendChild(row);
184
+ // The row menu: right-click, its ⋮, or Shift+F10.
185
+ const rowOf = (el) => el?.closest?.('.mail-sender-row');
186
+ let menu = null;
187
+ if (typeof E?.contextMenu === 'function') {
188
+ menu = E.contextMenu(listEl, {
189
+ match: '.mail-sender-row',
190
+ inherit: false,
191
+ items: [],
192
+ onBeforeOpen: (c) => {
193
+ const row = rowOf(c?.target);
194
+ const address = row?.dataset.address;
195
+ if (!address) return false;
196
+ menu.setItems([
197
+ {label: 'Stop trusting', icon: 'x', action: () => untrust(address)},
198
+ {label: 'Copy address', icon: 'copy', action: () => navigator.clipboard?.writeText(address).then(() => say('Copied.'), () => {})}
199
+ ]);
200
+ return true;
201
+ }
202
+ });
203
+ }
204
+ const onKey = (event) => {
205
+ const row = rowOf(event.target);
206
+ if (!row) return;
207
+ if (event.key === 'F10' && event.shiftKey) {
208
+ event.preventDefault();
209
+ openMenuAt(row.querySelector('.mail-row-more') ?? row);
210
+ } else if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && event.target === row) {
211
+ const rows = [...listEl.querySelectorAll('.mail-sender-row')];
212
+ const next = rows[rows.indexOf(row) + (event.key === 'ArrowDown' ? 1 : -1)];
213
+ if (next) { event.preventDefault(); next.focus(); }
156
214
  }
157
215
  };
158
- async function save(change, done) {
159
- input.disabled = true;
160
- try {
161
- const result = await ctx.api(`${ctx.base}/image-senders/contacts?${params}`, 'PUT', change);
162
- input.checked = result.contactImages !== false;
163
- drawBlocks(result.contactImageBlocks ?? []);
164
- say(done, 'ok');
165
- } catch (err) {
166
- if (typeof change.enabled === 'boolean') input.checked = !change.enabled;
167
- say(err.message, 'bad');
168
- } finally { input.disabled = false; }
169
- }
170
- input.addEventListener('change', () => save({enabled: input.checked},
171
- input.checked ? 'Images from verified contacts load straight away.' : 'Images from contacts are blocked like anyone else\'s.'));
172
- drawBlocks(data.contactImageBlocks ?? []);
216
+ listEl.addEventListener('keydown', onKey);
217
+ ctx.onClose?.(() => {
218
+ listEl.removeEventListener('keydown', onKey);
219
+ try { menu?.destroy?.(); } catch { /* gone */ }
220
+ try { bindings?.dispose?.(); } catch { /* gone */ }
221
+ });
173
222
  }
174
223
 
175
224
  /** The section both editions show. */
176
225
  export const imageSendersSection = {
177
226
  id: 'images', label: 'Images', render,
178
- help: 'Pictures in mail are blocked until you ask for them, because loading one tells the sender you opened it. Senders listed here are trusted: their pictures load straight away.'
227
+ help: 'Pictures in mail are blocked until you ask for them, because loading one tells the sender you opened it. Senders listed here are trusted: their pictures load straight away.',
228
+ guide: `<p>Pictures in a message are often fetched from the sender's server when you open it, which tells them that you opened it, when, and roughly where. So they are blocked until you ask.</p>
229
+ <h4>Trusted senders</h4>
230
+ <ul><li>In the reader, <b>Load images</b> loads them once; <b>Always from this sender</b> adds the sender here.</li>
231
+ <li><b>+ Trust a sender</b> adds an address straight away.</li>
232
+ <li>Right-click a sender, use its <b>⋮</b>, or press Shift+F10 to <b>Stop trusting</b> it or copy the address.</li>
233
+ <li>Switch <b>Offer to remember senders</b> off to stop the reader offering; the list is kept but ignored.</li></ul>
234
+ <h4>People in my contacts</h4>
235
+ <p>Where Contacts is available, pictures from your contacts can load straight away - only when your mail server confirms the message really came from them. A contact you block from a message stays listed here until you allow it again.</p>`
179
236
  };
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/keyboard.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/keyboard.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Keyboard navigation for the reader.