fix: persist htmlBody in drafts to preserve rich formatting #236
This commit is contained in:
@@ -744,7 +744,8 @@ export function EmailComposer({
|
|||||||
fromEmail,
|
fromEmail,
|
||||||
draftId || undefined,
|
draftId || undefined,
|
||||||
uploadedAttachments,
|
uploadedAttachments,
|
||||||
currentIdentity?.name || undefined
|
currentIdentity?.name || undefined,
|
||||||
|
plainTextMode ? undefined : body
|
||||||
);
|
);
|
||||||
|
|
||||||
setDraftId(savedDraftId);
|
setDraftId(savedDraftId);
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ export class DemoJMAPClient implements IJMAPClient {
|
|||||||
draftId?: string,
|
draftId?: string,
|
||||||
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
||||||
_fromName?: string,
|
_fromName?: string,
|
||||||
|
htmlBody?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const draftsMb = this.data.mailboxes.find(m => m.role === 'drafts');
|
const draftsMb = this.data.mailboxes.find(m => m.role === 'drafts');
|
||||||
const id = draftId || generateDemoId('email');
|
const id = draftId || generateDemoId('email');
|
||||||
@@ -402,9 +403,13 @@ export class DemoJMAPClient implements IJMAPClient {
|
|||||||
sentAt: new Date().toISOString(),
|
sentAt: new Date().toISOString(),
|
||||||
preview: body.substring(0, 200),
|
preview: body.substring(0, 200),
|
||||||
hasAttachment: !!attachments?.length,
|
hasAttachment: !!attachments?.length,
|
||||||
textBody: [{ partId: '1', blobId: generateDemoId('blob'), size: body.length, type: 'text/plain' }],
|
textBody: [{ partId: htmlBody ? 'text' : '1', blobId: generateDemoId('blob'), size: body.length, type: 'text/plain' }],
|
||||||
htmlBody: [],
|
htmlBody: htmlBody
|
||||||
bodyValues: { '1': { value: body } },
|
? [{ partId: 'html', blobId: generateDemoId('blob'), size: htmlBody.length, type: 'text/html' }]
|
||||||
|
: [],
|
||||||
|
bodyValues: htmlBody
|
||||||
|
? { text: { value: body }, html: { value: htmlBody } }
|
||||||
|
: { '1': { value: body } },
|
||||||
attachments: attachments?.map(a => ({ ...a, partId: generateDemoId('part') })),
|
attachments: attachments?.map(a => ({ ...a, partId: generateDemoId('part') })),
|
||||||
messageId: `<${id}@demo.example.com>`,
|
messageId: `<${id}@demo.example.com>`,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ export interface IJMAPClient {
|
|||||||
draftId?: string,
|
draftId?: string,
|
||||||
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
||||||
fromName?: string,
|
fromName?: string,
|
||||||
|
htmlBody?: string,
|
||||||
): Promise<string>;
|
): Promise<string>;
|
||||||
|
|
||||||
sendEmail(
|
sendEmail(
|
||||||
|
|||||||
+11
-4
@@ -1939,7 +1939,8 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
fromEmail?: string,
|
fromEmail?: string,
|
||||||
draftId?: string,
|
draftId?: string,
|
||||||
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
attachments?: Array<{ blobId: string; name: string; type: string; size: number; disposition?: 'attachment' | 'inline'; cid?: string }>,
|
||||||
fromName?: string
|
fromName?: string,
|
||||||
|
htmlBody?: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const mailboxes = await this.getMailboxes();
|
const mailboxes = await this.getMailboxes();
|
||||||
const draftsMailbox = mailboxes.find(mb => mb.role === 'drafts');
|
const draftsMailbox = mailboxes.find(mb => mb.role === 'drafts');
|
||||||
@@ -1958,7 +1959,8 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
keywords: Record<string, boolean>;
|
keywords: Record<string, boolean>;
|
||||||
mailboxIds: Record<string, boolean>;
|
mailboxIds: Record<string, boolean>;
|
||||||
bodyValues: Record<string, { value: string }>;
|
bodyValues: Record<string, { value: string }>;
|
||||||
textBody: { partId: string }[];
|
textBody: { partId: string; type?: string }[];
|
||||||
|
htmlBody?: { partId: string; type: string }[];
|
||||||
attachments?: { blobId: string; type: string; name: string; disposition: string; cid?: string }[];
|
attachments?: { blobId: string; type: string; name: string; disposition: string; cid?: string }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1970,8 +1972,13 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
subject,
|
subject,
|
||||||
keywords: { "$draft": true },
|
keywords: { "$draft": true },
|
||||||
mailboxIds: { [draftsMailbox.id]: true },
|
mailboxIds: { [draftsMailbox.id]: true },
|
||||||
bodyValues: { "1": { value: body } },
|
bodyValues: htmlBody
|
||||||
textBody: [{ partId: "1" }],
|
? { "text": { value: body }, "html": { value: htmlBody } }
|
||||||
|
: { "1": { value: body } },
|
||||||
|
textBody: htmlBody
|
||||||
|
? [{ partId: "text", type: "text/plain" }]
|
||||||
|
: [{ partId: "1" }],
|
||||||
|
...(htmlBody ? { htmlBody: [{ partId: "html", type: "text/html" }] } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (attachments?.length) {
|
if (attachments?.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user