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.
- package/CHANGELOG.md +13 -0
- package/docs/DommaFeatures.md +1 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-host.js +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +63 -6
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +75 -41
- package/plugins/_lib/admin/mail/drag-drop.js +1 -1
- package/plugins/_lib/admin/mail/folder-tree.js +1 -1
- package/plugins/_lib/admin/mail/font-controls.js +1 -1
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +1 -1
- package/plugins/_lib/admin/mail/identity.js +1 -1
- package/plugins/_lib/admin/mail/image-senders-section.js +156 -99
- package/plugins/_lib/admin/mail/keyboard.js +1 -1
- package/plugins/_lib/admin/mail/mail.css +1 -1
- package/plugins/_lib/admin/mail/mail.html +1 -1
- package/plugins/_lib/admin/mail/message-actions.js +1 -1
- package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
- package/plugins/_lib/admin/mail/panes.js +1 -1
- package/plugins/_lib/admin/mail/reader-kit.js +12 -4
- package/plugins/_lib/admin/mail/reader-runtime.js +458 -113
- package/plugins/_lib/admin/mail/reader-view.js +1 -1
- package/plugins/_lib/admin/mail/resizable.js +1 -1
- package/plugins/_lib/admin/mail/restore-spam.js +1 -1
- package/plugins/_lib/admin/mail/rules.js +1 -1
- package/plugins/_lib/admin/mail/scheduling.js +1 -1
- package/plugins/_lib/admin/mail/section-kit.js +1 -1
- package/plugins/_lib/admin/mail/security-note.js +1 -1
- package/plugins/_lib/admin/mail/settings-section.js +156 -99
- package/plugins/_lib/admin/mail/templates.js +1 -1
- package/plugins/_lib/admin/mail/threads.js +1 -1
- package/plugins/_lib/admin/mail/vacation.js +45 -1
- package/plugins/_lib/admin/mail/when-closed.js +1 -1
- package/plugins/_lib/admin/ui/dates.js +1 -1
- package/plugins/_lib/admin/ui/resizable.js +1 -1
- package/plugins/_lib/admin/ui/rich-field.js +1 -1
- package/plugins/_lib/domma-mail.lock.json +83 -83
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +31 -3
- package/plugins/_lib/mail/accountRoutes.js +1 -1
- package/plugins/_lib/mail/accounts.js +1 -1
- package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
- package/plugins/_lib/mail/bodyTokens.js +1 -1
- package/plugins/_lib/mail/compose.js +1 -1
- package/plugins/_lib/mail/defaults.js +1 -1
- package/plugins/_lib/mail/envelope.js +1 -1
- package/plugins/_lib/mail/folderActions.js +1 -1
- package/plugins/_lib/mail/folderRuntime.js +1 -1
- package/plugins/_lib/mail/folders.js +1 -1
- package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
- package/plugins/_lib/mail/mbox.js +1 -1
- package/plugins/_lib/mail/message-action.js +1 -1
- package/plugins/_lib/mail/messageSecurity.js +1 -1
- package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
- package/plugins/_lib/mail/networkAddresses.js +1 -1
- package/plugins/_lib/mail/networkPolicy.js +1 -1
- package/plugins/_lib/mail/oauthAccounts.js +1 -1
- package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
- package/plugins/_lib/mail/oauthRuntime.js +1 -1
- package/plugins/_lib/mail/pollSchedule.js +1 -1
- package/plugins/_lib/mail/poller.js +1 -1
- package/plugins/_lib/mail/pollerRuntime.js +1 -1
- package/plugins/_lib/mail/priority.js +1 -1
- package/plugins/_lib/mail/publicMailbox.js +1 -1
- package/plugins/_lib/mail/readRuntime.js +1 -1
- package/plugins/_lib/mail/render.js +1 -1
- package/plugins/_lib/mail/ruleRunner.js +1 -1
- package/plugins/_lib/mail/schedulerRuntime.js +1 -1
- package/plugins/_lib/mail/secretProvider.js +1 -1
- package/plugins/_lib/mail/secretbox.js +1 -1
- package/plugins/_lib/mail/senderAuth.js +1 -1
- package/plugins/_lib/mail/sieve.js +1 -1
- package/plugins/_lib/mail/smtpService.js +1 -1
- package/plugins/_lib/mail/snoozeRuntime.js +1 -1
- package/plugins/_lib/mail/store.js +1 -1
- package/plugins/_lib/mail/subscriptions.js +1 -1
- package/plugins/_lib/mail/syncPlan.js +1 -1
- package/plugins/_lib/mail/syncRuntime.js +1 -1
- package/plugins/_lib/mail/syncSelection.js +1 -1
- package/plugins/_lib/mail/unreadBadge.js +1 -1
- package/plugins/_lib/mail/unsubscribe.js +1 -1
- package/plugins/_lib/mail/vacationRuntime.js +1 -1
- package/plugins/_lib/mail/write.js +1 -1
- package/plugins/_lib/public/rich-text.mjs +1 -1
- package/plugins/_lib/rich-text.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/scheduling.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/section-kit.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/security-note.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* What the reader says about a signed or encrypted (S/MIME) message.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/settings-section.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/** Browser preferences for the shared mail reader. */
|
|
4
4
|
export const READ_DELAY_KEY = 'domma-mail.mark-read-seconds';
|
|
@@ -119,8 +119,40 @@ export function permissionWords(permission) {
|
|
|
119
119
|
return 'This browser cannot show notifications.';
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
const SETTINGS_CSS = `
|
|
123
|
+
.mail-prefs{display:flex;flex-direction:column;gap:1rem}
|
|
124
|
+
.mail-pref-group{border:1px solid var(--dm-border);border-radius:var(--dm-radius-md, 6px);padding:.75rem .9rem;display:flex;flex-direction:column;gap:.55rem}
|
|
125
|
+
.mail-pref-group>h4{margin:0;font-size:.8rem;text-transform:uppercase;letter-spacing:.04em;color:var(--dm-text-muted);display:flex;align-items:center;gap:.35rem}
|
|
126
|
+
.mail-pref-intro{margin:0;font-size:.85rem;color:var(--dm-text-muted)}
|
|
127
|
+
.mail-pref-row{display:flex;flex-direction:column;gap:.2rem}
|
|
128
|
+
.mail-pref-row .form-select,.mail-pref-row .form-input{max-width:22rem}
|
|
129
|
+
.mail-pref-hint{font-size:.75rem;color:var(--dm-text-muted)}
|
|
130
|
+
.mail-pref-check{display:flex;align-items:center;gap:.45rem;font-size:.875rem}
|
|
131
|
+
.mail-pref-tools{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
/** The longer help the engine shows in a slideover (static HTML, written here). */
|
|
135
|
+
const SETTINGS_GUIDE = `
|
|
136
|
+
<p>These preferences are kept in <strong>this browser</strong> only. They apply to every mailbox you open here, and another browser or computer keeps its own.</p>
|
|
137
|
+
<h4>Reading</h4>
|
|
138
|
+
<p><strong>Mark as read after</strong> - how many seconds a message must stay open before it is marked as read. 0 marks it at once; a larger number lets you glance at a message and move on while it stays unread.</p>
|
|
139
|
+
<h4>Writing</h4>
|
|
140
|
+
<ul>
|
|
141
|
+
<li><strong>Default text editor</strong> - rich text (bold, lists, links, pictures - sent with a plain-text copy) or plain text, which every mail program shows the same way.</li>
|
|
142
|
+
<li><strong>Automatically save draft</strong> - saves what you are writing to Drafts every few minutes, so a closed tab or a crash loses little. Discarding the message removes its automatic draft.</li>
|
|
143
|
+
<li><strong>Check spelling as I type</strong> - the browser's own spelling check, in its own language.</li>
|
|
144
|
+
</ul>
|
|
145
|
+
<p>Receipts, signing, encryption and where replies are filed belong to each mailbox, under Composing and Security.</p>
|
|
146
|
+
<h4>Notifications</h4>
|
|
147
|
+
<p>While the admin is open in any tab, new mail can show a popup and play a sound - checked about once a minute. Popups need the browser's permission: it is asked when you save with popups on. If the browser blocks them, allow them in its site settings (the padlock by the address). <strong>Play the sound</strong> and <strong>Show a test notification</strong> let you try both.</p>
|
|
148
|
+
<h4>Email links</h4>
|
|
149
|
+
<p>Makes this browser open <code>mailto:</code> links on any website in a new message here, instead of a mail program on this computer. The browser asks you to confirm; undo it in the browser's settings (in Chrome: Settings > Privacy and security > Site settings > Protocol handlers). Only works on a site served over https.</p>
|
|
150
|
+
`;
|
|
151
|
+
|
|
122
152
|
/**
|
|
123
|
-
* The Settings tab: preferences kept in this browser
|
|
153
|
+
* The Settings tab: preferences kept in this browser, in headed groups (Reading, Writing,
|
|
154
|
+
* Notifications, Email links), built with domma-reactive. One Save checks every value before
|
|
155
|
+
* any is stored.
|
|
124
156
|
*
|
|
125
157
|
* @param {{canWrite: boolean, canSend?: boolean, load: Function, save: Function,
|
|
126
158
|
* sidebarUrl?: string|null, userId?: string|null}} options
|
|
@@ -134,31 +166,125 @@ export function createSettingsSection({canWrite, canSend = false, load, save, si
|
|
|
134
166
|
id: 'settings',
|
|
135
167
|
label: 'Settings',
|
|
136
168
|
help: 'Preferences for reading and writing email in this browser.',
|
|
169
|
+
guide: SETTINGS_GUIDE,
|
|
137
170
|
async render(container, ctx) {
|
|
138
171
|
const kit = await import(new URL(`./section-kit.js?v=${ctx.assetVersion ?? '1'}`, import.meta.url).href);
|
|
172
|
+
const M = host?.M ?? globalThis.M;
|
|
139
173
|
const notify = sidebarUrl ? (host?.helpers.notifications ?? null) : null;
|
|
140
174
|
const who = userId ?? host?.getUser()?.id ?? null;
|
|
141
|
-
|
|
175
|
+
if (!document.getElementById('mail-prefs-css')) {
|
|
176
|
+
const style = document.createElement('style');
|
|
177
|
+
style.id = 'mail-prefs-css';
|
|
178
|
+
style.textContent = SETTINGS_CSS;
|
|
179
|
+
document.head.appendChild(style);
|
|
180
|
+
}
|
|
142
181
|
|
|
143
|
-
const
|
|
182
|
+
const supported = typeof Notification === 'function';
|
|
183
|
+
const prefs = readComposePrefs(S);
|
|
184
|
+
const current = notify ? notify.readNotifyPrefs(who, sidebarUrl) : {popup: false, sound: false};
|
|
185
|
+
const showLinks = Boolean(canSend && host?.helpers.mailCompose?.mailtoHandlerUrl
|
|
186
|
+
&& typeof navigator?.registerProtocolHandler === 'function');
|
|
187
|
+
const mailboxNote = canSend && host?.capabilities?.mailboxComposeSettings !== false;
|
|
144
188
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
189
|
+
const o = (v) => M.observable(v);
|
|
190
|
+
const m = {
|
|
191
|
+
canWrite, canSend, notify: Boolean(notify), supported, showLinks, mailboxNote,
|
|
192
|
+
markRead: o(String(load())),
|
|
193
|
+
editor: o(prefs.editor),
|
|
194
|
+
autosave: o(String(prefs.autosaveMinutes)),
|
|
195
|
+
spellcheck: o(prefs.spellcheck),
|
|
196
|
+
popup: o(current.popup && supported),
|
|
197
|
+
sound: o(current.sound === true),
|
|
198
|
+
permission: o(permissionWords(supported ? Notification.permission : undefined)),
|
|
199
|
+
linkStatus: o(''),
|
|
200
|
+
playSound() { notify?.playChime(); },
|
|
201
|
+
async testPopup() {
|
|
202
|
+
if (Notification.permission === 'default') await Notification.requestPermission();
|
|
203
|
+
m.permission.value = permissionWords(Notification.permission);
|
|
204
|
+
if (Notification.permission === 'granted') {
|
|
205
|
+
new Notification('New mail', {body: 'This is what a new message looks like.', tag: `dm-notify:${sidebarUrl}`});
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
registerLinks() {
|
|
209
|
+
try {
|
|
210
|
+
const mail = host.helpers.mailCompose;
|
|
211
|
+
navigator.registerProtocolHandler('mailto', mail.mailtoHandlerUrl(`${location.origin}${location.pathname}`));
|
|
212
|
+
m.linkStatus.value = 'Asked. If the browser showed a question, answer it to finish.';
|
|
213
|
+
} catch (err) {
|
|
214
|
+
m.linkStatus.value = /secure|https/i.test(err?.message ?? '')
|
|
215
|
+
? 'Only a site served over https can handle mailto: links.'
|
|
216
|
+
: (err?.message || 'This browser would not register it.');
|
|
158
217
|
}
|
|
159
|
-
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const autosaveOptions = AUTOSAVE_CHOICES.map(n => `<option value="${n}">${n === 0 ? 'Never' : `Every ${n} minute${n === 1 ? '' : 's'}`}</option>`).join('');
|
|
221
|
+
|
|
222
|
+
const root = document.createElement('div');
|
|
223
|
+
root.className = 'mail-prefs';
|
|
224
|
+
root.innerHTML = `
|
|
225
|
+
<p class="mail-pref-intro">Saved in this browser and used for all your mailboxes here. Another browser keeps its own.</p>
|
|
226
|
+
|
|
227
|
+
<section class="mail-pref-group" aria-labelledby="mail-pref-reading">
|
|
228
|
+
<h4 id="mail-pref-reading">Reading <span data-help-title="Reading" data-help="How the reader treats a message you open."></span></h4>
|
|
229
|
+
<p class="mail-pref-intro" data-bind-hidden="canWrite">This reader leaves messages unread. Marking messages as read needs an edition that can change them.</p>
|
|
230
|
+
<div class="mail-pref-row" data-bind-hidden="!canWrite">
|
|
231
|
+
<label class="form-label" for="mail-pref-markread">Mark a message as read after (seconds)
|
|
232
|
+
<span data-help-title="Mark as read" data-help="How long a message must stay open before it is marked as read. 0 marks it straight away; a larger number lets you glance at a message and move on with it still unread."></span></label>
|
|
233
|
+
<input id="mail-pref-markread" class="form-input" type="number" min="0" max="2147483" step="1" data-model="markRead.value">
|
|
234
|
+
<span class="mail-pref-hint">0 marks it as read as soon as it opens.</span>
|
|
235
|
+
</div>
|
|
236
|
+
</section>
|
|
237
|
+
|
|
238
|
+
<section class="mail-pref-group" aria-labelledby="mail-pref-writing" data-bind-hidden="!canSend">
|
|
239
|
+
<h4 id="mail-pref-writing">Writing <span data-help-title="Writing" data-help="How a new message, reply or forward starts out in this browser."></span></h4>
|
|
240
|
+
<div class="mail-pref-row">
|
|
241
|
+
<label class="form-label" for="mail-pref-editor">Default text editor
|
|
242
|
+
<span data-help-title="Default text editor" data-help="Rich text has formatting, pictures and links, and is sent with a plain-text copy. Plain text sends text only - what every mail program shows the same way."></span></label>
|
|
243
|
+
<select id="mail-pref-editor" class="form-select" data-model="editor.value">
|
|
244
|
+
<option value="rich">Rich text (formatting, pictures, links)</option>
|
|
245
|
+
<option value="plain">Plain text</option>
|
|
246
|
+
</select>
|
|
247
|
+
</div>
|
|
248
|
+
<div class="mail-pref-row">
|
|
249
|
+
<label class="form-label" for="mail-pref-autosave">Automatically save draft
|
|
250
|
+
<span data-help-title="Automatic drafts" data-help="Saves what you are writing to the Drafts folder every few minutes, so a closed tab or a crash loses little. A message you then discard takes its automatic draft with it."></span></label>
|
|
251
|
+
<select id="mail-pref-autosave" class="form-select" data-model="autosave.value">${autosaveOptions}</select>
|
|
252
|
+
</div>
|
|
253
|
+
<label class="mail-pref-check"><input type="checkbox" data-model="spellcheck.value"> Check spelling as I type
|
|
254
|
+
<span data-help-title="Spelling" data-help="The browser's own spelling check, in the browser's language. Switch it off if it marks names and terms you use a lot."></span></label>
|
|
255
|
+
<p class="mail-pref-hint" data-bind-hidden="!mailboxNote">Receipts, signing, encryption and where replies are filed belong to each mailbox: see Composing and Security.</p>
|
|
256
|
+
</section>
|
|
257
|
+
|
|
258
|
+
<section class="mail-pref-group" aria-labelledby="mail-pref-notify" data-bind-hidden="!notify">
|
|
259
|
+
<h4 id="mail-pref-notify">Notifications <span data-help-title="Notifications" data-help="While the admin is open in any tab, new mail can show a popup and play a sound. Mail is checked about once a minute."></span></h4>
|
|
260
|
+
<label class="mail-pref-check"><input type="checkbox" data-model="popup.value" data-bind-disabled="!supported"> Show a popup for new messages
|
|
261
|
+
<span data-help-title="Popups" data-help="The browser asks for permission when you save with this on. If it blocks them, allow notifications in the browser's site settings (the padlock by the address)."></span></label>
|
|
262
|
+
<label class="mail-pref-check"><input type="checkbox" data-model="sound.value"> Play a sound for new messages</label>
|
|
263
|
+
<div data-ref="folders"></div>
|
|
264
|
+
<p class="mail-pref-hint" data-bind-text="permission.value"></p>
|
|
265
|
+
<div class="mail-pref-tools">
|
|
266
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="playSound">Play the sound</button>
|
|
267
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="testPopup" data-bind-hidden="!supported">Show a test notification</button>
|
|
268
|
+
</div>
|
|
269
|
+
</section>
|
|
270
|
+
|
|
271
|
+
<section class="mail-pref-group" aria-labelledby="mail-pref-links" data-bind-hidden="!showLinks">
|
|
272
|
+
<h4 id="mail-pref-links">Email links <span data-help-title="Email links" data-help="Open mailto: links on any website in a new message here, instead of a mail program on this computer. The browser asks you to confirm. Needs https."></span></h4>
|
|
273
|
+
<p class="mail-pref-intro">To undo it later, use the browser's settings (in Chrome: Settings > Privacy and security > Site settings > Protocol handlers).</p>
|
|
274
|
+
<div class="mail-pref-tools">
|
|
275
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="registerLinks">Register as the mailto: links handler</button>
|
|
276
|
+
<span class="text-sm text-muted" data-bind-text="linkStatus.value"></span>
|
|
277
|
+
</div>
|
|
278
|
+
</section>`;
|
|
279
|
+
container.appendChild(root);
|
|
280
|
+
const bindings = M.applyBindings(m, root);
|
|
281
|
+
// The (?) markers are wired by the settings shell once the section is drawn.
|
|
282
|
+
ctx.onClose?.(() => { try { bindings?.dispose?.(); } catch { /* gone */ } });
|
|
283
|
+
|
|
284
|
+
const saveSteps = [];
|
|
285
|
+
if (canWrite) {
|
|
160
286
|
saveSteps.push(() => {
|
|
161
|
-
const value =
|
|
287
|
+
const value = m.markRead.peek();
|
|
162
288
|
const seconds = Number(value);
|
|
163
289
|
if (value === '' || value === null || value === undefined || !Number.isFinite(seconds) || seconds < 0 || seconds > 2147483) {
|
|
164
290
|
throw new Error('Enter a number of seconds between 0 and 2147483.');
|
|
@@ -166,108 +292,39 @@ export function createSettingsSection({canWrite, canSend = false, load, save, si
|
|
|
166
292
|
return () => save(seconds);
|
|
167
293
|
});
|
|
168
294
|
}
|
|
169
|
-
|
|
170
|
-
// ---- Composing -----------------------------------------------
|
|
171
295
|
if (canSend) {
|
|
172
|
-
kit.heading(container, 'Composing');
|
|
173
|
-
const prefs = readComposePrefs(S);
|
|
174
|
-
const {state} = kit.formIn(container, {
|
|
175
|
-
editor: {
|
|
176
|
-
type: 'select', label: 'Default text editor', required: true,
|
|
177
|
-
options: [
|
|
178
|
-
{value: 'rich', label: 'Rich text (formatting, pictures, links)'},
|
|
179
|
-
{value: 'plain', label: 'Plain text'}
|
|
180
|
-
],
|
|
181
|
-
formConfig: {hint: 'What a new message, reply or forward opens in. Plain text sends text only - what every mail program shows the same way.'}
|
|
182
|
-
},
|
|
183
|
-
autosave: {
|
|
184
|
-
type: 'select', label: 'Automatically save draft', required: true,
|
|
185
|
-
// Strings: Forma reads a 0 as "no value" and shows its
|
|
186
|
-
// "-- Select --" placeholder instead of Never.
|
|
187
|
-
options: AUTOSAVE_CHOICES.map(n => ({
|
|
188
|
-
value: String(n), label: n === 0 ? 'Never' : `Every ${n} minute${n === 1 ? '' : 's'}`
|
|
189
|
-
})),
|
|
190
|
-
formConfig: {hint: 'Saved to the Drafts folder while you write, so a closed tab or a crash loses little. A message you then discard takes its automatic draft with it.'}
|
|
191
|
-
},
|
|
192
|
-
spellcheck: {type: 'boolean', label: 'Check spelling as I type'}
|
|
193
|
-
}, {editor: prefs.editor, autosave: String(prefs.autosaveMinutes), spellcheck: prefs.spellcheck});
|
|
194
296
|
saveSteps.push(() => () => {
|
|
195
|
-
S.set(EDITOR_KEY, composeEditor(
|
|
196
|
-
S.set(AUTOSAVE_KEY, autosaveMinutes(
|
|
197
|
-
S.set(SPELLCHECK_KEY,
|
|
297
|
+
S.set(EDITOR_KEY, composeEditor(m.editor.peek()));
|
|
298
|
+
S.set(AUTOSAVE_KEY, autosaveMinutes(m.autosave.peek()));
|
|
299
|
+
S.set(SPELLCHECK_KEY, m.spellcheck.peek() !== false);
|
|
198
300
|
});
|
|
199
|
-
if (host?.capabilities?.mailboxComposeSettings !== false) {
|
|
200
|
-
kit.note(container, 'Receipts, signing, encryption and where replies are filed belong to each mailbox: see the Composing and Security tabs.');
|
|
201
|
-
}
|
|
202
301
|
}
|
|
203
|
-
|
|
204
|
-
// ---- Notifications -------------------------------------------
|
|
205
302
|
if (notify) {
|
|
206
|
-
|
|
207
|
-
kit.note(container, 'While the admin is open in any tab, new mail can pop up a notification and play a sound - checked about once a minute.');
|
|
208
|
-
const current = notify.readNotifyPrefs(who, sidebarUrl);
|
|
209
|
-
const supported = typeof Notification === 'function';
|
|
210
|
-
const {state} = kit.formIn(container, {
|
|
211
|
-
popup: {type: 'boolean', label: 'Show new messages notification popups', formConfig: {disabled: !supported}},
|
|
212
|
-
sound: {type: 'boolean', label: 'Sound notification'}
|
|
213
|
-
}, {popup: current.popup && supported, sound: current.sound});
|
|
303
|
+
// The edition's own part (which folders notify), drawn into its slot.
|
|
214
304
|
if (renderNotificationSettings && ctx.account) {
|
|
215
305
|
try {
|
|
216
|
-
const saveFolders = await renderNotificationSettings(
|
|
306
|
+
const saveFolders = await renderNotificationSettings(root.querySelector('[data-ref="folders"]'), ctx, kit);
|
|
217
307
|
if (saveFolders) saveSteps.push(() => saveFolders);
|
|
218
308
|
} catch (err) {
|
|
219
|
-
|
|
309
|
+
root.querySelector('[data-ref="folders"]').textContent = `Notification folders could not be loaded: ${err.message || 'Try reopening Settings.'}`;
|
|
220
310
|
}
|
|
221
311
|
}
|
|
222
|
-
const status = kit.note(container, permissionWords(supported ? Notification.permission : undefined));
|
|
223
|
-
const tools = kit.box(container, 'flex gap-2 items-center mb-2');
|
|
224
|
-
kit.button(tools, 'Play the sound', () => notify.playChime(), {icon: 'play'});
|
|
225
|
-
if (supported) {
|
|
226
|
-
kit.button(tools, 'Show a test notification', async () => {
|
|
227
|
-
if (Notification.permission === 'default') await Notification.requestPermission();
|
|
228
|
-
status.textContent = permissionWords(Notification.permission);
|
|
229
|
-
if (Notification.permission === 'granted') {
|
|
230
|
-
new Notification('New mail', {body: 'This is what a new message looks like.', tag: `dm-notify:${sidebarUrl}`});
|
|
231
|
-
}
|
|
232
|
-
}, {icon: 'bell'});
|
|
233
|
-
}
|
|
234
312
|
saveSteps.push(() => async () => {
|
|
235
|
-
let popup =
|
|
236
|
-
// Asked here, on the Save click: browsers only let a page
|
|
237
|
-
// ask in answer to something the person did.
|
|
313
|
+
let popup = m.popup.peek() === true && supported;
|
|
314
|
+
// Asked here, on the Save click: browsers only let a page ask in answer to something the person did.
|
|
238
315
|
if (popup && Notification.permission === 'default') {
|
|
239
316
|
await Notification.requestPermission();
|
|
240
|
-
|
|
317
|
+
m.permission.value = permissionWords(Notification.permission);
|
|
241
318
|
}
|
|
242
319
|
if (popup && Notification.permission === 'denied') popup = false;
|
|
243
|
-
notify.writeNotifyPrefs(who, sidebarUrl, {popup, sound:
|
|
320
|
+
notify.writeNotifyPrefs(who, sidebarUrl, {popup, sound: m.sound.peek() === true});
|
|
244
321
|
});
|
|
245
322
|
}
|
|
246
323
|
|
|
247
|
-
// ---- Email links ---------------------------------------------
|
|
248
|
-
if (canSend && host?.helpers.mailCompose?.mailtoHandlerUrl && typeof navigator?.registerProtocolHandler === 'function') {
|
|
249
|
-
kit.heading(container, 'Email links');
|
|
250
|
-
kit.note(container, 'Make this browser open mailto: links - on any website - in a new message here, instead of in a mail program on this computer. The browser asks you to confirm. To undo it, use the browser\u2019s settings (in Chrome: Settings > Privacy and security > Site settings > Protocol handlers).');
|
|
251
|
-
const linkRow = kit.box(container, 'flex gap-2 items-center mb-2');
|
|
252
|
-
const linkStatus = kit.box(linkRow, 'flex-1 text-sm mail-status text-muted', 'span');
|
|
253
|
-
kit.button(linkRow, 'Register as the mailto: links handler', async () => {
|
|
254
|
-
try {
|
|
255
|
-
const mail = host.helpers.mailCompose;
|
|
256
|
-
navigator.registerProtocolHandler('mailto', mail.mailtoHandlerUrl(`${location.origin}${location.pathname}`));
|
|
257
|
-
linkStatus.textContent = 'Asked. If the browser showed a question, answer it to finish.';
|
|
258
|
-
} catch (err) {
|
|
259
|
-
linkStatus.textContent = /secure|https/i.test(err?.message ?? '')
|
|
260
|
-
? 'Only a site served over https can handle mailto: links.'
|
|
261
|
-
: (err?.message || 'This browser would not register it.');
|
|
262
|
-
}
|
|
263
|
-
}, {icon: 'mail'});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
324
|
if (!saveSteps.length) return;
|
|
267
325
|
const bar = kit.actionBar(container);
|
|
268
326
|
kit.button(bar.row, 'Save', async () => {
|
|
269
|
-
// Every value checked before anything is stored: a bad number
|
|
270
|
-
// must not leave half the tab saved.
|
|
327
|
+
// Every value checked before anything is stored: a bad number must not leave half the tab saved.
|
|
271
328
|
let apply;
|
|
272
329
|
try {
|
|
273
330
|
apply = saveSteps.map(step => step());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/templates.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.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/threads.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Grouping messages into conversations.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/vacation.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* The automatic reply, and everything that must stop it.
|
|
@@ -97,6 +97,50 @@ export function normaliseVacation(account) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/** How many saved away messages a mailbox may keep. */
|
|
101
|
+
export const MAX_AWAY_MESSAGES = 20;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The saved away messages, in shape: each one a whole away message (no `enabled` - at
|
|
105
|
+
* most one is on, and that one is ALSO the account's `vacation`, which the runner reads).
|
|
106
|
+
*
|
|
107
|
+
* A mailbox from before saved messages has none stored: its current away message, if it
|
|
108
|
+
* has one written, becomes the first, so nothing someone wrote is lost.
|
|
109
|
+
*
|
|
110
|
+
* @param {object|null|undefined} account
|
|
111
|
+
* @returns {{id: string, name: string, subject: string, bodyHtml: string, bodyText: string,
|
|
112
|
+
* from: string|null, to: string|null, intervalDays: number, knownSendersOnly: boolean}[]}
|
|
113
|
+
*/
|
|
114
|
+
export function normaliseAwayMessages(account) {
|
|
115
|
+
const stored = Array.isArray(account?.awayMessages) ? account.awayMessages : null;
|
|
116
|
+
const source = stored ?? (() => {
|
|
117
|
+
const current = normaliseVacation(account);
|
|
118
|
+
return current.bodyHtml || current.bodyText || current.enabled ? [{...current, id: 'm1'}] : [];
|
|
119
|
+
})();
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
return source.slice(0, MAX_AWAY_MESSAGES).map((entry, index) => {
|
|
122
|
+
const {enabled: _on, ...message} = normaliseVacation({vacation: entry});
|
|
123
|
+
let id = /^[\w-]{1,40}$/.test(String(entry?.id ?? '')) ? String(entry.id) : `m${index + 1}`;
|
|
124
|
+
while (seen.has(id)) id = `${id}x`;
|
|
125
|
+
seen.add(id);
|
|
126
|
+
return {id, name: headerSafe(entry?.name).slice(0, 80) || message.subject, ...message};
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Which saved message is switched on: the one the account names, while the away message
|
|
132
|
+
* is on at all. A mailbox from before saved messages, switched on, has its first.
|
|
133
|
+
*
|
|
134
|
+
* @param {object|null|undefined} account
|
|
135
|
+
* @param {object[]} [messages]
|
|
136
|
+
* @returns {string|null}
|
|
137
|
+
*/
|
|
138
|
+
export function activeAwayId(account, messages = normaliseAwayMessages(account)) {
|
|
139
|
+
if (!normaliseVacation(account).enabled) return null;
|
|
140
|
+
if (account?.awayActiveId) return messages.some(m => m.id === account.awayActiveId) ? account.awayActiveId : null;
|
|
141
|
+
return Array.isArray(account?.awayMessages) ? null : (messages[0]?.id ?? null);
|
|
142
|
+
}
|
|
143
|
+
|
|
100
144
|
/**
|
|
101
145
|
* Is the away message switched on and inside its window?
|
|
102
146
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/mail/when-closed.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Run code when a Domma modal or slideover actually closes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/ui/dates.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Dates as a plugin shows them to a person: dd/mm/yyyy, and dd/mm/yyyy HH:mm
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.33.0, packages/core/src/admin/ui/rich-field.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* A Description field as a rich text editor, and a description shown in the admin.
|