1import type { PreviewAnnotationSubmission } from "@t3tools/contracts";
2
3interface AnnotationKeyboardEvent {
4 readonly key: string;
5 readonly metaKey: boolean;
6 readonly ctrlKey: boolean;
7 readonly shiftKey: boolean;
8 readonly isComposing: boolean;
9}
10
11export function resolveAnnotationSubmission(
12 event: AnnotationKeyboardEvent,
13 canSend: boolean,
14): PreviewAnnotationSubmission | null {
15 if (event.key !== "Enter" || event.shiftKey || event.isComposing) return null;
16 return event.metaKey || event.ctrlKey ? (canSend ? "send" : null) : "attach";
17}