Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Feat(email-compose): New email compose design (#469)

dev-rb53f2b9dd6d0e
diff --git a/js/app/packages/block-channel/component/FormatRibbon.tsx b/js/app/packages/block-channel/component/FormatRibbon.tsx
index 4f8d538e24..e41a3ebf45 100644
--- a/js/app/packages/block-channel/component/FormatRibbon.tsx
+++ b/js/app/packages/block-channel/component/FormatRibbon.tsx
@@ -20,7 +20,7 @@ export type FormatRibbonProps = {
export function FormatRibbon(props: FormatRibbonProps) {
return (
- <div class="flex flex-row w-full gap-2 items-center p-2">
+ <div class="flex flex-row w-full gap-2 items-center p-2 -ml-3">
<ActionButton
tooltip="Bold"
shortcut="meta+b"
diff --git a/js/app/packages/block-email/component/Compose.tsx b/js/app/packages/block-email/component/Compose.tsx
index c586540cf8..647bc97b27 100644
--- a/js/app/packages/block-email/component/Compose.tsx
+++ b/js/app/packages/block-email/component/Compose.tsx
@@ -3,30 +3,53 @@ import {
SplitHeaderBadge,
StaticSplitLabel,
} from '@app/component/split-layout/components/SplitLabel';
+import { useSplitLayout } from '@app/component/split-layout/layout';
import { useHasPaidAccess } from '@core/auth';
+import { CircleSpinner } from '@core/component/CircleSpinner';
+import { ClippedPanel } from '@core/component/ClippedPanel';
import { RecipientSelector } from '@core/component/RecipientSelector';
import { TextButton } from '@core/component/TextButton';
+import { toast } from '@core/component/Toast/Toast';
import { usePaywallState } from '@core/constant/PaywallState';
-import { fileDrop } from '@core/directive/fileDrop';
import { useEmailLinks } from '@core/email-link';
import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';
-import { useDisplayName, type WithCustomUserInput } from '@core/user';
+import {
+ type ContactInfo,
+ useDisplayName,
+ type WithCustomUserInput,
+} from '@core/user';
import { isErr } from '@core/util/maybeResult';
import Caution from '@icon/regular/warning.svg';
import { emailClient } from '@service-email/client';
-import type { Link as EmailAccountLink } from '@service-email/generated/schemas';
+import type { SendMessageResponse } from '@service-email/generated/schemas';
+import { useMutation } from '@tanstack/solid-query';
import {
createMemo,
+ createResource,
createSignal,
Match,
- onMount,
Show,
+ Suspense,
Switch,
} from 'solid-js';
-import { createStore } from 'solid-js/store';
-import { ComposeEmailInput } from './ComposeEmailInput';
+import { ComposeEmailInput, type ComposeInputData } from './ComposeEmailInput';
+
+type EmailComposeErrors =
+ | 'no_recipient'
+ | 'no_message'
+ | 'no_subject'
+ | 'no_link'
+ | 'generic';
+type EmailComposeVariables = {
+ body: { text: string; html: string; raw: string; attachments?: [] };
+};
-false && fileDrop;
+class EmailComposeError {
+ constructor(
+ public type: EmailComposeErrors,
+ public message: string
+ ) {}
+}
export function EmailCompose() {
const hasPaidAccess = useHasPaidAccess();
@@ -34,12 +57,11 @@ export function EmailCompose() {
const [subject, setSubject] = createSignal<string>('');
- const [emailInputAttachmentsStore, setEmailInputAttachmentsStore] =
- createStore<Record<string, any[]>>({});
-
- const [link, setLink] = createSignal<EmailAccountLink | null>(null);
const [linkError, setLinkError] = createSignal<string | null>(null);
- onMount(async () => {
+
+ const hasLinkError = createMemo(() => linkError() != null);
+
+ const [link] = createResource(async () => {
const maybeLinks = await emailClient.getLinks();
if (isErr(maybeLinks)) {
setLinkError('Could not find linked email account.');
@@ -48,7 +70,7 @@ export function EmailCompose() {
const [, { links }] = maybeLinks;
const [link] = links;
if (link) {
- setLink(link);
+ return link;
} else {
setLinkError('Could not find linked email account.');
}
@@ -101,6 +123,91 @@ export function EmailCompose() {
}
});
+ const { replaceSplit } = useSplitLayout();
+
+ // TODO: We should handle these errors in a form not in the mutation
+ const sendEmailMutation = useMutation<
+ SendMessageResponse,
+ EmailComposeError | Error,
+ EmailComposeVariables
+ >(() => ({
+ async mutationFn(contents) {
+ const _link = link();
+
+ if (!selectedRecipients().length) {
+ const e = 'Please select at least one recipient';
+ throw new EmailComposeError('no_recipient', e);
+ }
+
+ if (!contents.body.raw.trim()) {
+ const e = 'Please enter a message';
+ throw new EmailComposeError('no_message', e);
+ }
+
+ if (!subject()?.trim()) {
+ const e = 'Please enter a subject';
+ throw new EmailComposeError('no_subject', e);
+ }
+ if (!_link) {
+ const e = 'Unable to find linked email account';
+ throw new EmailComposeError('no_link', e);
+ }
+
+ const result = await emailClient.sendMessage({
+ message: {
+ link_id: _link.id, // For new emails
+ to: convertToContactInfoArray(selectedRecipients()),
+ cc:
+ ccRecipients && ccRecipients.length > 0
+ ? convertToContactInfoArray(ccRecipients())
+ : [],
+ bcc:
+ bccRecipients && bccRecipients.length > 0
+ ? convertToContactInfoArray(bccRecipients())
+ : [],
+ subject: subject(),
+ body_text: contents.body.text,
+ body_html: contents.body.html,
+ body_macro: contents.body.raw,
+ attachments: [],
+ },
+ });
+
+ if (isErr(result)) {
+ const e = 'Failed to send email';
+ throw new EmailComposeError('generic', e);
+ }
+
+ return result[1];
+ },
+ mutationKey: ['compose-email'],
+ onError(error) {
+ if (error instanceof Error || error.type === 'generic') {
+ toast.failure(error instanceof Error ? error.message : error.message);
+ }
+ },
+ onSuccess(data) {
+ toast.success('Email sent');
+ if (data.message.thread_db_id) {
+ replaceSplit({ type: 'email', id: data.message.thread_db_id }, true);
+ }
+ },
+ }));
+
+ const onSubmit = (data: ComposeInputData) => {
+ sendEmailMutation.mutate(data);
+ };
+
+ const withMutationError = (type: EmailComposeErrors) => {
+ const error = sendEmailMutation.error;
+
+ if (!error || error instanceof Error) return;
+
+ if (error.type !== type) return;
+
+ return error;
+ };
+
return (
<>
<SplitHeaderLeft>
@@ -112,9 +219,9 @@ export function EmailCompose() {
]}
/>
</SplitHeaderLeft>
- <div class="relative flex flex-col w-full h-full panel">
+ <div class="relative flex flex-col w-full h-full panel min-h-0 overflow-hidden">
<Switch>
- <Match when={linkError()}>
+ <Match when={hasLinkError()}>
<div class="w-full bg-alert-bg border-b border-t border-alert/20 text-alert-ink p-2">
<div class="flex items-center justify-between gap-2">
<Caution class="size-4" />
@@ -147,134 +254,193 @@ export function EmailCompose() {
</div>
</Match>
</Switch>
+
<div
- class="pt-2 h-full w-full overflow-y-auto px-4 flex flex-col"
+ class="macro-message-width mx-auto w-full max-h-full my-12 overflow-hidden"
classList={{
- 'pointer-events-none opacity-50': Boolean(linkError()),
+ 'pointer-events-none opacity-50': hasLinkError(),
}}
>
- <div class="macro-message-width mx-auto pb-1 w-full">
- <div class="mb-4 mt-12 h-6 flex items-center justify-between">
- <Show when={link()}>
- {(link) => (
- <div class="text-xs text-ink-extra-muted/50">
- from {link().email_address}
- </div>
- )}
- </Show>
- <div class="flex gap-2">
- <Show when={!showCc()}>
- <button
- type="button"
- class="text-sm text-secondary-text hover:text-primary-text hover:bg-hover"
- onClick={() => setShowCc(true)}
- disabled={!!linkError()}
- >
- + Cc
- </button>
- </Show>
- <Show when={!showBcc()}>
- <button
- type="button"
- class="text-sm text-secondary-text hover:text-primary-text hover:bg-hover"
- onClick={() => setShowBcc(true)}
- disabled={!!linkError()}
+ <ClippedPanel tl tr>
+ <div
+ class="w-full p-4 bg-input max-h-full overflow-hidden flex flex-col min-h-0"
+ classList={{
+ 'pointer-events-none opacity-50': hasLinkError(),
+ }}
+ >
+ <div class="macro-message-width mx-auto pb-1 w-full h-max shrink-0">
+ <div class="mb-4 h-6 flex items-center justify-between">
+ <Suspense
+ fallback={
+ <div class="flex gap-1 items-center">
+ <CircleSpinner class="w-4 h-4 animate-spin" />
+ <span class="text-ink-extra-muted/50 text-xs">
+ Processing...
+ </span>
+ </div>
+ }
>
- + Bcc
- </button>
- </Show>
- </div>
- </div>
+ <Show when={link()}>
+ {(link) => (
+ <div class="text-xs text-ink-extra-muted/50">
+ from {link().email_address}
+ </div>
+ )}
+ </Show>
+ </Suspense>
+ <div class="flex gap-2 ml-auto">
+ <Show when={!showCc()}>
+ <button
+ type="button"
+ class="text-sm text-secondary-text hover:text-primary-text hover:bg-hover"
+ onClick={() => setShowCc(true)}
+ disabled={hasLinkError()}
+ >
+ + Cc
+ </button>
+ </Show>
+ <Show when={!showBcc()}>
+ <button
+ type="button"
+ class="text-sm text-secondary-text hover:text-primary-text hover:bg-hover"
+ onClick={() => setShowBcc(true)}
+ disabled={hasLinkError()}
+ >
+ + Bcc
+ </button>
+ </Show>
+ </div>
+ </div>
- <div class="flex items-center gap-2 focus-within:bracket-offset-2 border-edge-muted border-b">
- <div class="text-sm w-8 shrink-0 text-ink-placeholder/70">To</div>
- <div class="flex-1">
- <RecipientSelector<'user' | 'contact'>
- options={destinationOptions}
- selectedOptions={selectedRecipients}
- setSelectedOptions={setSelectedRecipients}
- placeholder="Macro users or email addresses"
- triedToSubmit={triedToSubmit}
- focusOnMount={!linkError()}
- hideBorder
- noBrackets
- />
- </div>
- </div>
+ <div class="flex flex-col gap-2">
+ <div class="flex items-center gap-2 border-b border-edge-muted focus-within:border-accent">
+ <div class="text-base w-4 shrink-0 text-ink-placeholder/70">
+ To
+ </div>
+ <div class="flex-1">
+ <RecipientSelector<'user' | 'contact'>
+ options={destinationOptions}
+ selectedOptions={selectedRecipients}
+ setSelectedOptions={setSelectedRecipients}
+ placeholder="Macro users or email addresses"
+ triedToSubmit={triedToSubmit}
+ focusOnMount={!hasLinkError()}
+ hideBorder
+ noBrackets
+ disabled={hasLinkError()}
+ />
+ </div>
+ <Show when={withMutationError('no_recipient')}>
+ {(err) => (
+ <div class="text-failure-ink text-sm mt-1">
+ {err().message}
+ </div>
+ )}
+ </Show>
+ </div>
- <Show when={showCc()}>
- <div class="flex items-center gap-2 focus-within:bracket-offset-2 border-edge-muted border-b">
- <div class="text-sm w-8 shrink-0 text-ink-placeholder/70">
- Cc
- </div>
- <div class="flex-1">
- <RecipientSelector<'user' | 'contact'>
- options={destinationOptions}
- selectedOptions={ccRecipients}
- setSelectedOptions={setCcRecipients}
- placeholder="Macro users or email addresses"
- triedToSubmit={triedToSubmit}
- hideBorder
- noBrackets
- />
- </div>
- </div>
- </Show>
+ <Show when={showCc()}>
+ <div class="flex items-center gap-2 border-b border-edge-muted focus-within:border-accent">
+ <div class="text-sm w-4 shrink-0 text-ink-placeholder/70">
+ Cc
+ </div>
+ <div class="flex-1">
+ <RecipientSelector<'user' | 'contact'>
+ options={destinationOptions}
+ selectedOptions={ccRecipients}
+ setSelectedOptions={setCcRecipients}
+ placeholder="Macro users or email addresses"
+ triedToSubmit={triedToSubmit}
+ hideBorder
+ noBrackets
+ disabled={hasLinkError()}
+ />
+ </div>
+ </div>
+ </Show>
- <Show when={showBcc()}>
- <div class="mb-2 flex items-center gap-2 border-edge-muted border-b focus-within:bracket-offset-2">
- <div class="text-sm w-8 shrink-0 text-ink-placeholder/70">
- Bcc
- </div>
- <div class="flex-1">
- <RecipientSelector<'user' | 'contact'>
- options={destinationOptions}
- selectedOptions={bccRecipients}
- setSelectedOptions={setBccRecipients}
- placeholder="Macro users or email addresses"
- triedToSubmit={triedToSubmit}
- hideBorder
- noBrackets
- />
+ <Show when={showBcc()}>
+ <div class="flex items-center gap-2 border-b border-edge-muted focus-within:border-accent">
+ <div class="text-sm w-4 shrink-0 text-ink-placeholder/70">
+ Bcc
+ </div>
+ <div class="flex-1">
+ <RecipientSelector<'user' | 'contact'>
+ options={destinationOptions}
+ selectedOptions={bccRecipients}
+ setSelectedOptions={setBccRecipients}
+ placeholder="Macro users or email addresses"
+ triedToSubmit={triedToSubmit}
+ hideBorder
+ noBrackets
+ disabled={hasLinkError()}
+ />
+ </div>
+ </div>
+ </Show>
+
+ <div class="w-full flex items-center gap-2 border-b border-edge-muted focus-within:border-accent py-2">
+ <div class="text-base shrink-0 text-ink-placeholder/70">
+ Subject
+ </div>
+
+ <div class="flex-1">
+ <input
+ type="text"
+ value={subject()}
+ placeholder="Subject"
+ class="w-full text-base resize-none placeholder:text-ink-placeholder p-1 ml-1"
+ onInput={(e) => {
+ setSubject(e.currentTarget.value);
+ }}
+ disabled={hasLinkError()}
+ />
+ </div>
+
+ <Show when={withMutationError('no_subject')}>
+ {(err) => (
+ <div class="text-failure-ink text-sm mt-1">
+ {err().message}
+ </div>
+ )}
+ </Show>
+ </div>
</div>
</div>
- </Show>
-
- <input
- type="text"
- value={subject()}
- placeholder="Subject"
- class="text-xl mt-4 font-medium mb-6 bg-transparent border-none outline-none w-full resize-none appearance-none focus:ring-0"
- style="box-shadow: none;"
- onInput={(e) => {
- setSubject(e.currentTarget.value);
- }}
- disabled={!!linkError()}
- />
- </div>
- <div
- class="shrink-0 w-full pb-2 grow"
- classList={{
- 'pointer-events-none opacity-50': Boolean(linkError()),
- }}
- >
- <div class="mx-auto w-full h-full macro-message-width">
- <ComposeEmailInput
- selectedRecipients={selectedRecipients}
- ccRecipients={ccRecipients}
- bccRecipients={bccRecipients}
- subject={subject}
- link={link()}
- inputAttachments={{
- store: emailInputAttachmentsStore,
- setStore: setEmailInputAttachmentsStore,
- key: 'draft',
+
+ <div
+ class="w-full h-full flex flex-col min-h-0 mt-4"
+ classList={{
+ 'pointer-events-none opacity-50': hasLinkError(),
}}
- />
+ >
+ <ComposeEmailInput
+ onSubmit={onSubmit}
+ isSubmitting={sendEmailMutation.isPending}
+ disabled={hasLinkError()}
+ />
+ <Show when={withMutationError('no_message')}>
+ {(err) => (
+ <div class="text-failure-ink text-sm mt-1">
+ {err().message}
+ </div>
+ )}
+ </Show>
+ </div>
</div>
- </div>
+ </ClippedPanel>
</div>
</div>
</>
);
}
+
+function convertToContactInfoArray(
+ recipients: WithCustomUserInput<'user' | 'contact'>[]
+): ContactInfo[] {
+ return recipients.map((recipient) => ({
+ email: recipient.data.email,
+ name:
+ 'name' in recipient.data ? recipient.data.name || undefined : undefined,
+ }));
+}
diff --git a/js/app/packages/block-email/component/ComposeEmailInput.tsx b/js/app/packages/block-email/component/ComposeEmailInput.tsx
index 9dbfd3732b..cb59b052b2 100644
--- a/js/app/packages/block-email/component/ComposeEmailInput.tsx
+++ b/js/app/packages/block-email/component/ComposeEmailInput.tsx
@@ -1,33 +1,18 @@
-import { useSplitLayout } from '@app/component/split-layout/layout';
import { useSplitPanel } from '@app/component/split-layout/layoutUtils';
-import { globalSplitManager } from '@app/signal/splitLayout';
import { FormatRibbon } from '@block-channel/component/FormatRibbon';
-import { BrightJoins } from '@core/component/BrightJoins';
import { FileDropOverlay } from '@core/component/FileDropOverlay';
import { IconButton } from '@core/component/IconButton';
import { MarkdownTextarea } from '@core/component/LexicalMarkdown/component/core/MarkdownTextarea';
-import { toast } from '@core/component/Toast/Toast';
import { fileDrop } from '@core/directive/fileDrop';
-import type { WithCustomUserInput } from '@core/user';
-import { isErr } from '@core/util/maybeResult';
-import Plus from '@icon/regular/plus.svg';
import TextAa from '@icon/regular/text-aa.svg';
import type { DocumentMentionInfo } from '@lexical-core';
import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';
import ArrowFatLineUp from '@phosphor-icons/core/fill/arrow-fat-line-up-fill.svg?component-solid';
-import { emailClient } from '@service-email/client';
-import type {
- ContactInfo,
- Link as EmailAccountLink,
- MessageToSend,
-} from '@service-email/generated/schemas';
+import PaperclipIcon from '@phosphor-icons/core/regular/paperclip.svg?component-solid';
import { useUserId } from '@service-gql/client';
import type { FileType } from '@service-storage/generated/schemas/fileType';
import type { Item } from '@service-storage/generated/schemas/item';
-import {
- defaultSelectionData,
- type SelectionData,
-} from 'core/component/LexicalMarkdown/plugins';
+import { defaultSelectionData } from 'core/component/LexicalMarkdown/plugins';
import {
NODE_TRANSFORM,
type NodeTransformType,
@@ -39,7 +24,6 @@ import {
type TextFormatType,
} from 'lexical';
import { createSignal, onMount, Show } from 'solid-js';
-import { createStore } from 'solid-js/store';
import { type FocusableElement, tabbable } from 'tabbable';
import { handleFileUpload } from '../util/handleFileUpload';
import { makeAttachmentPublic } from '../util/makeAttachmentPublic';
@@ -51,30 +35,30 @@ import { AttachMenu } from './AttachMenu';
false && fileDrop;
-export function ComposeEmailInput(props: {
- selectedRecipients: () => WithCustomUserInput<'user' | 'contact'>[];
- ccRecipients: () => WithCustomUserInput<'user' | 'contact'>[];
- bccRecipients: () => WithCustomUserInput<'user' | 'contact'>[];
- subject: () => string;
- link: EmailAccountLink | null;
- inputAttachments?: {
- store: Record<string, any[]>;
- setStore: any;
- key: string;
+export type ComposeInputData = {
+ body: {
+ text: string;
+ html: string;
+ raw: string;
};
-}) {
+};
+
+type ComposeEmailInputProps = {
+ onSubmit: (data: ComposeInputData) => void;
+ disabled?: boolean;
+ isSubmitting?: boolean;
+};
+
+export function ComposeEmailInput(props: ComposeEmailInputProps) {
const [editor, setEditor] = createSignal<LexicalEditor>();
+
const [isDragging, setIsDragging] = createSignal<boolean>();
const [isPendingUpload, setIsPendingUpload] = createSignal<boolean>(false);
+
const [showFormatRibbon, setShowFormatRibbon] = createSignal<boolean>(false);
- const [formatState] = createStore<SelectionData>(
- structuredClone(defaultSelectionData)
- );
const [attachMenuOpen, setAttachMenuOpen] = createSignal(false);
+
const [content, setContent] = createSignal('');
- const [error, setError] = createSignal(false);
- const [errorMsg, setErrorMsg] = createSignal('');
- const [sending, setSending] = createSignal(false);
const panel = useSplitPanel();
@@ -102,21 +86,6 @@ export function ComposeEmailInput(props: {
let bodyDiv!: HTMLDivElement;
let attachButtonRef!: HTMLDivElement;
- function failure(msg: string) {
- setError(true);
- setErrorMsg(msg);
- }
-
- const convertToContactInfoArray = (
- recipients: WithCustomUserInput<'user' | 'contact'>[]
- ): ContactInfo[] => {
- return recipients.map((recipient) => ({
- email: recipient.data.email,
- name:
- 'name' in recipient.data ? recipient.data.name || undefined : undefined,
- }));
- };
-
function onAttach(items: Item[]) {
const documentMentionItems = items.map((item) => ({
documentId: item.id,
@@ -140,93 +109,24 @@ export function ComposeEmailInput(props: {
console.log('ComposeEmailInput: Document attachments processed');
}
- const { replaceSplit } = useSplitLayout();
-
// Set up hotkey scope for the compose message component
const [attachComposeHotkeys, composeHotkeyScope] =
useHotkeyDOMScope('compose-message');
let composeContainerRef: HTMLDivElement | undefined;
async function handleSend() {
- if (sending()) return;
-
const prepared = prepareEmailBody(editor());
if (!prepared) return;
- setError(false);
- setSending(true);
-
- const toRecipients = props?.selectedRecipients?.();
- const ccRecipients = props?.ccRecipients?.();
- const bccRecipients = props?.bccRecipients?.();
- const subject = props?.subject?.();
const bodyMacro = content();
- try {
- if (!toRecipients || toRecipients.length === 0) {
- const e = 'Please select at least one recipient';
- failure(e);
- return;
- }
-
- if (!bodyMacro?.trim()) {
- const e = 'Please enter a message';
- failure(e);
- return;
- }
-
- if (!subject?.trim()) {
- const e = 'Please enter a subject';
- failure(e);
- return;
- }
- if (!props.link) {
- const e = 'Unable to find linked email account';
- failure(e);
- return;
- }
-
- const messageToSend: MessageToSend = {
- link_id: props.link.id, // For new emails
- to: convertToContactInfoArray(toRecipients),
- cc:
- ccRecipients && ccRecipients.length > 0
- ? convertToContactInfoArray(ccRecipients)
- : [],
- bcc:
- bccRecipients && bccRecipients.length > 0
- ? convertToContactInfoArray(bccRecipients)
- : [],
- subject: subject,
- body_text: prepared.bodyText,
- body_html: prepared.bodyHtml,
- body_macro: bodyMacro,
- attachments: [],
- };
-
- const result = await emailClient.sendMessage({
- message: messageToSend,
- });
-
- if (isErr(result)) {
- const e = 'Failed to send email';
- failure(e);
- return;
- }
- toast.success('Email sent');
-
- const [, { message }] = result;
-
- if (message.thread_db_id) {
- replaceSplit({ type: 'email', id: message.thread_db_id }, true);
- }
- globalSplitManager();
- } catch (error) {
- console.error('Failed to send email:', error);
- failure('Failed to send email');
- } finally {
- setSending(false);
- }
+ props.onSubmit({
+ body: {
+ text: prepared.bodyText,
+ html: prepared.bodyHtml,
+ raw: bodyMacro,
+ },
+ });
}
onMount(() => {
@@ -253,15 +153,23 @@ export function ComposeEmailInput(props: {
ref={(el) => {
composeContainerRef = el;
}}
- class="relative flex flex-col flex-1 items-center justify-between bg-input border-t border-x border-edge-muted rounded-t-[5px] -mb-[7px]"
+ class="relative flex flex-col flex-1 items-center justify-between min-h-0"
>
- <BrightJoins dots={[false, false, true, true]} />
- <Show when={error()}>
- <div class="text-failure-ink text-sm mt-1">{errorMsg()}</div>
- </Show>
- <div class="w-full h-full flex flex-col">
+ <div class="w-full h-full flex flex-col overflow-hidden min-h-0">
+ <Show when={showFormatRibbon()}>
+ <FormatRibbon
+ state={structuredClone(defaultSelectionData)}
+ inlineFormat={(format: TextFormatType) => {
+ editor()?.dispatchCommand(FORMAT_TEXT_COMMAND, format);
+ }}
+ nodeFormat={(transform: NodeTransformType) => {
+ editor()?.dispatchCommand(NODE_TRANSFORM, transform);
+ }}
+ />
+ </Show>
+
<div
- class="min-h-20 grow w-full h-full flex flex-col cursor-text placeholder:text-ink-placeholder placeholder:opacity-50 px-3 pt-2 sm:pb-4"
+ class="min-h-60 grow w-full h-full flex flex-col cursor-text placeholder:text-ink-placeholder placeholder:opacity-50 overflow-auto"
ref={bodyDiv}
onclick={() => {
editor()?.focus();
@@ -276,7 +184,6 @@ export function ComposeEmailInput(props: {
items.forEach((item) => {
makeAttachmentPublic(item.documentId);
});
- // scheduleDraftSave();
});
},
}}
@@ -287,7 +194,7 @@ export function ComposeEmailInput(props: {
<MarkdownTextarea
captureEditor={setEditor}
class="text-sm break-words text-ink"
- editable={() => true}
+ editable={() => !props.disabled}
placeholder="Use `@` to reference files"
onChange={setContent}
onFocusLeaveStart={(e) => {
@@ -298,76 +205,59 @@ export function ComposeEmailInput(props: {
e.preventDefault();
focusSibling('next');
}}
- // onDocumentMention={(item) => {
- // makeAttachmentPublic(item.id);
- // }}
- // onUserMention={handleUserMention}
portalScope="local"
- // formatState={formatState}
- // setFormatState={setFormatState}
/>
</div>
- <Show when={showFormatRibbon()}>
- <FormatRibbon
- state={formatState}
- inlineFormat={(format: TextFormatType) => {
- editor()?.dispatchCommand(FORMAT_TEXT_COMMAND, format);
- }}
- nodeFormat={(transform: NodeTransformType) => {
- editor()?.dispatchCommand(NODE_TRANSFORM, transform);
- }}
- />
- </Show>
- <div class="flex flex-row w-full h-8 justify-between items-center p-2 mb-2 space-x-2 allow-css-brackets">
- <div class="flex flex-row items-center gap-2">
- <div class="relative" ref={attachButtonRef}>
- <IconButton
- theme="base"
- icon={Plus}
- tooltip={{ label: 'Attach' }}
- onClick={() => setAttachMenuOpen(true)}
- />
- <AttachMenu
- open={attachMenuOpen()}
- close={() => setAttachMenuOpen(false)}
- anchorRef={attachButtonRef}
- containerRef={bodyDiv}
- onAttach={onAttach}
- onAttachDocuments={onAttachDocuments}
- setIsPending={setIsPendingUpload}
- />
- </div>
+ </div>
+ <div class="flex flex-row w-full h-8 justify-between items-center space-x-2 allow-css-brackets mt-2">
+ <div class="flex flex-row items-center gap-2">
+ <div class="relative" ref={attachButtonRef}>
<IconButton
theme="base"
- icon={TextAa}
- onclick={() => {
- setShowFormatRibbon(!showFormatRibbon());
- }}
+ icon={PaperclipIcon}
+ tooltip={{ label: 'Attach' }}
+ disabled={props.disabled}
+ onClick={() => setAttachMenuOpen(true)}
+ />
+ <AttachMenu
+ open={attachMenuOpen()}
+ close={() => setAttachMenuOpen(false)}
+ anchorRef={attachButtonRef}
+ containerRef={bodyDiv}
+ onAttach={onAttach}
+ onAttachDocuments={onAttachDocuments}
+ setIsPending={setIsPendingUpload}
/>
</div>
- <button
- disabled={isPendingUpload() || sending()}
- onClick={() => {
- handleSend();
+ <IconButton
+ theme="base"
+ icon={TextAa}
+ disabled={props.disabled}
+ onclick={() => {
+ setShowFormatRibbon(!showFormatRibbon());
}}
- class="text-ink-muted bg-transparent rounded-full hover:scale-110! transition ease-in-out delay-150 flex flex-col justify-center items-center"
- >
- <div class="bg-transparent rounded-full size-8 flex flex-row justify-center items-center">
- <Show
- when={!isPendingUpload() && !sending()}
- fallback={
- <Spinner class="w-5 h-5 animate-spin cursor-disabled" />
- }
- >
- <ArrowFatLineUp
- width={20}
- height={20}
- class="!text-accent-ink !fill-accent"
- />
- </Show>
- </div>
- </button>
+ />
</div>
+ <button
+ type="button"
+ disabled={isPendingUpload() || props.isSubmitting || props.disabled}
+ onClick={() => {
+ handleSend();
+ }}
+ class="text-ink-muted focus:scale-110 hover:scale-110 transition ease-in-out delay-150 flex gap-2 justify-center items-center hover:bg-hover py-1 px-2 text-sm"
+ >
+ <Show
+ when={!isPendingUpload() && !props.isSubmitting}
+ fallback={<Spinner class="w-5 h-5 animate-spin cursor-disabled" />}
+ >
+ <span class="font-medium font-mono uppercase">Send</span>
+ <ArrowFatLineUp
+ width={20}
+ height={20}
+ class="text-accent-ink fill-accent rotate-90"
+ />
+ </Show>
+ </button>
</div>
</div>
);
diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsx
index 66260b0e4d..7f555910e6 100644
--- a/js/app/packages/core/component/RecipientSelector.tsx
+++ b/js/app/packages/core/component/RecipientSelector.tsx
@@ -217,6 +217,7 @@ type RecipientSelectorProps<K extends CombinedRecipientKind> = {
noPadding?: boolean;
noBrackets?: boolean;
includeSelf?: boolean;
+ disabled?: boolean;
};
export function RecipientSelector<K extends CombinedRecipientKind>(
@@ -313,7 +314,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
if (o.kind === 'custom') {
return o.data.invalid === false;
}
- return true;
+ return false;
}) as WithCustomUserInput<K>[]
);
props.setSelectedOptions(value as CombinedRecipientItem<K>[]);
@@ -389,6 +390,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
closeOnSelection={true}
open={isOpen()}
onOpenChange={setIsOpen}
+ disabled={props.disabled}
validationState={invalid() ? 'invalid' : 'valid'}
options={options() as CombinedRecipientItem[]}
optionLabel={getRecipientOptionLabel}