domma-cms 1.78.0 → 1.79.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 +6 -0
- package/admin/js/templates/docs/usage-site-settings.html +29 -1
- package/docs/DommaFeatures.md +62 -54
- package/docs/plans/2026-11-19-brand-kit-design.md +58 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/attach-arrange.js +176 -0
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-attach.js +268 -0
- package/plugins/_lib/admin/mail/cms-host.js +10 -3
- package/plugins/_lib/admin/mail/compose-window.js +37 -1
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
- 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 +1 -1
- package/plugins/_lib/admin/mail/keyboard.js +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 +1 -1
- package/plugins/_lib/admin/mail/reader-runtime.js +1 -1
- 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 +1 -1
- 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 +1 -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 +85 -83
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +1 -1
- package/plugins/_lib/mail/accountRoutes.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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/cms-attach.js.
|
|
2
|
+
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
|
+
/**
|
|
4
|
+
* Attachments from the CMS: Media and the File Store. CMS shell boundary - only cms-host.js imports this, and
|
|
5
|
+
* standalone Domma Mail never does.
|
|
6
|
+
*
|
|
7
|
+
* One chooser, two places to look. Each "provider" only knows how to list a place and how to fetch a file's bytes,
|
|
8
|
+
* through the admin APIs those Tools already have, as the signed-in person: a file they may not open is not
|
|
9
|
+
* listed, and the server checks again when its bytes are asked for. Nothing here is told to the compose window but
|
|
10
|
+
* the files chosen. Names come from other people's uploads, so they reach the screen as text, never as markup.
|
|
11
|
+
*
|
|
12
|
+
* @module _lib/admin/mail/cms-attach
|
|
13
|
+
*/
|
|
14
|
+
const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
|
|
15
|
+
const {choiceSummary, formatSize, mediaCrumbs, mediaEntries, mediaPath, mediaView, storeView} =
|
|
16
|
+
await import(new URL(`./attach-arrange.js?v=${version}`, import.meta.url).href);
|
|
17
|
+
|
|
18
|
+
const STORE = '/api/plugins/file-store';
|
|
19
|
+
|
|
20
|
+
function el(tag, attrs = {}, ...kids) {
|
|
21
|
+
const node = document.createElement(tag);
|
|
22
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
23
|
+
if (v == null || v === false) continue;
|
|
24
|
+
if (k === 'class') node.className = v;
|
|
25
|
+
else if (k === 'text') node.textContent = v;
|
|
26
|
+
else if (k.startsWith('on')) node.addEventListener(k.slice(2), v);
|
|
27
|
+
else if (k in node) node[k] = v;
|
|
28
|
+
else node.setAttribute(k, v === true ? '' : v);
|
|
29
|
+
}
|
|
30
|
+
node.append(...kids.flat().filter(x => x != null && x !== false));
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function asBase64(blob) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const reader = new FileReader();
|
|
37
|
+
reader.onload = () => resolve(String(reader.result).split(',')[1] ?? '');
|
|
38
|
+
reader.onerror = () => reject(new Error('A file could not be read.'));
|
|
39
|
+
reader.readAsDataURL(blob);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Can this person use a source? true, false (the Tool is off or not theirs: 403, 404), or null when the question
|
|
45
|
+
* could not be answered (the network), so that it is asked again next time rather than remembered as a no.
|
|
46
|
+
*/
|
|
47
|
+
async function probe(host, url) {
|
|
48
|
+
try { await host.api(url); return true; }
|
|
49
|
+
catch (err) { return err?.status === 403 || err?.status === 404 ? false : null; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Media: Media Pro's library when it is there (folders), the built-in list when it is not. */
|
|
53
|
+
function mediaProvider(host) {
|
|
54
|
+
let library = null;
|
|
55
|
+
return {
|
|
56
|
+
id: 'media', label: 'From Media', title: 'Attach from Media', places: [{id: 'media', name: 'Media'}],
|
|
57
|
+
available: () => probe(host, '/api/media/_count'),
|
|
58
|
+
/** Media is read afresh each time the chooser opens: files come and go between visits. */
|
|
59
|
+
reset() { library = null; },
|
|
60
|
+
async browse({folder, query}) {
|
|
61
|
+
if (!library) {
|
|
62
|
+
let payload;
|
|
63
|
+
try { payload = await host.api('/api/plugins/media-pro/library'); } catch { payload = await host.api('/api/media'); }
|
|
64
|
+
library = mediaEntries(payload, location.origin);
|
|
65
|
+
}
|
|
66
|
+
return {...mediaView(library, {folder, query}), crumbs: query ? [{id: '', name: 'Media'}] : mediaCrumbs(folder)};
|
|
67
|
+
},
|
|
68
|
+
async bytes(file, signal) {
|
|
69
|
+
const path = mediaPath(file.url, location.origin);
|
|
70
|
+
if (!path) throw new Error(`${file.name} is not in Media.`);
|
|
71
|
+
const res = await host.fetch(path, {credentials: 'same-origin', redirect: 'error', signal});
|
|
72
|
+
if (!res.ok) throw new Error(`${file.name} could not be fetched (${res.status}).`);
|
|
73
|
+
return res.blob();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The File Store: the person's own files and folders, and what has been shared with them. */
|
|
79
|
+
function storeProvider(host) {
|
|
80
|
+
return {
|
|
81
|
+
id: 'file-store', label: 'From File Store', title: 'Attach from the File Store',
|
|
82
|
+
places: [{id: 'mine', name: 'My files'}, {id: 'shared', name: 'Shared with me'}],
|
|
83
|
+
available: () => probe(host, `${STORE}/status`),
|
|
84
|
+
async browse({place, folder, query}) {
|
|
85
|
+
const params = new URLSearchParams({place});
|
|
86
|
+
if (folder && place === 'mine') params.set('folder', folder);
|
|
87
|
+
if (query) params.set('q', query);
|
|
88
|
+
return storeView(await host.api(`${STORE}/files?${params}`), {place});
|
|
89
|
+
},
|
|
90
|
+
async bytes(file, signal) {
|
|
91
|
+
const res = await host.fetch(`${STORE}/files/${encodeURIComponent(file.fileId)}/download`, {headers: host.authHeaders(), redirect: 'error', signal});
|
|
92
|
+
if (!res.ok) throw new Error(`${file.name} could not be fetched (${res.status}).`);
|
|
93
|
+
return res.blob();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const STYLE = `
|
|
99
|
+
.mail-pick { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; height: 100%; min-height: 0; }
|
|
100
|
+
.mail-pick-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
|
|
101
|
+
.mail-pick-bar .form-input { flex: 1 1 12rem; }
|
|
102
|
+
.mail-pick-places { display: inline-flex; gap: .25rem; }
|
|
103
|
+
.mail-pick-crumbs { display: flex; flex-wrap: wrap; gap: .15rem; align-items: center; font-size: var(--dm-text-sm, .875rem); }
|
|
104
|
+
.mail-pick-crumb { background: none; border: 0; padding: .1rem .3rem; color: var(--dm-primary); cursor: pointer; font: inherit; border-radius: var(--dm-radius-sm, .25rem); }
|
|
105
|
+
.mail-pick-crumb[aria-current="true"] { color: inherit; font-weight: 600; cursor: default; }
|
|
106
|
+
.mail-pick-list { flex: 1; min-height: 8rem; overflow-y: auto; border: 1px solid var(--dm-border); border-radius: var(--dm-radius-md, .5rem); }
|
|
107
|
+
.mail-pick-row { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .7rem; border: 0; border-bottom: 1px solid var(--dm-border); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
108
|
+
.mail-pick-row:last-child { border-bottom: 0; }
|
|
109
|
+
.mail-pick-row:hover { background: var(--dm-surface-raised, rgba(127,127,127,.1)); }
|
|
110
|
+
.mail-pick-row:focus-visible, .mail-pick-crumb:focus-visible { outline: 2px solid var(--dm-primary); outline-offset: -2px; }
|
|
111
|
+
.mail-pick-tick { flex: none; width: 1.1rem; height: 1.1rem; border: 1.5px solid var(--dm-border); border-radius: var(--dm-radius-sm, .25rem); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; line-height: 1; }
|
|
112
|
+
.mail-pick-row[aria-checked="true"] .mail-pick-tick { background: var(--dm-primary); border-color: var(--dm-primary); color: var(--dm-primary-text, #fff); }
|
|
113
|
+
.mail-pick-list:focus-visible { outline: 2px solid var(--dm-primary); outline-offset: -2px; }
|
|
114
|
+
.mail-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
115
|
+
.mail-pick-meta { flex: none; font-size: var(--dm-text-xs, .75rem); color: var(--dm-text-muted); white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
|
|
116
|
+
.mail-pick-note { padding: 1rem; margin: 0; color: var(--dm-text-muted); font-size: var(--dm-text-sm, .875rem); }
|
|
117
|
+
.mail-pick-foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
|
|
118
|
+
.mail-pick-sum { flex: 1; font-size: var(--dm-text-sm, .875rem); color: var(--dm-text-muted); }
|
|
119
|
+
.mail-pick-sum[data-over="true"] { color: var(--dm-danger); }
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The chooser: a slideover over the compose window. Resolves with the attachments chosen (possibly none).
|
|
124
|
+
*
|
|
125
|
+
* @param {object} host - the mail host
|
|
126
|
+
* @param {object} provider
|
|
127
|
+
* @param {{remainingBytes?: number}} opts
|
|
128
|
+
* @returns {Promise<Array<{filename, contentType, content}>>}
|
|
129
|
+
*/
|
|
130
|
+
function choose(host, provider, {remainingBytes = Infinity} = {}) {
|
|
131
|
+
const {E} = host;
|
|
132
|
+
return new Promise((resolve) => {
|
|
133
|
+
let settled = false;
|
|
134
|
+
const done = (list) => { if (!settled) { settled = true; resolve(list); } };
|
|
135
|
+
const so = E.slideover({title: provider.title, size: 'md', position: 'right'});
|
|
136
|
+
const chosen = new Map(); // id -> record, kept as the person moves between folders
|
|
137
|
+
let place = provider.places[0].id;
|
|
138
|
+
let folder = '';
|
|
139
|
+
let query = '';
|
|
140
|
+
let visit = 0; // a slow answer for a place already left is dropped
|
|
141
|
+
let fetching = false;
|
|
142
|
+
let closedByUs = false;
|
|
143
|
+
const stop = new AbortController(); // closing the chooser stops a download in hand
|
|
144
|
+
provider.reset?.();
|
|
145
|
+
|
|
146
|
+
const search = el('input', {type: 'search', class: 'form-input', placeholder: 'Search by name', 'aria-label': 'Search by name'});
|
|
147
|
+
const places = el('div', {class: 'mail-pick-places', role: 'group', 'aria-label': 'Where to look'});
|
|
148
|
+
const crumbs = el('nav', {class: 'mail-pick-crumbs', 'aria-label': 'Folder'});
|
|
149
|
+
const list = el('div', {class: 'mail-pick-list', tabIndex: -1});
|
|
150
|
+
const sum = el('span', {class: 'mail-pick-sum', 'aria-live': 'polite'});
|
|
151
|
+
const attach = el('button', {type: 'button', class: 'btn btn-primary btn-sm', text: 'Attach', disabled: true});
|
|
152
|
+
const cancel = el('button', {type: 'button', class: 'btn btn-ghost btn-sm', text: 'Cancel', onclick: () => so.close()});
|
|
153
|
+
const panel = el('div', {class: 'mail-pick'},
|
|
154
|
+
el('div', {class: 'mail-pick-bar'}, provider.places.length > 1 ? places : null, search), crumbs, list,
|
|
155
|
+
el('div', {class: 'mail-pick-foot'}, sum, cancel, attach));
|
|
156
|
+
|
|
157
|
+
const drawSum = () => {
|
|
158
|
+
const s = choiceSummary([...chosen.values()], remainingBytes);
|
|
159
|
+
sum.textContent = fetching ? sum.textContent : s.text;
|
|
160
|
+
sum.dataset.over = String(s.over);
|
|
161
|
+
attach.disabled = fetching || !s.ok;
|
|
162
|
+
attach.textContent = chosen.size > 1 ? `Attach ${chosen.size} files` : 'Attach';
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Made once and only re-marked, so the button just pressed keeps the focus.
|
|
166
|
+
const placeButtons = provider.places.map(p => el('button', {type: 'button', class: 'btn btn-sm btn-ghost', text: p.name, 'data-place': p.id,
|
|
167
|
+
onclick: () => { if (p.id !== place && !fetching) { place = p.id; folder = ''; load(); } }}));
|
|
168
|
+
places.replaceChildren(...placeButtons);
|
|
169
|
+
const drawPlaces = () => {
|
|
170
|
+
for (const b of placeButtons) {
|
|
171
|
+
const on = b.dataset.place === place;
|
|
172
|
+
b.classList.toggle('btn-primary', on); b.classList.toggle('btn-ghost', !on);
|
|
173
|
+
b.setAttribute('aria-pressed', String(on));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
async function load({focus = false} = {}) {
|
|
178
|
+
const mine = ++visit;
|
|
179
|
+
drawPlaces();
|
|
180
|
+
list.replaceChildren(el('p', {class: 'mail-pick-note', text: 'Loading…'}));
|
|
181
|
+
let view;
|
|
182
|
+
try { view = await provider.browse({place, folder, query}); }
|
|
183
|
+
catch (err) { if (mine === visit) list.replaceChildren(el('p', {class: 'mail-pick-note', text: `That could not be listed: ${err?.message || 'the request failed'}.`})); return; }
|
|
184
|
+
if (mine !== visit || settled) return;
|
|
185
|
+
crumbs.replaceChildren(...view.crumbs.flatMap((c, i) => [i ? el('span', {text: '›', 'aria-hidden': 'true'}) : null,
|
|
186
|
+
el('button', {type: 'button', class: 'mail-pick-crumb', text: c.name, 'aria-current': String(i === view.crumbs.length - 1 && !query),
|
|
187
|
+
onclick: () => { if ((folder !== c.id || query) && !fetching) { folder = c.id; query = ''; search.value = ''; load({focus: true}); } }})]));
|
|
188
|
+
const rows = [
|
|
189
|
+
...view.folders.map(f => el('button', {type: 'button', class: 'mail-pick-row', onclick: () => { if (fetching) return; folder = f.id; query = ''; search.value = ''; load({focus: true}); }},
|
|
190
|
+
el('span', {'aria-hidden': 'true', text: '📁'}), el('span', {class: 'mail-pick-name', text: f.name}), el('span', {class: 'mail-pick-meta', text: 'Folder'}))),
|
|
191
|
+
...view.files.map(f => {
|
|
192
|
+
const box = el('span', {class: 'mail-pick-tick', 'aria-hidden': 'true', text: chosen.has(f.id) ? '✓' : ''});
|
|
193
|
+
const row = el('button', {type: 'button', class: 'mail-pick-row', role: 'checkbox', 'aria-checked': String(chosen.has(f.id)), onclick: () => {
|
|
194
|
+
// What is being fetched is what was ticked when Attach was pressed.
|
|
195
|
+
if (fetching) return;
|
|
196
|
+
if (chosen.has(f.id)) chosen.delete(f.id); else chosen.set(f.id, f);
|
|
197
|
+
box.textContent = chosen.has(f.id) ? '✓' : ''; row.setAttribute('aria-checked', String(chosen.has(f.id)));
|
|
198
|
+
drawSum();
|
|
199
|
+
}}, box, el('span', {class: 'mail-pick-name', text: f.name, title: f.name}), el('span', {class: 'mail-pick-meta', text: [f.where, formatSize(f.size)].filter(Boolean).join(' · ')}));
|
|
200
|
+
return row;
|
|
201
|
+
})
|
|
202
|
+
];
|
|
203
|
+
list.replaceChildren(...(rows.length ? rows : [el('p', {class: 'mail-pick-note', text: query ? 'Nothing here has that in its name.' : 'There is nothing here.'})]));
|
|
204
|
+
// After going into a folder or back up, the keyboard is at the top of what is now showing.
|
|
205
|
+
if (focus) (rows[0] || list).focus();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let typing = 0;
|
|
209
|
+
search.addEventListener('input', () => { clearTimeout(typing); typing = setTimeout(() => { query = search.value.trim(); load(); }, 250); });
|
|
210
|
+
|
|
211
|
+
attach.addEventListener('click', async () => {
|
|
212
|
+
if (fetching) return;
|
|
213
|
+
fetching = true; drawSum();
|
|
214
|
+
const out = [];
|
|
215
|
+
const files = [...chosen.values()];
|
|
216
|
+
try {
|
|
217
|
+
let total = 0;
|
|
218
|
+
for (const [i, f] of files.entries()) {
|
|
219
|
+
sum.textContent = `Fetching ${i + 1} of ${files.length}: ${f.name}`;
|
|
220
|
+
const blob = await provider.bytes(f, stop.signal);
|
|
221
|
+
if (settled) return;
|
|
222
|
+
// The list's sizes were a promise; this is the file. Checked before it is turned into text, which doubles it.
|
|
223
|
+
total += blob.size;
|
|
224
|
+
if (total > remainingBytes) throw new Error(`${f.name} is ${formatSize(blob.size)}: with it, these are more than this message has room for.`);
|
|
225
|
+
out.push({filename: f.name, contentType: blob.type || 'application/octet-stream', content: await asBase64(blob)});
|
|
226
|
+
}
|
|
227
|
+
if (settled) return;
|
|
228
|
+
done(out);
|
|
229
|
+
closedByUs = true;
|
|
230
|
+
so.close();
|
|
231
|
+
} catch (err) {
|
|
232
|
+
if (settled) return; // closed part way: nothing to say
|
|
233
|
+
fetching = false; drawSum();
|
|
234
|
+
E.toast(err?.message || 'A file could not be fetched.', {type: 'error'});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const style = el('style', {text: STYLE});
|
|
239
|
+
so.element.append(panel, style);
|
|
240
|
+
const closed = () => { clearTimeout(typing); visit++; done([]); if (!closedByUs) stop.abort(); };
|
|
241
|
+
// The CMS's onceClosed takes the panel away itself; without it, this does.
|
|
242
|
+
if (typeof host.helpers?.onceClosed === 'function') host.helpers.onceClosed(so, closed);
|
|
243
|
+
else so.element.addEventListener('dm:slideover:close', () => { closed(); setTimeout(() => { try { so.destroy?.(); so.element?.remove(); } catch { /* gone */ } }, 400); }, {once: true});
|
|
244
|
+
so.open();
|
|
245
|
+
drawSum();
|
|
246
|
+
load();
|
|
247
|
+
setTimeout(() => search.focus(), 60);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The attachment sources the CMS offers the compose window: those the signed-in person can use, found out once.
|
|
253
|
+
*
|
|
254
|
+
* @param {object} host - the mail host (api, fetch, authHeaders, E, helpers)
|
|
255
|
+
* @returns {() => Promise<Array<{id, label, title, pick}>>}
|
|
256
|
+
*/
|
|
257
|
+
export function createCmsAttachmentSources(host) {
|
|
258
|
+
const providers = [mediaProvider(host), storeProvider(host)];
|
|
259
|
+
let found = null;
|
|
260
|
+
return async () => {
|
|
261
|
+
if (found) return found;
|
|
262
|
+
const answers = await Promise.all(providers.map(p => p.available()));
|
|
263
|
+
const list = providers.filter((p, i) => answers[i] === true).map(p => ({id: p.id, label: p.label, title: p.title, pick: (opts) => choose(host, p, opts)}));
|
|
264
|
+
// Remembered only when every source gave a real answer: a network blip must not hide one for the session.
|
|
265
|
+
if (!answers.includes(null)) found = list;
|
|
266
|
+
return list;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/cms-host.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/** The CMS shell boundary. Standalone never imports this adapter. */
|
|
4
4
|
const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
|
|
@@ -14,9 +14,16 @@ const [toolKit, help, loading, chrome, mailCompose, notifications, smoothCaret]
|
|
|
14
14
|
import('/admin/js/lib/smooth-caret.js').catch(() => ({}))
|
|
15
15
|
]);
|
|
16
16
|
|
|
17
|
+
const {createCmsAttachmentSources} = await import(new URL(`./cms-attach.js?v=${version}`, import.meta.url).href);
|
|
18
|
+
|
|
17
19
|
export function createCmsMailHost({pluginName}) {
|
|
18
|
-
|
|
20
|
+
// The compose window asks for these when it opens; they need the finished host to make their requests.
|
|
21
|
+
let sources = async () => [];
|
|
22
|
+
const host = createMailHost({
|
|
19
23
|
pluginName, framework: globalThis.Domma, storage: globalThis.S,
|
|
20
|
-
helpers: {...toolKit, ...help, loading, chrome, mailCompose, notifications, ...smoothCaret}
|
|
24
|
+
helpers: {...toolKit, ...help, loading, chrome, mailCompose, notifications, ...smoothCaret},
|
|
25
|
+
attachmentSources: () => sources()
|
|
21
26
|
});
|
|
27
|
+
sources = createCmsAttachmentSources(host);
|
|
28
|
+
return host;
|
|
22
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/compose-window.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
|
|
4
4
|
const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
|
|
@@ -11,6 +11,7 @@ const {makeResizable} = await import(new URL(`./resizable.js?v=${MAIL_MODULE_VER
|
|
|
11
11
|
const {whenClosed} = await import(new URL(`./when-closed.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
|
|
12
12
|
const {esc} = await import(new URL(`./reader-kit.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
|
|
13
13
|
const {installFontControls} = await import(new URL(`./font-controls.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
|
|
14
|
+
const {cleanPicked, cleanSources} = await import(new URL(`./attach-arrange.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
|
|
14
15
|
const {
|
|
15
16
|
collectGroups,
|
|
16
17
|
currentFragment,
|
|
@@ -310,6 +311,7 @@ export function createComposeWindow(mailHost) {
|
|
|
310
311
|
</div>
|
|
311
312
|
<div class="flex items-center gap-2 flex-wrap">
|
|
312
313
|
<button type="button" class="btn btn-sm btn-ghost" data-on-click="pickFiles">Attach files</button>
|
|
314
|
+
<span class="mail-attach-sources flex items-center gap-2 flex-wrap" data-ref="sources"></span>
|
|
313
315
|
<span data-bind-class="attachTone.value" data-bind-text="attachSummary.value"></span>
|
|
314
316
|
<span data-help-title="Attachments" data-help="The running total is shown as you add files, and turns red over this mailbox's limit - a message that large cannot be sent. Right-click a file (or use its ⋮, or Shift+F10) to remove it."></span>
|
|
315
317
|
</div>
|
|
@@ -384,6 +386,7 @@ export function createComposeWindow(mailHost) {
|
|
|
384
386
|
const picker = ref('template');
|
|
385
387
|
const editorHost = ref('editor');
|
|
386
388
|
const fileInput = ref('files');
|
|
389
|
+
const sourcesBox = ref('sources');
|
|
387
390
|
|
|
388
391
|
// ---- View state ------------------------------------------------------
|
|
389
392
|
|
|
@@ -660,6 +663,39 @@ export function createComposeWindow(mailHost) {
|
|
|
660
663
|
if (added.length) attachments.value = [...attachments.peek(), ...added];
|
|
661
664
|
});
|
|
662
665
|
|
|
666
|
+
// Other places to attach from, when the host offers any (in the CMS: Media and the File Store). Each
|
|
667
|
+
// source opens its own chooser; what it hands back is checked (attach-arrange.js) before it is attached.
|
|
668
|
+
Promise.resolve().then(() => (typeof mailHost.attachmentSources === 'function' ? mailHost.attachmentSources() : mailHost.attachmentSources))
|
|
669
|
+
.then((list) => {
|
|
670
|
+
for (const source of cleanSources(list)) {
|
|
671
|
+
const button = document.createElement('button');
|
|
672
|
+
button.type = 'button';
|
|
673
|
+
button.className = 'btn btn-sm btn-ghost';
|
|
674
|
+
button.textContent = source.label;
|
|
675
|
+
button.title = source.title;
|
|
676
|
+
button.dataset.attachSource = source.id;
|
|
677
|
+
button.addEventListener('click', async () => {
|
|
678
|
+
if (button.disabled) return;
|
|
679
|
+
button.disabled = true;
|
|
680
|
+
try {
|
|
681
|
+
const used = attachments.peek().reduce((n, a) => n + a.bytes, 0);
|
|
682
|
+
const handed = await source.pick({remainingBytes: Math.max(0, maxAttachmentBytes - used)});
|
|
683
|
+
const picked = cleanPicked(handed);
|
|
684
|
+
if (picked.length) attachments.value = [...attachments.peek(), ...picked.map(file => ({key: `a${nextKey++}`, ...file}))];
|
|
685
|
+
// Never dropped without a word: what could not be attached is said.
|
|
686
|
+
const lost = (Array.isArray(handed) ? handed.length : 0) - picked.length;
|
|
687
|
+
if (lost > 0) E.toast(`${lost} file${lost === 1 ? '' : 's'} could not be attached.`, {type: 'warning'});
|
|
688
|
+
} catch (err) {
|
|
689
|
+
E.toast(err?.message || 'Those files could not be attached.', {type: 'error'});
|
|
690
|
+
} finally {
|
|
691
|
+
button.disabled = false;
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
sourcesBox?.appendChild(button);
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
.catch(() => { /* a host whose sources fail still has "Attach files" */ });
|
|
698
|
+
|
|
663
699
|
/** @param {string} key */
|
|
664
700
|
function removeAttachment(key) {
|
|
665
701
|
attachments.value = attachments.peek().filter(a => a.key !== key);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/contacts.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Recipient suggestions from the host address book.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/diagnostics-section.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* The settings section that answers "which build is this, and what went wrong".
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/drag-drop.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/** Drag identities include the mailbox and source folder: UIDs alone are not unique. */
|
|
4
4
|
const PROTECTED_USES = new Set(['\\Inbox', '\\Sent', '\\Drafts', '\\Trash', '\\Junk', '\\Archive', '\\All', '\\Flagged']);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/folder-tree.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Mail folder presentation, shared by the Mail Reader and Email Pro.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/font-controls.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/fonts.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* The fonts and sizes the mail editor offers - pure, so both the compose
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/host-context.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/** Services supplied by the application that hosts the shared mail interface. */
|
|
4
4
|
export function createMailApi({getToken, fetch: request = globalThis.fetch, onUnauthorized = () => {}}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/identity.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Who a mailbox sends as, and what it signs off with.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/image-senders-section.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* The settings section for senders whose images always load.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/keyboard.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Keyboard navigation for the reader.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/message-actions.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* What other Tools add to a message's menu - Booking's "Book Sam...".
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/oauth-panel.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* "Sign in with Microsoft / Google" for a mailbox - the part of the mailbox
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/panes.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* Pane sizing for the mail reader, shared by the Mail Reader and Email Pro.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.0, packages/core/src/admin/mail/reader-kit.js.
|
|
2
2
|
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
3
|
/**
|
|
4
4
|
* The reader view's decisions that need no DOM - escaping, the mailbox form's
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.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.36.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.36.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.36.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.36.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.36.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.36.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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.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.36.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.36.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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Source: @domma-mail/core 0.
|
|
1
|
+
// Source: @domma-mail/core 0.36.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.36.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.36.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.
|