domma-cms 1.72.0 → 1.74.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 +63 -6
  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 +458 -113
  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 +1 -1
  39. package/plugins/_lib/domma-mail.lock.json +83 -83
  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 +1 -1
  87. package/plugins/_lib/rich-text.js +1 -1
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.31.0, packages/core/src/admin/mail/reader-runtime.js.
1
+ // Source: @domma-mail/core 0.33.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);
@@ -121,9 +121,13 @@ function formatSize(bytes) {
121
121
  * recipientsChanged?(recipients), close?()}`, an edition's part of every
122
122
  * compose window: it may draw into `context.slot` (shown with
123
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.
124
125
  * Optional, checked and feature-detected: an edition that passes it to an
125
126
  * older reader just does not get the entries. Item actions run on the next
126
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.
127
131
  * `settingsSections` lets an edition contribute settings without forking the
128
132
  * view: each is `{id, label, render(container, context)}`, and the shell
129
133
  * handles the tabs, the lazy drawing and a section that throws.
@@ -134,7 +138,7 @@ function formatSize(bytes) {
134
138
  * @returns {object} a Domma view
135
139
  */
136
140
  export function createReaderView({pluginName, assetVersion = ASSET_VERSION, settingsSections = [], features = {},
137
- extensions = {}, host: mailHost = null}) {
141
+ extensions = {}, host: mailHost = null, settingsScreen = null}) {
138
142
  mailHost ??= createMailHost({pluginName});
139
143
  const {api, storage: S, Domma, M, E, F, $} = mailHost;
140
144
  const {viewLifetime, helpPopovers, openMenuAt, promptWith, sidebarCount, loading} = mailHost.helpers;
@@ -510,7 +514,10 @@ return {
510
514
  function openCompose(options) {
511
515
  // `extensions.compose`: an edition's part of every compose window
512
516
  // (Email Pro's branding picker). See compose-window.js.
513
- const handle = openComposeWindow({...options, host: mailHost,
517
+ // Where it opens: the place picked from a menu, else the last one
518
+ // used (a keyboard shortcut, Contacts' Email…, a reopened draft).
519
+ const handle = openComposeWindow({placement: lastPlacement(), ...options, host: mailHost,
520
+ onPlacement: rememberPlacement,
514
521
  composeExtension: typeof extensions.compose === 'function' ? extensions.compose : null});
515
522
  if (handle) {
516
523
  composeHandles.add(handle);
@@ -518,6 +525,61 @@ return {
518
525
  }
519
526
  return handle;
520
527
  }
528
+ /**
529
+ * Where a message is written: the side panel or the whole screen.
530
+ * Remembered in this browser, so the shortcuts and the windows other
531
+ * screens open go where the last one went.
532
+ */
533
+ const PLACEMENT_KEY = 'domma-mail.compose-placement';
534
+ function lastPlacement() {
535
+ try { return S.get(PLACEMENT_KEY) === 'full' ? 'full' : 'side'; } catch { return 'side'; }
536
+ }
537
+ function rememberPlacement(placement) {
538
+ try { S.set(PLACEMENT_KEY, placement === 'full' ? 'full' : 'side'); } catch { /* not remembered */ }
539
+ }
540
+
541
+ /** The placement menus: the banner's (until the screen is left) and the reader header's (per message). */
542
+ const placementMenus = new Set();
543
+ const headMenus = new Set();
544
+
545
+ /**
546
+ * The New message, Reply, Reply all and Forward buttons: a click
547
+ * offers where to write it. A script's click (Email Pro's Suggest a
548
+ * reply presses Reply) opens straight away in the last place used,
549
+ * since nobody is there to pick. Without E.dropdown, every click does.
550
+ *
551
+ * @param {HTMLElement} button
552
+ * @param {string} verb - "Write", "Reply", "Forward"...
553
+ * @param {(placement: 'side'|'full') => void} start
554
+ * @param {Set} [into] - where the menu is kept for teardown
555
+ * @returns {void}
556
+ */
557
+ function withPlacementMenu(button, verb, start, into = placementMenus) {
558
+ const dropdown = typeof E?.dropdown === 'function' ? E.dropdown(button, {
559
+ items: [
560
+ {label: `${verb} in the side panel`, value: 'side'},
561
+ {label: `${verb} full screen`, value: 'full'}
562
+ ],
563
+ itemTemplate: item => `<span class="mail-place-item">${esc(item.label)}</span>`,
564
+ onSelect: ({value}) => {
565
+ const placement = value === 'full' ? 'full' : 'side';
566
+ rememberPlacement(placement);
567
+ start(placement);
568
+ }
569
+ }) : null;
570
+ if (dropdown) into.add(dropdown);
571
+ // Capture, so it runs before the dropdown's own click listener.
572
+ button.addEventListener('click', (event) => {
573
+ if (dropdown && event.isTrusted) return;
574
+ event.stopImmediatePropagation();
575
+ start(lastPlacement());
576
+ }, true);
577
+ }
578
+ function dropHeadMenus() {
579
+ for (const menu of [...headMenus]) { try { menu.destroy?.(); } catch { /* gone */ } }
580
+ headMenus.clear();
581
+ }
582
+
521
583
  /**
522
584
  * Settings and mailbox panels open from this visit: closed without
523
585
  * asking when the screen is left (the lifetime), and removed from the
@@ -693,6 +755,8 @@ return {
693
755
  function teardown() {
694
756
  if (teardownPromise) return teardownPromise;
695
757
  disposed = true;
758
+ for (const menu of [...placementMenus]) { try { menu.destroy?.(); } catch { /* gone */ } }
759
+ placementMenus.clear();
696
760
  const saves = [];
697
761
  for (const handle of [...composeHandles]) {
698
762
  if (handle.dirty?.()) {
@@ -918,6 +982,58 @@ return {
918
982
  *
919
983
  * @returns {void}
920
984
  */
985
+ /**
986
+ * A stand-in for a slideover that is a screen in place of the reader: the same
987
+ * open/close/on('close') a panel has, so the guard, the close question and the
988
+ * clean-up treat both alike. Back to mail (or Escape on the screen) closes it.
989
+ *
990
+ * @returns {{element: HTMLElement, open: Function, close: Function, on: Function, destroy: Function}}
991
+ */
992
+ function settingsScreenPanel() {
993
+ const root = $container.get(0);
994
+ const layout = root.querySelector('.mail-layout');
995
+ const element = document.createElement('section');
996
+ element.className = 'mail-settings-screen';
997
+ element.hidden = true;
998
+ const head = document.createElement('div');
999
+ head.className = 'mail-settings-head';
1000
+ const back = document.createElement('button');
1001
+ back.type = 'button';
1002
+ back.className = 'btn btn-sm btn-ghost';
1003
+ back.textContent = '\u2190 Back to mail';
1004
+ const title = document.createElement('h2');
1005
+ title.className = 'mail-settings-title';
1006
+ title.textContent = settingsScreen?.title || 'Email settings';
1007
+ head.append(back, title);
1008
+ element.appendChild(head);
1009
+ layout.after(element);
1010
+ const listeners = {close: [], open: []};
1011
+ let open = false;
1012
+ const panel = {
1013
+ element,
1014
+ on(event, fn) { (listeners[event] ??= []).push(fn); },
1015
+ open() {
1016
+ open = true;
1017
+ layout.hidden = true;
1018
+ element.hidden = false;
1019
+ listeners.open.forEach(fn => { try { fn(panel); } catch { /* ignore */ } });
1020
+ back.focus();
1021
+ },
1022
+ close() {
1023
+ if (!open) return;
1024
+ open = false;
1025
+ element.hidden = true;
1026
+ layout.hidden = false;
1027
+ listeners.close.forEach(fn => { try { fn(panel); } catch { /* ignore */ } });
1028
+ element.remove();
1029
+ },
1030
+ destroy() { element.remove(); layout.hidden = false; }
1031
+ };
1032
+ // Through the property, so the guarded close (the unsaved question) is the one called.
1033
+ back.addEventListener('click', () => panel.close());
1034
+ return panel;
1035
+ }
1036
+
921
1037
  function openSettings(target = null) {
922
1038
  // One at a time: a second click, or a needs-password error while
923
1039
  // it is open, must not stack a second panel on the first.
@@ -955,7 +1071,10 @@ return {
955
1071
  const dirtyGuards = () => [...guards].filter(g => { try { return Boolean(g.dirty?.()); } catch { return false; } });
956
1072
  // Each section saves on its own button; the panel asks only for
957
1073
  // sections that said (ctx.guard) they hold unsaved work.
958
- const slideover = guardPanel(E.slideover({title: 'Mail Settings', size: 'lg', position: 'right'}),
1074
+ const navProviders = new Map();
1075
+ const asScreen = Array.isArray(settingsScreen?.groups) && settingsScreen.groups.length > 0
1076
+ && Boolean($container.get(0)?.querySelector('.mail-layout'));
1077
+ const slideover = guardPanel(asScreen ? settingsScreenPanel() : E.slideover({title: 'Mail Settings', size: 'lg', position: 'right'}),
959
1078
  () => dirtyGuards().length > 0,
960
1079
  () => settingsDiscardQuestion(dirtyGuards().map(g => g.label)),
961
1080
  () => {
@@ -973,7 +1092,7 @@ return {
973
1092
  // width someone wants depends on their screen - the same reason
974
1093
  // compose is resizable. Its own remembered width, because the two
975
1094
  // are opened for different things.
976
- const stopSettingsResize = makeResizable(slideover, {
1095
+ const stopSettingsResize = asScreen ? () => {} : makeResizable(slideover, {
977
1096
  storage: mailHost.storage,
978
1097
  storageKey: 'domma-mail.settings-width',
979
1098
  defaultWidth: 760
@@ -996,8 +1115,19 @@ return {
996
1115
  {
997
1116
  id: 'mailboxes',
998
1117
  label: 'Mailboxes',
1118
+ collection: true,
999
1119
  icon: 'inbox',
1000
1120
  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.',
1121
+ 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>
1122
+ <h4>The list</h4>
1123
+ <ul><li>Click a mailbox, or press Enter on it, to edit its server, port, security and sign-in.</li>
1124
+ <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>
1125
+ <li>The <b>Default</b> mailbox is the one the screen opens on. <b>Open</b> marks the one you are reading now.</li>
1126
+ <li><b>+ Add mailbox</b> under the list adds another account.</li></ul>
1127
+ <h4>Passwords and sign-in</h4>
1128
+ <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>
1129
+ <h4>Unsaved changes</h4>
1130
+ <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>`,
1001
1131
  render: renderMailboxSection
