@postalsys/ee-client 1.11.1 → 2.0.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/README.md +66 -41
- package/index.d.ts +89 -16
- package/index.js +1691 -641
- package/package.json +8 -2
package/index.js
CHANGED
|
@@ -35,6 +35,19 @@ const MESSAGE_BODY_STYLES = `
|
|
|
35
35
|
overflow-x: auto;
|
|
36
36
|
}
|
|
37
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
|
+
|
|
38
51
|
/* Quoted thread history, folded away by EmailEngine - see _labelCollapsedThreads() */
|
|
39
52
|
.ee-collapsed-thread {
|
|
40
53
|
margin-top: 12px;
|
|
@@ -91,9 +104,304 @@ const ICON_PATHS = {
|
|
|
91
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"/>',
|
|
92
105
|
close: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
93
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"/>',
|
|
94
|
-
moon: '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'
|
|
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'
|
|
95
144
|
};
|
|
96
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
|
+
|
|
97
405
|
// Default cap on the files attached in the compose form, in bytes. They travel base64 encoded
|
|
98
406
|
// inside one JSON request, which grows them by a third, and most providers refuse a message
|
|
99
407
|
// much larger than this anyway. Hosts that know their limit pass maxAttachmentSize.
|
|
@@ -134,15 +442,18 @@ function splitAddressField(value) {
|
|
|
134
442
|
}
|
|
135
443
|
|
|
136
444
|
function parseAddressEntry(entry) {
|
|
137
|
-
|
|
138
|
-
|
|
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))) {
|
|
139
450
|
return { address: entry };
|
|
140
451
|
}
|
|
141
|
-
let name =
|
|
452
|
+
let name = entry.slice(0, open).trim();
|
|
142
453
|
if (name.length > 1 && name.startsWith('"') && name.endsWith('"')) {
|
|
143
454
|
name = name.slice(1, -1).replace(/\\(.)/g, '$1');
|
|
144
455
|
}
|
|
145
|
-
const address =
|
|
456
|
+
const address = entry.slice(open + 1, -1).trim();
|
|
146
457
|
return name ? { name, address } : { address };
|
|
147
458
|
}
|
|
148
459
|
|
|
@@ -164,10 +475,11 @@ function addressEntries(value) {
|
|
|
164
475
|
|
|
165
476
|
// Compose form titles, by mode
|
|
166
477
|
const COMPOSE_TITLES = {
|
|
167
|
-
new: 'New
|
|
478
|
+
new: 'New message',
|
|
168
479
|
reply: 'Reply',
|
|
169
|
-
'reply-all': 'Reply
|
|
170
|
-
forward: 'Forward'
|
|
480
|
+
'reply-all': 'Reply all',
|
|
481
|
+
forward: 'Forward',
|
|
482
|
+
draft: 'Draft'
|
|
171
483
|
};
|
|
172
484
|
|
|
173
485
|
// Below this container width the UI shows one pane at a time and the compose button
|
|
@@ -206,13 +518,20 @@ export class EmailEngineClient {
|
|
|
206
518
|
this.initialMessage = typeof options.message === 'string' && options.message ? options.message : null;
|
|
207
519
|
// Told whenever the open folder or message changes, so a host page can keep its address
|
|
208
520
|
// bar in step (see _notifyNavigate)
|
|
209
|
-
|
|
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
|
+
}
|
|
210
527
|
const maxAttachmentSize = Number(options.maxAttachmentSize);
|
|
211
528
|
this.maxAttachmentSize = maxAttachmentSize > 0 ? maxAttachmentSize : DEFAULT_MAX_ATTACHMENT_SIZE;
|
|
212
529
|
this.folders = [];
|
|
213
530
|
this.messages = [];
|
|
214
531
|
this.nextPageCursor = null;
|
|
215
532
|
this.prevPageCursor = null;
|
|
533
|
+
// Position of the listed page: { page (0-based), total } when the server reports them
|
|
534
|
+
this.listPosition = null;
|
|
216
535
|
|
|
217
536
|
// Set once destroy() runs; guards async completions (loadFolders,
|
|
218
537
|
// loadMessages, loadMessage) from re-rendering or scrolling into a
|
|
@@ -245,9 +564,9 @@ export class EmailEngineClient {
|
|
|
245
564
|
const requestedPageSize = savedPageSize ? parseInt(savedPageSize, 10) : parseInt(options.pageSize, 10);
|
|
246
565
|
this.pageSize = requestedPageSize > 0 ? requestedPageSize : 20;
|
|
247
566
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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);
|
|
251
570
|
|
|
252
571
|
// Start keep-alive timer for sess_ tokens
|
|
253
572
|
this._startKeepAliveTimer();
|
|
@@ -343,21 +662,30 @@ export class EmailEngineClient {
|
|
|
343
662
|
return `${this._accountPath()}/attachment/${encodeURIComponent(attachmentId)}`;
|
|
344
663
|
}
|
|
345
664
|
|
|
346
|
-
|
|
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 } = {}) {
|
|
347
676
|
// Reset the pane to its loading state so a retry after a failure does not
|
|
348
677
|
// keep showing the previous error while the new request is in flight.
|
|
349
678
|
this._setPaneHtml('.ee-folder-tree', '<div class="ee-loading">Loading folders...</div>');
|
|
350
679
|
|
|
351
680
|
try {
|
|
352
|
-
|
|
353
|
-
this.folders = data.mailboxes || [];
|
|
354
|
-
this._folderTreeCache = null;
|
|
681
|
+
await this._fetchFolders(counters);
|
|
355
682
|
if (this.container) {
|
|
356
683
|
this.renderFolderList();
|
|
357
684
|
}
|
|
358
685
|
return this.folders;
|
|
359
686
|
} catch (error) {
|
|
360
687
|
console.error('Failed to load folders:', error);
|
|
688
|
+
this._reportError(error, 'loadFolders', 'Failed to load the folders');
|
|
361
689
|
this._renderPaneError('.ee-folder-tree', 'Folders unavailable', error, () => this._loadInitialView());
|
|
362
690
|
throw error;
|
|
363
691
|
}
|
|
@@ -379,6 +707,7 @@ export class EmailEngineClient {
|
|
|
379
707
|
this.currentFolder = path;
|
|
380
708
|
this.nextPageCursor = data.nextPageCursor || null;
|
|
381
709
|
this.prevPageCursor = data.prevPageCursor || null;
|
|
710
|
+
this.listPosition = Number.isInteger(data.page) && Number.isInteger(data.total) ? { page: data.page, total: data.total } : null;
|
|
382
711
|
|
|
383
712
|
if (this.container) {
|
|
384
713
|
this.renderMessageList();
|
|
@@ -394,6 +723,7 @@ export class EmailEngineClient {
|
|
|
394
723
|
};
|
|
395
724
|
} catch (error) {
|
|
396
725
|
console.error('Failed to load messages:', error);
|
|
726
|
+
this._reportError(error, 'loadMessages', 'Failed to load the messages');
|
|
397
727
|
this._renderPaneError(
|
|
398
728
|
'.ee-message-list',
|
|
399
729
|
'Messages unavailable',
|
|
@@ -430,6 +760,9 @@ export class EmailEngineClient {
|
|
|
430
760
|
|
|
431
761
|
const msg = this.messages.find(m => m.id === messageId);
|
|
432
762
|
if (msg) {
|
|
763
|
+
if (msg.unseen) {
|
|
764
|
+
this._adjustUnseen(this.currentFolder, -1);
|
|
765
|
+
}
|
|
433
766
|
msg.unseen = false;
|
|
434
767
|
if (this.container) {
|
|
435
768
|
this.renderMessageList();
|
|
@@ -451,6 +784,7 @@ export class EmailEngineClient {
|
|
|
451
784
|
return this.currentMessage;
|
|
452
785
|
} catch (error) {
|
|
453
786
|
console.error('Failed to load message:', error);
|
|
787
|
+
this._reportError(error, 'loadMessage', 'Failed to load the message');
|
|
454
788
|
// A message that does not exist (deleted, moved, or a link with a mangled ID) is
|
|
455
789
|
// not worth retrying, and the API's validation text means nothing to a reader
|
|
456
790
|
if (error && (error.statusCode === 404 || error.statusCode === 400)) {
|
|
@@ -482,6 +816,9 @@ export class EmailEngineClient {
|
|
|
482
816
|
|
|
483
817
|
const msg = this.messages.find(m => m.id === messageId);
|
|
484
818
|
if (msg) {
|
|
819
|
+
if (msg.unseen === seen) {
|
|
820
|
+
this._adjustUnseen(this.currentFolder, seen ? -1 : 1);
|
|
821
|
+
}
|
|
485
822
|
msg.unseen = !seen;
|
|
486
823
|
if (this.container) {
|
|
487
824
|
this.renderMessageList();
|
|
@@ -498,13 +835,21 @@ export class EmailEngineClient {
|
|
|
498
835
|
return true;
|
|
499
836
|
} catch (error) {
|
|
500
837
|
console.error('Failed to update message flags:', error);
|
|
838
|
+
this._reportError(error, 'markAsRead', 'Failed to update the message flags');
|
|
501
839
|
throw error;
|
|
502
840
|
}
|
|
503
841
|
}
|
|
504
842
|
|
|
505
843
|
// Takes a message that left the folder (deleted or moved) off the list, and out of the
|
|
506
844
|
// viewer when it was the open one
|
|
507
|
-
_dropMessage(messageId) {
|
|
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
|
+
}
|
|
508
853
|
this.messages = this.messages.filter(m => m.id !== messageId);
|
|
509
854
|
if (this.container) {
|
|
510
855
|
this.renderMessageList();
|
|
@@ -530,6 +875,7 @@ export class EmailEngineClient {
|
|
|
530
875
|
return response || { deleted: true };
|
|
531
876
|
} catch (error) {
|
|
532
877
|
console.error('Failed to delete message:', error);
|
|
878
|
+
this._reportError(error, 'delete', 'Failed to delete the message');
|
|
533
879
|
throw error;
|
|
534
880
|
}
|
|
535
881
|
}
|
|
@@ -540,11 +886,12 @@ export class EmailEngineClient {
|
|
|
540
886
|
path: targetPath
|
|
541
887
|
});
|
|
542
888
|
|
|
543
|
-
this._dropMessage(messageId);
|
|
889
|
+
this._dropMessage(messageId, targetPath);
|
|
544
890
|
|
|
545
891
|
return true;
|
|
546
892
|
} catch (error) {
|
|
547
893
|
console.error('Failed to move message:', error);
|
|
894
|
+
this._reportError(error, 'move', 'Failed to move the message');
|
|
548
895
|
throw error;
|
|
549
896
|
}
|
|
550
897
|
}
|
|
@@ -558,10 +905,20 @@ export class EmailEngineClient {
|
|
|
558
905
|
return this._accountInfo;
|
|
559
906
|
}
|
|
560
907
|
|
|
561
|
-
// The address and content fields shared by a submission and a draft upload
|
|
562
|
-
//
|
|
563
|
-
_messagePayload(
|
|
564
|
-
const
|
|
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
|
+
}
|
|
565
922
|
for (const [key, value] of [
|
|
566
923
|
['to', to],
|
|
567
924
|
['cc', cc],
|
|
@@ -573,33 +930,59 @@ export class EmailEngineClient {
|
|
|
573
930
|
}
|
|
574
931
|
}
|
|
575
932
|
if (Array.isArray(attachments) && attachments.length) {
|
|
576
|
-
data.attachments = attachments.map(
|
|
933
|
+
data.attachments = attachments.map(attachmentPayload);
|
|
577
934
|
}
|
|
578
935
|
if (reference) {
|
|
579
936
|
data.reference = reference;
|
|
580
937
|
}
|
|
938
|
+
if (headers && typeof headers === 'object' && Object.keys(headers).length) {
|
|
939
|
+
data.headers = headers;
|
|
940
|
+
}
|
|
581
941
|
return data;
|
|
582
942
|
}
|
|
583
943
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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');
|
|
588
963
|
try {
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
const response = await this.apiRequest('POST', `${this._accountPath()}/submit`, messageData);
|
|
964
|
+
const response = await this.apiRequest('POST', `${this._accountPath()}/submit`, this._messagePayload(message));
|
|
965
|
+
this._emit('onMessageSent', response);
|
|
592
966
|
return response;
|
|
593
967
|
} catch (error) {
|
|
594
968
|
console.error('Failed to send message:', error);
|
|
969
|
+
this._reportError(error, 'send', 'Failed to send the message');
|
|
595
970
|
throw error;
|
|
596
971
|
}
|
|
597
972
|
}
|
|
598
973
|
|
|
599
|
-
|
|
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');
|
|
600
982
|
try {
|
|
601
983
|
if (!this.folders.length) {
|
|
602
|
-
|
|
984
|
+
// only the Drafts path is needed; a failure is this save's own
|
|
985
|
+
await this._fetchFolders();
|
|
603
986
|
}
|
|
604
987
|
const draftsFolder = this.folders.find(f => f.specialUse === '\\Drafts');
|
|
605
988
|
if (!draftsFolder) {
|
|
@@ -609,7 +992,7 @@ export class EmailEngineClient {
|
|
|
609
992
|
const messageData = {
|
|
610
993
|
path: draftsFolder.path,
|
|
611
994
|
flags: ['\\Draft'],
|
|
612
|
-
...this._messagePayload(
|
|
995
|
+
...this._messagePayload(message)
|
|
613
996
|
};
|
|
614
997
|
|
|
615
998
|
// The upload endpoint does not add a From header on its own, but the draft
|
|
@@ -624,13 +1007,41 @@ export class EmailEngineClient {
|
|
|
624
1007
|
}
|
|
625
1008
|
|
|
626
1009
|
const response = await this.apiRequest('POST', `${this._accountPath()}/message`, messageData);
|
|
1010
|
+
this._emit('onDraftSaved', response);
|
|
627
1011
|
return response;
|
|
628
1012
|
} catch (error) {
|
|
629
1013
|
console.error('Failed to save draft:', error);
|
|
1014
|
+
this._reportError(error, 'saveDraft', 'Failed to save the draft');
|
|
630
1015
|
throw error;
|
|
631
1016
|
}
|
|
632
1017
|
}
|
|
633
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
|
+
|
|
634
1045
|
// Parses a typed address field ("Name <a@example.com>, b@example.com") into address entries
|
|
635
1046
|
parseAddressList(value) {
|
|
636
1047
|
return splitAddressField(String(value || '')).map(parseAddressEntry);
|
|
@@ -658,7 +1069,16 @@ export class EmailEngineClient {
|
|
|
658
1069
|
// leaves alone, and what the form shows is what is sent.
|
|
659
1070
|
prepareResponse(msg, action, ownAddress = null) {
|
|
660
1071
|
if (action === 'forward') {
|
|
661
|
-
|
|
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
|
+
};
|
|
662
1082
|
}
|
|
663
1083
|
|
|
664
1084
|
const own = typeof ownAddress === 'string' ? ownAddress.toLowerCase() : '';
|
|
@@ -695,24 +1115,39 @@ export class EmailEngineClient {
|
|
|
695
1115
|
return { to, cc, subject: prefixSubject(msg.subject, 'Re'), reference: { message: msg.id, action: 'reply', inline: true } };
|
|
696
1116
|
}
|
|
697
1117
|
|
|
698
|
-
//
|
|
699
|
-
|
|
700
|
-
|
|
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) {
|
|
701
1122
|
return;
|
|
702
1123
|
}
|
|
703
1124
|
try {
|
|
704
|
-
|
|
1125
|
+
handler(...args);
|
|
705
1126
|
} catch (error) {
|
|
706
|
-
console.error(
|
|
1127
|
+
console.error(`${name} handler failed:`, error);
|
|
707
1128
|
}
|
|
708
1129
|
}
|
|
709
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
|
+
|
|
710
1143
|
async submitDraft(messageId, options = null) {
|
|
711
1144
|
try {
|
|
712
1145
|
const response = await this.apiRequest('POST', this._messagePath(messageId, '/submit'), options);
|
|
1146
|
+
this._emit('onMessageSent', response);
|
|
713
1147
|
return response;
|
|
714
1148
|
} catch (error) {
|
|
715
1149
|
console.error('Failed to submit draft:', error);
|
|
1150
|
+
this._reportError(error, 'send', 'Failed to send the draft');
|
|
716
1151
|
throw error;
|
|
717
1152
|
}
|
|
718
1153
|
}
|
|
@@ -866,15 +1301,14 @@ export class EmailEngineClient {
|
|
|
866
1301
|
|
|
867
1302
|
// Header for every state of the message list pane, titled with the folder
|
|
868
1303
|
// being shown. In the single-pane layout its back button leads to the folders.
|
|
869
|
-
_messageListHeader(path
|
|
1304
|
+
_messageListHeader(path) {
|
|
870
1305
|
const folder = path && this.folders.find(f => f.path === path);
|
|
871
1306
|
return `
|
|
872
1307
|
<div class="ee-pane-header">
|
|
873
1308
|
<div class="ee-pane-heading">
|
|
874
1309
|
${this._iconButton('show-folders', 'back', 'Folders', 'ee-nav-button')}
|
|
875
|
-
<span class="ee-pane-title">${this.escapeHtml(folder ? folder
|
|
1310
|
+
<span class="ee-pane-title">${this.escapeHtml(folder ? folderDisplayName(folder) : 'Messages')}</span>
|
|
876
1311
|
</div>
|
|
877
|
-
${controls}
|
|
878
1312
|
</div>
|
|
879
1313
|
`;
|
|
880
1314
|
}
|
|
@@ -915,12 +1349,13 @@ export class EmailEngineClient {
|
|
|
915
1349
|
const diff = now - date;
|
|
916
1350
|
|
|
917
1351
|
if (diff < 86400000) {
|
|
918
|
-
return date.toLocaleTimeString([], { hour: '
|
|
1352
|
+
return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
919
1353
|
} else if (diff < 604800000) {
|
|
920
|
-
return date.toLocaleDateString([], { weekday: 'short', hour: '
|
|
921
|
-
} else {
|
|
1354
|
+
return date.toLocaleDateString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' });
|
|
1355
|
+
} else if (date.getFullYear() === now.getFullYear()) {
|
|
922
1356
|
return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
|
|
923
1357
|
}
|
|
1358
|
+
return date.toLocaleDateString([], { year: 'numeric', month: 'short', day: 'numeric' });
|
|
924
1359
|
}
|
|
925
1360
|
|
|
926
1361
|
// The date in the message header: weekday, date and time to the minute
|
|
@@ -1035,11 +1470,7 @@ export class EmailEngineClient {
|
|
|
1035
1470
|
}
|
|
1036
1471
|
|
|
1037
1472
|
escapeHtml(value) {
|
|
1038
|
-
|
|
1039
|
-
return '';
|
|
1040
|
-
}
|
|
1041
|
-
const htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
|
|
1042
|
-
return String(value).replace(/[&<>"']/g, ch => htmlEscapes[ch]);
|
|
1473
|
+
return escapeHtml(value);
|
|
1043
1474
|
}
|
|
1044
1475
|
|
|
1045
1476
|
_authHeaders() {
|
|
@@ -1097,6 +1528,7 @@ export class EmailEngineClient {
|
|
|
1097
1528
|
this._saveBlob(blob, filename);
|
|
1098
1529
|
} catch (error) {
|
|
1099
1530
|
console.error('Failed to download attachment:', error);
|
|
1531
|
+
this._reportError(error, 'download', 'Failed to download the attachment');
|
|
1100
1532
|
this.alertMethod(this._errorMessage(error, 'Failed to download attachment. Please try again.'), 'Download Error', null, 'OK');
|
|
1101
1533
|
}
|
|
1102
1534
|
}
|
|
@@ -1117,6 +1549,7 @@ export class EmailEngineClient {
|
|
|
1117
1549
|
this._saveBlob(blob, filename);
|
|
1118
1550
|
} catch (error) {
|
|
1119
1551
|
console.error('Failed to download original message:', error);
|
|
1552
|
+
this._reportError(error, 'download', 'Failed to download the original message');
|
|
1120
1553
|
this.alertMethod(this._errorMessage(error, 'Failed to download original message. Please try again.'), 'Download Error', null, 'OK');
|
|
1121
1554
|
}
|
|
1122
1555
|
}
|
|
@@ -1144,7 +1577,7 @@ export class EmailEngineClient {
|
|
|
1144
1577
|
element: setting --ee-accent itself here would hide the host's value. */
|
|
1145
1578
|
.ee-client,
|
|
1146
1579
|
.ee-compose-button,
|
|
1147
|
-
.ee-compose
|
|
1580
|
+
.ee-compose,
|
|
1148
1581
|
.ee-toast {
|
|
1149
1582
|
--_accent: var(--ee-accent, #007bff);
|
|
1150
1583
|
--_accent-hover: var(--ee-accent-hover, #0056b3);
|
|
@@ -1184,66 +1617,80 @@ export class EmailEngineClient {
|
|
|
1184
1617
|
.ee-folder-list {
|
|
1185
1618
|
list-style: none;
|
|
1186
1619
|
margin: 0;
|
|
1187
|
-
padding:
|
|
1620
|
+
padding: 6px 8px;
|
|
1621
|
+
display: flex;
|
|
1622
|
+
flex-direction: column;
|
|
1623
|
+
gap: 1px;
|
|
1188
1624
|
}
|
|
1189
|
-
|
|
1625
|
+
|
|
1190
1626
|
.ee-folder-item {
|
|
1191
|
-
cursor: pointer;
|
|
1192
|
-
border-bottom: 1px solid #e0e0e0;
|
|
1193
1627
|
position: relative;
|
|
1194
1628
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
background: #e8e8e8;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
.ee-folder-item.active {
|
|
1201
|
-
background: var(--_accent);
|
|
1202
|
-
color: white;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
.ee-folder-item.active::before {
|
|
1206
|
-
content: '';
|
|
1207
|
-
position: absolute;
|
|
1208
|
-
left: 0;
|
|
1209
|
-
top: 0;
|
|
1210
|
-
bottom: 0;
|
|
1211
|
-
width: 3px;
|
|
1212
|
-
background: var(--_accent-hover);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1629
|
+
|
|
1630
|
+
/* The whole row is the button */
|
|
1215
1631
|
.ee-folder-content {
|
|
1216
|
-
padding: 8px 16px 8px 0px;
|
|
1217
1632
|
display: flex;
|
|
1218
1633
|
align-items: center;
|
|
1219
|
-
|
|
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;
|
|
1220
1645
|
}
|
|
1221
|
-
|
|
1222
|
-
.ee-folder-
|
|
1223
|
-
|
|
1224
|
-
font-size: 12px;
|
|
1225
|
-
margin-right: 4px;
|
|
1226
|
-
font-family: monospace;
|
|
1646
|
+
|
|
1647
|
+
.ee-folder-content:hover {
|
|
1648
|
+
background: #eef1f4;
|
|
1227
1649
|
}
|
|
1228
|
-
|
|
1229
|
-
.ee-folder-
|
|
1230
|
-
|
|
1231
|
-
|
|
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;
|
|
1232
1656
|
}
|
|
1233
|
-
|
|
1234
|
-
.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);
|
|
1235
1661
|
font-weight: 600;
|
|
1236
1662
|
}
|
|
1237
|
-
|
|
1238
|
-
.ee-folder-
|
|
1239
|
-
|
|
1663
|
+
|
|
1664
|
+
.ee-folder-icon {
|
|
1665
|
+
display: inline-flex;
|
|
1666
|
+
flex-shrink: 0;
|
|
1667
|
+
color: #6b7280;
|
|
1240
1668
|
}
|
|
1241
|
-
|
|
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
|
+
|
|
1242
1682
|
.ee-folder-count {
|
|
1243
|
-
font-size: 12px;
|
|
1244
|
-
opacity: 0.7;
|
|
1245
|
-
margin-left: 8px;
|
|
1246
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;
|
|
1247
1694
|
}
|
|
1248
1695
|
|
|
1249
1696
|
.ee-main {
|
|
@@ -1262,49 +1709,76 @@ export class EmailEngineClient {
|
|
|
1262
1709
|
flex-direction: column;
|
|
1263
1710
|
}
|
|
1264
1711
|
|
|
1712
|
+
/* A list row is a button holding spans laid out as blocks */
|
|
1265
1713
|
.ee-message-item {
|
|
1266
|
-
|
|
1714
|
+
display: block;
|
|
1715
|
+
width: 100%;
|
|
1716
|
+
padding: 10px 16px 10px 24px;
|
|
1717
|
+
border: none;
|
|
1267
1718
|
border-bottom: 1px solid #e0e0e0;
|
|
1719
|
+
background: transparent;
|
|
1720
|
+
color: inherit;
|
|
1721
|
+
font: inherit;
|
|
1722
|
+
text-align: left;
|
|
1268
1723
|
cursor: pointer;
|
|
1724
|
+
position: relative;
|
|
1269
1725
|
}
|
|
1270
|
-
|
|
1726
|
+
|
|
1271
1727
|
.ee-message-item:hover {
|
|
1272
1728
|
background: #f8f8f8;
|
|
1273
1729
|
}
|
|
1274
|
-
|
|
1730
|
+
|
|
1275
1731
|
.ee-message-item.active {
|
|
1276
1732
|
background: color-mix(in srgb, var(--_accent) 12%, white);
|
|
1277
1733
|
}
|
|
1278
|
-
|
|
1279
|
-
.ee-message-item.unread
|
|
1734
|
+
|
|
1735
|
+
.ee-message-item.unread .ee-message-from,
|
|
1736
|
+
.ee-message-item.unread .ee-message-subject-text {
|
|
1280
1737
|
font-weight: 600;
|
|
1281
1738
|
}
|
|
1282
|
-
|
|
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
|
+
|
|
1283
1750
|
.ee-message-header {
|
|
1284
1751
|
display: flex;
|
|
1285
1752
|
justify-content: space-between;
|
|
1286
|
-
margin-bottom:
|
|
1753
|
+
margin-bottom: 2px;
|
|
1287
1754
|
}
|
|
1288
|
-
|
|
1755
|
+
|
|
1289
1756
|
.ee-message-from {
|
|
1290
1757
|
flex: 1;
|
|
1291
1758
|
overflow: hidden;
|
|
1292
1759
|
text-overflow: ellipsis;
|
|
1293
1760
|
white-space: nowrap;
|
|
1294
1761
|
}
|
|
1295
|
-
|
|
1762
|
+
|
|
1763
|
+
.ee-message-to-label {
|
|
1764
|
+
color: #666;
|
|
1765
|
+
font-weight: 400;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1296
1768
|
.ee-message-date {
|
|
1297
1769
|
font-size: 12px;
|
|
1298
1770
|
color: #666;
|
|
1299
1771
|
flex-shrink: 0;
|
|
1300
1772
|
margin-left: 8px;
|
|
1773
|
+
font-variant-numeric: tabular-nums;
|
|
1301
1774
|
}
|
|
1302
|
-
|
|
1775
|
+
|
|
1303
1776
|
.ee-message-subject {
|
|
1304
1777
|
display: flex;
|
|
1305
1778
|
align-items: center;
|
|
1306
|
-
|
|
1779
|
+
color: #444;
|
|
1307
1780
|
}
|
|
1781
|
+
|
|
1308
1782
|
|
|
1309
1783
|
.ee-message-subject-text {
|
|
1310
1784
|
overflow: hidden;
|
|
@@ -1315,6 +1789,8 @@ export class EmailEngineClient {
|
|
|
1315
1789
|
}
|
|
1316
1790
|
|
|
1317
1791
|
.ee-message-preview {
|
|
1792
|
+
display: block;
|
|
1793
|
+
margin-top: 2px;
|
|
1318
1794
|
font-size: 12px;
|
|
1319
1795
|
color: #666;
|
|
1320
1796
|
overflow: hidden;
|
|
@@ -1606,42 +2082,71 @@ export class EmailEngineClient {
|
|
|
1606
2082
|
margin-bottom: 8px;
|
|
1607
2083
|
color: #333;
|
|
1608
2084
|
}
|
|
1609
|
-
|
|
2085
|
+
|
|
2086
|
+
.ee-attachment-grid {
|
|
2087
|
+
display: grid;
|
|
2088
|
+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
2089
|
+
gap: 8px;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
1610
2092
|
.ee-attachment-item {
|
|
1611
2093
|
display: flex;
|
|
1612
2094
|
align-items: center;
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
2095
|
+
gap: 10px;
|
|
2096
|
+
min-width: 0;
|
|
2097
|
+
padding: 8px 10px;
|
|
2098
|
+
background: #f8f9fa;
|
|
1616
2099
|
border: 1px solid #e0e0e0;
|
|
1617
|
-
border-radius:
|
|
2100
|
+
border-radius: 6px;
|
|
2101
|
+
color: inherit;
|
|
2102
|
+
font: inherit;
|
|
2103
|
+
text-align: left;
|
|
1618
2104
|
cursor: pointer;
|
|
1619
2105
|
transition: background 0.2s;
|
|
1620
2106
|
}
|
|
1621
|
-
|
|
2107
|
+
|
|
1622
2108
|
.ee-attachment-item:hover {
|
|
1623
|
-
background: #
|
|
2109
|
+
background: #eef1f4;
|
|
1624
2110
|
}
|
|
1625
|
-
|
|
1626
|
-
.ee-attachment-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
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;
|
|
1630
2123
|
}
|
|
1631
|
-
|
|
2124
|
+
|
|
1632
2125
|
.ee-attachment-info {
|
|
2126
|
+
display: flex;
|
|
2127
|
+
flex-direction: column;
|
|
1633
2128
|
flex: 1;
|
|
2129
|
+
min-width: 0;
|
|
1634
2130
|
}
|
|
1635
|
-
|
|
2131
|
+
|
|
1636
2132
|
.ee-attachment-name {
|
|
1637
2133
|
font-weight: 500;
|
|
1638
2134
|
color: #333;
|
|
2135
|
+
overflow: hidden;
|
|
2136
|
+
text-overflow: ellipsis;
|
|
2137
|
+
white-space: nowrap;
|
|
1639
2138
|
}
|
|
1640
|
-
|
|
2139
|
+
|
|
1641
2140
|
.ee-attachment-size {
|
|
1642
2141
|
font-size: 12px;
|
|
1643
2142
|
color: #666;
|
|
1644
2143
|
}
|
|
2144
|
+
|
|
2145
|
+
.ee-attachment-download {
|
|
2146
|
+
display: inline-flex;
|
|
2147
|
+
flex-shrink: 0;
|
|
2148
|
+
color: #666;
|
|
2149
|
+
}
|
|
1645
2150
|
|
|
1646
2151
|
.ee-empty-state {
|
|
1647
2152
|
display: flex;
|
|
@@ -1736,18 +2241,30 @@ export class EmailEngineClient {
|
|
|
1736
2241
|
overflow-y: auto;
|
|
1737
2242
|
}
|
|
1738
2243
|
|
|
1739
|
-
|
|
2244
|
+
/* Paging, under the list: the position, the arrows and the page size */
|
|
2245
|
+
.ee-list-footer {
|
|
1740
2246
|
display: flex;
|
|
1741
|
-
gap: 6px;
|
|
1742
2247
|
align-items: center;
|
|
2248
|
+
gap: 6px;
|
|
1743
2249
|
flex-shrink: 0;
|
|
2250
|
+
padding: 6px 12px 6px 16px;
|
|
2251
|
+
border-top: 1px solid #e0e0e0;
|
|
2252
|
+
background: #f8f9fa;
|
|
1744
2253
|
}
|
|
1745
|
-
|
|
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
|
+
|
|
1746
2263
|
.ee-page-size-selector {
|
|
1747
2264
|
display: flex;
|
|
1748
2265
|
gap: 6px;
|
|
1749
2266
|
align-items: center;
|
|
1750
|
-
margin-left:
|
|
2267
|
+
margin-left: 6px;
|
|
1751
2268
|
}
|
|
1752
2269
|
|
|
1753
2270
|
.ee-page-size-label {
|
|
@@ -1784,6 +2301,11 @@ export class EmailEngineClient {
|
|
|
1784
2301
|
transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
|
|
1785
2302
|
}
|
|
1786
2303
|
|
|
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;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
1787
2309
|
.ee-compose-button:hover {
|
|
1788
2310
|
background: var(--_accent-hover);
|
|
1789
2311
|
transform: translateY(-1px);
|
|
@@ -1861,204 +2383,336 @@ export class EmailEngineClient {
|
|
|
1861
2383
|
}
|
|
1862
2384
|
}
|
|
1863
2385
|
|
|
1864
|
-
|
|
1865
|
-
|
|
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 {
|
|
1866
2390
|
position: fixed;
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
width: 100%;
|
|
1870
|
-
height: 100%;
|
|
1871
|
-
background: rgba(0, 0, 0, 0.5);
|
|
2391
|
+
right: 24px;
|
|
2392
|
+
bottom: 0;
|
|
1872
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;
|
|
1873
2398
|
}
|
|
1874
|
-
|
|
1875
|
-
.ee-compose
|
|
1876
|
-
|
|
1877
|
-
align-items: center;
|
|
1878
|
-
justify-content: center;
|
|
2399
|
+
|
|
2400
|
+
.ee-compose * {
|
|
2401
|
+
box-sizing: border-box;
|
|
1879
2402
|
}
|
|
1880
|
-
|
|
2403
|
+
|
|
1881
2404
|
.ee-compose-dialog {
|
|
1882
|
-
background: white;
|
|
1883
|
-
border-radius: 8px;
|
|
1884
|
-
width: 90%;
|
|
1885
|
-
max-width: 600px;
|
|
1886
|
-
max-height: 90vh;
|
|
1887
|
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
1888
2405
|
display: flex;
|
|
1889
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;
|
|
1890
2415
|
}
|
|
1891
|
-
|
|
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
|
+
|
|
1892
2442
|
.ee-compose-header {
|
|
1893
|
-
padding: 16px 20px;
|
|
1894
|
-
border-bottom: 1px solid #e0e0e0;
|
|
1895
2443
|
display: flex;
|
|
1896
|
-
justify-content: space-between;
|
|
1897
2444
|
align-items: center;
|
|
2445
|
+
gap: 4px;
|
|
1898
2446
|
flex-shrink: 0;
|
|
2447
|
+
padding: 8px 8px 8px 16px;
|
|
2448
|
+
background: #2b3440;
|
|
2449
|
+
color: #fff;
|
|
1899
2450
|
}
|
|
1900
|
-
|
|
2451
|
+
|
|
1901
2452
|
.ee-compose-title {
|
|
1902
|
-
|
|
1903
|
-
|
|
2453
|
+
flex: 1;
|
|
2454
|
+
min-width: 0;
|
|
1904
2455
|
margin: 0;
|
|
2456
|
+
font-size: 14px;
|
|
2457
|
+
font-weight: 600;
|
|
2458
|
+
overflow: hidden;
|
|
2459
|
+
text-overflow: ellipsis;
|
|
2460
|
+
white-space: nowrap;
|
|
1905
2461
|
}
|
|
1906
|
-
|
|
1907
|
-
.ee-compose-
|
|
1908
|
-
|
|
1909
|
-
border: none;
|
|
1910
|
-
color: #666;
|
|
1911
|
-
cursor: pointer;
|
|
1912
|
-
padding: 0;
|
|
1913
|
-
width: 30px;
|
|
1914
|
-
height: 30px;
|
|
1915
|
-
border-radius: 50%;
|
|
1916
|
-
display: flex;
|
|
2462
|
+
|
|
2463
|
+
.ee-compose-window-button {
|
|
2464
|
+
display: inline-flex;
|
|
1917
2465
|
align-items: center;
|
|
1918
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;
|
|
1919
2475
|
}
|
|
1920
|
-
|
|
1921
|
-
.ee-compose-
|
|
1922
|
-
background:
|
|
2476
|
+
|
|
2477
|
+
.ee-compose-window-button:hover {
|
|
2478
|
+
background: rgba(255, 255, 255, 0.15);
|
|
2479
|
+
color: #fff;
|
|
1923
2480
|
}
|
|
1924
|
-
|
|
2481
|
+
|
|
1925
2482
|
.ee-compose-form {
|
|
1926
|
-
padding: 16px 20px;
|
|
1927
2483
|
display: flex;
|
|
1928
2484
|
flex-direction: column;
|
|
1929
|
-
gap: 10px;
|
|
1930
2485
|
flex: 1;
|
|
2486
|
+
min-height: 0;
|
|
1931
2487
|
overflow-y: auto;
|
|
2488
|
+
padding: 4px 16px 12px;
|
|
1932
2489
|
}
|
|
1933
2490
|
|
|
1934
|
-
/* One line per header field
|
|
1935
|
-
their compose headers
|
|
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 */
|
|
1936
2493
|
.ee-compose-row {
|
|
1937
2494
|
display: flex;
|
|
1938
2495
|
align-items: center;
|
|
1939
2496
|
gap: 10px;
|
|
2497
|
+
border-bottom: 1px solid #e5e8ec;
|
|
1940
2498
|
}
|
|
1941
2499
|
|
|
1942
2500
|
.ee-compose-label {
|
|
1943
|
-
flex: 0 0
|
|
2501
|
+
flex: 0 0 52px;
|
|
1944
2502
|
font-size: 13px;
|
|
1945
|
-
|
|
1946
|
-
color: #555;
|
|
2503
|
+
color: #666;
|
|
1947
2504
|
}
|
|
1948
2505
|
|
|
1949
2506
|
.ee-compose-input {
|
|
1950
2507
|
flex: 1;
|
|
1951
2508
|
min-width: 0;
|
|
1952
|
-
padding:
|
|
1953
|
-
border:
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
font
|
|
2509
|
+
padding: 10px 0;
|
|
2510
|
+
border: none;
|
|
2511
|
+
background: transparent;
|
|
2512
|
+
color: inherit;
|
|
2513
|
+
font: inherit;
|
|
1957
2514
|
}
|
|
1958
2515
|
|
|
1959
|
-
.ee-compose-input
|
|
1960
|
-
|
|
1961
|
-
|
|
2516
|
+
.ee-compose-input:focus {
|
|
2517
|
+
outline: none;
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
.ee-compose-row:focus-within {
|
|
2521
|
+
border-bottom-color: var(--_accent);
|
|
2522
|
+
}
|
|
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;
|
|
2596
|
+
outline: none;
|
|
2597
|
+
overflow-wrap: break-word;
|
|
2598
|
+
cursor: text;
|
|
2599
|
+
}
|
|
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;
|
|
1962
2625
|
}
|
|
1963
2626
|
|
|
1964
2627
|
/* Why the form did not go out, between the form and its buttons so it is on
|
|
1965
2628
|
screen however far the form is scrolled */
|
|
1966
2629
|
.ee-compose-error {
|
|
1967
|
-
margin: 0
|
|
2630
|
+
margin: 0 16px 8px;
|
|
1968
2631
|
padding: 8px 12px;
|
|
1969
2632
|
border: 1px solid #fcc;
|
|
1970
|
-
border-radius:
|
|
2633
|
+
border-radius: 6px;
|
|
1971
2634
|
background: #fee;
|
|
1972
2635
|
color: #c00;
|
|
1973
2636
|
font-size: 13px;
|
|
1974
2637
|
white-space: pre-line;
|
|
1975
2638
|
flex-shrink: 0;
|
|
1976
2639
|
}
|
|
1977
|
-
|
|
1978
|
-
.ee-compose-textarea {
|
|
1979
|
-
padding: 12px;
|
|
1980
|
-
border: 1px solid #ddd;
|
|
1981
|
-
border-radius: 4px;
|
|
1982
|
-
font-size: 14px;
|
|
1983
|
-
font-family: inherit;
|
|
1984
|
-
resize: vertical;
|
|
1985
|
-
min-height: 180px;
|
|
1986
|
-
}
|
|
1987
2640
|
|
|
1988
|
-
.ee-compose-input:focus,
|
|
1989
|
-
.ee-compose-textarea:focus {
|
|
1990
|
-
outline: none;
|
|
1991
|
-
border-color: var(--_accent);
|
|
1992
|
-
box-shadow: 0 0 0 2px color-mix(in srgb, var(--_accent) 12%, transparent);
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
2641
|
.ee-compose-actions {
|
|
1996
|
-
padding: 16px 20px;
|
|
1997
|
-
border-top: 1px solid #e0e0e0;
|
|
1998
2642
|
display: flex;
|
|
1999
|
-
|
|
2000
|
-
|
|
2643
|
+
align-items: center;
|
|
2644
|
+
gap: 6px;
|
|
2001
2645
|
flex-shrink: 0;
|
|
2646
|
+
padding: 10px 16px;
|
|
2647
|
+
border-top: 1px solid #e5e8ec;
|
|
2002
2648
|
}
|
|
2003
|
-
|
|
2649
|
+
|
|
2650
|
+
|
|
2004
2651
|
.ee-compose-send {
|
|
2652
|
+
padding: 8px 22px;
|
|
2653
|
+
border: none;
|
|
2654
|
+
border-radius: 18px;
|
|
2005
2655
|
background: var(--_accent);
|
|
2006
2656
|
color: white;
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
border-radius: 4px;
|
|
2010
|
-
font-size: 14px;
|
|
2011
|
-
font-weight: 500;
|
|
2657
|
+
font: inherit;
|
|
2658
|
+
font-weight: 600;
|
|
2012
2659
|
cursor: pointer;
|
|
2013
2660
|
}
|
|
2014
|
-
|
|
2661
|
+
|
|
2015
2662
|
.ee-compose-send:hover:not(:disabled) {
|
|
2016
2663
|
background: var(--_accent-hover);
|
|
2017
2664
|
}
|
|
2018
|
-
|
|
2019
|
-
.ee-compose-send:disabled
|
|
2020
|
-
|
|
2665
|
+
|
|
2666
|
+
.ee-compose-send:disabled,
|
|
2667
|
+
.ee-compose-save-draft:disabled {
|
|
2021
2668
|
cursor: not-allowed;
|
|
2022
2669
|
opacity: 0.6;
|
|
2023
2670
|
}
|
|
2024
|
-
|
|
2025
|
-
/* Cancel is the quiet way out, not a third weighted button */
|
|
2026
|
-
.ee-compose-cancel {
|
|
2027
|
-
margin-right: auto;
|
|
2028
|
-
background: transparent;
|
|
2029
|
-
color: #555;
|
|
2030
|
-
border: none;
|
|
2031
|
-
padding: 10px 12px;
|
|
2032
|
-
border-radius: 4px;
|
|
2033
|
-
font-size: 14px;
|
|
2034
|
-
cursor: pointer;
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
.ee-compose-cancel:hover {
|
|
2038
|
-
background: #f0f0f0;
|
|
2039
|
-
}
|
|
2040
2671
|
|
|
2041
2672
|
.ee-compose-save-draft {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
border: 1px solid
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
font
|
|
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;
|
|
2049
2680
|
cursor: pointer;
|
|
2050
2681
|
}
|
|
2051
2682
|
|
|
2052
2683
|
.ee-compose-save-draft:hover:not(:disabled) {
|
|
2053
|
-
background:
|
|
2054
|
-
|
|
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;
|
|
2055
2698
|
}
|
|
2056
2699
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
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
|
+
}
|
|
2062
2716
|
}
|
|
2063
2717
|
|
|
2064
2718
|
.ee-sidebar-compose {
|
|
@@ -2138,9 +2792,10 @@ export class EmailEngineClient {
|
|
|
2138
2792
|
color: #1a1a1a;
|
|
2139
2793
|
}
|
|
2140
2794
|
|
|
2141
|
-
/* Parts of the compose form that come and go (Cc/Bcc, the
|
|
2142
|
-
|
|
2143
|
-
.ee-compose
|
|
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] {
|
|
2144
2799
|
display: none !important;
|
|
2145
2800
|
}
|
|
2146
2801
|
|
|
@@ -2159,49 +2814,11 @@ export class EmailEngineClient {
|
|
|
2159
2814
|
text-decoration: underline;
|
|
2160
2815
|
}
|
|
2161
2816
|
|
|
2162
|
-
.ee-compose-files {
|
|
2163
|
-
display: flex;
|
|
2164
|
-
flex-direction: column;
|
|
2165
|
-
gap: 8px;
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
.ee-compose-files-row {
|
|
2169
|
-
display: flex;
|
|
2170
|
-
flex-wrap: wrap;
|
|
2171
|
-
align-items: center;
|
|
2172
|
-
gap: 8px 16px;
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
.ee-compose-attach {
|
|
2176
|
-
display: inline-flex;
|
|
2177
|
-
align-items: center;
|
|
2178
|
-
gap: 6px;
|
|
2179
|
-
background: transparent;
|
|
2180
|
-
border: 1px solid #ddd;
|
|
2181
|
-
border-radius: 4px;
|
|
2182
|
-
padding: 6px 12px;
|
|
2183
|
-
font: inherit;
|
|
2184
|
-
font-size: 13px;
|
|
2185
|
-
color: inherit;
|
|
2186
|
-
cursor: pointer;
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
.ee-compose-attach:hover {
|
|
2190
|
-
background: #f0f0f0;
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
.ee-compose-forward-attachments {
|
|
2194
|
-
display: inline-flex;
|
|
2195
|
-
align-items: center;
|
|
2196
|
-
gap: 6px;
|
|
2197
|
-
font-size: 13px;
|
|
2198
|
-
cursor: pointer;
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
2817
|
.ee-compose-chips {
|
|
2202
2818
|
display: flex;
|
|
2203
2819
|
flex-wrap: wrap;
|
|
2204
2820
|
gap: 6px;
|
|
2821
|
+
padding-bottom: 10px;
|
|
2205
2822
|
}
|
|
2206
2823
|
|
|
2207
2824
|
.ee-compose-chips:empty {
|
|
@@ -2251,24 +2868,58 @@ export class EmailEngineClient {
|
|
|
2251
2868
|
background: #e0e0e0;
|
|
2252
2869
|
}
|
|
2253
2870
|
|
|
2871
|
+
/* The message being answered or forwarded, behind a "..." toggle */
|
|
2254
2872
|
.ee-compose-quote {
|
|
2255
2873
|
display: flex;
|
|
2256
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;
|
|
2257
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;
|
|
2258
2891
|
}
|
|
2259
2892
|
|
|
2260
|
-
.ee-compose-quote-
|
|
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;
|
|
2261
2911
|
font-size: 13px;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
.ee-forward-label {
|
|
2915
|
+
flex: 0 0 56px;
|
|
2262
2916
|
color: #666;
|
|
2263
2917
|
}
|
|
2264
2918
|
|
|
2265
|
-
.ee-compose-quote-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
border-left: 3px solid #ddd;
|
|
2270
|
-
background: #fafafa;
|
|
2271
|
-
border-radius: 0 4px 4px 0;
|
|
2919
|
+
.ee-compose-quote-header:not(:empty) {
|
|
2920
|
+
margin-bottom: 12px;
|
|
2921
|
+
padding-bottom: 10px;
|
|
2922
|
+
border-bottom: 1px solid #e5e8ec;
|
|
2272
2923
|
}
|
|
2273
2924
|
|
|
2274
2925
|
/* Dark mode toggle button, in the Folders pane header */
|
|
@@ -2319,15 +2970,20 @@ export class EmailEngineClient {
|
|
|
2319
2970
|
border-color: #333;
|
|
2320
2971
|
}
|
|
2321
2972
|
|
|
2322
|
-
.ee-dark-mode .ee-folder-
|
|
2323
|
-
|
|
2973
|
+
.ee-dark-mode .ee-folder-content:hover {
|
|
2974
|
+
background: #2a2a2a;
|
|
2324
2975
|
}
|
|
2325
2976
|
|
|
2326
|
-
.ee-dark-mode .ee-folder-item
|
|
2327
|
-
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;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
.ee-dark-mode .ee-folder-icon {
|
|
2983
|
+
color: #999;
|
|
2328
2984
|
}
|
|
2329
2985
|
|
|
2330
|
-
.ee-dark-mode .ee-folder-
|
|
2986
|
+
.ee-dark-mode .ee-folder-count {
|
|
2331
2987
|
background: var(--_accent-hover);
|
|
2332
2988
|
}
|
|
2333
2989
|
|
|
@@ -2350,10 +3006,27 @@ export class EmailEngineClient {
|
|
|
2350
3006
|
|
|
2351
3007
|
.ee-dark-mode .ee-message-date,
|
|
2352
3008
|
.ee-dark-mode .ee-message-preview,
|
|
2353
|
-
.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 {
|
|
2354
3013
|
color: #999;
|
|
2355
3014
|
}
|
|
2356
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
|
+
|
|
2357
3030
|
.ee-dark-mode .ee-pane-header {
|
|
2358
3031
|
background: linear-gradient(to bottom, #2a2a2a, #252525);
|
|
2359
3032
|
border-color: #333;
|
|
@@ -2493,121 +3166,99 @@ export class EmailEngineClient {
|
|
|
2493
3166
|
color: #999;
|
|
2494
3167
|
}
|
|
2495
3168
|
|
|
2496
|
-
|
|
2497
|
-
background: #252525;
|
|
2498
|
-
border-color: #333;
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2501
|
-
/* 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
|
|
2502
3170
|
setDarkMode puts the ee-dark-mode class on them directly */
|
|
2503
3171
|
.ee-compose-button.ee-dark-mode {
|
|
2504
3172
|
background: var(--_accent-hover);
|
|
2505
3173
|
color: white;
|
|
2506
3174
|
}
|
|
2507
3175
|
|
|
2508
|
-
.ee-compose
|
|
2509
|
-
background: rgba(0, 0, 0, 0.7);
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
|
-
.ee-dark-mode .ee-compose-dialog {
|
|
2513
|
-
background: #202020;
|
|
3176
|
+
.ee-compose.ee-dark-mode {
|
|
2514
3177
|
color: #e0e0e0;
|
|
2515
3178
|
}
|
|
2516
3179
|
|
|
2517
|
-
.ee-dark-mode .ee-compose-
|
|
2518
|
-
background:
|
|
2519
|
-
border-color: #
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
.ee-dark-mode .ee-compose-close {
|
|
2523
|
-
color: #999;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
.ee-dark-mode .ee-compose-close:hover {
|
|
2527
|
-
color: #fff;
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
|
-
.ee-dark-mode .ee-compose-input,
|
|
2531
|
-
.ee-dark-mode .ee-compose-textarea {
|
|
2532
|
-
background: #1a1a1a;
|
|
2533
|
-
border-color: #444;
|
|
2534
|
-
color: #e0e0e0;
|
|
3180
|
+
.ee-compose.ee-dark-mode .ee-compose-dialog {
|
|
3181
|
+
background: #202020;
|
|
3182
|
+
border-color: #3a3a3a;
|
|
3183
|
+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
|
|
2535
3184
|
}
|
|
2536
3185
|
|
|
2537
|
-
.ee-dark-mode .ee-compose-
|
|
2538
|
-
|
|
2539
|
-
border-color: var(--_accent-hover);
|
|
2540
|
-
box-shadow: 0 0 0 2px color-mix(in srgb, var(--_accent) 25%, transparent);
|
|
3186
|
+
.ee-compose.ee-dark-mode .ee-compose-header {
|
|
3187
|
+
background: #111;
|
|
2541
3188
|
}
|
|
2542
3189
|
|
|
2543
|
-
.ee-dark-mode .ee-compose-
|
|
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) {
|
|
2544
3195
|
border-color: #333;
|
|
2545
3196
|
}
|
|
2546
3197
|
|
|
2547
|
-
.ee-dark-mode .ee-compose-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
background: #333;
|
|
2553
|
-
}
|
|
2554
|
-
|
|
2555
|
-
.ee-dark-mode .ee-compose-save-draft {
|
|
2556
|
-
color: var(--_accent-light);
|
|
2557
|
-
border-color: var(--_accent-light);
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
.ee-dark-mode .ee-compose-save-draft:hover:not(:disabled) {
|
|
2561
|
-
background: var(--_accent-light);
|
|
2562
|
-
color: #1a1a1a;
|
|
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 {
|
|
3202
|
+
color: #999;
|
|
2563
3203
|
}
|
|
2564
3204
|
|
|
2565
|
-
.ee-dark-mode .ee-
|
|
2566
|
-
|
|
3205
|
+
.ee-compose.ee-dark-mode .ee-compose-format,
|
|
3206
|
+
.ee-compose.ee-dark-mode .ee-compose-icon-button {
|
|
3207
|
+
color: #bbb;
|
|
2567
3208
|
}
|
|
2568
3209
|
|
|
2569
|
-
.ee-dark-mode .ee-
|
|
2570
|
-
|
|
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;
|
|
3217
|
+
color: #fff;
|
|
2571
3218
|
}
|
|
2572
3219
|
|
|
2573
|
-
.ee-dark-mode .ee-
|
|
2574
|
-
|
|
2575
|
-
color: #
|
|
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;
|
|
2576
3223
|
}
|
|
2577
3224
|
|
|
2578
|
-
.ee-dark-mode .ee-compose-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
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;
|
|
3231
|
+
border-color: #444;
|
|
3232
|
+
color: #e0e0e0;
|
|
2582
3233
|
}
|
|
2583
3234
|
|
|
2584
|
-
.ee-dark-mode .ee-compose-
|
|
2585
|
-
|
|
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;
|
|
2586
3239
|
}
|
|
2587
3240
|
|
|
2588
|
-
.ee-dark-mode .ee-compose-
|
|
2589
|
-
|
|
3241
|
+
.ee-compose.ee-dark-mode .ee-compose-editor a,
|
|
3242
|
+
.ee-compose.ee-dark-mode .ee-compose-link {
|
|
3243
|
+
color: var(--_accent-light);
|
|
2590
3244
|
}
|
|
2591
3245
|
|
|
2592
|
-
.ee-dark-mode .ee-compose-
|
|
2593
|
-
|
|
2594
|
-
|
|
3246
|
+
.ee-compose.ee-dark-mode .ee-compose-error {
|
|
3247
|
+
background: #3a2222;
|
|
3248
|
+
border-color: #5c3030;
|
|
3249
|
+
color: #f0a5a5;
|
|
2595
3250
|
}
|
|
2596
3251
|
|
|
2597
|
-
.ee-dark-mode .ee-compose
|
|
2598
|
-
|
|
2599
|
-
border-color: #444;
|
|
3252
|
+
.ee-dark-mode .ee-sidebar-compose {
|
|
3253
|
+
border-color: #333;
|
|
2600
3254
|
}
|
|
2601
3255
|
|
|
2602
|
-
.ee-dark-mode .ee-
|
|
2603
|
-
|
|
2604
|
-
.ee-dark-mode .ee-compose-quote-label {
|
|
2605
|
-
color: #999;
|
|
3256
|
+
.ee-dark-mode .ee-toolbar-divider {
|
|
3257
|
+
background: #444;
|
|
2606
3258
|
}
|
|
2607
3259
|
|
|
2608
|
-
.ee-dark-mode .ee-
|
|
2609
|
-
|
|
2610
|
-
border-color: #444;
|
|
3260
|
+
.ee-dark-mode .ee-address {
|
|
3261
|
+
color: #aaa;
|
|
2611
3262
|
}
|
|
2612
3263
|
`);
|
|
2613
3264
|
document.head.appendChild(style);
|
|
@@ -2707,39 +3358,105 @@ export class EmailEngineClient {
|
|
|
2707
3358
|
return;
|
|
2708
3359
|
}
|
|
2709
3360
|
|
|
2710
|
-
const sortedFolders = this.buildFolderTree();
|
|
2711
|
-
// Precompute which paths are some folder's parent so the per-row
|
|
2712
|
-
// has-children check is O(1) instead of scanning this.folders each time.
|
|
2713
|
-
const parentPaths = new Set(this.folders.map(f => f.parentPath));
|
|
2714
|
-
|
|
2715
3361
|
const html = `
|
|
2716
3362
|
<ul class="ee-folder-list">
|
|
2717
|
-
${
|
|
2718
|
-
.map(({ folder, depth }) =>
|
|
2719
|
-
const hasChildren = parentPaths.has(folder.path);
|
|
2720
|
-
return `
|
|
2721
|
-
<li class="ee-folder-item ${folder.path === this.currentFolder ? 'active' : ''}"
|
|
2722
|
-
data-path="${this.escapeHtml(folder.path)}"
|
|
2723
|
-
data-depth="${depth}">
|
|
2724
|
-
<div class="ee-folder-content" style="padding-left: ${8 + depth * 12}px;">
|
|
2725
|
-
${depth > 0 ? '<span class="ee-folder-indent">└ </span>' : ''}
|
|
2726
|
-
<span class="ee-folder-name ${hasChildren ? 'has-children' : ''}">${this.escapeHtml(folder.name)}</span>
|
|
2727
|
-
${folder.status && folder.status.messages > 0 ? `<span class="ee-folder-count">${folder.status.messages}</span>` : ''}
|
|
2728
|
-
</div>
|
|
2729
|
-
</li>
|
|
2730
|
-
`;
|
|
2731
|
-
})
|
|
3363
|
+
${this.buildFolderTree()
|
|
3364
|
+
.map(({ folder, depth }) => this._folderItemHtml(folder, depth))
|
|
2732
3365
|
.join('')}
|
|
2733
3366
|
</ul>
|
|
2734
3367
|
`;
|
|
2735
3368
|
folderTree.innerHTML = html;
|
|
3369
|
+
}
|
|
2736
3370
|
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
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
|
+
`;
|
|
2743
3460
|
}
|
|
2744
3461
|
|
|
2745
3462
|
renderMessageList() {
|
|
@@ -2753,61 +3470,18 @@ export class EmailEngineClient {
|
|
|
2753
3470
|
}
|
|
2754
3471
|
|
|
2755
3472
|
if (!this.messages.length) {
|
|
2756
|
-
messageList.innerHTML = `${this._messageListHeader(this.currentFolder)}<div class="ee-empty-state">No messages</div>`;
|
|
3473
|
+
messageList.innerHTML = `${this._messageListHeader(this.currentFolder)}<div class="ee-empty-state">No messages in this folder</div>`;
|
|
2757
3474
|
return;
|
|
2758
3475
|
}
|
|
2759
3476
|
|
|
2760
|
-
const
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
// one disabled, so the controls do not shift under the pointer between pages
|
|
2764
|
-
const controls = `
|
|
2765
|
-
<div class="ee-pagination-controls">
|
|
2766
|
-
${
|
|
2767
|
-
hasPagination
|
|
2768
|
-
? `
|
|
2769
|
-
${this._iconButton('prev-page', 'back', 'Previous page', '', !this.prevPageCursor)}
|
|
2770
|
-
${this._iconButton('next-page', 'next', 'Next page', '', !this.nextPageCursor)}
|
|
2771
|
-
`
|
|
2772
|
-
: ''
|
|
2773
|
-
}
|
|
2774
|
-
<label class="ee-page-size-selector" title="Messages per page">
|
|
2775
|
-
<span class="ee-page-size-label">Show</span>
|
|
2776
|
-
<select class="ee-button ee-page-size-select" data-action="page-size">
|
|
2777
|
-
<option value="10" ${this.pageSize === 10 ? 'selected' : ''}>10</option>
|
|
2778
|
-
<option value="20" ${this.pageSize === 20 ? 'selected' : ''}>20</option>
|
|
2779
|
-
<option value="30" ${this.pageSize === 30 ? 'selected' : ''}>30</option>
|
|
2780
|
-
<option value="50" ${this.pageSize === 50 ? 'selected' : ''}>50</option>
|
|
2781
|
-
<option value="100" ${this.pageSize === 100 ? 'selected' : ''}>100</option>
|
|
2782
|
-
</select>
|
|
2783
|
-
</label>
|
|
2784
|
-
</div>
|
|
2785
|
-
`;
|
|
2786
|
-
|
|
2787
|
-
const html = `
|
|
2788
|
-
${this._messageListHeader(this.currentFolder, controls)}
|
|
3477
|
+
const outgoing = this._isOutgoingFolder(this.currentFolder);
|
|
3478
|
+
messageList.innerHTML = `
|
|
3479
|
+
${this._messageListHeader(this.currentFolder)}
|
|
2789
3480
|
<div class="ee-message-items">
|
|
2790
|
-
${this.messages
|
|
2791
|
-
.map(
|
|
2792
|
-
msg => `
|
|
2793
|
-
<div class="ee-message-item ${msg.unseen ? 'unread' : ''} ${msg.id === (this.currentMessage && this.currentMessage.id) ? 'active' : ''}" data-id="${this.escapeHtml(msg.id)}">
|
|
2794
|
-
<div class="ee-message-header">
|
|
2795
|
-
<span class="ee-message-from">${this.escapeHtml(msg.from ? msg.from.name || msg.from.address : 'Unknown')}</span>
|
|
2796
|
-
<span class="ee-message-date">${this.formatDate(msg.date)}</span>
|
|
2797
|
-
</div>
|
|
2798
|
-
<div class="ee-message-subject">
|
|
2799
|
-
${this._responseMarkers(msg)}
|
|
2800
|
-
<span class="ee-message-subject-text">${this.escapeHtml(msg.subject || '(no subject)')}</span>
|
|
2801
|
-
${msg.attachments && msg.attachments.length > 0 ? `<span class="ee-attachment-indicator" title="Attachments">${icon('paperclip', 12)}${msg.attachments.length}</span>` : ''}
|
|
2802
|
-
</div>
|
|
2803
|
-
<div class="ee-message-preview">${this.escapeHtml(msg.intro || '')}</div>
|
|
2804
|
-
</div>
|
|
2805
|
-
`
|
|
2806
|
-
)
|
|
2807
|
-
.join('')}
|
|
3481
|
+
${this.messages.map(msg => this._messageItemHtml(msg, outgoing)).join('')}
|
|
2808
3482
|
</div>
|
|
3483
|
+
${this._messageListFooter()}
|
|
2809
3484
|
`;
|
|
2810
|
-
messageList.innerHTML = html;
|
|
2811
3485
|
|
|
2812
3486
|
messageList.querySelectorAll('.ee-message-item').forEach(item => {
|
|
2813
3487
|
item.addEventListener('click', () => {
|
|
@@ -2875,7 +3549,7 @@ export class EmailEngineClient {
|
|
|
2875
3549
|
${this._toolbarButton('forward', 'forward', 'Forward', 'Forward this message', 'ee-label-priority')}
|
|
2876
3550
|
<span class="ee-toolbar-divider"></span>`;
|
|
2877
3551
|
const actions = `
|
|
2878
|
-
${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}
|
|
2879
3553
|
${this._toolbarButton('toggle-read', isUnseen ? 'mailOpen' : 'mail', isUnseen ? 'Mark read' : 'Mark unread', isUnseen ? 'Mark as read' : 'Mark as unread')}
|
|
2880
3554
|
<span class="ee-button ee-move-button" title="Move to folder">
|
|
2881
3555
|
${icon('move')}<span class="ee-button-label">Move</span>${icon('chevronDown', 12)}
|
|
@@ -2925,28 +3599,7 @@ export class EmailEngineClient {
|
|
|
2925
3599
|
</div>
|
|
2926
3600
|
${this.renderOtpBox(msg.otp)}
|
|
2927
3601
|
<div class="ee-message-body"></div>
|
|
2928
|
-
${
|
|
2929
|
-
msg.attachments && msg.attachments.length > 0
|
|
2930
|
-
? `
|
|
2931
|
-
<div class="ee-attachments">
|
|
2932
|
-
<div class="ee-attachments-title">Attachments (${msg.attachments.length})</div>
|
|
2933
|
-
${msg.attachments
|
|
2934
|
-
.map(
|
|
2935
|
-
att => `
|
|
2936
|
-
<div class="ee-attachment-item" data-attachment-id="${this.escapeHtml(att.id)}">
|
|
2937
|
-
<div class="ee-attachment-icon">${icon('paperclip', 18)}</div>
|
|
2938
|
-
<div class="ee-attachment-info">
|
|
2939
|
-
<div class="ee-attachment-name">${this.escapeHtml(att.filename || 'Unnamed attachment')}</div>
|
|
2940
|
-
${att.size ? `<div class="ee-attachment-size">${this.formatFileSize(att.size)}</div>` : ''}
|
|
2941
|
-
</div>
|
|
2942
|
-
</div>
|
|
2943
|
-
`
|
|
2944
|
-
)
|
|
2945
|
-
.join('')}
|
|
2946
|
-
</div>
|
|
2947
|
-
`
|
|
2948
|
-
: ''
|
|
2949
|
-
}
|
|
3602
|
+
${this._attachmentsHtml(listedAttachments(msg.attachments))}
|
|
2950
3603
|
</div>
|
|
2951
3604
|
`;
|
|
2952
3605
|
viewer.innerHTML = html;
|
|
@@ -2991,6 +3644,13 @@ export class EmailEngineClient {
|
|
|
2991
3644
|
});
|
|
2992
3645
|
}
|
|
2993
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
|
+
|
|
2994
3654
|
viewer.querySelectorAll('[data-action="reply"], [data-action="reply-all"], [data-action="forward"]').forEach(button => {
|
|
2995
3655
|
button.addEventListener('click', () => {
|
|
2996
3656
|
this._respond(msg.id, button.dataset.action).catch(error => this._alertActionFailed(error, 'Failed to open the compose form'));
|
|
@@ -3057,6 +3717,34 @@ export class EmailEngineClient {
|
|
|
3057
3717
|
// Message content scrolling is now handled in loadMessage method
|
|
3058
3718
|
}
|
|
3059
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
|
+
|
|
3060
3748
|
// Replied / forwarded markers from the flags the server sets on the original once a reply or
|
|
3061
3749
|
// forward has been delivered (IMAP accounts; Gmail API and MS Graph report neither flag).
|
|
3062
3750
|
// labelled shows the words next to the icons, otherwise they are the accessible name only.
|
|
@@ -3109,6 +3797,12 @@ export class EmailEngineClient {
|
|
|
3109
3797
|
}
|
|
3110
3798
|
|
|
3111
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
|
+
}
|
|
3112
3806
|
// A message that sets its own colours or backgrounds was designed for a light page;
|
|
3113
3807
|
// in dark mode its dark text would land on a dark background, or the client's light
|
|
3114
3808
|
// text on its white tables, so it is shown on a light surface instead (see the
|
|
@@ -3169,11 +3863,12 @@ export class EmailEngineClient {
|
|
|
3169
3863
|
</div>
|
|
3170
3864
|
<button type="button" class="ee-compose-button${this.darkMode ? ' ee-dark-mode' : ''}" title="Compose email" aria-label="Compose">${icon('compose', 22)}</button>
|
|
3171
3865
|
<div class="ee-toast${this.darkMode ? ' ee-dark-mode' : ''}" role="status" aria-live="polite"></div>
|
|
3172
|
-
<div class="ee-compose
|
|
3173
|
-
<div class="ee-compose-dialog" role="dialog" aria-modal="
|
|
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')}">
|
|
3174
3868
|
<div class="ee-compose-header">
|
|
3175
|
-
<h3 class="ee-compose-title">${COMPOSE_TITLES.new}</h3>
|
|
3176
|
-
<button type="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>
|
|
3177
3872
|
</div>
|
|
3178
3873
|
<form class="ee-compose-form" novalidate>
|
|
3179
3874
|
<div class="ee-compose-row">
|
|
@@ -3193,33 +3888,48 @@ export class EmailEngineClient {
|
|
|
3193
3888
|
<label class="ee-compose-label" for="${this._composeId('subject')}">Subject</label>
|
|
3194
3889
|
<input type="text" class="ee-compose-input" id="${this._composeId('subject')}" name="subject">
|
|
3195
3890
|
</div>
|
|
3196
|
-
<
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
<label class="ee-compose-forward-attachments" hidden>
|
|
3203
|
-
<input type="checkbox" name="forwardAttachments" checked>
|
|
3204
|
-
<span class="ee-compose-forward-attachments-label"></span>
|
|
3205
|
-
</label>
|
|
3206
|
-
</div>
|
|
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>
|
|
3207
3897
|
</div>
|
|
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>
|
|
3208
3905
|
<div class="ee-compose-quote" hidden>
|
|
3209
|
-
<
|
|
3210
|
-
<div class="ee-compose-quote-
|
|
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>
|
|
3211
3911
|
</div>
|
|
3212
3912
|
</form>
|
|
3213
3913
|
<div class="ee-compose-error" role="alert" hidden></div>
|
|
3214
3914
|
<div class="ee-compose-actions">
|
|
3215
|
-
<button type="button" class="ee-compose-cancel">Cancel</button>
|
|
3216
|
-
<button type="button" class="ee-compose-save-draft">Save Draft</button>
|
|
3217
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>
|
|
3218
3920
|
</div>
|
|
3219
3921
|
</div>
|
|
3220
3922
|
</div>
|
|
3221
3923
|
`;
|
|
3222
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
|
+
|
|
3223
3933
|
// Pane navigation in the single-pane layout, delegated because the panes
|
|
3224
3934
|
// re-render their headers on every load
|
|
3225
3935
|
this.container.querySelector('.ee-client').addEventListener('click', e => {
|
|
@@ -3245,10 +3955,16 @@ export class EmailEngineClient {
|
|
|
3245
3955
|
return `${this._composeIdPrefix}-${field}`;
|
|
3246
3956
|
}
|
|
3247
3957
|
|
|
3248
|
-
//
|
|
3249
|
-
|
|
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.
|
|
3250
3966
|
compose(prefill = {}) {
|
|
3251
|
-
this._openCompose({ mode: 'new'
|
|
3967
|
+
return this._openCompose({ ...prefill, mode: 'new' });
|
|
3252
3968
|
}
|
|
3253
3969
|
|
|
3254
3970
|
// Opens the compose form as a reply to a message (the open one when messageId is omitted)
|
|
@@ -3276,62 +3992,182 @@ export class EmailEngineClient {
|
|
|
3276
3992
|
)
|
|
3277
3993
|
]);
|
|
3278
3994
|
|
|
3279
|
-
this._openCompose({ mode: action, original: msg, ...this.prepareResponse(msg, action, ownAddress) });
|
|
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
|
+
});
|
|
3280
4025
|
}
|
|
3281
4026
|
|
|
3282
|
-
_openCompose(
|
|
4027
|
+
async _openCompose(state = {}) {
|
|
3283
4028
|
const els = this._compose && this._compose.els;
|
|
3284
4029
|
if (!els) {
|
|
3285
4030
|
throw new Error('The compose form needs the client UI (a container)');
|
|
3286
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 }) {
|
|
3287
4042
|
this._resetCompose();
|
|
3288
|
-
this._compose
|
|
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
|
+
});
|
|
3289
4052
|
|
|
3290
4053
|
const asField = value => (typeof value === 'string' ? value : this.formatAddressList(value));
|
|
3291
|
-
const { form } = els;
|
|
4054
|
+
const { form, editor } = els;
|
|
3292
4055
|
form.elements.to.value = asField(to);
|
|
3293
4056
|
form.elements.cc.value = asField(cc);
|
|
3294
4057
|
form.elements.bcc.value = asField(bcc);
|
|
3295
4058
|
form.elements.subject.value = subject || '';
|
|
3296
|
-
|
|
4059
|
+
editor.innerHTML = html ? sanitizeEditorHtml(html) : textToEditorHtml(text || '');
|
|
4060
|
+
this._updateEditorEmpty();
|
|
3297
4061
|
this._showCopyFields({ cc: !!form.elements.cc.value, bcc: !!form.elements.bcc.value });
|
|
3298
4062
|
|
|
3299
4063
|
els.title.textContent = COMPOSE_TITLES[mode] || COMPOSE_TITLES.new;
|
|
3300
|
-
|
|
3301
|
-
// The server carries the original's attachments over on request (all or none)
|
|
3302
|
-
const originalAttachments = original && mode === 'forward' ? (original.attachments || []).filter(att => !att.inline && !att.embedded) : [];
|
|
3303
|
-
els.forwardAttachments.hidden = !originalAttachments.length;
|
|
3304
|
-
els.forwardAttachments.querySelector('.ee-compose-forward-attachments-label').textContent =
|
|
3305
|
-
`Include the original attachments (${originalAttachments.length})`;
|
|
3306
|
-
|
|
3307
4064
|
if (original && reference && reference.inline) {
|
|
3308
4065
|
this._renderComposeQuote(original, mode);
|
|
3309
4066
|
}
|
|
4067
|
+
this._renderComposeChips();
|
|
4068
|
+
this._compose.snapshot = this._composeSnapshot();
|
|
4069
|
+
}
|
|
3310
4070
|
|
|
3311
|
-
|
|
3312
|
-
const
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
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);
|
|
3319
4086
|
}
|
|
3320
4087
|
|
|
3321
|
-
//
|
|
3322
|
-
|
|
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 saving failed, so the message stays on screen.
|
|
4104
|
+
async _settleOpenCompose() {
|
|
4105
|
+
if (!this._isComposeDirty()) {
|
|
4106
|
+
return true;
|
|
4107
|
+
}
|
|
4108
|
+
this._setComposeMinimized(false);
|
|
4109
|
+
const save = await this.confirmMethod('Save the message you are writing as a draft?', 'Unsaved message', 'Discard', 'Save draft');
|
|
4110
|
+
if (!save) {
|
|
4111
|
+
return true;
|
|
4112
|
+
}
|
|
4113
|
+
return this._saveComposeDraft();
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// Closes the form, asking first when it holds unsaved changes
|
|
4117
|
+
async _requestCloseCompose() {
|
|
4118
|
+
if (await this._settleOpenCompose()) {
|
|
4119
|
+
this._closeCompose();
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
_setComposeMinimized(minimized) {
|
|
4124
|
+
const { dialog, minimizeButton } = this._compose.els;
|
|
4125
|
+
dialog.classList.toggle('minimized', minimized);
|
|
4126
|
+
const label = minimized ? 'Restore' : 'Minimize';
|
|
4127
|
+
minimizeButton.setAttribute('aria-label', label);
|
|
4128
|
+
minimizeButton.title = label;
|
|
4129
|
+
}
|
|
4130
|
+
|
|
4131
|
+
// The message being answered or forwarded, read-only under the editor. The quote that is sent
|
|
4132
|
+
// is built by the server from the stored original; this shows what it will contain. A reply's
|
|
4133
|
+
// quote starts folded, a forward's open, with the forwarded message's own header above it.
|
|
3323
4134
|
_renderComposeQuote(original, mode) {
|
|
3324
4135
|
const { quote } = this._compose.els;
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3327
|
-
quote.querySelector('.ee-compose-quote-label').textContent =
|
|
3328
|
-
mode === 'forward' ? 'The forwarded message is added below your text:' : `${sender}'s message is quoted below your reply:`;
|
|
4136
|
+
const forward = mode === 'forward';
|
|
4137
|
+
quote.querySelector('.ee-compose-quote-header').innerHTML = forward ? this._forwardHeaderHtml(original) : '';
|
|
3329
4138
|
// A shadow root cannot be attached twice, so each quote gets a fresh host
|
|
3330
4139
|
const host = document.createElement('div');
|
|
3331
4140
|
host.className = 'ee-compose-quote-body';
|
|
3332
4141
|
quote.querySelector('.ee-compose-quote-frame').replaceChildren(host);
|
|
3333
4142
|
this._labelCollapsedThreads(this._renderMessageBody(host, original));
|
|
3334
4143
|
quote.hidden = false;
|
|
4144
|
+
this._setQuoteExpanded(forward);
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
_setQuoteExpanded(expanded) {
|
|
4148
|
+
const { quote } = this._compose.els;
|
|
4149
|
+
const toggle = quote.querySelector('.ee-compose-quote-toggle');
|
|
4150
|
+
const forward = this._compose.mode === 'forward';
|
|
4151
|
+
toggle.setAttribute('aria-expanded', String(expanded));
|
|
4152
|
+
const label = `${expanded ? 'Hide' : 'Show'} ${forward ? 'forwarded message' : 'quoted text'}`;
|
|
4153
|
+
toggle.title = label;
|
|
4154
|
+
toggle.querySelector('.ee-compose-quote-toggle-label').textContent = label;
|
|
4155
|
+
quote.querySelector('.ee-compose-quote-content').hidden = !expanded;
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
// The header of a forwarded message, as the server adds it to the sent message
|
|
4159
|
+
_forwardHeaderHtml(original) {
|
|
4160
|
+
const rows = [
|
|
4161
|
+
['From', this._addressListHtml(original.from)],
|
|
4162
|
+
['Date', this.escapeHtml(this.formatFullDate(original.date))],
|
|
4163
|
+
['Subject', this.escapeHtml(original.subject || '(no subject)')],
|
|
4164
|
+
['To', this._addressListHtml(original.to)],
|
|
4165
|
+
['Cc', this._addressListHtml(original.cc)]
|
|
4166
|
+
].filter(([, value]) => value);
|
|
4167
|
+
return `
|
|
4168
|
+
<div class="ee-forward-title">Forwarded message</div>
|
|
4169
|
+
${rows.map(([label, value]) => `<div class="ee-forward-row"><span class="ee-forward-label">${label}</span><span>${value}</span></div>`).join('')}
|
|
4170
|
+
`;
|
|
3335
4171
|
}
|
|
3336
4172
|
|
|
3337
4173
|
// Shows the Cc and Bcc fields named true and hides the rest; the link offers whichever is hidden
|
|
@@ -3353,19 +4189,21 @@ export class EmailEngineClient {
|
|
|
3353
4189
|
_resetCompose() {
|
|
3354
4190
|
const { els } = this._compose;
|
|
3355
4191
|
els.form.reset();
|
|
4192
|
+
els.editor.replaceChildren();
|
|
3356
4193
|
els.chips.replaceChildren();
|
|
3357
4194
|
els.fileInput.value = '';
|
|
3358
|
-
els.
|
|
4195
|
+
els.linkbar.hidden = true;
|
|
3359
4196
|
els.quote.hidden = true;
|
|
4197
|
+
els.quote.querySelector('.ee-compose-quote-header').replaceChildren();
|
|
3360
4198
|
els.quote.querySelector('.ee-compose-quote-frame').replaceChildren();
|
|
3361
4199
|
this._clearComposeError();
|
|
3362
|
-
this._compose = { els, reference: null, files: [] };
|
|
4200
|
+
this._compose = { els, mode: 'new', reference: null, original: null, headers: null, draftId: null, files: [], snapshot: null };
|
|
3363
4201
|
this._showCopyFields({ cc: false, bcc: false });
|
|
3364
4202
|
}
|
|
3365
4203
|
|
|
3366
4204
|
_closeCompose() {
|
|
3367
4205
|
if (this._compose && this._compose.els) {
|
|
3368
|
-
this._compose.els.
|
|
4206
|
+
this._compose.els.root.hidden = true;
|
|
3369
4207
|
this._resetCompose();
|
|
3370
4208
|
}
|
|
3371
4209
|
}
|
|
@@ -3373,11 +4211,11 @@ export class EmailEngineClient {
|
|
|
3373
4211
|
// Shows why the form cannot go out, inside the form itself, and marks the field it is about.
|
|
3374
4212
|
// The message stays until the form is changed or closed.
|
|
3375
4213
|
_showComposeError(message, field = null) {
|
|
3376
|
-
const { form, error } = this._compose.els;
|
|
4214
|
+
const { form, error, editor } = this._compose.els;
|
|
3377
4215
|
this._clearComposeError();
|
|
3378
4216
|
error.textContent = message;
|
|
3379
4217
|
error.hidden = false;
|
|
3380
|
-
const input = field ? form.elements[field] : null;
|
|
4218
|
+
const input = field === 'message' ? editor : field ? form.elements[field] : null;
|
|
3381
4219
|
if (input) {
|
|
3382
4220
|
input.setAttribute('aria-invalid', 'true');
|
|
3383
4221
|
input.focus();
|
|
@@ -3385,22 +4223,26 @@ export class EmailEngineClient {
|
|
|
3385
4223
|
}
|
|
3386
4224
|
|
|
3387
4225
|
_clearComposeError() {
|
|
3388
|
-
const {
|
|
4226
|
+
const { dialog, error } = this._compose.els;
|
|
3389
4227
|
error.hidden = true;
|
|
3390
|
-
|
|
4228
|
+
dialog.querySelectorAll('[aria-invalid]').forEach(input => input.removeAttribute('aria-invalid'));
|
|
3391
4229
|
}
|
|
3392
4230
|
|
|
4231
|
+
// Attachment chips: picked files, and the original's files of a forward or the files of a
|
|
4232
|
+
// reopened draft, which travel as references. Each can be removed.
|
|
3393
4233
|
_renderComposeChips() {
|
|
3394
4234
|
this._compose.els.chips.innerHTML = this._compose.files
|
|
3395
|
-
.map(
|
|
3396
|
-
|
|
4235
|
+
.map((entry, index) => {
|
|
4236
|
+
const name = entry.kind === 'reference' ? entry.filename || 'Unnamed attachment' : entry.file.name;
|
|
4237
|
+
const size = entry.kind === 'reference' ? entry.size : entry.file.size;
|
|
4238
|
+
return `
|
|
3397
4239
|
<span class="ee-compose-chip">
|
|
3398
4240
|
${icon('paperclip', 12)}
|
|
3399
|
-
<span class="ee-compose-chip-name">${this.escapeHtml(
|
|
3400
|
-
|
|
3401
|
-
<button type="button" class="ee-compose-chip-remove" data-index="${index}" aria-label="Remove ${this.escapeHtml(
|
|
3402
|
-
</span
|
|
3403
|
-
)
|
|
4241
|
+
<span class="ee-compose-chip-name">${this.escapeHtml(name)}</span>
|
|
4242
|
+
${size ? `<span class="ee-compose-chip-size">${this.formatFileSize(size)}</span>` : ''}
|
|
4243
|
+
<button type="button" class="ee-compose-chip-remove" data-index="${index}" aria-label="Remove ${this.escapeHtml(name)}" title="Remove">${icon('close', 12)}</button>
|
|
4244
|
+
</span>`;
|
|
4245
|
+
})
|
|
3404
4246
|
.join('');
|
|
3405
4247
|
}
|
|
3406
4248
|
|
|
@@ -3417,9 +4259,10 @@ export class EmailEngineClient {
|
|
|
3417
4259
|
}
|
|
3418
4260
|
|
|
3419
4261
|
// Takes picked files into the form within the size limit. They are kept as File objects and
|
|
3420
|
-
// read only when the message is sent, so a removed file is never read at all.
|
|
4262
|
+
// read only when the message is sent, so a removed file is never read at all. Files of the
|
|
4263
|
+
// original travel as references and do not count against the limit.
|
|
3421
4264
|
_addComposeFiles(files) {
|
|
3422
|
-
let total = this._compose.files.reduce((sum,
|
|
4265
|
+
let total = this._compose.files.reduce((sum, entry) => sum + (entry.kind === 'file' ? entry.file.size : 0), 0);
|
|
3423
4266
|
const skipped = [];
|
|
3424
4267
|
for (const file of files) {
|
|
3425
4268
|
if (total + file.size > this.maxAttachmentSize) {
|
|
@@ -3427,7 +4270,7 @@ export class EmailEngineClient {
|
|
|
3427
4270
|
continue;
|
|
3428
4271
|
}
|
|
3429
4272
|
total += file.size;
|
|
3430
|
-
this._compose.files.push(file);
|
|
4273
|
+
this._compose.files.push({ kind: 'file', file });
|
|
3431
4274
|
}
|
|
3432
4275
|
this._renderComposeChips();
|
|
3433
4276
|
if (skipped.length) {
|
|
@@ -3437,19 +4280,25 @@ export class EmailEngineClient {
|
|
|
3437
4280
|
|
|
3438
4281
|
_readComposeAttachments(files) {
|
|
3439
4282
|
return Promise.all(
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
4283
|
+
// a reference entry goes as it is; attachmentPayload keeps only the fields it sends
|
|
4284
|
+
files.map(async entry =>
|
|
4285
|
+
entry.kind === 'reference'
|
|
4286
|
+
? entry
|
|
4287
|
+
: {
|
|
4288
|
+
filename: entry.file.name,
|
|
4289
|
+
contentType: entry.file.type || 'application/octet-stream',
|
|
4290
|
+
content: await this._readFileAsBase64(entry.file)
|
|
4291
|
+
}
|
|
4292
|
+
)
|
|
3445
4293
|
);
|
|
3446
4294
|
}
|
|
3447
4295
|
|
|
3448
|
-
// The form as a
|
|
3449
|
-
//
|
|
3450
|
-
//
|
|
4296
|
+
// The form as a message object, plus the first reason it cannot go out as asked (null when it
|
|
4297
|
+
// can). requireMessage applies the send rules: a recipient, and some text unless the message
|
|
4298
|
+
// is a forward.
|
|
3451
4299
|
_readComposeForm(requireMessage) {
|
|
3452
|
-
const { form } = this._compose.els;
|
|
4300
|
+
const { form, editor } = this._compose.els;
|
|
4301
|
+
const { reference, headers } = this._compose;
|
|
3453
4302
|
const fields = {};
|
|
3454
4303
|
const invalid = [];
|
|
3455
4304
|
for (const key of ['to', 'cc', 'bcc']) {
|
|
@@ -3457,41 +4306,34 @@ export class EmailEngineClient {
|
|
|
3457
4306
|
invalid.push(...fields[key].filter(entry => !ADDRESS_PATTERN.test(entry.address)).map(entry => entry.address || entry.name));
|
|
3458
4307
|
}
|
|
3459
4308
|
|
|
3460
|
-
|
|
3461
|
-
const
|
|
3462
|
-
if (isForward) {
|
|
3463
|
-
reference = { ...reference, forwardAttachments: form.elements.forwardAttachments.checked };
|
|
3464
|
-
}
|
|
4309
|
+
const text = editorText(editor);
|
|
4310
|
+
const html = text ? sanitizeEditorHtml(editor.innerHTML) : '';
|
|
3465
4311
|
|
|
3466
|
-
const
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
text: form.elements.message.value,
|
|
3470
|
-
files: this._compose.files,
|
|
3471
|
-
options: { cc: fields.cc, bcc: fields.bcc, reference }
|
|
3472
|
-
};
|
|
4312
|
+
const message = { to: fields.to, cc: fields.cc, bcc: fields.bcc, subject: form.elements.subject.value.trim(), text, html, reference, headers };
|
|
4313
|
+
const isForward = !!reference && reference.action === 'forward';
|
|
4314
|
+
const empty = !fields.to.length && !fields.cc.length && !fields.bcc.length && !message.subject && !text && !this._compose.files.length && !reference;
|
|
3473
4315
|
|
|
3474
|
-
|
|
4316
|
+
let problem = null;
|
|
3475
4317
|
if (requireMessage && !fields.to.length) {
|
|
3476
|
-
|
|
4318
|
+
problem = { message: 'Add at least one recipient.', field: 'to' };
|
|
3477
4319
|
} else if (!requireMessage && empty) {
|
|
3478
|
-
|
|
4320
|
+
problem = { message: 'Nothing to save - fill in at least one field first.', field: 'to' };
|
|
3479
4321
|
} else if (invalid.length) {
|
|
3480
|
-
|
|
3481
|
-
} else if (requireMessage && !
|
|
4322
|
+
problem = { message: `Not a valid email address: ${invalid.join(', ')}`, field: 'to' };
|
|
4323
|
+
} else if (requireMessage && !text && !isForward) {
|
|
3482
4324
|
// A forward can go without a note of its own; anything else needs some text
|
|
3483
|
-
|
|
4325
|
+
problem = { message: 'Write a message before sending.', field: 'message' };
|
|
3484
4326
|
}
|
|
3485
|
-
return
|
|
4327
|
+
return { message, problem };
|
|
3486
4328
|
}
|
|
3487
4329
|
|
|
3488
4330
|
// Runs a compose request with its button showing progress. The form is checked first, the
|
|
3489
4331
|
// picked files are read, and on success the form closes and the result is returned; on any
|
|
3490
4332
|
// failure the reason is shown over the form, kept as it was, and the result is null.
|
|
3491
4333
|
async _runComposeAction(button, busyText, errorTitle, requireMessage, submit) {
|
|
3492
|
-
const
|
|
3493
|
-
if (
|
|
3494
|
-
this._showComposeError(
|
|
4334
|
+
const { message, problem } = this._readComposeForm(requireMessage);
|
|
4335
|
+
if (problem) {
|
|
4336
|
+
this._showComposeError(problem.message, problem.field);
|
|
3495
4337
|
return null;
|
|
3496
4338
|
}
|
|
3497
4339
|
this._clearComposeError();
|
|
@@ -3500,8 +4342,8 @@ export class EmailEngineClient {
|
|
|
3500
4342
|
button.disabled = true;
|
|
3501
4343
|
button.textContent = busyText;
|
|
3502
4344
|
try {
|
|
3503
|
-
|
|
3504
|
-
const result = await submit(
|
|
4345
|
+
message.attachments = await this._readComposeAttachments(this._compose.files);
|
|
4346
|
+
const result = await submit(message);
|
|
3505
4347
|
this._closeCompose();
|
|
3506
4348
|
return result || {};
|
|
3507
4349
|
} catch (error) {
|
|
@@ -3514,61 +4356,298 @@ export class EmailEngineClient {
|
|
|
3514
4356
|
}
|
|
3515
4357
|
}
|
|
3516
4358
|
|
|
4359
|
+
// Saves the form as a draft, replacing the stored draft it was opened from. Resolves whether
|
|
4360
|
+
// it was saved; on failure the form stays open with the reason.
|
|
4361
|
+
async _saveComposeDraft() {
|
|
4362
|
+
const { draftId, els } = this._compose;
|
|
4363
|
+
const response = await this._runComposeAction(els.saveDraftButton, 'Saving...', 'Could not save the draft', false, message =>
|
|
4364
|
+
draftId ? this.updateDraft(draftId, message) : this.saveDraft(message)
|
|
4365
|
+
);
|
|
4366
|
+
if (!response) {
|
|
4367
|
+
return false;
|
|
4368
|
+
}
|
|
4369
|
+
this.notify('Draft saved.');
|
|
4370
|
+
this._afterDraftChange(draftId, response.path);
|
|
4371
|
+
return true;
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
// Brings the list and viewer up to date after a draft was saved, replaced or sent
|
|
4375
|
+
_afterDraftChange(oldDraftId, draftsPath) {
|
|
4376
|
+
if (this._destroyed) {
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
if (oldDraftId && this.currentMessage && this.currentMessage.id === oldDraftId) {
|
|
4380
|
+
this.currentMessage = null;
|
|
4381
|
+
this.renderMessage();
|
|
4382
|
+
this._notifyNavigate();
|
|
4383
|
+
}
|
|
4384
|
+
if (this.currentFolder && (this.currentFolder === draftsPath || this._isOutgoingFolder(this.currentFolder))) {
|
|
4385
|
+
this._fireAndForget(this.loadMessages(this.currentFolder));
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
async _sendCompose() {
|
|
4390
|
+
const { draftId, els } = this._compose;
|
|
4391
|
+
const response = await this._runComposeAction(els.sendButton, 'Sending...', 'Could not send the message', true, message => this.sendMessage(message));
|
|
4392
|
+
if (!response) {
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4395
|
+
// Submitting only queues the message; delivery happens afterwards and can still fail
|
|
4396
|
+
this.notify('Message queued for delivery.');
|
|
4397
|
+
if (draftId) {
|
|
4398
|
+
await this._discardDraft(draftId);
|
|
4399
|
+
this._afterDraftChange(draftId, null);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
async _discardCompose() {
|
|
4404
|
+
if (this._isComposeDirty()) {
|
|
4405
|
+
const discard = await this.confirmMethod('Discard this message?', 'Discard message', 'Cancel', 'Discard');
|
|
4406
|
+
if (!discard) {
|
|
4407
|
+
return;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
this._closeCompose();
|
|
4411
|
+
}
|
|
4412
|
+
|
|
4413
|
+
// The placeholder shows while the editor holds no text
|
|
4414
|
+
_updateEditorEmpty() {
|
|
4415
|
+
const { editor } = this._compose.els;
|
|
4416
|
+
editor.classList.toggle('ee-empty', !editor.textContent.trim() && !editor.querySelector('li, blockquote'));
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
// Marks the toolbar buttons whose format applies at the caret
|
|
4420
|
+
_updateFormatButtons() {
|
|
4421
|
+
const { editor, formatButtons } = this._compose.els;
|
|
4422
|
+
if (typeof document.queryCommandState !== 'function' || !editor.contains(document.activeElement)) {
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4425
|
+
for (const button of formatButtons) {
|
|
4426
|
+
let state = false;
|
|
4427
|
+
try {
|
|
4428
|
+
state = document.queryCommandState(button.dataset.command);
|
|
4429
|
+
} catch {
|
|
4430
|
+
// not supported
|
|
4431
|
+
}
|
|
4432
|
+
button.setAttribute('aria-pressed', String(state));
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
|
|
4436
|
+
_openLinkbar() {
|
|
4437
|
+
const { editor, linkbar } = this._compose.els;
|
|
4438
|
+
const selection = window.getSelection();
|
|
4439
|
+
const range = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
|
|
4440
|
+
this._compose.linkRange = range && editor.contains(range.commonAncestorContainer) ? range.cloneRange() : null;
|
|
4441
|
+
const input = linkbar.querySelector('[name="link"]');
|
|
4442
|
+
input.value = '';
|
|
4443
|
+
linkbar.hidden = false;
|
|
4444
|
+
input.focus();
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
// Hides the link field and puts the selection back where it was in the editor
|
|
4448
|
+
_closeLinkbar() {
|
|
4449
|
+
const { editor, linkbar } = this._compose.els;
|
|
4450
|
+
linkbar.hidden = true;
|
|
4451
|
+
editor.focus();
|
|
4452
|
+
const range = this._compose.linkRange;
|
|
4453
|
+
if (range) {
|
|
4454
|
+
const selection = window.getSelection();
|
|
4455
|
+
selection.removeAllRanges();
|
|
4456
|
+
selection.addRange(range);
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
|
|
4460
|
+
// Turns the selection into a link, or inserts the address as one at the caret. Only http(s)
|
|
4461
|
+
// and mailto addresses are taken; a bare host gets https://.
|
|
4462
|
+
_insertLink() {
|
|
4463
|
+
const { linkbar } = this._compose.els;
|
|
4464
|
+
const input = linkbar.querySelector('[name="link"]');
|
|
4465
|
+
let url = input.value.trim();
|
|
4466
|
+
if (!url) {
|
|
4467
|
+
this._closeLinkbar();
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4470
|
+
if (!/^[a-z][a-z0-9+.-]*:/i.test(url)) {
|
|
4471
|
+
url = url.includes('@') && !url.includes('/') ? `mailto:${url}` : `https://${url}`;
|
|
4472
|
+
}
|
|
4473
|
+
if (!SAFE_LINK.test(url)) {
|
|
4474
|
+
this._showComposeError('Links must start with http://, https:// or mailto:');
|
|
4475
|
+
input.focus();
|
|
4476
|
+
return;
|
|
4477
|
+
}
|
|
4478
|
+
this._closeLinkbar();
|
|
4479
|
+
const range = this._compose.linkRange;
|
|
4480
|
+
if (!range || range.collapsed) {
|
|
4481
|
+
const label = url.replace(/^mailto:/i, '');
|
|
4482
|
+
document.execCommand('insertHTML', false, `<a href="${this.escapeHtml(url)}">${this.escapeHtml(label)}</a>`);
|
|
4483
|
+
} else {
|
|
4484
|
+
document.execCommand('createLink', false, url);
|
|
4485
|
+
}
|
|
4486
|
+
this._updateEditorEmpty();
|
|
4487
|
+
}
|
|
4488
|
+
|
|
4489
|
+
// Pasted and dropped content goes through the editor's filter; files become attachments
|
|
4490
|
+
_onEditorPaste(e) {
|
|
4491
|
+
const data = e.clipboardData;
|
|
4492
|
+
if (!data) {
|
|
4493
|
+
return;
|
|
4494
|
+
}
|
|
4495
|
+
e.preventDefault();
|
|
4496
|
+
const html = data.getData('text/html');
|
|
4497
|
+
const text = data.getData('text/plain');
|
|
4498
|
+
if (html) {
|
|
4499
|
+
document.execCommand('insertHTML', false, sanitizeEditorHtml(html));
|
|
4500
|
+
} else if (text) {
|
|
4501
|
+
document.execCommand('insertText', false, text);
|
|
4502
|
+
} else if (data.files && data.files.length) {
|
|
4503
|
+
this._addComposeFiles(Array.from(data.files));
|
|
4504
|
+
}
|
|
4505
|
+
this._updateEditorEmpty();
|
|
4506
|
+
}
|
|
4507
|
+
|
|
3517
4508
|
setupComposeModal() {
|
|
3518
4509
|
if (typeof document === 'undefined' || !this.container) {
|
|
3519
4510
|
return;
|
|
3520
4511
|
}
|
|
3521
4512
|
|
|
3522
|
-
const
|
|
4513
|
+
const root = this.container.querySelector('.ee-compose');
|
|
4514
|
+
const dialog = root.querySelector('.ee-compose-dialog');
|
|
3523
4515
|
const els = {
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
4516
|
+
root,
|
|
4517
|
+
dialog,
|
|
4518
|
+
form: dialog.querySelector('.ee-compose-form'),
|
|
4519
|
+
title: dialog.querySelector('.ee-compose-title'),
|
|
4520
|
+
editor: dialog.querySelector('.ee-compose-editor'),
|
|
4521
|
+
toolbar: dialog.querySelector('.ee-compose-toolbar'),
|
|
4522
|
+
formatButtons: Array.from(dialog.querySelectorAll('.ee-compose-format[data-command]')),
|
|
4523
|
+
linkbar: dialog.querySelector('.ee-compose-linkbar'),
|
|
4524
|
+
chips: dialog.querySelector('.ee-compose-chips'),
|
|
4525
|
+
fileInput: dialog.querySelector('.ee-compose-file-input'),
|
|
4526
|
+
quote: dialog.querySelector('.ee-compose-quote'),
|
|
4527
|
+
error: dialog.querySelector('.ee-compose-error'),
|
|
4528
|
+
sendButton: dialog.querySelector('.ee-compose-send'),
|
|
4529
|
+
saveDraftButton: dialog.querySelector('.ee-compose-save-draft'),
|
|
4530
|
+
minimizeButton: dialog.querySelector('[data-action="minimize"]')
|
|
3532
4531
|
};
|
|
3533
|
-
|
|
3534
|
-
this.
|
|
4532
|
+
this._compose = { els };
|
|
4533
|
+
this._resetCompose();
|
|
3535
4534
|
|
|
3536
4535
|
this.container
|
|
3537
4536
|
.querySelectorAll('.ee-compose-button, .ee-sidebar-compose-button')
|
|
3538
|
-
.forEach(button => button.addEventListener('click', () => this.compose()));
|
|
4537
|
+
.forEach(button => button.addEventListener('click', () => this._composeFailSafe(this.compose())));
|
|
4538
|
+
|
|
4539
|
+
this._bindComposeWindow(els);
|
|
4540
|
+
this._bindComposeEditor(els);
|
|
4541
|
+
this._bindComposeFields(els);
|
|
4542
|
+
}
|
|
3539
4543
|
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
4544
|
+
// A compose action started from a click has no caller to report to
|
|
4545
|
+
_composeFailSafe(promise) {
|
|
4546
|
+
return promise.catch(error => this._alertActionFailed(error, 'Something went wrong in the compose form'));
|
|
4547
|
+
}
|
|
3543
4548
|
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
4549
|
+
// Close, discard, minimize, and the keys that work anywhere in the form
|
|
4550
|
+
_bindComposeWindow(els) {
|
|
4551
|
+
const { dialog, linkbar } = els;
|
|
4552
|
+
dialog.querySelector('[data-action="close"]').addEventListener('click', () => this._composeFailSafe(this._requestCloseCompose()));
|
|
4553
|
+
dialog.querySelector('[data-action="discard"]').addEventListener('click', () => this._composeFailSafe(this._discardCompose()));
|
|
4554
|
+
els.minimizeButton.addEventListener('click', () => this._setComposeMinimized(!dialog.classList.contains('minimized')));
|
|
4555
|
+
// A minimized form comes back with a click on its title bar
|
|
4556
|
+
dialog.querySelector('.ee-compose-header').addEventListener('click', e => {
|
|
4557
|
+
if (dialog.classList.contains('minimized') && !e.target.closest('button')) {
|
|
4558
|
+
this._setComposeMinimized(false);
|
|
3548
4559
|
}
|
|
3549
4560
|
});
|
|
3550
4561
|
|
|
3551
|
-
//
|
|
4562
|
+
// Keys work while focus is in the form: Escape closes it (or the link field), Ctrl+Enter sends
|
|
3552
4563
|
this._composeKeydownHandler = e => {
|
|
3553
|
-
if (e.key === 'Escape'
|
|
3554
|
-
|
|
4564
|
+
if (e.key === 'Escape') {
|
|
4565
|
+
e.preventDefault();
|
|
4566
|
+
if (!linkbar.hidden) {
|
|
4567
|
+
this._closeLinkbar();
|
|
4568
|
+
} else {
|
|
4569
|
+
this._composeFailSafe(this._requestCloseCompose());
|
|
4570
|
+
}
|
|
4571
|
+
} else if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
|
4572
|
+
e.preventDefault();
|
|
4573
|
+
els.sendButton.click();
|
|
3555
4574
|
}
|
|
3556
4575
|
};
|
|
3557
|
-
|
|
4576
|
+
dialog.addEventListener('keydown', this._composeKeydownHandler);
|
|
4577
|
+
|
|
4578
|
+
els.saveDraftButton.addEventListener('click', () => this._composeFailSafe(this._saveComposeDraft()));
|
|
4579
|
+
els.sendButton.addEventListener('click', () => this._composeFailSafe(this._sendCompose()));
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
// The editor: typing state, paste and drop, the formatting toolbar and the link field
|
|
4583
|
+
_bindComposeEditor(els) {
|
|
4584
|
+
const { dialog, editor, toolbar, linkbar } = els;
|
|
4585
|
+
editor.addEventListener('input', () => this._updateEditorEmpty());
|
|
4586
|
+
editor.addEventListener('keyup', () => this._updateFormatButtons());
|
|
4587
|
+
editor.addEventListener('mouseup', () => this._updateFormatButtons());
|
|
4588
|
+
editor.addEventListener('paste', e => this._onEditorPaste(e));
|
|
4589
|
+
// Dropped files are attached; dropped markup would bypass the paste filter, so text only
|
|
4590
|
+
dialog.addEventListener('dragover', e => e.preventDefault());
|
|
4591
|
+
dialog.addEventListener('drop', e => {
|
|
4592
|
+
e.preventDefault();
|
|
4593
|
+
const files = e.dataTransfer && Array.from(e.dataTransfer.files || []);
|
|
4594
|
+
if (files && files.length) {
|
|
4595
|
+
this._addComposeFiles(files);
|
|
4596
|
+
} else if (e.dataTransfer && editor.contains(e.target)) {
|
|
4597
|
+
document.execCommand('insertText', false, e.dataTransfer.getData('text/plain'));
|
|
4598
|
+
}
|
|
4599
|
+
});
|
|
4600
|
+
|
|
4601
|
+
// keep the selection in the editor while a toolbar button is pressed
|
|
4602
|
+
toolbar.addEventListener('mousedown', e => {
|
|
4603
|
+
if (e.target.closest('.ee-compose-format')) {
|
|
4604
|
+
e.preventDefault();
|
|
4605
|
+
}
|
|
4606
|
+
});
|
|
4607
|
+
toolbar.addEventListener('click', e => {
|
|
4608
|
+
if (e.target.closest('[data-action="link"]')) {
|
|
4609
|
+
this._openLinkbar();
|
|
4610
|
+
return;
|
|
4611
|
+
}
|
|
4612
|
+
const button = e.target.closest('.ee-compose-format[data-command]');
|
|
4613
|
+
if (button) {
|
|
4614
|
+
editor.focus();
|
|
4615
|
+
document.execCommand(button.dataset.command, false, null);
|
|
4616
|
+
this._updateEditorEmpty();
|
|
4617
|
+
this._updateFormatButtons();
|
|
4618
|
+
}
|
|
4619
|
+
});
|
|
4620
|
+
linkbar.querySelector('[data-action="insert-link"]').addEventListener('click', () => this._insertLink());
|
|
4621
|
+
linkbar.querySelector('[data-action="cancel-link"]').addEventListener('click', () => this._closeLinkbar());
|
|
4622
|
+
linkbar.querySelector('[name="link"]').addEventListener('keydown', e => {
|
|
4623
|
+
if (e.key === 'Enter') {
|
|
4624
|
+
e.preventDefault();
|
|
4625
|
+
this._insertLink();
|
|
4626
|
+
}
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
3558
4629
|
|
|
4630
|
+
// The address fields, attachments and the quote toggle
|
|
4631
|
+
_bindComposeFields(els) {
|
|
4632
|
+
const { dialog, form, fileInput, chips, quote } = els;
|
|
4633
|
+
// the editor's input bubbles here too
|
|
3559
4634
|
form.addEventListener('input', () => {
|
|
3560
4635
|
if (!els.error.hidden) {
|
|
3561
4636
|
this._clearComposeError();
|
|
3562
4637
|
}
|
|
3563
4638
|
});
|
|
3564
4639
|
|
|
4640
|
+
quote.querySelector('.ee-compose-quote-toggle').addEventListener('click', e => {
|
|
4641
|
+
this._setQuoteExpanded(e.currentTarget.getAttribute('aria-expanded') !== 'true');
|
|
4642
|
+
});
|
|
4643
|
+
|
|
3565
4644
|
form.querySelector('[data-action="show-cc"]').addEventListener('click', () => {
|
|
3566
4645
|
const ccShown = !form.querySelector('[data-field="cc"]').hidden;
|
|
3567
4646
|
this._showCopyFields({ cc: true, bcc: true });
|
|
3568
4647
|
(ccShown ? form.elements.bcc : form.elements.cc).focus();
|
|
3569
4648
|
});
|
|
3570
4649
|
|
|
3571
|
-
|
|
4650
|
+
dialog.querySelector('[data-action="attach"]').addEventListener('click', () => fileInput.click());
|
|
3572
4651
|
fileInput.addEventListener('change', () => {
|
|
3573
4652
|
const files = Array.from(fileInput.files || []);
|
|
3574
4653
|
fileInput.value = '';
|
|
@@ -3581,40 +4660,6 @@ export class EmailEngineClient {
|
|
|
3581
4660
|
this._renderComposeChips();
|
|
3582
4661
|
}
|
|
3583
4662
|
});
|
|
3584
|
-
|
|
3585
|
-
// Save the composed message as a draft instead of sending it
|
|
3586
|
-
const saveDraftButton = modal.querySelector('.ee-compose-save-draft');
|
|
3587
|
-
saveDraftButton.addEventListener('click', async () => {
|
|
3588
|
-
const response = await this._runComposeAction(saveDraftButton, 'Saving...', 'Could not save the draft', false, (...args) =>
|
|
3589
|
-
this.saveDraft(...args)
|
|
3590
|
-
);
|
|
3591
|
-
if (!response) {
|
|
3592
|
-
return;
|
|
3593
|
-
}
|
|
3594
|
-
this.notify('Draft saved to the Drafts folder.');
|
|
3595
|
-
// Refresh the list when the user is looking at the Drafts folder
|
|
3596
|
-
if (!this._destroyed && response.path && this.currentFolder === response.path) {
|
|
3597
|
-
this._fireAndForget(this.loadMessages(this.currentFolder));
|
|
3598
|
-
}
|
|
3599
|
-
});
|
|
3600
|
-
|
|
3601
|
-
// Send email
|
|
3602
|
-
const sendButton = modal.querySelector('.ee-compose-send');
|
|
3603
|
-
sendButton.addEventListener('click', async () => {
|
|
3604
|
-
const response = await this._runComposeAction(sendButton, 'Sending...', 'Could not send the message', true, (...args) => this.sendMessage(...args));
|
|
3605
|
-
if (response) {
|
|
3606
|
-
// Submitting only queues the message; delivery happens afterwards and can still fail
|
|
3607
|
-
this.notify('Message queued for delivery.');
|
|
3608
|
-
}
|
|
3609
|
-
});
|
|
3610
|
-
|
|
3611
|
-
// Handle Enter key in form (Ctrl+Enter to send)
|
|
3612
|
-
form.addEventListener('keydown', e => {
|
|
3613
|
-
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
|
3614
|
-
e.preventDefault();
|
|
3615
|
-
sendButton.click();
|
|
3616
|
-
}
|
|
3617
|
-
});
|
|
3618
4663
|
}
|
|
3619
4664
|
|
|
3620
4665
|
positionComposeButton() {
|
|
@@ -3713,7 +4758,7 @@ export class EmailEngineClient {
|
|
|
3713
4758
|
init() {
|
|
3714
4759
|
if (typeof document === 'undefined') {
|
|
3715
4760
|
console.warn('EmailEngineClient UI features are only available in browser environments');
|
|
3716
|
-
return;
|
|
4761
|
+
return Promise.resolve(false);
|
|
3717
4762
|
}
|
|
3718
4763
|
|
|
3719
4764
|
this.createStyles();
|
|
@@ -3725,13 +4770,14 @@ export class EmailEngineClient {
|
|
|
3725
4770
|
toggleBtn.addEventListener('click', () => this.toggleDarkMode());
|
|
3726
4771
|
}
|
|
3727
4772
|
|
|
3728
|
-
this._loadInitialView();
|
|
4773
|
+
return this._loadInitialView();
|
|
3729
4774
|
}
|
|
3730
4775
|
|
|
3731
4776
|
// Load the folder list and open the account's inbox. Used on startup and by
|
|
3732
4777
|
// the Retry button that loadFolders renders when the request fails; both
|
|
3733
4778
|
// failure paths already put an error panel in the UI, so the rejection is
|
|
3734
4779
|
// logged and swallowed here rather than surfacing as an unhandled rejection.
|
|
4780
|
+
// Resolves whether the view loaded.
|
|
3735
4781
|
_loadInitialView() {
|
|
3736
4782
|
// Drop whatever a previous attempt left here; loadFolders and loadMessages
|
|
3737
4783
|
// paint their own loading states from this point on.
|
|
@@ -3752,10 +4798,14 @@ export class EmailEngineClient {
|
|
|
3752
4798
|
this._renderPaneError('.ee-message-list', 'Folders unavailable', error, () => this._loadInitialView());
|
|
3753
4799
|
throw error;
|
|
3754
4800
|
})
|
|
3755
|
-
.then(async () =>
|
|
4801
|
+
.then(async () => {
|
|
4802
|
+
await this._listFolderOf(await message);
|
|
4803
|
+
return true;
|
|
4804
|
+
})
|
|
3756
4805
|
.catch(error => {
|
|
3757
4806
|
// Both loadFolders and loadMessages have already rendered a panel
|
|
3758
4807
|
console.error('Failed to load the initial view:', error);
|
|
4808
|
+
return false;
|
|
3759
4809
|
});
|
|
3760
4810
|
}
|
|
3761
4811
|
|
|
@@ -3835,7 +4885,7 @@ export class EmailEngineClient {
|
|
|
3835
4885
|
// Update UI. The compose button and modal are siblings of .ee-client, so
|
|
3836
4886
|
// they carry the class themselves.
|
|
3837
4887
|
this.container
|
|
3838
|
-
.querySelectorAll('.ee-client, .ee-compose-button, .ee-compose
|
|
4888
|
+
.querySelectorAll('.ee-client, .ee-compose-button, .ee-compose, .ee-toast')
|
|
3839
4889
|
.forEach(el => el.classList.toggle('ee-dark-mode', this.darkMode));
|
|
3840
4890
|
|
|
3841
4891
|
// Update toggle button icon
|
|
@@ -3874,9 +4924,9 @@ export class EmailEngineClient {
|
|
|
3874
4924
|
this._composeButtonCleanup = null;
|
|
3875
4925
|
}
|
|
3876
4926
|
|
|
3877
|
-
//
|
|
3878
|
-
if (this._composeKeydownHandler &&
|
|
3879
|
-
|
|
4927
|
+
// The compose form's keys listen on the form itself
|
|
4928
|
+
if (this._composeKeydownHandler && this._compose && this._compose.els) {
|
|
4929
|
+
this._compose.els.dialog.removeEventListener('keydown', this._composeKeydownHandler);
|
|
3880
4930
|
this._composeKeydownHandler = null;
|
|
3881
4931
|
}
|
|
3882
4932
|
|