From 95e0d1df0b7a563d3d3c7a6c64bdbd78e48383af Mon Sep 17 00:00:00 2001 From: abhinav7x94 <204053250+abhinav7x94@users.noreply.github.com> Date: Sun, 16 Aug 2026 03:43:34 +0530 Subject: [PATCH] fix(web): submit latest editor content on shortcut --- apps/web/components/add-document/note.tsx | 11 +- .../content/text-editor-content.tsx | 4 +- apps/web/components/document-modal/index.tsx | 27 ++-- apps/web/components/fullscreen-note-modal.tsx | 22 ++-- apps/web/components/quick-note-card.tsx | 22 ++-- apps/web/components/text-editor/index.test.ts | 116 ++++++++++++++++++ apps/web/components/text-editor/index.tsx | 64 ++++++++-- 7 files changed, 223 insertions(+), 43 deletions(-) create mode 100644 apps/web/components/text-editor/index.test.ts diff --git a/apps/web/components/add-document/note.tsx b/apps/web/components/add-document/note.tsx index ef462df4..98952449 100644 --- a/apps/web/components/add-document/note.tsx +++ b/apps/web/components/add-document/note.tsx @@ -5,7 +5,7 @@ import { LinkIcon } from "lucide-react" import { cn } from "@lib/utils" import { Button } from "@ui/components/button" import { dmSansClassName } from "@/lib/fonts" -import { TextEditor } from "../text-editor" +import { resolveSubmittedContent, TextEditor } from "../text-editor" import { extractUrls } from "@/lib/url-helpers" interface NoteContentProps { @@ -31,11 +31,10 @@ export function NoteContent({ const { urls: detectedUrls } = useMemo(() => extractUrls(content), [content]) const showBulkOffer = detectedUrls.length >= 2 && !dismissed - const canSubmit = content.trim().length > 0 && !isSubmitting - - const handleSubmit = () => { - if (canSubmit && onSubmit) { - onSubmit(content) + const handleSubmit = (submittedContent?: string) => { + const contentToSubmit = resolveSubmittedContent(submittedContent, content) + if (contentToSubmit.trim() && !isSubmitting && onSubmit) { + onSubmit(contentToSubmit) } } diff --git a/apps/web/components/document-modal/content/text-editor-content.tsx b/apps/web/components/document-modal/content/text-editor-content.tsx index 1e4c1d05..b5f51813 100644 --- a/apps/web/components/document-modal/content/text-editor-content.tsx +++ b/apps/web/components/document-modal/content/text-editor-content.tsx @@ -14,7 +14,7 @@ export interface TextEditorProps { hasUnsavedChanges: boolean isSaving: boolean onContentChange: (content: string) => void - onSave: () => void + onSave: (content?: string) => void onReset: () => void } @@ -60,7 +60,7 @@ export function TextEditorContent({