emailengine-app 2.88.0 → 2.90.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/.ncurc.js +36 -45
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +58 -0
- package/Dockerfile +5 -1
- package/bin/healthcheck.js +1 -1
- package/copy-static-files.sh +0 -8
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +1 -4
- package/lib/account/field-codec.js +396 -0
- package/lib/account.js +158 -453
- package/lib/api-routes/account-routes.js +42 -6
- package/lib/api-routes/route-metadata.js +5 -2
- package/lib/api-routes/submit-routes.js +15 -2
- package/lib/api-token-auth.js +342 -274
- package/lib/arf-detect.js +174 -149
- package/lib/attachment-size.js +29 -0
- package/lib/autodetect-imap-settings.js +83 -234
- package/lib/consts.js +1 -5
- package/lib/db.js +1 -4
- package/lib/email-client/base-client.js +907 -780
- package/lib/email-client/gmail-client.js +557 -450
- package/lib/email-client/imap/cid-parts.js +61 -0
- package/lib/email-client/imap/mailbox.js +376 -422
- package/lib/email-client/imap/sync-operations.js +239 -178
- package/lib/email-client/new-message-steps.js +168 -2
- package/lib/email-client/outlook/graph-message.js +266 -0
- package/lib/email-client/outlook/subscription-expiry.js +30 -0
- package/lib/email-client/outlook-client.js +652 -808
- package/lib/get-raw-email.js +338 -232
- package/lib/get-secret.js +1 -4
- package/lib/license-subscription.js +77 -11
- package/lib/load-env.js +48 -0
- package/lib/logger.js +1 -4
- package/lib/mcp/tools.js +244 -207
- package/lib/metric-values.js +76 -0
- package/lib/metrics.js +320 -0
- package/lib/node-version.js +99 -12
- package/lib/oauth/gmail.js +39 -120
- package/lib/oauth/http-request.js +195 -0
- package/lib/oauth/mail-ru.js +24 -58
- package/lib/oauth/outlook.js +37 -137
- package/lib/oauth/pubsub/google.js +176 -117
- package/lib/oauth2-apps.js +440 -463
- package/lib/openapi/build-document.js +10 -10
- package/lib/read-env-value.js +1 -1
- package/lib/route-descriptors.js +78 -0
- package/lib/schemas.js +10 -1
- package/lib/sentry-integrations.js +299 -0
- package/lib/sentry.js +75 -27
- package/lib/settings.js +4 -1
- package/lib/sso-routes.js +249 -0
- package/lib/sso.js +29 -6
- package/lib/tools.js +5 -4
- package/lib/ui-routes/account-edit-form.js +198 -0
- package/lib/ui-routes/account-page.js +241 -0
- package/lib/ui-routes/account-routes.js +12 -318
- package/lib/ui-routes/auth-routes.js +10 -10
- package/lib/ui-routes/dashboard-routes.js +4 -0
- package/lib/ui-view-context.js +328 -0
- package/lib/utils/public-suffix.js +22 -101
- package/lib/web-safe-html.js +70 -13
- package/lib/worker-metrics.js +82 -0
- package/list-generate.js +57 -23
- package/package.json +34 -33
- package/sbom.json +380 -1612
- package/scripts/refresh-test-tokens.js +1 -1
- package/server.js +351 -707
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +18 -0
- package/static/js/ee-client.js +2619 -645
- package/static/js/ui.js +12 -2
- package/static/licenses.html +1055 -969
- package/translations/messages.pot +71 -60
- package/views/accounts/browse.hbs +19 -1
- package/views/dashboard.hbs +9 -0
- package/views/upgrade.hbs +25 -0
- package/workers/api.js +20 -451
- package/data/public_suffix_list.dat +0 -16597
- package/lib/net-tos-guard.js +0 -42
package/static/js/ee-client.js
CHANGED
|
@@ -29,6 +29,25 @@ const MESSAGE_BODY_STYLES = `
|
|
|
29
29
|
height: auto;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/* A message laid out wider than the viewer (a 600px newsletter on a phone) scrolls
|
|
33
|
+
sideways inside the clipped host instead of losing its right edge */
|
|
34
|
+
.ee-message-body-content {
|
|
35
|
+
overflow-x: auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* A plain-text message: EmailEngine renders it as HTML with a fixed 12px font, inline, so the
|
|
39
|
+
override needs the weight of !important; the message itself had no styling to lose */
|
|
40
|
+
.ee-message-body-content[data-plain] :is(div, p, span, pre) {
|
|
41
|
+
font-family: inherit !important;
|
|
42
|
+
font-size: inherit !important;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ee-message-body-content > pre {
|
|
46
|
+
white-space: pre-wrap;
|
|
47
|
+
font-family: inherit;
|
|
48
|
+
margin: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
/* Quoted thread history, folded away by EmailEngine - see _labelCollapsedThreads() */
|
|
33
52
|
.ee-collapsed-thread {
|
|
34
53
|
margin-top: 12px;
|
|
@@ -78,7 +97,389 @@ const ICON_PATHS = {
|
|
|
78
97
|
move: '<path d="M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1"/><path d="M2 13h10"/><path d="m9 16 3-3-3-3"/>',
|
|
79
98
|
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>',
|
|
80
99
|
send: '<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>',
|
|
81
|
-
compose: '<path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/>'
|
|
100
|
+
compose: '<path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/>',
|
|
101
|
+
reply: '<polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/>',
|
|
102
|
+
replyAll: '<polyline points="7 17 2 12 7 7"/><polyline points="12 17 7 12 12 7"/><path d="M22 18v-2a4 4 0 0 0-4-4H7"/>',
|
|
103
|
+
forward: '<polyline points="15 17 20 12 15 7"/><path d="M4 18v-2a4 4 0 0 1 4-4h12"/>',
|
|
104
|
+
paperclip: '<path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/>',
|
|
105
|
+
close: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
106
|
+
sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',
|
|
107
|
+
moon: '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',
|
|
108
|
+
inbox: '<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',
|
|
109
|
+
file: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',
|
|
110
|
+
junk: '<path d="M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86L7.86 2z"/><path d="M12 8v4"/><path d="M12 16h.01"/>',
|
|
111
|
+
archive: '<rect width="20" height="5" x="2" y="3" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>',
|
|
112
|
+
folder: '<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',
|
|
113
|
+
star: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>',
|
|
114
|
+
minimize: '<path d="M5 12h14"/>',
|
|
115
|
+
expand: '<path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/>',
|
|
116
|
+
bold: '<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"/>',
|
|
117
|
+
italic: '<line x1="19" x2="10" y1="4" y2="4"/><line x1="14" x2="5" y1="20" y2="20"/><line x1="15" x2="9" y1="4" y2="20"/>',
|
|
118
|
+
list: '<path d="M3 12h.01"/><path d="M3 18h.01"/><path d="M3 6h.01"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M8 6h13"/>',
|
|
119
|
+
listOrdered:
|
|
120
|
+
'<path d="M10 12h11"/><path d="M10 18h11"/><path d="M10 6h11"/><path d="M4 10h2"/><path d="M4 6h1v4"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/>',
|
|
121
|
+
link: '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',
|
|
122
|
+
more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>'
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Escapes text for HTML element content and quoted attribute values
|
|
126
|
+
const HTML_ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
|
|
127
|
+
function escapeHtml(value) {
|
|
128
|
+
if (value === null || value === undefined) {
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
return String(value).replace(/[&<>"']/g, ch => HTML_ESCAPES[ch]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Folder icons by special-use flag; any other folder gets the plain folder icon
|
|
135
|
+
const FOLDER_ICONS = {
|
|
136
|
+
'\\Inbox': 'inbox',
|
|
137
|
+
'\\Drafts': 'file',
|
|
138
|
+
'\\Sent': 'send',
|
|
139
|
+
'\\Trash': 'trash',
|
|
140
|
+
'\\Junk': 'junk',
|
|
141
|
+
'\\Archive': 'archive',
|
|
142
|
+
'\\All': 'archive',
|
|
143
|
+
'\\Flagged': 'star'
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// The name a folder is shown by. Servers name the inbox "INBOX" (RFC 3501 makes the name special
|
|
147
|
+
// and case-insensitive), which reads as shouting next to "Drafts" and "Sent".
|
|
148
|
+
function folderDisplayName(folder) {
|
|
149
|
+
if (!folder) {
|
|
150
|
+
return '';
|
|
151
|
+
}
|
|
152
|
+
if (folder.specialUse === '\\Inbox' && /^inbox$/i.test(folder.name)) {
|
|
153
|
+
return 'Inbox';
|
|
154
|
+
}
|
|
155
|
+
return folder.name;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// What a reader counts as attachments: not the images that the HTML body shows in place
|
|
159
|
+
// (EmailEngine marks those embedded)
|
|
160
|
+
function listedAttachments(list) {
|
|
161
|
+
return (Array.isArray(list) ? list : []).filter(att => att && !att.embedded);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// An attachment's size in bytes. EmailEngine reports encodedSize, the length of the base64 the
|
|
165
|
+
// file travels in, which is four thirds of the file; size is used when a backend gives it.
|
|
166
|
+
function attachmentSize(att) {
|
|
167
|
+
if (att.size > 0) {
|
|
168
|
+
return att.size;
|
|
169
|
+
}
|
|
170
|
+
return att.encodedSize > 0 ? Math.floor((att.encodedSize * 3) / 4) : 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// A short type label for an attachment card: the extension, or the MIME subtype without one
|
|
174
|
+
function attachmentType(att) {
|
|
175
|
+
const match = /\.([a-z0-9]{1,5})$/i.exec(att.filename || '');
|
|
176
|
+
if (match) {
|
|
177
|
+
return match[1].toUpperCase();
|
|
178
|
+
}
|
|
179
|
+
const subtype = String(att.contentType || '').split('/')[1] || '';
|
|
180
|
+
return /^[a-z0-9]{1,5}$/i.test(subtype) ? subtype.toUpperCase() : 'FILE';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// An attachment of a stored message as a compose attachment that references it by id
|
|
184
|
+
function referenceAttachment(att) {
|
|
185
|
+
return { reference: att.id, filename: att.filename, contentType: att.contentType, size: attachmentSize(att) };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// One attachment of a submission or a draft upload: new content, or a reference to an
|
|
189
|
+
// attachment of a stored message. A reference carries the name and type along, which the
|
|
190
|
+
// server would otherwise replace with "attachment-1.*" and application/octet-stream.
|
|
191
|
+
function attachmentPayload(att) {
|
|
192
|
+
if (att.reference) {
|
|
193
|
+
const entry = { reference: att.reference };
|
|
194
|
+
if (att.filename) {
|
|
195
|
+
entry.filename = att.filename;
|
|
196
|
+
}
|
|
197
|
+
if (att.contentType) {
|
|
198
|
+
entry.contentType = att.contentType;
|
|
199
|
+
}
|
|
200
|
+
return entry;
|
|
201
|
+
}
|
|
202
|
+
return { filename: att.filename, contentType: att.contentType, content: att.content };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// sendMessage, saveDraft and updateDraft take one message object since 2.0. A 1.x call
|
|
206
|
+
// (to, subject, text, options) would otherwise send a message without its subject and text.
|
|
207
|
+
function assertMessageObject(message, method) {
|
|
208
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
209
|
+
throw new TypeError(
|
|
210
|
+
`${method}() takes a message object, e.g. ${method}({ to, subject, text }). The (to, subject, text, options) form was removed in ee-client 2.0.`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// The HTML the compose editor keeps: what its toolbar makes, plus the quote structure of a
|
|
216
|
+
// reopened draft. Anything else is unwrapped to its text (DROPPED_TAGS go with their content).
|
|
217
|
+
const ALLOWED_TAGS = new Set(['P', 'DIV', 'BR', 'B', 'STRONG', 'I', 'EM', 'U', 'UL', 'OL', 'LI', 'A', 'BLOCKQUOTE']);
|
|
218
|
+
const DROPPED_TAGS = new Set([
|
|
219
|
+
'SCRIPT',
|
|
220
|
+
'STYLE',
|
|
221
|
+
'TEMPLATE',
|
|
222
|
+
'IFRAME',
|
|
223
|
+
'OBJECT',
|
|
224
|
+
'EMBED',
|
|
225
|
+
'HEAD',
|
|
226
|
+
'TITLE',
|
|
227
|
+
'META',
|
|
228
|
+
'LINK',
|
|
229
|
+
'NOSCRIPT',
|
|
230
|
+
'TEXTAREA',
|
|
231
|
+
'SELECT',
|
|
232
|
+
'SVG',
|
|
233
|
+
'MATH'
|
|
234
|
+
]);
|
|
235
|
+
const SAFE_LINK = /^(?:https?:|mailto:)/i;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Filters HTML down to the editor's allowlist: the tags above, no attributes except an
|
|
239
|
+
* http(s) or mailto href on links. The input is parsed in an inert document (no scripts run, no
|
|
240
|
+
* images load) and the output built element by element, so nothing of the input's markup is
|
|
241
|
+
* copied over as text.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} html - untrusted HTML (pasted content, a stored draft)
|
|
244
|
+
* @returns {string} safe HTML for the editor
|
|
245
|
+
*/
|
|
246
|
+
function sanitizeEditorHtml(html) {
|
|
247
|
+
const source = new DOMParser().parseFromString(`<!doctype html><body>${String(html || '')}`, 'text/html');
|
|
248
|
+
const target = document.implementation.createHTMLDocument('');
|
|
249
|
+
const copy = (from, to) => {
|
|
250
|
+
for (const node of from.childNodes) {
|
|
251
|
+
if (node.nodeType === 3) {
|
|
252
|
+
to.appendChild(target.createTextNode(node.nodeValue));
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (node.nodeType !== 1 || DROPPED_TAGS.has(node.tagName.toUpperCase())) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const tag = node.tagName.toUpperCase();
|
|
259
|
+
if (!ALLOWED_TAGS.has(tag)) {
|
|
260
|
+
copy(node, to);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const el = target.createElement(tag.toLowerCase());
|
|
264
|
+
if (tag === 'A') {
|
|
265
|
+
const href = (node.getAttribute('href') || '').trim();
|
|
266
|
+
if (SAFE_LINK.test(href)) {
|
|
267
|
+
el.setAttribute('href', href);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
copy(node, el);
|
|
271
|
+
to.appendChild(el);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
copy(source.body, target.body);
|
|
275
|
+
return target.body.innerHTML;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const BLOCK_TAGS = new Set(['P', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'TABLE', 'TR', 'PRE']);
|
|
279
|
+
|
|
280
|
+
// The text of a node's children: blocks on lines of their own, a blank line after a paragraph
|
|
281
|
+
function blockText(node) {
|
|
282
|
+
let out = '';
|
|
283
|
+
const lineBreak = () => {
|
|
284
|
+
if (out && !out.endsWith('\n')) {
|
|
285
|
+
out += '\n';
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
for (const child of node.childNodes) {
|
|
289
|
+
if (child.nodeType === 3) {
|
|
290
|
+
out += child.nodeValue.replace(/\s+/g, ' ');
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (child.nodeType !== 1) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const tag = child.tagName.toUpperCase();
|
|
297
|
+
if (tag === 'BR') {
|
|
298
|
+
out += '\n';
|
|
299
|
+
} else if (tag === 'BLOCKQUOTE') {
|
|
300
|
+
lineBreak();
|
|
301
|
+
out += `${trimLines(blockText(child))
|
|
302
|
+
.split('\n')
|
|
303
|
+
.map(line => `> ${line}`.trimEnd())
|
|
304
|
+
.join('\n')}\n`;
|
|
305
|
+
} else if (tag === 'UL' || tag === 'OL') {
|
|
306
|
+
lineBreak();
|
|
307
|
+
out += listText(child, tag === 'OL');
|
|
308
|
+
} else if (BLOCK_TAGS.has(tag)) {
|
|
309
|
+
lineBreak();
|
|
310
|
+
out += blockText(child);
|
|
311
|
+
lineBreak();
|
|
312
|
+
if (tag === 'P') {
|
|
313
|
+
out += '\n';
|
|
314
|
+
}
|
|
315
|
+
} else if (tag === 'A') {
|
|
316
|
+
const label = blockText(child);
|
|
317
|
+
const href = (child.getAttribute('href') || '').replace(/^mailto:/i, '');
|
|
318
|
+
out += href && href !== label.trim() ? `${label} (${href})` : label;
|
|
319
|
+
} else {
|
|
320
|
+
out += blockText(child);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// A list as "- item" or "1. item" lines; a nested list is indented under its item
|
|
327
|
+
function listText(list, ordered) {
|
|
328
|
+
let out = '';
|
|
329
|
+
let index = 0;
|
|
330
|
+
for (const item of list.children) {
|
|
331
|
+
const marker = item.tagName.toUpperCase() === 'LI' ? (ordered ? `${++index}. ` : '- ') : '';
|
|
332
|
+
const lines = trimLines(blockText(item)).split('\n');
|
|
333
|
+
out += `${marker}${lines[0]}\n${lines
|
|
334
|
+
.slice(1)
|
|
335
|
+
.map(line => ` ${line}\n`)
|
|
336
|
+
.join('')}`;
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function trimLines(text) {
|
|
342
|
+
return text
|
|
343
|
+
.split('\n')
|
|
344
|
+
.map(line => line.trim())
|
|
345
|
+
.join('\n')
|
|
346
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
347
|
+
.trim();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* The plain-text alternative of the editor's HTML: blocks on lines of their own, list items
|
|
352
|
+
* marked "- " or "1. ", quotes prefixed "> " and links followed by their address.
|
|
353
|
+
*
|
|
354
|
+
* @param {Node} root
|
|
355
|
+
* @returns {string}
|
|
356
|
+
*/
|
|
357
|
+
function editorText(root) {
|
|
358
|
+
return trimLines(blockText(root));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Puts the caret at the start of an editable element
|
|
362
|
+
function placeCaretAtStart(el) {
|
|
363
|
+
const selection = window.getSelection();
|
|
364
|
+
if (!selection) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const range = document.createRange();
|
|
368
|
+
range.setStart(el, 0);
|
|
369
|
+
range.collapse(true);
|
|
370
|
+
selection.removeAllRanges();
|
|
371
|
+
selection.addRange(range);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// The threading headers of a stored draft, carried over when it is saved again or sent from the
|
|
375
|
+
// compose form, so the reply it holds stays in its thread
|
|
376
|
+
function threadingHeaders(msg) {
|
|
377
|
+
const headers = (msg && msg.headers) || {};
|
|
378
|
+
const first = value =>
|
|
379
|
+
String((Array.isArray(value) ? value[0] : value) || '')
|
|
380
|
+
.replace(/\s+/g, ' ')
|
|
381
|
+
.trim();
|
|
382
|
+
const result = {};
|
|
383
|
+
const inReplyTo = first(headers['in-reply-to']) || first(msg && msg.inReplyTo);
|
|
384
|
+
const references = first(headers.references);
|
|
385
|
+
if (inReplyTo) {
|
|
386
|
+
result['In-Reply-To'] = inReplyTo;
|
|
387
|
+
}
|
|
388
|
+
if (references) {
|
|
389
|
+
result.References = references;
|
|
390
|
+
}
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Plain text as editor HTML: escaped, one paragraph per blank-line separated block
|
|
395
|
+
function textToEditorHtml(text) {
|
|
396
|
+
if (!text) {
|
|
397
|
+
return '';
|
|
398
|
+
}
|
|
399
|
+
return String(text)
|
|
400
|
+
.split(/\n{2,}/)
|
|
401
|
+
.map(block => `<p>${escapeHtml(block).replace(/\n/g, '<br>')}</p>`)
|
|
402
|
+
.join('');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Default cap on the files attached in the compose form, in bytes. They travel base64 encoded
|
|
406
|
+
// inside one JSON request, which grows them by a third, and most providers refuse a message
|
|
407
|
+
// much larger than this anyway. Hosts that know their limit pass maxAttachmentSize.
|
|
408
|
+
const DEFAULT_MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
409
|
+
|
|
410
|
+
// What a compose form address has to look like before it is sent. Deliberately loose: the
|
|
411
|
+
// server validates properly, this only catches a name typed without its address.
|
|
412
|
+
const ADDRESS_PATTERN = /^[^\s@<>",;]+@[^\s@<>",;]+$/;
|
|
413
|
+
|
|
414
|
+
// Splits an address field on commas and semicolons that are not inside a quoted name or an
|
|
415
|
+
// angle-bracketed address, so "Doe, John" <john@example.com> stays one entry.
|
|
416
|
+
function splitAddressField(value) {
|
|
417
|
+
const parts = [];
|
|
418
|
+
let current = '';
|
|
419
|
+
let quoted = false;
|
|
420
|
+
let bracketed = false;
|
|
421
|
+
for (let i = 0; i < value.length; i++) {
|
|
422
|
+
const chr = value[i];
|
|
423
|
+
if (chr === '\\' && quoted && i + 1 < value.length) {
|
|
424
|
+
current += chr + value[++i];
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (chr === '"' && !bracketed) {
|
|
428
|
+
quoted = !quoted;
|
|
429
|
+
} else if (chr === '<' && !quoted) {
|
|
430
|
+
bracketed = true;
|
|
431
|
+
} else if (chr === '>' && !quoted) {
|
|
432
|
+
bracketed = false;
|
|
433
|
+
} else if ((chr === ',' || chr === ';') && !quoted && !bracketed) {
|
|
434
|
+
parts.push(current);
|
|
435
|
+
current = '';
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
current += chr;
|
|
439
|
+
}
|
|
440
|
+
parts.push(current);
|
|
441
|
+
return parts.map(part => part.trim()).filter(Boolean);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function parseAddressEntry(entry) {
|
|
445
|
+
// "Name <address>": the address is between the last "<" and a closing ">" at the end.
|
|
446
|
+
// Found by index rather than a /^(.*)<([^>]*)>$/ match, which backtracks in quadratic
|
|
447
|
+
// time on a long run of "<" without the closing ">"
|
|
448
|
+
const open = entry.lastIndexOf('<');
|
|
449
|
+
if (open < 0 || !entry.endsWith('>') || entry.indexOf('>', open) !== entry.length - 1 || /[\n\r\u2028\u2029]/.test(entry.slice(0, open))) {
|
|
450
|
+
return { address: entry };
|
|
451
|
+
}
|
|
452
|
+
let name = entry.slice(0, open).trim();
|
|
453
|
+
if (name.length > 1 && name.startsWith('"') && name.endsWith('"')) {
|
|
454
|
+
name = name.slice(1, -1).replace(/\\(.)/g, '$1');
|
|
455
|
+
}
|
|
456
|
+
const address = entry.slice(open + 1, -1).trim();
|
|
457
|
+
return name ? { name, address } : { address };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Adds "Re: " or "Fwd: " unless the subject already starts with that prefix, so a long
|
|
461
|
+
// thread does not read "Re: Re: Re:"
|
|
462
|
+
function prefixSubject(subject, prefix) {
|
|
463
|
+
const value = (subject || '').trim();
|
|
464
|
+
const pattern = prefix === 'Re' ? /^re\s*:/i : /^fwd?\s*:/i;
|
|
465
|
+
return pattern.test(value) ? value : `${prefix}: ${value}`.trim();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Address entries that carry an address, from a list, a single entry or a bare address string.
|
|
469
|
+
// The server can return name-only entries and a single object where a list is expected.
|
|
470
|
+
function addressEntries(value) {
|
|
471
|
+
return (Array.isArray(value) ? value : value ? [value] : [])
|
|
472
|
+
.map(entry => (typeof entry === 'string' ? { address: entry } : entry))
|
|
473
|
+
.filter(entry => entry && typeof entry.address === 'string' && entry.address);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Compose form titles, by mode
|
|
477
|
+
const COMPOSE_TITLES = {
|
|
478
|
+
new: 'New message',
|
|
479
|
+
reply: 'Reply',
|
|
480
|
+
'reply-all': 'Reply all',
|
|
481
|
+
forward: 'Forward',
|
|
482
|
+
draft: 'Draft'
|
|
82
483
|
};
|
|
83
484
|
|
|
84
485
|
// Below this container width the UI shows one pane at a time and the compose button
|
|
@@ -112,10 +513,25 @@ export class EmailEngineClient {
|
|
|
112
513
|
|
|
113
514
|
this.currentFolder = null;
|
|
114
515
|
this.currentMessage = null;
|
|
516
|
+
// A message to open on startup instead of the inbox listing (a deep link). Its folder
|
|
517
|
+
// is listed next to it, so the reader lands where the message lives.
|
|
518
|
+
this.initialMessage = typeof options.message === 'string' && options.message ? options.message : null;
|
|
519
|
+
// Told whenever the open folder or message changes, so a host page can keep its address
|
|
520
|
+
// bar in step (see _notifyNavigate)
|
|
521
|
+
// Host callbacks (see _emit): navigation, so the host can keep its address bar in step, and
|
|
522
|
+
// the outcomes it may want to track - a message queued for delivery, a draft stored, and a
|
|
523
|
+
// request that failed, with what the client was doing at the time
|
|
524
|
+
for (const name of ['onNavigate', 'onMessageSent', 'onDraftSaved', 'onError']) {
|
|
525
|
+
this[name] = typeof options[name] === 'function' ? options[name] : null;
|
|
526
|
+
}
|
|
527
|
+
const maxAttachmentSize = Number(options.maxAttachmentSize);
|
|
528
|
+
this.maxAttachmentSize = maxAttachmentSize > 0 ? maxAttachmentSize : DEFAULT_MAX_ATTACHMENT_SIZE;
|
|
115
529
|
this.folders = [];
|
|
116
530
|
this.messages = [];
|
|
117
531
|
this.nextPageCursor = null;
|
|
118
532
|
this.prevPageCursor = null;
|
|
533
|
+
// Position of the listed page: { page (0-based), total } when the server reports them
|
|
534
|
+
this.listPosition = null;
|
|
119
535
|
|
|
120
536
|
// Set once destroy() runs; guards async completions (loadFolders,
|
|
121
537
|
// loadMessages, loadMessage) from re-rendering or scrolling into a
|
|
@@ -148,9 +564,9 @@ export class EmailEngineClient {
|
|
|
148
564
|
const requestedPageSize = savedPageSize ? parseInt(savedPageSize, 10) : parseInt(options.pageSize, 10);
|
|
149
565
|
this.pageSize = requestedPageSize > 0 ? requestedPageSize : 20;
|
|
150
566
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
567
|
+
// Resolves once the first view has loaded: true when it did, false when its requests failed
|
|
568
|
+
// (the panes then show why). An API-only client has nothing to load.
|
|
569
|
+
this.ready = this.container ? this.init() : Promise.resolve(true);
|
|
154
570
|
|
|
155
571
|
// Start keep-alive timer for sess_ tokens
|
|
156
572
|
this._startKeepAliveTimer();
|
|
@@ -246,28 +662,38 @@ export class EmailEngineClient {
|
|
|
246
662
|
return `${this._accountPath()}/attachment/${encodeURIComponent(attachmentId)}`;
|
|
247
663
|
}
|
|
248
664
|
|
|
249
|
-
|
|
665
|
+
// Stores the folder list without rendering or reporting anything
|
|
666
|
+
async _fetchFolders(counters = false) {
|
|
667
|
+
const data = await this.apiRequest('GET', `${this._accountPath()}/mailboxes${counters ? '?counters=true' : ''}`);
|
|
668
|
+
this.folders = data.mailboxes || [];
|
|
669
|
+
this._folderTreeCache = null;
|
|
670
|
+
return this.folders;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// counters adds each folder's message and unread counts, at the cost of a STATUS command per
|
|
674
|
+
// folder on IMAP. The UI shows them, so it asks by default; an API-only client asks when told to.
|
|
675
|
+
async loadFolders({ counters = !!this.container } = {}) {
|
|
250
676
|
// Reset the pane to its loading state so a retry after a failure does not
|
|
251
677
|
// keep showing the previous error while the new request is in flight.
|
|
252
678
|
this._setPaneHtml('.ee-folder-tree', '<div class="ee-loading">Loading folders...</div>');
|
|
253
679
|
|
|
254
680
|
try {
|
|
255
|
-
|
|
256
|
-
this.folders = data.mailboxes || [];
|
|
257
|
-
this._folderTreeCache = null;
|
|
681
|
+
await this._fetchFolders(counters);
|
|
258
682
|
if (this.container) {
|
|
259
683
|
this.renderFolderList();
|
|
260
684
|
}
|
|
261
685
|
return this.folders;
|
|
262
686
|
} catch (error) {
|
|
263
687
|
console.error('Failed to load folders:', error);
|
|
688
|
+
this._reportError(error, 'loadFolders', 'Failed to load the folders');
|
|
264
689
|
this._renderPaneError('.ee-folder-tree', 'Folders unavailable', error, () => this._loadInitialView());
|
|
265
690
|
throw error;
|
|
266
691
|
}
|
|
267
692
|
}
|
|
268
693
|
|
|
694
|
+
// Loads and renders one page of a folder's message list. The open message stays open: it is
|
|
695
|
+
// the folder click (openFolder()) that closes it, while paging and refreshes keep it.
|
|
269
696
|
async loadMessages(path, cursor = null) {
|
|
270
|
-
this._setView('list');
|
|
271
697
|
this._setPaneHtml('.ee-message-list', `${this._messageListHeader(path)}<div class="ee-loading">Loading messages...</div>`);
|
|
272
698
|
|
|
273
699
|
try {
|
|
@@ -281,16 +707,15 @@ export class EmailEngineClient {
|
|
|
281
707
|
this.currentFolder = path;
|
|
282
708
|
this.nextPageCursor = data.nextPageCursor || null;
|
|
283
709
|
this.prevPageCursor = data.prevPageCursor || null;
|
|
284
|
-
|
|
285
|
-
// Clear active email selection when folder changes
|
|
286
|
-
this.currentMessage = null;
|
|
710
|
+
this.listPosition = Number.isInteger(data.page) && Number.isInteger(data.total) ? { page: data.page, total: data.total } : null;
|
|
287
711
|
|
|
288
712
|
if (this.container) {
|
|
289
713
|
this.renderMessageList();
|
|
290
714
|
this.renderFolderList(); // Re-render to update active state
|
|
291
|
-
this.renderMessage(); // Clear message viewer
|
|
292
715
|
}
|
|
293
716
|
|
|
717
|
+
this._notifyNavigate();
|
|
718
|
+
|
|
294
719
|
return {
|
|
295
720
|
messages: this.messages,
|
|
296
721
|
nextPageCursor: this.nextPageCursor,
|
|
@@ -298,6 +723,7 @@ export class EmailEngineClient {
|
|
|
298
723
|
};
|
|
299
724
|
} catch (error) {
|
|
300
725
|
console.error('Failed to load messages:', error);
|
|
726
|
+
this._reportError(error, 'loadMessages', 'Failed to load the messages');
|
|
301
727
|
this._renderPaneError(
|
|
302
728
|
'.ee-message-list',
|
|
303
729
|
'Messages unavailable',
|
|
@@ -309,6 +735,14 @@ export class EmailEngineClient {
|
|
|
309
735
|
}
|
|
310
736
|
}
|
|
311
737
|
|
|
738
|
+
// Switches to another folder: closes the open message and lists the folder
|
|
739
|
+
openFolder(path) {
|
|
740
|
+
this.currentMessage = null;
|
|
741
|
+
this.renderMessage();
|
|
742
|
+
this._setView('list');
|
|
743
|
+
return this.loadMessages(path);
|
|
744
|
+
}
|
|
745
|
+
|
|
312
746
|
async loadMessage(messageId) {
|
|
313
747
|
this._setView('message');
|
|
314
748
|
this._setPaneHtml('.ee-message-viewer', `${this._messageToolbar()}<div class="ee-loading">Loading message...</div>`);
|
|
@@ -322,9 +756,13 @@ export class EmailEngineClient {
|
|
|
322
756
|
this.currentMessage = data;
|
|
323
757
|
|
|
324
758
|
this.currentMessage.unseen = false;
|
|
759
|
+
this._notifyNavigate();
|
|
325
760
|
|
|
326
761
|
const msg = this.messages.find(m => m.id === messageId);
|
|
327
762
|
if (msg) {
|
|
763
|
+
if (msg.unseen) {
|
|
764
|
+
this._adjustUnseen(this.currentFolder, -1);
|
|
765
|
+
}
|
|
328
766
|
msg.unseen = false;
|
|
329
767
|
if (this.container) {
|
|
330
768
|
this.renderMessageList();
|
|
@@ -334,26 +772,38 @@ export class EmailEngineClient {
|
|
|
334
772
|
if (this.container && !this._destroyed) {
|
|
335
773
|
this.renderMessage();
|
|
336
774
|
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
//
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
window.scrollTo({ top: containerTop, behavior: 'smooth' });
|
|
775
|
+
// The message opens at the top of the client: bring that into view when the
|
|
776
|
+
// page is scrolled past it (a long list on a phone), and leave the page alone
|
|
777
|
+
// otherwise. scrollIntoView honours the host's scroll-margin-top, which is how
|
|
778
|
+
// a page with a fixed header keeps the toolbar clear of it.
|
|
779
|
+
if (this.container.getBoundingClientRect().top < 0) {
|
|
780
|
+
this.container.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
344
781
|
}
|
|
345
782
|
}
|
|
346
783
|
|
|
347
784
|
return this.currentMessage;
|
|
348
785
|
} catch (error) {
|
|
349
786
|
console.error('Failed to load message:', error);
|
|
350
|
-
this.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
787
|
+
this._reportError(error, 'loadMessage', 'Failed to load the message');
|
|
788
|
+
// A message that does not exist (deleted, moved, or a link with a mangled ID) is
|
|
789
|
+
// not worth retrying, and the API's validation text means nothing to a reader
|
|
790
|
+
if (error && (error.statusCode === 404 || error.statusCode === 400)) {
|
|
791
|
+
this._renderPaneError(
|
|
792
|
+
'.ee-message-viewer',
|
|
793
|
+
'Message not found',
|
|
794
|
+
'It may have been moved or deleted, or the link to it is incomplete.',
|
|
795
|
+
null,
|
|
796
|
+
this._messageToolbar()
|
|
797
|
+
);
|
|
798
|
+
} else {
|
|
799
|
+
this._renderPaneError(
|
|
800
|
+
'.ee-message-viewer',
|
|
801
|
+
'Message unavailable',
|
|
802
|
+
error,
|
|
803
|
+
() => this._fireAndForget(this.loadMessage(messageId)),
|
|
804
|
+
this._messageToolbar()
|
|
805
|
+
);
|
|
806
|
+
}
|
|
357
807
|
throw error;
|
|
358
808
|
}
|
|
359
809
|
}
|
|
@@ -366,6 +816,9 @@ export class EmailEngineClient {
|
|
|
366
816
|
|
|
367
817
|
const msg = this.messages.find(m => m.id === messageId);
|
|
368
818
|
if (msg) {
|
|
819
|
+
if (msg.unseen === seen) {
|
|
820
|
+
this._adjustUnseen(this.currentFolder, seen ? -1 : 1);
|
|
821
|
+
}
|
|
369
822
|
msg.unseen = !seen;
|
|
370
823
|
if (this.container) {
|
|
371
824
|
this.renderMessageList();
|
|
@@ -382,29 +835,47 @@ export class EmailEngineClient {
|
|
|
382
835
|
return true;
|
|
383
836
|
} catch (error) {
|
|
384
837
|
console.error('Failed to update message flags:', error);
|
|
838
|
+
this._reportError(error, 'markAsRead', 'Failed to update the message flags');
|
|
385
839
|
throw error;
|
|
386
840
|
}
|
|
387
841
|
}
|
|
388
842
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
843
|
+
// Takes a message that left the folder (deleted or moved) off the list, and out of the
|
|
844
|
+
// viewer when it was the open one
|
|
845
|
+
_dropMessage(messageId, targetPath = null) {
|
|
846
|
+
const dropped = this.messages.find(m => m.id === messageId);
|
|
847
|
+
if (dropped && dropped.unseen) {
|
|
848
|
+
this._adjustUnseen(this.currentFolder, -1);
|
|
849
|
+
if (targetPath) {
|
|
850
|
+
this._adjustUnseen(targetPath, 1);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
this.messages = this.messages.filter(m => m.id !== messageId);
|
|
854
|
+
if (this.container) {
|
|
855
|
+
this.renderMessageList();
|
|
856
|
+
}
|
|
392
857
|
|
|
393
|
-
|
|
858
|
+
if (this.currentMessage && this.currentMessage.id === messageId) {
|
|
859
|
+
this.currentMessage = null;
|
|
394
860
|
if (this.container) {
|
|
395
|
-
this.
|
|
861
|
+
this.renderMessage();
|
|
396
862
|
}
|
|
863
|
+
this._notifyNavigate();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
397
866
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
this.renderMessage();
|
|
402
|
-
}
|
|
403
|
-
}
|
|
867
|
+
async deleteMessage(messageId) {
|
|
868
|
+
try {
|
|
869
|
+
const response = await this.apiRequest('DELETE', this._messagePath(messageId));
|
|
404
870
|
|
|
405
|
-
|
|
871
|
+
this._dropMessage(messageId);
|
|
872
|
+
|
|
873
|
+
// { deleted, moved: { destination, message } } - moved is set when the message went
|
|
874
|
+
// to Trash instead of being removed
|
|
875
|
+
return response || { deleted: true };
|
|
406
876
|
} catch (error) {
|
|
407
877
|
console.error('Failed to delete message:', error);
|
|
878
|
+
this._reportError(error, 'delete', 'Failed to delete the message');
|
|
408
879
|
throw error;
|
|
409
880
|
}
|
|
410
881
|
}
|
|
@@ -415,29 +886,16 @@ export class EmailEngineClient {
|
|
|
415
886
|
path: targetPath
|
|
416
887
|
});
|
|
417
888
|
|
|
418
|
-
this.
|
|
419
|
-
if (this.container) {
|
|
420
|
-
this.renderMessageList();
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (this.currentMessage && this.currentMessage.id === messageId) {
|
|
424
|
-
this.currentMessage = null;
|
|
425
|
-
if (this.container) {
|
|
426
|
-
this.renderMessage();
|
|
427
|
-
}
|
|
428
|
-
}
|
|
889
|
+
this._dropMessage(messageId, targetPath);
|
|
429
890
|
|
|
430
891
|
return true;
|
|
431
892
|
} catch (error) {
|
|
432
893
|
console.error('Failed to move message:', error);
|
|
894
|
+
this._reportError(error, 'move', 'Failed to move the message');
|
|
433
895
|
throw error;
|
|
434
896
|
}
|
|
435
897
|
}
|
|
436
898
|
|
|
437
|
-
_normalizeRecipients(to) {
|
|
438
|
-
return Array.isArray(to) ? to.map(addr => (typeof addr === 'string' ? { address: addr } : addr)) : [typeof to === 'string' ? { address: to } : to];
|
|
439
|
-
}
|
|
440
|
-
|
|
441
899
|
// Account details (name, email address) fetched once and cached for the lifetime
|
|
442
900
|
// of the instance; used as the From identity of saved drafts.
|
|
443
901
|
async _getAccountInfo() {
|
|
@@ -447,26 +905,84 @@ export class EmailEngineClient {
|
|
|
447
905
|
return this._accountInfo;
|
|
448
906
|
}
|
|
449
907
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
908
|
+
// The address and content fields shared by a submission and a draft upload, from a message
|
|
909
|
+
// object (see sendMessage). Empty recipient lists and empty parts are left out.
|
|
910
|
+
_messagePayload(message) {
|
|
911
|
+
const { to, cc, bcc, subject, text, html, attachments, reference, headers } = message;
|
|
912
|
+
const data = {};
|
|
913
|
+
if (typeof subject === 'string') {
|
|
914
|
+
data.subject = subject;
|
|
915
|
+
}
|
|
916
|
+
if (typeof text === 'string') {
|
|
917
|
+
data.text = text;
|
|
918
|
+
}
|
|
919
|
+
if (typeof html === 'string' && html) {
|
|
920
|
+
data.html = html;
|
|
921
|
+
}
|
|
922
|
+
for (const [key, value] of [
|
|
923
|
+
['to', to],
|
|
924
|
+
['cc', cc],
|
|
925
|
+
['bcc', bcc]
|
|
926
|
+
]) {
|
|
927
|
+
const list = addressEntries(value);
|
|
928
|
+
if (list.length) {
|
|
929
|
+
data[key] = list;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (Array.isArray(attachments) && attachments.length) {
|
|
933
|
+
data.attachments = attachments.map(attachmentPayload);
|
|
934
|
+
}
|
|
935
|
+
if (reference) {
|
|
936
|
+
data.reference = reference;
|
|
937
|
+
}
|
|
938
|
+
if (headers && typeof headers === 'object' && Object.keys(headers).length) {
|
|
939
|
+
data.headers = headers;
|
|
940
|
+
}
|
|
941
|
+
return data;
|
|
942
|
+
}
|
|
457
943
|
|
|
458
|
-
|
|
944
|
+
/**
|
|
945
|
+
* Submits a message for delivery.
|
|
946
|
+
*
|
|
947
|
+
* @param {Object} message
|
|
948
|
+
* @param {string|Object|Object[]} message.to - "Name <address>", { name, address } or a list
|
|
949
|
+
* @param {string|Object|Object[]} [message.cc]
|
|
950
|
+
* @param {string|Object|Object[]} [message.bcc]
|
|
951
|
+
* @param {string} [message.subject]
|
|
952
|
+
* @param {string} [message.text] - the plain text part
|
|
953
|
+
* @param {string} [message.html] - the HTML part
|
|
954
|
+
* @param {Object[]} [message.attachments] - { filename, contentType, content (base64) }, or
|
|
955
|
+
* { reference, filename, contentType } for an attachment of a stored message by its id
|
|
956
|
+
* @param {Object} [message.reference] - EmailEngine's reference block ({ message, action,
|
|
957
|
+
* inline, forwardAttachments }); the server adds the threading headers and the quote
|
|
958
|
+
* @param {Object} [message.headers] - extra headers, e.g. In-Reply-To of a reopened draft
|
|
959
|
+
* @returns {Promise<Object>} the queue response ({ messageId, queueId, ... })
|
|
960
|
+
*/
|
|
961
|
+
async sendMessage(message) {
|
|
962
|
+
assertMessageObject(message, 'sendMessage');
|
|
963
|
+
try {
|
|
964
|
+
const response = await this.apiRequest('POST', `${this._accountPath()}/submit`, this._messagePayload(message));
|
|
965
|
+
this._emit('onMessageSent', response);
|
|
459
966
|
return response;
|
|
460
967
|
} catch (error) {
|
|
461
968
|
console.error('Failed to send message:', error);
|
|
969
|
+
this._reportError(error, 'send', 'Failed to send the message');
|
|
462
970
|
throw error;
|
|
463
971
|
}
|
|
464
972
|
}
|
|
465
973
|
|
|
466
|
-
|
|
974
|
+
/**
|
|
975
|
+
* Stores a message in the Drafts folder. Takes the same message object as sendMessage.
|
|
976
|
+
*
|
|
977
|
+
* @param {Object} message
|
|
978
|
+
* @returns {Promise<Object>} the upload response ({ id, path, uid, ... })
|
|
979
|
+
*/
|
|
980
|
+
async saveDraft(message) {
|
|
981
|
+
assertMessageObject(message, 'saveDraft');
|
|
467
982
|
try {
|
|
468
983
|
if (!this.folders.length) {
|
|
469
|
-
|
|
984
|
+
// only the Drafts path is needed; a failure is this save's own
|
|
985
|
+
await this._fetchFolders();
|
|
470
986
|
}
|
|
471
987
|
const draftsFolder = this.folders.find(f => f.specialUse === '\\Drafts');
|
|
472
988
|
if (!draftsFolder) {
|
|
@@ -476,15 +992,9 @@ export class EmailEngineClient {
|
|
|
476
992
|
const messageData = {
|
|
477
993
|
path: draftsFolder.path,
|
|
478
994
|
flags: ['\\Draft'],
|
|
479
|
-
|
|
480
|
-
text
|
|
995
|
+
...this._messagePayload(message)
|
|
481
996
|
};
|
|
482
997
|
|
|
483
|
-
const recipients = to ? this._normalizeRecipients(to) : [];
|
|
484
|
-
if (recipients.length) {
|
|
485
|
-
messageData.to = recipients;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
998
|
// The upload endpoint does not add a From header on its own, but the draft
|
|
489
999
|
// needs one to be deliverable later - use the account's own identity.
|
|
490
1000
|
try {
|
|
@@ -497,19 +1007,147 @@ export class EmailEngineClient {
|
|
|
497
1007
|
}
|
|
498
1008
|
|
|
499
1009
|
const response = await this.apiRequest('POST', `${this._accountPath()}/message`, messageData);
|
|
1010
|
+
this._emit('onDraftSaved', response);
|
|
500
1011
|
return response;
|
|
501
1012
|
} catch (error) {
|
|
502
1013
|
console.error('Failed to save draft:', error);
|
|
1014
|
+
this._reportError(error, 'saveDraft', 'Failed to save the draft');
|
|
503
1015
|
throw error;
|
|
504
1016
|
}
|
|
505
1017
|
}
|
|
506
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* Replaces a stored draft with a new version. IMAP has no way to change a stored message, so
|
|
1021
|
+
* the new version is saved first and the old one removed after; attachments the new version
|
|
1022
|
+
* references from the old draft are copied before it goes.
|
|
1023
|
+
*
|
|
1024
|
+
* @param {string} messageId - the draft to replace
|
|
1025
|
+
* @param {Object} message - the new version, as for sendMessage
|
|
1026
|
+
* @returns {Promise<Object>} the upload response of the new version
|
|
1027
|
+
*/
|
|
1028
|
+
async updateDraft(messageId, message) {
|
|
1029
|
+
assertMessageObject(message, 'updateDraft');
|
|
1030
|
+
const saved = await this.saveDraft(message);
|
|
1031
|
+
await this._discardDraft(messageId);
|
|
1032
|
+
return saved;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// Removes a draft for good (not to Trash: it is a superseded or sent copy). A failure is
|
|
1036
|
+
// logged only; the newer version is already safe.
|
|
1037
|
+
async _discardDraft(messageId) {
|
|
1038
|
+
try {
|
|
1039
|
+
await this.apiRequest('DELETE', this._messagePath(messageId, '?force=true'));
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
console.error('Failed to remove the previous draft:', error);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// Parses a typed address field ("Name <a@example.com>, b@example.com") into address entries
|
|
1046
|
+
parseAddressList(value) {
|
|
1047
|
+
return splitAddressField(String(value || '')).map(parseAddressEntry);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// The reverse of parseAddressList, for filling a compose field
|
|
1051
|
+
formatAddressList(list) {
|
|
1052
|
+
return addressEntries(list)
|
|
1053
|
+
.map(entry => {
|
|
1054
|
+
if (!entry.name) {
|
|
1055
|
+
return entry.address;
|
|
1056
|
+
}
|
|
1057
|
+
const name = /[",;<>@\\]/.test(entry.name) ? `"${entry.name.replace(/(["\\])/g, '\\$1')}"` : entry.name;
|
|
1058
|
+
return `${name} <${entry.address}>`;
|
|
1059
|
+
})
|
|
1060
|
+
.join(', ');
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Recipients, subject and submit reference for a reply, reply-all or forward of msg, as the
|
|
1064
|
+
// compose form shows them. ownAddress (the account's) is left out of the recipients.
|
|
1065
|
+
//
|
|
1066
|
+
// Reply-all is resolved here rather than by the server: EmailEngine's reply-all merges the
|
|
1067
|
+
// original recipients into whatever is sent, so one the user removed from the form would be
|
|
1068
|
+
// put back. It goes out as a reply with every recipient spelled out instead, which the server
|
|
1069
|
+
// leaves alone, and what the form shows is what is sent.
|
|
1070
|
+
prepareResponse(msg, action, ownAddress = null) {
|
|
1071
|
+
if (action === 'forward') {
|
|
1072
|
+
// The original's files travel as references, one per file, so each can be left out;
|
|
1073
|
+
// forwardAttachments would carry all of them or none
|
|
1074
|
+
const attachments = listedAttachments(msg.attachments).map(referenceAttachment);
|
|
1075
|
+
return {
|
|
1076
|
+
to: [],
|
|
1077
|
+
cc: [],
|
|
1078
|
+
subject: prefixSubject(msg.subject, 'Fwd'),
|
|
1079
|
+
reference: { message: msg.id, action: 'forward', inline: true, forwardAttachments: false },
|
|
1080
|
+
attachments
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
const own = typeof ownAddress === 'string' ? ownAddress.toLowerCase() : '';
|
|
1085
|
+
const seen = new Set(own ? [own] : []);
|
|
1086
|
+
const take = list =>
|
|
1087
|
+
addressEntries(list)
|
|
1088
|
+
.filter(entry => {
|
|
1089
|
+
const key = entry.address.toLowerCase();
|
|
1090
|
+
if (seen.has(key)) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
seen.add(key);
|
|
1094
|
+
return true;
|
|
1095
|
+
})
|
|
1096
|
+
.map(entry => (entry.name ? { name: entry.name, address: entry.address } : { address: entry.address }));
|
|
1097
|
+
|
|
1098
|
+
// Answer the address the message nominates, otherwise its sender - or, for a message the
|
|
1099
|
+
// account sent itself (Sent folder), the people it went to. The account's own address is
|
|
1100
|
+
// never an answer, so a Reply-To naming the account falls through to the next candidate.
|
|
1101
|
+
const fromSelf = !!own && addressEntries(msg.from).some(entry => entry.address.toLowerCase() === own);
|
|
1102
|
+
let to = [];
|
|
1103
|
+
for (const candidate of [msg.replyTo, fromSelf ? msg.to : msg.from]) {
|
|
1104
|
+
to = take(candidate);
|
|
1105
|
+
if (to.length) {
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
if (!to.length) {
|
|
1110
|
+
// A message from the account to itself: answer it anyway
|
|
1111
|
+
to = addressEntries(msg.from).map(entry => ({ ...entry }));
|
|
1112
|
+
}
|
|
1113
|
+
const cc = action === 'reply-all' ? take(addressEntries(msg.to).concat(addressEntries(msg.cc))) : [];
|
|
1114
|
+
|
|
1115
|
+
return { to, cc, subject: prefixSubject(msg.subject, 'Re'), reference: { message: msg.id, action: 'reply', inline: true } };
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// Calls a host callback by its option name. A host error must not break the client.
|
|
1119
|
+
_emit(name, ...args) {
|
|
1120
|
+
const handler = this[name];
|
|
1121
|
+
if (typeof handler !== 'function' || this._destroyed) {
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
try {
|
|
1125
|
+
handler(...args);
|
|
1126
|
+
} catch (error) {
|
|
1127
|
+
console.error(`${name} handler failed:`, error);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// Tells the host which folder and message are open
|
|
1132
|
+
_notifyNavigate() {
|
|
1133
|
+
this._emit('onNavigate', { path: this.currentFolder, messageId: this.currentMessage ? this.currentMessage.id : null });
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// Tells the host a request failed: action names what the client was doing ('loadFolders',
|
|
1137
|
+
// 'loadMessages', 'loadMessage', 'markAsRead', 'delete', 'move', 'send', 'saveDraft' or
|
|
1138
|
+
// 'download'), and description says it in words
|
|
1139
|
+
_reportError(error, action, description) {
|
|
1140
|
+
this._emit('onError', error, { action, description });
|
|
1141
|
+
}
|
|
1142
|
+
|
|
507
1143
|
async submitDraft(messageId, options = null) {
|
|
508
1144
|
try {
|
|
509
1145
|
const response = await this.apiRequest('POST', this._messagePath(messageId, '/submit'), options);
|
|
1146
|
+
this._emit('onMessageSent', response);
|
|
510
1147
|
return response;
|
|
511
1148
|
} catch (error) {
|
|
512
1149
|
console.error('Failed to submit draft:', error);
|
|
1150
|
+
this._reportError(error, 'send', 'Failed to send the draft');
|
|
513
1151
|
throw error;
|
|
514
1152
|
}
|
|
515
1153
|
}
|
|
@@ -550,7 +1188,7 @@ export class EmailEngineClient {
|
|
|
550
1188
|
// are needed - and to[N] for any index is handled, not just to[0].
|
|
551
1189
|
.map(field =>
|
|
552
1190
|
field.message
|
|
553
|
-
.replace(/to\[\d+\]\.address|"address"/g, 'email address')
|
|
1191
|
+
.replace(/(?:to|cc|bcc)\[\d+\]\.address|"address"/g, 'email address')
|
|
554
1192
|
.replace(/"subject"/g, 'subject')
|
|
555
1193
|
.replace(/"text"/g, 'message')
|
|
556
1194
|
);
|
|
@@ -595,8 +1233,9 @@ export class EmailEngineClient {
|
|
|
595
1233
|
// missing, optionally with a Retry button. Without this a failed request
|
|
596
1234
|
// leaves the pane stuck on its "Loading..." placeholder forever, with the
|
|
597
1235
|
// only trace of the failure in the developer console.
|
|
1236
|
+
// error is the failed request's error, or a plain explanation to show instead
|
|
598
1237
|
_renderPaneError(selector, title, error, retry = null, header = '') {
|
|
599
|
-
const detail = this._errorMessage(error, '');
|
|
1238
|
+
const detail = typeof error === 'string' ? error : this._errorMessage(error, '');
|
|
600
1239
|
const pane = this._setPaneHtml(
|
|
601
1240
|
selector,
|
|
602
1241
|
`
|
|
@@ -633,6 +1272,19 @@ export class EmailEngineClient {
|
|
|
633
1272
|
promise.catch(() => {});
|
|
634
1273
|
}
|
|
635
1274
|
|
|
1275
|
+
// A short notice at the bottom of the client that goes away on its own, for outcomes that
|
|
1276
|
+
// need no answer (a message queued, a draft saved). Errors keep using alertMethod.
|
|
1277
|
+
notify(message) {
|
|
1278
|
+
const toast = this.container && this.container.querySelector('.ee-toast');
|
|
1279
|
+
if (!toast || this._destroyed) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
toast.textContent = message;
|
|
1283
|
+
toast.classList.add('show');
|
|
1284
|
+
clearTimeout(this._toastTimer);
|
|
1285
|
+
this._toastTimer = setTimeout(() => toast.classList.remove('show'), 4000);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
636
1288
|
// Message actions (flag, delete, move) have no pane of their own to report into:
|
|
637
1289
|
// when one fails the message simply stays put, which is indistinguishable from
|
|
638
1290
|
// nothing having happened. Say so instead.
|
|
@@ -649,15 +1301,14 @@ export class EmailEngineClient {
|
|
|
649
1301
|
|
|
650
1302
|
// Header for every state of the message list pane, titled with the folder
|
|
651
1303
|
// being shown. In the single-pane layout its back button leads to the folders.
|
|
652
|
-
_messageListHeader(path
|
|
1304
|
+
_messageListHeader(path) {
|
|
653
1305
|
const folder = path && this.folders.find(f => f.path === path);
|
|
654
1306
|
return `
|
|
655
1307
|
<div class="ee-pane-header">
|
|
656
1308
|
<div class="ee-pane-heading">
|
|
657
1309
|
${this._iconButton('show-folders', 'back', 'Folders', 'ee-nav-button')}
|
|
658
|
-
<span class="ee-pane-title">${this.escapeHtml(folder ? folder
|
|
1310
|
+
<span class="ee-pane-title">${this.escapeHtml(folder ? folderDisplayName(folder) : 'Messages')}</span>
|
|
659
1311
|
</div>
|
|
660
|
-
${controls}
|
|
661
1312
|
</div>
|
|
662
1313
|
`;
|
|
663
1314
|
}
|
|
@@ -698,12 +1349,37 @@ export class EmailEngineClient {
|
|
|
698
1349
|
const diff = now - date;
|
|
699
1350
|
|
|
700
1351
|
if (diff < 86400000) {
|
|
701
|
-
return date.toLocaleTimeString([], { hour: '
|
|
1352
|
+
return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
702
1353
|
} else if (diff < 604800000) {
|
|
703
|
-
return date.toLocaleDateString([], { weekday: 'short', hour: '
|
|
704
|
-
} else {
|
|
1354
|
+
return date.toLocaleDateString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' });
|
|
1355
|
+
} else if (date.getFullYear() === now.getFullYear()) {
|
|
705
1356
|
return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
|
|
706
1357
|
}
|
|
1358
|
+
return date.toLocaleDateString([], { year: 'numeric', month: 'short', day: 'numeric' });
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// The date in the message header: weekday, date and time to the minute
|
|
1362
|
+
formatFullDate(dateStr) {
|
|
1363
|
+
const date = new Date(dateStr);
|
|
1364
|
+
if (isNaN(date.getTime())) {
|
|
1365
|
+
return '';
|
|
1366
|
+
}
|
|
1367
|
+
return date.toLocaleString(undefined, { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// Header addresses as escaped HTML: "Name <address>" with the address muted, the bare address
|
|
1371
|
+
// when there is no name, and the name alone for a name-only entry
|
|
1372
|
+
_addressListHtml(list) {
|
|
1373
|
+
return (Array.isArray(list) ? list : list ? [list] : [])
|
|
1374
|
+
.map(entry => (typeof entry === 'string' ? { address: entry } : entry))
|
|
1375
|
+
.filter(entry => entry && (entry.name || entry.address))
|
|
1376
|
+
.map(entry => {
|
|
1377
|
+
if (entry.name && entry.address) {
|
|
1378
|
+
return `${this.escapeHtml(entry.name)} <span class="ee-address"><${this.escapeHtml(entry.address)}></span>`;
|
|
1379
|
+
}
|
|
1380
|
+
return this.escapeHtml(entry.name || entry.address);
|
|
1381
|
+
})
|
|
1382
|
+
.join(', ');
|
|
707
1383
|
}
|
|
708
1384
|
|
|
709
1385
|
formatFileSize(bytes) {
|
|
@@ -794,11 +1470,7 @@ export class EmailEngineClient {
|
|
|
794
1470
|
}
|
|
795
1471
|
|
|
796
1472
|
escapeHtml(value) {
|
|
797
|
-
|
|
798
|
-
return '';
|
|
799
|
-
}
|
|
800
|
-
const htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
|
|
801
|
-
return String(value).replace(/[&<>"']/g, ch => htmlEscapes[ch]);
|
|
1473
|
+
return escapeHtml(value);
|
|
802
1474
|
}
|
|
803
1475
|
|
|
804
1476
|
_authHeaders() {
|
|
@@ -856,6 +1528,7 @@ export class EmailEngineClient {
|
|
|
856
1528
|
this._saveBlob(blob, filename);
|
|
857
1529
|
} catch (error) {
|
|
858
1530
|
console.error('Failed to download attachment:', error);
|
|
1531
|
+
this._reportError(error, 'download', 'Failed to download the attachment');
|
|
859
1532
|
this.alertMethod(this._errorMessage(error, 'Failed to download attachment. Please try again.'), 'Download Error', null, 'OK');
|
|
860
1533
|
}
|
|
861
1534
|
}
|
|
@@ -876,6 +1549,7 @@ export class EmailEngineClient {
|
|
|
876
1549
|
this._saveBlob(blob, filename);
|
|
877
1550
|
} catch (error) {
|
|
878
1551
|
console.error('Failed to download original message:', error);
|
|
1552
|
+
this._reportError(error, 'download', 'Failed to download the original message');
|
|
879
1553
|
this.alertMethod(this._errorMessage(error, 'Failed to download original message. Please try again.'), 'Download Error', null, 'OK');
|
|
880
1554
|
}
|
|
881
1555
|
}
|
|
@@ -898,6 +1572,18 @@ export class EmailEngineClient {
|
|
|
898
1572
|
}
|
|
899
1573
|
|
|
900
1574
|
const style = this._createStyle(`
|
|
1575
|
+
/* The accent comes from the host's --ee-accent, --ee-accent-hover and --ee-accent-light
|
|
1576
|
+
(set on the container). They are resolved into private names once per root
|
|
1577
|
+
element: setting --ee-accent itself here would hide the host's value. */
|
|
1578
|
+
.ee-client,
|
|
1579
|
+
.ee-compose-button,
|
|
1580
|
+
.ee-compose,
|
|
1581
|
+
.ee-toast {
|
|
1582
|
+
--_accent: var(--ee-accent, #007bff);
|
|
1583
|
+
--_accent-hover: var(--ee-accent-hover, #0056b3);
|
|
1584
|
+
--_accent-light: var(--ee-accent-light, #66b2ff);
|
|
1585
|
+
}
|
|
1586
|
+
|
|
901
1587
|
.ee-client {
|
|
902
1588
|
--ee-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
903
1589
|
display: flex;
|
|
@@ -931,66 +1617,80 @@ export class EmailEngineClient {
|
|
|
931
1617
|
.ee-folder-list {
|
|
932
1618
|
list-style: none;
|
|
933
1619
|
margin: 0;
|
|
934
|
-
padding:
|
|
1620
|
+
padding: 6px 8px;
|
|
1621
|
+
display: flex;
|
|
1622
|
+
flex-direction: column;
|
|
1623
|
+
gap: 1px;
|
|
935
1624
|
}
|
|
936
|
-
|
|
1625
|
+
|
|
937
1626
|
.ee-folder-item {
|
|
938
|
-
cursor: pointer;
|
|
939
|
-
border-bottom: 1px solid #e0e0e0;
|
|
940
1627
|
position: relative;
|
|
941
1628
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
background: #e8e8e8;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
.ee-folder-item.active {
|
|
948
|
-
background: #007bff;
|
|
949
|
-
color: white;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
.ee-folder-item.active::before {
|
|
953
|
-
content: '';
|
|
954
|
-
position: absolute;
|
|
955
|
-
left: 0;
|
|
956
|
-
top: 0;
|
|
957
|
-
bottom: 0;
|
|
958
|
-
width: 3px;
|
|
959
|
-
background: #0056b3;
|
|
960
|
-
}
|
|
961
|
-
|
|
1629
|
+
|
|
1630
|
+
/* The whole row is the button */
|
|
962
1631
|
.ee-folder-content {
|
|
963
|
-
padding: 8px 16px 8px 0px;
|
|
964
1632
|
display: flex;
|
|
965
1633
|
align-items: center;
|
|
966
|
-
|
|
1634
|
+
gap: 10px;
|
|
1635
|
+
width: 100%;
|
|
1636
|
+
min-height: 34px;
|
|
1637
|
+
padding: 6px 10px 6px 12px;
|
|
1638
|
+
border: none;
|
|
1639
|
+
border-radius: 6px;
|
|
1640
|
+
background: transparent;
|
|
1641
|
+
color: inherit;
|
|
1642
|
+
font: inherit;
|
|
1643
|
+
text-align: left;
|
|
1644
|
+
cursor: pointer;
|
|
967
1645
|
}
|
|
968
|
-
|
|
969
|
-
.ee-folder-
|
|
970
|
-
|
|
971
|
-
font-size: 12px;
|
|
972
|
-
margin-right: 4px;
|
|
973
|
-
font-family: monospace;
|
|
1646
|
+
|
|
1647
|
+
.ee-folder-content:hover {
|
|
1648
|
+
background: #eef1f4;
|
|
974
1649
|
}
|
|
975
|
-
|
|
976
|
-
.ee-folder-
|
|
977
|
-
|
|
978
|
-
|
|
1650
|
+
|
|
1651
|
+
.ee-folder-content:focus-visible,
|
|
1652
|
+
.ee-message-item:focus-visible,
|
|
1653
|
+
.ee-attachment-item:focus-visible {
|
|
1654
|
+
outline: 2px solid var(--_accent);
|
|
1655
|
+
outline-offset: -2px;
|
|
979
1656
|
}
|
|
980
|
-
|
|
981
|
-
.ee-folder-
|
|
1657
|
+
|
|
1658
|
+
.ee-folder-item.active .ee-folder-content {
|
|
1659
|
+
background: color-mix(in srgb, var(--_accent) 14%, white);
|
|
1660
|
+
color: var(--_accent-hover);
|
|
982
1661
|
font-weight: 600;
|
|
983
1662
|
}
|
|
984
|
-
|
|
985
|
-
.ee-folder-
|
|
986
|
-
|
|
1663
|
+
|
|
1664
|
+
.ee-folder-icon {
|
|
1665
|
+
display: inline-flex;
|
|
1666
|
+
flex-shrink: 0;
|
|
1667
|
+
color: #6b7280;
|
|
987
1668
|
}
|
|
988
|
-
|
|
989
|
-
.ee-folder-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1669
|
+
|
|
1670
|
+
.ee-folder-item.active .ee-folder-icon {
|
|
1671
|
+
color: inherit;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
.ee-folder-name {
|
|
1675
|
+
flex: 1;
|
|
1676
|
+
min-width: 0;
|
|
1677
|
+
overflow: hidden;
|
|
1678
|
+
text-overflow: ellipsis;
|
|
1679
|
+
white-space: nowrap;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
.ee-folder-count {
|
|
993
1683
|
flex-shrink: 0;
|
|
1684
|
+
min-width: 20px;
|
|
1685
|
+
padding: 0 6px;
|
|
1686
|
+
border-radius: 10px;
|
|
1687
|
+
background: var(--_accent);
|
|
1688
|
+
color: white;
|
|
1689
|
+
font-size: 11px;
|
|
1690
|
+
font-weight: 600;
|
|
1691
|
+
line-height: 18px;
|
|
1692
|
+
text-align: center;
|
|
1693
|
+
font-variant-numeric: tabular-nums;
|
|
994
1694
|
}
|
|
995
1695
|
|
|
996
1696
|
.ee-main {
|
|
@@ -1009,49 +1709,76 @@ export class EmailEngineClient {
|
|
|
1009
1709
|
flex-direction: column;
|
|
1010
1710
|
}
|
|
1011
1711
|
|
|
1712
|
+
/* A list row is a button holding spans laid out as blocks */
|
|
1012
1713
|
.ee-message-item {
|
|
1013
|
-
|
|
1714
|
+
display: block;
|
|
1715
|
+
width: 100%;
|
|
1716
|
+
padding: 10px 16px 10px 24px;
|
|
1717
|
+
border: none;
|
|
1014
1718
|
border-bottom: 1px solid #e0e0e0;
|
|
1719
|
+
background: transparent;
|
|
1720
|
+
color: inherit;
|
|
1721
|
+
font: inherit;
|
|
1722
|
+
text-align: left;
|
|
1015
1723
|
cursor: pointer;
|
|
1724
|
+
position: relative;
|
|
1016
1725
|
}
|
|
1017
|
-
|
|
1726
|
+
|
|
1018
1727
|
.ee-message-item:hover {
|
|
1019
1728
|
background: #f8f8f8;
|
|
1020
1729
|
}
|
|
1021
|
-
|
|
1730
|
+
|
|
1022
1731
|
.ee-message-item.active {
|
|
1023
|
-
background:
|
|
1732
|
+
background: color-mix(in srgb, var(--_accent) 12%, white);
|
|
1024
1733
|
}
|
|
1025
|
-
|
|
1026
|
-
.ee-message-item.unread
|
|
1734
|
+
|
|
1735
|
+
.ee-message-item.unread .ee-message-from,
|
|
1736
|
+
.ee-message-item.unread .ee-message-subject-text {
|
|
1027
1737
|
font-weight: 600;
|
|
1028
1738
|
}
|
|
1029
|
-
|
|
1739
|
+
|
|
1740
|
+
.ee-unread-dot {
|
|
1741
|
+
position: absolute;
|
|
1742
|
+
left: 9px;
|
|
1743
|
+
top: 17px;
|
|
1744
|
+
width: 8px;
|
|
1745
|
+
height: 8px;
|
|
1746
|
+
border-radius: 50%;
|
|
1747
|
+
background: var(--_accent);
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1030
1750
|
.ee-message-header {
|
|
1031
1751
|
display: flex;
|
|
1032
1752
|
justify-content: space-between;
|
|
1033
|
-
margin-bottom:
|
|
1753
|
+
margin-bottom: 2px;
|
|
1034
1754
|
}
|
|
1035
|
-
|
|
1755
|
+
|
|
1036
1756
|
.ee-message-from {
|
|
1037
1757
|
flex: 1;
|
|
1038
1758
|
overflow: hidden;
|
|
1039
1759
|
text-overflow: ellipsis;
|
|
1040
1760
|
white-space: nowrap;
|
|
1041
1761
|
}
|
|
1042
|
-
|
|
1762
|
+
|
|
1763
|
+
.ee-message-to-label {
|
|
1764
|
+
color: #666;
|
|
1765
|
+
font-weight: 400;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1043
1768
|
.ee-message-date {
|
|
1044
1769
|
font-size: 12px;
|
|
1045
1770
|
color: #666;
|
|
1046
1771
|
flex-shrink: 0;
|
|
1047
1772
|
margin-left: 8px;
|
|
1773
|
+
font-variant-numeric: tabular-nums;
|
|
1048
1774
|
}
|
|
1049
|
-
|
|
1775
|
+
|
|
1050
1776
|
.ee-message-subject {
|
|
1051
1777
|
display: flex;
|
|
1052
1778
|
align-items: center;
|
|
1053
|
-
|
|
1779
|
+
color: #444;
|
|
1054
1780
|
}
|
|
1781
|
+
|
|
1055
1782
|
|
|
1056
1783
|
.ee-message-subject-text {
|
|
1057
1784
|
overflow: hidden;
|
|
@@ -1062,6 +1789,8 @@ export class EmailEngineClient {
|
|
|
1062
1789
|
}
|
|
1063
1790
|
|
|
1064
1791
|
.ee-message-preview {
|
|
1792
|
+
display: block;
|
|
1793
|
+
margin-top: 2px;
|
|
1065
1794
|
font-size: 12px;
|
|
1066
1795
|
color: #666;
|
|
1067
1796
|
overflow: hidden;
|
|
@@ -1071,14 +1800,42 @@ export class EmailEngineClient {
|
|
|
1071
1800
|
}
|
|
1072
1801
|
|
|
1073
1802
|
.ee-attachment-indicator {
|
|
1074
|
-
display: inline-
|
|
1803
|
+
display: inline-flex;
|
|
1804
|
+
align-items: center;
|
|
1805
|
+
white-space: nowrap;
|
|
1806
|
+
flex-shrink: 0;
|
|
1075
1807
|
font-size: 11px;
|
|
1076
1808
|
color: #666;
|
|
1077
1809
|
margin-left: 8px;
|
|
1078
1810
|
}
|
|
1079
1811
|
|
|
1080
|
-
.ee-attachment-indicator
|
|
1081
|
-
|
|
1812
|
+
.ee-attachment-indicator .ee-icon {
|
|
1813
|
+
margin-right: 2px;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/* Replied / forwarded markers, from the message flags (see _responseMarkers) */
|
|
1817
|
+
.ee-response-marker {
|
|
1818
|
+
display: inline-flex;
|
|
1819
|
+
align-items: center;
|
|
1820
|
+
gap: 4px;
|
|
1821
|
+
color: #666;
|
|
1822
|
+
margin-right: 6px;
|
|
1823
|
+
flex-shrink: 0;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
.ee-message-title-markers {
|
|
1827
|
+
display: flex;
|
|
1828
|
+
gap: 4px;
|
|
1829
|
+
margin: -8px 0 12px;
|
|
1830
|
+
font-size: 12px;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
.ee-message-title-markers:empty {
|
|
1834
|
+
display: none;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
.ee-dark-mode .ee-response-marker {
|
|
1838
|
+
color: #999;
|
|
1082
1839
|
}
|
|
1083
1840
|
|
|
1084
1841
|
.ee-message-viewer {
|
|
@@ -1134,7 +1891,7 @@ export class EmailEngineClient {
|
|
|
1134
1891
|
.ee-button:focus-visible,
|
|
1135
1892
|
.ee-move-button:focus-within,
|
|
1136
1893
|
.ee-compose-button:focus-visible {
|
|
1137
|
-
outline: 2px solid
|
|
1894
|
+
outline: 2px solid var(--_accent);
|
|
1138
1895
|
outline-offset: 1px;
|
|
1139
1896
|
}
|
|
1140
1897
|
|
|
@@ -1164,13 +1921,13 @@ export class EmailEngineClient {
|
|
|
1164
1921
|
}
|
|
1165
1922
|
|
|
1166
1923
|
.ee-button-primary {
|
|
1167
|
-
background:
|
|
1168
|
-
border-color:
|
|
1924
|
+
background: var(--_accent);
|
|
1925
|
+
border-color: var(--_accent);
|
|
1169
1926
|
color: white;
|
|
1170
1927
|
}
|
|
1171
1928
|
|
|
1172
1929
|
.ee-button-primary:hover:not(:disabled) {
|
|
1173
|
-
background:
|
|
1930
|
+
background: var(--_accent-hover);
|
|
1174
1931
|
}
|
|
1175
1932
|
|
|
1176
1933
|
.ee-button-danger:hover:not(:disabled) {
|
|
@@ -1204,9 +1961,7 @@ export class EmailEngineClient {
|
|
|
1204
1961
|
|
|
1205
1962
|
.ee-message-content {
|
|
1206
1963
|
flex: 1;
|
|
1207
|
-
|
|
1208
|
-
the floating compose button */
|
|
1209
|
-
padding: 20px 20px 88px;
|
|
1964
|
+
padding: 20px;
|
|
1210
1965
|
overflow-y: auto;
|
|
1211
1966
|
}
|
|
1212
1967
|
|
|
@@ -1238,7 +1993,7 @@ export class EmailEngineClient {
|
|
|
1238
1993
|
.ee-otp {
|
|
1239
1994
|
margin-bottom: 16px;
|
|
1240
1995
|
padding: 14px 16px;
|
|
1241
|
-
background:
|
|
1996
|
+
background: color-mix(in srgb, var(--_accent) 7%, white);
|
|
1242
1997
|
border-radius: 8px;
|
|
1243
1998
|
}
|
|
1244
1999
|
|
|
@@ -1291,14 +2046,14 @@ export class EmailEngineClient {
|
|
|
1291
2046
|
height: 32px;
|
|
1292
2047
|
padding: 0 16px;
|
|
1293
2048
|
font-size: 13px;
|
|
1294
|
-
background:
|
|
1295
|
-
border-color:
|
|
2049
|
+
background: var(--_accent);
|
|
2050
|
+
border-color: var(--_accent);
|
|
1296
2051
|
color: white;
|
|
1297
2052
|
border-radius: 16px;
|
|
1298
2053
|
}
|
|
1299
2054
|
|
|
1300
2055
|
.ee-otp .ee-otp-copy:hover:not(:disabled) {
|
|
1301
|
-
background:
|
|
2056
|
+
background: var(--_accent-hover);
|
|
1302
2057
|
}
|
|
1303
2058
|
|
|
1304
2059
|
.ee-otp-status,
|
|
@@ -1327,41 +2082,71 @@ export class EmailEngineClient {
|
|
|
1327
2082
|
margin-bottom: 8px;
|
|
1328
2083
|
color: #333;
|
|
1329
2084
|
}
|
|
1330
|
-
|
|
2085
|
+
|
|
2086
|
+
.ee-attachment-grid {
|
|
2087
|
+
display: grid;
|
|
2088
|
+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
2089
|
+
gap: 8px;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
1331
2092
|
.ee-attachment-item {
|
|
1332
2093
|
display: flex;
|
|
1333
2094
|
align-items: center;
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
2095
|
+
gap: 10px;
|
|
2096
|
+
min-width: 0;
|
|
2097
|
+
padding: 8px 10px;
|
|
2098
|
+
background: #f8f9fa;
|
|
1337
2099
|
border: 1px solid #e0e0e0;
|
|
1338
|
-
border-radius:
|
|
2100
|
+
border-radius: 6px;
|
|
2101
|
+
color: inherit;
|
|
2102
|
+
font: inherit;
|
|
2103
|
+
text-align: left;
|
|
1339
2104
|
cursor: pointer;
|
|
1340
2105
|
transition: background 0.2s;
|
|
1341
2106
|
}
|
|
1342
|
-
|
|
2107
|
+
|
|
1343
2108
|
.ee-attachment-item:hover {
|
|
1344
|
-
background: #
|
|
2109
|
+
background: #eef1f4;
|
|
1345
2110
|
}
|
|
1346
|
-
|
|
1347
|
-
.ee-attachment-
|
|
1348
|
-
|
|
1349
|
-
|
|
2111
|
+
|
|
2112
|
+
.ee-attachment-type {
|
|
2113
|
+
flex-shrink: 0;
|
|
2114
|
+
width: 38px;
|
|
2115
|
+
padding: 6px 0;
|
|
2116
|
+
border-radius: 4px;
|
|
2117
|
+
background: color-mix(in srgb, var(--_accent) 12%, white);
|
|
2118
|
+
color: var(--_accent-hover);
|
|
2119
|
+
font-size: 10px;
|
|
2120
|
+
font-weight: 700;
|
|
2121
|
+
letter-spacing: 0.03em;
|
|
2122
|
+
text-align: center;
|
|
1350
2123
|
}
|
|
1351
|
-
|
|
2124
|
+
|
|
1352
2125
|
.ee-attachment-info {
|
|
2126
|
+
display: flex;
|
|
2127
|
+
flex-direction: column;
|
|
1353
2128
|
flex: 1;
|
|
2129
|
+
min-width: 0;
|
|
1354
2130
|
}
|
|
1355
|
-
|
|
2131
|
+
|
|
1356
2132
|
.ee-attachment-name {
|
|
1357
2133
|
font-weight: 500;
|
|
1358
2134
|
color: #333;
|
|
2135
|
+
overflow: hidden;
|
|
2136
|
+
text-overflow: ellipsis;
|
|
2137
|
+
white-space: nowrap;
|
|
1359
2138
|
}
|
|
1360
|
-
|
|
2139
|
+
|
|
1361
2140
|
.ee-attachment-size {
|
|
1362
2141
|
font-size: 12px;
|
|
1363
2142
|
color: #666;
|
|
1364
2143
|
}
|
|
2144
|
+
|
|
2145
|
+
.ee-attachment-download {
|
|
2146
|
+
display: inline-flex;
|
|
2147
|
+
flex-shrink: 0;
|
|
2148
|
+
color: #666;
|
|
2149
|
+
}
|
|
1365
2150
|
|
|
1366
2151
|
.ee-empty-state {
|
|
1367
2152
|
display: flex;
|
|
@@ -1456,18 +2241,30 @@ export class EmailEngineClient {
|
|
|
1456
2241
|
overflow-y: auto;
|
|
1457
2242
|
}
|
|
1458
2243
|
|
|
1459
|
-
|
|
2244
|
+
/* Paging, under the list: the position, the arrows and the page size */
|
|
2245
|
+
.ee-list-footer {
|
|
1460
2246
|
display: flex;
|
|
1461
|
-
gap: 6px;
|
|
1462
2247
|
align-items: center;
|
|
2248
|
+
gap: 6px;
|
|
1463
2249
|
flex-shrink: 0;
|
|
2250
|
+
padding: 6px 12px 6px 16px;
|
|
2251
|
+
border-top: 1px solid #e0e0e0;
|
|
2252
|
+
background: #f8f9fa;
|
|
1464
2253
|
}
|
|
1465
|
-
|
|
2254
|
+
|
|
2255
|
+
.ee-list-range {
|
|
2256
|
+
flex: 1;
|
|
2257
|
+
font-size: 12px;
|
|
2258
|
+
color: #666;
|
|
2259
|
+
font-variant-numeric: tabular-nums;
|
|
2260
|
+
white-space: nowrap;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
1466
2263
|
.ee-page-size-selector {
|
|
1467
2264
|
display: flex;
|
|
1468
2265
|
gap: 6px;
|
|
1469
2266
|
align-items: center;
|
|
1470
|
-
margin-left:
|
|
2267
|
+
margin-left: 6px;
|
|
1471
2268
|
}
|
|
1472
2269
|
|
|
1473
2270
|
.ee-page-size-label {
|
|
@@ -1482,7 +2279,6 @@ export class EmailEngineClient {
|
|
|
1482
2279
|
.ee-message-items {
|
|
1483
2280
|
flex: 1;
|
|
1484
2281
|
overflow-y: auto;
|
|
1485
|
-
padding-bottom: 88px;
|
|
1486
2282
|
}
|
|
1487
2283
|
|
|
1488
2284
|
.ee-compose-button {
|
|
@@ -1491,48 +2287,39 @@ export class EmailEngineClient {
|
|
|
1491
2287
|
right: 20px;
|
|
1492
2288
|
display: inline-flex;
|
|
1493
2289
|
align-items: center;
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
2290
|
+
justify-content: center;
|
|
2291
|
+
width: 56px;
|
|
2292
|
+
height: 56px;
|
|
2293
|
+
padding: 0;
|
|
2294
|
+
background: var(--_accent);
|
|
1498
2295
|
border: none;
|
|
1499
|
-
border-radius:
|
|
2296
|
+
border-radius: 50%;
|
|
1500
2297
|
color: white;
|
|
1501
|
-
font-family: var(--ee-font, inherit);
|
|
1502
|
-
font-size: 15px;
|
|
1503
|
-
font-weight: 600;
|
|
1504
2298
|
cursor: pointer;
|
|
1505
|
-
box-shadow: 0 4px 12px
|
|
2299
|
+
box-shadow: 0 4px 12px color-mix(in srgb, var(--_accent) 30%, transparent);
|
|
1506
2300
|
z-index: 1000;
|
|
1507
2301
|
transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
|
|
1508
2302
|
}
|
|
1509
2303
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
box-shadow: 0 6px 16px rgba(0,123,255,0.4);
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
.ee-compose-button.ee-compose-compact {
|
|
1517
|
-
width: 56px;
|
|
1518
|
-
height: 56px;
|
|
1519
|
-
padding: 0;
|
|
1520
|
-
justify-content: center;
|
|
1521
|
-
border-radius: 50%;
|
|
2304
|
+
/* An open message on a phone has its own reply actions; the button would cover the text */
|
|
2305
|
+
.ee-client[data-view="message"] ~ .ee-compose-button {
|
|
2306
|
+
display: none;
|
|
1522
2307
|
}
|
|
1523
2308
|
|
|
1524
|
-
.ee-compose-
|
|
1525
|
-
|
|
2309
|
+
.ee-compose-button:hover {
|
|
2310
|
+
background: var(--_accent-hover);
|
|
2311
|
+
transform: translateY(-1px);
|
|
2312
|
+
box-shadow: 0 6px 16px color-mix(in srgb, var(--_accent) 40%, transparent);
|
|
1526
2313
|
}
|
|
1527
2314
|
|
|
1528
2315
|
/* Medium widths: the viewer is too narrow for labelled buttons, so the
|
|
1529
2316
|
toolbar goes icon-only, as webmail toolbars usually are */
|
|
1530
|
-
@container ee-viewer (max-width:
|
|
1531
|
-
.ee-message-actions .ee-button:not(.ee-keep-label) .ee-button-label {
|
|
2317
|
+
@container ee-viewer (max-width: 699px) {
|
|
2318
|
+
.ee-message-actions .ee-button:not(.ee-keep-label):not(.ee-label-priority) .ee-button-label {
|
|
1532
2319
|
display: none;
|
|
1533
2320
|
}
|
|
1534
2321
|
|
|
1535
|
-
.ee-message-actions .ee-button:not(.ee-keep-label) {
|
|
2322
|
+
.ee-message-actions .ee-button:not(.ee-keep-label):not(.ee-label-priority) {
|
|
1536
2323
|
width: 30px;
|
|
1537
2324
|
padding: 0;
|
|
1538
2325
|
}
|
|
@@ -1543,6 +2330,22 @@ export class EmailEngineClient {
|
|
|
1543
2330
|
}
|
|
1544
2331
|
}
|
|
1545
2332
|
|
|
2333
|
+
/* Below this even the reply group goes icon-only */
|
|
2334
|
+
@container ee-viewer (max-width: 439px) {
|
|
2335
|
+
.ee-message-actions .ee-label-priority .ee-button-label {
|
|
2336
|
+
display: none;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
.ee-message-actions .ee-label-priority {
|
|
2340
|
+
width: 30px;
|
|
2341
|
+
padding: 0;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
.ee-toolbar-divider {
|
|
2345
|
+
display: none;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
|
|
1546
2349
|
/* Narrow widths: one pane at a time, in the order a phone mail app uses
|
|
1547
2350
|
(folders, list, message), with back buttons in the pane headers. The
|
|
1548
2351
|
shown pane follows data-view on .ee-client. */
|
|
@@ -1569,185 +2372,554 @@ export class EmailEngineClient {
|
|
|
1569
2372
|
.ee-message-content {
|
|
1570
2373
|
padding: 16px 16px 88px;
|
|
1571
2374
|
}
|
|
2375
|
+
|
|
2376
|
+
.ee-message-items {
|
|
2377
|
+
padding-bottom: 88px;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
/* the floating button is the Compose button here */
|
|
2381
|
+
.ee-sidebar-compose {
|
|
2382
|
+
display: none;
|
|
2383
|
+
}
|
|
1572
2384
|
}
|
|
1573
2385
|
|
|
1574
|
-
|
|
1575
|
-
|
|
2386
|
+
/* Compose: a panel docked to the bottom right of the window, without a backdrop, so the
|
|
2387
|
+
message being answered stays readable and the list stays usable. It fills the screen
|
|
2388
|
+
on a phone. The outer element only positions the panel. */
|
|
2389
|
+
.ee-compose {
|
|
1576
2390
|
position: fixed;
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
width: 100%;
|
|
1580
|
-
height: 100%;
|
|
1581
|
-
background: rgba(0, 0, 0, 0.5);
|
|
2391
|
+
right: 24px;
|
|
2392
|
+
bottom: 0;
|
|
1582
2393
|
z-index: 2000;
|
|
2394
|
+
font-family: var(--ee-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
|
|
2395
|
+
font-size: 14px;
|
|
2396
|
+
line-height: 1.5;
|
|
2397
|
+
color: #333;
|
|
1583
2398
|
}
|
|
1584
|
-
|
|
1585
|
-
.ee-compose
|
|
1586
|
-
|
|
1587
|
-
align-items: center;
|
|
1588
|
-
justify-content: center;
|
|
2399
|
+
|
|
2400
|
+
.ee-compose * {
|
|
2401
|
+
box-sizing: border-box;
|
|
1589
2402
|
}
|
|
1590
|
-
|
|
2403
|
+
|
|
1591
2404
|
.ee-compose-dialog {
|
|
1592
|
-
background: white;
|
|
1593
|
-
border-radius: 8px;
|
|
1594
|
-
width: 90%;
|
|
1595
|
-
max-width: 600px;
|
|
1596
|
-
max-height: 80vh;
|
|
1597
|
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
1598
2405
|
display: flex;
|
|
1599
2406
|
flex-direction: column;
|
|
2407
|
+
width: min(600px, calc(100vw - 48px));
|
|
2408
|
+
height: min(680px, calc(100vh - 32px));
|
|
2409
|
+
background: white;
|
|
2410
|
+
border: 1px solid #d5dbe3;
|
|
2411
|
+
border-bottom: none;
|
|
2412
|
+
border-radius: 10px 10px 0 0;
|
|
2413
|
+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
|
|
2414
|
+
overflow: hidden;
|
|
1600
2415
|
}
|
|
1601
|
-
|
|
2416
|
+
|
|
2417
|
+
/* Minimizing is for the docked panel; on a phone the form is the whole screen */
|
|
2418
|
+
@media (min-width: 701px) {
|
|
2419
|
+
.ee-compose-dialog.minimized {
|
|
2420
|
+
width: 300px;
|
|
2421
|
+
height: auto;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
.ee-compose-dialog.minimized > :not(.ee-compose-header) {
|
|
2425
|
+
display: none;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
.ee-compose-dialog.minimized .ee-compose-header {
|
|
2429
|
+
cursor: pointer;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
.ee-compose-window-button > span {
|
|
2434
|
+
display: inline-flex;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
.ee-compose-dialog:not(.minimized) .ee-when-minimized,
|
|
2438
|
+
.ee-compose-dialog.minimized .ee-when-open {
|
|
2439
|
+
display: none;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
1602
2442
|
.ee-compose-header {
|
|
1603
|
-
padding: 16px 20px;
|
|
1604
|
-
border-bottom: 1px solid #e0e0e0;
|
|
1605
2443
|
display: flex;
|
|
1606
|
-
justify-content: space-between;
|
|
1607
2444
|
align-items: center;
|
|
2445
|
+
gap: 4px;
|
|
1608
2446
|
flex-shrink: 0;
|
|
2447
|
+
padding: 8px 8px 8px 16px;
|
|
2448
|
+
background: #2b3440;
|
|
2449
|
+
color: #fff;
|
|
1609
2450
|
}
|
|
1610
|
-
|
|
2451
|
+
|
|
1611
2452
|
.ee-compose-title {
|
|
1612
|
-
|
|
1613
|
-
|
|
2453
|
+
flex: 1;
|
|
2454
|
+
min-width: 0;
|
|
1614
2455
|
margin: 0;
|
|
2456
|
+
font-size: 14px;
|
|
2457
|
+
font-weight: 600;
|
|
2458
|
+
overflow: hidden;
|
|
2459
|
+
text-overflow: ellipsis;
|
|
2460
|
+
white-space: nowrap;
|
|
1615
2461
|
}
|
|
1616
|
-
|
|
1617
|
-
.ee-compose-
|
|
1618
|
-
|
|
1619
|
-
border: none;
|
|
1620
|
-
font-size: 24px;
|
|
1621
|
-
color: #666;
|
|
1622
|
-
cursor: pointer;
|
|
1623
|
-
padding: 0;
|
|
1624
|
-
width: 30px;
|
|
1625
|
-
height: 30px;
|
|
1626
|
-
border-radius: 50%;
|
|
1627
|
-
display: flex;
|
|
2462
|
+
|
|
2463
|
+
.ee-compose-window-button {
|
|
2464
|
+
display: inline-flex;
|
|
1628
2465
|
align-items: center;
|
|
1629
2466
|
justify-content: center;
|
|
2467
|
+
width: 28px;
|
|
2468
|
+
height: 28px;
|
|
2469
|
+
padding: 0;
|
|
2470
|
+
border: none;
|
|
2471
|
+
border-radius: 6px;
|
|
2472
|
+
background: transparent;
|
|
2473
|
+
color: rgba(255, 255, 255, 0.85);
|
|
2474
|
+
cursor: pointer;
|
|
1630
2475
|
}
|
|
1631
|
-
|
|
1632
|
-
.ee-compose-
|
|
1633
|
-
background:
|
|
2476
|
+
|
|
2477
|
+
.ee-compose-window-button:hover {
|
|
2478
|
+
background: rgba(255, 255, 255, 0.15);
|
|
2479
|
+
color: #fff;
|
|
1634
2480
|
}
|
|
1635
|
-
|
|
2481
|
+
|
|
1636
2482
|
.ee-compose-form {
|
|
1637
|
-
padding: 20px;
|
|
1638
2483
|
display: flex;
|
|
1639
2484
|
flex-direction: column;
|
|
1640
|
-
gap: 16px;
|
|
1641
2485
|
flex: 1;
|
|
2486
|
+
min-height: 0;
|
|
1642
2487
|
overflow-y: auto;
|
|
2488
|
+
padding: 4px 16px 12px;
|
|
1643
2489
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
2490
|
+
|
|
2491
|
+
/* One line per header field, the label beside its input and a rule under it, as mail
|
|
2492
|
+
clients lay out their compose headers */
|
|
2493
|
+
.ee-compose-row {
|
|
1646
2494
|
display: flex;
|
|
1647
|
-
|
|
1648
|
-
gap:
|
|
2495
|
+
align-items: center;
|
|
2496
|
+
gap: 10px;
|
|
2497
|
+
border-bottom: 1px solid #e5e8ec;
|
|
1649
2498
|
}
|
|
1650
|
-
|
|
2499
|
+
|
|
1651
2500
|
.ee-compose-label {
|
|
1652
|
-
|
|
1653
|
-
|
|
2501
|
+
flex: 0 0 52px;
|
|
2502
|
+
font-size: 13px;
|
|
2503
|
+
color: #666;
|
|
1654
2504
|
}
|
|
1655
|
-
|
|
2505
|
+
|
|
1656
2506
|
.ee-compose-input {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
2507
|
+
flex: 1;
|
|
2508
|
+
min-width: 0;
|
|
2509
|
+
padding: 10px 0;
|
|
2510
|
+
border: none;
|
|
2511
|
+
background: transparent;
|
|
2512
|
+
color: inherit;
|
|
2513
|
+
font: inherit;
|
|
1662
2514
|
}
|
|
1663
|
-
|
|
2515
|
+
|
|
1664
2516
|
.ee-compose-input:focus {
|
|
1665
2517
|
outline: none;
|
|
1666
|
-
border-color: #007bff;
|
|
1667
|
-
box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
|
|
1668
2518
|
}
|
|
1669
|
-
|
|
1670
|
-
.ee-compose-
|
|
1671
|
-
|
|
1672
|
-
border: 1px solid #ddd;
|
|
1673
|
-
border-radius: 4px;
|
|
1674
|
-
font-size: 14px;
|
|
1675
|
-
font-family: inherit;
|
|
1676
|
-
resize: vertical;
|
|
1677
|
-
min-height: 200px;
|
|
2519
|
+
|
|
2520
|
+
.ee-compose-row:focus-within {
|
|
2521
|
+
border-bottom-color: var(--_accent);
|
|
1678
2522
|
}
|
|
1679
|
-
|
|
1680
|
-
.ee-compose-
|
|
2523
|
+
|
|
2524
|
+
.ee-compose-row:has([aria-invalid="true"]) {
|
|
2525
|
+
border-bottom-color: #dc3545;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
.ee-compose-toolbar {
|
|
2529
|
+
display: flex;
|
|
2530
|
+
gap: 2px;
|
|
2531
|
+
padding: 6px 0;
|
|
2532
|
+
border-bottom: 1px solid #e5e8ec;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
.ee-compose-format,
|
|
2536
|
+
.ee-compose-icon-button {
|
|
2537
|
+
display: inline-flex;
|
|
2538
|
+
align-items: center;
|
|
2539
|
+
justify-content: center;
|
|
2540
|
+
width: 30px;
|
|
2541
|
+
height: 30px;
|
|
2542
|
+
padding: 0;
|
|
2543
|
+
border: none;
|
|
2544
|
+
border-radius: 6px;
|
|
2545
|
+
background: transparent;
|
|
2546
|
+
color: #555;
|
|
2547
|
+
cursor: pointer;
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
.ee-compose-format:hover,
|
|
2551
|
+
.ee-compose-icon-button:hover {
|
|
2552
|
+
background: #eef1f4;
|
|
2553
|
+
color: #222;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
.ee-compose-format[aria-pressed="true"] {
|
|
2557
|
+
background: color-mix(in srgb, var(--_accent) 14%, white);
|
|
2558
|
+
color: var(--_accent-hover);
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
.ee-compose-linkbar {
|
|
2562
|
+
display: flex;
|
|
2563
|
+
align-items: center;
|
|
2564
|
+
gap: 8px;
|
|
2565
|
+
padding: 6px 0;
|
|
2566
|
+
border-bottom: 1px solid #e5e8ec;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
.ee-compose-linkbar .ee-compose-input {
|
|
2570
|
+
padding: 6px 8px;
|
|
2571
|
+
border: 1px solid #d5dbe3;
|
|
2572
|
+
border-radius: 6px;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
.ee-compose-small-button {
|
|
2576
|
+
flex-shrink: 0;
|
|
2577
|
+
padding: 6px 10px;
|
|
2578
|
+
border: 1px solid #d5dbe3;
|
|
2579
|
+
border-radius: 6px;
|
|
2580
|
+
background: white;
|
|
2581
|
+
color: inherit;
|
|
2582
|
+
font: inherit;
|
|
2583
|
+
font-size: 13px;
|
|
2584
|
+
cursor: pointer;
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
.ee-compose-small-button:hover {
|
|
2588
|
+
background: #eef1f4;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
.ee-compose-editor {
|
|
2592
|
+
position: relative;
|
|
2593
|
+
flex: 1 0 auto;
|
|
2594
|
+
min-height: 160px;
|
|
2595
|
+
padding: 12px 0;
|
|
1681
2596
|
outline: none;
|
|
1682
|
-
|
|
1683
|
-
|
|
2597
|
+
overflow-wrap: break-word;
|
|
2598
|
+
cursor: text;
|
|
1684
2599
|
}
|
|
1685
|
-
|
|
2600
|
+
|
|
2601
|
+
.ee-compose-editor.ee-empty::before {
|
|
2602
|
+
content: attr(data-placeholder);
|
|
2603
|
+
color: #999;
|
|
2604
|
+
pointer-events: none;
|
|
2605
|
+
position: absolute;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
.ee-compose-editor p {
|
|
2609
|
+
margin: 0 0 0.8em;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
.ee-compose-editor blockquote {
|
|
2613
|
+
margin: 0 0 0.8em 0.4em;
|
|
2614
|
+
padding-left: 10px;
|
|
2615
|
+
border-left: 2px solid #ccc;
|
|
2616
|
+
color: #555;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
.ee-compose-editor a {
|
|
2620
|
+
color: var(--_accent);
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
.ee-compose-editor[aria-invalid="true"] {
|
|
2624
|
+
box-shadow: inset 0 -2px 0 #dc3545;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
/* Why the form did not go out, between the form and its buttons so it is on
|
|
2628
|
+
screen however far the form is scrolled */
|
|
2629
|
+
.ee-compose-error {
|
|
2630
|
+
margin: 0 16px 8px;
|
|
2631
|
+
padding: 8px 12px;
|
|
2632
|
+
border: 1px solid #fcc;
|
|
2633
|
+
border-radius: 6px;
|
|
2634
|
+
background: #fee;
|
|
2635
|
+
color: #c00;
|
|
2636
|
+
font-size: 13px;
|
|
2637
|
+
white-space: pre-line;
|
|
2638
|
+
flex-shrink: 0;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
1686
2641
|
.ee-compose-actions {
|
|
1687
|
-
padding: 16px 20px;
|
|
1688
|
-
border-top: 1px solid #e0e0e0;
|
|
1689
2642
|
display: flex;
|
|
1690
|
-
|
|
1691
|
-
|
|
2643
|
+
align-items: center;
|
|
2644
|
+
gap: 6px;
|
|
1692
2645
|
flex-shrink: 0;
|
|
2646
|
+
padding: 10px 16px;
|
|
2647
|
+
border-top: 1px solid #e5e8ec;
|
|
1693
2648
|
}
|
|
1694
|
-
|
|
2649
|
+
|
|
2650
|
+
|
|
1695
2651
|
.ee-compose-send {
|
|
1696
|
-
|
|
1697
|
-
color: white;
|
|
2652
|
+
padding: 8px 22px;
|
|
1698
2653
|
border: none;
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
font
|
|
2654
|
+
border-radius: 18px;
|
|
2655
|
+
background: var(--_accent);
|
|
2656
|
+
color: white;
|
|
2657
|
+
font: inherit;
|
|
2658
|
+
font-weight: 600;
|
|
1703
2659
|
cursor: pointer;
|
|
1704
2660
|
}
|
|
1705
|
-
|
|
2661
|
+
|
|
1706
2662
|
.ee-compose-send:hover:not(:disabled) {
|
|
1707
|
-
background:
|
|
2663
|
+
background: var(--_accent-hover);
|
|
1708
2664
|
}
|
|
1709
|
-
|
|
1710
|
-
.ee-compose-send:disabled
|
|
1711
|
-
|
|
2665
|
+
|
|
2666
|
+
.ee-compose-send:disabled,
|
|
2667
|
+
.ee-compose-save-draft:disabled {
|
|
1712
2668
|
cursor: not-allowed;
|
|
1713
2669
|
opacity: 0.6;
|
|
1714
2670
|
}
|
|
1715
|
-
|
|
1716
|
-
.ee-compose-
|
|
1717
|
-
|
|
1718
|
-
|
|
2671
|
+
|
|
2672
|
+
.ee-compose-save-draft {
|
|
2673
|
+
margin-left: auto;
|
|
2674
|
+
padding: 7px 14px;
|
|
2675
|
+
border: 1px solid #d5dbe3;
|
|
2676
|
+
border-radius: 18px;
|
|
2677
|
+
background: white;
|
|
2678
|
+
color: inherit;
|
|
2679
|
+
font: inherit;
|
|
2680
|
+
cursor: pointer;
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
.ee-compose-save-draft:hover:not(:disabled) {
|
|
2684
|
+
background: #eef1f4;
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
.ee-compose-format:focus-visible,
|
|
2688
|
+
.ee-compose-icon-button:focus-visible,
|
|
2689
|
+
.ee-compose-window-button:focus-visible,
|
|
2690
|
+
.ee-compose-send:focus-visible,
|
|
2691
|
+
.ee-compose-save-draft:focus-visible,
|
|
2692
|
+
.ee-compose-small-button:focus-visible,
|
|
2693
|
+
.ee-compose-quote-toggle:focus-visible,
|
|
2694
|
+
.ee-compose-chip-remove:focus-visible,
|
|
2695
|
+
.ee-compose-link:focus-visible {
|
|
2696
|
+
outline: 2px solid var(--_accent);
|
|
2697
|
+
outline-offset: 1px;
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
/* On a phone the form is the whole screen; minimizing it makes no sense there */
|
|
2701
|
+
@media (max-width: 700px) {
|
|
2702
|
+
.ee-compose {
|
|
2703
|
+
inset: 0;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
.ee-compose-dialog {
|
|
2707
|
+
width: 100%;
|
|
2708
|
+
height: 100%;
|
|
2709
|
+
border: none;
|
|
2710
|
+
border-radius: 0;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
.ee-compose [data-action="minimize"] {
|
|
2714
|
+
display: none;
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
.ee-sidebar-compose {
|
|
2719
|
+
padding: 12px;
|
|
2720
|
+
border-bottom: 1px solid #e0e0e0;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
.ee-sidebar-compose-button {
|
|
2724
|
+
display: flex;
|
|
2725
|
+
align-items: center;
|
|
2726
|
+
justify-content: center;
|
|
2727
|
+
gap: 8px;
|
|
2728
|
+
width: 100%;
|
|
2729
|
+
height: 38px;
|
|
1719
2730
|
border: none;
|
|
1720
|
-
|
|
1721
|
-
|
|
2731
|
+
border-radius: 6px;
|
|
2732
|
+
background: var(--_accent);
|
|
2733
|
+
color: white;
|
|
2734
|
+
font: inherit;
|
|
1722
2735
|
font-size: 14px;
|
|
2736
|
+
font-weight: 600;
|
|
1723
2737
|
cursor: pointer;
|
|
1724
2738
|
}
|
|
1725
2739
|
|
|
1726
|
-
.ee-compose-
|
|
1727
|
-
background:
|
|
2740
|
+
.ee-sidebar-compose-button:hover {
|
|
2741
|
+
background: var(--_accent-hover);
|
|
1728
2742
|
}
|
|
1729
2743
|
|
|
1730
|
-
.ee-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
2744
|
+
.ee-toolbar-divider {
|
|
2745
|
+
width: 1px;
|
|
2746
|
+
height: 20px;
|
|
2747
|
+
margin: 0 4px;
|
|
2748
|
+
background: #ddd;
|
|
2749
|
+
flex-shrink: 0;
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
.ee-address {
|
|
2753
|
+
color: #666;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/* A styled message on the light surface its colours were chosen for (see
|
|
2757
|
+
_renderMessageBody); plain messages follow the theme */
|
|
2758
|
+
.ee-dark-mode .ee-message-body[data-styled],
|
|
2759
|
+
.ee-dark-mode .ee-compose-quote-body[data-styled] {
|
|
2760
|
+
background: #ffffff;
|
|
2761
|
+
color: #222;
|
|
2762
|
+
padding: 12px;
|
|
2763
|
+
border-radius: 6px;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
.ee-toast {
|
|
2767
|
+
position: fixed;
|
|
2768
|
+
left: 50%;
|
|
2769
|
+
bottom: 24px;
|
|
2770
|
+
transform: translate(-50%, 16px);
|
|
2771
|
+
max-width: calc(100vw - 32px);
|
|
2772
|
+
padding: 10px 16px;
|
|
2773
|
+
border-radius: 6px;
|
|
2774
|
+
background: #323232;
|
|
2775
|
+
color: #fff;
|
|
2776
|
+
font-family: var(--ee-font, inherit);
|
|
1736
2777
|
font-size: 14px;
|
|
1737
|
-
|
|
2778
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
|
2779
|
+
opacity: 0;
|
|
2780
|
+
pointer-events: none;
|
|
2781
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
2782
|
+
z-index: 2100;
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
.ee-toast.show {
|
|
2786
|
+
opacity: 1;
|
|
2787
|
+
transform: translate(-50%, 0);
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
.ee-toast.ee-dark-mode {
|
|
2791
|
+
background: #e0e0e0;
|
|
2792
|
+
color: #1a1a1a;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
/* Parts of the compose form that come and go (Cc/Bcc, the link field, the quote) use
|
|
2796
|
+
the hidden attribute, which a display rule would otherwise override */
|
|
2797
|
+
.ee-compose [hidden],
|
|
2798
|
+
.ee-compose[hidden] {
|
|
2799
|
+
display: none !important;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
.ee-compose-link {
|
|
2803
|
+
flex-shrink: 0;
|
|
2804
|
+
background: none;
|
|
2805
|
+
border: none;
|
|
2806
|
+
padding: 4px 0;
|
|
2807
|
+
font: inherit;
|
|
2808
|
+
font-size: 13px;
|
|
2809
|
+
color: var(--_accent);
|
|
1738
2810
|
cursor: pointer;
|
|
1739
2811
|
}
|
|
1740
2812
|
|
|
1741
|
-
.ee-compose-
|
|
1742
|
-
|
|
1743
|
-
color: white;
|
|
2813
|
+
.ee-compose-link:hover {
|
|
2814
|
+
text-decoration: underline;
|
|
1744
2815
|
}
|
|
1745
2816
|
|
|
1746
|
-
.ee-compose-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
2817
|
+
.ee-compose-chips {
|
|
2818
|
+
display: flex;
|
|
2819
|
+
flex-wrap: wrap;
|
|
2820
|
+
gap: 6px;
|
|
2821
|
+
padding-bottom: 10px;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
.ee-compose-chips:empty {
|
|
2825
|
+
display: none;
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
.ee-compose-chip {
|
|
2829
|
+
display: inline-flex;
|
|
2830
|
+
align-items: center;
|
|
2831
|
+
gap: 6px;
|
|
2832
|
+
max-width: 100%;
|
|
2833
|
+
padding: 4px 4px 4px 10px;
|
|
2834
|
+
border: 1px solid #ddd;
|
|
2835
|
+
border-radius: 16px;
|
|
2836
|
+
background: #f8f9fa;
|
|
2837
|
+
font-size: 13px;
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
.ee-compose-chip-name {
|
|
2841
|
+
overflow: hidden;
|
|
2842
|
+
text-overflow: ellipsis;
|
|
2843
|
+
white-space: nowrap;
|
|
2844
|
+
min-width: 0;
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
.ee-compose-chip-size {
|
|
2848
|
+
color: #666;
|
|
2849
|
+
flex-shrink: 0;
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
.ee-compose-chip-remove {
|
|
2853
|
+
display: inline-flex;
|
|
2854
|
+
align-items: center;
|
|
2855
|
+
justify-content: center;
|
|
2856
|
+
width: 22px;
|
|
2857
|
+
height: 22px;
|
|
2858
|
+
padding: 0;
|
|
2859
|
+
border: none;
|
|
2860
|
+
border-radius: 50%;
|
|
2861
|
+
background: transparent;
|
|
2862
|
+
color: #666;
|
|
2863
|
+
cursor: pointer;
|
|
2864
|
+
flex-shrink: 0;
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
.ee-compose-chip-remove:hover {
|
|
2868
|
+
background: #e0e0e0;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
/* The message being answered or forwarded, behind a "..." toggle */
|
|
2872
|
+
.ee-compose-quote {
|
|
2873
|
+
display: flex;
|
|
2874
|
+
flex-direction: column;
|
|
2875
|
+
align-items: flex-start;
|
|
2876
|
+
gap: 8px;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
.ee-compose-quote-toggle {
|
|
2880
|
+
display: inline-flex;
|
|
2881
|
+
align-items: center;
|
|
2882
|
+
gap: 6px;
|
|
2883
|
+
padding: 2px 10px 2px 6px;
|
|
2884
|
+
border: 1px solid #d5dbe3;
|
|
2885
|
+
border-radius: 12px;
|
|
2886
|
+
background: #f3f5f7;
|
|
2887
|
+
color: #555;
|
|
2888
|
+
font: inherit;
|
|
2889
|
+
font-size: 12px;
|
|
2890
|
+
cursor: pointer;
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
.ee-compose-quote-toggle:hover {
|
|
2894
|
+
background: #e8ecf0;
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
.ee-compose-quote-content {
|
|
2898
|
+
align-self: stretch;
|
|
2899
|
+
padding: 4px 0 4px 12px;
|
|
2900
|
+
border-left: 2px solid #ccc;
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
.ee-forward-title {
|
|
2904
|
+
font-weight: 600;
|
|
2905
|
+
margin-bottom: 4px;
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
.ee-forward-row {
|
|
2909
|
+
display: flex;
|
|
2910
|
+
gap: 8px;
|
|
2911
|
+
font-size: 13px;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
.ee-forward-label {
|
|
2915
|
+
flex: 0 0 56px;
|
|
2916
|
+
color: #666;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
.ee-compose-quote-header:not(:empty) {
|
|
2920
|
+
margin-bottom: 12px;
|
|
2921
|
+
padding-bottom: 10px;
|
|
2922
|
+
border-bottom: 1px solid #e5e8ec;
|
|
1751
2923
|
}
|
|
1752
2924
|
|
|
1753
2925
|
/* Dark mode toggle button, in the Folders pane header */
|
|
@@ -1773,8 +2945,7 @@ export class EmailEngineClient {
|
|
|
1773
2945
|
}
|
|
1774
2946
|
|
|
1775
2947
|
.ee-dark-mode-icon {
|
|
1776
|
-
|
|
1777
|
-
line-height: 1;
|
|
2948
|
+
display: flex;
|
|
1778
2949
|
}
|
|
1779
2950
|
|
|
1780
2951
|
/* Dark mode styles */
|
|
@@ -1799,16 +2970,21 @@ export class EmailEngineClient {
|
|
|
1799
2970
|
border-color: #333;
|
|
1800
2971
|
}
|
|
1801
2972
|
|
|
1802
|
-
.ee-dark-mode .ee-folder-
|
|
1803
|
-
|
|
2973
|
+
.ee-dark-mode .ee-folder-content:hover {
|
|
2974
|
+
background: #2a2a2a;
|
|
1804
2975
|
}
|
|
1805
2976
|
|
|
1806
|
-
.ee-dark-mode .ee-folder-item
|
|
1807
|
-
background: #
|
|
2977
|
+
.ee-dark-mode .ee-folder-item.active .ee-folder-content {
|
|
2978
|
+
background: color-mix(in srgb, var(--_accent) 35%, #1a1a1a);
|
|
2979
|
+
color: #fff;
|
|
1808
2980
|
}
|
|
1809
2981
|
|
|
1810
|
-
.ee-dark-mode .ee-folder-
|
|
1811
|
-
|
|
2982
|
+
.ee-dark-mode .ee-folder-icon {
|
|
2983
|
+
color: #999;
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
.ee-dark-mode .ee-folder-count {
|
|
2987
|
+
background: var(--_accent-hover);
|
|
1812
2988
|
}
|
|
1813
2989
|
|
|
1814
2990
|
.ee-dark-mode .ee-message-list {
|
|
@@ -1825,15 +3001,32 @@ export class EmailEngineClient {
|
|
|
1825
3001
|
}
|
|
1826
3002
|
|
|
1827
3003
|
.ee-dark-mode .ee-message-item.active {
|
|
1828
|
-
background: #
|
|
3004
|
+
background: color-mix(in srgb, var(--_accent) 35%, #1a1a1a);
|
|
1829
3005
|
}
|
|
1830
3006
|
|
|
1831
3007
|
.ee-dark-mode .ee-message-date,
|
|
1832
3008
|
.ee-dark-mode .ee-message-preview,
|
|
1833
|
-
.ee-dark-mode .ee-
|
|
3009
|
+
.ee-dark-mode .ee-message-to-label,
|
|
3010
|
+
.ee-dark-mode .ee-attachment-indicator,
|
|
3011
|
+
.ee-dark-mode .ee-list-range,
|
|
3012
|
+
.ee-dark-mode .ee-attachment-download {
|
|
1834
3013
|
color: #999;
|
|
1835
3014
|
}
|
|
1836
3015
|
|
|
3016
|
+
.ee-dark-mode .ee-message-subject {
|
|
3017
|
+
color: #ccc;
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
.ee-dark-mode .ee-list-footer {
|
|
3021
|
+
background: #252525;
|
|
3022
|
+
border-color: #333;
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
.ee-dark-mode .ee-attachment-type {
|
|
3026
|
+
background: color-mix(in srgb, var(--_accent) 30%, #1a1a1a);
|
|
3027
|
+
color: #e0e0e0;
|
|
3028
|
+
}
|
|
3029
|
+
|
|
1837
3030
|
.ee-dark-mode .ee-pane-header {
|
|
1838
3031
|
background: linear-gradient(to bottom, #2a2a2a, #252525);
|
|
1839
3032
|
border-color: #333;
|
|
@@ -1878,9 +3071,10 @@ export class EmailEngineClient {
|
|
|
1878
3071
|
}
|
|
1879
3072
|
|
|
1880
3073
|
.ee-dark-mode .ee-button-primary,
|
|
1881
|
-
.ee-dark-mode .ee-button-primary:hover:not(:disabled)
|
|
1882
|
-
|
|
1883
|
-
|
|
3074
|
+
.ee-dark-mode .ee-button-primary:hover:not(:disabled),
|
|
3075
|
+
.ee-dark-mode .ee-sidebar-compose-button {
|
|
3076
|
+
background: var(--_accent-hover);
|
|
3077
|
+
border-color: var(--_accent-hover);
|
|
1884
3078
|
color: white;
|
|
1885
3079
|
}
|
|
1886
3080
|
|
|
@@ -1948,7 +3142,7 @@ export class EmailEngineClient {
|
|
|
1948
3142
|
}
|
|
1949
3143
|
|
|
1950
3144
|
.ee-dark-mode .ee-otp {
|
|
1951
|
-
background: #
|
|
3145
|
+
background: color-mix(in srgb, var(--_accent) 18%, #1a1a1a);
|
|
1952
3146
|
}
|
|
1953
3147
|
|
|
1954
3148
|
.ee-dark-mode .ee-otp-title {
|
|
@@ -1962,8 +3156,8 @@ export class EmailEngineClient {
|
|
|
1962
3156
|
}
|
|
1963
3157
|
|
|
1964
3158
|
.ee-dark-mode .ee-otp .ee-otp-copy {
|
|
1965
|
-
background:
|
|
1966
|
-
border-color:
|
|
3159
|
+
background: var(--_accent-hover);
|
|
3160
|
+
border-color: var(--_accent-hover);
|
|
1967
3161
|
color: white;
|
|
1968
3162
|
}
|
|
1969
3163
|
|
|
@@ -1972,81 +3166,99 @@ export class EmailEngineClient {
|
|
|
1972
3166
|
color: #999;
|
|
1973
3167
|
}
|
|
1974
3168
|
|
|
1975
|
-
|
|
1976
|
-
background: #252525;
|
|
1977
|
-
border-color: #333;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
/* The compose button and modal sit beside .ee-client, not inside it, so
|
|
3169
|
+
/* The compose button and form sit beside .ee-client, not inside it, so
|
|
1981
3170
|
setDarkMode puts the ee-dark-mode class on them directly */
|
|
1982
3171
|
.ee-compose-button.ee-dark-mode {
|
|
1983
|
-
background:
|
|
3172
|
+
background: var(--_accent-hover);
|
|
1984
3173
|
color: white;
|
|
1985
3174
|
}
|
|
1986
3175
|
|
|
1987
|
-
.ee-compose
|
|
1988
|
-
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
.ee-compose-modal.ee-dark-mode {
|
|
1992
|
-
background: rgba(0, 0, 0, 0.7);
|
|
3176
|
+
.ee-compose.ee-dark-mode {
|
|
3177
|
+
color: #e0e0e0;
|
|
1993
3178
|
}
|
|
1994
3179
|
|
|
1995
|
-
.ee-dark-mode .ee-compose-dialog {
|
|
3180
|
+
.ee-compose.ee-dark-mode .ee-compose-dialog {
|
|
1996
3181
|
background: #202020;
|
|
1997
|
-
color: #
|
|
3182
|
+
border-color: #3a3a3a;
|
|
3183
|
+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
|
|
1998
3184
|
}
|
|
1999
3185
|
|
|
2000
|
-
.ee-dark-mode .ee-compose-
|
|
2001
|
-
|
|
3186
|
+
.ee-compose.ee-dark-mode .ee-compose-header {
|
|
3187
|
+
background: #111;
|
|
2002
3188
|
}
|
|
2003
3189
|
|
|
2004
|
-
.ee-dark-mode .ee-compose-
|
|
2005
|
-
|
|
3190
|
+
.ee-compose.ee-dark-mode .ee-compose-row,
|
|
3191
|
+
.ee-compose.ee-dark-mode .ee-compose-toolbar,
|
|
3192
|
+
.ee-compose.ee-dark-mode .ee-compose-linkbar,
|
|
3193
|
+
.ee-compose.ee-dark-mode .ee-compose-actions,
|
|
3194
|
+
.ee-compose.ee-dark-mode .ee-compose-quote-header:not(:empty) {
|
|
2006
3195
|
border-color: #333;
|
|
2007
3196
|
}
|
|
2008
3197
|
|
|
2009
|
-
.ee-dark-mode .ee-compose-
|
|
3198
|
+
.ee-compose.ee-dark-mode .ee-compose-label,
|
|
3199
|
+
.ee-compose.ee-dark-mode .ee-forward-label,
|
|
3200
|
+
.ee-compose.ee-dark-mode .ee-compose-chip-size,
|
|
3201
|
+
.ee-compose.ee-dark-mode .ee-compose-chip-remove {
|
|
2010
3202
|
color: #999;
|
|
2011
3203
|
}
|
|
2012
3204
|
|
|
2013
|
-
.ee-dark-mode .ee-compose-
|
|
3205
|
+
.ee-compose.ee-dark-mode .ee-compose-format,
|
|
3206
|
+
.ee-compose.ee-dark-mode .ee-compose-icon-button {
|
|
3207
|
+
color: #bbb;
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
.ee-compose.ee-dark-mode .ee-compose-format:hover,
|
|
3211
|
+
.ee-compose.ee-dark-mode .ee-compose-icon-button:hover,
|
|
3212
|
+
.ee-compose.ee-dark-mode .ee-compose-small-button:hover,
|
|
3213
|
+
.ee-compose.ee-dark-mode .ee-compose-save-draft:hover:not(:disabled),
|
|
3214
|
+
.ee-compose.ee-dark-mode .ee-compose-chip-remove:hover,
|
|
3215
|
+
.ee-compose.ee-dark-mode .ee-compose-quote-toggle:hover {
|
|
3216
|
+
background: #333;
|
|
2014
3217
|
color: #fff;
|
|
2015
3218
|
}
|
|
2016
3219
|
|
|
2017
|
-
.ee-dark-mode .ee-compose-
|
|
2018
|
-
|
|
2019
|
-
|
|
3220
|
+
.ee-compose.ee-dark-mode .ee-compose-format[aria-pressed="true"] {
|
|
3221
|
+
background: color-mix(in srgb, var(--_accent) 35%, #1a1a1a);
|
|
3222
|
+
color: #fff;
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
.ee-compose.ee-dark-mode .ee-compose-small-button,
|
|
3226
|
+
.ee-compose.ee-dark-mode .ee-compose-save-draft,
|
|
3227
|
+
.ee-compose.ee-dark-mode .ee-compose-chip,
|
|
3228
|
+
.ee-compose.ee-dark-mode .ee-compose-quote-toggle,
|
|
3229
|
+
.ee-compose.ee-dark-mode .ee-compose-linkbar .ee-compose-input {
|
|
3230
|
+
background: #2a2a2a;
|
|
2020
3231
|
border-color: #444;
|
|
2021
3232
|
color: #e0e0e0;
|
|
2022
3233
|
}
|
|
2023
3234
|
|
|
2024
|
-
.ee-dark-mode .ee-compose-
|
|
2025
|
-
.ee-dark-mode .ee-compose-
|
|
2026
|
-
border-color: #
|
|
2027
|
-
|
|
3235
|
+
.ee-compose.ee-dark-mode .ee-compose-editor blockquote,
|
|
3236
|
+
.ee-compose.ee-dark-mode .ee-compose-quote-content {
|
|
3237
|
+
border-color: #555;
|
|
3238
|
+
color: #ccc;
|
|
2028
3239
|
}
|
|
2029
3240
|
|
|
2030
|
-
.ee-dark-mode .ee-compose-
|
|
2031
|
-
|
|
3241
|
+
.ee-compose.ee-dark-mode .ee-compose-editor a,
|
|
3242
|
+
.ee-compose.ee-dark-mode .ee-compose-link {
|
|
3243
|
+
color: var(--_accent-light);
|
|
2032
3244
|
}
|
|
2033
3245
|
|
|
2034
|
-
.ee-dark-mode .ee-compose-
|
|
2035
|
-
background: #
|
|
3246
|
+
.ee-compose.ee-dark-mode .ee-compose-error {
|
|
3247
|
+
background: #3a2222;
|
|
3248
|
+
border-color: #5c3030;
|
|
3249
|
+
color: #f0a5a5;
|
|
2036
3250
|
}
|
|
2037
3251
|
|
|
2038
|
-
.ee-dark-mode .ee-compose
|
|
2039
|
-
|
|
3252
|
+
.ee-dark-mode .ee-sidebar-compose {
|
|
3253
|
+
border-color: #333;
|
|
2040
3254
|
}
|
|
2041
3255
|
|
|
2042
|
-
.ee-dark-mode .ee-
|
|
2043
|
-
|
|
2044
|
-
border-color: #66b2ff;
|
|
3256
|
+
.ee-dark-mode .ee-toolbar-divider {
|
|
3257
|
+
background: #444;
|
|
2045
3258
|
}
|
|
2046
3259
|
|
|
2047
|
-
.ee-dark-mode .ee-
|
|
2048
|
-
|
|
2049
|
-
color: #1a1a1a;
|
|
3260
|
+
.ee-dark-mode .ee-address {
|
|
3261
|
+
color: #aaa;
|
|
2050
3262
|
}
|
|
2051
3263
|
`);
|
|
2052
3264
|
document.head.appendChild(style);
|
|
@@ -2146,39 +3358,105 @@ export class EmailEngineClient {
|
|
|
2146
3358
|
return;
|
|
2147
3359
|
}
|
|
2148
3360
|
|
|
2149
|
-
const sortedFolders = this.buildFolderTree();
|
|
2150
|
-
// Precompute which paths are some folder's parent so the per-row
|
|
2151
|
-
// has-children check is O(1) instead of scanning this.folders each time.
|
|
2152
|
-
const parentPaths = new Set(this.folders.map(f => f.parentPath));
|
|
2153
|
-
|
|
2154
3361
|
const html = `
|
|
2155
3362
|
<ul class="ee-folder-list">
|
|
2156
|
-
${
|
|
2157
|
-
.map(({ folder, depth }) =>
|
|
2158
|
-
const hasChildren = parentPaths.has(folder.path);
|
|
2159
|
-
return `
|
|
2160
|
-
<li class="ee-folder-item ${folder.path === this.currentFolder ? 'active' : ''}"
|
|
2161
|
-
data-path="${this.escapeHtml(folder.path)}"
|
|
2162
|
-
data-depth="${depth}">
|
|
2163
|
-
<div class="ee-folder-content" style="padding-left: ${8 + depth * 12}px;">
|
|
2164
|
-
${depth > 0 ? '<span class="ee-folder-indent">└ </span>' : ''}
|
|
2165
|
-
<span class="ee-folder-name ${hasChildren ? 'has-children' : ''}">${this.escapeHtml(folder.name)}</span>
|
|
2166
|
-
${folder.status && folder.status.messages > 0 ? `<span class="ee-folder-count">${folder.status.messages}</span>` : ''}
|
|
2167
|
-
</div>
|
|
2168
|
-
</li>
|
|
2169
|
-
`;
|
|
2170
|
-
})
|
|
3363
|
+
${this.buildFolderTree()
|
|
3364
|
+
.map(({ folder, depth }) => this._folderItemHtml(folder, depth))
|
|
2171
3365
|
.join('')}
|
|
2172
3366
|
</ul>
|
|
2173
3367
|
`;
|
|
2174
3368
|
folderTree.innerHTML = html;
|
|
3369
|
+
}
|
|
2175
3370
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
3371
|
+
// One folder row: an icon by special use, the name, and the unread count. The row is a button,
|
|
3372
|
+
// so the folders can be reached and opened from the keyboard.
|
|
3373
|
+
_folderItemHtml(folder, depth) {
|
|
3374
|
+
const active = folder.path === this.currentFolder;
|
|
3375
|
+
const unseen = folder.status && folder.status.unseen > 0 ? folder.status.unseen : 0;
|
|
3376
|
+
const name = folderDisplayName(folder);
|
|
3377
|
+
const label = unseen ? `${name}, ${unseen} unread` : name;
|
|
3378
|
+
return `
|
|
3379
|
+
<li class="ee-folder-item${active ? ' active' : ''}" data-path="${this.escapeHtml(folder.path)}" data-depth="${depth}">
|
|
3380
|
+
<button type="button" class="ee-folder-content" style="padding-left: ${12 + depth * 16}px;" aria-label="${this.escapeHtml(label)}"${active ? ' aria-current="true"' : ''}>
|
|
3381
|
+
<span class="ee-folder-icon">${icon(FOLDER_ICONS[folder.specialUse] || 'folder', 16)}</span>
|
|
3382
|
+
<span class="ee-folder-name">${this.escapeHtml(name)}</span>
|
|
3383
|
+
${unseen ? `<span class="ee-folder-count">${unseen}</span>` : ''}
|
|
3384
|
+
</button>
|
|
3385
|
+
</li>
|
|
3386
|
+
`;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
// Keeps a folder's unread count in step with a read state the client changed itself, so the
|
|
3390
|
+
// badge does not wait for the next folder listing
|
|
3391
|
+
_adjustUnseen(path, delta) {
|
|
3392
|
+
const folder = this.folders.find(f => f.path === path);
|
|
3393
|
+
if (!folder || !folder.status || typeof folder.status.unseen !== 'number') {
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
folder.status.unseen = Math.max(0, folder.status.unseen + delta);
|
|
3397
|
+
this.renderFolderList();
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3400
|
+
// Folders whose messages the account sent itself: the list names the recipients instead
|
|
3401
|
+
_isOutgoingFolder(path) {
|
|
3402
|
+
const folder = this.folders.find(f => f.path === path);
|
|
3403
|
+
return !!folder && (folder.specialUse === '\\Sent' || folder.specialUse === '\\Drafts');
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
// The correspondent column of a list row: the sender, or "To: ..." in Sent and Drafts
|
|
3407
|
+
_correspondentHtml(msg, outgoing) {
|
|
3408
|
+
if (outgoing) {
|
|
3409
|
+
const names = addressEntries(msg.to)
|
|
3410
|
+
.concat(addressEntries(msg.cc))
|
|
3411
|
+
.map(entry => entry.name || entry.address);
|
|
3412
|
+
return names.length ? `<span class="ee-message-to-label">To:</span> ${this.escapeHtml(names.join(', '))}` : '(no recipients)';
|
|
3413
|
+
}
|
|
3414
|
+
return this.escapeHtml(msg.from ? msg.from.name || msg.from.address : 'Unknown');
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
_messageItemHtml(msg, outgoing) {
|
|
3418
|
+
const active = msg.id === (this.currentMessage && this.currentMessage.id);
|
|
3419
|
+
const attachments = listedAttachments(msg.attachments).length;
|
|
3420
|
+
const status = msg.unseen ? '<span class="ee-unread-dot" role="img" aria-label="Unread"></span>' : '';
|
|
3421
|
+
return `
|
|
3422
|
+
<button type="button" class="ee-message-item${msg.unseen ? ' unread' : ''}${active ? ' active' : ''}" data-id="${this.escapeHtml(msg.id)}"${active ? ' aria-current="true"' : ''}>
|
|
3423
|
+
<span class="ee-message-header">
|
|
3424
|
+
${status}
|
|
3425
|
+
<span class="ee-message-from">${this._correspondentHtml(msg, outgoing)}</span>
|
|
3426
|
+
<span class="ee-message-date">${this.formatDate(msg.date)}</span>
|
|
3427
|
+
</span>
|
|
3428
|
+
<span class="ee-message-subject">
|
|
3429
|
+
${this._responseMarkers(msg)}
|
|
3430
|
+
<span class="ee-message-subject-text">${this.escapeHtml(msg.subject || '(no subject)')}</span>
|
|
3431
|
+
${attachments ? `<span class="ee-attachment-indicator" role="img" aria-label="${attachments} attachments" title="Attachments">${icon('paperclip', 12)}${attachments}</span>` : ''}
|
|
3432
|
+
</span>
|
|
3433
|
+
${msg.intro ? `<span class="ee-message-preview">${this.escapeHtml(msg.intro)}</span>` : ''}
|
|
3434
|
+
</button>
|
|
3435
|
+
`;
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3438
|
+
// The bottom bar of the message list: where the page sits in the folder, the page arrows
|
|
3439
|
+
// and the page size
|
|
3440
|
+
_messageListFooter() {
|
|
3441
|
+
const count = this.messages.length;
|
|
3442
|
+
let range = '';
|
|
3443
|
+
if (this.listPosition && count) {
|
|
3444
|
+
const first = this.listPosition.page * this.pageSize + 1;
|
|
3445
|
+
range = `${first}-${first + count - 1} of ${this.listPosition.total}`;
|
|
3446
|
+
}
|
|
3447
|
+
const hasPagination = this.nextPageCursor || this.prevPageCursor;
|
|
3448
|
+
return `
|
|
3449
|
+
<div class="ee-list-footer">
|
|
3450
|
+
<span class="ee-list-range">${range}</span>
|
|
3451
|
+
${hasPagination ? this._iconButton('prev-page', 'back', 'Previous page', '', !this.prevPageCursor) + this._iconButton('next-page', 'next', 'Next page', '', !this.nextPageCursor) : ''}
|
|
3452
|
+
<label class="ee-page-size-selector" title="Messages per page">
|
|
3453
|
+
<span class="ee-page-size-label">Per page</span>
|
|
3454
|
+
<select class="ee-button ee-page-size-select" data-action="page-size">
|
|
3455
|
+
${[10, 20, 30, 50, 100].map(size => `<option value="${size}"${this.pageSize === size ? ' selected' : ''}>${size}</option>`).join('')}
|
|
3456
|
+
</select>
|
|
3457
|
+
</label>
|
|
3458
|
+
</div>
|
|
3459
|
+
`;
|
|
2182
3460
|
}
|
|
2183
3461
|
|
|
2184
3462
|
renderMessageList() {
|
|
@@ -2191,61 +3469,19 @@ export class EmailEngineClient {
|
|
|
2191
3469
|
return;
|
|
2192
3470
|
}
|
|
2193
3471
|
|
|
2194
|
-
if (!this.messages.length) {
|
|
2195
|
-
messageList.innerHTML = `${this._messageListHeader(this.currentFolder)}<div class="ee-empty-state">No messages</div>`;
|
|
2196
|
-
return;
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
const
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
// one disabled, so the controls do not shift under the pointer between pages
|
|
2203
|
-
const controls = `
|
|
2204
|
-
<div class="ee-pagination-controls">
|
|
2205
|
-
${
|
|
2206
|
-
hasPagination
|
|
2207
|
-
? `
|
|
2208
|
-
${this._iconButton('prev-page', 'back', 'Previous page', '', !this.prevPageCursor)}
|
|
2209
|
-
${this._iconButton('next-page', 'next', 'Next page', '', !this.nextPageCursor)}
|
|
2210
|
-
`
|
|
2211
|
-
: ''
|
|
2212
|
-
}
|
|
2213
|
-
<label class="ee-page-size-selector" title="Messages per page">
|
|
2214
|
-
<span class="ee-page-size-label">Show</span>
|
|
2215
|
-
<select class="ee-button ee-page-size-select" data-action="page-size">
|
|
2216
|
-
<option value="10" ${this.pageSize === 10 ? 'selected' : ''}>10</option>
|
|
2217
|
-
<option value="20" ${this.pageSize === 20 ? 'selected' : ''}>20</option>
|
|
2218
|
-
<option value="30" ${this.pageSize === 30 ? 'selected' : ''}>30</option>
|
|
2219
|
-
<option value="50" ${this.pageSize === 50 ? 'selected' : ''}>50</option>
|
|
2220
|
-
<option value="100" ${this.pageSize === 100 ? 'selected' : ''}>100</option>
|
|
2221
|
-
</select>
|
|
2222
|
-
</label>
|
|
2223
|
-
</div>
|
|
2224
|
-
`;
|
|
2225
|
-
|
|
2226
|
-
const html = `
|
|
2227
|
-
${this._messageListHeader(this.currentFolder, controls)}
|
|
3472
|
+
if (!this.messages.length) {
|
|
3473
|
+
messageList.innerHTML = `${this._messageListHeader(this.currentFolder)}<div class="ee-empty-state">No messages in this folder</div>`;
|
|
3474
|
+
return;
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
const outgoing = this._isOutgoingFolder(this.currentFolder);
|
|
3478
|
+
messageList.innerHTML = `
|
|
3479
|
+
${this._messageListHeader(this.currentFolder)}
|
|
2228
3480
|
<div class="ee-message-items">
|
|
2229
|
-
${this.messages
|
|
2230
|
-
.map(
|
|
2231
|
-
msg => `
|
|
2232
|
-
<div class="ee-message-item ${msg.unseen ? 'unread' : ''} ${msg.id === (this.currentMessage && this.currentMessage.id) ? 'active' : ''}" data-id="${this.escapeHtml(msg.id)}">
|
|
2233
|
-
<div class="ee-message-header">
|
|
2234
|
-
<span class="ee-message-from">${this.escapeHtml(msg.from ? msg.from.name || msg.from.address : 'Unknown')}</span>
|
|
2235
|
-
<span class="ee-message-date">${this.formatDate(msg.date)}</span>
|
|
2236
|
-
</div>
|
|
2237
|
-
<div class="ee-message-subject">
|
|
2238
|
-
<span class="ee-message-subject-text">${this.escapeHtml(msg.subject || '(no subject)')}</span>
|
|
2239
|
-
${msg.attachments && msg.attachments.length > 0 ? `<span class="ee-attachment-indicator">${msg.attachments.length}</span>` : ''}
|
|
2240
|
-
</div>
|
|
2241
|
-
<div class="ee-message-preview">${this.escapeHtml(msg.intro || '')}</div>
|
|
2242
|
-
</div>
|
|
2243
|
-
`
|
|
2244
|
-
)
|
|
2245
|
-
.join('')}
|
|
3481
|
+
${this.messages.map(msg => this._messageItemHtml(msg, outgoing)).join('')}
|
|
2246
3482
|
</div>
|
|
3483
|
+
${this._messageListFooter()}
|
|
2247
3484
|
`;
|
|
2248
|
-
messageList.innerHTML = html;
|
|
2249
3485
|
|
|
2250
3486
|
messageList.querySelectorAll('.ee-message-item').forEach(item => {
|
|
2251
3487
|
item.addEventListener('click', () => {
|
|
@@ -2306,8 +3542,14 @@ export class EmailEngineClient {
|
|
|
2306
3542
|
// query); aria-label and title carry the full name either way. The move control
|
|
2307
3543
|
// is a native select laid invisibly over a button so it looks like the rest of
|
|
2308
3544
|
// the toolbar while keeping the platform's own folder picker.
|
|
3545
|
+
const respond = isDraft
|
|
3546
|
+
? ''
|
|
3547
|
+
: `${this._toolbarButton('reply', 'reply', 'Reply', 'Reply to the sender', 'ee-label-priority')}
|
|
3548
|
+
${addressEntries(msg.to).length + addressEntries(msg.cc).length > 1 ? this._toolbarButton('reply-all', 'replyAll', 'Reply all', 'Reply to everyone', 'ee-label-priority') : ''}
|
|
3549
|
+
${this._toolbarButton('forward', 'forward', 'Forward', 'Forward this message', 'ee-label-priority')}
|
|
3550
|
+
<span class="ee-toolbar-divider"></span>`;
|
|
2309
3551
|
const actions = `
|
|
2310
|
-
${isDraft ? this._toolbarButton('
|
|
3552
|
+
${isDraft ? this._toolbarButton('edit-draft', 'compose', 'Edit', 'Continue writing this draft', 'ee-button-primary ee-keep-label') + this._toolbarButton('send-draft', 'send', 'Send draft', 'Send this draft as it is', 'ee-label-priority') : respond}
|
|
2311
3553
|
${this._toolbarButton('toggle-read', isUnseen ? 'mailOpen' : 'mail', isUnseen ? 'Mark read' : 'Mark unread', isUnseen ? 'Mark as read' : 'Mark as unread')}
|
|
2312
3554
|
<span class="ee-button ee-move-button" title="Move to folder">
|
|
2313
3555
|
${icon('move')}<span class="ee-button-label">Move</span>${icon('chevronDown', 12)}
|
|
@@ -2330,54 +3572,34 @@ export class EmailEngineClient {
|
|
|
2330
3572
|
${this._messageToolbar(actions)}
|
|
2331
3573
|
<div class="ee-message-content">
|
|
2332
3574
|
<h2 class="ee-message-title">${this.escapeHtml(msg.subject || '(no subject)')}</h2>
|
|
3575
|
+
<div class="ee-message-title-markers">${this._responseMarkers(msg, true)}</div>
|
|
2333
3576
|
<div class="ee-message-meta">
|
|
2334
3577
|
<div class="ee-message-meta-row">
|
|
2335
3578
|
<span class="ee-message-meta-label">From</span>
|
|
2336
|
-
<span class="ee-message-meta-value">${
|
|
3579
|
+
<span class="ee-message-meta-value">${this._addressListHtml(msg.from) || 'Unknown'}</span>
|
|
2337
3580
|
</div>
|
|
2338
3581
|
<div class="ee-message-meta-row">
|
|
2339
3582
|
<span class="ee-message-meta-label">To</span>
|
|
2340
|
-
<span class="ee-message-meta-value">${
|
|
3583
|
+
<span class="ee-message-meta-value">${this._addressListHtml(msg.to)}</span>
|
|
2341
3584
|
</div>
|
|
2342
3585
|
${
|
|
2343
3586
|
msg.cc && msg.cc.length
|
|
2344
3587
|
? `
|
|
2345
3588
|
<div class="ee-message-meta-row">
|
|
2346
3589
|
<span class="ee-message-meta-label">Cc</span>
|
|
2347
|
-
<span class="ee-message-meta-value">${
|
|
3590
|
+
<span class="ee-message-meta-value">${this._addressListHtml(msg.cc)}</span>
|
|
2348
3591
|
</div>
|
|
2349
3592
|
`
|
|
2350
3593
|
: ''
|
|
2351
3594
|
}
|
|
2352
3595
|
<div class="ee-message-meta-row">
|
|
2353
3596
|
<span class="ee-message-meta-label">Date</span>
|
|
2354
|
-
<span class="ee-message-meta-value">${this.escapeHtml(
|
|
3597
|
+
<span class="ee-message-meta-value">${this.escapeHtml(this.formatFullDate(msg.date))}</span>
|
|
2355
3598
|
</div>
|
|
2356
3599
|
</div>
|
|
2357
3600
|
${this.renderOtpBox(msg.otp)}
|
|
2358
3601
|
<div class="ee-message-body"></div>
|
|
2359
|
-
${
|
|
2360
|
-
msg.attachments && msg.attachments.length > 0
|
|
2361
|
-
? `
|
|
2362
|
-
<div class="ee-attachments">
|
|
2363
|
-
<div class="ee-attachments-title">Attachments (${msg.attachments.length})</div>
|
|
2364
|
-
${msg.attachments
|
|
2365
|
-
.map(
|
|
2366
|
-
att => `
|
|
2367
|
-
<div class="ee-attachment-item" data-attachment-id="${this.escapeHtml(att.id)}">
|
|
2368
|
-
<div class="ee-attachment-icon">📎</div>
|
|
2369
|
-
<div class="ee-attachment-info">
|
|
2370
|
-
<div class="ee-attachment-name">${this.escapeHtml(att.filename || 'Unnamed attachment')}</div>
|
|
2371
|
-
${att.size ? `<div class="ee-attachment-size">${this.formatFileSize(att.size)}</div>` : ''}
|
|
2372
|
-
</div>
|
|
2373
|
-
</div>
|
|
2374
|
-
`
|
|
2375
|
-
)
|
|
2376
|
-
.join('')}
|
|
2377
|
-
</div>
|
|
2378
|
-
`
|
|
2379
|
-
: ''
|
|
2380
|
-
}
|
|
3602
|
+
${this._attachmentsHtml(listedAttachments(msg.attachments))}
|
|
2381
3603
|
</div>
|
|
2382
3604
|
`;
|
|
2383
3605
|
viewer.innerHTML = html;
|
|
@@ -2406,11 +3628,11 @@ export class EmailEngineClient {
|
|
|
2406
3628
|
|
|
2407
3629
|
try {
|
|
2408
3630
|
await this.submitDraft(msg.id);
|
|
2409
|
-
|
|
3631
|
+
this.notify('Draft queued for delivery.');
|
|
2410
3632
|
// Refresh the folder view - the provider removes the draft once it is sent,
|
|
2411
3633
|
// immediately for Gmail and MS Graph, after SMTP delivery for IMAP accounts.
|
|
2412
3634
|
if (!this._destroyed && this.currentFolder) {
|
|
2413
|
-
await this.
|
|
3635
|
+
await this.openFolder(this.currentFolder);
|
|
2414
3636
|
}
|
|
2415
3637
|
} catch (error) {
|
|
2416
3638
|
console.error('Failed to send draft:', error);
|
|
@@ -2422,20 +3644,33 @@ export class EmailEngineClient {
|
|
|
2422
3644
|
});
|
|
2423
3645
|
}
|
|
2424
3646
|
|
|
3647
|
+
const editDraftButton = viewer.querySelector('[data-action="edit-draft"]');
|
|
3648
|
+
if (editDraftButton) {
|
|
3649
|
+
editDraftButton.addEventListener('click', () => {
|
|
3650
|
+
this.editDraft(msg.id).catch(error => this._alertActionFailed(error, 'Failed to open the draft'));
|
|
3651
|
+
});
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
viewer.querySelectorAll('[data-action="reply"], [data-action="reply-all"], [data-action="forward"]').forEach(button => {
|
|
3655
|
+
button.addEventListener('click', () => {
|
|
3656
|
+
this._respond(msg.id, button.dataset.action).catch(error => this._alertActionFailed(error, 'Failed to open the compose form'));
|
|
3657
|
+
});
|
|
3658
|
+
});
|
|
3659
|
+
|
|
2425
3660
|
viewer.querySelector('[data-action="toggle-read"]').addEventListener('click', () => {
|
|
2426
3661
|
const currentlyUnseen = msg.unseen;
|
|
2427
3662
|
this.markAsRead(msg.id, currentlyUnseen).catch(error => this._alertActionFailed(error, 'Failed to update the message flags'));
|
|
2428
3663
|
});
|
|
2429
3664
|
|
|
2430
3665
|
viewer.querySelector('[data-action="delete"]').addEventListener('click', async () => {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
'Delete'
|
|
2436
|
-
);
|
|
3666
|
+
// Whether a delete moves the message to Trash or removes it depends on the backend
|
|
3667
|
+
// and the folder (IMAP removes it from Trash and Junk, Gmail always moves it), so the
|
|
3668
|
+
// question makes no promise and the notice reports what the server did
|
|
3669
|
+
const result = await this.confirmMethod('Delete this message?', 'Delete Message', 'Cancel', 'Delete');
|
|
2437
3670
|
if (result) {
|
|
2438
|
-
this.deleteMessage(msg.id)
|
|
3671
|
+
this.deleteMessage(msg.id)
|
|
3672
|
+
.then(response => this.notify(response && response.moved ? 'Message moved to Trash.' : 'Message deleted.'))
|
|
3673
|
+
.catch(error => this._alertActionFailed(error, 'Failed to delete the message'));
|
|
2439
3674
|
}
|
|
2440
3675
|
});
|
|
2441
3676
|
|
|
@@ -2482,6 +3717,55 @@ export class EmailEngineClient {
|
|
|
2482
3717
|
// Message content scrolling is now handled in loadMessage method
|
|
2483
3718
|
}
|
|
2484
3719
|
|
|
3720
|
+
// The attachments of the open message as download cards: a type label, the name and the size
|
|
3721
|
+
_attachmentsHtml(attachments) {
|
|
3722
|
+
if (!attachments.length) {
|
|
3723
|
+
return '';
|
|
3724
|
+
}
|
|
3725
|
+
const cards = attachments
|
|
3726
|
+
.map(att => {
|
|
3727
|
+
const name = att.filename || 'Unnamed attachment';
|
|
3728
|
+
const size = attachmentSize(att);
|
|
3729
|
+
return `
|
|
3730
|
+
<button type="button" class="ee-attachment-item" data-attachment-id="${this.escapeHtml(att.id)}" aria-label="Download ${this.escapeHtml(name)}" title="Download ${this.escapeHtml(name)}">
|
|
3731
|
+
<span class="ee-attachment-type">${this.escapeHtml(attachmentType(att))}</span>
|
|
3732
|
+
<span class="ee-attachment-info">
|
|
3733
|
+
<span class="ee-attachment-name">${this.escapeHtml(name)}</span>
|
|
3734
|
+
${size ? `<span class="ee-attachment-size">${this.formatFileSize(size)}</span>` : ''}
|
|
3735
|
+
</span>
|
|
3736
|
+
<span class="ee-attachment-download">${icon('download', 16)}</span>
|
|
3737
|
+
</button>`;
|
|
3738
|
+
})
|
|
3739
|
+
.join('');
|
|
3740
|
+
return `
|
|
3741
|
+
<div class="ee-attachments">
|
|
3742
|
+
<div class="ee-attachments-title">${attachments.length === 1 ? '1 attachment' : `${attachments.length} attachments`}</div>
|
|
3743
|
+
<div class="ee-attachment-grid">${cards}</div>
|
|
3744
|
+
</div>
|
|
3745
|
+
`;
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
// Replied / forwarded markers from the flags the server sets on the original once a reply or
|
|
3749
|
+
// forward has been delivered (IMAP accounts; Gmail API and MS Graph report neither flag).
|
|
3750
|
+
// labelled shows the words next to the icons, otherwise they are the accessible name only.
|
|
3751
|
+
//
|
|
3752
|
+
// EmailEngine adds \Answered to a forwarded message as well as $Forwarded, so one marker is
|
|
3753
|
+
// shown: Forwarded when that flag is set, Replied otherwise.
|
|
3754
|
+
_responseMarkers(msg, labelled = false) {
|
|
3755
|
+
const flags = Array.isArray(msg.flags) ? msg.flags : [];
|
|
3756
|
+
const marker = flags.includes('$Forwarded')
|
|
3757
|
+
? { icon: 'forward', label: 'Forwarded' }
|
|
3758
|
+
: flags.includes('\\Answered')
|
|
3759
|
+
? { icon: 'reply', label: 'Replied' }
|
|
3760
|
+
: null;
|
|
3761
|
+
if (!marker) {
|
|
3762
|
+
return '';
|
|
3763
|
+
}
|
|
3764
|
+
return labelled
|
|
3765
|
+
? `<span class="ee-response-marker">${icon(marker.icon, 12)}<span>${marker.label}</span></span>`
|
|
3766
|
+
: `<span class="ee-response-marker" role="img" aria-label="${marker.label}" title="${marker.label}">${icon(marker.icon, 12)}</span>`;
|
|
3767
|
+
}
|
|
3768
|
+
|
|
2485
3769
|
// An icon-only button. Static arguments only, never message data.
|
|
2486
3770
|
_iconButton(action, iconName, label, extraClass = '', disabled = false) {
|
|
2487
3771
|
return `<button type="button" class="ee-button ee-icon-button ${extraClass}" data-action="${action}" aria-label="${label}" title="${label}"${disabled ? ' disabled' : ''}>${icon(iconName)}</button>`;
|
|
@@ -2513,6 +3797,22 @@ export class EmailEngineClient {
|
|
|
2513
3797
|
}
|
|
2514
3798
|
|
|
2515
3799
|
root.replaceChildren(style, content);
|
|
3800
|
+
// A message that had no HTML of its own: EmailEngine's conversion sets a small fixed font,
|
|
3801
|
+
// and the plain-text rule lets it read at the size of the rest of the client
|
|
3802
|
+
const encodedSize = msg.text && msg.text.encodedSize;
|
|
3803
|
+
if (encodedSize && encodedSize.plain && !encodedSize.html) {
|
|
3804
|
+
content.dataset.plain = 'true';
|
|
3805
|
+
}
|
|
3806
|
+
// A message that sets its own colours or backgrounds was designed for a light page;
|
|
3807
|
+
// in dark mode its dark text would land on a dark background, or the client's light
|
|
3808
|
+
// text on its white tables, so it is shown on a light surface instead (see the
|
|
3809
|
+
// [data-styled] rule). A plain message has none and follows the theme.
|
|
3810
|
+
const styled = Array.from(content.querySelectorAll('[style], [bgcolor], [color]')).some(
|
|
3811
|
+
el => el.hasAttribute('bgcolor') || el.hasAttribute('color') || el.style.color || el.style.backgroundColor || el.style.backgroundImage
|
|
3812
|
+
);
|
|
3813
|
+
if (styled) {
|
|
3814
|
+
host.dataset.styled = 'true';
|
|
3815
|
+
}
|
|
2516
3816
|
return root;
|
|
2517
3817
|
}
|
|
2518
3818
|
|
|
@@ -2548,46 +3848,88 @@ export class EmailEngineClient {
|
|
|
2548
3848
|
${
|
|
2549
3849
|
this.showDarkModeToggle
|
|
2550
3850
|
? `<button type="button" class="ee-dark-mode-toggle" title="Toggle dark mode" aria-label="Toggle dark mode">
|
|
2551
|
-
<span class="ee-dark-mode-icon">${this.darkMode ? '
|
|
3851
|
+
<span class="ee-dark-mode-icon">${icon(this.darkMode ? 'sun' : 'moon', 14)}</span>
|
|
2552
3852
|
</button>`
|
|
2553
3853
|
: ''
|
|
2554
3854
|
}
|
|
2555
3855
|
</div>
|
|
3856
|
+
<div class="ee-sidebar-compose">
|
|
3857
|
+
<button type="button" class="ee-sidebar-compose-button" data-action="compose">${icon('compose', 16)}<span>Compose</span></button>
|
|
3858
|
+
</div>
|
|
2556
3859
|
<div class="ee-folder-tree"></div>
|
|
2557
3860
|
</div>
|
|
2558
3861
|
<div class="ee-message-list">${this._messageListPlaceholder()}</div>
|
|
2559
3862
|
<div class="ee-message-viewer">${this._messageViewerPlaceholder()}</div>
|
|
2560
3863
|
</div>
|
|
2561
|
-
<button type="button" class="ee-compose-button${this.darkMode ? ' ee-dark-mode' : ''}" title="Compose email" aria-label="Compose">${icon('compose', 22)}
|
|
2562
|
-
<div class="ee-
|
|
2563
|
-
|
|
3864
|
+
<button type="button" class="ee-compose-button${this.darkMode ? ' ee-dark-mode' : ''}" title="Compose email" aria-label="Compose">${icon('compose', 22)}</button>
|
|
3865
|
+
<div class="ee-toast${this.darkMode ? ' ee-dark-mode' : ''}" role="status" aria-live="polite"></div>
|
|
3866
|
+
<div class="ee-compose${this.darkMode ? ' ee-dark-mode' : ''}" hidden>
|
|
3867
|
+
<div class="ee-compose-dialog" role="dialog" aria-modal="false" aria-labelledby="${this._composeId('title')}">
|
|
2564
3868
|
<div class="ee-compose-header">
|
|
2565
|
-
<h3 class="ee-compose-title"
|
|
2566
|
-
<button class="ee-compose-
|
|
3869
|
+
<h3 class="ee-compose-title" id="${this._composeId('title')}">${COMPOSE_TITLES.new}</h3>
|
|
3870
|
+
<button type="button" class="ee-compose-window-button" data-action="minimize" aria-label="Minimize" title="Minimize"><span class="ee-when-open">${icon('minimize', 16)}</span><span class="ee-when-minimized">${icon('expand', 16)}</span></button>
|
|
3871
|
+
<button type="button" class="ee-compose-window-button ee-compose-close" data-action="close" aria-label="Close" title="Close">${icon('close', 16)}</button>
|
|
2567
3872
|
</div>
|
|
2568
|
-
<form class="ee-compose-form">
|
|
2569
|
-
<div class="ee-compose-
|
|
2570
|
-
<label class="ee-compose-label">To
|
|
2571
|
-
<input type="
|
|
3873
|
+
<form class="ee-compose-form" novalidate>
|
|
3874
|
+
<div class="ee-compose-row">
|
|
3875
|
+
<label class="ee-compose-label" for="${this._composeId('to')}">To</label>
|
|
3876
|
+
<input type="text" class="ee-compose-input" id="${this._composeId('to')}" name="to" autocomplete="off" spellcheck="false">
|
|
3877
|
+
<button type="button" class="ee-compose-link" data-action="show-cc">Cc / Bcc</button>
|
|
3878
|
+
</div>
|
|
3879
|
+
<div class="ee-compose-row" data-field="cc" hidden>
|
|
3880
|
+
<label class="ee-compose-label" for="${this._composeId('cc')}">Cc</label>
|
|
3881
|
+
<input type="text" class="ee-compose-input" id="${this._composeId('cc')}" name="cc" autocomplete="off" spellcheck="false">
|
|
3882
|
+
</div>
|
|
3883
|
+
<div class="ee-compose-row" data-field="bcc" hidden>
|
|
3884
|
+
<label class="ee-compose-label" for="${this._composeId('bcc')}">Bcc</label>
|
|
3885
|
+
<input type="text" class="ee-compose-input" id="${this._composeId('bcc')}" name="bcc" autocomplete="off" spellcheck="false">
|
|
3886
|
+
</div>
|
|
3887
|
+
<div class="ee-compose-row">
|
|
3888
|
+
<label class="ee-compose-label" for="${this._composeId('subject')}">Subject</label>
|
|
3889
|
+
<input type="text" class="ee-compose-input" id="${this._composeId('subject')}" name="subject">
|
|
2572
3890
|
</div>
|
|
2573
|
-
<div class="ee-compose-
|
|
2574
|
-
|
|
2575
|
-
|
|
3891
|
+
<div class="ee-compose-toolbar" role="toolbar" aria-label="Formatting">
|
|
3892
|
+
${this._formatButton('bold', 'bold', 'Bold')}
|
|
3893
|
+
${this._formatButton('italic', 'italic', 'Italic')}
|
|
3894
|
+
${this._formatButton('insertUnorderedList', 'list', 'Bulleted list')}
|
|
3895
|
+
${this._formatButton('insertOrderedList', 'listOrdered', 'Numbered list')}
|
|
3896
|
+
<button type="button" class="ee-compose-format" data-action="link" aria-label="Link" title="Link">${icon('link', 16)}</button>
|
|
2576
3897
|
</div>
|
|
2577
|
-
<div class="ee-compose-
|
|
2578
|
-
<
|
|
2579
|
-
<
|
|
3898
|
+
<div class="ee-compose-linkbar" hidden>
|
|
3899
|
+
<input type="url" class="ee-compose-input" name="link" aria-label="Link address" placeholder="https://" autocomplete="off">
|
|
3900
|
+
<button type="button" class="ee-compose-small-button" data-action="insert-link">Add link</button>
|
|
3901
|
+
<button type="button" class="ee-compose-small-button" data-action="cancel-link">Cancel</button>
|
|
3902
|
+
</div>
|
|
3903
|
+
<div class="ee-compose-editor" contenteditable="true" role="textbox" aria-multiline="true" aria-label="Message" data-placeholder="Write your message"></div>
|
|
3904
|
+
<div class="ee-compose-chips"></div>
|
|
3905
|
+
<div class="ee-compose-quote" hidden>
|
|
3906
|
+
<button type="button" class="ee-compose-quote-toggle" aria-expanded="false" title="Show the quoted message">${icon('more', 16)}<span class="ee-compose-quote-toggle-label"></span></button>
|
|
3907
|
+
<div class="ee-compose-quote-content" hidden>
|
|
3908
|
+
<div class="ee-compose-quote-header"></div>
|
|
3909
|
+
<div class="ee-compose-quote-frame"></div>
|
|
3910
|
+
</div>
|
|
2580
3911
|
</div>
|
|
2581
3912
|
</form>
|
|
3913
|
+
<div class="ee-compose-error" role="alert" hidden></div>
|
|
2582
3914
|
<div class="ee-compose-actions">
|
|
2583
|
-
<button type="button" class="ee-compose-cancel">Cancel</button>
|
|
2584
|
-
<button type="button" class="ee-compose-save-draft">Save Draft</button>
|
|
2585
3915
|
<button type="button" class="ee-compose-send">Send</button>
|
|
3916
|
+
<button type="button" class="ee-compose-icon-button" data-action="attach" aria-label="Attach files" title="Attach files">${icon('paperclip', 18)}</button>
|
|
3917
|
+
<input type="file" class="ee-compose-file-input" multiple hidden>
|
|
3918
|
+
<button type="button" class="ee-compose-save-draft">Save draft</button>
|
|
3919
|
+
<button type="button" class="ee-compose-icon-button" data-action="discard" aria-label="Discard" title="Discard">${icon('trash', 18)}</button>
|
|
2586
3920
|
</div>
|
|
2587
3921
|
</div>
|
|
2588
3922
|
</div>
|
|
2589
3923
|
`;
|
|
2590
3924
|
|
|
3925
|
+
// Folder rows are rebuilt on every count change, so their clicks are taken here once
|
|
3926
|
+
this.container.querySelector('.ee-folder-tree').addEventListener('click', e => {
|
|
3927
|
+
const row = e.target.closest('.ee-folder-content');
|
|
3928
|
+
if (row) {
|
|
3929
|
+
this._fireAndForget(this.openFolder(row.closest('.ee-folder-item').getAttribute('data-path')));
|
|
3930
|
+
}
|
|
3931
|
+
});
|
|
3932
|
+
|
|
2591
3933
|
// Pane navigation in the single-pane layout, delegated because the panes
|
|
2592
3934
|
// re-render their headers on every load
|
|
2593
3935
|
this.container.querySelector('.ee-client').addEventListener('click', e => {
|
|
@@ -2604,144 +3946,724 @@ export class EmailEngineClient {
|
|
|
2604
3946
|
this.positionComposeButton();
|
|
2605
3947
|
}
|
|
2606
3948
|
|
|
3949
|
+
// Unique element ids for the compose form labels, so two clients on one page do not share them
|
|
3950
|
+
_composeId(field) {
|
|
3951
|
+
if (!this._composeIdPrefix) {
|
|
3952
|
+
EmailEngineClient._composeCounter = (EmailEngineClient._composeCounter || 0) + 1;
|
|
3953
|
+
this._composeIdPrefix = `ee-compose-${EmailEngineClient._composeCounter}`;
|
|
3954
|
+
}
|
|
3955
|
+
return `${this._composeIdPrefix}-${field}`;
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
// A formatting toolbar button. Static arguments only, never message data.
|
|
3959
|
+
_formatButton(command, iconName, label) {
|
|
3960
|
+
return `<button type="button" class="ee-compose-format" data-command="${command}" aria-label="${label}" title="${label}" aria-pressed="false">${icon(iconName, 16)}</button>`;
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
// Opens a blank compose form, optionally prefilled: { to, cc, bcc, subject, text, html }. The
|
|
3964
|
+
// address fields take a string or address entries; html is filtered to what the editor keeps.
|
|
3965
|
+
// Resolves false when the user kept an unsaved message open instead.
|
|
3966
|
+
compose(prefill = {}) {
|
|
3967
|
+
return this._openCompose({ ...prefill, mode: 'new' });
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
// Opens the compose form as a reply to a message (the open one when messageId is omitted)
|
|
3971
|
+
reply(messageId = null, { all = false } = {}) {
|
|
3972
|
+
return this._respond(messageId, all ? 'reply-all' : 'reply');
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3975
|
+
// Opens the compose form to forward a message (the open one when messageId is omitted)
|
|
3976
|
+
forward(messageId = null) {
|
|
3977
|
+
return this._respond(messageId, 'forward');
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
async _respond(messageId, action) {
|
|
3981
|
+
const id = messageId || (this.currentMessage && this.currentMessage.id);
|
|
3982
|
+
if (!id) {
|
|
3983
|
+
throw new Error('No message to respond to');
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
const [msg, ownAddress] = await Promise.all([
|
|
3987
|
+
this.currentMessage && this.currentMessage.id === id ? this.currentMessage : this.apiRequest('GET', this._messagePath(id, '?webSafeHtml=true')),
|
|
3988
|
+
// Without it the account's own address may stay among the reply-all recipients
|
|
3989
|
+
this._getAccountInfo().then(
|
|
3990
|
+
info => info && info.email,
|
|
3991
|
+
() => null
|
|
3992
|
+
)
|
|
3993
|
+
]);
|
|
3994
|
+
|
|
3995
|
+
return this._openCompose({ mode: action, original: msg, ...this.prepareResponse(msg, action, ownAddress) });
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
/**
|
|
3999
|
+
* Opens a stored draft in the compose form (the open message when messageId is omitted).
|
|
4000
|
+
* Saving replaces the stored draft, sending removes it. The draft's HTML is filtered to what
|
|
4001
|
+
* the editor keeps, so a quote keeps its paragraphs, emphasis and quote bars but not a layout
|
|
4002
|
+
* of its own; its files come along as attachments.
|
|
4003
|
+
*
|
|
4004
|
+
* @param {string} [messageId]
|
|
4005
|
+
* @returns {Promise<boolean>} false when the user kept another unsaved message open instead
|
|
4006
|
+
*/
|
|
4007
|
+
async editDraft(messageId = null) {
|
|
4008
|
+
const id = messageId || (this.currentMessage && this.currentMessage.id);
|
|
4009
|
+
if (!id) {
|
|
4010
|
+
throw new Error('No draft to edit');
|
|
4011
|
+
}
|
|
4012
|
+
const msg = await this.apiRequest('GET', this._messagePath(id, '?textType=*'));
|
|
4013
|
+
const text = msg.text || {};
|
|
4014
|
+
return this._openCompose({
|
|
4015
|
+
mode: 'draft',
|
|
4016
|
+
to: msg.to,
|
|
4017
|
+
cc: msg.cc,
|
|
4018
|
+
bcc: msg.bcc,
|
|
4019
|
+
subject: msg.subject || '',
|
|
4020
|
+
html: text.html || textToEditorHtml(text.plain || ''),
|
|
4021
|
+
attachments: listedAttachments(msg.attachments).map(referenceAttachment),
|
|
4022
|
+
headers: threadingHeaders(msg),
|
|
4023
|
+
draftId: id
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
async _openCompose(state = {}) {
|
|
4028
|
+
const els = this._compose && this._compose.els;
|
|
4029
|
+
if (!els) {
|
|
4030
|
+
throw new Error('The compose form needs the client UI (a container)');
|
|
4031
|
+
}
|
|
4032
|
+
if (!(await this._settleOpenCompose())) {
|
|
4033
|
+
return false;
|
|
4034
|
+
}
|
|
4035
|
+
this._fillCompose(state);
|
|
4036
|
+
this._showCompose();
|
|
4037
|
+
return true;
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
// Puts a compose state into the form: fields, editor content, attachments and the quote
|
|
4041
|
+
_fillCompose({ mode = 'new', to, cc, bcc, subject, text, html, reference = null, original = null, attachments = [], headers = null, draftId = null }) {
|
|
4042
|
+
this._resetCompose();
|
|
4043
|
+
const { els } = this._compose;
|
|
4044
|
+
Object.assign(this._compose, {
|
|
4045
|
+
mode,
|
|
4046
|
+
reference,
|
|
4047
|
+
original,
|
|
4048
|
+
headers,
|
|
4049
|
+
draftId,
|
|
4050
|
+
files: (attachments || []).filter(att => att && att.reference).map(att => ({ ...att, kind: 'reference' }))
|
|
4051
|
+
});
|
|
4052
|
+
|
|
4053
|
+
const asField = value => (typeof value === 'string' ? value : this.formatAddressList(value));
|
|
4054
|
+
const { form, editor } = els;
|
|
4055
|
+
form.elements.to.value = asField(to);
|
|
4056
|
+
form.elements.cc.value = asField(cc);
|
|
4057
|
+
form.elements.bcc.value = asField(bcc);
|
|
4058
|
+
form.elements.subject.value = subject || '';
|
|
4059
|
+
editor.innerHTML = html ? sanitizeEditorHtml(html) : textToEditorHtml(text || '');
|
|
4060
|
+
this._updateEditorEmpty();
|
|
4061
|
+
this._showCopyFields({ cc: !!form.elements.cc.value, bcc: !!form.elements.bcc.value });
|
|
4062
|
+
|
|
4063
|
+
els.title.textContent = COMPOSE_TITLES[mode] || COMPOSE_TITLES.new;
|
|
4064
|
+
if (original && reference && reference.inline) {
|
|
4065
|
+
this._renderComposeQuote(original, mode);
|
|
4066
|
+
}
|
|
4067
|
+
this._renderComposeChips();
|
|
4068
|
+
this._compose.snapshot = this._composeSnapshot();
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
_showCompose() {
|
|
4072
|
+
const { els } = this._compose;
|
|
4073
|
+
els.root.hidden = false;
|
|
4074
|
+
this._setComposeMinimized(false);
|
|
4075
|
+
const { form, editor } = els;
|
|
4076
|
+
if (form.elements.to.value) {
|
|
4077
|
+
editor.focus();
|
|
4078
|
+
placeCaretAtStart(editor);
|
|
4079
|
+
} else {
|
|
4080
|
+
form.elements.to.focus();
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
|
|
4084
|
+
_isComposeOpen() {
|
|
4085
|
+
return !!(this._compose && this._compose.els && !this._compose.els.root.hidden);
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
// What the form holds, to tell whether anything changed since it was opened
|
|
4089
|
+
_composeSnapshot() {
|
|
4090
|
+
const { form, editor } = this._compose.els;
|
|
4091
|
+
return JSON.stringify([
|
|
4092
|
+
['to', 'cc', 'bcc', 'subject'].map(key => form.elements[key].value),
|
|
4093
|
+
editor.innerHTML,
|
|
4094
|
+
this._compose.files.map(entry => (entry.kind === 'reference' ? entry.reference : entry.file.name))
|
|
4095
|
+
]);
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
_isComposeDirty() {
|
|
4099
|
+
return this._isComposeOpen() && this._compose.snapshot !== this._composeSnapshot();
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
// Before the form is closed or reused: a changed message is saved as a draft or discarded, as
|
|
4103
|
+
// the user chooses. Resolves false when the question was dismissed or saving failed, so the
|
|
4104
|
+
// message stays on screen.
|
|
4105
|
+
async _settleOpenCompose() {
|
|
4106
|
+
if (!this._isComposeDirty()) {
|
|
4107
|
+
return true;
|
|
4108
|
+
}
|
|
4109
|
+
this._setComposeMinimized(false);
|
|
4110
|
+
const save = await this.confirmMethod('Save the message you are writing as a draft?', 'Unsaved message', 'Discard', 'Save draft');
|
|
4111
|
+
// A host dialog closed without either button (its close button, Escape, the backdrop)
|
|
4112
|
+
// answers null, and that is no decision to throw the message away: it stays on screen
|
|
4113
|
+
if (save === null) {
|
|
4114
|
+
return false;
|
|
4115
|
+
}
|
|
4116
|
+
if (!save) {
|
|
4117
|
+
return true;
|
|
4118
|
+
}
|
|
4119
|
+
return this._saveComposeDraft();
|
|
4120
|
+
}
|
|
4121
|
+
|
|
4122
|
+
// Closes the form, asking first when it holds unsaved changes
|
|
4123
|
+
async _requestCloseCompose() {
|
|
4124
|
+
if (await this._settleOpenCompose()) {
|
|
4125
|
+
this._closeCompose();
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
_setComposeMinimized(minimized) {
|
|
4130
|
+
const { dialog, minimizeButton } = this._compose.els;
|
|
4131
|
+
dialog.classList.toggle('minimized', minimized);
|
|
4132
|
+
const label = minimized ? 'Restore' : 'Minimize';
|
|
4133
|
+
minimizeButton.setAttribute('aria-label', label);
|
|
4134
|
+
minimizeButton.title = label;
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
// The message being answered or forwarded, read-only under the editor. The quote that is sent
|
|
4138
|
+
// is built by the server from the stored original; this shows what it will contain. A reply's
|
|
4139
|
+
// quote starts folded, a forward's open, with the forwarded message's own header above it.
|
|
4140
|
+
_renderComposeQuote(original, mode) {
|
|
4141
|
+
const { quote } = this._compose.els;
|
|
4142
|
+
const forward = mode === 'forward';
|
|
4143
|
+
quote.querySelector('.ee-compose-quote-header').innerHTML = forward ? this._forwardHeaderHtml(original) : '';
|
|
4144
|
+
// A shadow root cannot be attached twice, so each quote gets a fresh host
|
|
4145
|
+
const host = document.createElement('div');
|
|
4146
|
+
host.className = 'ee-compose-quote-body';
|
|
4147
|
+
quote.querySelector('.ee-compose-quote-frame').replaceChildren(host);
|
|
4148
|
+
this._labelCollapsedThreads(this._renderMessageBody(host, original));
|
|
4149
|
+
quote.hidden = false;
|
|
4150
|
+
this._setQuoteExpanded(forward);
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
_setQuoteExpanded(expanded) {
|
|
4154
|
+
const { quote } = this._compose.els;
|
|
4155
|
+
const toggle = quote.querySelector('.ee-compose-quote-toggle');
|
|
4156
|
+
const forward = this._compose.mode === 'forward';
|
|
4157
|
+
toggle.setAttribute('aria-expanded', String(expanded));
|
|
4158
|
+
const label = `${expanded ? 'Hide' : 'Show'} ${forward ? 'forwarded message' : 'quoted text'}`;
|
|
4159
|
+
toggle.title = label;
|
|
4160
|
+
toggle.querySelector('.ee-compose-quote-toggle-label').textContent = label;
|
|
4161
|
+
quote.querySelector('.ee-compose-quote-content').hidden = !expanded;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
// The header of a forwarded message, as the server adds it to the sent message
|
|
4165
|
+
_forwardHeaderHtml(original) {
|
|
4166
|
+
const rows = [
|
|
4167
|
+
['From', this._addressListHtml(original.from)],
|
|
4168
|
+
['Date', this.escapeHtml(this.formatFullDate(original.date))],
|
|
4169
|
+
['Subject', this.escapeHtml(original.subject || '(no subject)')],
|
|
4170
|
+
['To', this._addressListHtml(original.to)],
|
|
4171
|
+
['Cc', this._addressListHtml(original.cc)]
|
|
4172
|
+
].filter(([, value]) => value);
|
|
4173
|
+
return `
|
|
4174
|
+
<div class="ee-forward-title">Forwarded message</div>
|
|
4175
|
+
${rows.map(([label, value]) => `<div class="ee-forward-row"><span class="ee-forward-label">${label}</span><span>${value}</span></div>`).join('')}
|
|
4176
|
+
`;
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4179
|
+
// Shows the Cc and Bcc fields named true and hides the rest; the link offers whichever is hidden
|
|
4180
|
+
_showCopyFields(show) {
|
|
4181
|
+
const { form } = this._compose.els;
|
|
4182
|
+
const hidden = [];
|
|
4183
|
+
for (const key of ['cc', 'bcc']) {
|
|
4184
|
+
form.querySelector(`[data-field="${key}"]`).hidden = !show[key];
|
|
4185
|
+
if (!show[key]) {
|
|
4186
|
+
hidden.push(key === 'cc' ? 'Cc' : 'Bcc');
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
const link = form.querySelector('[data-action="show-cc"]');
|
|
4190
|
+
link.hidden = !hidden.length;
|
|
4191
|
+
link.textContent = hidden.join(' / ');
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
// Empties the form and starts a new compose state; the element references are kept
|
|
4195
|
+
_resetCompose() {
|
|
4196
|
+
const { els } = this._compose;
|
|
4197
|
+
els.form.reset();
|
|
4198
|
+
els.editor.replaceChildren();
|
|
4199
|
+
els.chips.replaceChildren();
|
|
4200
|
+
els.fileInput.value = '';
|
|
4201
|
+
els.linkbar.hidden = true;
|
|
4202
|
+
els.quote.hidden = true;
|
|
4203
|
+
els.quote.querySelector('.ee-compose-quote-header').replaceChildren();
|
|
4204
|
+
els.quote.querySelector('.ee-compose-quote-frame').replaceChildren();
|
|
4205
|
+
this._clearComposeError();
|
|
4206
|
+
this._compose = { els, mode: 'new', reference: null, original: null, headers: null, draftId: null, files: [], snapshot: null };
|
|
4207
|
+
this._showCopyFields({ cc: false, bcc: false });
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
_closeCompose() {
|
|
4211
|
+
if (this._compose && this._compose.els) {
|
|
4212
|
+
this._compose.els.root.hidden = true;
|
|
4213
|
+
this._resetCompose();
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
// Shows why the form cannot go out, inside the form itself, and marks the field it is about.
|
|
4218
|
+
// The message stays until the form is changed or closed.
|
|
4219
|
+
_showComposeError(message, field = null) {
|
|
4220
|
+
const { form, error, editor } = this._compose.els;
|
|
4221
|
+
this._clearComposeError();
|
|
4222
|
+
error.textContent = message;
|
|
4223
|
+
error.hidden = false;
|
|
4224
|
+
const input = field === 'message' ? editor : field ? form.elements[field] : null;
|
|
4225
|
+
if (input) {
|
|
4226
|
+
input.setAttribute('aria-invalid', 'true');
|
|
4227
|
+
input.focus();
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
_clearComposeError() {
|
|
4232
|
+
const { dialog, error } = this._compose.els;
|
|
4233
|
+
error.hidden = true;
|
|
4234
|
+
dialog.querySelectorAll('[aria-invalid]').forEach(input => input.removeAttribute('aria-invalid'));
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
// Attachment chips: picked files, and the original's files of a forward or the files of a
|
|
4238
|
+
// reopened draft, which travel as references. Each can be removed.
|
|
4239
|
+
_renderComposeChips() {
|
|
4240
|
+
this._compose.els.chips.innerHTML = this._compose.files
|
|
4241
|
+
.map((entry, index) => {
|
|
4242
|
+
const name = entry.kind === 'reference' ? entry.filename || 'Unnamed attachment' : entry.file.name;
|
|
4243
|
+
const size = entry.kind === 'reference' ? entry.size : entry.file.size;
|
|
4244
|
+
return `
|
|
4245
|
+
<span class="ee-compose-chip">
|
|
4246
|
+
${icon('paperclip', 12)}
|
|
4247
|
+
<span class="ee-compose-chip-name">${this.escapeHtml(name)}</span>
|
|
4248
|
+
${size ? `<span class="ee-compose-chip-size">${this.formatFileSize(size)}</span>` : ''}
|
|
4249
|
+
<button type="button" class="ee-compose-chip-remove" data-index="${index}" aria-label="Remove ${this.escapeHtml(name)}" title="Remove">${icon('close', 12)}</button>
|
|
4250
|
+
</span>`;
|
|
4251
|
+
})
|
|
4252
|
+
.join('');
|
|
4253
|
+
}
|
|
4254
|
+
|
|
4255
|
+
_readFileAsBase64(file) {
|
|
4256
|
+
return new Promise((resolve, reject) => {
|
|
4257
|
+
const reader = new FileReader();
|
|
4258
|
+
reader.onload = () => {
|
|
4259
|
+
const result = String(reader.result || '');
|
|
4260
|
+
resolve(result.slice(result.indexOf(',') + 1));
|
|
4261
|
+
};
|
|
4262
|
+
reader.onerror = () => reject(reader.error || new Error(`Could not read ${file.name}`));
|
|
4263
|
+
reader.readAsDataURL(file);
|
|
4264
|
+
});
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4267
|
+
// Takes picked files into the form within the size limit. They are kept as File objects and
|
|
4268
|
+
// read only when the message is sent, so a removed file is never read at all. Files of the
|
|
4269
|
+
// original travel as references and do not count against the limit.
|
|
4270
|
+
_addComposeFiles(files) {
|
|
4271
|
+
let total = this._compose.files.reduce((sum, entry) => sum + (entry.kind === 'file' ? entry.file.size : 0), 0);
|
|
4272
|
+
const skipped = [];
|
|
4273
|
+
for (const file of files) {
|
|
4274
|
+
if (total + file.size > this.maxAttachmentSize) {
|
|
4275
|
+
skipped.push(file.name);
|
|
4276
|
+
continue;
|
|
4277
|
+
}
|
|
4278
|
+
total += file.size;
|
|
4279
|
+
this._compose.files.push({ kind: 'file', file });
|
|
4280
|
+
}
|
|
4281
|
+
this._renderComposeChips();
|
|
4282
|
+
if (skipped.length) {
|
|
4283
|
+
this._showComposeError(`Attachments are limited to ${this.formatFileSize(this.maxAttachmentSize)} in total. Not attached: ${skipped.join(', ')}`);
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
|
|
4287
|
+
_readComposeAttachments(files) {
|
|
4288
|
+
return Promise.all(
|
|
4289
|
+
// a reference entry goes as it is; attachmentPayload keeps only the fields it sends
|
|
4290
|
+
files.map(async entry =>
|
|
4291
|
+
entry.kind === 'reference'
|
|
4292
|
+
? entry
|
|
4293
|
+
: {
|
|
4294
|
+
filename: entry.file.name,
|
|
4295
|
+
contentType: entry.file.type || 'application/octet-stream',
|
|
4296
|
+
content: await this._readFileAsBase64(entry.file)
|
|
4297
|
+
}
|
|
4298
|
+
)
|
|
4299
|
+
);
|
|
4300
|
+
}
|
|
4301
|
+
|
|
4302
|
+
// The form as a message object, plus the first reason it cannot go out as asked (null when it
|
|
4303
|
+
// can). requireMessage applies the send rules: a recipient, and some text unless the message
|
|
4304
|
+
// is a forward.
|
|
4305
|
+
_readComposeForm(requireMessage) {
|
|
4306
|
+
const { form, editor } = this._compose.els;
|
|
4307
|
+
const { reference, headers } = this._compose;
|
|
4308
|
+
const fields = {};
|
|
4309
|
+
const invalid = [];
|
|
4310
|
+
for (const key of ['to', 'cc', 'bcc']) {
|
|
4311
|
+
fields[key] = this.parseAddressList(form.elements[key].value);
|
|
4312
|
+
invalid.push(...fields[key].filter(entry => !ADDRESS_PATTERN.test(entry.address)).map(entry => entry.address || entry.name));
|
|
4313
|
+
}
|
|
4314
|
+
|
|
4315
|
+
const text = editorText(editor);
|
|
4316
|
+
const html = text ? sanitizeEditorHtml(editor.innerHTML) : '';
|
|
4317
|
+
|
|
4318
|
+
const message = { to: fields.to, cc: fields.cc, bcc: fields.bcc, subject: form.elements.subject.value.trim(), text, html, reference, headers };
|
|
4319
|
+
const isForward = !!reference && reference.action === 'forward';
|
|
4320
|
+
const empty = !fields.to.length && !fields.cc.length && !fields.bcc.length && !message.subject && !text && !this._compose.files.length && !reference;
|
|
4321
|
+
|
|
4322
|
+
let problem = null;
|
|
4323
|
+
if (requireMessage && !fields.to.length) {
|
|
4324
|
+
problem = { message: 'Add at least one recipient.', field: 'to' };
|
|
4325
|
+
} else if (!requireMessage && empty) {
|
|
4326
|
+
problem = { message: 'Nothing to save - fill in at least one field first.', field: 'to' };
|
|
4327
|
+
} else if (invalid.length) {
|
|
4328
|
+
problem = { message: `Not a valid email address: ${invalid.join(', ')}`, field: 'to' };
|
|
4329
|
+
} else if (requireMessage && !text && !isForward) {
|
|
4330
|
+
// A forward can go without a note of its own; anything else needs some text
|
|
4331
|
+
problem = { message: 'Write a message before sending.', field: 'message' };
|
|
4332
|
+
}
|
|
4333
|
+
return { message, problem };
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
// Runs a compose request with its button showing progress. The form is checked first, the
|
|
4337
|
+
// picked files are read, and on success the form closes and the result is returned; on any
|
|
4338
|
+
// failure the reason is shown over the form, kept as it was, and the result is null.
|
|
4339
|
+
async _runComposeAction(button, busyText, errorTitle, requireMessage, submit) {
|
|
4340
|
+
const { message, problem } = this._readComposeForm(requireMessage);
|
|
4341
|
+
if (problem) {
|
|
4342
|
+
this._showComposeError(problem.message, problem.field);
|
|
4343
|
+
return null;
|
|
4344
|
+
}
|
|
4345
|
+
this._clearComposeError();
|
|
4346
|
+
|
|
4347
|
+
const originalText = button.textContent;
|
|
4348
|
+
button.disabled = true;
|
|
4349
|
+
button.textContent = busyText;
|
|
4350
|
+
try {
|
|
4351
|
+
message.attachments = await this._readComposeAttachments(this._compose.files);
|
|
4352
|
+
const result = await submit(message);
|
|
4353
|
+
this._closeCompose();
|
|
4354
|
+
return result || {};
|
|
4355
|
+
} catch (error) {
|
|
4356
|
+
console.error(`${errorTitle}:`, error);
|
|
4357
|
+
this._showComposeError(`${errorTitle}: ${this._formatSendError(error)}`);
|
|
4358
|
+
return null;
|
|
4359
|
+
} finally {
|
|
4360
|
+
button.disabled = false;
|
|
4361
|
+
button.textContent = originalText;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
// Saves the form as a draft, replacing the stored draft it was opened from. Resolves whether
|
|
4366
|
+
// it was saved; on failure the form stays open with the reason.
|
|
4367
|
+
async _saveComposeDraft() {
|
|
4368
|
+
const { draftId, els } = this._compose;
|
|
4369
|
+
const response = await this._runComposeAction(els.saveDraftButton, 'Saving...', 'Could not save the draft', false, message =>
|
|
4370
|
+
draftId ? this.updateDraft(draftId, message) : this.saveDraft(message)
|
|
4371
|
+
);
|
|
4372
|
+
if (!response) {
|
|
4373
|
+
return false;
|
|
4374
|
+
}
|
|
4375
|
+
this.notify('Draft saved.');
|
|
4376
|
+
this._afterDraftChange(draftId, response.path);
|
|
4377
|
+
return true;
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
// Brings the list and viewer up to date after a draft was saved, replaced or sent
|
|
4381
|
+
_afterDraftChange(oldDraftId, draftsPath) {
|
|
4382
|
+
if (this._destroyed) {
|
|
4383
|
+
return;
|
|
4384
|
+
}
|
|
4385
|
+
if (oldDraftId && this.currentMessage && this.currentMessage.id === oldDraftId) {
|
|
4386
|
+
this.currentMessage = null;
|
|
4387
|
+
this.renderMessage();
|
|
4388
|
+
this._notifyNavigate();
|
|
4389
|
+
}
|
|
4390
|
+
if (this.currentFolder && (this.currentFolder === draftsPath || this._isOutgoingFolder(this.currentFolder))) {
|
|
4391
|
+
this._fireAndForget(this.loadMessages(this.currentFolder));
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
|
|
4395
|
+
async _sendCompose() {
|
|
4396
|
+
const { draftId, els } = this._compose;
|
|
4397
|
+
const response = await this._runComposeAction(els.sendButton, 'Sending...', 'Could not send the message', true, message => this.sendMessage(message));
|
|
4398
|
+
if (!response) {
|
|
4399
|
+
return;
|
|
4400
|
+
}
|
|
4401
|
+
// Submitting only queues the message; delivery happens afterwards and can still fail
|
|
4402
|
+
this.notify('Message queued for delivery.');
|
|
4403
|
+
if (draftId) {
|
|
4404
|
+
await this._discardDraft(draftId);
|
|
4405
|
+
this._afterDraftChange(draftId, null);
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
async _discardCompose() {
|
|
4410
|
+
if (this._isComposeDirty()) {
|
|
4411
|
+
const discard = await this.confirmMethod('Discard this message?', 'Discard message', 'Cancel', 'Discard');
|
|
4412
|
+
if (!discard) {
|
|
4413
|
+
return;
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4416
|
+
this._closeCompose();
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
// The placeholder shows while the editor holds no text
|
|
4420
|
+
_updateEditorEmpty() {
|
|
4421
|
+
const { editor } = this._compose.els;
|
|
4422
|
+
editor.classList.toggle('ee-empty', !editor.textContent.trim() && !editor.querySelector('li, blockquote'));
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4425
|
+
// Marks the toolbar buttons whose format applies at the caret
|
|
4426
|
+
_updateFormatButtons() {
|
|
4427
|
+
const { editor, formatButtons } = this._compose.els;
|
|
4428
|
+
if (typeof document.queryCommandState !== 'function' || !editor.contains(document.activeElement)) {
|
|
4429
|
+
return;
|
|
4430
|
+
}
|
|
4431
|
+
for (const button of formatButtons) {
|
|
4432
|
+
let state = false;
|
|
4433
|
+
try {
|
|
4434
|
+
state = document.queryCommandState(button.dataset.command);
|
|
4435
|
+
} catch {
|
|
4436
|
+
// not supported
|
|
4437
|
+
}
|
|
4438
|
+
button.setAttribute('aria-pressed', String(state));
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
_openLinkbar() {
|
|
4443
|
+
const { editor, linkbar } = this._compose.els;
|
|
4444
|
+
const selection = window.getSelection();
|
|
4445
|
+
const range = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
|
|
4446
|
+
this._compose.linkRange = range && editor.contains(range.commonAncestorContainer) ? range.cloneRange() : null;
|
|
4447
|
+
const input = linkbar.querySelector('[name="link"]');
|
|
4448
|
+
input.value = '';
|
|
4449
|
+
linkbar.hidden = false;
|
|
4450
|
+
input.focus();
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
// Hides the link field and puts the selection back where it was in the editor
|
|
4454
|
+
_closeLinkbar() {
|
|
4455
|
+
const { editor, linkbar } = this._compose.els;
|
|
4456
|
+
linkbar.hidden = true;
|
|
4457
|
+
editor.focus();
|
|
4458
|
+
const range = this._compose.linkRange;
|
|
4459
|
+
if (range) {
|
|
4460
|
+
const selection = window.getSelection();
|
|
4461
|
+
selection.removeAllRanges();
|
|
4462
|
+
selection.addRange(range);
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
|
|
4466
|
+
// Turns the selection into a link, or inserts the address as one at the caret. Only http(s)
|
|
4467
|
+
// and mailto addresses are taken; a bare host gets https://.
|
|
4468
|
+
_insertLink() {
|
|
4469
|
+
const { linkbar } = this._compose.els;
|
|
4470
|
+
const input = linkbar.querySelector('[name="link"]');
|
|
4471
|
+
let url = input.value.trim();
|
|
4472
|
+
if (!url) {
|
|
4473
|
+
this._closeLinkbar();
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4476
|
+
if (!/^[a-z][a-z0-9+.-]*:/i.test(url)) {
|
|
4477
|
+
url = url.includes('@') && !url.includes('/') ? `mailto:${url}` : `https://${url}`;
|
|
4478
|
+
}
|
|
4479
|
+
if (!SAFE_LINK.test(url)) {
|
|
4480
|
+
this._showComposeError('Links must start with http://, https:// or mailto:');
|
|
4481
|
+
input.focus();
|
|
4482
|
+
return;
|
|
4483
|
+
}
|
|
4484
|
+
this._closeLinkbar();
|
|
4485
|
+
const range = this._compose.linkRange;
|
|
4486
|
+
if (!range || range.collapsed) {
|
|
4487
|
+
const label = url.replace(/^mailto:/i, '');
|
|
4488
|
+
document.execCommand('insertHTML', false, `<a href="${this.escapeHtml(url)}">${this.escapeHtml(label)}</a>`);
|
|
4489
|
+
} else {
|
|
4490
|
+
document.execCommand('createLink', false, url);
|
|
4491
|
+
}
|
|
4492
|
+
this._updateEditorEmpty();
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
// Pasted and dropped content goes through the editor's filter; files become attachments
|
|
4496
|
+
_onEditorPaste(e) {
|
|
4497
|
+
const data = e.clipboardData;
|
|
4498
|
+
if (!data) {
|
|
4499
|
+
return;
|
|
4500
|
+
}
|
|
4501
|
+
e.preventDefault();
|
|
4502
|
+
const html = data.getData('text/html');
|
|
4503
|
+
const text = data.getData('text/plain');
|
|
4504
|
+
if (html) {
|
|
4505
|
+
document.execCommand('insertHTML', false, sanitizeEditorHtml(html));
|
|
4506
|
+
} else if (text) {
|
|
4507
|
+
document.execCommand('insertText', false, text);
|
|
4508
|
+
} else if (data.files && data.files.length) {
|
|
4509
|
+
this._addComposeFiles(Array.from(data.files));
|
|
4510
|
+
}
|
|
4511
|
+
this._updateEditorEmpty();
|
|
4512
|
+
}
|
|
4513
|
+
|
|
2607
4514
|
setupComposeModal() {
|
|
2608
4515
|
if (typeof document === 'undefined' || !this.container) {
|
|
2609
4516
|
return;
|
|
2610
4517
|
}
|
|
2611
4518
|
|
|
2612
|
-
const
|
|
2613
|
-
const
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
modal.classList.remove('show');
|
|
2631
|
-
form.reset();
|
|
4519
|
+
const root = this.container.querySelector('.ee-compose');
|
|
4520
|
+
const dialog = root.querySelector('.ee-compose-dialog');
|
|
4521
|
+
const els = {
|
|
4522
|
+
root,
|
|
4523
|
+
dialog,
|
|
4524
|
+
form: dialog.querySelector('.ee-compose-form'),
|
|
4525
|
+
title: dialog.querySelector('.ee-compose-title'),
|
|
4526
|
+
editor: dialog.querySelector('.ee-compose-editor'),
|
|
4527
|
+
toolbar: dialog.querySelector('.ee-compose-toolbar'),
|
|
4528
|
+
formatButtons: Array.from(dialog.querySelectorAll('.ee-compose-format[data-command]')),
|
|
4529
|
+
linkbar: dialog.querySelector('.ee-compose-linkbar'),
|
|
4530
|
+
chips: dialog.querySelector('.ee-compose-chips'),
|
|
4531
|
+
fileInput: dialog.querySelector('.ee-compose-file-input'),
|
|
4532
|
+
quote: dialog.querySelector('.ee-compose-quote'),
|
|
4533
|
+
error: dialog.querySelector('.ee-compose-error'),
|
|
4534
|
+
sendButton: dialog.querySelector('.ee-compose-send'),
|
|
4535
|
+
saveDraftButton: dialog.querySelector('.ee-compose-save-draft'),
|
|
4536
|
+
minimizeButton: dialog.querySelector('[data-action="minimize"]')
|
|
2632
4537
|
};
|
|
4538
|
+
this._compose = { els };
|
|
4539
|
+
this._resetCompose();
|
|
4540
|
+
|
|
4541
|
+
this.container
|
|
4542
|
+
.querySelectorAll('.ee-compose-button, .ee-sidebar-compose-button')
|
|
4543
|
+
.forEach(button => button.addEventListener('click', () => this._composeFailSafe(this.compose())));
|
|
4544
|
+
|
|
4545
|
+
this._bindComposeWindow(els);
|
|
4546
|
+
this._bindComposeEditor(els);
|
|
4547
|
+
this._bindComposeFields(els);
|
|
4548
|
+
}
|
|
2633
4549
|
|
|
2634
|
-
|
|
2635
|
-
|
|
4550
|
+
// A compose action started from a click has no caller to report to
|
|
4551
|
+
_composeFailSafe(promise) {
|
|
4552
|
+
return promise.catch(error => this._alertActionFailed(error, 'Something went wrong in the compose form'));
|
|
4553
|
+
}
|
|
2636
4554
|
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
4555
|
+
// Close, discard, minimize, and the keys that work anywhere in the form
|
|
4556
|
+
_bindComposeWindow(els) {
|
|
4557
|
+
const { dialog, linkbar } = els;
|
|
4558
|
+
dialog.querySelector('[data-action="close"]').addEventListener('click', () => this._composeFailSafe(this._requestCloseCompose()));
|
|
4559
|
+
dialog.querySelector('[data-action="discard"]').addEventListener('click', () => this._composeFailSafe(this._discardCompose()));
|
|
4560
|
+
els.minimizeButton.addEventListener('click', () => this._setComposeMinimized(!dialog.classList.contains('minimized')));
|
|
4561
|
+
// A minimized form comes back with a click on its title bar
|
|
4562
|
+
dialog.querySelector('.ee-compose-header').addEventListener('click', e => {
|
|
4563
|
+
if (dialog.classList.contains('minimized') && !e.target.closest('button')) {
|
|
4564
|
+
this._setComposeMinimized(false);
|
|
2641
4565
|
}
|
|
2642
4566
|
});
|
|
2643
4567
|
|
|
2644
|
-
//
|
|
4568
|
+
// Keys work while focus is in the form: Escape closes it (or the link field), Ctrl+Enter sends
|
|
2645
4569
|
this._composeKeydownHandler = e => {
|
|
2646
|
-
if (e.key === 'Escape'
|
|
2647
|
-
|
|
4570
|
+
if (e.key === 'Escape') {
|
|
4571
|
+
e.preventDefault();
|
|
4572
|
+
if (!linkbar.hidden) {
|
|
4573
|
+
this._closeLinkbar();
|
|
4574
|
+
} else {
|
|
4575
|
+
this._composeFailSafe(this._requestCloseCompose());
|
|
4576
|
+
}
|
|
4577
|
+
} else if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
|
4578
|
+
e.preventDefault();
|
|
4579
|
+
els.sendButton.click();
|
|
2648
4580
|
}
|
|
2649
4581
|
};
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
// Save the composed message as a draft instead of sending it
|
|
2653
|
-
saveDraftButton.addEventListener('click', async () => {
|
|
2654
|
-
const formData = new FormData(form);
|
|
2655
|
-
const to = formData.get('to').trim();
|
|
2656
|
-
const subject = formData.get('subject').trim();
|
|
2657
|
-
const message = formData.get('message').trim();
|
|
2658
|
-
|
|
2659
|
-
if (!to && !subject && !message) {
|
|
2660
|
-
modal.classList.remove('show');
|
|
2661
|
-
await this.alertMethod('Nothing to save - fill in at least one field first.', 'Validation Error', null, 'OK');
|
|
2662
|
-
modal.classList.add('show');
|
|
2663
|
-
setTimeout(() => form.querySelector('input[name="to"]').focus(), 100);
|
|
2664
|
-
return;
|
|
2665
|
-
}
|
|
4582
|
+
dialog.addEventListener('keydown', this._composeKeydownHandler);
|
|
2666
4583
|
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
4584
|
+
els.saveDraftButton.addEventListener('click', () => this._composeFailSafe(this._saveComposeDraft()));
|
|
4585
|
+
els.sendButton.addEventListener('click', () => this._composeFailSafe(this._sendCompose()));
|
|
4586
|
+
}
|
|
2670
4587
|
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
} finally {
|
|
2688
|
-
saveDraftButton.disabled = false;
|
|
2689
|
-
saveDraftButton.textContent = originalText;
|
|
4588
|
+
// The editor: typing state, paste and drop, the formatting toolbar and the link field
|
|
4589
|
+
_bindComposeEditor(els) {
|
|
4590
|
+
const { dialog, editor, toolbar, linkbar } = els;
|
|
4591
|
+
editor.addEventListener('input', () => this._updateEditorEmpty());
|
|
4592
|
+
editor.addEventListener('keyup', () => this._updateFormatButtons());
|
|
4593
|
+
editor.addEventListener('mouseup', () => this._updateFormatButtons());
|
|
4594
|
+
editor.addEventListener('paste', e => this._onEditorPaste(e));
|
|
4595
|
+
// Dropped files are attached; dropped markup would bypass the paste filter, so text only
|
|
4596
|
+
dialog.addEventListener('dragover', e => e.preventDefault());
|
|
4597
|
+
dialog.addEventListener('drop', e => {
|
|
4598
|
+
e.preventDefault();
|
|
4599
|
+
const files = e.dataTransfer && Array.from(e.dataTransfer.files || []);
|
|
4600
|
+
if (files && files.length) {
|
|
4601
|
+
this._addComposeFiles(files);
|
|
4602
|
+
} else if (e.dataTransfer && editor.contains(e.target)) {
|
|
4603
|
+
document.execCommand('insertText', false, e.dataTransfer.getData('text/plain'));
|
|
2690
4604
|
}
|
|
2691
4605
|
});
|
|
2692
4606
|
|
|
2693
|
-
//
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
if (
|
|
2701
|
-
|
|
2702
|
-
modal.classList.remove('show');
|
|
2703
|
-
await this.alertMethod('Please fill in the recipient and message fields.', 'Validation Error', null, 'OK');
|
|
2704
|
-
modal.classList.add('show');
|
|
2705
|
-
// Re-focus the appropriate field
|
|
2706
|
-
const fieldToFocus = !to ? form.querySelector('input[name="to"]') : form.querySelector('textarea[name="message"]');
|
|
2707
|
-
setTimeout(() => fieldToFocus.focus(), 100);
|
|
4607
|
+
// keep the selection in the editor while a toolbar button is pressed
|
|
4608
|
+
toolbar.addEventListener('mousedown', e => {
|
|
4609
|
+
if (e.target.closest('.ee-compose-format')) {
|
|
4610
|
+
e.preventDefault();
|
|
4611
|
+
}
|
|
4612
|
+
});
|
|
4613
|
+
toolbar.addEventListener('click', e => {
|
|
4614
|
+
if (e.target.closest('[data-action="link"]')) {
|
|
4615
|
+
this._openLinkbar();
|
|
2708
4616
|
return;
|
|
2709
4617
|
}
|
|
4618
|
+
const button = e.target.closest('.ee-compose-format[data-command]');
|
|
4619
|
+
if (button) {
|
|
4620
|
+
editor.focus();
|
|
4621
|
+
document.execCommand(button.dataset.command, false, null);
|
|
4622
|
+
this._updateEditorEmpty();
|
|
4623
|
+
this._updateFormatButtons();
|
|
4624
|
+
}
|
|
4625
|
+
});
|
|
4626
|
+
linkbar.querySelector('[data-action="insert-link"]').addEventListener('click', () => this._insertLink());
|
|
4627
|
+
linkbar.querySelector('[data-action="cancel-link"]').addEventListener('click', () => this._closeLinkbar());
|
|
4628
|
+
linkbar.querySelector('[name="link"]').addEventListener('keydown', e => {
|
|
4629
|
+
if (e.key === 'Enter') {
|
|
4630
|
+
e.preventDefault();
|
|
4631
|
+
this._insertLink();
|
|
4632
|
+
}
|
|
4633
|
+
});
|
|
4634
|
+
}
|
|
2710
4635
|
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
// Close modal before showing success alert
|
|
2719
|
-
closeModal();
|
|
2720
|
-
await this.alertMethod('Email sent successfully!', 'Success', null, 'OK');
|
|
2721
|
-
} catch (error) {
|
|
2722
|
-
console.error('Failed to send email:', error);
|
|
2723
|
-
// Close modal before showing error alert
|
|
2724
|
-
modal.classList.remove('show');
|
|
2725
|
-
const errorMessage = this._formatSendError(error);
|
|
2726
|
-
await this.alertMethod(errorMessage, 'Send Error', null, 'OK');
|
|
2727
|
-
|
|
2728
|
-
// Reopen modal with preserved values after error alert
|
|
2729
|
-
modal.classList.add('show');
|
|
2730
|
-
// Re-focus the To field to allow user to continue editing
|
|
2731
|
-
const toField = form.querySelector('input[name="to"]');
|
|
2732
|
-
setTimeout(() => toField.focus(), 100);
|
|
2733
|
-
} finally {
|
|
2734
|
-
// Re-enable send button
|
|
2735
|
-
sendButton.disabled = false;
|
|
2736
|
-
sendButton.textContent = originalText;
|
|
4636
|
+
// The address fields, attachments and the quote toggle
|
|
4637
|
+
_bindComposeFields(els) {
|
|
4638
|
+
const { dialog, form, fileInput, chips, quote } = els;
|
|
4639
|
+
// the editor's input bubbles here too
|
|
4640
|
+
form.addEventListener('input', () => {
|
|
4641
|
+
if (!els.error.hidden) {
|
|
4642
|
+
this._clearComposeError();
|
|
2737
4643
|
}
|
|
2738
4644
|
});
|
|
2739
4645
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
4646
|
+
quote.querySelector('.ee-compose-quote-toggle').addEventListener('click', e => {
|
|
4647
|
+
this._setQuoteExpanded(e.currentTarget.getAttribute('aria-expanded') !== 'true');
|
|
4648
|
+
});
|
|
4649
|
+
|
|
4650
|
+
form.querySelector('[data-action="show-cc"]').addEventListener('click', () => {
|
|
4651
|
+
const ccShown = !form.querySelector('[data-field="cc"]').hidden;
|
|
4652
|
+
this._showCopyFields({ cc: true, bcc: true });
|
|
4653
|
+
(ccShown ? form.elements.bcc : form.elements.cc).focus();
|
|
4654
|
+
});
|
|
4655
|
+
|
|
4656
|
+
dialog.querySelector('[data-action="attach"]').addEventListener('click', () => fileInput.click());
|
|
4657
|
+
fileInput.addEventListener('change', () => {
|
|
4658
|
+
const files = Array.from(fileInput.files || []);
|
|
4659
|
+
fileInput.value = '';
|
|
4660
|
+
this._addComposeFiles(files);
|
|
4661
|
+
});
|
|
4662
|
+
chips.addEventListener('click', e => {
|
|
4663
|
+
const remove = e.target.closest('.ee-compose-chip-remove');
|
|
4664
|
+
if (remove) {
|
|
4665
|
+
this._compose.files.splice(Number(remove.dataset.index), 1);
|
|
4666
|
+
this._renderComposeChips();
|
|
2745
4667
|
}
|
|
2746
4668
|
});
|
|
2747
4669
|
}
|
|
@@ -2756,26 +4678,24 @@ export class EmailEngineClient {
|
|
|
2756
4678
|
return;
|
|
2757
4679
|
}
|
|
2758
4680
|
|
|
4681
|
+
const sidebarCompose = this.container.querySelector('.ee-sidebar-compose');
|
|
2759
4682
|
const updateButtonPosition = () => {
|
|
2760
4683
|
const containerRect = this.container.getBoundingClientRect();
|
|
2761
4684
|
const margin = 20; // Desired margin from edges
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
//
|
|
2765
|
-
//
|
|
2766
|
-
//
|
|
2767
|
-
//
|
|
2768
|
-
|
|
4685
|
+
const buttonSize = 56;
|
|
4686
|
+
|
|
4687
|
+
// The floating button is the Compose button of the one-pane layout only. Whether
|
|
4688
|
+
// that layout is on is the stylesheet's container query to decide, so read its
|
|
4689
|
+
// answer (the folder pane's own Compose button is laid out) rather than repeat
|
|
4690
|
+
// the breakpoint. A hidden container (display: none) reports a zero-size rect;
|
|
4691
|
+
// the ResizeObserver below brings the button back once the container is shown.
|
|
4692
|
+
const wide = sidebarCompose && sidebarCompose.offsetParent !== null;
|
|
4693
|
+
if (wide || (!containerRect.width && !containerRect.height)) {
|
|
2769
4694
|
composeButton.style.display = 'none';
|
|
2770
4695
|
return;
|
|
2771
4696
|
}
|
|
2772
4697
|
composeButton.style.display = '';
|
|
2773
4698
|
|
|
2774
|
-
// A labelled pill on roomy layouts, a round icon button where width is
|
|
2775
|
-
// short and the button would cover too much of the single pane
|
|
2776
|
-
composeButton.classList.toggle('ee-compose-compact', containerRect.width < NARROW_WIDTH);
|
|
2777
|
-
const buttonSize = composeButton.offsetWidth || 56;
|
|
2778
|
-
|
|
2779
4699
|
// Calculate the ideal position (bottom-right of container with margin)
|
|
2780
4700
|
const idealBottom = window.innerHeight - containerRect.bottom + margin;
|
|
2781
4701
|
const idealRight = window.innerWidth - containerRect.right + margin;
|
|
@@ -2844,7 +4764,7 @@ export class EmailEngineClient {
|
|
|
2844
4764
|
init() {
|
|
2845
4765
|
if (typeof document === 'undefined') {
|
|
2846
4766
|
console.warn('EmailEngineClient UI features are only available in browser environments');
|
|
2847
|
-
return;
|
|
4767
|
+
return Promise.resolve(false);
|
|
2848
4768
|
}
|
|
2849
4769
|
|
|
2850
4770
|
this.createStyles();
|
|
@@ -2856,19 +4776,31 @@ export class EmailEngineClient {
|
|
|
2856
4776
|
toggleBtn.addEventListener('click', () => this.toggleDarkMode());
|
|
2857
4777
|
}
|
|
2858
4778
|
|
|
2859
|
-
this._loadInitialView();
|
|
4779
|
+
return this._loadInitialView();
|
|
2860
4780
|
}
|
|
2861
4781
|
|
|
2862
4782
|
// Load the folder list and open the account's inbox. Used on startup and by
|
|
2863
4783
|
// the Retry button that loadFolders renders when the request fails; both
|
|
2864
4784
|
// failure paths already put an error panel in the UI, so the rejection is
|
|
2865
4785
|
// logged and swallowed here rather than surfacing as an unhandled rejection.
|
|
4786
|
+
// Resolves whether the view loaded.
|
|
2866
4787
|
_loadInitialView() {
|
|
2867
4788
|
// Drop whatever a previous attempt left here; loadFolders and loadMessages
|
|
2868
4789
|
// paint their own loading states from this point on.
|
|
2869
4790
|
this._setPaneHtml('.ee-message-list', this._messageListPlaceholder());
|
|
2870
4791
|
|
|
2871
|
-
|
|
4792
|
+
// A deep-linked message loads alongside the folders, not after them. Only the first load
|
|
4793
|
+
// follows the link: a Retry after a folder failure starts from the inbox as usual. A
|
|
4794
|
+
// message that fails has already put its error in the viewer.
|
|
4795
|
+
const messageId = this.initialMessage;
|
|
4796
|
+
this.initialMessage = null;
|
|
4797
|
+
const message = messageId ? this.loadMessage(messageId).catch(() => null) : Promise.resolve(null);
|
|
4798
|
+
|
|
4799
|
+
// The folders come first without their unread counts: those cost a STATUS command per
|
|
4800
|
+
// folder on the IMAP connection the message and the listing are read over too, so asking
|
|
4801
|
+
// for them up front made the first view wait behind them - seconds on a distant server.
|
|
4802
|
+
// They follow once the view is up.
|
|
4803
|
+
return this.loadFolders({ counters: false })
|
|
2872
4804
|
.catch(error => {
|
|
2873
4805
|
// loadFolders reports into the sidebar, but the message list is the
|
|
2874
4806
|
// larger pane and would still read "Select a folder" - a folder the
|
|
@@ -2876,21 +4808,58 @@ export class EmailEngineClient {
|
|
|
2876
4808
|
this._renderPaneError('.ee-message-list', 'Folders unavailable', error, () => this._loadInitialView());
|
|
2877
4809
|
throw error;
|
|
2878
4810
|
})
|
|
2879
|
-
.then(() => {
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
this.folders[0];
|
|
2884
|
-
if (inbox) {
|
|
2885
|
-
return this.loadMessages(inbox.path);
|
|
2886
|
-
}
|
|
4811
|
+
.then(async () => {
|
|
4812
|
+
await this._listFolderOf(await message);
|
|
4813
|
+
this._fireAndForget(this._loadFolderCounters());
|
|
4814
|
+
return true;
|
|
2887
4815
|
})
|
|
2888
4816
|
.catch(error => {
|
|
2889
4817
|
// Both loadFolders and loadMessages have already rendered a panel
|
|
2890
4818
|
console.error('Failed to load the initial view:', error);
|
|
4819
|
+
return false;
|
|
2891
4820
|
});
|
|
2892
4821
|
}
|
|
2893
4822
|
|
|
4823
|
+
// Fetches the folder list again with unread counts and redraws the folder pane. Without them
|
|
4824
|
+
// the folders still work, so a failure only leaves the counts out.
|
|
4825
|
+
async _loadFolderCounters() {
|
|
4826
|
+
try {
|
|
4827
|
+
await this._fetchFolders(true);
|
|
4828
|
+
} catch (error) {
|
|
4829
|
+
console.warn('Failed to load folder counts:', error);
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
if (this.container && !this._destroyed) {
|
|
4833
|
+
this.renderFolderList();
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4837
|
+
_inboxFolder() {
|
|
4838
|
+
return (
|
|
4839
|
+
this.folders.find(f => f.specialUse && f.specialUse.includes('\\Inbox')) ||
|
|
4840
|
+
this.folders.find(f => f.name.toLowerCase() === 'inbox') ||
|
|
4841
|
+
this.folders[0]
|
|
4842
|
+
);
|
|
4843
|
+
}
|
|
4844
|
+
|
|
4845
|
+
// Lists the folder holding a message, or the inbox when there is no message or it reports no
|
|
4846
|
+
// folder (Gmail API accounts) or one that is not listed
|
|
4847
|
+
_listFolderOf(message) {
|
|
4848
|
+
const folder = (message && message.path && this.folders.find(f => f.path === message.path)) || this._inboxFolder();
|
|
4849
|
+
if (folder && !this._destroyed) {
|
|
4850
|
+
return this.loadMessages(folder.path);
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
|
|
4854
|
+
// Opens one message by its EmailEngine ID and lists the folder holding it. A message that
|
|
4855
|
+
// cannot be loaded leaves its error in the viewer and the inbox in the list, so the reader
|
|
4856
|
+
// still has somewhere to go.
|
|
4857
|
+
async openMessage(messageId) {
|
|
4858
|
+
const [message] = await Promise.all([this.loadMessage(messageId).catch(() => null), this.folders.length ? null : this.loadFolders()]);
|
|
4859
|
+
await this._listFolderOf(message);
|
|
4860
|
+
return message;
|
|
4861
|
+
}
|
|
4862
|
+
|
|
2894
4863
|
_updateActivity() {
|
|
2895
4864
|
this.lastActivity = Date.now();
|
|
2896
4865
|
}
|
|
@@ -2940,12 +4909,14 @@ export class EmailEngineClient {
|
|
|
2940
4909
|
|
|
2941
4910
|
// Update UI. The compose button and modal are siblings of .ee-client, so
|
|
2942
4911
|
// they carry the class themselves.
|
|
2943
|
-
this.container
|
|
4912
|
+
this.container
|
|
4913
|
+
.querySelectorAll('.ee-client, .ee-compose-button, .ee-compose, .ee-toast')
|
|
4914
|
+
.forEach(el => el.classList.toggle('ee-dark-mode', this.darkMode));
|
|
2944
4915
|
|
|
2945
4916
|
// Update toggle button icon
|
|
2946
|
-
const
|
|
2947
|
-
if (
|
|
2948
|
-
|
|
4917
|
+
const toggleIcon = this.container.querySelector('.ee-dark-mode-icon');
|
|
4918
|
+
if (toggleIcon) {
|
|
4919
|
+
toggleIcon.innerHTML = icon(this.darkMode ? 'sun' : 'moon', 14);
|
|
2949
4920
|
}
|
|
2950
4921
|
}
|
|
2951
4922
|
|
|
@@ -2969,15 +4940,18 @@ export class EmailEngineClient {
|
|
|
2969
4940
|
this.keepAliveTimer = null;
|
|
2970
4941
|
}
|
|
2971
4942
|
|
|
4943
|
+
clearTimeout(this._toastTimer);
|
|
4944
|
+
clearTimeout(this._otpCopyTimer);
|
|
4945
|
+
|
|
2972
4946
|
// Remove the compose button's window scroll/resize listeners
|
|
2973
4947
|
if (this._composeButtonCleanup) {
|
|
2974
4948
|
this._composeButtonCleanup();
|
|
2975
4949
|
this._composeButtonCleanup = null;
|
|
2976
4950
|
}
|
|
2977
4951
|
|
|
2978
|
-
//
|
|
2979
|
-
if (this._composeKeydownHandler &&
|
|
2980
|
-
|
|
4952
|
+
// The compose form's keys listen on the form itself
|
|
4953
|
+
if (this._composeKeydownHandler && this._compose && this._compose.els) {
|
|
4954
|
+
this._compose.els.dialog.removeEventListener('keydown', this._composeKeydownHandler);
|
|
2981
4955
|
this._composeKeydownHandler = null;
|
|
2982
4956
|
}
|
|
2983
4957
|
|