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