domma-cms 1.71.1 → 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 (87) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/docs/DommaFeatures.md +1 -0
  3. package/package.json +1 -1
  4. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  5. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  6. package/plugins/_lib/admin/mail/compose-window.js +90 -3
  7. package/plugins/_lib/admin/mail/contacts.js +1 -1
  8. package/plugins/_lib/admin/mail/diagnostics-section.js +75 -41
  9. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  10. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  11. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  12. package/plugins/_lib/admin/mail/fonts.js +1 -1
  13. package/plugins/_lib/admin/mail/host-context.js +1 -1
  14. package/plugins/_lib/admin/mail/identity.js +1 -1
  15. package/plugins/_lib/admin/mail/image-senders-section.js +156 -99
  16. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  17. package/plugins/_lib/admin/mail/mail.css +1 -1
  18. package/plugins/_lib/admin/mail/mail.html +1 -1
  19. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  20. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  21. package/plugins/_lib/admin/mail/panes.js +1 -1
  22. package/plugins/_lib/admin/mail/reader-kit.js +12 -4
  23. package/plugins/_lib/admin/mail/reader-runtime.js +372 -96
  24. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  25. package/plugins/_lib/admin/mail/resizable.js +1 -1
  26. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  27. package/plugins/_lib/admin/mail/rules.js +1 -1
  28. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  29. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  30. package/plugins/_lib/admin/mail/security-note.js +1 -1
  31. package/plugins/_lib/admin/mail/settings-section.js +156 -99
  32. package/plugins/_lib/admin/mail/templates.js +1 -1
  33. package/plugins/_lib/admin/mail/threads.js +1 -1
  34. package/plugins/_lib/admin/mail/vacation.js +45 -1
  35. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  36. package/plugins/_lib/admin/ui/dates.js +1 -1
  37. package/plugins/_lib/admin/ui/resizable.js +1 -1
  38. package/plugins/_lib/admin/ui/rich-field.js +291 -0
  39. package/plugins/_lib/domma-mail.lock.json +83 -80
  40. package/plugins/_lib/mail/accountFileStore.js +1 -1
  41. package/plugins/_lib/mail/accountRepository.js +31 -3
  42. package/plugins/_lib/mail/accountRoutes.js +1 -1
  43. package/plugins/_lib/mail/accounts.js +1 -1
  44. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  45. package/plugins/_lib/mail/bodyTokens.js +1 -1
  46. package/plugins/_lib/mail/compose.js +1 -1
  47. package/plugins/_lib/mail/defaults.js +1 -1
  48. package/plugins/_lib/mail/envelope.js +1 -1
  49. package/plugins/_lib/mail/folderActions.js +1 -1
  50. package/plugins/_lib/mail/folderRuntime.js +1 -1
  51. package/plugins/_lib/mail/folders.js +1 -1
  52. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  53. package/plugins/_lib/mail/mbox.js +1 -1
  54. package/plugins/_lib/mail/message-action.js +1 -1
  55. package/plugins/_lib/mail/messageSecurity.js +1 -1
  56. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  57. package/plugins/_lib/mail/networkAddresses.js +1 -1
  58. package/plugins/_lib/mail/networkPolicy.js +1 -1
  59. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  60. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  61. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  62. package/plugins/_lib/mail/pollSchedule.js +1 -1
  63. package/plugins/_lib/mail/poller.js +1 -1
  64. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  65. package/plugins/_lib/mail/priority.js +1 -1
  66. package/plugins/_lib/mail/publicMailbox.js +1 -1
  67. package/plugins/_lib/mail/readRuntime.js +1 -1
  68. package/plugins/_lib/mail/render.js +1 -1
  69. package/plugins/_lib/mail/ruleRunner.js +1 -1
  70. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  71. package/plugins/_lib/mail/secretProvider.js +1 -1
  72. package/plugins/_lib/mail/secretbox.js +1 -1
  73. package/plugins/_lib/mail/senderAuth.js +1 -1
  74. package/plugins/_lib/mail/sieve.js +1 -1
  75. package/plugins/_lib/mail/smtpService.js +1 -1
  76. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  77. package/plugins/_lib/mail/store.js +1 -1
  78. package/plugins/_lib/mail/subscriptions.js +1 -1
  79. package/plugins/_lib/mail/syncPlan.js +1 -1
  80. package/plugins/_lib/mail/syncRuntime.js +1 -1
  81. package/plugins/_lib/mail/syncSelection.js +1 -1
  82. package/plugins/_lib/mail/unreadBadge.js +1 -1
  83. package/plugins/_lib/mail/unsubscribe.js +1 -1
  84. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  85. package/plugins/_lib/mail/write.js +1 -1
  86. package/plugins/_lib/public/rich-text.mjs +104 -0
  87. package/plugins/_lib/rich-text.js +153 -0
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/admin/mail/reader-runtime.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/reader-runtime.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);
@@ -117,9 +117,17 @@ function formatSize(bytes) {
117
117
  * - `folderItems(folder, view)` -> Domma menu items, added to a folder's
118
118
  * menu (right-click, ⋮, Shift+F10);
119
119
  * - `mailboxItems(account, view)` -> the same, on a mailbox row's menu.
120
+ * - `compose(context)` -> `{fields?(), identityChanged?(identity),
121
+ * recipientsChanged?(recipients), close?()}`, an edition's part of every
122
+ * compose window: it may draw into `context.slot` (shown with
123
+ * `context.show()`), and `fields()` is added to what Save and Send post.
124
+ * `context.identities` / `setIdentity(id)` / `hideFrom()` let it offer the senders itself.
120
125
  * Optional, checked and feature-detected: an edition that passes it to an
121
126
  * older reader just does not get the entries. Item actions run on the next
122
127
  * task, so one picked with Enter cannot hand its own Enter to a dialog.
128
+ * `settingsScreen: {title?, groups: [{label, sections: [id]}]}` shows Settings as a screen of its own in
129
+ * place of the reader (grouped navigation down the left, Back to mail) rather than a slideover of tabs.
130
+ * Sections in no group go under "More". Without it, the slideover as before.
123
131
  * `settingsSections` lets an edition contribute settings without forking the
124
132
  * view: each is `{id, label, render(container, context)}`, and the shell
125
133
  * handles the tabs, the lazy drawing and a section that throws.
@@ -130,7 +138,7 @@ function formatSize(bytes) {
130
138
  * @returns {object} a Domma view
131
139
  */
132
140
  export function createReaderView({pluginName, assetVersion = ASSET_VERSION, settingsSections = [], features = {},
133
- extensions = {}, host: mailHost = null}) {
141
+ extensions = {}, host: mailHost = null, settingsScreen = null}) {
134
142
  mailHost ??= createMailHost({pluginName});
135
143
  const {api, storage: S, Domma, M, E, F, $} = mailHost;
136
144
  const {viewLifetime, helpPopovers, openMenuAt, promptWith, sidebarCount, loading} = mailHost.helpers;
@@ -504,7 +512,10 @@ return {
504
512
  */
505
513
  const composeHandles = new Set();
506
514
  function openCompose(options) {
507
- const handle = openComposeWindow({...options, host: mailHost});
515
+ // `extensions.compose`: an edition's part of every compose window
516
+ // (Email Pro's branding picker). See compose-window.js.
517
+ const handle = openComposeWindow({...options, host: mailHost,
518
+ composeExtension: typeof extensions.compose === 'function' ? extensions.compose : null});
508
519
  if (handle) {
509
520
  composeHandles.add(handle);
510
521
  handle.onClosed?.(() => composeHandles.delete(handle));
@@ -733,6 +744,7 @@ return {
733
744
  this.onUnmount = teardown;
734
745
  this.refreshContacts = () => here() ? refreshContacts() : Promise.resolve();
735
746
  this.compose = draft => here() && features.send ? startNewMessage(draft) : Promise.resolve();
747
+ this.openSettings = target => {if (here()) openSettings(target);};
736
748
  lifetime.add(teardown);
737
749
 
738
750
  /**
@@ -910,6 +922,58 @@ return {
910
922
  *
911
923
  * @returns {void}
912
924
  */
925
+ /**
926
+ * A stand-in for a slideover that is a screen in place of the reader: the same
927
+ * open/close/on('close') a panel has, so the guard, the close question and the
928
+ * clean-up treat both alike. Back to mail (or Escape on the screen) closes it.
929
+ *
930
+ * @returns {{element: HTMLElement, open: Function, close: Function, on: Function, destroy: Function}}
931
+ */
932
+ function settingsScreenPanel() {
933
+ const root = $container.get(0);
934
+ const layout = root.querySelector('.mail-layout');
935
+ const element = document.createElement('section');
936
+ element.className = 'mail-settings-screen';
937
+ element.hidden = true;
938
+ const head = document.createElement('div');
939
+ head.className = 'mail-settings-head';
940
+ const back = document.createElement('button');
941
+ back.type = 'button';
942
+ back.className = 'btn btn-sm btn-ghost';
943
+ back.textContent = '\u2190 Back to mail';
944
+ const title = document.createElement('h2');
945
+ title.className = 'mail-settings-title';
946
+ title.textContent = settingsScreen?.title || 'Email settings';
947
+ head.append(back, title);
948
+ element.appendChild(head);
949
+ layout.after(element);
950
+ const listeners = {close: [], open: []};
951
+ let open = false;
952
+ const panel = {
953
+ element,
954
+ on(event, fn) { (listeners[event] ??= []).push(fn); },
955
+ open() {
956
+ open = true;
957
+ layout.hidden = true;
958
+ element.hidden = false;
959
+ listeners.open.forEach(fn => { try { fn(panel); } catch { /* ignore */ } });
960
+ back.focus();
961
+ },
962
+ close() {
963
+ if (!open) return;
964
+ open = false;
965
+ element.hidden = true;
966
+ layout.hidden = false;
967
+ listeners.close.forEach(fn => { try { fn(panel); } catch { /* ignore */ } });
968
+ element.remove();
969
+ },
970
+ destroy() { element.remove(); layout.hidden = false; }
971
+ };
972
+ // Through the property, so the guarded close (the unsaved question) is the one called.
973
+ back.addEventListener('click', () => panel.close());
974
+ return panel;
975
+ }
976
+
913
977
  function openSettings(target = null) {
914
978
  // One at a time: a second click, or a needs-password error while
915
979
  // it is open, must not stack a second panel on the first.
@@ -947,7 +1011,10 @@ return {
947
1011
  const dirtyGuards = () => [...guards].filter(g => { try { return Boolean(g.dirty?.()); } catch { return false; } });
948
1012
  // Each section saves on its own button; the panel asks only for
949
1013
  // sections that said (ctx.guard) they hold unsaved work.
950
- const slideover = guardPanel(E.slideover({title: 'Mail Settings', size: 'lg', position: 'right'}),
1014
+ const navProviders = new Map();
1015
+ const asScreen = Array.isArray(settingsScreen?.groups) && settingsScreen.groups.length > 0
1016
+ && Boolean($container.get(0)?.querySelector('.mail-layout'));
1017
+ const slideover = guardPanel(asScreen ? settingsScreenPanel() : E.slideover({title: 'Mail Settings', size: 'lg', position: 'right'}),
951
1018
  () => dirtyGuards().length > 0,
952
1019
  () => settingsDiscardQuestion(dirtyGuards().map(g => g.label)),
953
1020
  () => {
@@ -965,7 +1032,7 @@ return {
965
1032
  // width someone wants depends on their screen - the same reason
966
1033
  // compose is resizable. Its own remembered width, because the two
967
1034
  // are opened for different things.
968
- const stopSettingsResize = makeResizable(slideover, {
1035
+ const stopSettingsResize = asScreen ? () => {} : makeResizable(slideover, {
969
1036
  storage: mailHost.storage,
970
1037
  storageKey: 'domma-mail.settings-width',
971
1038
  defaultWidth: 760
@@ -988,8 +1055,19 @@ return {
988
1055
  {
989
1056
  id: 'mailboxes',
990
1057
  label: 'Mailboxes',
1058
+ collection: true,
991
1059
  icon: 'inbox',
992
1060
  help: 'The IMAP accounts this screen reads. Each person\'s mailboxes are their own - nobody else in the admin can see them. Passwords are stored sealed and never sent back to the browser.',
1061
+ guide: `<p>A mailbox is an email account this screen reads (IMAP) - and, where the edition sends, its outgoing server. Each person's mailboxes are their own: nobody else in the admin can see them.</p>
1062
+ <h4>The list</h4>
1063
+ <ul><li>Click a mailbox, or press Enter on it, to edit its server, port, security and sign-in.</li>
1064
+ <li>Right-click it, use its <b>⋮</b>, or press Shift+F10 for <b>Edit</b>, <b>Open in the reader</b>, <b>Make default</b> and <b>Remove</b>.</li>
1065
+ <li>The <b>Default</b> mailbox is the one the screen opens on. <b>Open</b> marks the one you are reading now.</li>
1066
+ <li><b>+ Add mailbox</b> under the list adds another account.</li></ul>
1067
+ <h4>Passwords and sign-in</h4>
1068
+ <p>Passwords are stored sealed on the server and never sent back to the browser. A Microsoft or Google mailbox can sign in instead of using a password; a chip on its row says when it needs signing in again.</p>
1069
+ <h4>Unsaved changes</h4>
1070
+ <p>Changes left in a mailbox's form are kept in this browser (never the password) and the row says <b>Unsaved changes</b> - Edit to pick them up or throw them away.</p>`,
993
1071
  render: renderMailboxSection
994
1072
  },
995
1073
  // Blocking remote images is not a Pro feature, and neither is
@@ -1026,6 +1104,10 @@ return {
1026
1104
  */
1027
1105
  function context(section = null) {
1028
1106
  return {
1107
+ // Screen mode only: a section that keeps a list (identities, away messages,
1108
+ // templates…) hands its items to the section list's right-click menu instead
1109
+ // of drawing a list column, so the editor gets the width.
1110
+ navMenu: asScreen && section ? (provider) => { navProviders.set(section.id, provider); } : undefined,
1029
1111
  // What opened this section, when something did (a menu
1030
1112
  // item asking for a new rule). Only for that section.
1031
1113
  request: target && section?.id === target.section ? (target.request ?? null) : null,
@@ -1107,6 +1189,25 @@ return {
1107
1189
  marker.setAttribute('data-help-title', section.label);
1108
1190
  marker.setAttribute('data-help', section.help);
1109
1191
  head.append(title, marker);
1192
+ // Longer help in a slideover, for a section that brings it: `guide` is the
1193
+ // section's own static HTML (written in code, never user text).
1194
+ if (section.guide) {
1195
+ const more = document.createElement('button');
1196
+ more.type = 'button';
1197
+ more.className = 'btn btn-sm btn-ghost mail-section-help';
1198
+ more.textContent = 'Help';
1199
+ more.setAttribute('aria-haspopup', 'dialog');
1200
+ more.addEventListener('click', () => {
1201
+ const help = E.slideover({title: `${section.label} - help`, size: 'md', position: 'right'});
1202
+ const box = document.createElement('div');
1203
+ box.className = 'mail-help-body';
1204
+ box.innerHTML = section.guide;
1205
+ help.element.appendChild(box);
1206
+ help.open();
1207
+ whenClosed(help, () => setTimeout(() => { try { help.element?.remove(); } catch { /* gone */ } }, 400));
1208
+ });
1209
+ head.appendChild(more);
1210
+ }
1110
1211
  panel.appendChild(head);
1111
1212
  }
1112
1213
  try {
@@ -1121,6 +1222,134 @@ return {
1121
1222
  helpDisposers.push(helpPopovers(panel, {position: 'bottom'}));
1122
1223
  }
1123
1224
 
1225
+ /**
1226
+ * Settings as a screen: the groups down the left, one section at a time on the right.
1227
+ * Sections are drawn on first view and kept, as the tabs are.
1228
+ */
1229
+ function drawScreen() {
1230
+ const byId = new Map(sections.map(section => [section.id, section]));
1231
+ const placed = new Set();
1232
+ const groups = settingsScreen.groups.map(group => ({
1233
+ label: String(group.label ?? ''),
1234
+ sections: (group.sections ?? []).map(id => byId.get(id)).filter(section => section && !placed.has(section.id) && placed.add(section.id))
1235
+ })).filter(group => group.sections.length);
1236
+ const rest = sections.filter(section => !placed.has(section.id));
1237
+ if (rest.length) groups.push({label: 'More', sections: rest});
1238
+
1239
+ // Built with domma-reactive: one flat list of group headings and section links (a
1240
+ // nested data-each renders an unbound copy), each link's state an observable.
1241
+ const items = [];
1242
+ for (const group of groups) {
1243
+ items.push({key: `g:${group.label}`, isGroup: true, label: group.label, id: '',
1244
+ active: M.observable(false), dirty: M.observable(false)});
1245
+ for (const section of group.sections) {
1246
+ items.push({key: `s:${section.id}`, isGroup: false, label: section.label, id: section.id,
1247
+ active: M.observable(false), dirty: M.observable(false)});
1248
+ }
1249
+ }
1250
+ const body = document.createElement('div');
1251
+ body.className = 'mail-settings-body';
1252
+ body.innerHTML = `<nav class="mail-settings-nav" aria-label="Settings" data-each="items key=key">
1253
+ <div class="mail-settings-group-label" data-bind-hidden="!isGroup" data-bind-text="label"></div>
1254
+ <button type="button" class="mail-settings-link" data-bind-hidden="isGroup" data-bind-class="active.value && 'is-active'"
1255
+ data-bind-aria-current="active.value ? 'page' : 'false'" data-bind-aria-description="dirty.value ? 'Unsaved changes' : ''"
1256
+ data-on-click="$root.show(id)"><span data-bind-text="label"></span><span class="mail-tab-pip" aria-hidden="true" data-bind-hidden="!dirty.value"></span></button>
1257
+ </nav><div class="mail-settings-main"></div>`;
1258
+ const main = body.querySelector('.mail-settings-main');
1259
+ const panels = new Map();
1260
+ function ensure(id) {
1261
+ const section = byId.get(id);
1262
+ if (!section) return null;
1263
+ let panel = panels.get(id);
1264
+ // Drawn for another mailbox (Folders to sync… on a mailbox's menu opens that one
1265
+ // first): drawn again, so a section never shows one mailbox's settings under another.
1266
+ if (panel && panel.dataset.account !== String(currentAccountId ?? '')) {
1267
+ panel.remove();
1268
+ panels.delete(id);
1269
+ panel = null;
1270
+ }
1271
+ if (!panel) {
1272
+ panel = document.createElement('div');
1273
+ panel.className = 'mail-settings-panel';
1274
+ panel.dataset.account = String(currentAccountId ?? '');
1275
+ main.appendChild(panel);
1276
+ panels.set(id, panel);
1277
+ panel.hidden = true;
1278
+ draw(section, panel);
1279
+ }
1280
+ return panel;
1281
+ }
1282
+ function show(id) {
1283
+ if (!ensure(id)) return;
1284
+ for (const item of items) item.active.value = item.id === id;
1285
+ for (const [key, el] of panels) el.hidden = key !== id;
1286
+ try { S.set('domma-mail.settings-section', id); } catch { /* storage off */ }
1287
+ }
1288
+ const navBindings = M.applyBindings({items, show}, body.querySelector('.mail-settings-nav'));
1289
+ // List sections are drawn (hidden) at once, so their items are in the menu on the first right-click.
1290
+ setTimeout(() => { for (const section of sections) if (section.collection) ensure(section.id); }, 0);
1291
+ closeFns.add(() => { try { navBindings?.dispose?.(); } catch { /* gone */ } });
1292
+ // The section list's own menu: right-click a section (or Shift+F10 on it).
1293
+ const navEl = body.querySelector('.mail-settings-nav');
1294
+ const navMenu = E?.contextMenu?.(navEl, {
1295
+ match: '.mail-settings-link', inherit: false, items: [],
1296
+ onBeforeOpen: (c) => {
1297
+ const label = c?.target?.closest?.('.mail-settings-link')?.textContent?.trim();
1298
+ const item = items.find(i => !i.isGroup && label && label.startsWith(i.label));
1299
+ if (!item) return false;
1300
+ const section = byId.get(item.id);
1301
+ // A list section's own items: drawn (hidden) first so they are known.
1302
+ if (section?.collection) ensure(item.id);
1303
+ let own = [];
1304
+ try { own = navProviders.get(item.id)?.() ?? []; } catch { own = []; }
1305
+ if (section?.collection && !navProviders.has(item.id)) own = [{label: 'Loading…', icon: 'clock', disabled: () => true, action: () => {}}];
1306
+ // Every action (and those in submenus) first brings its section into view.
1307
+ const wrap = (entry) => (entry.type === 'divider' || entry.type === 'header' ? entry
1308
+ : Array.isArray(entry.submenu) ? {...entry, submenu: entry.submenu.map(wrap)}
1309
+ : !entry.action ? entry : {...entry, action: () => { show(item.id); entry.action(); }});
1310
+ navMenu.setItems([
1311
+ ...own.map(wrap),
1312
+ ...(own.length ? [{type: 'divider'}] : [{label: `Open ${item.label}`, icon: 'arrow-right', action: () => show(item.id)}]),
1313
+ ...(section?.guide ? [{label: `Help for ${item.label}`, icon: 'help-circle', action: () => {
1314
+ show(item.id);
1315
+ setTimeout(() => panels.get(item.id)?.querySelector('.mail-section-help')?.click(), 50);
1316
+ }}] : []),
1317
+ {type: 'divider'},
1318
+ {label: 'Back to mail', icon: 'arrow-left', action: () => slideover.close()}
1319
+ ]);
1320
+ return true;
1321
+ }
1322
+ });
1323
+ const onNavKey = (event) => {
1324
+ if (event.key === 'F10' && event.shiftKey && event.target.closest?.('.mail-settings-link')) {
1325
+ event.preventDefault();
1326
+ openMenuAt(event.target.closest('.mail-settings-link'));
1327
+ }
1328
+ };
1329
+ navEl.addEventListener('keydown', onNavKey);
1330
+ closeFns.add(() => { navEl.removeEventListener('keydown', onNavKey); try { navMenu?.destroy?.(); } catch { /* gone */ } });
1331
+
1332
+ refreshPips = () => {
1333
+ const dirty = new Set(dirtyGuards().map(g => guardSection.get(g)).filter(Boolean));
1334
+ for (const item of items) if (!item.isGroup) item.dirty.value = dirty.has(item.id);
1335
+ };
1336
+ const onEdit = () => setTimeout(() => refreshPips(), 0);
1337
+ for (const type of ['input', 'change', 'keyup', 'click']) body.addEventListener(type, onEdit, true);
1338
+ const pipTimer = setInterval(() => refreshPips(), 1000);
1339
+ closeFns.add(() => clearInterval(pipTimer));
1340
+
1341
+ slideover.element.appendChild(body);
1342
+ let remembered = null;
1343
+ try { remembered = S.get('domma-mail.settings-section'); } catch { /* storage off */ }
1344
+ const first = [target?.section, remembered, groups[0]?.sections[0]?.id].find(id => byId.has(id));
1345
+ slideover.open();
1346
+ show(first);
1347
+ }
1348
+
1349
+ if (asScreen) {
1350
+ drawScreen();
1351
+ return;
1352
+ }
1124
1353
  if (sections.length === 1) {
1125
1354
  host.appendChild(document.createElement('div'));
1126
1355
  draw(sections[0], host.lastChild);
@@ -1226,6 +1455,7 @@ return {
1226
1455
  function redraw() {
1227
1456
  const focused = document.activeElement?.closest?.('.mail-box-row')?.dataset.id ?? null;
1228
1457
  const next = mailboxSectionBody(redraw);
1458
+ try { body.__dispose?.(); } catch { /* gone */ }
1229
1459
  body.replaceWith(next);
1230
1460
  body = next;
1231
1461
  Domma.icons.scan(body);
@@ -1238,6 +1468,15 @@ return {
1238
1468
  };
1239
1469
  const boxOf = (row) => mailboxes.find(b => b.id === row?.dataset.id) ?? null;
1240
1470
 
1471
+ // The settings list's right-click on "Mailboxes": each mailbox, then Add mailbox.
1472
+ ctx?.navMenu?.(() => [
1473
+ ...mailboxes.map(box => ({label: box.label || box.username || 'Mailbox', icon: box.id === currentAccountId ? 'check' : 'inbox',
1474
+ submenu: mailboxRowItems(box, redraw, container).filter(e => !/^Add /.test(e.label ?? ''))
1475
+ .filter((e, n, all) => e.type !== 'divider' || (n < all.length - 1 && all[n + 1].type !== 'divider'))})),
1476
+ {type: 'divider'},
1477
+ {label: 'Add mailbox…', icon: 'plus', action: () => openMailboxForm(null)}
1478
+ ]);
1479
+
1241
1480
  const elements = (typeof E !== 'undefined' && E?.contextMenu) ? E
1242
1481
  : (typeof Domma !== 'undefined' ? Domma?.elements : null);
1243
1482
  let menu = null;
@@ -1249,7 +1488,7 @@ return {
1249
1488
  onBeforeOpen: (c) => {
1250
1489
  const box = boxOf(rowOf(c?.target));
1251
1490
  if (!box) return false;
1252
- menu.setItems(mailboxRowItems(box, redraw));
1491
+ menu.setItems(mailboxRowItems(box, redraw, container));
1253
1492
  return true;
1254
1493
  }
1255
1494
  });
@@ -1271,11 +1510,21 @@ return {
1271
1510
  }
1272
1511
  };
1273
1512
  container.addEventListener('keydown', onKey);
1513
+ // A click on a row (not its buttons) edits it - the row's main action.
1514
+ const onClick = (event) => {
1515
+ const row = rowOf(event.target);
1516
+ if (!row || event.target.closest('button')) return;
1517
+ const box = boxOf(row);
1518
+ if (box) openMailboxForm(box);
1519
+ };
1520
+ container.addEventListener('click', onClick);
1521
+ ctx?.onClose?.(() => container.removeEventListener('click', onClick));
1274
1522
  // Saved, removed or connected elsewhere (the form, the folder
1275
1523
  // pane's menu): the rows follow.
1276
1524
  mailboxRedraws.add(redraw);
1277
1525
  ctx?.onClose?.(() => {
1278
1526
  mailboxRedraws.delete(redraw);
1527
+ try { body.__dispose?.(); } catch { /* gone */ }
1279
1528
  container.removeEventListener('keydown', onKey);
1280
1529
  try { menu?.destroy?.(); } catch { /* gone */ }
1281
1530
  });
@@ -1295,15 +1544,78 @@ return {
1295
1544
  * @param {Function} redraw
1296
1545
  * @returns {object[]}
1297
1546
  */
1298
- function mailboxRowItems(box, redraw) {
1299
- return menuItems(mailboxRowMenuModel({isDefault: box.isDefault === true, count: mailboxes.length}), {
1547
+ function mailboxRowItems(box, redraw, container = null) {
1548
+ const signIn = describeSignIn?.(box) ?? null;
1549
+ return menuItems(mailboxRowMenuModel({isDefault: box.isDefault === true, count: mailboxes.length,
1550
+ oauth: Boolean(box.oauth), needsSignIn: Boolean(signIn && signIn.tone !== 'ok'),
1551
+ isOpen: box.id === currentAccountId}), {
1300
1552
  edit: () => openMailboxForm(box),
1301
1553
  open: () => openMailboxInReader(box),
1554
+ refresh: () => checkMailboxNow(box),
1555
+ test: () => testMailbox(box),
1556
+ // The sign-in (Connect / Reconnect) lives in the mailbox's form.
1557
+ reconnect: () => openMailboxForm(box),
1558
+ folders: () => showMailboxFolders(box, container),
1302
1559
  default: () => toggleDefaultMailbox(box, redraw),
1303
- remove: () => removeMailbox(box, redraw)
1560
+ remove: () => removeMailbox(box, redraw),
1561
+ add: () => openMailboxForm(null)
1304
1562
  });
1305
1563
  }
1306
1564
 
1565
+ /**
1566
+ * Try a saved mailbox's connection as stored (the server uses the stored password or
1567
+ * sign-in), and say how it went.
1568
+ *
1569
+ * @param {object} box
1570
+ * @returns {Promise<void>}
1571
+ */
1572
+ async function testMailbox(box) {
1573
+ E.toast(`Connecting to "${box.label}"…`, {type: 'info'});
1574
+ try {
1575
+ const result = await api(`${BASE}/accounts/test`, 'POST', {
1576
+ id: box.id, label: box.label, host: box.host, port: box.port, secure: box.secure,
1577
+ username: box.username, password: '', ...(box.oauth ? {oauth: box.oauth} : {})
1578
+ });
1579
+ if (!here()) return;
1580
+ E.toast(result.ok ? `"${box.label}" connected successfully.` : (result.error || 'It did not connect.'),
1581
+ {type: result.ok ? 'success' : 'error'});
1582
+ } catch (err) {
1583
+ if (here()) E.toast(err.message, {type: 'error'});
1584
+ }
1585
+ }
1586
+
1587
+ /**
1588
+ * Check a mailbox for new mail now - opening it in the reader first if it is not the one open.
1589
+ *
1590
+ * @param {object} box
1591
+ * @returns {Promise<void>}
1592
+ */
1593
+ async function checkMailboxNow(box) {
1594
+ if (box.id !== currentAccountId) await selectAccount(box.id);
1595
+ if (!here()) return;
1596
+ await refreshMailbox();
1597
+ E.toast(`Checked "${box.label}".`, {type: 'success'});
1598
+ }
1599
+
1600
+ /**
1601
+ * Go to the Folders settings for this mailbox: it becomes the open mailbox (settings
1602
+ * apply to the open one), then the Folders section is shown - by its nav link on the
1603
+ * settings screen, or the Folders tab in the slideover.
1604
+ *
1605
+ * @param {object} box
1606
+ * @param {HTMLElement|null} container
1607
+ * @returns {Promise<void>}
1608
+ */
1609
+ async function showMailboxFolders(box, container) {
1610
+ if (box.id !== currentAccountId) await selectAccount(box.id);
1611
+ if (!here()) return;
1612
+ const shell = container?.closest?.('.mail-settings-screen, .dm-slideover');
1613
+ const link = [...(shell?.querySelectorAll('.mail-settings-link, .tab-item') ?? [])]
1614
+ .find(el => el.textContent.trim().replace(/\s+/g, ' ').startsWith('Folders'));
1615
+ if (link) link.click();
1616
+ else E.toast('Open Settings > Folders to choose which folders are kept in step.', {type: 'info'});
1617
+ }
1618
+
1307
1619
  /**
1308
1620
  * Show a mailbox in the reader, closing Settings to do it.
1309
1621
  *
@@ -1374,95 +1686,58 @@ return {
1374
1686
  * @returns {HTMLElement}
1375
1687
  */
1376
1688
  function mailboxSectionBody(redraw) {
1689
+ // Built with domma-reactive: one row per mailbox, drawn from plain values worked out
1690
+ // here (the body is rebuilt whole when the list changes, so no row needs to follow
1691
+ // a change in place). Chips and labels are text, never markup.
1692
+ const rows = mailboxes.map(box => {
1693
+ const signIn = describeSignIn?.(box) ?? null;
1694
+ const draft = Boolean(readMailboxDraft(box.id));
1695
+ return {
1696
+ id: box.id,
1697
+ label: box.label,
1698
+ sub: signIn
1699
+ ? `${box.username} · ${box.oauth.provider === 'google' ? 'Google' : 'Microsoft'} sign-in`
1700
+ : `${box.username} · ${box.host}:${box.port}${box.secure ? '' : ' (no TLS)'}`,
1701
+ isDefault: box.isDefault === true && mailboxes.length > 1,
1702
+ isOpen: box.id === currentAccountId && mailboxes.length > 1,
1703
+ signInChip: signIn && signIn.tone !== 'ok' ? signIn.chip : '',
1704
+ signInText: signIn && signIn.tone !== 'ok' ? signIn.text : '',
1705
+ signInClass: signIn && signIn.tone !== 'ok' ? `badge mail-oauth-chip mail-oauth-chip--${signIn.tone}` : 'badge',
1706
+ draft,
1707
+ aria: `${box.label} - Enter to edit, Shift+F10 for actions`
1708
+ };
1709
+ });
1377
1710
  const body = document.createElement('div');
1378
1711
  body.className = 'flex flex-col gap-2';
1379
-
1380
- if (!mailboxes.length) {
1381
- const empty = document.createElement('p');
1382
- empty.className = 'text-sm text-muted mail-empty-line';
1383
- empty.textContent = 'No mailboxes yet. Add one to read its mail here.';
1384
- body.appendChild(empty);
1385
- }
1386
-
1387
- for (const box of mailboxes) {
1388
- const row = document.createElement('div');
1389
- row.className = 'mail-box-row';
1390
- row.dataset.id = box.id;
1391
- row.tabIndex = 0;
1392
- row.setAttribute('aria-label', `${box.label} - Enter to edit, Shift+F10 for actions`);
1393
- row.title = 'Right-click, ⋮ or Shift+F10 for actions';
1394
-
1395
- const info = document.createElement('div');
1396
- info.className = 'flex-1 mail-ellipsis';
1397
- const name = document.createElement('div');
1398
- name.className = 'font-semibold text-sm';
1399
- name.textContent = box.label;
1400
- if (box.isDefault && mailboxes.length > 1) {
1401
- const badge = document.createElement('span');
1402
- badge.className = 'badge badge-primary mail-default-badge';
1403
- badge.textContent = 'Default';
1404
- name.appendChild(badge);
1405
- }
1406
- if (box.id === currentAccountId && mailboxes.length > 1) {
1407
- const open = document.createElement('span');
1408
- open.className = 'badge badge-secondary mail-default-badge';
1409
- open.textContent = 'Open';
1410
- name.appendChild(open);
1411
- }
1412
- const sub = document.createElement('div');
1413
- sub.className = 'text-xs text-muted mail-box-sub';
1414
- const signIn = describeSignIn?.(box) ?? null;
1415
- sub.textContent = signIn
1416
- ? `${box.username} · ${box.oauth.provider === 'google' ? 'Google' : 'Microsoft'} sign-in`
1417
- : `${box.username} · ${box.host}:${box.port}${box.secure ? '' : ' (no TLS)'}`;
1418
- if (signIn && signIn.tone !== 'ok') {
1419
- const chip = document.createElement('span');
1420
- chip.className = `badge mail-oauth-chip mail-oauth-chip--${signIn.tone}`;
1421
- chip.textContent = signIn.chip;
1422
- chip.title = signIn.text;
1423
- name.appendChild(chip);
1424
- }
1425
- if (readMailboxDraft(box.id)) {
1426
- const chip = document.createElement('span');
1427
- chip.className = 'badge badge-warning mail-default-badge';
1428
- chip.textContent = 'Unsaved changes';
1429
- chip.title = 'You left changes to this mailbox unsaved - Edit to pick them up or throw them away';
1430
- name.appendChild(chip);
1431
- }
1432
- info.appendChild(name);
1433
- info.appendChild(sub);
1434
- row.appendChild(info);
1435
-
1436
- const editBtn = document.createElement('button');
1437
- editBtn.type = 'button';
1438
- editBtn.className = 'btn btn-sm btn-ghost';
1439
- editBtn.textContent = 'Edit';
1440
- editBtn.addEventListener('click', () => openMailboxForm(box));
1441
- row.appendChild(editBtn);
1442
-
1443
- const more = document.createElement('button');
1444
- more.type = 'button';
1445
- more.className = 'btn btn-sm btn-ghost mail-row-more';
1446
- more.title = 'More actions';
1447
- more.setAttribute('aria-label', 'More actions');
1448
- more.setAttribute('aria-haspopup', 'menu');
1449
- const glyph = document.createElement('span');
1450
- glyph.setAttribute('data-icon', 'more-vertical');
1451
- glyph.setAttribute('data-icon-size', '14');
1452
- more.appendChild(glyph);
1453
- more.addEventListener('click', () => openMenuAt(more));
1454
- row.appendChild(more);
1455
-
1456
- body.appendChild(row);
1457
- }
1458
-
1459
- const addBtn = document.createElement('button');
1460
- addBtn.type = 'button';
1461
- addBtn.className = 'btn btn-sm btn-primary';
1462
- addBtn.classList.add('mail-add-btn');
1463
- addBtn.textContent = readMailboxDraft(null) ? 'Add mailbox (unsaved changes)' : 'Add mailbox';
1464
- addBtn.addEventListener('click', () => openMailboxForm(null));
1465
- body.appendChild(addBtn);
1712
+ body.innerHTML = `
1713
+ <p class="text-sm text-muted mail-empty-line" data-bind-hidden="rows.length">No mailboxes yet. Add one to read its mail here.</p>
1714
+ <div class="flex flex-col gap-2" data-each="rows key=id">
1715
+ <div class="mail-box-row" tabindex="0" data-bind-data-id="id" data-bind-aria-label="aria" title="Click to edit - right-click, ⋮ or Shift+F10 for actions">
1716
+ <div class="flex-1 mail-ellipsis">
1717
+ <div class="font-semibold text-sm"><span data-bind-text="label"></span><span class="badge badge-primary mail-default-badge" data-bind-hidden="!isDefault">Default</span><span class="badge badge-secondary mail-default-badge" data-bind-hidden="!isOpen">Open</span><span data-bind-class="signInClass" data-bind-hidden="!signInChip" data-bind-text="signInChip" data-bind-title="signInText"></span><span class="badge badge-warning mail-default-badge" data-bind-hidden="!draft" title="You left changes to this mailbox unsaved - Edit to pick them up or throw them away">Unsaved changes</span></div>
1718
+ <div class="text-xs text-muted mail-box-sub" data-bind-text="sub"></div>
1719
+ </div>
1720
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="$root.edit($data)">Edit</button>
1721
+ <button type="button" class="btn btn-sm btn-ghost mail-row-more" title="More actions" aria-label="More actions" aria-haspopup="menu" data-on-click="$root.more($data)"><span data-icon="more-vertical" data-icon-size="14"></span></button>
1722
+ </div>
1723
+ </div>
1724
+ <hr class="mail-list-divider">
1725
+ <div class="flex items-center gap-2">
1726
+ <button type="button" class="btn btn-sm btn-primary mail-add-btn" data-on-click="add" data-bind-text="addLabel"></button>
1727
+ <span data-help-title="Add a mailbox" data-help="Any IMAP account: your server's address, port and security, and the username and password you sign in with. A Microsoft or Google mailbox can sign in with its own button where the edition offers it."></span>
1728
+ </div>`;
1729
+ const model = {
1730
+ rows,
1731
+ addLabel: readMailboxDraft(null) ? '+ Add mailbox (unsaved changes)' : '+ Add mailbox',
1732
+ edit(row) { const box = mailboxes.find(b => b.id === row.id); if (box) openMailboxForm(box); },
1733
+ more(row, event) {
1734
+ event?.stopPropagation?.();
1735
+ openMenuAt(event?.currentTarget ?? body.querySelector(`.mail-box-row[data-id="${CSS.escape(row.id)}"] .mail-row-more`));
1736
+ },
1737
+ add() { openMailboxForm(null); }
1738
+ };
1739
+ const bindings = M.applyBindings(model, body);
1740
+ body.__dispose = () => { try { bindings?.dispose?.(); } catch { /* gone */ } };
1466
1741
  Domma.icons.scan(body);
1467
1742
 
1468
1743
  return body;
@@ -6763,6 +7038,7 @@ return {
6763
7038
  this.onUnmount = teardown;
6764
7039
  this.refreshContacts = () => here() ? refreshContacts() : Promise.resolve();
6765
7040
  this.compose = draft => here() && features.send ? startNewMessage(draft) : Promise.resolve();
7041
+ this.openSettings = target => {if (here()) openSettings(target);};
6766
7042
  }
6767
7043
  };
6768
7044
  }
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/admin/mail/reader-view.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/reader-view.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Existing CMS entry point for the shared mail view. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/admin/mail/resizable.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The mail reader's resizable slideovers.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/admin/mail/restore-spam.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/restore-spam.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Undo restores both junk status and the original folder, following each UID remap. */
4
4
  export async function restoreSpam({api, base, account, from, destination, uids, spam}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/admin/mail/rules.js.
1
+ // Source: @domma-mail/core 0.32.0, packages/core/src/admin/mail/rules.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Filing rules.