1002
1132
  },
1003
1133
  // Blocking remote images is not a Pro feature, and neither is
@@ -1034,6 +1164,10 @@ return {
1034
1164
  */
1035
1165
  function context(section = null) {
1036
1166
  return {
1167
+ // Screen mode only: a section that keeps a list (identities, away messages,
1168
+ // templates…) hands its items to the section list's right-click menu instead
1169
+ // of drawing a list column, so the editor gets the width.
1170
+ navMenu: asScreen && section ? (provider) => { navProviders.set(section.id, provider); } : undefined,
1037
1171
  // What opened this section, when something did (a menu
1038
1172
  // item asking for a new rule). Only for that section.
1039
1173
  request: target && section?.id === target.section ? (target.request ?? null) : null,
@@ -1115,6 +1249,25 @@ return {
1115
1249
  marker.setAttribute('data-help-title', section.label);
1116
1250
  marker.setAttribute('data-help', section.help);
1117
1251
  head.append(title, marker);
1252
+ // Longer help in a slideover, for a section that brings it: `guide` is the
1253
+ // section's own static HTML (written in code, never user text).
1254
+ if (section.guide) {
1255
+ const more = document.createElement('button');
1256
+ more.type = 'button';
1257
+ more.className = 'btn btn-sm btn-ghost mail-section-help';
1258
+ more.textContent = 'Help';
1259
+ more.setAttribute('aria-haspopup', 'dialog');
1260
+ more.addEventListener('click', () => {
1261
+ const help = E.slideover({title: `${section.label} - help`, size: 'md', position: 'right'});
1262
+ const box = document.createElement('div');
1263
+ box.className = 'mail-help-body';
1264
+ box.innerHTML = section.guide;
1265
+ help.element.appendChild(box);
1266
+ help.open();
1267
+ whenClosed(help, () => setTimeout(() => { try { help.element?.remove(); } catch { /* gone */ } }, 400));
1268
+ });
1269
+ head.appendChild(more);
1270
+ }
1118
1271
  panel.appendChild(head);
1119
1272
  }
1120
1273
  try {
@@ -1129,6 +1282,134 @@ return {
1129
1282
  helpDisposers.push(helpPopovers(panel, {position: 'bottom'}));
1130
1283
  }
1131
1284
 
1285
+ /**
1286
+ * Settings as a screen: the groups down the left, one section at a time on the right.
1287
+ * Sections are drawn on first view and kept, as the tabs are.
1288
+ */
1289
+ function drawScreen() {
1290
+ const byId = new Map(sections.map(section => [section.id, section]));
1291
+ const placed = new Set();
1292
+ const groups = settingsScreen.groups.map(group => ({
1293
+ label: String(group.label ?? ''),
1294
+ sections: (group.sections ?? []).map(id => byId.get(id)).filter(section => section && !placed.has(section.id) && placed.add(section.id))
1295
+ })).filter(group => group.sections.length);
1296
+ const rest = sections.filter(section => !placed.has(section.id));
1297
+ if (rest.length) groups.push({label: 'More', sections: rest});
1298
+
1299
+ // Built with domma-reactive: one flat list of group headings and section links (a
1300
+ // nested data-each renders an unbound copy), each link's state an observable.
1301
+ const items = [];
1302
+ for (const group of groups) {
1303
+ items.push({key: `g:${group.label}`, isGroup: true, label: group.label, id: '',
1304
+ active: M.observable(false), dirty: M.observable(false)});
1305
+ for (const section of group.sections) {
1306
+ items.push({key: `s:${section.id}`, isGroup: false, label: section.label, id: section.id,
1307
+ active: M.observable(false), dirty: M.observable(false)});
1308
+ }
1309
+ }
1310
+ const body = document.createElement('div');
1311
+ body.className = 'mail-settings-body';
1312
+ body.innerHTML = `<nav class="mail-settings-nav" aria-label="Settings" data-each="items key=key">
1313
+ <div class="mail-settings-group-label" data-bind-hidden="!isGroup" data-bind-text="label"></div>
1314
+ <button type="button" class="mail-settings-link" data-bind-hidden="isGroup" data-bind-class="active.value && 'is-active'"
1315
+ data-bind-aria-current="active.value ? 'page' : 'false'" data-bind-aria-description="dirty.value ? 'Unsaved changes' : ''"
1316
+ 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>
1317
+ </nav><div class="mail-settings-main"></div>`;
1318
+ const main = body.querySelector('.mail-settings-main');
1319
+ const panels = new Map();
1320
+ function ensure(id) {
1321
+ const section = byId.get(id);
1322
+ if (!section) return null;
1323
+ let panel = panels.get(id);
1324
+ // Drawn for another mailbox (Folders to sync… on a mailbox's menu opens that one
1325
+ // first): drawn again, so a section never shows one mailbox's settings under another.
1326
+ if (panel && panel.dataset.account !== String(currentAccountId ?? '')) {
1327
+ panel.remove();
1328
+ panels.delete(id);
1329
+ panel = null;
1330
+ }
1331
+ if (!panel) {
1332
+ panel = document.createElement('div');
1333
+ panel.className = 'mail-settings-panel';
1334
+ panel.dataset.account = String(currentAccountId ?? '');
1335
+ main.appendChild(panel);
1336
+ panels.set(id, panel);
1337
+ panel.hidden = true;
1338
+ draw(section, panel);
1339
+ }
1340
+ return panel;
1341
+ }
1342
+ function show(id) {
1343
+ if (!ensure(id)) return;
1344
+ for (const item of items) item.active.value = item.id === id;
1345
+ for (const [key, el] of panels) el.hidden = key !== id;
1346
+ try { S.set('domma-mail.settings-section', id); } catch { /* storage off */ }
1347
+ }
1348
+ const navBindings = M.applyBindings({items, show}, body.querySelector('.mail-settings-nav'));
1349
+ // List sections are drawn (hidden) at once, so their items are in the menu on the first right-click.
1350
+ setTimeout(() => { for (const section of sections) if (section.collection) ensure(section.id); }, 0);
1351
+ closeFns.add(() => { try { navBindings?.dispose?.(); } catch { /* gone */ } });
1352
+ // The section list's own menu: right-click a section (or Shift+F10 on it).
1353
+ const navEl = body.querySelector('.mail-settings-nav');
1354
+ const navMenu = E?.contextMenu?.(navEl, {
1355
+ match: '.mail-settings-link', inherit: false, items: [],
1356
+ onBeforeOpen: (c) => {
1357
+ const label = c?.target?.closest?.('.mail-settings-link')?.textContent?.trim();
1358
+ const item = items.find(i => !i.isGroup && label && label.startsWith(i.label));
1359
+ if (!item) return false;
1360
+ const section = byId.get(item.id);
1361
+ // A list section's own items: drawn (hidden) first so they are known.
1362
+ if (section?.collection) ensure(item.id);
1363
+ let own = [];
1364
+ try { own = navProviders.get(item.id)?.() ?? []; } catch { own = []; }
1365
+ if (section?.collection && !navProviders.has(item.id)) own = [{label: 'Loading…', icon: 'clock', disabled: () => true, action: () => {}}];
1366
+ // Every action (and those in submenus) first brings its section into view.
1367
+ const wrap = (entry) => (entry.type === 'divider' || entry.type === 'header' ? entry
1368
+ : Array.isArray(entry.submenu) ? {...entry, submenu: entry.submenu.map(wrap)}
1369
+ : !entry.action ? entry : {...entry, action: () => { show(item.id); entry.action(); }});
1370
+ navMenu.setItems([
1371
+ ...own.map(wrap),
1372
+ ...(own.length ? [{type: 'divider'}] : [{label: `Open ${item.label}`, icon: 'arrow-right', action: () => show(item.id)}]),
1373
+ ...(section?.guide ? [{label: `Help for ${item.label}`, icon: 'help-circle', action: () => {
1374
+ show(item.id);
1375
+ setTimeout(() => panels.get(item.id)?.querySelector('.mail-section-help')?.click(), 50);
1376
+ }}] : []),
1377
+ {type: 'divider'},
1378
+ {label: 'Back to mail', icon: 'arrow-left', action: () => slideover.close()}
1379
+ ]);
1380
+ return true;
1381
+ }
1382
+ });
1383
+ const onNavKey = (event) => {
1384
+ if (event.key === 'F10' && event.shiftKey && event.target.closest?.('.mail-settings-link')) {
1385
+ event.preventDefault();
1386
+ openMenuAt(event.target.closest('.mail-settings-link'));
1387
+ }
1388
+ };
1389
+ navEl.addEventListener('keydown', onNavKey);
1390
+ closeFns.add(() => { navEl.removeEventListener('keydown', onNavKey); try { navMenu?.destroy?.(); } catch { /* gone */ } });
1391
+
1392
+ refreshPips = () => {
1393
+ const dirty = new Set(dirtyGuards().map(g => guardSection.get(g)).filter(Boolean));
1394
+ for (const item of items) if (!item.isGroup) item.dirty.value = dirty.has(item.id);
1395
+ };
1396
+ const onEdit = () => setTimeout(() => refreshPips(), 0);
1397
+ for (const type of ['input', 'change', 'keyup', 'click']) body.addEventListener(type, onEdit, true);
1398
+ const pipTimer = setInterval(() => refreshPips(), 1000);
1399
+ closeFns.add(() => clearInterval(pipTimer));
1400
+
1401
+ slideover.element.appendChild(body);
1402
+ let remembered = null;
1403
+ try { remembered = S.get('domma-mail.settings-section'); } catch { /* storage off */ }
1404
+ const first = [target?.section, remembered, groups[0]?.sections[0]?.id].find(id => byId.has(id));
1405
+ slideover.open();
1406
+ show(first);
1407
+ }
1408
+
1409
+ if (asScreen) {
1410
+ drawScreen();
1411
+ return;
1412
+ }
1132
1413
  if (sections.length === 1) {
1133
1414
  host.appendChild(document.createElement('div'));
1134
1415
  draw(sections[0], host.lastChild);
@@ -1234,6 +1515,7 @@ return {
1234
1515
  function redraw() {
1235
1516
  const focused = document.activeElement?.closest?.('.mail-box-row')?.dataset.id ?? null;
1236
1517
  const next = mailboxSectionBody(redraw);
1518
+ try { body.__dispose?.(); } catch { /* gone */ }
1237
1519
  body.replaceWith(next);
1238
1520
  body = next;
1239
1521
  Domma.icons.scan(body);
@@ -1246,6 +1528,15 @@ return {
1246
1528
  };
1247
1529
  const boxOf = (row) => mailboxes.find(b => b.id === row?.dataset.id) ?? null;
1248
1530
 
1531
+ // The settings list's right-click on "Mailboxes": each mailbox, then Add mailbox.
1532
+ ctx?.navMenu?.(() => [
1533
+ ...mailboxes.map(box => ({label: box.label || box.username || 'Mailbox', icon: box.id === currentAccountId ? 'check' : 'inbox',
1534
+ submenu: mailboxRowItems(box, redraw, container).filter(e => !/^Add /.test(e.label ?? ''))
1535
+ .filter((e, n, all) => e.type !== 'divider' || (n < all.length - 1 && all[n + 1].type !== 'divider'))})),
1536
+ {type: 'divider'},
1537
+ {label: 'Add mailbox…', icon: 'plus', action: () => openMailboxForm(null)}
1538
+ ]);
1539
+
1249
1540
  const elements = (typeof E !== 'undefined' && E?.contextMenu) ? E
1250
1541
  : (typeof Domma !== 'undefined' ? Domma?.elements : null);
1251
1542
  let menu = null;
@@ -1257,7 +1548,7 @@ return {
1257
1548
  onBeforeOpen: (c) => {
1258
1549
  const box = boxOf(rowOf(c?.target));
1259
1550
  if (!box) return false;
1260
- menu.setItems(mailboxRowItems(box, redraw));
1551
+ menu.setItems(mailboxRowItems(box, redraw, container));
1261
1552
  return true;
1262
1553
  }
1263
1554
  });
@@ -1279,11 +1570,21 @@ return {
1279
1570
  }
1280
1571
  };
1281
1572
  container.addEventListener('keydown', onKey);
1573
+ // A click on a row (not its buttons) edits it - the row's main action.
1574
+ const onClick = (event) => {
1575
+ const row = rowOf(event.target);
1576
+ if (!row || event.target.closest('button')) return;
1577
+ const box = boxOf(row);
1578
+ if (box) openMailboxForm(box);
1579
+ };
1580
+ container.addEventListener('click', onClick);
1581
+ ctx?.onClose?.(() => container.removeEventListener('click', onClick));
1282
1582
  // Saved, removed or connected elsewhere (the form, the folder
1283
1583
  // pane's menu): the rows follow.
1284
1584
  mailboxRedraws.add(redraw);
1285
1585
  ctx?.onClose?.(() => {
1286
1586
  mailboxRedraws.delete(redraw);
1587
+ try { body.__dispose?.(); } catch { /* gone */ }
1287
1588
  container.removeEventListener('keydown', onKey);
1288
1589
  try { menu?.destroy?.(); } catch { /* gone */ }
1289
1590
  });
@@ -1303,15 +1604,78 @@ return {
1303
1604
  * @param {Function} redraw
1304
1605
  * @returns {object[]}
1305
1606
  */
1306
- function mailboxRowItems(box, redraw) {
1307
- return menuItems(mailboxRowMenuModel({isDefault: box.isDefault === true, count: mailboxes.length}), {
1607
+ function mailboxRowItems(box, redraw, container = null) {
1608
+ const signIn = describeSignIn?.(box) ?? null;
1609
+ return menuItems(mailboxRowMenuModel({isDefault: box.isDefault === true, count: mailboxes.length,
1610
+ oauth: Boolean(box.oauth), needsSignIn: Boolean(signIn && signIn.tone !== 'ok'),
1611
+ isOpen: box.id === currentAccountId}), {
1308
1612
  edit: () => openMailboxForm(box),
1309
1613
  open: () => openMailboxInReader(box),
1614
+ refresh: () => checkMailboxNow(box),
1615
+ test: () => testMailbox(box),
1616
+ // The sign-in (Connect / Reconnect) lives in the mailbox's form.
1617
+ reconnect: () => openMailboxForm(box),
1618
+ folders: () => showMailboxFolders(box, container),
1310
1619
  default: () => toggleDefaultMailbox(box, redraw),
1311
- remove: () => removeMailbox(box, redraw)
1620
+ remove: () => removeMailbox(box, redraw),
1621
+ add: () => openMailboxForm(null)
1312
1622
  });
1313
1623
  }
1314
1624
 
1625
+ /**
1626
+ * Try a saved mailbox's connection as stored (the server uses the stored password or
1627
+ * sign-in), and say how it went.
1628
+ *
1629
+ * @param {object} box
1630
+ * @returns {Promise<void>}
1631
+ */
1632
+ async function testMailbox(box) {
1633
+ E.toast(`Connecting to "${box.label}"…`, {type: 'info'});
1634
+ try {
1635
+ const result = await api(`${BASE}/accounts/test`, 'POST', {
1636
+ id: box.id, label: box.label, host: box.host, port: box.port, secure: box.secure,
1637
+ username: box.username, password: '', ...(box.oauth ? {oauth: box.oauth} : {})
1638
+ });
1639
+ if (!here()) return;
1640
+ E.toast(result.ok ? `"${box.label}" connected successfully.` : (result.error || 'It did not connect.'),
1641
+ {type: result.ok ? 'success' : 'error'});
1642
+ } catch (err) {
1643
+ if (here()) E.toast(err.message, {type: 'error'});
1644
+ }
1645
+ }
1646
+
1647
+ /**
1648
+ * Check a mailbox for new mail now - opening it in the reader first if it is not the one open.
1649
+ *
1650
+ * @param {object} box
1651
+ * @returns {Promise<void>}
1652
+ */
1653
+ async function checkMailboxNow(box) {
1654
+ if (box.id !== currentAccountId) await selectAccount(box.id);
1655
+ if (!here()) return;
1656
+ await refreshMailbox();
1657
+ E.toast(`Checked "${box.label}".`, {type: 'success'});
1658
+ }
1659
+
1660
+ /**
1661
+ * Go to the Folders settings for this mailbox: it becomes the open mailbox (settings
1662
+ * apply to the open one), then the Folders section is shown - by its nav link on the
1663
+ * settings screen, or the Folders tab in the slideover.
1664
+ *
1665
+ * @param {object} box
1666
+ * @param {HTMLElement|null} container
1667
+ * @returns {Promise<void>}
1668
+ */
1669
+ async function showMailboxFolders(box, container) {
1670
+ if (box.id !== currentAccountId) await selectAccount(box.id);
1671
+ if (!here()) return;
1672
+ const shell = container?.closest?.('.mail-settings-screen, .dm-slideover');
1673
+ const link = [...(shell?.querySelectorAll('.mail-settings-link, .tab-item') ?? [])]
1674
+ .find(el => el.textContent.trim().replace(/\s+/g, ' ').startsWith('Folders'));
1675
+ if (link) link.click();
1676
+ else E.toast('Open Settings > Folders to choose which folders are kept in step.', {type: 'info'});
1677
+ }
1678
+
1315
1679
  /**
1316
1680
  * Show a mailbox in the reader, closing Settings to do it.
1317
1681
  *
@@ -1382,95 +1746,58 @@ return {
1382
1746
  * @returns {HTMLElement}
1383
1747
  */
1384
1748
  function mailboxSectionBody(redraw) {
1749
+ // Built with domma-reactive: one row per mailbox, drawn from plain values worked out
1750
+ // here (the body is rebuilt whole when the list changes, so no row needs to follow
1751
+ // a change in place). Chips and labels are text, never markup.
1752
+ const rows = mailboxes.map(box => {
1753
+ const signIn = describeSignIn?.(box) ?? null;
1754
+ const draft = Boolean(readMailboxDraft(box.id));
1755
+ return {
1756
+ id: box.id,
1757
+ label: box.label,
1758
+ sub: signIn
1759
+ ? `${box.username} · ${box.oauth.provider === 'google' ? 'Google' : 'Microsoft'} sign-in`
1760
+ : `${box.username} · ${box.host}:${box.port}${box.secure ? '' : ' (no TLS)'}`,
1761
+ isDefault: box.isDefault === true && mailboxes.length > 1,
1762
+ isOpen: box.id === currentAccountId && mailboxes.length > 1,
1763
+ signInChip: signIn && signIn.tone !== 'ok' ? signIn.chip : '',
1764
+ signInText: signIn && signIn.tone !== 'ok' ? signIn.text : '',
1765
+ signInClass: signIn && signIn.tone !== 'ok' ? `badge mail-oauth-chip mail-oauth-chip--${signIn.tone}` : 'badge',
1766
+ draft,
1767
+ aria: `${box.label} - Enter to edit, Shift+F10 for actions`
1768
+ };
1769
+ });
1385
1770
  const body = document.createElement('div');
1386
1771
  body.className = 'flex flex-col gap-2';
1387
-
1388
- if (!mailboxes.length) {
1389
- const empty = document.createElement('p');
1390
- empty.className = 'text-sm text-muted mail-empty-line';
1391
- empty.textContent = 'No mailboxes yet. Add one to read its mail here.';
1392
- body.appendChild(empty);
1393
- }
1394
-
1395
- for (const box of mailboxes) {
1396
- const row = document.createElement('div');
1397
- row.className = 'mail-box-row';
1398
- row.dataset.id = box.id;
1399
- row.tabIndex = 0;
1400
- row.setAttribute('aria-label', `${box.label} - Enter to edit, Shift+F10 for actions`);
1401
- row.title = 'Right-click, ⋮ or Shift+F10 for actions';
1402
-
1403
- const info = document.createElement('div');
1404
- info.className = 'flex-1 mail-ellipsis';
1405
- const name = document.createElement('div');
1406
- name.className = 'font-semibold text-sm';
1407
- name.textContent = box.label;
1408
- if (box.isDefault && mailboxes.length > 1) {
1409
- const badge = document.createElement('span');
1410
- badge.className = 'badge badge-primary mail-default-badge';
1411
- badge.textContent = 'Default';
1412
- name.appendChild(badge);
1413
- }
1414
- if (box.id === currentAccountId && mailboxes.length > 1) {
1415
- const open = document.createElement('span');
1416
- open.className = 'badge badge-secondary mail-default-badge';
1417
- open.textContent = 'Open';
1418
- name.appendChild(open);
1419
- }
1420
- const sub = document.createElement('div');
1421
- sub.className = 'text-xs text-muted mail-box-sub';
1422
- const signIn = describeSignIn?.(box) ?? null;
1423
- sub.textContent = signIn
1424
- ? `${box.username} · ${box.oauth.provider === 'google' ? 'Google' : 'Microsoft'} sign-in`
1425
- : `${box.username} · ${box.host}:${box.port}${box.secure ? '' : ' (no TLS)'}`;
1426
- if (signIn && signIn.tone !== 'ok') {
1427
- const chip = document.createElement('span');
1428
- chip.className = `badge mail-oauth-chip mail-oauth-chip--${signIn.tone}`;
1429
- chip.textContent = signIn.chip;
1430
- chip.title = signIn.text;
1431
- name.appendChild(chip);
1432
- }
1433
- if (readMailboxDraft(box.id)) {
1434
- const chip = document.createElement('span');
1435
- chip.className = 'badge badge-warning mail-default-badge';
1436
- chip.textContent = 'Unsaved changes';
1437
- chip.title = 'You left changes to this mailbox unsaved - Edit to pick them up or throw them away';
1438
- name.appendChild(chip);
1439
- }
1440
- info.appendChild(name);
1441
- info.appendChild(sub);
1442
- row.appendChild(info);
1443
-
1444
- const editBtn = document.createElement('button');
1445
- editBtn.type = 'button';
1446
- editBtn.className = 'btn btn-sm btn-ghost';
1447
- editBtn.textContent = 'Edit';
1448
- editBtn.addEventListener('click', () => openMailboxForm(box));
1449
- row.appendChild(editBtn);
1450
-
1451
- const more = document.createElement('button');
1452
- more.type = 'button';
1453
- more.className = 'btn btn-sm btn-ghost mail-row-more';
1454
- more.title = 'More actions';
1455
- more.setAttribute('aria-label', 'More actions');
1456
- more.setAttribute('aria-haspopup', 'menu');
1457
- const glyph = document.createElement('span');
1458
- glyph.setAttribute('data-icon', 'more-vertical');
1459
- glyph.setAttribute('data-icon-size', '14');
1460
- more.appendChild(glyph);
1461
- more.addEventListener('click', () => openMenuAt(more));
1462
- row.appendChild(more);
1463
-
1464
- body.appendChild(row);
1465
- }
1466
-
1467
- const addBtn = document.createElement('button');
1468
- addBtn.type = 'button';
1469
- addBtn.className = 'btn btn-sm btn-primary';
1470
- addBtn.classList.add('mail-add-btn');
1471
- addBtn.textContent = readMailboxDraft(null) ? 'Add mailbox (unsaved changes)' : 'Add mailbox';
1472
- addBtn.addEventListener('click', () => openMailboxForm(null));
1473
- body.appendChild(addBtn);
1772
+ body.innerHTML = `
1773
+ <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>
1774
+ <div class="flex flex-col gap-2" data-each="rows key=id">
1775
+ <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">
1776
+ <div class="flex-1 mail-ellipsis">
1777
+ <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>
1778
+ <div class="text-xs text-muted mail-box-sub" data-bind-text="sub"></div>
1779
+ </div>
1780
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="$root.edit($data)">Edit</button>
1781
+ <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>
1782
+ </div>
1783
+ </div>
1784
+ <hr class="mail-list-divider">
1785
+ <div class="flex items-center gap-2">
1786
+ <button type="button" class="btn btn-sm btn-primary mail-add-btn" data-on-click="add" data-bind-text="addLabel"></button>
1787
+ <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>
1788
+ </div>`;
1789
+ const model = {
1790
+ rows,
1791
+ addLabel: readMailboxDraft(null) ? '+ Add mailbox (unsaved changes)' : '+ Add mailbox',
1792
+ edit(row) { const box = mailboxes.find(b => b.id === row.id); if (box) openMailboxForm(box); },
1793
+ more(row, event) {
1794
+ event?.stopPropagation?.();
1795
+ openMenuAt(event?.currentTarget ?? body.querySelector(`.mail-box-row[data-id="${CSS.escape(row.id)}"] .mail-row-more`));
1796
+ },
1797
+ add() { openMailboxForm(null); }
1798
+ };
1799
+ const bindings = M.applyBindings(model, body);
1800
+ body.__dispose = () => { try { bindings?.dispose?.(); } catch { /* gone */ } };
1474
1801
  Domma.icons.scan(body);
1475
1802
 
1476
1803
  return body;
@@ -3180,6 +3507,7 @@ return {
3180
3507
  cancelMarkRead();
3181
3508
  // A message still on its way must not land in the cleared pane.
3182
3509
  openSeq += 1;
3510
+ dropHeadMenus();
3183
3511
  readerHeadEl.textContent = '';
3184
3512
  showEmpty(readerBodyEl, 'mail', 'Select a message to read it.');
3185
3513
  }
@@ -3260,6 +3588,7 @@ return {
3260
3588
  * @returns {void}
3261
3589
  */
3262
3590
  function renderMessage(message) {
3591
+ dropHeadMenus();
3263
3592
  readerHeadEl.textContent = '';
3264
3593
 
3265
3594
  const subject = document.createElement('h2');
@@ -3303,12 +3632,16 @@ return {
3303
3632
  }
3304
3633
 
3305
3634
  if (features.send) {
3306
- actions.appendChild(actionButton('Reply', 'corner-up-left',
3307
- () => compose(message, 'reply'), 'Reply to the sender (r)'));
3308
- actions.appendChild(actionButton('Reply all', 'corner-up-right',
3309
- () => compose(message, 'replyAll'), 'Reply to everyone (Shift-R)'));
3310
- actions.appendChild(actionButton('Forward', 'send',
3311
- () => compose(message, 'forward'), 'Forward to someone else (f)'));
3635
+ // Each asks where to write: the side panel or full screen.
3636
+ for (const [label, icon, mode, hint] of [
3637
+ ['Reply', 'corner-up-left', 'reply', 'Reply to the sender (r)'],
3638
+ ['Reply all', 'corner-up-right', 'replyAll', 'Reply to everyone (Shift-R)'],
3639
+ ['Forward', 'send', 'forward', 'Forward to someone else (f)']
3640
+ ]) {
3641
+ const button = actionButton(label, icon, () => {}, hint);
3642
+ withPlacementMenu(button, label, placement => compose(message, mode, {placement}), headMenus);
3643
+ actions.appendChild(button);
3644
+ }
3312
3645
  }
3313
3646
 
3314
3647
  if (canSnooze(message)) {
@@ -3872,9 +4205,11 @@ return {
3872
4205
  ] : []),
3873
4206
  // The reading pane's three, without opening the message first.
3874
4207
  ...(features.send && !isDraft(target) ? [
3875
- {label: 'Reply', icon: 'corner-up-left', action: () => compose(target, 'reply')},
3876
- {label: 'Reply all', icon: 'corner-up-right', action: () => compose(target, 'replyAll')},
3877
- {label: 'Forward', icon: 'send', action: () => compose(target, 'forward')},
4208
+ ...[['Reply', 'corner-up-left', 'reply'], ['Reply all', 'corner-up-right', 'replyAll'],
4209
+ ['Forward', 'send', 'forward']].map(([label, icon, mode]) => ({label, icon, submenu: [
4210
+ {label: 'In the side panel', icon: 'panel-right', action: () => { rememberPlacement('side'); compose(target, mode, {placement: 'side'}); }},
4211
+ {label: 'Full screen', icon: 'maximize-2', action: () => { rememberPlacement('full'); compose(target, mode, {placement: 'full'}); }}
4212
+ ]})),
3878
4213
  {type: 'divider'}
3879
4214
  ] : []),
3880
4215
  {
@@ -6165,7 +6500,7 @@ return {
6165
6500
  * @param {'reply'|'replyAll'|'forward'} mode
6166
6501
  * @returns {Promise<void>}
6167
6502
  */
6168
- async function compose(message, mode, {quote = null} = {}) {
6503
+ async function compose(message, mode, {quote = null, placement} = {}) {
6169
6504
  const accountId = currentAccountId;
6170
6505
  const profile = identitySoon();
6171
6506
  try {
@@ -6180,7 +6515,8 @@ return {
6180
6515
  // Quote in reply: just the selected text under the
6181
6516
  // attribution line, not the whole message.
6182
6517
  draft: quote ? quoteSelection(result.draft, quote) : result.draft,
6183
- mode
6518
+ mode,
6519
+ ...(placement ? {placement} : {})
6184
6520
  }));
6185
6521
  } catch (err) {
6186
6522
  E.toast(err.message || 'That reply could not be started.', {type: 'error'});
@@ -6551,12 +6887,20 @@ return {
6551
6887
  try {
6552
6888
  const chrome = mailHost.helpers.chrome ?? {};
6553
6889
  if (features.send) {
6554
- bannerCompose = Boolean(chrome.addBannerAction?.($container, {
6890
+ // The click is the menu's (below); an admin whose banner hands
6891
+ // back no button keeps the plain click.
6892
+ let menued = false;
6893
+ const composeButton = chrome.addBannerAction?.($container, {
6555
6894
  id: `${pluginName}-compose`,
6556
6895
  icon: 'edit-3',
6557
6896
  title: 'New message',
6558
- onClick: () => startNewMessage()
6559
- }));
6897
+ onClick: () => { if (!menued) startNewMessage(); }
6898
+ });
6899
+ bannerCompose = Boolean(composeButton);
6900
+ if (composeButton?.nodeType === 1) {
6901
+ withPlacementMenu(composeButton, 'Write', placement => startNewMessage(undefined, placement));
6902
+ menued = true;
6903
+ }
6560
6904
  }
6561
6905
  const refreshPlaced = chrome.addBannerAction?.($container, {
6562
6906
  id: `${pluginName}-refresh`,
@@ -6616,9 +6960,10 @@ return {
6616
6960
  *
6617
6961
  * @param {object} [draft] - `{to, cc, bcc, subject, body}`
6618
6962
  */
6619
- async function startNewMessage(draft) {
6963
+ async function startNewMessage(draft, placement) {
6620
6964
  try {
6621
- openCompose(composeOptions(await identitySoon(), {mode: 'new', ...(draft ? {draft} : {})}));
6965
+ openCompose(composeOptions(await identitySoon(), {mode: 'new', ...(draft ? {draft} : {}),
6966
+ ...(placement ? {placement} : {})}));
6622
6967
  } catch (err) {
6623
6968
  E.toast(err.message || 'Compose could not be opened.', {type: 'error'});
6624
6969
  }
@@ -6684,7 +7029,7 @@ return {
6684
7029
  if (compose && bannerCompose) compose.remove();
6685
7030
  else if (compose) {
6686
7031
  compose.hidden = false;
6687
- compose.addEventListener('click', () => startNewMessage());
7032
+ withPlacementMenu(compose, 'Write', placement => startNewMessage(undefined, placement));
6688
7033
  }
6689
7034
  }
6690
7035